pyGHDL.dom.PSL

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

Classes


Classes

class pyGHDL.dom.PSL.VerificationUnit(node, identifier)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.PSLModel.VerificationUnit.

Represents a PSL verification unit (vunit).

Inheritance

Inheritance diagram of VerificationUnit

Parameters:
__init__(node, identifier)[source]

Initializes a PSL verification unit (vunit).

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The verification unit’s identifier.

Return type:

None

classmethod parse(vunitNode)[source]

Translates the IIR node of the verification unit to a VerificationUnit.

Parameters:

vunitNode (Iir) – The IIR node of the verification unit.

Returns:

The translated verification unit.

_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.

AddContextItem(contextItem)

Add a context item at the end of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to add.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

InsertContextItem()

→ Insert a context item at a position of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

property ContextItems: list[LibraryClause | UseClause | ContextReference]

Read-only property to access the sequence of all context items comprising library, use and context clauses (_contextItems).

Returns:

Sequence of context items.

property ContextReferences: list[ContextReference]

Read-only property to access the sequence of context clauses (_contextReferences).

Returns:

Sequence of context clauses.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

property DependencyVertex: Vertex

Read-only property to access the corresponding dependency vertex (_dependencyVertex).

The dependency vertex references this design unit by its value field.

Returns:

The corresponding dependency vertex.

property Document: Document

Property to access the document (_document).

Returns:

The document.

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 type found by walking the parent chain upwards.

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

GetIdentifier(normalizedIdentifier)

Return the identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier in its declared spelling.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property HierarchyVertex: Vertex

Read-only property to access the corresponding hierarchy vertex (_hierarchyVertex).

The hierarchy vertex references this design unit by its value field.

Returns:

The corresponding hierarchy vertex.

property Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

InsertContextItem(index, contextItem)

Insert a context item at a position of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

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

  • contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to insert.

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

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

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

  • ValueError – If parameter ‘contextItem’ is None.

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

IsLibraryVisible(libraryIdentifier)

Check if the logical name of a library is visible in this design unit.

The name work is implicitly visible, the name std too, except in a context declaration. Every other name needs a library clause, also the real name of the working library. The library clause is searched in this design unit’s context clause, in the context clause of its primary unit, and in the contexts these reference, also in nested ones. The design unit must be in a library of a design.

Parameters:

libraryIdentifier (str) – The normalized identifier of the library.

Return type:

bool

Returns:

True, if the library’s name is visible.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property Library: Library

Property to access the library (_parent).

Returns:

The library.

property LibraryReferences: list[LibraryClause]

Read-only property to access the sequence of library clauses (_libraryReferences).

Returns:

Sequence of library clauses.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property PackageReferences: list[UseClause]

Read-only property to access the sequence of use clauses (_packageReferences).

Returns:

Sequence of use clauses.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property ReferencedContexts: dict[str, Context]

Read-only property to access the referenced contexts (_referencedContexts).

Returns:

Dictionary of referenced contexts, indexed by normalized identifier.

property ReferencedLibraries: dict[str, Library]

Read-only property to access the referenced libraries (_referencedLibraries).

Returns:

Dictionary of referenced libraries, indexed by normalized identifier.

property ReferencedPackages: dict[str, Package]

Read-only property to access the referenced packages (_referencedPackages).

Returns:

Dictionary of referenced packages, indexed by normalized identifier.

RemoveContextItem(contextItem)

Remove a context item from the context clause.

The context item is detached: its parent is cleared, and it’s removed from ContextItems and from LibraryReferences, PackageReferences or ContextReferences. The context item itself is unchanged and can be added to another design unit, or inserted at another position.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to remove.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

  • NotAChildError – If parameter ‘contextItem’ is not a context item of this design unit.

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

InsertContextItem()

→ Insert a context item at a position of the context clause.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

Visit(visitor)

Walk this model element with a visitor.

A model class implements its walk; a class without one raises.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Raises:

NotImplementedError – Always, because the element’s class has no walk of its own.

Return type:

None

_CONTINUES_PARENT_REGION: ClassVar[bool] = False

True if it continues its parent’s declarative region.

_ContextClauseUnits()

Return the design units whose context clause applies to this design unit.

Return type:

tuple[DesignUnit, ...]

Returns:

Tuple of this design unit.

_IMPLICIT_LIBRARIES: ClassVar[tuple[str, ...]] = ('work', 'std')

Library names visible without a library clause.

_VisitContextClause(visitor)

Walk the context clause, i.e. the context items preceding the design unit, with a visitor.

