pyGHDL.dom.Concurrent

This module implements derived concurrent statement classes from pyVHDLModel.Concurrent.

Classes


Classes

class pyGHDL.dom.Concurrent.GenericAssociationItem(associationNode, formal, actual)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Association.GenericAssociationItem.

A base-class for all generic association items used in generic map aspects.

Inheritance

Inheritance diagram of GenericAssociationItem

Parameters:
  • associationNode (Iir)

  • formal (Symbol)

  • actual (ExpressionUnion)

__init__(associationNode, formal, actual)[source]

Initializes a generic association item.

Parameters:
  • associationNode (Iir) – The IIR node of the association element.

  • formal (Symbol) – Reference to the formal part, or None for a positional association.

  • actual (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The actual part of this association.

Return type:

None

_iirNode: Iir

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

_position: Position

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

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

Read-only property to access the actual (_actual).

Returns:

The actual.

Copy()

Create a copy of this association item.

The copy has no parent. Its formal and actual are copies of this item’s formal and actual.

Return type:

Self

Returns:

The new association item.

property Formal: Name | Symbol | None

Read-only property to access the formal (_formal).

Returns:

The formal, or None if not set.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)

Walk this association item, its formal and its actual with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the association item.

Format: formal => actual, or actual alone when positional

Return type:

str

Returns:

Formatted association item.

_actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The actual part of this association.

_formal: Name | Symbol | None

Reference to the formal part, or None for a positional association.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.PortAssociationItem(associationNode, formal, actual)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Association.PortAssociationItem.

A base-class for all port association items used in port map aspects.

Inheritance

Inheritance diagram of PortAssociationItem

Parameters:
  • associationNode (Iir)

  • formal (Symbol)

  • actual (ExpressionUnion)

__init__(associationNode, formal, actual)[source]

Initializes a port association item.

Parameters:
  • associationNode (Iir) – The IIR node of the association element.

  • formal (Symbol) – Reference to the formal part, or None for a positional association.

  • actual (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The actual part of this association.

Return type:

None

_iirNode: Iir

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

_position: Position

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

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

Read-only property to access the actual (_actual).

Returns:

The actual.

Copy()

Create a copy of this association item.

The copy has no parent. Its formal and actual are copies of this item’s formal and actual.

Return type:

Self

Returns:

The new association item.

property Formal: Name | Symbol | None

Read-only property to access the formal (_formal).

Returns:

The formal, or None if not set.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)

Walk this association item, its formal and its actual with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the association item.

Format: formal => actual, or actual alone when positional

Return type:

str

Returns:

Formatted association item.

_actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The actual part of this association.

_formal: Name | Symbol | None

Reference to the formal part, or None for a positional association.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.ParameterAssociationItem(associationNode, formal, actual)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Association.ParameterAssociationItem.

A base-class for all parameter association items used in parameter map aspects.

Inheritance

Inheritance diagram of ParameterAssociationItem

Parameters:
  • associationNode (Iir)

  • formal (Symbol)

  • actual (ExpressionUnion)

__init__(associationNode, formal, actual)[source]

Initializes a parameter association item.

Parameters:
  • associationNode (Iir) – The IIR node of the association element.

  • formal (Symbol) – Reference to the formal part, or None for a positional association.

  • actual (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The actual part of this association.

Return type:

None

_iirNode: Iir

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

_position: Position

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

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

Read-only property to access the actual (_actual).

Returns:

The actual.

Copy()

Create a copy of this association item.

The copy has no parent. Its formal and actual are copies of this item’s formal and actual.

Return type:

Self

Returns:

The new association item.

property Formal: Name | Symbol | None

Read-only property to access the formal (_formal).

Returns:

The formal, or None if not set.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)

Walk this association item, its formal and its actual with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()

Formats the association item.

Format: formal => actual, or actual alone when positional

Return type:

str

Returns:

Formatted association item.

_actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The actual part of this association.

_formal: Name | Symbol | None

