pyGHDL.dom._Translate
This module offers helper functions to translate often used IIR substructures to pyGHDL.dom (pyVHDLModel) constructs.
Functions
GetArrayConstraintsFromSubtypeIndication(): Undocumented.GetRecordConstraintsFromSubtypeIndication(): Undocumented.GetTypeFromNode(): Undocumented.GetAnonymousTypeFromNode(): Undocumented.GetSubtypeIndicationFromNode(): Extracts the subtype indication from an IIR node and translates it to aSymbol.GetSubtypeIndicationFromIndicationNode(): Translate a subtype indication to aSymbol.GetSimpleTypeFromNode(): Undocumented.GetScalarConstrainedSubtypeFromNode(): Translate a scalar subtype indication IIR node to a subtype symbol.GetArrayConstrainedSubtypeFromNode(): Undocumented.GetRecordConstrainedSubtypeFromNode(): Undocumented.GetSubtypeFromNode(): Undocumented.GetRangeFromNode(): Translate a range IIR node to aSimpleRange.GetDiscreteRangeFromNode(): Translate a discrete range IIR node to aRange.GetExpressionFromNode(): Translates an expression IIR node to anBaseExpression.GetModeViewElementsFromChainedNodes(): Translates a chain of mode view elements (IIR nodes) to a sequence ofGetGenericsFromChainedNodes(): Translates a chain of generics (IIR nodes) to a sequence ofpyVHDLModel.Interface.GenericInterfaceItem.GetPortsFromChainedNodes(): Translates a chain of ports (IIR nodes) to a sequence ofpyVHDLModel.Interface.PortInterfaceItem.GetParameterFromChainedNodes(): Translates a chain of parameters (IIR nodes) to a sequence ofpyVHDLModel.Interface.ParameterInterfaceItem.
Functions
- pyGHDL.dom._Translate.GetName(node)[source]
Translates a name IIR node to a
Name.A name can be a simple name or complex name consisting of selected, parenthesis, attribute, … names. Complex names are composed as a chain of name objects, which can be traversed using the
Prefixproperty.
- pyGHDL.dom._Translate.GetSubtypeIndicationFromNode(node, entity, name)[source]
Extracts the subtype indication from an IIR node and translates it to a
Symbol.Note
This function calls
GetSubtypeIndicationFromIndicationNode().This function should be used directly if
nodes.Get_Subtype_Indication(...)was already called or a subtype indication is return by another getter.- Parameters:
node (
TypeVar(Iir, bound=c_int)) – The IIR node to get the subtype indication from.entity (
str) – The entity kind the subtype indication is extracted from (e.g.constant). Used in exception messages.name (
str) – The entity’s name the subtype indication is extracted from (e.g.BITS). Used in exception messages.
- Return type:
- Returns:
A symbol representing a reference to a type/subtype and possible array or record constraints.
- pyGHDL.dom._Translate.GetSubtypeIndicationFromIndicationNode(subtypeIndicationNode, entity, name)[source]
Translate a subtype indication to a
Symbol.- Parameters:
subtypeIndicationNode (
TypeVar(Iir, bound=c_int)) – The subtype indication IIR node.entity (
str) – The entity kind the subtype indication is extracted from (e.g.constant). Used in exception messages.name (
str) – The entity’s name the subtype indication is extracted from (e.g.BITS). Used in exception messages.
- Return type:
- Returns:
A symbol representing a reference to a type/subtype and possible array or record constraints.
- pyGHDL.dom._Translate.GetSimpleTypeFromNode(subtypeIndicationNode)[source]
- Return type:
- Parameters:
subtypeIndicationNode (Iir)
- pyGHDL.dom._Translate.GetScalarConstrainedSubtypeFromNode(subtypeIndicationNode)[source]
Translate a scalar subtype indication IIR node to a subtype symbol.
A
Subtype_Definitionnode carries a type mark and optionally a range constraint, because the node is also used for a subtype indication that only adds a resolution indication (subtype resolvedBit is resolveBit myBit;). Without a range constraint the result is aSimpleSubtypeSymbol; with one it is aConstrainedScalarSubtypeSymbol, whose constraint is mandatory.- Parameters:
subtypeIndicationNode (
TypeVar(Iir, bound=c_int)) – The subtype indication IIR node.- Return type:
- Returns:
The translated subtype symbol.
- Raises:
DOMException – If the range constraint’s IIR node isn’t a known range.
- pyGHDL.dom._Translate.GetArrayConstrainedSubtypeFromNode(subtypeIndicationNode)[source]
- Return type:
- Parameters:
subtypeIndicationNode (Iir)
- pyGHDL.dom._Translate.GetRecordConstrainedSubtypeFromNode(subtypeIndicationNode)[source]
- Return type:
- Parameters:
subtypeIndicationNode (Iir)
- pyGHDL.dom._Translate.GetRangeFromNode(node)[source]
Translate a range IIR node to a
SimpleRange.
- pyGHDL.dom._Translate.GetDiscreteRangeFromNode(discreteRangeNode, entity)[source]
Translate a discrete range IIR node to a
Range.A discrete range is either an explicit range (
0 to 7,vector'range) or a discrete subtype indication - a type mark (bit), optionally with a range constraint (integer range 0 to 7). Everything but the explicit-bounds form becomes aRangeFromNamewrapping the referenced symbol.Shared by
for ... loopstatements,for ... generatestatements and aggregate choices, which all use the same VHDLdiscrete_rangegrammar rule.- Parameters:
- Return type:
- Returns:
The translated range.
- Raises:
DOMException – If the IIR node’s kind isn’t a known discrete range.
- pyGHDL.dom._Translate.GetExpressionFromNode(node)[source]
Translates an expression IIR node to an
BaseExpression.
- pyGHDL.dom._Translate.GetModeViewElementsFromChainedNodes(nodeChain)[source]
Translates a chain of mode view elements (IIR nodes) to a sequence of
pyVHDLModel.Interface.ModeViewElement.- Parameters:
nodeChain (
TypeVar(Iir, bound=c_int)) – The IIR node representing the first mode view element in the chain.- Return type:
- Returns:
A generator returning mode view elements.
Note
Unlike declarations/interface items (where the last node in a
Has_Identifier_Listgroup owns the shared subtype/value and earlier ones are Null), mode view elements are the other way around: the first node in the group (Has_Identifier_List == True) owns the realMode/Mode_View_Name- subsequent nodes only contribute their identifier, ending with the node whereHas_Identifier_ListbecomesFalse. Verified against real GHDL analysis forx, y : out;:xhasHas_Identifier_List=True,Mode=out;yhasHas_Identifier_List=False,Mode=<unset>.
- pyGHDL.dom._Translate.GetGenericsFromChainedNodes(nodeChain)[source]
Translates a chain of generics (IIR nodes) to a sequence of
pyVHDLModel.Interface.GenericInterfaceItem.
- pyGHDL.dom._Translate.GetPortsFromChainedNodes(nodeChain)[source]
Translates a chain of ports (IIR nodes) to a sequence of
pyVHDLModel.Interface.PortInterfaceItem.