The context clause is reported, even if it has no context items.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()[source]

Formats the verification unit declaration.

Format: vunit myUnit

Return type:

str

Returns:

Formatted verification unit declaration.

_contextItems: list[ContextUnion]

List of all context items (library, use and context clauses).

_contextReferences: list[ContextReference]

List of context clauses.

_dependencyVertex: Vertex

Reference to the vertex in the dependency graph representing the design unit.
This reference is set by CreateDependencyGraph().

_document: Document

The VHDL library, the design unit was analyzed into.

_documentation

The associated documentation of a model entity.

_hierarchyVertex: Vertex

The vertex in the hierarchy graph

_identifier

The identifier of a model entity.

_libraryReferences: list[LibraryClause]

List of library clauses.

_normalizedIdentifier

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

_packageReferences: list[UseClause]

List of use clauses.

_parent

Reference to a parent entity in the logical model hierarchy.

_referencedContexts: dict[str, Context]

Referenced contexts based on explicit context references or implicit inheritance

_referencedLibraries: dict[str, Library]

Referenced libraries based on explicit library clauses or implicit inheritance

_referencedPackages: dict[str, dict[str, Package]]

Referenced packages based on explicit use clauses or implicit inheritance

class pyGHDL.dom.PSL.VerificationProperty(node, identifier)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.PSLModel.VerificationProperty.

Represents a PSL verification property (vprop).

Inheritance

Inheritance diagram of VerificationProperty

Parameters:
__init__(node, identifier)[source]

Initializes a PSL verification property (vprop).

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The verification property’s identifier.

Return type:

None

classmethod parse(vpropNode)[source]

Translates the IIR node of the verification property to a VerificationProperty.

Parameters:

vpropNode (Iir) – The IIR node of the verification property.

Returns:

The translated verification property.

_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.

AddContextItem(contextItem)

Add a context item at the end of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to add.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

InsertContextItem()

→ Insert a context item at a position of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

property ContextItems: list[LibraryClause | UseClause | ContextReference]

Read-only property to access the sequence of all context items comprising library, use and context clauses (_contextItems).

Returns:

Sequence of context items.

property ContextReferences: list[ContextReference]

Read-only property to access the sequence of context clauses (_contextReferences).

Returns:

Sequence of context clauses.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

property DependencyVertex: Vertex

Read-only property to access the corresponding dependency vertex (_dependencyVertex).

The dependency vertex references this design unit by its value field.

Returns:

The corresponding dependency vertex.

property Document: Document

Property to access the document (_document).

Returns:

The document.

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 type found by walking the parent chain upwards.

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

GetIdentifier(normalizedIdentifier)

Return the identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier in its declared spelling.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property HierarchyVertex: Vertex

Read-only property to access the corresponding hierarchy vertex (_hierarchyVertex).

The hierarchy vertex references this design unit by its value field.

Returns:

The corresponding hierarchy vertex.

property Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

InsertContextItem(index, contextItem)

Insert a context item at a position of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

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

  • contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to insert.

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

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

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

  • ValueError – If parameter ‘contextItem’ is None.

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

IsLibraryVisible(libraryIdentifier)

Check if the logical name of a library is visible in this design unit.

The name work is implicitly visible, the name std too, except in a context declaration. Every other name needs a library clause, also the real name of the working library. The library clause is searched in this design unit’s context clause, in the context clause of its primary unit, and in the contexts these reference, also in nested ones. The design unit must be in a library of a design.

Parameters:

libraryIdentifier (str) – The normalized identifier of the library.

Return type:

bool

Returns:

True, if the library’s name is visible.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property Library: Library

Property to access the library (_parent).

Returns:

The library.

property LibraryReferences: list[LibraryClause]

Read-only property to access the sequence of library clauses (_libraryReferences).

Returns:

Sequence of library clauses.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property PackageReferences: list[UseClause]

Read-only property to access the sequence of use clauses (_packageReferences).

Returns:

Sequence of use clauses.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property ReferencedContexts: dict[str, Context]

Read-only property to access the referenced contexts (_referencedContexts).

Returns:

Dictionary of referenced contexts, indexed by normalized identifier.

property ReferencedLibraries: dict[str, Library]

Read-only property to access the referenced libraries (_referencedLibraries).

Returns:

Dictionary of referenced libraries, indexed by normalized identifier.

property ReferencedPackages: dict[str, Package]

Read-only property to access the referenced packages (_referencedPackages).

Returns:

Dictionary of referenced packages, indexed by normalized identifier.

RemoveContextItem(contextItem)

