pyGHDL.dom.Concurrent
This module implements derived concurrent statement classes from pyVHDLModel.Concurrent.
Classes
GenericAssociationItem: This class implements apyGHDL.domobject derived frompyVHDLModel.Association.GenericAssociationItem.PortAssociationItem: This class implements apyGHDL.domobject derived frompyVHDLModel.Association.PortAssociationItem.ParameterAssociationItem: This class implements apyGHDL.domobject derived frompyVHDLModel.Association.ParameterAssociationItem.ComponentInstantiation: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ComponentInstantiation.EntityInstantiation: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.EntityInstantiation.ConfigurationInstantiation: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConfigurationInstantiation.ConcurrentBlockStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentBlockStatement.ProcessStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ProcessStatement.IfGenerateBranch: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.IfGenerateBranch.ElsifGenerateBranch: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ElsifGenerateBranch.ElseGenerateBranch: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ElseGenerateBranch.IfGenerateStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.IfGenerateStatement.IndexedGenerateChoice: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.IndexedGenerateChoice.RangedGenerateChoice: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.RangedGenerateChoice.GenerateCase: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.GenerateCase.OthersGenerateCase: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.OthersGenerateCase.CaseGenerateStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.CaseGenerateStatement.ForGenerateStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ForGenerateStatement.WaveformElement: This class implements apyGHDL.domobject derived frompyVHDLModel.Base.WaveformElement.ConditionalWaveform: This class implements apyGHDL.domobject derived frompyVHDLModel.Common.ConditionalWaveform.SelectedWaveform: This class implements apyGHDL.domobject derived frompyVHDLModel.Common.SelectedWaveform.OthersSelectedWaveform: This class implements apyGHDL.domobject derived frompyVHDLModel.Common.OthersSelectedWaveform.ConcurrentSimpleSignalAssignment: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentSimpleSignalAssignment.ConcurrentConditionalSignalAssignment: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentConditionalSignalAssignment.ConcurrentSelectedSignalAssignment: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentSelectedSignalAssignment.ConcurrentProcedureCall: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentProcedureCall.ConcurrentAssertStatement: This class implements apyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentAssertStatement.
Classes
- class pyGHDL.dom.Concurrent.GenericAssociationItem(associationNode, formal, actual)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Association.GenericAssociationItem.A base-class for all generic association items used in generic map aspects.
Inheritance
- __init__(associationNode, formal, actual)[source]
Initializes a generic association item.
- Parameters:
- Return type:
None
- _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:
- Returns:
The new association item.
- property Formal: Name | Symbol | None
Read-only property to access the formal (
_formal).- Returns:
The formal, or
Noneif not set.
- GetAncestor(type)
Return the closest ancestor of the given
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the association item.
Format:
formal => actual, oractualalone when positional- Return type:
- Returns:
Formatted association item.
- _actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
The actual part of this 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.domobject derived frompyVHDLModel.Association.PortAssociationItem.A base-class for all port association items used in port map aspects.
Inheritance
- __init__(associationNode, formal, actual)[source]
Initializes a port association item.
- Parameters:
- Return type:
None
- _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:
- Returns:
The new association item.
- property Formal: Name | Symbol | None
Read-only property to access the formal (
_formal).- Returns:
The formal, or
Noneif not set.
- GetAncestor(type)
Return the closest ancestor of the given
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the association item.
Format:
formal => actual, oractualalone when positional- Return type:
- Returns:
Formatted association item.
- _actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
The actual part of this 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.domobject derived frompyVHDLModel.Association.ParameterAssociationItem.A base-class for all parameter association items used in parameter map aspects.
Inheritance
- __init__(associationNode, formal, actual)[source]
Initializes a parameter association item.
- Parameters:
- Return type:
None
- _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:
- Returns:
The new association item.
- property Formal: Name | Symbol | None
Read-only property to access the formal (
_formal).- Returns:
The formal, or
Noneif not set.
- GetAncestor(type)
Return the closest ancestor of the given
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the association item.
Format:
formal => actual, oractualalone when positional- Return type:
- Returns:
Formatted association item.
- _actual: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
The actual part of this 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.domobject derived frompyVHDLModel.Concurrent.ComponentInstantiation.Represents a component instantiation.
The instantiated component is available as
Component, the associations asGenericAssociationItemsandPortAssociationItems. The label is mandatory.Example
inst : component Counter; --^^^^ <- Label -- ^^^^^^^ <- Component
Inheritance
- 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.
- _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:
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:
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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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, from0(first) to the number of port associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last port association.portAssociationItem (
PortAssociationItem) – The port association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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
_positionis 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:
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:
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.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitMapAspects(visitor)
Walk the generic map aspect and the port map aspect of this instantiation with a visitor.
- _VisitPortMapAspect(visitor)
Walk the port map aspect, if there are port associations, with a visitor.
The associations are separated by commas.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _component: ComponentInstantiationSymbol
Reference to the instantiated component.
- _genericAssociationItems: list[GenericAssociationItem]
List of all generic associations.
- _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.domobject derived frompyVHDLModel.Concurrent.EntityInstantiation.Represents a direct entity instantiation.
The instantiated entity is available as
Entityand the optionally selected architecture asArchitecture. The label is mandatory.Example
inst : entity work.Counter(rtl); --^^^^ <- Label -- ^^^^^^^^^^^^ <- Entity -- ^^^ <- optional Architecture
Inheritance
- Parameters:
instantiationNode (Iir)
label (str)
entitySymbol (EntityInstantiationSymbol)
architectureSymbol (ArchitectureSymbol)
genericAssociationItems (Iterable[AssociationItem])
portAssociationItems (Iterable[AssociationItem])
- __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.
- _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:
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:
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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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, from0(first) to the number of port associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last port association.portAssociationItem (
PortAssociationItem) – The port association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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
_positionis 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:
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:
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.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitMapAspects(visitor)
Walk the generic map aspect and the port map aspect of this instantiation with a visitor.
- _VisitPortMapAspect(visitor)
Walk the port map aspect, if there are port associations, with a visitor.
The associations are separated by commas.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.
- _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.domobject derived frompyVHDLModel.Concurrent.ConfigurationInstantiation.Represents a configuration instantiation.
The instantiated configuration is available as
Configuration. The label is mandatory.Example
inst : configuration Counter; --^^^^ <- Label -- ^^^^^^^ <- Configuration
Inheritance
- 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.
- _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:
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:
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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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, from0(first) to the number of port associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last port association.portAssociationItem (
PortAssociationItem) – The port association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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
_positionis 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:
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:
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.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitMapAspects(visitor)
Walk the generic map aspect and the port map aspect of this instantiation with a visitor.
- _VisitPortMapAspect(visitor)
Walk the port map aspect, if there are port associations, with a visitor.
The associations are separated by commas.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _configuration: ConfigurationInstantiationSymbol
Reference to the instantiated configuration.
- _genericAssociationItems: list[GenericAssociationItem]
List of all generic associations.
- _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.domobject derived frompyVHDLModel.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;
See also
Inheritance
- Parameters:
- __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.
- _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:
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:
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:
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:
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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
index (
int) – Position, from0(first) toGenericCount(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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, from0(first) to the number of port associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last port association.portAssociationItem (
PortAssociationItem) – The port association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
index (
int) – Position, from0(first) toPortCount(append). A negative index counts from the end, as forlist.insert():-1inserts before the last port.portItem (
PortSignalInterfaceItem) – The port to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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:
- 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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) toGenericCountminus one (last). A negative index counts from the end, as for alistindex:-1moves 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.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:
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, from0(first) toPortCountminus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
_positionis 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:
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:
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:
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:
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:
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:
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.
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:
- 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:
- 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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- Returns:
List of declared items, in declaration order.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Block,)
Reserved words after
end.
- _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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- Return type:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitPortClause(visitor)
Walk the port clause, if there are ports, with a visitor.
The ports are separated by semicolons.
- _VisitPortMapAspect(visitor)
Walk the port map aspect, if there are port associations, with a visitor.
The associations are separated by commas.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
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.domobject derived frompyVHDLModel.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
- Parameters:
- __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, orNoneif 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, orNoneif 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.
- _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:
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:
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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_namespacefirst. 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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- 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:
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:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- 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:
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
_positionis 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:
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:
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- Returns:
List of declared items, in declaration order.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Process,)
Reserved words after
end.
- _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:
- _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:
- _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:
- _LabelRegion()[source]
Return the process, whose declarative region declares the labels of its statements.
- Return type:
- 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:
- 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:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the sequential statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()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
Noneif 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.domobject derived frompyVHDLModel.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
- Parameters:
- __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.
- _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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- property AlternativeLabel: str | None
Read-only property to access the alternative label (
_alternativeLabel).- Returns:
The alternative label, or
Noneif 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
Noneif 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
_positionis 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:
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:
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.
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
- _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.
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.domobject derived frompyVHDLModel.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
- Parameters:
- __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.
- _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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- property AlternativeLabel: str | None
Read-only property to access the alternative label (
_alternativeLabel).- Returns:
The alternative label, or
Noneif 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
Noneif 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
_positionis 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:
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:
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.
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
- _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.
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.domobject derived frompyVHDLModel.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
- Parameters:
- __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.
- _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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- property AlternativeLabel: str | None
Read-only property to access the alternative label (
_alternativeLabel).- Returns:
The alternative label, or
Noneif 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
Noneif 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
_positionis 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:
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:
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.
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
- _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.
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.domobject derived frompyVHDLModel.Concurrent.IfGenerateStatement.Represents an if-generate statement.
It has one
ifbranch (IfBranch), any number ofelsifbranches (ElsifBranches) and an optionalelsebranch (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;
See also
Inheritance
- Parameters:
generateNode (Iir)
label (str)
ifBranch (IfGenerateBranch)
elsifBranches (Iterable[ElsifGenerateBranch])
elseBranch (ElseGenerateBranch)
- __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, orNoneif none was given.
- Return type:
None
- classmethod parse(generateNode, label)[source]
Translates the IIR node of the generate statement to an
IfGenerateStatement.
- _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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- property ElseBranch: ElseGenerateBranch | None
Read-only property to access the else branch (
_elseBranch).- Returns:
The else branch, or
Noneif 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Generate,)
Reserved words after
end.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _elseBranch: ElseGenerateBranch | None
The optional
elsebranch, orNoneif none was given.
- _elsifBranches: list[ElsifGenerateBranch]
List of all
elsifbranches, in the order they were written.
- _ifBranch: IfGenerateBranch
The mandatory
ifbranch.
- _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.domobject derived frompyVHDLModel.Concurrent.IndexedGenerateChoice.Represents a case-generate choice given by a single value.
The value is available as
Expression.Example
when 8 => -- ^ <- Expression
Inheritance
- 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
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the indexed case-generate choice.
Format:
0- Return type:
- 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.domobject derived frompyVHDLModel.Concurrent.RangedGenerateChoice.Represents a case-generate choice given by a range.
The range is available as
Range.Example
when 0 to 3 => -- ^^^^^^ <- Range
Inheritance
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the ranged case-generate choice.
Format:
0 to 3- Return type:
- Returns:
Formatted ranged case-generate choice.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Concurrent.GenerateCase(node, choices, declaredItems=None, statements=None, alternativeLabel=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Concurrent.GenerateCase.Represents one alternative of a case-generate statement, selected by its choices.
Example
when 8 => -- ^ <- Choices
Inheritance
- Parameters:
- __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:
- 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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
_positionis 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:
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:
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.
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the case-generate alternative.
Format:
when 0 | 1 =>- Return type:
- Returns:
Formatted case-generate alternative.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
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.domobject derived frompyVHDLModel.Concurrent.OthersGenerateCase.Represents the
othersalternative of a case-generate statement.It covers every choice not named explicitly.
Example
when others => -- ^^^^^^ <- the choice
Inheritance
- Parameters:
- __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.
- _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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
_positionis 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:
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:
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.
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:
- 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
otherscase-generate alternative, its declared items and its statements with a visitor.
- _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:
- _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:
- _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:
- 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:
- 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:
- 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the
otherscase-generate alternative.Format:
when others =>- Return type:
- Returns:
Formatted
otherscase-generate alternative.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
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.domobject derived frompyVHDLModel.Concurrent.CaseGenerateStatement.Represents a case-generate statement.
The expression being tested is available as
SelectExpression, the alternatives asCases. 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
- Parameters:
- __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.
- _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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Generate,)
Reserved words after
end.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.
- _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.domobject derived frompyVHDLModel.Concurrent.ForGenerateStatement.Represents a for-generate statement.
The loop index is available as
LoopIndex, the iteration range asRangeand the generated statements asStatements. The label is mandatory.Example
gen : for i in 0 to 3 generate --^^^ <- Label -- ^ <- LoopIndex -- ^^^^^^ <- Range q(i) <= '0'; -- ^^^^^^^^^^^^ <- Statements end generate;
Inheritance
- Parameters:
- __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.
- _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:
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:
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
If allow blackbox property is locally set, return the local value,
Otherwise, return allow blackbox value from parent object.
- 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Clear all lookup tables and remove all declared items from
_namespace. Interface items and imported items stay in the namespace.Iterate all declared items:
Every declared item is added to
_namespace, except a protected type body.If the declared item is a
ProtectedTypeBody, skip it: it completes its protected type.If the declared item is a
FullType, then add an entry to_types.If the declared item is a
Subtype, then add an entry to_subtypes.If the declared item is a
Function, then add an entry to_functions.If the declared item is a
Procedure, then add an entry to_procedures.If the declared item is a
Constant, then add an entry to_constants.If the declared item is a
Signal, then add an entry to_signals.If the declared item is a
Variable, TODO.If the declared item is a
SharedVariable, then add an entry to_sharedVariables.If the declared item is a
File, then add an entry to_files.If the declared item is neither of these types, call
_IndexOtherDeclaredItem().
Derived classes may override this virtual function.
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
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- 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:
- 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, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
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:
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, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
ConcurrentStatement) – The concurrent statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.after (
ConcurrentStatement) – The statement of this construct to insert after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to insert.before (
ConcurrentStatement) – The statement of this construct to insert before.
- 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:
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, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
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:
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, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves 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.ValueError – If parameter ‘index’ is out of range.
- Return type:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.after (
ConcurrentStatement) – The statement of this construct to move after.
- 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:
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:
statement (
ConcurrentStatement) – The concurrent statement to move.before (
ConcurrentStatement) – The statement of this construct to move before.
- 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:
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
_positionis 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:
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:
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.
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:
- 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.
- _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:
- _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:
- _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:
- 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:
- 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:
- Returns:
List of declared items, in declaration order.
- _END_KEYWORDS = (ReservedWord.Generate,)
Reserved words after
end.
- _END_KEYWORDS_OPTIONAL = False
The reserved words after
endare 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:
- _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:
- _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:
- _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:
- _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:
- Returns:
Tuple of labeled statements, in statement order.
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:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- 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:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- 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:
- _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:
- _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:
- _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:
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:
- 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:
- _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:
- _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:
- _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:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitStatements(visitor)
Walk the concurrent statements in statement order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _allowBlackbox
Allow blackboxes for components;
Noneinherits the parent’s setting.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _areStatementsIndexed
TrueifIndexStatements()filled_instantiationsand_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.
- _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.
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.domobject derived frompyVHDLModel.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
See also
Inheritance
- 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
Noneif 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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _after: ExpressionUnion
The delay after which the value is assigned, or
Noneif 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.domobject derived frompyVHDLModel.Common.ConditionalWaveform.Represents one branch of a conditional signal assignment.
Each branch pairs a waveform (
Waveform) with a condition (Condition). The final branch has nowhen, so its condition isNone.Example
s <= '1' when cond else '0'; -- ^^^^^^^^^^^^^ <- this branch: Waveform=['1'], Condition=cond -- ^^^ <- final branch (no ``when``): Waveform=['0'], Condition=None
See also
Inheritance
- Parameters:
node (Iir)
waveform (Iterable[WaveformElement])
condition (ExpressionUnion)
- __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.
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.domobject derived frompyVHDLModel.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']
See also
Inheritance
- Parameters:
node (Iir)
choices (Iterable)
waveform (Iterable[WaveformElement])
- __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
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.domobject derived frompyVHDLModel.Common.OthersSelectedWaveform.Represents the
othersalternative 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
- Parameters:
node (Iir)
waveform (Iterable[WaveformElement])
- __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
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.domobject derived frompyVHDLModel.Concurrent.ConcurrentSimpleSignalAssignment.Represents a simple concurrent signal assignment.
The assignment’s destination is available as
Target, its value asWaveform.Example
lbl : q <= '1'; --^^^ <- optional Label -- ^ <- Target -- ^^^ <- Waveform
See also
Inheritance
- Parameters:
assignmentNode (Iir)
label (str)
target (SignalSymbol)
waveform (Iterable[WaveformElement])
- __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, orNoneif 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.
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- 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.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _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.ConcurrentConditionalSignalAssignment(assignmentNode, label, target, conditionalWaveforms)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentConditionalSignalAssignment.Represents a conditional concurrent signal assignment.
The alternatives are available as
ConditionalWaveforms, a list ofConditionalWaveform. 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
- Parameters:
assignmentNode (Iir)
label (str)
target (SignalSymbol)
conditionalWaveforms (Iterable[ConditionalWaveform])
- __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, orNoneif 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.
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- _VisitConditionalWaveforms(visitor)
Walk the conditional waveforms, separated by the reserved word
else, with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _conditionalWaveforms: list[ConditionalWaveform]
All alternatives, in order.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Concurrent.ConcurrentSelectedSignalAssignment(assignmentNode, label, target, expression, selectedWaveforms)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentSelectedSignalAssignment.Represents a selected concurrent signal assignment.
The selector is available as
Expression, the alternatives asSelectedWaveforms, a list ofSelectedWaveform. 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]
See also
Inheritance
- 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, orNoneif 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.
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
_positionis 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.
- _VisitSelectedWaveforms(visitor)
Walk the selected waveforms, separated by commas, with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
The expression held by this construct.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- _selectedWaveforms: list[SelectedWaveform | OthersSelectedWaveform]
All alternatives, in order.
- class pyGHDL.dom.Concurrent.ConcurrentProcedureCall(callNode, label, procedureName, parameterAssociationItems)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.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
See also
Inheritance
- __init__(callNode, label, procedureName, parameterAssociationItems)[source]
Initializes a concurrent procedure call.
- Parameters:
- Return type:
None
- classmethod parse(concurrentCallNode, label)[source]
Translates the IIR node of the concurrent procedure call to a
ConcurrentProcedureCall.
- _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:
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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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, from0(first) to the number of parameter associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter association.parameterAssociationItem (
ParameterAssociationItem) – The parameter association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.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:
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
_positionis 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:
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.
- _VisitProcedureCall(visitor)
Walk the called procedure and the actual parameter part, if there are parameters, with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _parameterAssociationItems: list[ParameterAssociationItem]
List of all parameter associations of the call.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Concurrent.ConcurrentAssertStatement(assertNode, condition, message=None, severity=None, label=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Concurrent.ConcurrentAssertStatement.Represents a concurrent assertion statement.
The checked condition is available as
Condition, the optional report string asMessageand the optional severity asSeverity.Example
lbl : assert cond report "bad" severity note; --^^^ <- optional Label -- ^^^^ <- Condition -- ^^^^^ <- optional Message -- ^^^^ <- optional Severity
See also
Inheritance
- Parameters:
- __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
Noneif none was given.severity (BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal) – Optional, the reported severity level, or
Noneif none was given.label (
str) – Optional, the label of the concurrent assertion statement, orNoneif it has none.
- Return type:
None
- classmethod parse(assertNode, label)[source]
Translates the IIR node of the assertion to a
ConcurrentAssertStatement.
- _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
typefound 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:
- 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, orNoneto accept every attribute.- Return type:
- 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
Noneif 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
_positionis 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
Noneif not set.
- Visit(visitor)[source]
Walk this concurrent assertion, its condition, its message and its severity with a visitor.
- _VisitAssertion(visitor)
Walk the condition, the message and the severity of an assertion with a visitor.
- _VisitReportAndSeverity(visitor)
Walk the message and the severity, if given, each after its reserved word, with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- _condition
The condition guarding this statement.
- _label
The label of a model entity.
- _message
The reported message, or
Noneif 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
Noneif none was given.