pyGHDL.dom.Aggregates

This module contains all DOM classes for VHDL’s design units (context, architecture, package, package body, context and configuration.

Classes


Classes

class pyGHDL.dom.Aggregates.SimpleAggregateElement(node, expression)[source]

Represents an aggregate element given by position.

A positional element has no choice of its own; only its value (Expression).

Example

res := ('1', '0', '1', '0', '1', '0', '1', '0');
--      ^^^                                        <- Expression

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.SimpleAggregateElement.

Inheritance

Inheritance diagram of SimpleAggregateElement

Parameters:
__init__(node, expression)[source]

Initializes a simple aggregate element.

Parameters:
  • node (TypeVar(Iir, bound= c_int)) – The IIR node this object was translated from.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this aggregate element supplies.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

The IIR node’s position in the source file, resolved on first access and then cached.

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

VHDLModelException – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__str__()[source]

Formats the simple aggregate element.

Format: val

Return type:

str

Returns:

Formatted simple aggregate element.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this aggregate element supplies.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Aggregates.IndexedAggregateElement(node, index, expression)[source]

Represents an aggregate element chosen by an index.

The index is available as Index, the assigned value as Expression.

Example

res := (0 => '1', others => '0');
--      ^                           <- Index
--           ^^^                    <- Expression

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.IndexedAggregateElement.

Inheritance

Inheritance diagram of IndexedAggregateElement

Parameters:
__init__(node, index, expression)[source]

Initializes an aggregate element chosen by an index.

Parameters:
  • node (TypeVar(Iir, bound= c_int)) – The IIR node this object was translated from.

  • index (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The index selecting the element this value is assigned to.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this aggregate element supplies.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

The IIR node’s position in the source file, resolved on first access and then cached.

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

VHDLModelException – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property Index: int

Read-only property to access the index (_index).

Returns:

The index.

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__str__()[source]

Formats the indexed aggregate element.

Format: 0 => val

Return type:

str

Returns:

Formatted indexed aggregate element.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this aggregate element supplies.

_index: int

The index selecting the element this value is assigned to.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Aggregates.RangedAggregateElement(node, rng, expression)[source]

Represents an aggregate element chosen by a range.

The range is available as Range, the assigned value as Expression.

Example

res := (1 to 3 => '0', others => '1');
--      ^^^^^^                           <- Range
--                ^^^                    <- Expression

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.RangedAggregateElement.

Inheritance

Inheritance diagram of RangedAggregateElement

Parameters:
__init__(node, rng, expression)[source]

Initializes an aggregate element chosen by a range.

Parameters:
  • node (TypeVar(Iir, bound= c_int)) – The IIR node this object was translated from.

  • rng (Range) – The range selecting the elements this value is assigned to.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this aggregate element supplies.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

The IIR node’s position in the source file, resolved on first access and then cached.

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

VHDLModelException – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property Range: <pyTooling.Decorators.readonly object at 0x7f3f461e7d50>

Read-only property to access the range (_range).

Returns:

The range.

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__str__()[source]

Formats the ranged aggregate element.

Format: 0 to 3 => val

Return type:

str

Returns:

Formatted ranged aggregate element.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this aggregate element supplies.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: <pyTooling.Decorators.readonly object at 0x7f3f461e7d50>

The range selecting the elements this value is assigned to.

class pyGHDL.dom.Aggregates.NamedAggregateElement(node, name, expression)[source]

Represents an aggregate element chosen by a name.

Used for record aggregates, where the choice names a record element (Name).

Example

r := (a => '1', b => '0');
--    ^                      <- Name
--         ^^^               <- Expression

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.NamedAggregateElement.

Inheritance

Inheritance diagram of NamedAggregateElement

Parameters:
__init__(node, name, expression)[source]

Initializes an aggregate element chosen by a name.

Parameters:
  • node (TypeVar(Iir, bound= c_int)) – The IIR node this object was translated from.

  • name (Symbol) – Reference to the name selecting the element this value is assigned to.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this aggregate element supplies.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

The IIR node’s position in the source file, resolved on first access and then cached.

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

VHDLModelException – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property Name: Symbol

Read-only property to access the name (_name).

Returns:

The name.

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__str__()[source]

Formats the named aggregate element.

Format: elem => val

Return type:

str

Returns:

Formatted named aggregate element.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this aggregate element supplies.

_name: Symbol

Reference to the name selecting the element this value is assigned to.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Aggregates.OthersAggregateElement(node, expression)[source]

Represents the others element of an aggregate.

It supplies the value (Expression) for every choice not named explicitly.

Example

res := (0 => '1', others => '0');
--                ^^^^^^            <- the choice
--                          ^^^     <- Expression

This class implements a pyGHDL.dom object derived from pyVHDLModel.Expression.OthersAggregateElement.

Inheritance

Inheritance diagram of OthersAggregateElement

Parameters:
__init__(node, expression)[source]

Initializes an others aggregate element.

Parameters:
  • node (TypeVar(Iir, bound= c_int)) – The IIR node this object was translated from.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this aggregate element supplies.

Return type:

None

_iirNode: Iir

The IIR node in libghdl’s tree this DOM object was translated from.

_position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

The IIR node’s position in the source file, resolved on first access and then cached.

property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

Read-only property to access the expression (_expression).

Returns:

The expression.

GetAncestor(type)

Return the closest ancestor of the given type found by walking the parent chain upwards.

Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.

Parameters:

type (Type) – Class (type) of the ancestor to find.

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

VHDLModelException – If the root of the model is reached without finding an ancestor of the requested type.

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

property Parent: ModelEntity

Property to access the model entity’s parent element reference in a logical hierarchy (_parent).

Returns:

Reference to the parent entity.

property Position: <pyTooling.Decorators.readonly object at 0x7f3f462456d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__str__()[source]

Formats the others aggregate element.

Format: others => val

Return type:

str

Returns:

Formatted others aggregate element.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this aggregate element supplies.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.