Remove a context item from the context clause.

The context item is detached: its parent is cleared, and it’s removed from ContextItems and from LibraryReferences, PackageReferences or ContextReferences. The context item itself is unchanged and can be added to another design unit, or inserted at another position.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to remove.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

  • NotAChildError – If parameter ‘contextItem’ is not a context item of this design unit.

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

InsertContextItem()

→ Insert a context item at a position of the context clause.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

Visit(visitor)

Walk this model element with a visitor.

A model class implements its walk; a class without one raises.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Raises:

NotImplementedError – Always, because the element’s class has no walk of its own.

Return type:

None

_CONTINUES_PARENT_REGION: ClassVar[bool] = False

True if it continues its parent’s declarative region.

_ContextClauseUnits()

Return the design units whose context clause applies to this design unit.

Return type:

tuple[DesignUnit, ...]

Returns:

Tuple of this design unit.

_IMPLICIT_LIBRARIES: ClassVar[tuple[str, ...]] = ('work', 'std')

Library names visible without a library clause.

_VisitContextClause(visitor)

Walk the context clause, i.e. the context items preceding the design unit, with a visitor.

The context clause is reported, even if it has no context items.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()[source]

Formats the verification property declaration.

Format: vprop myUnit

Return type:

str

Returns:

Formatted verification property declaration.

_contextItems: list[ContextUnion]

List of all context items (library, use and context clauses).

_contextReferences: list[ContextReference]

List of context clauses.

_dependencyVertex: Vertex

Reference to the vertex in the dependency graph representing the design unit.
This reference is set by CreateDependencyGraph().

_document: Document

The VHDL library, the design unit was analyzed into.

_documentation

The associated documentation of a model entity.

_hierarchyVertex: Vertex

The vertex in the hierarchy graph

_identifier

The identifier of a model entity.

_libraryReferences: list[LibraryClause]

List of library clauses.

_normalizedIdentifier

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

_packageReferences: list[UseClause]

List of use clauses.

_parent

Reference to a parent entity in the logical model hierarchy.

_referencedContexts: dict[str, Context]

Referenced contexts based on explicit context references or implicit inheritance

_referencedLibraries: dict[str, Library]

Referenced libraries based on explicit library clauses or implicit inheritance

_referencedPackages: dict[str, dict[str, Package]]

Referenced packages based on explicit use clauses or implicit inheritance

class pyGHDL.dom.PSL.VerificationMode(node, identifier)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.PSLModel.VerificationMode.

Represents a PSL verification mode (vmode).

Inheritance

Inheritance diagram of VerificationMode

Parameters:
__init__(node, identifier)[source]

Initializes a PSL verification mode (vmode).

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The verification mode’s identifier.

Return type:

None

classmethod parse(vmodeNode)[source]

Translates the IIR node of the verification mode to a VerificationMode.

Parameters:

vmodeNode (Iir) – The IIR node of the verification mode.

Returns:

The translated verification mode.

_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.

AddContextItem(contextItem)

Add a context item at the end of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to add.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

InsertContextItem()

→ Insert a context item at a position of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

property ContextItems: list[LibraryClause | UseClause | ContextReference]

Read-only property to access the sequence of all context items comprising library, use and context clauses (_contextItems).

Returns:

Sequence of context items.

property ContextReferences: list[ContextReference]

Read-only property to access the sequence of context clauses (_contextReferences).

Returns:

Sequence of context clauses.

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

property DependencyVertex: Vertex

Read-only property to access the corresponding dependency vertex (_dependencyVertex).

The dependency vertex references this design unit by its value field.

Returns:

The corresponding dependency vertex.

property Document: Document

Property to access the document (_document).

Returns:

The document.

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 type found by walking the parent chain upwards.

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

GetIdentifier(normalizedIdentifier)

Return the identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier in its declared spelling.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property HierarchyVertex: Vertex

Read-only property to access the corresponding hierarchy vertex (_hierarchyVertex).

The hierarchy vertex references this design unit by its value field.

Returns:

The corresponding hierarchy vertex.

property Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

InsertContextItem(index, contextItem)

Insert a context item at a position of the context clause.

The context item’s parent is set to this design unit. A library clause is also added to LibraryReferences, a use clause to PackageReferences and a context reference to ContextReferences, in the order of ContextItems. A context item may repeat an earlier one.

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

  • contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to insert.

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

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

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

  • ValueError – If parameter ‘contextItem’ is None.

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

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

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

RemoveContextItem()

→ Remove a context item from the context clause.

