pyVHDLModel.Declaration
This module contains parts of an abstract document language model for VHDL.
Classes
EntityClass: AnEntityClassis an enumeration. It represents a VHDL language entity class (entity,label, …).Attribute: Represents an attribute declaration.AttributeSpecification: Represents an attribute specification.Alias: Represents an alias declaration.
Classes
- class pyVHDLModel.Declaration.EntityClass(*values)[source]
An
EntityClassis an enumeration. It represents a VHDL language entity class (entity,label, …).Inheritance
- Entity = 0
Entity
- Architecture = 1
Architecture
- Configuration = 2
Configuration
- Procedure = 3
Procedure
- Function = 4
Function
- Package = 5
Package
- Type = 6
Type
- Subtype = 7
Subtype
- Constant = 8
Constant
- Signal = 9
Signal
- Variable = 10
Variable
- Component = 11
Component
- Label = 12
Label
- Literal = 13
Literal
- Units = 14
Units
- Group = 15
Group
- File = 16
File
- Property = 17
Property
- Sequence = 18
Sequence
- View = 19
View
- Others = 20
Others
- __RESERVED_WORDS: ClassVar[dict[int, ReservedWord]] = {0: ReservedWord.Entity, 1: ReservedWord.Architecture, 2: ReservedWord.Configuration, 3: ReservedWord.Procedure, 4: ReservedWord.Function, 5: ReservedWord.Package, 6: ReservedWord.Type, 7: ReservedWord.Subtype, 8: ReservedWord.Constant, 9: ReservedWord.Signal, 10: ReservedWord.Variable, 11: ReservedWord.Component, 12: ReservedWord.Label, 13: ReservedWord.Literal, 14: ReservedWord.Units, 15: ReservedWord.Group, 16: ReservedWord.File, 17: ReservedWord.Property, 18: ReservedWord.Sequence, 19: ReservedWord.View}
The reserved word of each entity class, by value;
Othershas none.
- property ReservedWord: ReservedWord | None
Read-only property to return the reserved word of the entity class.
- Returns:
The reserved word, or
NoneforEntityClass.Others.
- classmethod __contains__(value)
Return True if value is in cls.
value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)
- class pyVHDLModel.Declaration.Attribute(identifier, subtype, documentation=None, parent=None)[source]
Represents an attribute declaration.
Example
attribute TotalBits : natural;
Inheritance
- Parameters:
identifier (str)
subtype (Symbol)
documentation (Nullable[str])
parent (Nullable[ModelEntity])
- __init__(identifier, subtype, documentation=None, parent=None)[source]
Initializes an attribute declaration.
- __str__()[source]
Formats the attribute declaration.
Format:
attribute myAttribute: bit- Return type:
- Returns:
Formatted attribute declaration.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- 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 Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).- Returns:
Normalized name 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.
- __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.
- class pyVHDLModel.Declaration.AttributeSpecification(identifiers, attribute, entityClass, expression, documentation=None, parent=None)[source]
Represents an attribute specification.
Example
attribute TotalBits of BusType : subtype is 32;
Inheritance
- Parameters:
identifiers (Iterable[Name])
attribute (Name)
entityClass (EntityClass)
expression (ExpressionUnion)
documentation (Nullable[str])
parent (Nullable[ModelEntity])
- __init__(identifiers, attribute, entityClass, expression, documentation=None, parent=None)[source]
Initializes an attribute specification.
- Parameters:
identifiers (
Iterable[Name]) – List of all names the attribute is specified for.attribute (
Name) – Reference to the specified attribute.entityClass (
EntityClass) – The entity class the named items belong to.expression (
BaseExpression|QualifiedExpression|FunctionCall|TypeConversion|Literal) – The value assigned to the attribute.documentation (
str|None) – The documentation comment associated with this declaration.parent (
ModelEntity|None) – The parent model entity of this entity.
- Return type:
None
- _entityClass: EntityClass
The entity class the named items belong to.
- _expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
The value assigned to the attribute.
- Visit(visitor)[source]
Walk this attribute specification, its attribute, its entity specification and its expression with a visitor.
- property Identifiers: list[Name]
Read-only property to access the identifiers (
_identifiers).- Returns:
List of identifiers.
- property Attribute: Name
Read-only property to access the attribute (
_attribute).- Returns:
The attribute.
- property EntityClass: EntityClass
Read-only property to access the entity class (
_entityClass).- Returns:
The entity class.
- property Expression: BaseExpression | QualifiedExpression | FunctionCall | TypeConversion | Literal
Read-only property to access the expression (
_expression).- Returns:
The expression.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- 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.
- __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.
- class pyVHDLModel.Declaration.Alias(identifier, name, subtype=None, documentation=None, parent=None)[source]
Represents an alias declaration.
Nameis aSymbol- like every other cross-reference in this model - rather than a bareName, so it participates in the usual resolve-later mechanism (Reference/IsResolved). UnlikePackageReferenceSymboland similar, there is no single fixedPossibleReferencevalue that always fits: an alias without a subtype indication can refer to almost anything nameable (an object, a type, a subprogram, a literal, …), while an alias with a subtype indication can - per the LRM - only ever refer to an object (a constant, variable, signal, or file); thepossibleReferencespassed to theSymbolshould reflect whichever case applies.Example
alias a : bit_vector(3 downto 0) is s(3 downto 0); -- ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ -- optional Subtype Name alias b is s; -- ^ -- Name
Inheritance
- Parameters:
identifier (str)
name (Symbol)
subtype (Nullable[SubtypeSymbol])
documentation (Nullable[str])
parent (Nullable[ModelEntity])
- __init__(identifier, name, subtype=None, documentation=None, parent=None)[source]
Initializes an alias declaration.
- Parameters:
identifier (
str) – The identifier of a model entity.name (
Symbol) – Reference to the name being aliased.subtype (
SubtypeSymbol|None) – Reference to the alias’ subtype, orNoneif none was given.documentation (
str|None) – The documentation comment associated with this declaration.parent (
ModelEntity|None) – The parent model entity of this entity.
- Return type:
None
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- 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 Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).- Returns:
Normalized name 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.
- __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.
- _subtype: SubtypeSymbol | None
Reference to the alias’ subtype, or
Noneif none was given.
- Visit(visitor)[source]
Walk this alias declaration, its subtype (if any) and its name with a visitor.
- property Subtype: SubtypeSymbol | None
Read-only property to access the subtype (
_subtype).- Returns:
The subtype, or
Noneif not set.