pyGHDL.dom.NonStandard

This module implements the non-standard classes Design, Library and Document.

These three are not VHDL language constructs, but the entry points of pyGHDL.dom: a document reads and parses a source file through libghdl, a library groups documents, and a design owns the libraries.

Classes


Classes

class pyGHDL.dom.NonStandard.Design(name=None, vhdlVersion=2008, tabSize=8)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Design.

A Design represents set of VHDL libraries as well as all loaded and analysed source files (see Document).

It’s the root of this code document-object-model (CodeDOM). It contains at least one VHDL library (see Library). When the design is analysed (see Analyze()), multiple graph data structures will be created and populated with vertices and edges. As a first result, the design’s compile order and hierarchy can be iterated. As a second result, the design’s top-level is identified and referenced from the design (see TopLevel).

The design contains references to the following graphs:

Inheritance

Inheritance diagram of Design

Parameters:
_SUPPORTED_VHDL_VERSIONS = (2008, 2019)

VHDL versions currently supported by this class. Older revisions (87, 93, 2000, 2002) are not planned to be supported for now.

_VHDL_VERSION_TO_STD_OPTION = {2008: '08', 2019: '19'}

Mapping from a supported VHDLVersion to GHDL’s ‘–std=’ option value.

__init__(name=None, vhdlVersion=2008, tabSize=8)[source]

Initialize a VHDL design.

Parameters:
  • name (str) – Optional, name of the design.

  • vhdlVersion (VHDLVersion) – Optional, the VHDL version used to analyze this design.

  • tabSize (int) – Optional, the number of columns between two tab stops. Default: 8.

Raises:
  • DOMException – If parameter ‘vhdlVersion’ is not supported.

  • ValueError – If parameter ‘tabSize’ is None.

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

  • ValueError – If parameter ‘tabSize’ is out of range 1..120.

Return type:

None

_vhdlVersion: VHDLVersion

The VHDL version this design is analyzed with.

_tabSize: int

The number of columns between two tab stops.

_loadDefaultLibraryDuration: Duration | None

LoadDefaultLibraries()’ duration, None if not called.

_analyzeDuration: Duration | None

Duration of Analyze(), None if not called.

_warnings: List

Warnings raised by pyVHDLModel while the design is analyzed.

property VHDLVersion: VHDLVersion

Read-only property to access the VHDL version this design is analyzed with (_vhdlVersion).

The version is checked against _SUPPORTED_VHDL_VERSIONS when the design is created and is translated to GHDL’s --std= option value via _VHDL_VERSION_TO_STD_OPTION.

Returns:

The design’s VHDL version.

property TabSize: int

Read-only property to access the number of columns between two tab stops (_tabSize).

libghdl expands tabs with it when it computes columns, like the ones of messages and of comment continuation lines. The setting applies to libghdl as a whole, so to all documents loaded after this design was created.

Returns:

The design’s tab size.

__ghdl_init()

Initialization: set options and then load libraries.

LoadDefaultLibraries(flavor=None)[source]

Loads the std and ieee libraries into the design.

How long this took is measured and kept in _loadDefaultLibraryDuration.

Parameters:

flavor (IEEEFlavor | None) – Optional, the IEEE library flavor to load, or None for the default.

Analyze()[source]

Analyzes all documents of this design.

How long this took is measured and kept in _analyzeDuration, and the warnings pyVHDLModel raises during the analysis are collected in _warnings.

property LoadDefaultLibraryDuration: Duration | None

Read-only property to access the duration of LoadDefaultLibraries() (_loadDefaultLibraryDuration).

Returns:

The duration of loading the std and ieee libraries, or None if they weren’t loaded.

property AnalyzeDuration: Duration | None

Read-only property to access the duration of Analyze() (_analyzeDuration).

Returns:

The duration of the design’s analysis, or None if it wasn’t analyzed.

AddDocument(document, library)[source]

Add a document (VHDL source file) to the design and register all embedded design units to the given VHDL library.

All checks are done, before the design, the document or the library is changed.

Algorithm

  1. Check the document isn’t a document of a design, and the design contains no document of the same path.

  2. Check none of the document’s entities, architectures, packages, package bodies, configurations and contexts exists in the library.

  3. Add the document to the design and set the document’s library.

  4. Add the document’s entities, architectures, packages, package bodies, configurations and contexts to the library and update their library membership.

Parameters:
  • document (Document) – The VHDL source code file.

  • library (Library) – The VHDL library used to register the embedded design units to.

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

  • TypeError – If parameter ‘document’ is not of type Document.

  • AlreadyInDesignError – If parameter ‘document’ is already a document of a design.

  • DuplicateDocumentError – If the design already contains a document of the same path.

  • ValueError – If parameter ‘library’ is None.

  • TypeError – If parameter ‘library’ is not of type Library.

  • LibraryNotRegisteredError – If the given VHDL library is not a library in the design.

  • EntityExistsInLibraryError – If the processed entity’s name is already existing in the VHDL library.

  • ArchitectureExistsInLibraryError – If the processed architecture’s name is already existing in the VHDL library.

  • PackageExistsInLibraryError – If the processed package’s name is already existing in the VHDL library.

  • PackageBodyExistsError – If the processed package body’s name is already existing in the VHDL library.

  • ConfigurationExistsInLibraryError – If the processed configuration’s name is already existing in the VHDL library.

  • ContextExistsInLibraryError – If the processed context’s name is already existing in the VHDL library.

Return type:

None

See also

RemoveDocument()

→ Remove a document from the design.

AddLibrary(library)[source]

Add a VHDL library to the design.

Ensure the libraries name doesn’t collide with existing libraries in the design.
If ok, set the libraries parent reference to the design.

Parameters:

library (Library) – Library object to loaded.

Raises:
  • LibraryExistsInDesignError – If the library already exists in the design.

  • LibraryRegisteredToForeignDesignError – If library is already used by a different design.

Return type:

None

property AllowBlackbox: bool

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

Algorithm

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

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

Returns:

True, if blackboxes are allowed.

Raises:

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

Setter accepts:

bool | None

AnalyzeDependencies()[source]

Analyze the dependencies of design units.

Algorithm

  1. Create all vertices of the dependency graph by iterating all design units in all libraries.
    → CreateDependencyGraph()

  2. Create the compile order graph.
    → CreateCompileOrderGraph()

  3. Index all packages.
    → IndexPackages()

  4. Index all entities.
    → IndexEntities()

  5. Link all architectures.
    → LinkArchitectures()

  6. Index all architectures.
    → IndexArchitectures()

  7. Link all package bodies.
    → LinkPackageBodies()

  8. Index all package bodies.
    → IndexPackageBodies()

  9. Link all package instances.
    → LinkPackageInstances()

  10. Link all contexts.
    → LinkContexts()

  11. Link all library references.
    → LinkLibraryReferences()

  12. Link all package references.
    → LinkPackageReferences()

  13. Link all context references.
    → LinkContextReferences()

  14. Link all components.
    → LinkComponents()

  15. Link all instantiations.
    → LinkInstantiations()

  16. Create the hierarchy graph.
    → CreateHierarchyGraph()

  17. Compute the compile order.
    → ComputeCompileOrder()

Raises:

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

Return type:

None

AnalyzeObjects()[source]

Analyze the types and objects of the design.

It runs after the dependency analysis (AnalyzeDependencies()), which links the use clauses and computes the compile order.

Algorithm

  1. Resolve the type marks of all declarations.
    → ResolveTypeMarks()

Todo

  • Resolve the names in expressions, e.g. constants and generics in ranges and constraints, or signal attributes.

  • Build the type and object graph (ObjectGraph) from these references.

  • Wire the signals into a netlist.

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

  • UnhandledCriticalWarningError – If the name of an alias can’t be resolved, and no WarningCollector collects the UnresolvedNameWarning.

  • UnhandledCriticalWarningError – If an incomplete type has no full type declaration, and no WarningCollector collects the IncompleteTypeWarning.

Return type:

None

property CompileOrderGraph: Graph