Reference to the formal part, or None for a positional association.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.ComponentInstantiation(instantiationNode, label, componentSymbol, genericAssociationItems=None, portAssociationItems=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ComponentInstantiation.

Represents a component instantiation.

The instantiated component is available as Component, the associations as GenericAssociationItems and PortAssociationItems. The label is mandatory.

Example

  inst : component Counter;
--^^^^                        <- Label
--                 ^^^^^^^    <- Component

Inheritance

Inheritance diagram of ComponentInstantiation

Parameters:
  • instantiationNode (Iir)

  • label (str)

  • componentSymbol (ComponentInstantiationSymbol)

  • genericAssociationItems (Iterable[AssociationItem])

  • portAssociationItems (Iterable[AssociationItem])

__init__(instantiationNode, label, componentSymbol, genericAssociationItems=None, portAssociationItems=None)[source]

Initializes a component instantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • label (str) – The label of the component instantiation statement.

  • componentSymbol (ComponentInstantiationSymbol) – Reference to the instantiated component.

  • genericAssociationItems (Iterable[AssociationItem]) – Optional, list of all generic associations in the generic map aspect.

  • portAssociationItems (Iterable[AssociationItem]) – Optional, list of all port associations in the port map aspect.

Return type:

None

classmethod parse(instantiationNode, instantiatedUnit, label)[source]

Translates the IIR node of the instantiation statement to a ComponentInstantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • instantiatedUnit (Iir) – The IIR node of the instantiated unit.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated instantiation statement.

_iirNode: Iir

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

_position: Position

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

AddGenericAssociationItem(genericAssociationItem)

Add a generic association at the end of the generic map aspect.

The association’s parent is set to this language construct.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to add.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the generic map aspect has a named association.

Return type:

None

See also

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

AddPortAssociationItem(portAssociationItem)

Add a port association at the end of the port map aspect.

The association’s parent is set to this language construct.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to add.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the port map aspect has a named association.

Return type:

None

See also

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Component: ComponentInstantiationSymbol

Read-only property to access the component (_component).

Returns:

The component.

property GenericAssociationItems: list[GenericAssociationItem]

Read-only property to access the generic associations (_genericAssociationItems).

Returns:

List of generic association items.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

InsertGenericAssociationItem(index, genericAssociationItem)

Insert a generic association at a position of the generic map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of generic associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last generic association.

  • genericAssociationItem (GenericAssociationItem) – The generic association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

InsertPortAssociationItem(index, portAssociationItem)

Insert a port association at a position of the port map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the port map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of port associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last port association.

  • portAssociationItem (PortAssociationItem) – The port association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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 PortAssociationItems: list[PortAssociationItem]

Read-only property to access the port associations (_portAssociationItems).

Returns:

List of port association items.

property Position: Position

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.

RemoveGenericAssociationItem(genericAssociationItem)

Remove a generic association from the generic map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to remove.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemovePortAssociationItem(portAssociationItem)

Remove a port association from the port map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to remove.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • NotAChildError – If parameter ‘portAssociationItem’ is not a port association of this language construct.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

Visit(visitor)[source]

Walk this component instantiation, its component and its map aspects with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitGenericMapAspect(visitor)

Walk the generic map aspect, if there are generic associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitMapAspects(visitor)

Walk the generic map aspect and the port map aspect of this instantiation with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitPortMapAspect(visitor)

Walk the port map aspect, if there are port associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_component: ComponentInstantiationSymbol

Reference to the instantiated component.

_genericAssociationItems: list[GenericAssociationItem]

List of all generic associations.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_portAssociationItems: list[PortAssociationItem]

List of all port associations.

class pyGHDL.dom.Concurrent.EntityInstantiation(instantiationNode, label, entitySymbol, architectureSymbol=None, genericAssociationItems=None, portAssociationItems=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.EntityInstantiation.

Represents a direct entity instantiation.

The instantiated entity is available as Entity and the optionally selected architecture as Architecture. The label is mandatory.

Example

  inst : entity work.Counter(rtl);
--^^^^                               <- Label
--              ^^^^^^^^^^^^         <- Entity
--                           ^^^     <- optional Architecture

Inheritance

Inheritance diagram of EntityInstantiation

Parameters:
__init__(instantiationNode, label, entitySymbol, architectureSymbol=None, genericAssociationItems=None, portAssociationItems=None)[source]

Initializes a direct entity instantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • label (str) – The label of the entity instantiation statement.

  • entitySymbol (EntityInstantiationSymbol) – Reference to the directly instantiated entity.

  • architectureSymbol (ArchitectureSymbol) – Optional, reference to the selected architecture, if one was given.

  • genericAssociationItems (Iterable[AssociationItem]) – Optional, list of all generic associations in the generic map aspect.

  • portAssociationItems (Iterable[AssociationItem]) – Optional, list of all port associations in the port map aspect.

Return type:

None

classmethod parse(instantiationNode, instantiatedUnit, label)[source]

Translates the IIR node of the instantiation statement to an EntityInstantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • instantiatedUnit (Iir) – The IIR node of the instantiated unit.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated instantiation statement.

_iirNode: Iir

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

_position: Position

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

AddGenericAssociationItem(genericAssociationItem)

Add a generic association at the end of the generic map aspect.

The association’s parent is set to this language construct.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to add.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the generic map aspect has a named association.

Return type:

None

See also

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

AddPortAssociationItem(portAssociationItem)

Add a port association at the end of the port map aspect.

The association’s parent is set to this language construct.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to add.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the port map aspect has a named association.

Return type:

None

See also

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Architecture: ArchitectureSymbol

Read-only property to access the architecture (_architecture).

Returns:

The architecture.

property Entity: EntityInstantiationSymbol

Read-only property to access the entity (_entity).

Returns:

The entity.

property GenericAssociationItems: list[GenericAssociationItem]

Read-only property to access the generic associations (_genericAssociationItems).

Returns:

List of generic association items.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

InsertGenericAssociationItem(index, genericAssociationItem)

Insert a generic association at a position of the generic map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of generic associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last generic association.

  • genericAssociationItem (GenericAssociationItem) – The generic association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

InsertPortAssociationItem(index, portAssociationItem)

Insert a port association at a position of the port map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the port map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of port associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last port association.

  • portAssociationItem (PortAssociationItem) – The port association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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 PortAssociationItems: list[PortAssociationItem]

Read-only property to access the port associations (_portAssociationItems).

Returns:

List of port association items.

property Position: Position

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.

RemoveGenericAssociationItem(genericAssociationItem)

Remove a generic association from the generic map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to remove.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemovePortAssociationItem(portAssociationItem)

Remove a port association from the port map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to remove.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • NotAChildError – If parameter ‘portAssociationItem’ is not a port association of this language construct.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

Visit(visitor)[source]

Walk this entity instantiation, its entity, its architecture (if any) and its map aspects with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitGenericMapAspect(visitor)

Walk the generic map aspect, if there are generic associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitMapAspects(visitor)

Walk the generic map aspect and the port map aspect of this instantiation with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitPortMapAspect(visitor)

Walk the port map aspect, if there are port associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_architecture: ArchitectureSymbol

Reference to the selected architecture, if one was given.

_entity: EntityInstantiationSymbol

Reference to the directly instantiated entity.

_genericAssociationItems: list[GenericAssociationItem]

List of all generic associations.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_portAssociationItems: list[PortAssociationItem]

List of all port associations.

class pyGHDL.dom.Concurrent.ConfigurationInstantiation(instantiationNode, label, configurationSymbol, genericAssociationItems=None, portAssociationItems=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConfigurationInstantiation.

Represents a configuration instantiation.

The instantiated configuration is available as Configuration. The label is mandatory.

Example

  inst : configuration Counter;
--^^^^                            <- Label
--                     ^^^^^^^    <- Configuration

Inheritance

Inheritance diagram of ConfigurationInstantiation

Parameters:
  • instantiationNode (Iir)

  • label (str)

  • configurationSymbol (ConfigurationInstantiationSymbol)

  • genericAssociationItems (Iterable[AssociationItem])

  • portAssociationItems (Iterable[AssociationItem])

__init__(instantiationNode, label, configurationSymbol, genericAssociationItems=None, portAssociationItems=None)[source]

Initializes a configuration instantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • label (str) – The label of the configuration instantiation statement.

  • configurationSymbol (ConfigurationInstantiationSymbol) – Reference to the instantiated configuration.

  • genericAssociationItems (Iterable[AssociationItem]) – Optional, list of all generic associations in the generic map aspect.

  • portAssociationItems (Iterable[AssociationItem]) – Optional, list of all port associations in the port map aspect.

Return type:

None

classmethod parse(instantiationNode, instantiatedUnit, label)[source]

Translates the IIR node of the instantiation statement to a ConfigurationInstantiation.

Parameters:
  • instantiationNode (Iir) – The IIR node of the instantiation statement.

  • instantiatedUnit (Iir) – The IIR node of the instantiated unit.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated instantiation statement.

_iirNode: Iir

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

_position: Position

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

AddGenericAssociationItem(genericAssociationItem)

Add a generic association at the end of the generic map aspect.

The association’s parent is set to this language construct.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to add.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the generic map aspect has a named association.

Return type:

None

See also

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

AddPortAssociationItem(portAssociationItem)

Add a port association at the end of the port map aspect.

The association’s parent is set to this language construct.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to add.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the port map aspect has a named association.

Return type:

None

See also

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Configuration: ConfigurationInstantiationSymbol

Read-only property to access the configuration (_configuration).

Returns:

The configuration.

property GenericAssociationItems: list[GenericAssociationItem]

Read-only property to access the generic associations (_genericAssociationItems).

Returns:

List of generic association items.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

InsertGenericAssociationItem(index, genericAssociationItem)

Insert a generic association at a position of the generic map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of generic associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last generic association.

  • genericAssociationItem (GenericAssociationItem) – The generic association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

InsertPortAssociationItem(index, portAssociationItem)

Insert a port association at a position of the port map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the port map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of port associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last port association.

  • portAssociationItem (PortAssociationItem) – The port association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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 PortAssociationItems: list[PortAssociationItem]

Read-only property to access the port associations (_portAssociationItems).

Returns:

List of port association items.

property Position: Position

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.

RemoveGenericAssociationItem(genericAssociationItem)

Remove a generic association from the generic map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to remove.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemovePortAssociationItem(portAssociationItem)

Remove a port association from the port map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to remove.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • NotAChildError – If parameter ‘portAssociationItem’ is not a port association of this language construct.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

Visit(visitor)[source]

Walk this configuration instantiation, its configuration and its map aspects with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitGenericMapAspect(visitor)

Walk the generic map aspect, if there are generic associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitMapAspects(visitor)

Walk the generic map aspect and the port map aspect of this instantiation with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitPortMapAspect(visitor)

Walk the port map aspect, if there are port associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_configuration: ConfigurationInstantiationSymbol

Reference to the instantiated configuration.

_genericAssociationItems: list[GenericAssociationItem]

List of all generic associations.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_portAssociationItems: list[PortAssociationItem]

List of all port associations.

class pyGHDL.dom.Concurrent.ConcurrentBlockStatement(blockNode, label, genericItems=None, genericAssociationItems=None, portItems=None, portAssociationItems=None, declaredItems=None, statements=None, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentBlockStatement.

Represents a block statement.

A block groups concurrent statements (Statements) and may declare its own items (DeclaredItems). It always forms a hierarchy level; independently of that, it may also have a block header: a generic clause (GenericItems) with its generic map aspect (GenericAssociationItems), and a port clause (PortItems) with its port map aspect (PortAssociationItems).

Example

  blk : block
--^^^                              <- Label
    generic (G : positive := 1);
--          ^^^^^^^^^^^^^^^^^^     <- GenericItems
    generic map (G => 2);
--              ^^^^^^^^           <- GenericAssociationItems
    port (bp : in bit);
--        ^^^^^^^^^^^              <- PortItems
    port map (bp => clock);
--           ^^^^^^^^^^^^          <- PortAssociationItems
    signal inner : bit := '0';
--  ^^^^^^^^^^^^^^^^^^^^^^^^^^     <- DeclaredItems
  begin
    inner <= bp;
--  ^^^^^^^^^^^^                   <- Statements
  end block;

Inheritance

Inheritance diagram of ConcurrentBlockStatement

Parameters:
  • blockNode (Iir)

  • label (str)

  • genericItems (Iterable)

  • genericAssociationItems (Iterable)

  • portItems (Iterable)

  • portAssociationItems (Iterable)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • documentation (str)

__init__(blockNode, label, genericItems=None, genericAssociationItems=None, portItems=None, portAssociationItems=None, declaredItems=None, statements=None, documentation=None)[source]

Initializes a block statement.

Parameters:
  • blockNode (Iir) – The IIR node of the block statement.

  • label (str) – The label of the block statement.

  • genericItems (Iterable) – Optional, list of all generics, in declaration order.

  • genericAssociationItems (Iterable) – Optional, list of all generic associations in the generic map aspect.

  • portItems (Iterable) – Optional, list of all ports, in declaration order.

  • portAssociationItems (Iterable) – Optional, list of all port associations in the port map aspect.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • documentation (str) – Optional, the documentation comment associated with this statement.

Return type:

None

classmethod parse(blockNode, label)[source]

Translates the IIR node of the block statement to a ConcurrentBlockStatement.

Parameters:
  • blockNode (Iir) – The IIR node of the block statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated block statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddGenericAssociationItem(genericAssociationItem)

Add a generic association at the end of the generic map aspect.

The association’s parent is set to this language construct.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to add.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the generic map aspect has a named association.

Return type:

None

See also

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

AddGenericItem(genericItem)

Add a generic at the end of the generic clause.

The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.

Parameters:

genericItem (GenericInterfaceItemMixin) – The generic to add.

Raises:
  • ValueError – If parameter ‘genericItem’ is None.

  • TypeError – If parameter ‘genericItem’ is not of type GenericInterfaceItemMixin.

  • AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.

  • DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.

Return type:

None

See also

InsertGenericItem()

→ Insert a generic at a position of the generic clause.

RemoveGenericItem()

→ Remove a generic from the generic clause.

AddPortAssociationItem(portAssociationItem)

Add a port association at the end of the port map aspect.

The association’s parent is set to this language construct.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to add.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and the port map aspect has a named association.

Return type:

None

See also

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

AddPortItem(portItem)

Add a port at the end of the port clause.

The port’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.

Parameters:

portItem (PortSignalInterfaceItem) – The port to add.

Raises:
  • ValueError – If parameter ‘portItem’ is None.

  • TypeError – If parameter ‘portItem’ is not of type PortSignalInterfaceItem.

  • AlreadyInDesignError – If parameter ‘portItem’ already has a parent.

  • DuplicatePortError – If an existing declaration of the language construct shares an identifier with the port.

Return type:

None

See also

InsertPortItem()

→ Insert a port at a position of the port clause.

RemovePortItem()

→ Remove a port from the port clause.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Documentation: str | None

Read-only property to access the model entity’s documentation (_documentation).

Returns:

Associated documentation of a model entity.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

property GenericAssociationItems: list[GenericAssociationItem]

Read-only property to access the generic associations (_genericAssociationItems).

Returns:

List of generic association items.

property GenericCount: int

Read-only property to return the number of generics in _genericItems.

Returns:

The generic count.

property GenericItems: list[GenericInterfaceItemMixin]

Read-only property to access the generic items (_genericItems).

Returns:

List of generic items.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()[source]

A block’s ports share the declarative region of its declarative part.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertGenericAssociationItem(index, genericAssociationItem)

Insert a generic association at a position of the generic map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of generic associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last generic association.

  • genericAssociationItem (GenericAssociationItem) – The generic association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.

  • DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

RemoveGenericAssociationItem()

→ Remove a generic association from the generic map aspect.

InsertGenericItem(index, genericItem)

Insert a generic at a position of the generic clause.

The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.

Parameters:
Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘genericItem’ is None.

  • TypeError – If parameter ‘genericItem’ is not of type GenericInterfaceItemMixin.

  • AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.

  • DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.

Return type:

None

See also

AddGenericItem()

→ Add a generic at the end of the generic clause.

RemoveGenericItem()

→ Remove a generic from the generic clause.

MoveGenericItem()

→ Move a generic to a position of the generic clause.

InsertPortAssociationItem(index, portAssociationItem)

Insert a port association at a position of the port map aspect.

The association’s parent is set to this language construct.

A named association (formal => actual) can’t repeat the formal of another named association of the port map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of port associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last port association.

  • portAssociationItem (PortAssociationItem) – The port association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • AlreadyInDesignError – If parameter ‘portAssociationItem’ already has a parent.

  • DuplicatePortAssociationError – If the association is named, and another named association of the port map aspect has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

RemovePortAssociationItem()

→ Remove a port association from the port map aspect.

InsertPortItem(index, portItem)

Insert a port at a position of the port clause.

The port’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.

Parameters:
Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘portItem’ is None.

  • TypeError – If parameter ‘portItem’ is not of type PortSignalInterfaceItem.

  • AlreadyInDesignError – If parameter ‘portItem’ already has a parent.

  • DuplicatePortError – If an existing declaration of the language construct shares an identifier with the port.

Return type:

None

See also

AddPortItem()

→ Add a port at the end of the port clause.

RemovePortItem()

→ Remove a port from the port clause.

MovePortItem()

→ Move a port to a position of the port clause.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

IterateSingleGenericDeclarations(predicate=None)

Iterate all generics per declared identifier, in declaration order.

A generic constant yields one single declaration per identifier: generic (A, B : positive) yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.

Parameters:

predicate (Callable[[SingleGenericDeclarationMixin | GenericInterfaceItemMixin], bool] | None) – Optional, filter function to select the yielded generics. Default: all.

Return type:

Generator[SingleGenericDeclarationMixin | GenericInterfaceItemMixin]

Returns:

A generator to iterate all (selected) generics.

IterateSinglePortDeclarations(predicate=None)

Iterate all ports per declared identifier, in declaration order.

A port yields one single declaration per identifier: port (a, b : in bit) yields two.

Parameters:

predicate (Callable[[SinglePortDeclarationMixin], bool] | None) – Optional, filter function to select the yielded ports. Default: all.

Return type:

Generator[SinglePortDeclarationMixin]

Returns:

A generator to iterate all (selected) ports.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveGenericItem(genericItem, index)

Move a generic to a position of the generic clause.

The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.

Parameters:
  • genericItem (GenericInterfaceItemMixin) – The generic to move.

  • index (int) – Position of the generic after the move, from 0 (first) to GenericCount minus one (last). A negative index counts from the end, as for a list index: -1 moves the generic to the end.

Raises:
  • ValueError – If parameter ‘genericItem’ is None.

  • TypeError – If parameter ‘genericItem’ is not of type GenericInterfaceItemMixin.

  • NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

See also

InsertGenericItem()

→ Insert a generic at a position of the generic clause.

RemoveGenericItem()

→ Remove a generic from the generic clause.

MovePortItem(portItem, index)

Move a port to a position of the port clause.

The port stays a port of this language construct: only the order of the port clause changes.

Parameters:
  • portItem (PortSignalInterfaceItem) – The port to move.

  • index (int) – Position of the port after the move, from 0 (first) to PortCount minus one (last). A negative index counts from the end, as for a list index: -1 moves the port to the end.

Raises:
  • ValueError – If parameter ‘portItem’ is None.

  • TypeError – If parameter ‘portItem’ is not of type PortSignalInterfaceItem.

  • NotAChildError – If parameter ‘portItem’ is not a port of this language construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

InsertPortItem()

→ Insert a port at a position of the port clause.

RemovePortItem()

→ Remove a port from the port clause.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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 PortAssociationItems: list[PortAssociationItem]

Read-only property to access the port associations (_portAssociationItems).

Returns:

List of port association items.

property PortCount: int

Read-only property to return the number of ports in _portItems.

Returns:

The port count.

property PortItems: list[PortInterfaceItemMixin]

Read-only property to access the port items (_portItems).

Returns:

List of port items.

property Position: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveGenericAssociationItem(genericAssociationItem)

Remove a generic association from the generic map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

genericAssociationItem (GenericAssociationItem) – The generic association to remove.

Raises:
  • ValueError – If parameter ‘genericAssociationItem’ is None.

  • TypeError – If parameter ‘genericAssociationItem’ is not of type GenericAssociationItem.

  • NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.

Return type:

None

See also

AddGenericAssociationItem()

→ Add a generic association at the end of the generic map aspect.

InsertGenericAssociationItem()

→ Insert a generic association at a position of the generic map aspect.

RemoveGenericItem(genericItem)

Remove a generic from the generic clause.

The generic is detached: its parent is cleared and its identifiers are removed from the language construct’s namespace, if it has one. The generic itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

genericItem (GenericInterfaceItemMixin) – The generic to remove.

Raises:
  • ValueError – If parameter ‘genericItem’ is None.

  • TypeError – If parameter ‘genericItem’ is not of type GenericInterfaceItemMixin.

  • NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.

Return type:

None

See also

AddGenericItem()

→ Add a generic at the end of the generic clause.

InsertGenericItem()

→ Insert a generic at a position of the generic clause.

MoveGenericItem()

→ Move a generic to a position of the generic clause.

RemovePortAssociationItem(portAssociationItem)

Remove a port association from the port map aspect.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

portAssociationItem (PortAssociationItem) – The port association to remove.

Raises:
  • ValueError – If parameter ‘portAssociationItem’ is None.

  • TypeError – If parameter ‘portAssociationItem’ is not of type PortAssociationItem.

  • NotAChildError – If parameter ‘portAssociationItem’ is not a port association of this language construct.

Return type:

None

See also

AddPortAssociationItem()

→ Add a port association at the end of the port map aspect.

InsertPortAssociationItem()

→ Insert a port association at a position of the port map aspect.

RemovePortItem(portItem)

Remove a port from the port clause.

The port is detached: its parent is cleared and its identifiers are removed from the language construct’s namespace, if it has one. The port itself is unchanged and can be added to another language construct, or inserted at another position.

Parameters:

portItem (PortSignalInterfaceItem) – The port to remove.

Raises:
  • ValueError – If parameter ‘portItem’ is None.

  • TypeError – If parameter ‘portItem’ is not of type PortSignalInterfaceItem.

  • NotAChildError – If parameter ‘portItem’ is not a port of this language construct.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the port isn’t declared in it.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the port refers to another element, e.g. a duplicate declaration.

Return type:

None

See also

AddPortItem()

→ Add a port at the end of the port clause.

InsertPortItem()

→ Insert a port at a position of the port clause.

MovePortItem()

→ Move a port to a position of the port clause.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

SplitGenericItem(genericItem)

Split a generic with an identifier list into one generic per identifier.

The generic keeps its first identifier. For every other identifier, a new generic is created by its Copy() and inserted right after it, in list order; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.

Parameters:

genericItem (GenericInterfaceItemMixin) – The generic to split.

Return type:

tuple[GenericInterfaceItemMixin, ...]

Returns:

Tuple of generics, one per identifier in list order, starting with the split generic.

Raises:
  • ValueError – If parameter ‘genericItem’ is None.

  • TypeError – If parameter ‘genericItem’ is not of type GenericInterfaceItemMixin.

  • NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveGenericItem()

→ Remove a generic from the generic clause.

SplitPortItem(portItem)

Split a port with an identifier list into one port per identifier.

The port keeps its first identifier. For every other identifier, a new port is created by its Copy() and inserted right after it, in list order; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new ports. A port declaring one identifier is unchanged.

Parameters:

portItem (PortSignalInterfaceItem) – The port to split.

Return type:

tuple[PortSignalInterfaceItem, ...]

Returns:

Tuple of ports, one per identifier in list order, starting with the split port.

Raises:
  • ValueError – If parameter ‘portItem’ is None.

  • TypeError – If parameter ‘portItem’ is not of type PortSignalInterfaceItem.

  • NotAChildError – If parameter ‘portItem’ is not a port of this language construct.

  • NotInNamespaceError – If the namespace is indexed, and an identifier of the port refers to another element, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemovePortItem()

→ Remove a port from the port clause.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this block, its block header, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()[source]

Return all declarations of this block: its generics and ports share the declarative region.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the generics, the ports, then the declared items.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Block,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexGenericItems()

Add the generics to the host’s namespace; a generic subprogram is an overload.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexPortItems()

Add the ports to the host’s namespace.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitGenericClause(visitor)

Walk the generic clause, if there are generics, with a visitor.

The generics are separated by semicolons.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitGenericMapAspect(visitor)

Walk the generic map aspect, if there are generic associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitPortClause(visitor)

Walk the port clause, if there are ports, with a visitor.

The ports are separated by semicolons.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitPortMapAspect(visitor)

Walk the port map aspect, if there are port associations, with a visitor.

The associations are separated by commas.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_components

Dictionary of all components declared in this concurrent declaration region.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_documentation

The associated documentation of a model entity.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_genericAssociationItems

List of all generic associations.

_genericItems

List of all generics, in declaration order.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_label

The label of a model entity.

_namespace

The namespace of this concurrent declaration region.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent

Reference to a parent entity in the logical model hierarchy.

_portAssociationItems

List of all port associations.

_portItems

List of all ports, in declaration order.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.ProcessStatement(processNode, label=None, declaredItems=None, statements=None, sensitivityList=None, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ProcessStatement.

Represents a process statement.

A process declares its own items (DeclaredItems) and groups sequential statements (Statements). It may name a sensitivity list (SensitivityList).

Example

  proc : process (clock)
--^^^^                     <- optional Label
--                ^^^^^    <- optional SensitivityList
    variable v : bit;
--  ^^^^^^^^^^^^^^^^^      <- DeclaredItems
  begin
    v := '1';
--  ^^^^^^^^^              <- Statements
  end process;

Inheritance

Inheritance diagram of ProcessStatement

Parameters:
  • processNode (Iir)

  • label (str)

  • declaredItems (Iterable)

  • statements (Iterable[SequentialStatement])

  • sensitivityList (Iterable[Symbol])

  • documentation (str)

__init__(processNode, label=None, declaredItems=None, statements=None, sensitivityList=None, documentation=None)[source]

Initializes a process statement.

Parameters:
  • processNode (Iir) – The IIR node of the process statement.

  • label (str) – Optional, the label of the process statement, or None if it has none.

  • declaredItems (Iterable) – Optional, list of all declared items in this sequential declaration region.

  • statements (Iterable[SequentialStatement]) – Optional, list of all sequential statements in this construct.

  • sensitivityList (Iterable[Symbol]) – Optional, list of all signal names in the sensitivity list, or None if none was given.

  • documentation (str) – Optional, the documentation comment associated with this statement.

Return type:

None

classmethod parse(processNode, label, hasSensitivityList)[source]

Translates the IIR node of the process statement to a ProcessStatement.

Parameters:
  • processNode (Iir) – The IIR node of the process statement.

  • label (str) – The statement’s label, or None if it has none.

  • hasSensitivityList (bool) – True if the process was declared with a sensitivity list.

Return type:

Self

Returns:

The translated process statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a sequential statement at the end of this construct.

The statement’s parent is set to this construct.

Parameters:

statement (SequentialStatement) – The sequential statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

property Constants: dict[str, Constant]

Read-only property to access the declared constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Documentation: str | None

Read-only property to access the model entity’s documentation (_documentation).

Returns:

Associated documentation of a model entity.

property Files: dict[str, File]

Read-only property to access the declared files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the declared functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the sequential declaration region.

All lookup tables are cleared and all declared items are removed from _namespace first. Then every declared item is added to _namespace, and additionally to the lookup table matching its kind. Items of an unhandled kind are passed to _IndexOtherDeclaredItem(). A protected type body completes its protected type, so it’s skipped. Indexing again yields the same lookup tables and namespace.

See also

ConcurrentDeclarationRegionMixin.IndexDeclaredItems()

The same algorithm for a concurrent declaration region.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a sequential statement at a position of this construct.

The statement’s parent is set to this construct.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (SequentialStatement) – The sequential statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a sequential statement after another statement of this construct.

The statement’s parent is set to this construct.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementBefore()

→ Insert a sequential statement before another statement.

InsertStatementBefore(statement, before)

Insert a sequential statement before another statement of this construct.

The statement’s parent is set to this construct.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type SequentialStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares a label of the statement.

Return type:

None

See also

InsertStatement()

→ Insert a sequential statement at a position of this construct.

InsertStatementAfter()

→ Insert a sequential statement after another statement.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a sequential statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes.

Parameters:
  • statement (SequentialStatement) – The sequential statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementAfter()

→ Move a sequential statement after another statement.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

RemoveStatement()

→ Remove a sequential statement from this construct.

MoveStatementAfter(statement, after)

Move a sequential statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementBefore()

→ Move a sequential statement before another statement.

MoveStatementBefore(statement, before)

Move a sequential statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a sequential statement to a position of this construct.

MoveStatementAfter()

→ Move a sequential statement after another statement.

property Namespace: Namespace

Read-only property to access this region’s namespace (_namespace).

Returns:

The namespace.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the declared procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a sequential statement from this construct.

The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.

Parameters:

statement (SequentialStatement) – The sequential statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a sequential statement at the end of this construct.

InsertStatement()

→ Insert a sequential statement at a position of this construct.

MoveStatement()

→ Move a sequential statement to a position of this construct.

property SensitivityList: list[Name]

Read-only property to access the sensitivity list (_sensitivityList).

Returns:

List of sensitivity list.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[SequentialStatement]

Read-only property to access the list of sequential statements (_statements).

Returns:

A list of sequential statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the declared subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the declared types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

property Variables: dict[str, Variable]

Read-only property to access the declared variables (_variables).

Returns:

Dictionary of variables, indexed by normalized identifier.

Visit(visitor)[source]

Walk this process, its sensitivity list (if any), its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Variable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.DesignUnit.UseClause'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Process,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_LabelRegion()[source]

Return the process, whose declarative region declares the labels of its statements.

Return type:

ProcessStatement

Returns:

The process itself.

_Labels()

Return the labeled statements of this construct, including the statements nested in compound statements.

Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

static _LabelsOf(statement)

Return a statement, if it’s labeled, and the labeled statements nested in it.

Parameters:

statement (SequentialStatement) – The sequential statement.

Return type:

tuple[SequentialStatement, ...]

Returns:

Tuple of labeled statements, depth-first in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the sequential statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_constants

Dictionary of all constants declared in this sequential declaration region.

_declaredItems

List of all declared items in this sequential declaration region.

_documentation

The associated documentation of a model entity.

_files

Dictionary of all files declared in this sequential declaration region.

_functions

Dictionary of all functions declared in this sequential declaration region, indexed by name; each entry is a list of overloads.

_label

The label of a model entity.

_namespace

The namespace of this sequential declaration region.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this sequential declaration region, indexed by name; each entry is a list of overloads.

_sensitivityList: list[Name]

List of all signal names in the sensitivity list, or None if none was given.

_statements

List of all sequential statements in this construct.

_subtypes

Dictionary of all subtypes declared in this sequential declaration region.

_types

Dictionary of all types declared in this sequential declaration region.

_variables

Dictionary of all variables declared in this sequential declaration region.

class pyGHDL.dom.Concurrent.IfGenerateBranch(branchNode, condition, declaredItems=None, statements=None, alternativeLabel=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.IfGenerateBranch.

Represents if-generate branch in a generate statement with a concurrent declaration region and concurrent statements.

Example

gen: if condition generate
  -- concurrent declarations
begin
  -- concurrent statements
elsif condition generate
  -- ...
else generate
  -- ...
end generate;

Inheritance

Inheritance diagram of IfGenerateBranch

Parameters:
  • branchNode (Iir)

  • condition (ExpressionUnion)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • alternativeLabel (str)

__init__(branchNode, condition, declaredItems=None, statements=None, alternativeLabel=None)[source]

Initializes an if..generate branch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition under which this branch’s declarations and statements are elaborated.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • alternativeLabel (str) – Optional, the branch’s alternative label, if one was given.

Return type:

None

classmethod parse(generateNode)[source]

Translates the IIR node of the generate statement to an IfGenerateBranch.

Parameters:

generateNode (Iir) – The IIR node of the generate statement.

Return type:

Self

Returns:

The translated generate statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property AlternativeLabel: str | None

Read-only property to access the alternative label (_alternativeLabel).

Returns:

The alternative label, or None if not set.

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

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

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedAlternativeLabel: str | None

Read-only property to access the normalized alternative label (_normalizedAlternativeLabel).

Returns:

The normalized alternative label, or None if not set.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this if-generate branch, its condition, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_alternativeLabel: Nullable[str]

The branch’s alternative label, if one was given.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_components

Dictionary of all components declared in this concurrent declaration region.

_condition

The condition guarding this statement.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_namespace

The namespace of this concurrent declaration region.

_normalizedAlternativeLabel: Nullable[str]

The normalized (lower case) alternative label.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.ElsifGenerateBranch(branchNode, condition, declaredItems=None, statements=None, alternativeLabel=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ElsifGenerateBranch.

Represents elsif-generate branch in a generate statement with a concurrent declaration region and concurrent statements.

Example

gen: if condition generate
  -- ...
elsif condition generate
  -- concurrent declarations
begin
  -- concurrent statements
else generate
  -- ...
end generate;

Inheritance

Inheritance diagram of ElsifGenerateBranch

Parameters:
  • branchNode (Iir)

  • condition (ExpressionUnion)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • alternativeLabel (str)

__init__(branchNode, condition, declaredItems=None, statements=None, alternativeLabel=None)[source]

Initializes an elsif branch of an if..generate statement.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition under which this branch’s declarations and statements are elaborated.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • alternativeLabel (str) – Optional, the branch’s alternative label, if one was given.

Return type:

None

classmethod parse(generateNode, condition)[source]

Translates the IIR node of the generate statement to an ElsifGenerateBranch.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • condition (Iir) – The condition guarding the branch.

Return type:

Self

Returns:

The translated generate statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property AlternativeLabel: str | None

Read-only property to access the alternative label (_alternativeLabel).

Returns:

The alternative label, or None if not set.

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

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

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedAlternativeLabel: str | None

Read-only property to access the normalized alternative label (_normalizedAlternativeLabel).

Returns:

The normalized alternative label, or None if not set.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this elsif-generate branch, its condition, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_alternativeLabel: Nullable[str]

The branch’s alternative label, if one was given.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_components

Dictionary of all components declared in this concurrent declaration region.

_condition

The condition guarding this statement.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_namespace

The namespace of this concurrent declaration region.

_normalizedAlternativeLabel: Nullable[str]

The normalized (lower case) alternative label.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.ElseGenerateBranch(branchNode, declaredItems=None, statements=None, alternativeLabel=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ElseGenerateBranch.

Represents else-generate branch in a generate statement with a concurrent declaration region and concurrent statements.

Example

gen: if condition generate
  -- ...
elsif condition generate
  -- ...
else generate
  -- concurrent declarations
begin
  -- concurrent statements
end generate;

Inheritance

Inheritance diagram of ElseGenerateBranch

Parameters:
  • branchNode (Iir)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • alternativeLabel (str)

__init__(branchNode, declaredItems=None, statements=None, alternativeLabel=None)[source]

Initializes an else generate branch.

Parameters:
  • branchNode (Iir) – The IIR node of the branch this object represents.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • alternativeLabel (str) – Optional, the branch’s alternative label, if one was given.

Return type:

None

classmethod parse(generateNode)[source]

Translates the IIR node of the generate statement to an ElseGenerateBranch.

Parameters:

generateNode (Iir) – The IIR node of the generate statement.

Return type:

Self

Returns:

The translated generate statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property AlternativeLabel: str | None

Read-only property to access the alternative label (_alternativeLabel).

Returns:

The alternative label, or None if not set.

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedAlternativeLabel: str | None

Read-only property to access the normalized alternative label (_normalizedAlternativeLabel).

Returns:

The normalized alternative label, or None if not set.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this else-generate branch, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_alternativeLabel: Nullable[str]

The branch’s alternative label, if one was given.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_components

Dictionary of all components declared in this concurrent declaration region.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_namespace

The namespace of this concurrent declaration region.

_normalizedAlternativeLabel: Nullable[str]

The normalized (lower case) alternative label.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.IfGenerateStatement(generateNode, label, ifBranch, elsifBranches=None, elseBranch=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.IfGenerateStatement.

Represents an if-generate statement.

It has one if branch (IfBranch), any number of elsif branches (ElsifBranches) and an optional else branch (ElseBranch). The label is mandatory and the branch conditions must be static expressions.

Example

  gen : if WIDTH > 8 generate
--^^^                           <- Label
--      ^^^^^^^^^^^^^^^^^^^^^   <- IfBranch
    q <= '0';
  elsif WIDTH > 4 generate
--^^^^^^^^^^^^^^^^^^^^^^^^      <- ElsifBranches[0]
    q <= '1';
  else generate
--^^^^^^^^^^^^^                 <- ElseBranch
    q <= 'Z';
  end generate;

Inheritance

Inheritance diagram of IfGenerateStatement

Parameters:
__init__(generateNode, label, ifBranch, elsifBranches=None, elseBranch=None)[source]

Initializes an if..generate statement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The label of the if..generate statement.

  • ifBranch (IfGenerateBranch) – The mandatory if branch.

  • elsifBranches (Iterable[ElsifGenerateBranch]) – Optional, list of all elsif branches, in the order they were written.

  • elseBranch (ElseGenerateBranch) – Optional, the else branch, or None if none was given.

Return type:

None

classmethod parse(generateNode, label)[source]

Translates the IIR node of the generate statement to an IfGenerateStatement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated generate statement.

_iirNode: Iir

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

_position: Position

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

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property ElseBranch: ElseGenerateBranch | None

Read-only property to access the else branch (_elseBranch).

Returns:

The else branch, or None if not set.

property ElsifBranches: list[ElsifGenerateBranch]

Read-only property to access the elsif branches (_elsifBranches).

Returns:

List of elsif branches.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 IfBranch: IfGenerateBranch

Read-only property to access the if branch (_ifBranch).

Returns:

The if branch.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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.

Visit(visitor)[source]

Walk this if-generate statement and its branches with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Generate,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox: bool | None

Allow blackboxes for components; None inherits the parent’s setting.

_elseBranch: ElseGenerateBranch | None

The optional else branch, or None if none was given.

_elsifBranches: list[ElsifGenerateBranch]

List of all elsif branches, in the order they were written.

_ifBranch: IfGenerateBranch

The mandatory if branch.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.IndexedGenerateChoice(node, expression)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.IndexedGenerateChoice.

Represents a case-generate choice given by a single value.

The value is available as Expression.

Example

when 8 =>
--   ^      <- Expression

Inheritance

Inheritance diagram of IndexedGenerateChoice

Parameters:
  • node (Iir)

  • expression (ExpressionUnion)

__init__(node, expression)[source]

Initializes a case-generate choice given by a single value.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression this choice selects on.

Return type:

None

_iirNode: Iir

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

_position: Position

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)[source]

Walk this case-generate choice and its value with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the indexed case-generate choice.

Format: 0

Return type:

str

Returns:

Formatted indexed case-generate choice.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression this choice selects on.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.RangedGenerateChoice(node, rng)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.RangedGenerateChoice.

Represents a case-generate choice given by a range.

The range is available as Range.

Example

when 0 to 3 =>
--   ^^^^^^      <- Range

Inheritance

Inheritance diagram of RangedGenerateChoice

Parameters:
__init__(node, rng)[source]

Initializes a case-generate choice given by a range.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • rng (Range) – The range this choice selects on.

Return type:

None

_iirNode: Iir

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

_position: Position

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

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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: Range

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

Returns:

The range.

Visit(visitor)[source]

Walk this case-generate choice and its range with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the ranged case-generate choice.

Format: 0 to 3

Return type:

str

Returns:

Formatted ranged case-generate choice.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_range: Range

The range this choice selects on.

class pyGHDL.dom.Concurrent.GenerateCase(node, choices, declaredItems=None, statements=None, alternativeLabel=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.GenerateCase.

Represents one alternative of a case-generate statement, selected by its choices.

Example

when 8 =>
--   ^      <- Choices

Inheritance

Inheritance diagram of GenerateCase

Parameters:
  • node (Iir)

  • choices (Iterable[ConcurrentChoice])

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • alternativeLabel (str)

__init__(node, choices, declaredItems=None, statements=None, alternativeLabel=None)[source]

Initializes a generate case.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • choices (Iterable[ConcurrentChoice]) – List of all choices selecting this alternative.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • alternativeLabel (str) – Optional, the alternative’s label.

Return type:

None

classmethod parse(caseNode, choices)[source]

Translates the IIR node of the alternative to a GenerateCase.

Parameters:
  • caseNode (Iir) – The IIR node of the alternative.

  • choices (Iterable[ConcurrentChoice]) – List of all choices selecting this alternative.

Return type:

Self

Returns:

The translated alternative.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this case-generate alternative, its choices, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the case-generate alternative.

Format: when 0 | 1 =>

Return type:

str

Returns:

Formatted case-generate alternative.

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_choices

List of all choices selecting this alternative.

_components

Dictionary of all components declared in this concurrent declaration region.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_label

The label of a model entity.

_namespace

The namespace of this concurrent declaration region.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.OthersGenerateCase(caseNode, declaredItems=None, statements=None, alternativeLabel=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.OthersGenerateCase.

Represents the others alternative of a case-generate statement.

It covers every choice not named explicitly.

Example

when others =>
--   ^^^^^^      <- the choice

Inheritance

Inheritance diagram of OthersGenerateCase

Parameters:
  • caseNode (Iir)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • alternativeLabel (str)

__init__(caseNode, declaredItems=None, statements=None, alternativeLabel=None)[source]

Initializes an others generate alternative.

Parameters:
  • caseNode (Iir) – The IIR node of the case statement.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • alternativeLabel (str) – Optional, the alternative’s label.

Return type:

None

classmethod parse(caseNode)[source]

Translates the IIR node of the alternative to an OthersGenerateCase.

Parameters:

caseNode (Iir) – The IIR node of the alternative.

Return type:

Self

Returns:

The translated alternative.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this others case-generate alternative, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

__str__()[source]

Formats the others case-generate alternative.

Format: when others =>

Return type:

str

Returns:

Formatted others case-generate alternative.

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_choices

List of all choices selecting this alternative.

_components

Dictionary of all components declared in this concurrent declaration region.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_label

The label of a model entity.

_namespace

The namespace of this concurrent declaration region.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.CaseGenerateStatement(generateNode, label, expression, cases)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.CaseGenerateStatement.

Represents a case-generate statement.

The expression being tested is available as SelectExpression, the alternatives as Cases. The label is mandatory and the selector must be a static expression.

Example

  gen : case MODE generate
--^^^                          <- Label
--           ^^^^              <- SelectExpression
    when 0 => q <= '0';
--  ^^^^^^^^^^^^^^^^^^^        <- Cases[0]
    when others => q <= '1';
--  ^^^^^^^^^^^^^^^^^^^^^^^^   <- Cases[1]
  end generate;

Inheritance

Inheritance diagram of CaseGenerateStatement

Parameters:
  • generateNode (Iir)

  • label (str)

  • expression (ExpressionUnion)

  • cases (Iterable[ConcurrentCase])

__init__(generateNode, label, expression, cases)[source]

Initializes a case..generate statement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The label of the case..generate statement.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The expression selecting the alternative.

  • cases (Iterable[ConcurrentCase]) – List of all alternatives, in the order they were written.

Return type:

None

classmethod parse(generateNode, label)[source]

Translates the IIR node of the generate statement to a CaseGenerateStatement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated generate statement.

_iirNode: Iir

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

_position: Position

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

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property Cases: list[GenerateCase]

Read-only property to access the cases (_cases).

Returns:

List of cases.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 SelectExpression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

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

Returns:

The select expression.

Visit(visitor)[source]

Walk this case-generate statement, its selector and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Generate,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL: ClassVar[bool] = False

The reserved words after end are optional.

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox: bool | None

Allow blackboxes for components; None inherits the parent’s setting.

_cases: list[GenerateCase]

List of all alternatives, in the order they were written.

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression being tested; it must be static.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.ForGenerateStatement(generateNode, label, loopIndex, rng, declaredItems=None, statements=None, parent=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ForGenerateStatement.

Represents a for-generate statement.

The loop index is available as LoopIndex, the iteration range as Range and the generated statements as Statements. The label is mandatory.

Example

  gen : for i in 0 to 3 generate
--^^^                              <- Label
--          ^                      <- LoopIndex
--               ^^^^^^            <- Range
    q(i) <= '0';
--  ^^^^^^^^^^^^                   <- Statements
  end generate;

Inheritance

Inheritance diagram of ForGenerateStatement

Parameters:
  • generateNode (Iir)

  • label (str)

  • loopIndex (str)

  • rng (Range)

  • declaredItems (Iterable)

  • statements (Iterable[ConcurrentStatement])

  • parent (Nullable[ModelEntity])

__init__(generateNode, label, loopIndex, rng, declaredItems=None, statements=None, parent=None)[source]

Initializes a for..generate statement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The label of the for..generate statement.

  • loopIndex (str) – The name of the generate loop’s index.

  • rng (Range) – The range the generate loop iterates over.

  • declaredItems (Iterable) – Optional, list of all declared items in this concurrent declaration region.

  • statements (Iterable[ConcurrentStatement]) – Optional, list of all concurrent statements in this construct.

  • parent (ModelEntity | None) – Optional, the parent model entity of this entity.

Return type:

None

classmethod parse(generateNode, label)[source]

Translates the IIR node of the generate statement to a ForGenerateStatement.

Parameters:
  • generateNode (Iir) – The IIR node of the generate statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated generate statement.

_iirNode

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

_position

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

AddDeclaredItem(declaredItem)

Add a declared item at the end of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:

declaredItem (ModelEntity) – The declared item to add.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

AddStatement(statement)

Add a concurrent statement at the end of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to add.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

property AllowBlackbox: bool

Property to return whether a design supports blackboxes, inherited from the parent if not set locally (_allowBlackbox).

Algorithm

  1. If allow blackbox property is locally set, return the local value,

  2. Otherwise, return allow blackbox value from parent object.

Returns:

True, if blackboxes are allowed.

Raises:

VHDLModelException – If neither a local value is set nor a parent object is available to inherit the value from.

Setter accepts:

bool | None

property Components: dict[str, Any]

Read-only property to access the components (_components).

Returns:

Dictionary of components, indexed by normalized identifier.

property Constants: dict[str, Constant]

Read-only property to access the constants (_constants).

Returns:

Dictionary of constants, indexed by normalized identifier.

property DeclaredItems: list

Read-only property to access the declared items (_declaredItems).

Returns:

List of declared items.

property Files: dict[str, File]

Read-only property to access the files (_files).

Returns:

Dictionary of files, indexed by normalized identifier.

property Functions: dict[str, list[Function]]

Read-only property to access the functions (_functions).

Returns:

Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

IndexDeclaredItems()

Index declared items listed in the concurrent declaration region.

Algorithm

  1. Clear all lookup tables and remove all declared items from _namespace. Interface items and imported items stay in the namespace.

  2. Iterate all declared items:

Indexing again yields the same lookup tables and namespace.

See also

pyVHDLModel.Design.IndexPackages()

Iterate all packages in the design and index declared items.

pyVHDLModel.Library.IndexPackages()

Iterate all packages in the library and index declared items.

pyVHDLModel.Library._IndexOtherDeclaredItem()

Iterate all packages in the library and index declared items.

Raises:

UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

IndexStatements()[source]

Index the instantiations, blocks and generate statements of this construct, and the statements nested in them.

Both lookup tables (_instantiations, _hierarchy) are cleared first, so indexing again yields the same lookup tables. Afterwards, the statement mutators (e.g. InsertStatement()) keep them up to date.

Return type:

None

InsertDeclaredItem(index, declaredItem)

Insert a declared item at a position of the declarative region.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.

Parameters:
  • index (int) – Position, from 0 (first) to the number of declared items (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last declared item.

  • declaredItem (ModelEntity) – The declared item to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

InsertDeclaredItemAfter(declaredItem, after)

Insert a declared item after another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • after (ModelEntity) – The declared item of this declarative region to insert after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemBefore()

→ Insert a declared item before another declared item.

InsertDeclaredItemBefore(declaredItem, before)

Insert a declared item before another declared item.

The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.

Parameters:
  • declaredItem (ModelEntity) – The declared item to insert.

  • before (ModelEntity) – The declared item of this declarative region to insert before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.

  • AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

  • DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.

Return type:

None

See also

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

InsertDeclaredItemAfter()

→ Insert a declared item after another declared item.

InsertStatement(index, statement)

Insert a concurrent statement at a position of this construct.

The statement’s parent is set to this construct: a process, block or generate statement connects its namespace to this construct’s namespace. If the statements are indexed (IndexStatements()), an instantiation, a block or a generate statement is added to the lookup table matching its kind, and the statements nested in it are indexed.

A statement label is declared in the declarative region of this construct: it may neither repeat another statement’s label, nor an identifier declared in the region, including the region an entity shares with its architectures. An unlabeled statement declares nothing.

Parameters:
  • index (int) – Position, from 0 (first) to the number of statements (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last statement.

  • statement (ConcurrentStatement) – The concurrent statement to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

InsertStatementAfter(statement, after)

Insert a concurrent statement after another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementBefore()

→ Insert a concurrent statement before another statement.

InsertStatementBefore(statement, before)

Insert a concurrent statement before another statement of this construct.

The statement’s parent is set to this construct. If the statements are indexed, an instantiation, a block or a generate statement is added to the lookup table matching its kind.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ConcurrentStatement.

  • AlreadyInDesignError – If parameter ‘statement’ already has a parent.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

  • DuplicateLabelError – If the declarative region already declares the statement’s label.

Return type:

None

See also

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

InsertStatementAfter()

→ Insert a concurrent statement after another statement.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property LoopIndex: str

Read-only property to access the loop index (_loopIndex).

Returns:

The loop index.

MoveDeclaredItem(declaredItem, index)

Move a declared item to a position of the declarative region.

The declared item stays a declared item of this declarative region: only the order of the declared items changes.

If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • index (int) – Position of the declared item after the move, from 0 (first) to the number of declared items minus one (last). A negative index counts from the end, as for a list index: -1 moves the declared item to the end.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

MoveDeclaredItemAfter(declaredItem, after)

Move a declared item after another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item after itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • after (ModelEntity) – The declared item of this declarative region to move after.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemBefore()

→ Move a declared item before another declared item.

MoveDeclaredItemBefore(declaredItem, before)

Move a declared item before another declared item.

The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for MoveDeclaredItem(). Moving a declared item before itself keeps it in place.

Parameters:
  • declaredItem (ModelEntity) – The declared item to move.

  • before (ModelEntity) – The declared item of this declarative region to move before.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.

Return type:

None

See also

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

MoveDeclaredItemAfter()

→ Move a declared item after another declared item.

MoveStatement(statement, index)

Move a concurrent statement to a position of this construct.

The statement stays a statement of this construct: only the order of the statements changes. If the statements are indexed (IndexStatements()), the lookup tables are unchanged.

Parameters:
  • statement (ConcurrentStatement) – The concurrent statement to move.

  • index (int) – Position of the statement after the move, from 0 (first) to the number of statements minus one (last). A negative index counts from the end, as for a list index: -1 moves the statement to the end.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

Return type:

None

See also

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

RemoveStatement()

→ Remove a concurrent statement from this construct.

MoveStatementAfter(statement, after)

Move a concurrent statement after another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement after itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘after’ is None.

  • TypeError – If parameter ‘after’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘after’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementBefore()

→ Move a concurrent statement before another statement.

MoveStatementBefore(statement, before)

Move a concurrent statement before another statement of this construct.

The statement stays a statement of this construct: only the order of the statements changes, as for MoveStatement(). Moving a statement before itself keeps it in place.

Parameters:
Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

  • ValueError – If parameter ‘before’ is None.

  • TypeError – If parameter ‘before’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘before’ is not a statement of this construct.

Return type:

None

See also

MoveStatement()

→ Move a concurrent statement to a position of this construct.

MoveStatementAfter()

→ Move a concurrent statement after another statement.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Procedures: dict[str, list[Procedure]]

Read-only property to access the procedures (_procedures).

Returns:

Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.

property Range: Range

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

Returns:

The range.

RemoveDeclaredItem(declaredItem)

Remove a declared item from the declarative region.

The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.

The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the removal.

Parameters:

declaredItem (ModelEntity) – The declared item to remove.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

Return type:

None

See also

AddDeclaredItem()

→ Add a declared item at the end of the declarative region.

InsertDeclaredItem()

→ Insert a declared item at a position of the declarative region.

MoveDeclaredItem()

→ Move a declared item to a position of the declarative region.

RemoveStatement(statement)

Remove a concurrent statement from this construct.

The statement is detached: its parent is cleared. If the statements are indexed, an instantiation, a block or a generate statement is removed from its lookup table. The statement itself is unchanged and can be added to another construct, or inserted at another position. A removed process, block or generate statement keeps the link of its namespace to this construct’s namespace.

Parameters:

statement (ConcurrentStatement) – The concurrent statement to remove.

Raises:
  • ValueError – If parameter ‘statement’ is None.

  • TypeError – If parameter ‘statement’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘statement’ is not a statement of this construct.

Return type:

None

See also

AddStatement()

→ Add a concurrent statement at the end of this construct.

InsertStatement()

→ Insert a concurrent statement at a position of this construct.

MoveStatement()

→ Move a concurrent statement to a position of this construct.

property SharedVariables: dict[str, SharedVariable]

Read-only property to access the shared variables (_sharedVariables).

Returns:

Dictionary of shared variables, indexed by normalized identifier.

property Signals: dict[str, Signal]

Read-only property to access the signals (_signals).

Returns:

Dictionary of signals, indexed by normalized identifier.

SplitDeclaredItem(declaredItem)

Split a declared item with an identifier list into one declaration per identifier.

The declared item keeps its first identifier. For every other identifier, a new declaration is created by its Copy() and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.

Parameters:

declaredItem (ModelEntity) – The declared item to split.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations, one per identifier in list order, starting with the split declared item.

Raises:
  • ValueError – If parameter ‘declaredItem’ is None.

  • TypeError – If parameter ‘declaredItem’ is not of type ModelEntity.

  • NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.

  • NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.

See also

Split()

→ Split a declaration with an identifier list.

RemoveDeclaredItem()

→ Remove a declared item from the declarative region.

property Statements: list[ConcurrentStatement]

Read-only property to access the statements (_statements).

Returns:

List of statements.

property Subtypes: dict[str, Subtype]

Read-only property to access the subtypes (_subtypes).

Returns:

Dictionary of subtypes, indexed by normalized identifier.

property Types: dict[str, FullType]

Read-only property to access the types (_types).

Returns:

Dictionary of types, indexed by normalized identifier.

Visit(visitor)[source]

Walk this for-generate statement, its range, its declared items and its statements with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddOverloadToNamespace(item)

Add a function or procedure to the namespace, if it’s the overload declared last.

The namespace keeps one entry per identifier: the overload declared last, as after IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.

Return type:

None

_AddToNamespace(element)

Add an element’s identifiers to this region’s namespace.

Nothing is added to a region not indexed yet: IndexDeclaredItems() adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.

Return type:

None

_ClashingDeclarations(item)

Return the declarations sharing an identifier with the given item, which may not share it.

The declarations (_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.

Parameters:

item (ModelEntity) – The new declaration, or the new labeled statement.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.

_DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Signal'>, <class 'pyVHDLModel.Object.SharedVariable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.DesignUnit.Component'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.Configuration.ComponentConfiguration'>, <class 'pyVHDLModel.Interface.ModeViewDeclaration'>, <class 'pyVHDLModel.DesignUnit.UseClause'>, <class 'pyVHDLModel.PSLModel.PSLEntity'>)

Accepted classes of declared items (pyVHDLModel).

_Declarations()

Return all declarations of this declarative region.

A host class with interface items extends the list by its interface items, listed first.

Return type:

tuple[ModelEntity, ...]

Returns:

Tuple of declarations: the declared items, in declaration order.

_DeclaredItemsSharingIdentifiers(declaredItem)

Return the other declared items of this region sharing an identifier with the given declared item.

Parameters:

declaredItem (ModelEntity) – The declared item.

Return type:

list[ModelEntity]

Returns:

List of declared items, in declaration order.

_END_KEYWORDS = (ReservedWord.Generate,)

Reserved words after end.

_END_KEYWORDS_OPTIONAL = False

The reserved words after end are optional.

_IndexDeclaredItem(item)

Add a declared item to the namespace and to the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOtherDeclaredItem(item)

Hook for declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_IndexOverload(item)

Add an inserted function or procedure to its lookup table and to the namespace.

The list of overloads follows the declaration order. The namespace is updated by _AddOverloadToNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The inserted function or procedure.

Return type:

None

_IndexStatement(statement)

Add an instantiation, a block or a generate statement to its lookup table, and index the statements nested in it.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_Labels()

Return the labeled statements, whose labels are declared in this construct’s declarative region.

A statement nested in a block or generate statement is declared in that statement’s declarative region.

Return type:

tuple[ConcurrentStatement, ...]

Returns:

Tuple of labeled statements, in statement order.

_MayShareIdentifier(item, existing)

Check if two declarations may share an identifier in one declarative region.

Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.

Parameters:
Return type:

bool

Returns:

True, if both declarations may share an identifier.

_RemoveDeclaredItemEntries(lookupTable, item)

Remove a declared item’s entries from a lookup table and from the namespace.

Every identifier is checked before anything is removed.

Parameters:
Raises:
  • NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.

  • NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveDeclaredItemsFromNamespace()

Remove all declared items of this region from its namespace.

Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.

Return type:

None

_RemoveFromNamespace(element)

Remove an element’s identifiers from this region’s namespace.

Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (_RemoveOverloadFromNamespace()).

Parameters:

element (NamedEntityMixin | MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.

Raises:
  • NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.

  • NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.

Return type:

None

_RemoveOverloadFromNamespace(item)

Remove a function or procedure from the namespace.

Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_SharedRegions()

Return the other language constructs forming one declarative region with this one.

An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.

Return type:

tuple[DeclarationRegionMixin, ...]

Returns:

Tuple of declarative regions.

_UnindexDeclaredItem(item)

Remove a declared item from the namespace and from the lookup table matching its kind.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOtherDeclaredItem(item)

Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.

Parameters:

item (ModelEntity) – The declared item.

Return type:

None

_UnindexOverload(item)

Remove a function or procedure from its lookup table and from the namespace.

The namespace is updated first, by _RemoveOverloadFromNamespace().

Parameters:

item (NamedEntityMixin | MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.

Raises:
  • NotInNamespaceError – If the identifier isn’t declared in the namespace.

  • NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.

Return type:

None

_UnindexStatement(statement)

Remove an instantiation, a block or a generate statement from its lookup table.

Parameters:

statement (ConcurrentStatement) – The concurrent statement of this construct.

Return type:

None

_VisitDeclaredItems(visitor)

Walk the declared items in declaration order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitStatements(visitor)

Walk the concurrent statements in statement order with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_allowBlackbox

Allow blackboxes for components; None inherits the parent’s setting.

_areDeclaredItemsIndexed

True if IndexDeclaredItems() filled the namespace.

_areStatementsIndexed

True if IndexStatements() filled _instantiations and _hierarchy.

_components

Dictionary of all components declared in this concurrent declaration region.

_constants

Dictionary of all constants declared in this concurrent declaration region.

_declaredItems

List of all declared items in this concurrent declaration region.

_files

Dictionary of all files declared in this concurrent declaration region.

_functions

Dictionary of all functions declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_hierarchy

All elements creating a hierarchy level (blocks and generates), in declaration order.

_instantiations

All instantiations, indexed by label.

_label

The label of a model entity.

_loopIndex: str

The name of the generate loop’s index.

_namespace

The namespace of this concurrent declaration region.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent

Reference to a parent entity in the logical model hierarchy.

_procedures

Dictionary of all procedures declared in this concurrent declaration region, indexed by name; each entry is a list of overloads.

_range: Range

The range the generate loop iterates over.

_sharedVariables

Dictionary of all shared variables declared in this concurrent declaration region.

_signals

Dictionary of all signals declared in this concurrent declaration region.

_statements

List of all concurrent statements in this construct.

_subtypes

Dictionary of all subtypes declared in this concurrent declaration region.

_types

Dictionary of all types declared in this concurrent declaration region.

class pyGHDL.dom.Concurrent.WaveformElement(waveNode, expression, after)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Base.WaveformElement.

Represents one element of a waveform in a signal assignment.

A waveform element assigns a value (Expression) after an optional delay (After).

Example

s <= '1' after 5 ns;
--   ^^^               <- Expression
--             ^^^^    <- After

Inheritance

Inheritance diagram of WaveformElement

Parameters:
  • waveNode (Iir)

  • expression (ExpressionUnion)

  • after (ExpressionUnion)

__init__(waveNode, expression, after)[source]

Initializes a waveform element.

Parameters:
  • waveNode (Iir) – The IIR node of the waveform element.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The value this waveform element assigns.

  • after (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The delay after which the value is assigned, or None if none was given.

Return type:

None

classmethod parse(waveNode)[source]

Translates the IIR node of the waveform element to a WaveformElement.

Parameters:

waveNode (Iir) – The IIR node of the waveform element.

Returns:

The translated waveform element.

_iirNode

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

_position

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

property After: Expression

Read-only property to access the waveform element’s delay (_after).

Returns:

The after.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)[source]

Walk this waveform element, its value and its delay (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_after: ExpressionUnion

The delay after which the value is assigned, or None if none was given.

_expression: ExpressionUnion

The value this waveform element assigns.

_parent

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.Concurrent.ConditionalWaveform(node, waveform, condition=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.ConditionalWaveform.

Represents one branch of a conditional signal assignment.

Each branch pairs a waveform (Waveform) with a condition (Condition). The final branch has no when, so its condition is None.

Example

s <= '1' when cond else '0';
--   ^^^^^^^^^^^^^             <- this branch: Waveform=['1'], Condition=cond
--                      ^^^    <- final branch (no ``when``): Waveform=['0'], Condition=None

Inheritance

Inheritance diagram of ConditionalWaveform

Parameters:
__init__(node, waveform, condition=None)[source]

Initializes a conditional waveform.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • waveform (Iterable[WaveformElement]) – List of all waveform elements, in the order they were written.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the condition selecting this alternative.

Return type:

None

classmethod parse(node)[source]

Translates an IIR node to a ConditionalWaveform.

Parameters:

node (Iir) – The IIR node this object is translated from.

Return type:

Self

Returns:

The translated object.

_iirNode

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

_position

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

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

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)[source]

Walk this conditional waveform, its waveform and its condition (if any) with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

property Waveform: list[WaveformElement]

Read-only property to access the waveform (_waveform).

Returns:

List of waveform.

_VisitWaveform(visitor)

Walk the waveform elements, separated by commas, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_condition

The condition guarding this statement.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_waveform

List of all waveform elements, in the order they were written.

class pyGHDL.dom.Concurrent.SelectedWaveform(node, choices, waveform)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.SelectedWaveform.

Represents one alternative of a selected signal assignment.

Each alternative pairs a waveform (Waveform) with the choices selecting it (Choices).

Example

with sel select s <= '1' when '0', '0' when others;
--                   ^^^^^^^^^^^^                     <- this alternative: Choices=['0'], Waveform=['1']

Inheritance

Inheritance diagram of SelectedWaveform

Parameters:
__init__(node, choices, waveform)[source]

Initializes a selected waveform.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • choices (Iterable) – List of all choices selecting this alternative.

  • waveform (Iterable[WaveformElement]) – List of all waveform elements, in the order they were written.

Return type:

None

_iirNode: Iir

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

_position: Position

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

property Choices: list[BaseChoice]

Read-only property to access the choices (_choices).

Returns:

List of choices.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)[source]

Walk this selected waveform, its waveform and its choices with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

property Waveform: list[WaveformElement]

Read-only property to access the waveform (_waveform).

Returns:

List of waveform.

_VisitWaveform(visitor)

Walk the waveform elements, separated by commas, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_choices: list[BaseChoice]

List of all choices selecting this alternative.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_waveform: list[WaveformElement]

List of all waveform elements, in the order they were written.

class pyGHDL.dom.Concurrent.OthersSelectedWaveform(node, waveform)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Common.OthersSelectedWaveform.

Represents the others alternative of a selected signal assignment.

It supplies the waveform (Waveform) for every choice not named explicitly.

Example

with sel select s <= '1' when '0', '0' when others;
--                                 ^^^^^^^^^^^^^^^    <- the others alternative

Inheritance

Inheritance diagram of OthersSelectedWaveform

Parameters:
__init__(node, waveform)[source]

Initializes an others selected waveform.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • waveform (Iterable[WaveformElement]) – List of all waveform elements, in the order they were written.

Return type:

None

_iirNode: Iir

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

_position: Position

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

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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: Position

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.

Visit(visitor)[source]

Walk this others selected waveform and its waveform with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

property Waveform: list[WaveformElement]

Read-only property to access the waveform (_waveform).

Returns:

List of waveform.

_VisitWaveform(visitor)

Walk the waveform elements, separated by commas, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_waveform: list[WaveformElement]

List of all waveform elements, in the order they were written.

class pyGHDL.dom.Concurrent.ConcurrentSimpleSignalAssignment(assignmentNode, label, target, waveform)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentSimpleSignalAssignment.

Represents a simple concurrent signal assignment.

The assignment’s destination is available as Target, its value as Waveform.

Example

  lbl : q <= '1';
--^^^               <- optional Label
--      ^           <- Target
--           ^^^    <- Waveform

Inheritance

Inheritance diagram of ConcurrentSimpleSignalAssignment

Parameters:
__init__(assignmentNode, label, target, waveform)[source]

Initializes a simple concurrent signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The label of the concurrent signal assignment, or None if it has none.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • waveform (Iterable[WaveformElement]) – List of all waveform elements, in the order they were written.

Return type:

None

classmethod parse(assignmentNode, label)[source]

Translates the IIR node of the assignment statement to a ConcurrentSimpleSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

_iirNode: Iir

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

_position: Position

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

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this concurrent signal assignment, its target and its waveform with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

property Waveform: list[WaveformElement]

Read-only property to access the waveform (_waveform).

Returns:

List of waveform.

_VisitWaveform(visitor)

Walk the waveform elements, separated by commas, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

_waveform: list[WaveformElement]

List of all waveform elements, in the order they were written.

class pyGHDL.dom.Concurrent.ConcurrentConditionalSignalAssignment(assignmentNode, label, target, conditionalWaveforms)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentConditionalSignalAssignment.

Represents a conditional concurrent signal assignment.

The alternatives are available as ConditionalWaveforms, a list of ConditionalWaveform. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : q <= '1' when cond else '0';
--^^^                                  <- optional Label
--      ^                              <- Target
--           ^^^^^^^^^^^^^             <- ConditionalWaveforms[0]
--                              ^^^    <- ConditionalWaveforms[1]

Inheritance

Inheritance diagram of ConcurrentConditionalSignalAssignment

Parameters:
__init__(assignmentNode, label, target, conditionalWaveforms)[source]

Initializes a conditional concurrent signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The label of the conditional concurrent signal assignment, or None if it has none.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • conditionalWaveforms (Iterable[ConditionalWaveform]) – All alternatives, in order.

Return type:

None

classmethod parse(assignmentNode, label)[source]

Translates the IIR node of the assignment statement to a ConcurrentConditionalSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

_iirNode: Iir

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

_position: Position

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

property ConditionalWaveforms: list[ConditionalWaveform]

Read-only property to access the conditional waveforms (_conditionalWaveforms).

Returns:

List of conditional waveforms.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this conditional signal assignment, its target and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitConditionalWaveforms(visitor)

Walk the conditional waveforms, separated by the reserved word else, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_conditionalWaveforms: list[ConditionalWaveform]

All alternatives, in order.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Concurrent.ConcurrentSelectedSignalAssignment(assignmentNode, label, target, expression, selectedWaveforms)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentSelectedSignalAssignment.

Represents a selected concurrent signal assignment.

The selector is available as Expression, the alternatives as SelectedWaveforms, a list of SelectedWaveform. The model holds them in a list and has no distinct field per alternative, so the markers below name list elements.

Example

  lbl : with sel select q <= '1' when '0', '0' when others;
--^^^                                                         <- optional Label
--           ^^^                                              <- Expression
--                      ^                                     <- Target
--                           ^^^^^^^^^^^^                     <- SelectedWaveforms[0]
--                                         ^^^^^^^^^^^^^^^    <- SelectedWaveforms[1]

Inheritance

Inheritance diagram of ConcurrentSelectedSignalAssignment

Parameters:
  • assignmentNode (Iir)

  • label (str)

  • target (SignalSymbol)

  • expression (ExpressionUnion)

  • selectedWaveforms (Iterable)

__init__(assignmentNode, label, target, expression, selectedWaveforms)[source]

Initializes a selected concurrent signal assignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The label of the selected concurrent signal assignment, or None if it has none.

  • target (SignalSymbol) – Reference to the assignment’s destination.

  • expression (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The selector expression.

  • selectedWaveforms (Iterable) – All alternatives, in order.

Return type:

None

classmethod parse(assignmentNode, label)[source]

Translates the IIR node of the assignment statement to a ConcurrentSelectedSignalAssignment.

Parameters:
  • assignmentNode (Iir) – The IIR node of the assignment statement.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assignment statement.

_iirNode: Iir

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

_position: Position

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 SelectedWaveforms: list[SelectedWaveform | OthersSelectedWaveform]

Read-only property to access the selected waveforms (_selectedWaveforms).

Returns:

List of selected waveforms.

property Target: SignalSymbol

Read-only property to access the target (_target).

Returns:

The target.

Visit(visitor)[source]

Walk this selected signal assignment, its selector, its target and its alternatives with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitSelectedWaveforms(visitor)

Walk the selected waveforms, separated by commas, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal

The expression held by this construct.

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_selectedWaveforms: list[SelectedWaveform | OthersSelectedWaveform]

All alternatives, in order.

_target: Symbol

Reference to the assignment’s destination.

class pyGHDL.dom.Concurrent.ConcurrentProcedureCall(callNode, label, procedureName, parameterAssociationItems)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentProcedureCall.

Represents a concurrent procedure call.

Like every concurrent statement, it can carry an optional label (Label).

Example

  proc_lbl : proc(clock, open);
--^^^^^^^^                        <- optional Label
--           ^^^^^^^^^^^^^^^^^    <- the call

Inheritance

Inheritance diagram of ConcurrentProcedureCall

Parameters:
  • callNode (Iir)

  • label (str)

  • procedureName (Symbol)

  • parameterAssociationItems (Iterable)

__init__(callNode, label, procedureName, parameterAssociationItems)[source]

Initializes a concurrent procedure call.

Parameters:
  • callNode (Iir) – The IIR node of the subprogram call.

  • label (str) – The label of the concurrent procedure call, or None if it has none.

  • procedureName (Symbol) – Reference to the called procedure.

  • parameterAssociationItems (Iterable) – List of all parameter associations of the call.

Return type:

None

classmethod parse(concurrentCallNode, label)[source]

Translates the IIR node of the concurrent procedure call to a ConcurrentProcedureCall.

Parameters:
  • concurrentCallNode (Iir) – The IIR node of the concurrent procedure call.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated concurrent procedure call.

_iirNode: Iir

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

_position: Position

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

AddParameterAssociationItem(parameterAssociationItem)

Add a parameter association at the end of the parameter association list.

The association’s parent is set to this procedure call.

Parameters:

parameterAssociationItem (ParameterAssociationItem) – The parameter association to add.

Raises:
  • ValueError – If parameter ‘parameterAssociationItem’ is None.

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

  • AlreadyInDesignError – If parameter ‘parameterAssociationItem’ already has a parent.

  • DuplicateParameterAssociationError – If the association is named, and another named association of the parameter association list has the same formal.

  • AssociationOrderError – If the association is positional, and the parameter association list has a named association.

Return type:

None

See also

InsertParameterAssociationItem()

→ Insert a parameter association at a position of the parameter association list.

RemoveParameterAssociationItem()

→ Remove a parameter association from the parameter association list.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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.

InsertParameterAssociationItem(index, parameterAssociationItem)

Insert a parameter association at a position of the parameter association list.

The association’s parent is set to this procedure call.

A named association (formal => actual) can’t repeat the formal of another named association of the parameter association list. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.

Parameters:
  • index (int) – Position, from 0 (first) to the number of parameter associations (append). A negative index counts from the end, as for list.insert(): -1 inserts before the last parameter association.

  • parameterAssociationItem (ParameterAssociationItem) – The parameter association to insert.

Raises:
  • ValueError – If parameter ‘index’ is None.

  • TypeError – If parameter ‘index’ is not of type int.

  • ValueError – If parameter ‘index’ is out of range.

  • ValueError – If parameter ‘parameterAssociationItem’ is None.

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

  • AlreadyInDesignError – If parameter ‘parameterAssociationItem’ already has a parent.

  • DuplicateParameterAssociationError – If the association is named, and another named association of the parameter association list has the same formal.

  • AssociationOrderError – If the association is positional, and a named association precedes the position.

  • AssociationOrderError – If the association is named, and a positional association follows the position.

Return type:

None

See also

AddParameterAssociationItem()

→ Add a parameter association at the end of the parameter association list.

RemoveParameterAssociationItem()

→ Remove a parameter association from the parameter association list.

property Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

property ParameterAssociationItems: list[ParameterAssociationItem]

Read-only property to access the parameter association items (_parameterAssociationItems).

Returns:

List of parameter association items.

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: Position

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 Procedure: Symbol

Read-only property to access the procedure (_procedure).

Returns:

The procedure.

RemoveParameterAssociationItem(parameterAssociationItem)

Remove a parameter association from the parameter association list.

The association is detached: its parent is cleared. The association itself is unchanged and can be added to another procedure call, or inserted at another position.

Parameters:

parameterAssociationItem (ParameterAssociationItem) – The parameter association to remove.

Raises:
  • ValueError – If parameter ‘parameterAssociationItem’ is None.

  • TypeError – If parameter ‘parameterAssociationItem’ is not of type ParameterAssociationItem.

  • NotAChildError – If parameter ‘parameterAssociationItem’ is not a parameter association of this procedure call.

Return type:

None

See also

AddParameterAssociationItem()

→ Add a parameter association at the end of the parameter association list.

InsertParameterAssociationItem()

→ Insert a parameter association at a position of the parameter association list.

Visit(visitor)[source]

Walk this concurrent procedure call, its procedure and its parameters with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitProcedureCall(visitor)

Walk the called procedure and the actual parameter part, if there are parameters, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_label: str | None

The label of a model entity.

_normalizedLabel: str | None

The normalized (lower case) label of a model entity.

_parameterAssociationItems: list[ParameterAssociationItem]

List of all parameter associations of the call.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_procedure: Symbol

Reference to the called procedure.

class pyGHDL.dom.Concurrent.ConcurrentAssertStatement(assertNode, condition, message=None, severity=None, label=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Concurrent.ConcurrentAssertStatement.

Represents a concurrent assertion statement.

The checked condition is available as Condition, the optional report string as Message and the optional severity as Severity.

Example

  lbl : assert cond report "bad" severity note;
--^^^                                             <- optional Label
--             ^^^^                               <- Condition
--                         ^^^^^                  <- optional Message
--                                        ^^^^    <- optional Severity

Inheritance

Inheritance diagram of ConcurrentAssertStatement

Parameters:
  • assertNode (Iir)

  • condition (ExpressionUnion)

  • message (ExpressionUnion)

  • severity (ExpressionUnion)

  • label (str)

__init__(assertNode, condition, message=None, severity=None, label=None)[source]

Initializes a concurrent assertion statement.

Parameters:
  • assertNode (Iir) – The IIR node of the assertion.

  • condition (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – The condition that must hold; the report is issued when it is false.

  • message (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported message, or None if none was given.

  • severity (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported severity level, or None if none was given.

  • label (str) – Optional, the label of the concurrent assertion statement, or None if it has none.

Return type:

None

classmethod parse(assertNode, label)[source]

Translates the IIR node of the assertion to a ConcurrentAssertStatement.

Parameters:
  • assertNode (Iir) – The IIR node of the assertion.

  • label (str) – The statement’s label, or None if it has none.

Return type:

Self

Returns:

The translated assertion.

_iirNode

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

_position

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

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

Read-only property to access the condition of a statement (_condition).

Returns:

The expression representing the condition of a statement.

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=None)

Return the class’ methods that carry at least one matching attribute.

Parameters:

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

Return type:

dict[Callable[..., Any], 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 Label: str | None

Read-only property to access the model entity’s label (_label).

Returns:

Label of a model entity.

property Message: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the message (_message).

Returns:

The message, or None if not set.

property NormalizedLabel: str | None

Read-only property to access the model entity’s normalized label (_normalizedLabel).

Returns:

Normalized label of a model entity.

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: Position

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 Severity: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal | None

Read-only property to access the severity (_severity).

Returns:

The severity, or None if not set.

Visit(visitor)[source]

Walk this concurrent assertion, its condition, its message and its severity with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitAssertion(visitor)

Walk the condition, the message and the severity of an assertion with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_VisitReportAndSeverity(visitor)

Walk the message and the severity, if given, each after its reserved word, with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

Return the object’s state for pickling, collecting every slot of the class hierarchy.

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If a slot was never assigned, so it has no value to serialize.

__new__(**kwargs)
__setstate__(state)

Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.

Parameters:

state (dict[str, Any]) – Dictionary of slot names and their values.

Raises:

ExtendedTypeError – If the given state misses a slot or carries an unexpected one.

Return type:

None

_condition

The condition guarding this statement.

_label

The label of a model entity.

_message

The reported message, or None if none was given.

_normalizedLabel

The normalized (lower case) label of a model entity.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_severity

The reported severity level, or None if none was given.