IsLibraryVisible(libraryIdentifier)

Check if the logical name of a library is visible in this design unit.

The name work is implicitly visible, the name std too, except in a context declaration. Every other name needs a library clause, also the real name of the working library. The library clause is searched in this design unit’s context clause, in the context clause of its primary unit, and in the contexts these reference, also in nested ones. The design unit must be in a library of a design.

Parameters:

libraryIdentifier (str) – The normalized identifier of the library.

Return type:

bool

Returns:

True, if the library’s name is visible.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property Library: Library

Property to access the library (_parent).

Returns:

The library.

property LibraryReferences: list[LibraryClause]

Read-only property to access the sequence of library clauses (_libraryReferences).

Returns:

Sequence of library clauses.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

Returns:

Normalized name of a model entity.

property PackageReferences: list[UseClause]

Read-only property to access the sequence of use clauses (_packageReferences).

Returns:

Sequence of use clauses.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

property ReferencedContexts: dict[str, Context]

Read-only property to access the referenced contexts (_referencedContexts).

Returns:

Dictionary of referenced contexts, indexed by normalized identifier.

property ReferencedLibraries: dict[str, Library]

Read-only property to access the referenced libraries (_referencedLibraries).

Returns:

Dictionary of referenced libraries, indexed by normalized identifier.

property ReferencedPackages: dict[str, Package]

Read-only property to access the referenced packages (_referencedPackages).

Returns:

Dictionary of referenced packages, indexed by normalized identifier.

RemoveContextItem(contextItem)

Remove a context item from the context clause.

The context item is detached: its parent is cleared, and it’s removed from ContextItems and from LibraryReferences, PackageReferences or ContextReferences. The context item itself is unchanged and can be added to another design unit, or inserted at another position.

Parameters:

contextItem (LibraryClause | UseClause | ContextReference) – The library clause, use clause or context reference to remove.

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

  • TypeError – If parameter ‘contextItem’ is not of type LibraryClause, UseClause or ContextReference.

  • NotAChildError – If parameter ‘contextItem’ is not a context item of this design unit.

Return type:

None

Attention

The mutator doesn’t update what Analyze() derived from the context items: the referenced libraries, packages and contexts (ReferencedLibraries, ReferencedPackages, ReferencedContexts), the namespace entries of a use clause, the edges of the dependency graph, and the references of the symbols. A design changed after its analysis needs a new analysis.

See also

AddContextItem()

→ Add a context item at the end of the context clause.

InsertContextItem()

→ Insert a context item at a position of the context clause.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

Visit(visitor)

Walk this model element with a visitor.

A model class implements its walk; a class without one raises.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Raises:

NotImplementedError – Always, because the element’s class has no walk of its own.

Return type:

None

_CONTINUES_PARENT_REGION: ClassVar[bool] = False

True if it continues its parent’s declarative region.

_ContextClauseUnits()

Return the design units whose context clause applies to this design unit.

Return type:

tuple[DesignUnit, ...]

Returns:

Tuple of this design unit.

_IMPLICIT_LIBRARIES: ClassVar[tuple[str, ...]] = ('work', 'std')

Library names visible without a library clause.

_VisitContextClause(visitor)

Walk the context clause, i.e. the context items preceding the design unit, with a visitor.

The context clause is reported, even if it has no context items.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()[source]

Formats the verification mode declaration.

Format: vmode myUnit

Return type:

str

Returns:

Formatted verification mode declaration.

_contextItems: list[ContextUnion]

List of all context items (library, use and context clauses).

_contextReferences: list[ContextReference]

List of context clauses.

_dependencyVertex: Vertex

Reference to the vertex in the dependency graph representing the design unit.
This reference is set by CreateDependencyGraph().

_document: Document

The VHDL library, the design unit was analyzed into.

_documentation

The associated documentation of a model entity.

_hierarchyVertex: Vertex

The vertex in the hierarchy graph

_identifier

The identifier of a model entity.

_libraryReferences: list[LibraryClause]

List of library clauses.

_normalizedIdentifier

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

_packageReferences: list[UseClause]

List of use clauses.

_parent

Reference to a parent entity in the logical model hierarchy.

_referencedContexts: dict[str, Context]

Referenced contexts based on explicit context references or implicit inheritance

_referencedLibraries: dict[str, Library]

Referenced libraries based on explicit library clauses or implicit inheritance

_referencedPackages: dict[str, dict[str, Package]]

Referenced packages based on explicit use clauses or implicit inheritance