Read-only property to access the compile-order graph (_compileOrderGraph).

Returns:

Reference to the compile-order graph.

CreateCompileOrderGraph()[source]

Create a compile-order graph with bidirectional references to the dependency graph.

Add vertices representing a document (VHDL source file) to the dependency graph. Each “document” vertex in dependency graph is copied into the compile-order graph and bidirectionally referenced.

In addition, each vertex of a corresponding design unit in a document is linked to the vertex representing that document to express the design unit in document relationship.

Each added vertex has the following properties:

  • The vertex’ ID is the document’s filename.

  • The vertex’ value references the document.

  • A key-value-pair called kind denotes the vertex’s kind as an enumeration value of type DependencyGraphVertexKind.

  • A key-value-pair called predefined does not exist.

Algorithm

  1. Iterate all documents in the design.

    • Create a vertex for that document with the document’s path as vertex ID and reference the document by the vertex’ value field.
      In return, set the documents’s _dependencyVertex field to reference the created vertex.

    • Copy the vertex from dependency graph to compile-order graph and link both vertices bidirectionally.
      In addition, set the documents’s _dependencyVertex field to reference the copied vertex.

      • Add a key-value-pair called compileOrderVertex to the dependency graph’s vertex.

      • Add a key-value-pair called dependencyVertex to the compiler-order graph’s vertex.

    1. Iterate the documents design units and create an edge from the design unit’s corresponding dependency vertex to the documents corresponding dependency vertex. This expresses a “design unit is located in document” relation.

      • Add a key-value-pair called kind` denoting the edge’s kind as an enumeration value of type DependencyGraphEdgeKind.

Return type:

None

CreateDependencyGraph()[source]

Create all vertices of the dependency graph by iterating all design units in all libraries.

This method will purely create a sea of vertices without any linking between vertices. The edges will be created later by other methods.
See AnalyzeDependencies() for these methods and their algorithmic order.

Each vertex has the following properties:

  • The vertex’ ID is the design unit’s identifier.

  • The vertex’ value references the design unit.

  • A key-value-pair called kind denotes the vertex’s kind as an enumeration value of type DependencyGraphVertexKind.

  • A key-value-pair called predefined denotes if the referenced design unit is a predefined language entity.

Algorithm

  1. Iterate all libraries in the design.

    • Create a vertex for that library and reference the library by the vertex’ value field.
      In return, set the library’s _dependencyVertex field to reference the created vertex.

    1. Iterate all contexts in that library.

      • Create a vertex for that context and reference the context by the vertex’ value field.
        In return, set the context’s _dependencyVertex field to reference the created vertex.

    2. Iterate all packages in that library.

      • Create a vertex for that package and reference the package by the vertex’ value field.
        In return, set the package’s _dependencyVertex field to reference the created vertex.

    3. Iterate all package bodies in that library.

      • Create a vertex for that package body and reference the package body by the vertex’ value field.
        In return, set the package body’s _dependencyVertex field to reference the created vertex.

    4. Iterate all entities in that library.

      • Create a vertex for that entity and reference the entity by the vertex’ value field.
        In return, set the entity’s _dependencyVertex field to reference the created vertex.

    5. Iterate all architectures in that library.

      • Create a vertex for that architecture and reference the architecture by the vertex’ value field.
        In return, set the architecture’s _dependencyVertex field to reference the created vertex.

    6. Iterate all configurations in that library.

      • Create a vertex for that configuration and reference the configuration by the vertex’ value field.
        In return, set the configuration’s _dependencyVertex field to reference the created vertex.

Return type:

None

CreateHierarchyGraph()[source]

Create the hierarchy graph from dependency graph.

Algorithm

  1. Iterate all vertices corresponding to entities and architectures in the dependency graph:

    • Copy these vertices to the hierarchy graph and create a bidirectional linking.
      In addition, set the referenced design unit’s _hierarchyVertex field to reference the copied vertex.

      • Add a key-value-pair called hierarchyVertex to the dependency graph’s vertex.

      • Add a key-value-pair called dependencyVertex to the hierarchy graph’s vertex.

  2. Iterate all architectures …

    Todo

    Design::CreateHierarchyGraph describe algorithm

    1. Iterate all outbound edges

      Todo

      Design::CreateHierarchyGraph describe algorithm

Return type:

None

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 DependencyGraph: Graph

Read-only property to access the dependency graph (_dependencyGraph).

Returns:

Reference to the dependency graph.

property Documents: list[Document]

Read-only property to access the list of all documents (VHDL source files) loaded for this design (_documents).

Returns:

A list of all documents.

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.

GetConfiguration(libraryName, configurationName)[source]

Return the configuration named configurationName from the library named libraryName.

The lookup is case-insensitive. Nothing is created, if the library or configuration doesn’t exist.

Parameters:
  • libraryName (str) – Name of the library containing the configuration.

  • configurationName (str) – Name of the requested configuration.

Return type:

Configuration

Returns:

The configuration.

Raises:
  • ValueError – If parameter ‘libraryName’ is None or empty.

  • TypeError – If parameter ‘libraryName’ is not of type str.

  • ValueError – If parameter ‘configurationName’ is None or empty.

  • TypeError – If parameter ‘configurationName’ is not of type str.

  • LibraryNotFoundError – If the library doesn’t exist in the design.

  • ConfigurationNotFoundError – If the configuration doesn’t exist in the library.

GetContext(libraryName, contextName)[source]

Return the context named contextName from the library named libraryName.

The lookup is case-insensitive. Nothing is created, if the library or context doesn’t exist.

Parameters:
  • libraryName (str) – Name of the library containing the context.

  • contextName (str) – Name of the requested context.

Return type:

Context

Returns:

The context.

Raises:
  • ValueError – If parameter ‘libraryName’ is None or empty.

  • TypeError – If parameter ‘libraryName’ is not of type str.

  • ValueError – If parameter ‘contextName’ is None or empty.

  • TypeError – If parameter ‘contextName’ is not of type str.

  • LibraryNotFoundError – If the library doesn’t exist in the design.

  • ContextNotFoundError – If the context doesn’t exist in the library.

GetEntity(libraryName, entityName)[source]

Return the entity named entityName from the library named libraryName.

The lookup is case-insensitive. Nothing is created, if the library or entity doesn’t exist.

Parameters:
  • libraryName (str) – Name of the library containing the entity.

  • entityName (str) – Name of the requested entity.

Return type:

Entity

Returns:

The entity.

Raises:
  • ValueError – If parameter ‘libraryName’ is None or empty.

  • TypeError – If parameter ‘libraryName’ is not of type str.

  • ValueError – If parameter ‘entityName’ is None or empty.

  • TypeError – If parameter ‘entityName’ is not of type str.

  • LibraryNotFoundError – If the library doesn’t exist in the design.

  • EntityNotFoundError – If the entity doesn’t exist in the library.

GetLibrary(libraryName)[source]

Return an (existing) VHDL library object of name libraryName.

If the requested VHDL library doesn’t exist, a new VHDL library with that name will be created.

Parameters:

libraryName (str) – Name of the requested VHDL library.

Return type:

Library

Returns:

The VHDL library object.

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.

GetPackage(libraryName, packageName)[source]

Return the package named packageName from the library named libraryName.

The lookup is case-insensitive. Nothing is created, if the library or package doesn’t exist.

Parameters:
  • libraryName (str) – Name of the library containing the package.

  • packageName (str) – Name of the requested package.

Return type:

Package

Returns:

The package.

Raises:
  • ValueError – If parameter ‘libraryName’ is None or empty.

  • TypeError – If parameter ‘libraryName’ is not of type str.

  • ValueError – If parameter ‘packageName’ is None or empty.

  • TypeError – If parameter ‘packageName’ is not of type str.

  • LibraryNotFoundError – If the library doesn’t exist in the design.

  • PackageNotFoundError – If the package doesn’t exist in the library.

property HierarchyGraph: Graph

Read-only property to access the hierarchy graph (_hierarchyGraph).

Returns:

Reference to the hierarchy graph.

IndexArchitectures()[source]

Index all declared items in all architectures in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all architectures
      → pyVHDLModel.Library.IndexArchitectures()

See also

IndexPackages()

Index all declared items in all packages in all libraries.

IndexPackageBodies()

Index all declared items in all package bodies in all libraries.

IndexEntities()

Index all declared items in all entities in all libraries.

Raises:

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

Return type:

None

IndexEntities()[source]

Index all declared items in all entities in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all entities
      → pyVHDLModel.Library.IndexEntities()

See also

IndexPackages()

Index all declared items in all packages in all libraries.

IndexPackageBodies()

Index all declared items in all package bodies in all libraries.

IndexArchitectures()

Index all declared items in all architectures in all libraries.

Raises:

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

Return type:

None

IndexPackageBodies()[source]

Index all declared items in all package bodies in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all package bodies
      → pyVHDLModel.Library.IndexPackageBodies()

See also

IndexPackages()

Index all declared items in all packages in all libraries.

IndexEntities()

Index all declared items in all entities in all libraries.

IndexArchitectures()

Index all declared items in all architectures in all libraries.

Raises:

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

Return type:

None

IndexPackages()[source]

Index all declared items in all packages in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all packages
      → pyVHDLModel.Library.IndexPackages()

See also

IndexPackageBodies()

Index all declared items in all package bodies in all libraries.

IndexEntities()

Index all declared items in all entities in all libraries.

IndexArchitectures()

Index all declared items in all architectures in all libraries.

Raises:

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

Return type:

None

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.

IterateDesignUnits(filter=<DesignUnitKind.All: 63>)[source]

Iterate all design units in the design.

A union of DesignUnitKind values can be given to filter the returned result for suitable design units.

Algorithm

  1. Iterate all VHDL libraries.

    1. Iterate all contexts in that library.

    2. Iterate all packages in that library.

    3. Iterate all package bodies in that library.

    4. Iterate all entites in that library.

    5. Iterate all architectures in that library.

    6. Iterate all configurations in that library.

Parameters:

filter (DesignUnitKind) – Optional, an enumeration with possibly multiple flags to filter the returned design units. Default: DesignUnitKind.All.

Return type:

Generator[DesignUnit]

Returns:

A generator to iterate all matched design units in the design.

See also

pyVHDLModel.Library.IterateDesignUnits()

Iterate all design units in the library.

pyVHDLModel.Document.IterateDesignUnits()

Iterate all design units in the document.

IterateDocumentsInCompileOrder()[source]

Iterate all document in compile-order.

Algorithm

  • Check if compile-order graph was populated with vertices and its vertices are linked by edges.

  1. Iterate compile-order graph in topological order.
    pyTooling.Graph.Graph.IterateTopologically()

    • yield the compiler-order vertex’ referenced document.

Return type:

Generator[Document]

Returns:

A generator to iterate all documents in compile-order in the design.

Raises:

CompileOrderNotComputedError – If compile-order was not computed.
Call Analyze() or AnalyzeDependencies() before.

See also

Todo

missing text

pyVHDLModel.Design.ComputeCompileOrder()

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 Libraries: dict[str, Library]

Read-only property to access the dictionary of library names and VHDL libraries (_libraries).

Returns:

A dictionary of library names and VHDL libraries.

LinkArchitectures()[source]

Link all architectures to corresponding entities in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all architecture groups (grouped per entity symbol’s name). → pyVHDLModel.Library.LinkArchitectures()

      • Check if entity symbol’s name exists as an entity in this library.

      1. For each architecture in the same architecture group:

See also

LinkPackageBodies()

Link all package bodies to corresponding packages in all libraries.

LinkPackageInstances()

Link all package instances to corresponding generic packages in all libraries.

Return type:

None

LinkComponents()[source]

Link components to matching entities found in same VHDL library.

Algorithm

  1. Iterate all design units with component declarations (packages and architectures):

    1. Iterate all component declarations in a package or architecture:

      • Check if an entity with matching name can be found in the VHDL library the package is declared within. If found, set the component’s entity reference to that entity, otherwise check if blackboxes are allowed for that component. If so, mark the component as a blackbox, otherwise, raise an exception.

    2. Iterate concurrent statements with declaration regions (block statements, generate statements) if the design unit is an architecture:

Raises:

ComponentEntityNotFoundError – If no entity is found for a component, which doesn’t allow blackboxes.

Return type:

None

See also

LinkInstantiations()

Link instantiations to components and entities.

AnalyzeDependencies()

Analyze dependencies in a design (calls this method).

LinkContextReferences()[source]

Link all context references (context clause) to the matching context.

Algorithm

  1. Iterate all design units:

    • Iterate all context references in the design unit:

      • Iterate each context symbol within the context reference.

        1. Get the library identifier from the symbol.

        2. Get the context identifier from the symbol.

        3. Resolve library:

          • If library name is work, get library from design unit.

          • If library name isn’t visible (IsLibraryVisible()), raise an exception.

          • Otherwise, lookup library by name in design.

        4. Resolve context:

          • Lookup context by name in library.

        5. Update design unit:

          • Update the context symbol’s target with the referenced context.

          • Add an entry in the design unit’s _referencedContexts dictionary referencing the referenced context.

          • Add an edge in the dependency graph from design unit to the referenced context.

  2. Iterate all context vertices in the dependency graph (_dependencyGraph) in topological order:

    • Get the context from the context vertex.

    • Iterate all predecessor vertices (design unit vertices) of the context vertex:

      1. Get the design unit from design unit vertex.

      2. Iterate referenced libraries of the context:

        • Add an entry in the design unit’s _referencedLibraries dictionary referencing the referenced library.

        • Add an empty dictionary in the design unit’s _referencedPackages dictionary.

      3. Iterate referenced packages of the context:

        • Add an entry in the design unit’s _referencedPackages dictionary referencing the referenced package.

  3. Iterate all design units with a namespace, the contexts they reference and, transitively, the contexts these reference: import the declarations, which LinkContexts() imported into the namespace of a context, into the design unit’s namespace.

See also

LinkLibraryReferences()

Link library clause.

LinkPackageReferences()

Link use clause.

AnalyzeDependencies()

Analyze dependencies and link relations.

Raises:
  • ContextReferenceLibraryNotVisibleError – If a context reference references a library, whose name isn’t visible (IsLibraryVisible()).

  • ContextNotFoundError – If a context reference references a context, which doesn’t exist in its library.

  • UseClauseNotLinkedError – If a use clause of a referenced context isn’t linked.
    Call LinkContexts() before.

Return type:

None

LinkContexts()[source]

Resolves and links all items (library clauses, use clauses and nested context references) in contexts.

It iterates all contexts in the design. Therefore, the library of the context is used as the working library. By default, the working library is implicitly referenced in _referencedLibraries. In addition, a new empty dictionary is created in _referencedPackages and _referencedContexts for that working library.

At first, all library clauses are resolved (a library clause my have multiple library reference symbols). For each referenced library an entry in _referencedLibraries is generated and new empty dictionaries in _referencedPackages and _referencedContexts for that working library. In addition, a vertex in the dependency graph is added for that relationship.

The library clauses of all contexts are resolved before the use clauses of any context.

At second, all use clauses are linked as the use clauses of a design unit’s context clause (a use clause may have multiple package member reference symbols).
→ _LinkUseClause()

The declarations they make potentially visible are imported into the context’s namespace. The design units referencing the context import them from there (LinkContextReferences()).

Raises:
  • ReferencedLibraryNotExistingError – If a library clause references a library, which doesn’t exist in the design.

  • UseClauseLibraryNotVisibleError – If a use clause references a library, whose name isn’t visible (IsLibraryVisible()).

  • PackageNotFoundError – If a use clause references a package, which doesn’t exist in its library.

  • UnknownSymbolKindError – If the type of a symbol in a use clause is unknown.

  • PackageInstantiationNotLinkedError – If a use clause names a package instantiation, which isn’t linked to its generic package.
    Call LinkPackageInstances() before.

  • UnhandledCriticalWarningError – If a use clause names a package member, which the package doesn’t declare, a primary unit, which the library doesn’t contain, a prefix, which isn’t a visible package, or an uninstantiated generic package, and no WarningCollector collects the UnresolvedNameWarning.

Return type:

None

LinkLibraryReferences()[source]

Link all library references (library clause) to the matching VHDL library.

Algorithm

  1. Iterate all design units with contexts:

    • If the design unit is a primary unit:

      1. Iterate all library identifiers in DEFAULT_LIBRARIES (std):

        • Get the referenced library by name from the design.

        • Add an entry in the design unit’s _referencedLibraries dictionary referencing the referenced library.

        • Add an empty dictionary in the design unit’s _referencedPackages dictionary.

        • Add an empty dictionary in the design unit’s _referencedContexts dictionary.

        • Add an edge in the dependency graph from design unit to the referenced library.

      2. Get the design unit’s library, unless it’s a library in DEFAULT_LIBRARIES:

        • Add an entry in the design unit’s _referencedLibraries dictionary referencing the referenced library.

        • Add an empty dictionary in the design unit’s _referencedPackages dictionary.

        • Add an empty dictionary in the design unit’s _referencedContexts dictionary.

        • Add an edge in the dependency graph from design unit to the referenced library.

    • If the design unit is a secondary unit:

      • If design unit is an architecture, get the corresponding entity’s referenced libraries.

      • If design unit is a package body, get the corresponding package’s referenced libraries.

      • Otherwise, raise an exception

      For every referenced library create new dictionary entries in the design unit’s _referencedLibraries.

  2. Iterate every library reference (library clause) in the design unit:

    • Iterate every library symbol within the library reference:

      • Get the library identifier from the symbol.

      • Continue the inner loop, if identifier is work.

      • Get the referenced library from the design or raise an exception.

      • Update the library symbol’s target with the referenced library.

      • Add an entry in the design unit’s _referencedLibraries dictionary referencing the referenced library.

      • Add an empty dictionary in the design unit’s _referencedPackages dictionary.

      • Add an empty dictionary in the design unit’s _referencedContexts dictionary.

      • Add an edge in the dependency graph from design unit to the referenced library.

See also

LinkPackageReferences()

Link use clause.

LinkContextReferences()

Link context clause.

AnalyzeDependencies()

Analyze dependencies and link relations.

Raises:
  • LibraryNotFoundError – If library std isn’t loaded.
    Call LoadStdLibrary() before.

  • UnknownSecondaryUnitKindError – If a secondary unit is neither an architecture nor a package body.

  • LibraryClauseLibraryNotFoundError – If a library clause references a library, which doesn’t exist in the design.

Return type:

None

LinkPackageBodies()[source]

Link all package bodies to corresponding packages in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all package bodies. → pyVHDLModel.Library.LinkPackageBodies()

      • Check if package body symbol’s name exists as a package in this library.

      • Add package body to package pyVHDLModel.DesignUnit.Package._packageBody.

      • Assign found package to package body’s package symbol pyVHDLModel.DesignUnit.PackageBody._package

      • Set parent namespace of package body’s namespace to the package’s namespace.

      • Add an edge in the dependency graph from the package body’s corresponding dependency vertex to the package’s corresponding dependency vertex.

See also

LinkArchitectures()

Link all architectures to corresponding entities in all libraries.

LinkPackageInstances()

Link all package instances to corresponding generic packages in all libraries.

Return type:

None

LinkPackageInstances()[source]

Link all package instances to corresponding generic packages in all libraries.

Algorithm

  1. Iterate all libraries:

    1. Iterate all package instances. → pyVHDLModel.Library.LinkPackageInstances()

Todo

  • Check if package instance’s symbol’s name exists as a generic package in this library.

  • Add generic package to package instance pyVHDLModel.DesignUnit.Package._packageBody.

  • Assign found package to package body’s package symbol pyVHDLModel.DesignUnit.PackageBody._package

  • Set parent namespace of package body’s namespace to the package’s namespace.

  • Add an edge in the dependency graph from the package body’s corresponding dependency vertex to the package’s corresponding dependency vertex.

See also

LinkArchitectures()

Link all architectures to corresponding entities in all libraries.

LinkPackageBodies()

Link all package bodies to corresponding packages in all libraries.

Return type:

None

LinkPackageReferences()[source]

Link all package references (use clause) to the matching packages, and import the declarations they make potentially visible.

Algorithm

  1. Iterate all design units with contexts:

    • If the design unit is a primary unit:

      • If primary unit isn’t package std.standard:

        1. Iterate all library, packages tuples in DEFAULT_PACKAGES (std: [standard]):

          • Raise an exception, if library isn’t listed in design unit’s _referencedLibraries.

          • For every package in packages:

            • Get the referenced package by library name and package name from the design.

            • Add an entry in the design unit’s _referencedPackages dictionary referencing the referenced package.

            • Add an edge in the dependency graph from design unit to the referenced package.

            • Import all declarations of the package into the design unit’s namespace, as by the implicit use std.standard.all;.

    • If the design unit is a secondary unit:

      • If design unit is an architecture, get the corresponding entity’s referenced packages.

      • If design unit is a package body, get the corresponding package’s referenced packages.

      • Otherwise, raise an exception

      For every referenced package create new dictionary entries in the design unit’s _referencedPackages.

  2. Link every use clause of the design unit’s context clause into the design unit’s namespace.
    → _LinkUseClause()

  3. Link every use clause in the declarative part of the design unit and of every declarative region nested in it (e.g. a process, a subprogram or a block) into the namespace of its declarative region.
    → _LinkUseClause()

See also

LinkLibraryReferences()

Link library clause.

LinkContextReferences()

Link context clause.

AnalyzeDependencies()

Analyze dependencies and link relations.

Raises:
  • LibraryReferenceNotLinkedError – If a primary unit doesn’t reference library std.
    Call LinkLibraryReferences() before.

  • PackageNotFoundError – If library std doesn’t contain package standard.
    Call LoadStdLibrary() before.

  • UnknownSecondaryUnitKindError – If a secondary unit is neither an architecture nor a package body.

  • UseClauseLibraryNotVisibleError – If a use clause references a library, whose name isn’t visible (IsLibraryVisible()).

  • PackageNotFoundError – If a use clause references a package, which doesn’t exist in its library.

  • UnhandledCriticalWarningError – If a use clause names a package member, which the package doesn’t declare, a primary unit, which the library doesn’t contain, a prefix, which isn’t a visible package, or an uninstantiated generic package, and no WarningCollector collects the UnresolvedNameWarning.

Return type:

None

LoadIEEELibrary(flavor=None)[source]

Load the predefined VHDL library ieee into the design.

This will create a virtual source code file ieee.vhdl and register VHDL design units of library ieee to that file.

Parameters:

flavor (IEEEFlavor | None) – Optional, select the IEEE library flavor: IEEE, Synopsys, MentorGraphics. Default: None, the IEEE flavor.

Return type:

Library

Returns:

The library object of library ieee.

LoadStdLibrary()[source]

Load the predefined VHDL library std into the design.

This will create a virtual source code file std.vhdl and register VHDL design units of library std to that file.

Return type:

Library

Returns:

The library object of library std.

property Name: str | None

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

Returns:

The name of the design.

property ObjectGraph: Graph

Read-only property to access the object graph (_objectGraph).

Returns:

Reference to the object graph.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

RemoveDocument(document)[source]

Remove a document (VHDL source file) from the design.

The document is detached: its parent and library are cleared. Its entities, architectures, packages, package bodies, configurations and contexts leave the library, and their parent is cleared. The design units stay design units of the document, so the document can be added to a design again.

Parameters:

document (Document) – The VHDL source code file.

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

  • TypeError – If parameter ‘document’ is not of type Document.

  • NotAChildError – If parameter ‘document’ is not a document of this design.

Return type:

None

See also

AddDocument()

→ Add a document to the design.

RemoveLibrary(library)[source]

Remove a VHDL library from the design.

The library is detached: its parent is cleared. Its design units stay design units of the library, so the library can be added to a design again (AddLibrary()).

Parameters:

library (Library) – The VHDL library to remove.

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

  • TypeError – If parameter ‘library’ is not of type Library.

  • NotAChildError – If parameter ‘library’ is not a library of this design.

  • LibraryInUseError – If documents of this design still use the library.

Return type:

None

See also

AddLibrary()

→ Add a VHDL library to the design.

RemoveDocument()

→ Remove a document from the design.

ResetAnalysis()[source]

Reset everything an analysis (Analyze()) derived, so the design can be analyzed again.

Everything built by the user is kept: libraries, documents, design units, declarations and the declarations in namespaces. Lookup tables built by indexing (e.g. IndexPackages()) are kept too, as indexing again yields the same lookup tables. Resetting a design, which wasn’t analyzed, changes nothing.

Algorithm

  1. Delete the dependency, compile-order, hierarchy and object graph (Delete()), so their vertices and edges are freed at once, replace them by empty graphs, and forget the top-level.

  2. Clear the references to vertices of all libraries, documents and design units.

  3. Clear the references of all design units: referenced libraries, packages and contexts, the symbols of library clauses, use clauses and context references, and the items imported into namespaces. Use clauses in declarative regions nested in a design unit are cleared too, as are the references of type marks and alias names (ResolveTypeMarks()) and the base types of subtypes; a subtype of a predefined library (Library.IsPredefined) keeps its base type.

  4. Unlink architectures from entities and package bodies from packages: an entity’s architectures, a package’s body, the symbols referencing the entity or package, and the link to the parent namespace.

  5. Unlink package instantiations from their generic package: the symbol and the components copied from it.

  6. Unbind all components: their entity and blackbox state.

  7. Clear the symbols of entity and component instantiations.

Return type:

None

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

ResolveTypeMarks()[source]

Resolve the type marks of all declarations in the design.

It’s the first step of AnalyzeObjects(), after the use clauses are linked. Each type mark is looked up at its place (LookupName()), so the visibility rules apply: e.g. a type declared after the place isn’t visible, and conflicting use clauses make a type mark ambiguous. A resolved type mark references the type, the subtype or the generic type (Reference); a type mark denoting an alias of a type references the type. Resolving again yields the same references, as long as the design isn’t changed; after a change, Analyze() links the use clauses again.

Algorithm

  1. Iterate the design units of the predefined libraries (Library.IsPredefined), then the design units of all documents in compile order (the compile-order graph, ComputeCompileOrder()), so a package is resolved before its users.

  2. Iterate the declarative regions of each design unit, the outermost first (IterateDeclarationRegions()):

    1. Index the declared items of a region not indexed yet, e.g. a process or a subprogram.

    2. Iterate the region’s declarations in declaration order; each resolves its references (ResolveReferences()):

See also

ResetAnalysis()

Reset everything an analysis derived, including the references of type marks.

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

  • UnhandledCriticalWarningError – If the name of an alias can’t be resolved, and no WarningCollector collects the UnresolvedNameWarning.

  • UnhandledCriticalWarningError – If an incomplete type has no full type declaration, and no WarningCollector collects the IncompleteTypeWarning.

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

Return type:

None

SearchConfiguration(configurationName)[source]

Return all configurations named configurationName from the libraries of the design.

The search is case-insensitive. Each configuration references its library by Library.

Parameters:

configurationName (str) – Name of the searched configuration.

Return type:

tuple[Configuration, ...]

Returns:

Tuple of configurations in the order of the design’s libraries, empty if no library contains one.

Raises:
  • ValueError – If parameter ‘configurationName’ is None or empty.

  • TypeError – If parameter ‘configurationName’ is not of type str.

SearchContext(contextName)[source]

Return all contexts named contextName from the libraries of the design.

The search is case-insensitive. Each context references its library by Library.

Parameters:

contextName (str) – Name of the searched context.

Return type:

tuple[Context, ...]

Returns:

Tuple of contexts in the order of the design’s libraries, empty if no library contains one.

Raises:
  • ValueError – If parameter ‘contextName’ is None or empty.

  • TypeError – If parameter ‘contextName’ is not of type str.

SearchEntity(entityName)[source]

Return all entities named entityName from the libraries of the design.

The search is case-insensitive. Each entity references its library by Library.

Parameters:

entityName (str) – Name of the searched entity.

Return type:

tuple[Entity, ...]

Returns:

Tuple of entities in the order of the design’s libraries, empty if no library contains one.

Raises:
  • ValueError – If parameter ‘entityName’ is None or empty.

  • TypeError – If parameter ‘entityName’ is not of type str.

SearchPackage(packageName)[source]

Return all packages named packageName from the libraries of the design.

The search is case-insensitive. Each package references its library by Library.

Parameters:

packageName (str) – Name of the searched package.

Return type:

tuple[Package, ...]

Returns:

Tuple of packages in the order of the design’s libraries, empty if no library contains one.

Raises:
  • ValueError – If parameter ‘packageName’ is None or empty.

  • TypeError – If parameter ‘packageName’ is not of type str.

property TopLevel: Entity | Configuration

Read-only property to return the design’s top-level (_toplevel).

When called the first time, the hierarchy graph is checked for its root elements. When there is only one root element in the graph, a new field toplevel is added to _hierarchyGraph referencing that single element. In addition, the result is cached in _toplevel.

Returns:

Reference to the design’s top-level.

Raises:
  • HierarchyNotComputedError – If the hierarchy graph is not yet computed from dependency graph.
    Call Analyze() or AnalyzeDependencies() before.

  • AmbiguousTopLevelError – If there is more than one top-level.

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

_IterateComponents()[source]

Iterate all components of packages and architectures, including the components declared in blocks and generate statements nested in architectures.

Return type:

Generator[tuple[Library, Component]]

Returns:

A generator to iterate tuples of the library of the design unit and a component.

_LinkUseClause(designUnit, namespace, useClause, isContextItem)[source]

Link the symbols of a use clause and import the declarations they make potentially visible into a namespace.

Algorithm

Iterate every package symbol within the use clause (a use clause can have multiple comma-separated symbols):

  1. Get the package name from the symbol: the symbol’s name for a PackageReferenceSymbol (use lib.pkg;), else its prefix (use lib.pkg.all;, use lib.pkg.item;). Get the library name, the prefix of the package name. If the symbol is neither of the three package symbol types, raise an exception.

  2. If the use clause names a library (use work.all;, use lib.unit;, the prefix is work or the visible name of a library (IsLibraryVisible()), and unit isn’t a package of it):

    • .all: import all primary units of the library (entities, packages, configurations, contexts).

    • .unit: import the primary unit of that name; if there is none, raise an UnresolvedNameWarning.

    Continue with the next symbol.

  3. Resolve the package:

    • Without a library name (use pkg.all;): lookup the directly visible package at the use clause (Lookup()), e.g. made visible by use lib.pkg; or declared in an enclosing region. If there is none, raise an UnresolvedNameWarning and continue with the next symbol.

    • With a library name: if library name is work, get the library of the design unit; if library name isn’t visible (IsLibraryVisible()), raise an exception; otherwise lookup the library by name in the design. Lookup the package by name in the library; if it doesn’t exist, raise an exception.

  4. Update the design unit:

    • Update the package symbol’s reference with the package.

    • If the package was named with its library and the use clause is an item of the design unit’s context clause, add an entry in the design unit’s _referencedPackages dictionary.

    • If the package was named with its library, add an edge in the dependency graph from design unit to the package.

  5. If the package is an uninstantiated generic package, raise an UnresolvedNameWarning and continue with the next symbol.

  6. Import the public package members into the namespace (AddImport()), each with the use clause as origin:

    • AllPackageMembersReferenceSymbol (use lib.pkg.all;): every declaration of the package, incl. the enumeration literals and physical units of its types (IterateDeclarations()).

    • PackageMemberReferenceSymbol (use lib.pkg.item;): every declaration of the package with the identifier item, e.g. all overloads of a subprogram, and the enumeration literals and physical units of a type or of a subtype’s base type (IterateMemberDeclarations()). If there is none, raise an UnresolvedNameWarning.

    • PackageReferenceSymbol (use lib.pkg;): the package itself.

Parameters:
  • designUnit (DesignUnit) – The design unit containing the use clause.

  • namespace (Namespace) – The namespace of the declarative region or of the context declaration containing the use clause.

  • useClause (UseClause) – The use clause.

  • isContextItem (bool) – True, if the use clause is an item of the design unit’s context clause.

Raises:
  • UseClauseLibraryNotVisibleError – If a use clause references a library, whose name isn’t visible (IsLibraryVisible()).

  • PackageNotFoundError – If a use clause references a package, which doesn’t exist in its library.

  • UnknownSymbolKindError – If the type of a symbol in the use clause is unknown.

  • PackageInstantiationNotLinkedError – If a package instantiation isn’t linked to its generic package.

  • UnhandledCriticalWarningError – If a use clause names a package member, which the package doesn’t declare, a primary unit, which the library doesn’t contain, a prefix, which isn’t a visible package, or an uninstantiated generic package, and no WarningCollector collects the UnresolvedNameWarning.

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)
__repr__()[source]

Formats a representation of the design.

Format: Document: 'my_design'

Return type:

str

Returns:

String representation of the design.

__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()

Formats a representation of the design.

Format: Document: 'my_design'

Return type:

str

Returns:

String representation of the design.

_allowBlackbox: bool | None

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

_compileOrderGraph: Graph

A graph derived from dependency graph containing the order of documents for compilation.

_dependencyGraph: Graph

The graph of all dependencies in the designs.

_documents: list[Document]

List of all documents loaded for a design.

_documentsByPath: dict[Path, Document]

The documents loaded for a design, indexed by path.

_hierarchyGraph: Graph

A graph derived from dependency graph containing the design hierarchy.

_libraries: dict[str, Library]

List of all libraries defined for a design.

_name: str | None

Name of the design.

_objectGraph: Graph

The graph of all types and objects in the design.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_toplevel: Entity | Configuration

When computed, the toplevel design unit is cached in this field.

class pyGHDL.dom.NonStandard.Library(identifier, documentation=None, allowBlackbox=None, parent=None)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Library.

A Library represents a VHDL library. It contains all primary and secondary design units.

Inheritance

Inheritance diagram of Library

Parameters:
  • identifier (str)

  • documentation (Nullable[str])

  • allowBlackbox (Nullable[bool])

  • parent (Nullable[ModelEntity])

property AllowBlackbox: bool

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

Algorithm

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

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

Returns:

True, if blackboxes are allowed.

Raises:

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

Setter accepts:

bool | None

property Architectures: dict[str, dict[str, Architecture]]

Read-only property to access the dictionary of all architecture declarations in this library (_architectures).

Returns:

Dictionary of all architectures, indexed by normalized entity identifier, then by normalized architecture identifier.

property Configurations: dict[str, Configuration]

Read-only property to access the dictionary of all configuration declarations in this library (_configurations).

Returns:

Dictionary of all configurations, indexed by normalized identifier.

property Contexts: dict[str, Context]

Read-only property to access the dictionary of all context declarations in this library (_contexts).

Returns:

Dictionary of all contexts, indexed by normalized identifier.

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 library by its value field.

Returns:

The corresponding dependency vertex.

property Documentation: str | None

Property to access the library’s documentation (_documentation).

Hint

Unlike every other documented entity, a library’s documentation cannot come from VHDL source: the language has no library declaration to attach a comment to. It is therefore settable, so a caller can supply one from elsewhere - a compile-order file, a project description, …

Returns:

Associated documentation of this VHDL library.

property Entities: dict[str, Entity]

Read-only property to access the dictionary of all entity declarations in this library (_entities).

Returns:

Dictionary of all entities, indexed by normalized identifier.

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.

IndexArchitectures()[source]

Index declared items in all architectures.

Algorithm

  1. Iterate all architectures:

See also

IndexPackages()

Index all declared items in a package.

IndexPackageBodies()

Index all declared items in a package body.

IndexEntities()

Index all declared items in an entity.

Raises:

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

Return type:

None

IndexEntities()[source]

Index declared items in all entities.

Algorithm

  1. Iterate all entities:

See also

IndexPackages()

Index all declared items in a package.

IndexPackageBodies()

Index all declared items in a package body.

IndexArchitectures()

Index all declared items in an architecture.

Raises:

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

Return type:

None

IndexPackageBodies()[source]

Index declared items in all package bodies.

Algorithm

  1. Iterate all package bodies:

See also

IndexPackages()

Index all declared items in a package.

IndexEntities()

Index all declared items in an entity.

IndexArchitectures()

Index all declared items in an architecture.

Raises:

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

Return type:

None

IndexPackages()[source]

Index declared items in all packages.

Algorithm

  1. Iterate all packages:

See also

IndexPackageBodies()

Index all declared items in a package body.

IndexEntities()

Index all declared items in an entity.

IndexArchitectures()

Index all declared items in an architecture.

Raises:

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

Return type:

None

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.

property IsPredefined: bool

Check if the library is a predefined library built by pyVHDLModel.

A predefined library is a PredefinedLibrary, e.g. std.

Its declarations are complete when constructed, e.g. a subtype has its base type, so an analysis neither resolves nor resets them. A library std or ieee read from VHDL source files isn’t predefined in this sense.

Returns:

False

IterateDesignUnits(filter=<DesignUnitKind.All: 63>)[source]

Iterate all design units in the library.

A union of DesignUnitKind values can be given to filter the returned result for suitable design units.

Algorithm

  1. Iterate all contexts in that library.

  2. Iterate all packages in that library.

  3. Iterate all package bodies in that library.

  4. Iterate all entities in that library.

  5. Iterate all architectures in that library.

  6. Iterate all configurations in that library.

Parameters:

filter (DesignUnitKind) – Optional, an enumeration with possibly multiple flags to filter the returned design units. Default: DesignUnitKind.All.

Return type:

Generator[DesignUnit]

Returns:

A generator to iterate all matched design units in the library.

See also

pyVHDLModel.Design.IterateDesignUnits()

Iterate all design units in the design.

pyVHDLModel.Document.IterateDesignUnits()

Iterate all design units in the document.

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.

LinkArchitectures()[source]

Link all architectures to corresponding entities.

Algorithm

  1. Iterate all architecture groups (grouped per entity symbol’s name).

    • Check if entity symbol’s name exists as an entity in this library.

    1. For each architecture in the same architecture group:

Raises:
  • ArchitectureEntityNotFoundError – If entity name doesn’t exist.

  • ArchitectureExistsInLibraryError – If architecture name already exists for entity.

Return type:

None

See also

LinkPackageBodies()

Link all package bodies to corresponding packages.

LinkPackageInstances()

Link all package instances to corresponding generic packages.

LinkPackageBodies()[source]

Link all package bodies to corresponding packages.

Algorithm

  1. Iterate all package bodies.

Raises:
  • PackageBodyPackageNotFoundError – If package name doesn’t exist.

  • UnhandledCriticalWarningError – If a package has another package body, which is replaced, and no WarningCollector collects the DuplicateDeclarationWarning.

Return type:

None

See also

LinkArchitectures()

Link all architectures to corresponding entities.

LinkPackageInstances()

Link all package instances to corresponding generic packages.

LinkPackageInstances()[source]

Link all package instances to corresponding generic packages.

Algorithm

  1. Iterate all package instances.

    Todo

    • Check if package body symbol’s name exists as a package in this library.

    • Add package body to package pyVHDLModel.DesignUnit.Package._packageBody.

    • Assign found package to package body’s package symbol pyVHDLModel.DesignUnit.PackageBody._package

    • Set parent namespace of package body’s namespace to the package’s namespace.

    • Add an edge in the dependency graph from the package body’s corresponding dependency vertex to the package’s corresponding dependency vertex.

Raises:
  • PackageInstantiationLibraryNotFoundError – If the library of the generic package doesn’t exist in the design.

  • PackageInstantiationLibraryNotVisibleError – If the name of that library isn’t visible (IsLibraryVisible()).

  • PackageNotFoundError – If generic package name doesn’t exist.

  • NotAGenericPackageError – If the package isn’t a generic package.

Return type:

None

See also

LinkArchitectures()

Link all architectures to corresponding entities.

LinkPackageBodies()

Link all package bodies to corresponding packages.

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 PackageBodies: dict[str, PackageBody]

Read-only property to access the dictionary of all package body declarations in this library (_packageBodies).

Returns:

Dictionary of all package bodies, indexed by normalized identifier.

property Packages: dict[str, Package]

Read-only property to access the dictionary of all package declarations in this library (_packages).

Returns:

Dictionary of all packages, indexed by normalized identifier.

property Parent: ModelEntity

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

Returns:

Reference to the parent entity.

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.

__init__(identifier, documentation=None, allowBlackbox=None, parent=None)[source]

Initialize a VHDL library.

Parameters:
  • identifier (str) – Name of the VHDL library.

  • documentation (str | None) – Optional, documentation of this VHDL library, if the caller has one to supply. Default: None, no documentation.

  • allowBlackbox (bool | None) – Optional, specify if blackboxes are allowed in this design. Default: None, inherited from the parent.

  • parent (ModelEntity | None) – Optional, the parent model entity (design) of this VHDL library. Default: None, no parent.

Return type:

None

__new__(**kwargs)
__repr__()[source]

Formats a representation of the library.

Format: Library: 'my_library'

Return type:

str

Returns:

String representation of the library.

__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()

Formats a representation of the library.

Format: Library: 'my_library'

Return type:

str

Returns:

String representation of the library.

_allowBlackbox: bool | None

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

_architectures: dict[str, dict[str, Architecture]]

Dictionary of all architectures defined in a library.

_configurations: dict[str, Configuration]

Dictionary of all configurations defined in a library.

_contexts: dict[str, Context]

Dictionary of all contexts defined in a library.

_dependencyVertex: Vertex

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

_documentation: str | None

The associated documentation of a model entity.

_entities: dict[str, Entity]

Dictionary of all entities defined in a library.

_identifier: str

The identifier of a model entity.

_normalizedIdentifier: str

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

_packageBodies: dict[str, PackageBody]

Dictionary of all package bodies defined in a library.

_packages: dict[str, Package]

Dictionary of all packages defined in a library.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

class pyGHDL.dom.NonStandard.Document(path, sourceCode=None, vhdlVersion=2008, dontParse=False, dontTranslate=False)[source]

This class implements a pyGHDL.dom object derived from pyVHDLModel.Document.

A Document represents a sourcefile. It contains primary and secondary design units.

Inheritance

Inheritance diagram of Document

Parameters:
__ghdlFileID: Any

libghdl’s name table identifier for _filename.

__ghdlSourceFileEntry: Any

libghdl’s source file entry holding this document’s source code.

__init__(path, sourceCode=None, vhdlVersion=2008, dontParse=False, dontTranslate=False)[source]

Initializes a VHDL document.

Parameters:
  • path (Path) – Path to the document. None if in-memory document.

  • sourceCode (str) – Optional, the source code to analyze, or None to read it from path.

  • vhdlVersion (VHDLVersion) – Optional, VHDL version used for analyzing this source file.

  • dontParse (bool) – Optional, True to skip parsing the source code.

  • dontTranslate (bool) – Optional, True to parse the source code, but skip translating it to the DOM.

Return type:

None

_filename: Path

The source file this document was read from.

AddDesignUnit(designUnit)[source]

Add a design unit at the end of the document.

The design unit’s document is set to this document. If the document is registered in a design (Design.AddDocument()), the design unit enters the document’s library too.

Parameters:

designUnit (DesignUnit) – The design unit to add.

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

  • TypeError – If parameter ‘designUnit’ is not of type DesignUnit.

  • AlreadyInDesignError – If parameter ‘designUnit’ is already a design unit of a document.

  • DuplicateDesignUnitError – If the document contains a design unit of the same kind and identifier.

  • EntityExistsInLibraryError – If the library already contains an entity of the same identifier.

  • ArchitectureExistsInLibraryError – If the library already contains an architecture of the same identifier for the same entity.

  • PackageExistsInLibraryError – If the library already contains a package of the same identifier.

  • PackageBodyExistsError – If the library already contains a package body of the same identifier.

  • ConfigurationExistsInLibraryError – If the library already contains a configuration of the same identifier.

  • ContextExistsInLibraryError – If the library already contains a context of the same identifier.

Return type:

None

See also

InsertDesignUnit()

→ Insert a design unit at a position of the document.

RemoveDesignUnit()

→ Remove a design unit from the document.

property Architectures: dict[str, dict[str, Architecture]]

Read-only property to access the dictionary of all architecture declarations in this document (_architectures).

Returns:

Dictionary of all architectures, indexed by normalized entity identifier, then by normalized architecture identifier.

property CompileOrderVertex: Vertex

Read-only property to access the corresponding compile-order vertex (_compileOrderVertex).

The compile-order vertex references this document by its value field.

Returns:

The corresponding compile-order vertex.

property Configurations: dict[str, Configuration]

Read-only property to access the dictionary of all configuration declarations in this document (_configurations).

Returns:

Dictionary of all configurations, indexed by normalized identifier.

property Contexts: dict[str, Context]

Read-only property to access the dictionary of all context declarations in this document (_contexts).

Returns:

Dictionary of all contexts, indexed by normalized identifier.

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 DesignUnits: list[DesignUnit]

Read-only property to access a list of all design units declarations found in this document (_designUnits).

Returns:

List of all design units.

property Documentation: str | None

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

Returns:

Associated documentation of a model entity.

property Entities: dict[str, Entity]

Read-only property to access the dictionary of all entity declarations in this document (_entities).

Returns:

Dictionary of all entities, indexed by normalized identifier.

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.

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.

InsertDesignUnit(index, designUnit)[source]

Insert a design unit at a position of the document.

The design units of a document are in source order. The design unit’s document is set to this document. If the document is registered in a design (Design.AddDocument()), the design unit enters the document’s library too: the library becomes its parent. PSL verification units, properties and modes enter no library.

Parameters:
  • index (int) – Position, from 0 (first) to the number of design units (append). A negative index counts from the end, as for list.insert().

  • designUnit (DesignUnit) – The design unit 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 ‘designUnit’ is None.

  • TypeError – If parameter ‘designUnit’ is not of type DesignUnit.

  • AlreadyInDesignError – If parameter ‘designUnit’ is already a design unit of a document.

  • DuplicateDesignUnitError – If the document contains a design unit of the same kind and identifier.

  • EntityExistsInLibraryError – If the library already contains an entity of the same identifier.

  • ArchitectureExistsInLibraryError – If the library already contains an architecture of the same identifier for the same entity.

  • PackageExistsInLibraryError – If the library already contains a package of the same identifier.

  • PackageBodyExistsError – If the library already contains a package body of the same identifier.

  • ConfigurationExistsInLibraryError – If the library already contains a configuration of the same identifier.

  • ContextExistsInLibraryError – If the library already contains a context of the same identifier.

Return type:

None

See also

AddDesignUnit()

→ Add a design unit at the end of the document.

RemoveDesignUnit()

→ Remove a design unit from the document.

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.

IterateDesignUnits(filter=<DesignUnitKind.All: 63>)[source]

Iterate all design units in the document.

A union of DesignUnitKind values can be given to filter the returned result for suitable design units.

Algorithm

  • If contexts are selected in the filter:

    1. Iterate all contexts in that library.

  • If packages are selected in the filter:

    1. Iterate all packages in that library.

  • If package bodies are selected in the filter:

    1. Iterate all package bodies in that library.

  • If entites are selected in the filter:

    1. Iterate all entites in that library.

  • If architectures are selected in the filter:

    1. Iterate all architectures in that library.

  • If configurations are selected in the filter:

    1. Iterate all configurations in that library.

Parameters:

filter (DesignUnitKind) – Optional, an enumeration with possibly multiple flags to filter the returned design units. Default: DesignUnitKind.All.

Return type:

Generator[DesignUnit]

Returns:

A generator to iterate all matched design units in the document.

See also

pyVHDLModel.Design.IterateDesignUnits()

Iterate all design units in the design.

pyVHDLModel.Library.IterateDesignUnits()

Iterate all design units in the library.

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

Read-only property to access the document’s VHDL library (_library).

Returns:

VHDL library used to analyze the VHDL file’s design units into.

property PackageBodies: dict[str, PackageBody]

Read-only property to access the dictionary of all package body declarations in this document (_packageBodies).

Returns:

Dictionary of all package bodies, indexed by normalized identifier.

property Packages: dict[str, Package]

Read-only property to access the dictionary of all package declarations in this document (_packages).

Returns:

Dictionary of all packages, indexed by normalized identifier.

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 Path: Path

Read-only property to access the document’s path (_path).

Returns:

The path of this document.

RemoveDesignUnit(designUnit)[source]

Remove a design unit from the document.

The design unit is detached: its document is cleared. If the document is registered in a design (Design.AddDocument()), the design unit leaves the document’s library too, and its parent is cleared. The design unit itself is unchanged and can be added to another document, or inserted at another position.

Parameters:

designUnit (DesignUnit) – The design unit to remove.

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

  • TypeError – If parameter ‘designUnit’ is not of type DesignUnit.

  • NotAChildError – If parameter ‘designUnit’ is not a design unit of this document.

Return type:

None

See also

AddDesignUnit()

→ Add a design unit at the end of the document.

InsertDesignUnit()

→ Insert a design unit at a position of the document.

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

property VHDLVersion: VHDLVersion

Read-only property to access the document’s VHDL version (_vhdlVersion).

Returns:

VHDL version used to analyze this VHDL file.

property VerificationModes: dict[str, VerificationMode]

Read-only property to access the dictionary of all verification mode declarations in this document (_verificationModes).

Returns:

Dictionary of all verification mode declarations, indexed by normalized identifier.

property VerificationProperties: dict[str, VerificationProperty]

Read-only property to access the dictionary of all verification property declarations in this document (_verificationProperties).

Returns:

Dictionary of all verification properties, indexed by normalized identifier.

property VerificationUnits: dict[str, VerificationUnit]

Read-only property to access the dictionary of all verification unit declarations in this document (_verificationUnits).

Returns:

Dictionary of all verification units, indexed by normalized identifier.

Visit(visitor)[source]

Walk this document and its design units with a visitor.

Parameters:

visitor (Visitor) – The visitor receiving the events.

Return type:

None

_AddArchitecture(item)[source]

Add an architecture to the document’s lists of design units.

Parameters:

item (Architecture) – Architecture object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type Architecture.

  • DuplicateDesignUnitError – If architecture name already exists for the referenced entity name in document.

Return type:

None

_AddConfiguration(item)[source]

Add a configuration to the document’s lists of design units.

Parameters:

item (Configuration) – Configuration object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type Configuration.

  • DuplicateDesignUnitError – If configuration name already exists in document.

Return type:

None

_AddContext(item)[source]

Add a context to the document’s lists of design units.

Parameters:

item (Context) – Context object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type Context.

  • DuplicateDesignUnitError – If context name already exists in document.

Return type:

None

_AddDesignUnit(item)[source]

Add a design unit to the document’s lists of design units.

Parameters:

item (DesignUnit) – Design unit to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type DesignUnit.

  • ValueError – If parameter ‘item’ is an unknown DesignUnit.

  • DuplicateDesignUnitError – If the document contains a design unit of the same kind and identifier.

Return type:

None

_AddEntity(item)[source]

Add an entity to the document’s lists of design units.

Parameters:

item (Entity) – Entity object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type Entity.

  • DuplicateDesignUnitError – If entity name already exists in document.

Return type:

None

_AddPackage(item)[source]

Add a package to the document’s lists of design units.

Parameters:

item (Package) – Package object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type Package.

  • DuplicateDesignUnitError – If package name already exists in document.

Return type:

None

_AddPackageBody(item)[source]

Add a package body to the document’s lists of design units.

Parameters:

item (PackageBody) – Package body object to be added to the document.

Raises:
  • TypeError – If parameter ‘item’ is not of type PackageBody.

  • DuplicateDesignUnitError – If package body name already exists in document.

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)
__repr__()[source]

Formats a representation of the document.

Format: Document: 'path/to/file.vhdl'

Return type:

str

Returns:

String representation of the document.

__setstate__(state)

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

Parameters:

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

Raises:

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

Return type:

None

__str__()

Formats a representation of the document.

Format: Document: 'path/to/file.vhdl'

Return type:

str

Returns:

String representation of the document.

_architectures: dict[str, dict[str, Architecture]]

Dictionary of all architectures defined in a document.

_compileOrderVertex: Vertex

Reference to the vertex in the compile-order graph representing the document.
This reference is set by CreateCompileOrderGraph().

_configurations: dict[str, Configuration]

Dictionary of all configurations defined in a document.

_contexts: dict[str, Context]

Dictionary of all contexts defined in a document.

_dependencyVertex: Vertex

Reference to the vertex in the dependency graph representing the document.
This reference is set by CreateCompileOrderGraph().

_designUnits: list[DesignUnit]

List of all design units defined in a document.

_documentation: str | None

The associated documentation of a model entity.

_entities: dict[str, Entity]

Dictionary of all entities defined in a document.

_library: Library

VHDL library used for analyzing the source file’s content into.

_packageBodies: dict[str, PackageBody]

Dictionary of all package bodies defined in a document.

_packages: dict[str, Package]

Dictionary of all packages defined in a document.

_parent: ModelEntity

Reference to a parent entity in the logical model hierarchy.

_path: Path

Path to the document.

_verificationModes: dict[str, VerificationMode]

Dictionary of all PSL verification modes defined in a document.

_verificationProperties: dict[str, VerificationProperty]

Dictionary of all PSL verification properties defined in a document.

_verificationUnits: dict[str, VerificationUnit]

Dictionary of all PSL verification units defined in a document.

_vhdlVersion: VHDLVersion

VHDL version used for analyzing this source file.

_warnings: List

Warnings raised by pyGHDL.dom while this document is translated.

__ghdlFile: Any

The IIR design file node returned by libghdl when the source code was parsed.

__ghdlProcessingDuration: Duration | None

Duration of libghdl’s parsing, None if it was skipped.

__domTranslationDuration: Duration | None

Duration of the IIR to DOM translation, None if it was skipped.

__loadFromPath()

Reads the source file named by _filename and hands it to libghdl.

Raises:

DOMException – If the source file does not exist.

__loadFromString(sourceCode)

Hands the given source code to libghdl under the name in _filename.

Hint

The source file itself is not read, which is how a document can be analyzed in-memory from a string.

Parameters:

sourceCode (str) – The source code to analyze.

translate()[source]

Translates the design units of the parsed IIR tree to pyGHDL.dom objects.

Raises:
  • DOMException – If a design unit’s kind is not handled.

  • UnhandledExceptionError – If a construct is not supported yet and no WarningCollector is active.

property LibGHDLProcessingDuration: Duration | None

Read-only property to access the duration of libghdl’s parsing (__ghdlProcessingDuration).

The duration is measured while the document is constructed, so it is set only if dontParse was False.

Returns:

The parse duration, or None if the document was constructed with dontParse=True.

property DOMTranslationDuration: Duration | None

Read-only property to access the duration of the IIR to DOM translation (__domTranslationDuration).

The duration is measured while the document is constructed, so it is set only if neither dontParse nor dontTranslate was True.

Returns:

The translation duration, or None if the document was constructed with dontParse=True or dontTranslate=True.