pyGHDL.dom._Translate

This module offers helper functions to translate often used IIR substructures to pyGHDL.dom (pyVHDLModel) constructs.

Functions


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 Prefix property.

Parameters:

node (TypeVar(Iir, bound= c_int)) – The name IIR node to translate.

Return type:

Name

Returns:

A name object.

pyGHDL.dom._Translate.GetArrayConstraintsFromSubtypeIndication(subtypeIndication)[source]
Return type:

List

Parameters:

subtypeIndication (Iir)

pyGHDL.dom._Translate.GetRecordConstraintsFromSubtypeIndication(subtypeIndication)[source]
Return type:

Dict

Parameters:

subtypeIndication (Iir)

pyGHDL.dom._Translate.GetTypeFromNode(node)[source]
Return type:

BaseType

Parameters:

node (Iir)

pyGHDL.dom._Translate.GetAnonymousTypeFromNode(node)[source]
Return type:

BaseType

Parameters:

node (Iir)

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:

Symbol

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:

Symbol

Returns:

A symbol representing a reference to a type/subtype and possible array or record constraints.

pyGHDL.dom._Translate.GetSimpleTypeFromNode(subtypeIndicationNode)[source]
Return type:

SimpleSubtypeSymbol

Parameters:

subtypeIndicationNode (Iir)

pyGHDL.dom._Translate.GetScalarConstrainedSubtypeFromNode(subtypeIndicationNode)[source]

Translate a scalar subtype indication IIR node to a subtype symbol.

A Subtype_Definition node 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 a SimpleSubtypeSymbol; with one it is a ConstrainedScalarSubtypeSymbol, whose constraint is mandatory.

Parameters:

subtypeIndicationNode (TypeVar(Iir, bound= c_int)) – The subtype indication IIR node.

Return type:

SimpleSubtypeSymbol | ConstrainedScalarSubtypeSymbol

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:

ConstrainedArraySubtypeSymbol

Parameters:

subtypeIndicationNode (Iir)

pyGHDL.dom._Translate.GetRecordConstrainedSubtypeFromNode(subtypeIndicationNode)[source]
Return type:

ConstrainedRecordSubtypeSymbol

Parameters:

subtypeIndicationNode (Iir)

pyGHDL.dom._Translate.GetSubtypeFromNode(subtypeNode)[source]
Return type:

Symbol

Parameters:

subtypeNode (Iir)

pyGHDL.dom._Translate.GetRangeFromNode(node)[source]

Translate a range IIR node to a SimpleRange.

Parameters:

node (TypeVar(Iir, bound= c_int)) – The IIR node representing a range.

Return type:

SimpleRange

Returns:

The translated range object.

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 a RangeFromName wrapping the referenced symbol.

Shared by for ... loop statements, for ... generate statements and aggregate choices, which all use the same VHDL discrete_range grammar rule.

Parameters:
  • discreteRangeNode (TypeVar(Iir, bound= c_int)) – The IIR node representing a discrete range.

  • entity (str) – The construct the discrete range appears in (e.g. for...loop). Used in exception messages.

Return type:

Range

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.

Parameters:

node (TypeVar(Iir, bound= c_int)) – The IIR node representing an expression.

Return type:

BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Returns:

The translated expression.

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:

Generator[ModeViewElement, None, None]

Returns:

A generator returning mode view elements.

Note

Unlike declarations/interface items (where the last node in a Has_Identifier_List group 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 real Mode/ Mode_View_Name - subsequent nodes only contribute their identifier, ending with the node where Has_Identifier_List becomes False. Verified against real GHDL analysis for x, y : out;: x has Has_Identifier_List=True, Mode=out; y has Has_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.

Parameters:

nodeChain (TypeVar(Iir, bound= c_int)) – The IIR node representing the first generic in the chain.

Return type:

Generator[GenericInterfaceItemMixin, None, None]

Returns:

A generator returning generic interface items.

pyGHDL.dom._Translate.GetPortsFromChainedNodes(nodeChain)[source]

Translates a chain of ports (IIR nodes) to a sequence of pyVHDLModel.Interface.PortInterfaceItem.

Parameters:

nodeChain (TypeVar(Iir, bound= c_int)) – The IIR node representing the first port in the chain.

Return type:

Generator[PortInterfaceItemMixin, None, None]

Returns:

A generator returning port interface items.

pyGHDL.dom._Translate.GetParameterFromChainedNodes(nodeChain)[source]

Translates a chain of parameters (IIR nodes) to a sequence of pyVHDLModel.Interface.ParameterInterfaceItem.

Parameters:

nodeChain (TypeVar(Iir, bound= c_int)) – The IIR node representing the first parameter in the chain.

Return type:

Generator[ParameterInterfaceItemMixin, None, None]

Returns:

A generator returning parameter interface items.