class pyGHDL.dom.PSL.DefaultClock(node, identifier, documentation=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.PSLModel.DefaultClock.

Represents a PSL default clock declaration.

It names the clock expression used by PSL directives that do not state one themselves.

Inheritance

Inheritance diagram of DefaultClock

Parameters:
  • node (Iir)

  • identifier (str)

  • documentation (str)

__init__(node, identifier, documentation=None)[source]

Initializes a PSL default clock declaration.

Parameters:
  • node (Iir) – The IIR node this object was translated from.

  • identifier (str) – The default clock’s identifier.

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

Return type:

None

classmethod parse(defaultClockNode)[source]

Translates the IIR node of the PSL default clock to a DefaultClock.

A PSL default clock declaration (default clock is rising_edge(clk);) has no identifier. libghdl keeps the clock expression as a PSL node, which has no Python binding, so the clock expression’s source text (comments removed, whitespace collapsed) becomes the identifier: rising_edge(clk).

Parameters:

defaultClockNode (Iir) – The IIR node of the PSL default clock.

Returns:

The translated PSL default clock.

Raises:

DOMException – If the source text at the node’s location is no PSL default clock declaration.

_iirNode: Iir

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

_position: Position

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

DenoteBy(name, region, place, symbol)

Determine the model entity a name denoting this declaration denotes, as a part of a type mark (Name.Denote).

A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.

Parameters:
  • name (Name) – The name denoting this declaration, a part of the type mark.

  • region (DeclarativeRegionMixin) – The declarative region containing the type mark.

  • place (ModelEntity) – The declaration containing the type mark.

  • symbol (Symbol) – The type mark.

Return type:

ModelEntity | None

Returns:

None, as a name in a type mark can’t denote this declaration (reported as a warning).

Raises:

UnhandledCriticalWarningError – Always, if no WarningCollector collects the UnresolvedTypeMarkWarning.

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 type found by walking the parent chain upwards.

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

Parameters:

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

Return type:

ModelEntity

Returns:

The closest ancestor of the requested type.

Raises:

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

GetIdentifier(normalizedIdentifier)

Return the identifier as declared, for the model entity’s normalized identifier.

Parameters:

normalizedIdentifier (str) – The model entity’s normalized (lower case) identifier.

Return type:

str

Returns:

The identifier in its declared spelling.

classmethod GetMethodsWithAttributes(predicate=None)

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

Parameters:

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

Return type:

dict[Callable[..., Any], tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

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

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

property Identifier: str

Read-only property to access the model entity’s identifier (_identifier).

Returns:

Name of a model entity.

property IsOverloadable: bool

Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.

Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.

Returns:

True, if this model entity is an overloadable declaration.

IterateImplicitDeclarations()

Iterate the declarations this declaration implies.

An enumerated type implies its enumeration literals, a physical type its units; they override this method.

Return type:

Generator[tuple[str, ModelEntity]]

Returns:

A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.

IterateTypeMarks(region)

Iterate the type marks of this declaration, each with the region and the place to look it up.

The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.

Parameters:

region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

Generator[tuple[DeclarativeRegionMixin, ModelEntity, SubtypeSymbol]]

Returns:

A generator to iterate (region, place, type mark) tuples, in declaration order: none.

property NormalizedIdentifier: str

Read-only property to access the model entity’s normalized identifier (_normalizedIdentifier).

See also

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.

property Position: Position

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

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.

ResetReferences(designUnit, region)

Reset the references ResolveReferences() derived: the references of this declaration’s type marks.

A use clause, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Return type:

None

ResolveReferences(designUnit, region)

Resolve the references of this declaration: its type marks (IterateTypeMarks()).

Each type mark is resolved at its place by the region it is looked up in (ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.

Parameters:
  • designUnit (DesignUnit) – The design unit containing this declaration.

  • region (DeclarativeRegionMixin) – The declarative region declaring this declaration.

Raises:

UnhandledCriticalWarningError – If a type mark can’t be resolved, and no WarningCollector collects the UnresolvedTypeMarkWarning.

Return type:

None

Visit(visitor)

Walk this model element with a visitor.

A model class implements its walk; a class without one raises.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Raises:

NotImplementedError – Always, because the element’s class has no walk of its own.

Return type:

None

__getstate__()

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

Return type:

dict[str, Any]

Returns:

Dictionary of slot names and their values.

Raises:

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

__new__(**kwargs)
__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()[source]

Formats the default clock declaration.

Format: default clock myClock

Return type:

str

Returns:

Formatted default clock declaration.

_documentation: str | None

The associated documentation of a model entity.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

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

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.