pyVHDLModel
Summary
- Doc-string:
documented
File |
Expected |
Covered |
Uncovered |
Coverage |
|---|---|---|---|---|
__init__.py |
243 |
196 |
47 |
80.7% |
Overall (27 files) |
3278 |
3185 |
93 |
97.2% |
Packages
Package |
Expected |
Covered |
Uncovered |
Coverage |
|---|---|---|---|---|
353 |
353 |
0 |
100.0% |
Modules
Module |
Expected |
Covered |
Uncovered |
Coverage |
|---|---|---|---|---|
30 |
29 |
1 |
96.7% |
|
229 |
228 |
1 |
99.6% |
|
71 |
70 |
1 |
98.6% |
|
143 |
132 |
11 |
92.3% |
|
42 |
41 |
1 |
97.6% |
|
51 |
50 |
1 |
98.0% |
|
121 |
118 |
3 |
97.5% |
|
239 |
239 |
0 |
100.0% |
|
369 |
361 |
8 |
97.8% |
|
75 |
68 |
7 |
90.7% |
|
22 |
21 |
1 |
95.5% |
|
171 |
171 |
0 |
100.0% |
|
52 |
52 |
0 |
100.0% |
|
31 |
26 |
5 |
83.9% |
|
43 |
43 |
0 |
100.0% |
|
15 |
15 |
0 |
100.0% |
|
11 |
8 |
3 |
72.7% |
|
130 |
130 |
0 |
100.0% |
|
12 |
11 |
1 |
91.7% |
|
143 |
143 |
0 |
100.0% |
|
42 |
42 |
0 |
100.0% |
|
163 |
161 |
2 |
98.8% |
|
94 |
94 |
0 |
100.0% |
|
383 |
383 |
0 |
100.0% |
Source
pyVHDLModel/__init__.pydocumentedundocumentedignoredexcludednot counted
32"""
33**An abstract VHDL language model.**
34
35This package provides a unified abstract language model for VHDL. Projects reading from source files can derive own
36classes and implement additional logic to create a concrete language model for their tools.
37
38Projects consuming pre-processed VHDL data (parsed, analyzed or elaborated) can build higher level features and services
39on such a model, while supporting multiple frontends.
40
41.. admonition:: Copyright Information
42
43 :copyright: Copyright 2017-2026 Patrick Lehmann - Bötzingen, Germany
44 :copyright: Copyright 2016-2017 Patrick Lehmann - Dresden, Germany
45 :license: Apache License, Version 2.0
46"""
...
48
49__author__ = "Patrick Lehmann"
50__email__ = "Paebbels@gmail.com"
51__copyright__ = "2016-2026, Patrick Lehmann"
52__license__ = "Apache License, Version 2.0"
53__version__ = "0.40.0rc4"
55__project_url__ = "https://github.com/VHDL/pyVHDLModel"
56__documentation_url__ = "https://vhdl.github.io/pyVHDLModel"
57__issue_tracker_url__ = "https://GitHub.com/VHDL/pyVHDLModel/issues"
58
...
105
108ConcurrentDeclarationRegionMixin._DECLARED_ITEM_TYPES = (
109 BaseType, Subprogram, Package, PackageBody, Constant, Signal, SharedVariable, File, Alias, Component, Attribute,
110 AttributeSpecification, ComponentConfiguration, ModeViewDeclaration, UseClause, PSLEntity
111)
112Package._DECLARED_ITEM_TYPES = (*ConcurrentDeclarationRegionMixin._DECLARED_ITEM_TYPES, DeferredConstant)
113SequentialDeclarationRegionMixin._DECLARED_ITEM_TYPES = (
114 BaseType, Subprogram, Package, PackageBody, Constant, Variable, File, Alias, Attribute, AttributeSpecification,
115 UseClause
116)
117ProtectedTypeDeclarationRegionMixin._DECLARED_ITEM_TYPES = (Subprogram, )
118
120@export
121@unique
122class VHDLVersion(Enum):
123 """
124 An enumeration for all possible version numbers for VHDL and VHDL-AMS.
125
126 A version can be given as integer or string and is represented as a unified
127 enumeration value.
128
129 This enumeration supports compare operators.
130 """
131
132 Any = -1 #: Any
133 VHDL87 = 87 #: VHDL-1987
134 VHDL93 = 93 #: VHDL-1993
135 AMS93 = 1993 #: VHDL-AMS-1993
136 AMS99 = 1999 #: VHDL-AMS-1999
137 VHDL2000 = 2000 #: VHDL-2000
138 VHDL2002 = 2002 #: VHDL-2002
139 VHDL2008 = 2008 #: VHDL-2008
140 AMS2017 = 2017 #: VHDL-AMS-2017
141 VHDL2019 = 2019 #: VHDL-2019
142 Latest = 10000 #: Latest VHDL (2019)
143
144 __VERSION_MAPPINGS__: dict[Union[int, str], Enum] = {
145 -1: Any,
146 87: VHDL87,
147 93: VHDL93,
148 # 93: AMS93,
149 99: AMS99,
150 0: VHDL2000,
151 2: VHDL2002,
152 8: VHDL2008,
153 17: AMS2017,
154 19: VHDL2019,
155 1987: VHDL87,
156 # 1993: VHDL93,
157 1993: AMS93,
158 1999: AMS99,
159 2000: VHDL2000,
160 2002: VHDL2002,
161 2008: VHDL2008,
162 2017: AMS2017,
163 2019: VHDL2019,
164 10000: Latest,
165 "Any": Any,
166 "87": VHDL87,
167 "93": VHDL93,
168 # "93": AMS93,
169 "99": AMS99,
170 "00": VHDL2000,
171 "02": VHDL2002,
172 "08": VHDL2008,
173 "17": AMS2017,
174 "19": VHDL2019,
175 "1987": VHDL87,
176 # "1993": VHDL93,
177 "1993": AMS93,
178 "1999": AMS99,
179 "2000": VHDL2000,
180 "2002": VHDL2002,
181 "2008": VHDL2008,
182 "2017": AMS2017,
183 "2019": VHDL2019,
184 "Latest": Latest,
185 } #: Dictionary of VHDL and VHDL-AMS year codes variants as integer and strings for mapping to unique enum values.
186
187 def __init__(self, *_) -> None:
188 """Patch the embedded MAP dictionary"""
...
192
193 @classmethod
194 def Parse(cls, value: Union[int, str]) -> VHDLVersion:
195 """
196 Parses a VHDL or VHDL-AMS year code as integer or string to an enum value.
197
198 :param value: VHDL/VHDL-AMS year code.
199 :returns: Enumeration value.
200 :raises ValueError: If the year code is not recognized.
201 """
...
206
207 def __lt__(self, other: Any) -> bool:
208 """
209 Compare two VHDL/VHDL-AMS versions if the version is less than the second operand.
210
211 :param other: Parameter to compare against.
212 :returns: True if version is less than the second operand.
213 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
214 """
...
221
222 def __le__(self, other: Any) -> bool:
223 """
224 Compare two VHDL/VHDL-AMS versions if the version is less or equal than the second operand.
225
226 :param other: Parameter to compare against.
227 :returns: True if version is less or equal than the second operand.
228 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
229 """
...
236
237 def __gt__(self, other: Any) -> bool:
238 """
239 Compare two VHDL/VHDL-AMS versions if the version is greater than the second operand.
240
241 :param other: Parameter to compare against.
242 :returns: True if version is greater than the second operand.
243 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
244 """
...
251
252 def __ge__(self, other: Any) -> bool:
253 """
254 Compare two VHDL/VHDL-AMS versions if the version is greater or equal than the second operand.
255
256 :param other: Parameter to compare against.
257 :returns: True if version is greater or equal than the second operand.
258 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
259 """
...
266
267 def __ne__(self, other: Any) -> bool:
268 """
269 Compare two VHDL/VHDL-AMS versions if the version is unequal to the second operand.
270
271 :param other: Parameter to compare against.
272 :returns: True if version is unequal to the second operand.
273 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
274 """
...
281
282 def __eq__(self, other: Any) -> bool:
283 """
284 Compare two VHDL/VHDL-AMS versions if the version is equal to the second operand.
285
286 :param other: Parameter to compare against.
287 :returns: True if version is equal to the second operand.
288 :raises TypeError: If parameter ``other`` is not of type :class:`VHDLVersion`.
289 """
...
299
300 def __hash__(self) -> int:
301 """
302 Return the hash of the VHDL version using the underlying version number.
303
304 .. note::
305
306 ``Any`` compares equal to every other member (see :meth:`__eq__`), which no hash value can satisfy
307 simultaneously for all members without collapsing every member to the same hash. This implementation
308 hashes by ``self.value``, which is internally consistent for all comparisons *except* those
309 involving ``Any`` - avoid using ``Any`` as a dict key or set member.
310
311 :returns: Hash value of the underlying VHDL version number.
312 """
...
314
315 @readonly
316 def IsVHDL(self) -> bool:
317 """
318 Check if the version is a VHDL (not VHDL-AMS) version.
319
320 :returns: ``True``, if the version is a VHDL version.
321 """
...
323
324 @readonly
325 def IsAMS(self) -> bool:
326 """
327 Check if the version is a VHDL-AMS (not VHDL) version.
328
329 :returns: ``True``, if the version is a VHDL-AMS version.
330 """
...
332
333 def __str__(self) -> str:
334 """
335 Formats the VHDL version to pattern ``VHDL'xx`` or in case of VHDL-AMS to ``VHDL-AMS'xx``.
336
337 :returns: Formatted VHDL/VHDL-AMS version.
338 """
...
349
350 def __repr__(self) -> str:
351 """
352 Formats the VHDL/VHDL-AMS version to pattern ``xxxx``.
353
354 :returns: Formatted VHDL/VHDL-AMS version.
355 """
...
362
364@export
365class IEEEFlavor(Flag):
366 """
367 The ``IEEE`` VHDL library as a fixed set of predefined VHDL packages according to IEEE Std. 1076.
368
369 Nonetheless, some vendors decided to sneak in additional packages into the ``IEEE`` namespace. |br|
370 Supported flavors are:
371
372 * ``Synopsys``
373 * ``MentorGraphics``
374
375 In addition, IEEE Std. 1076.X extensions can be loaded. |br|
376 Supported extensions are:
377
378 * ``WithVITAL`` - IEEE Std. 1076.4
379
380 """
381 Unknown = 0 #: Unknown IEEE flavor
382 IEEE = 1 #: IEEE Std. 1076 compliant list of IEEE packages.
383 Synopsys = 2 #: Additional packages created by Synopsys are visible within the IEEE library.
384 MentorGraphics = 4 #: Additional packages created by Mentor Graphics are visible within the IEEE library.
385 WithVITAL = 32 #: Additionally load IEEE Std 1076.4 VITAL packages. (VITAL = VHDL Initiative Towards ASIC Libraries)
386
388@export
389@unique
390class ObjectClass(Enum):
391 """
392 An ``ObjectClass`` is an enumeration and represents an object's class (``constant``, ``signal``, ...).
393
394 In case no *object class* is defined, ``Default`` is used, so the *object class* is inferred from context.
395 """
396
397 Default = 0 #: Object class not defined, thus it's context dependent.
398 Constant = 1 #: Constant
399 Variable = 2 #: Variable
400 Signal = 3 #: Signal
401 File = 4 #: File
402 Type = 5 #: Type
404 Procedure = 6 #: Procedure
405 Function = 7 #: Function
406
407 def __str__(self) -> str:
408 """
409 Formats the object class.
410
411 :returns: Formatted object class.
412 """
...
414
416@export
417@unique
418class DesignUnitKind(Flag):
419 """
420 A ``DesignUnitKind`` is an enumeration and represents the kind of design unit (``Entity``, ``Architecture``, ...).
421
422 """
423 Context = auto() #: Context
424 Package = auto() #: Package
425 PackageBody = auto() #: Package Body
426 Entity = auto() #: Entity
427 Architecture = auto() #: Architecture
428 Configuration = auto() #: Configuration
429
430 Primary = Context | Configuration | Entity | Package #: List of primary design units.
431 Secondary = PackageBody | Architecture #: List of secondary design units.
432 WithContext = Configuration | Package | Entity | PackageBody | Architecture #: List of design units with a context.
433 WithDeclaredItems = Package | Entity | PackageBody | Architecture #: List of design units having a declaration region.
434
435 All = Primary | Secondary #: List of all design units.
436
438@export
439@unique
440class DependencyGraphVertexKind(Flag):
441 """
442 A ``DependencyGraphVertexKind`` is an enumeration and represents the kind of vertex in the dependency graph.
443 """
444 Document = auto() #: A document (VHDL source file).
445 Library = auto() #: A VHDL library.
446
447 Context = auto() #: A context design unit.
448 Package = auto() #: A package design unit.
449 PackageBody = auto() #: A package body design unit.
450 Entity = auto() #: A entity design unit.
451 Architecture = auto() #: A architecture design unit.
452 Component = auto() #: A VHDL component.
453 Configuration = auto() #: A configuration design unit.
454
456@export
457@unique
458class DependencyGraphEdgeKind(Flag):
459 """
460 A ``DependencyGraphEdgeKind`` is an enumeration and represents the kind of edge in the dependency graph.
461 """
462 Document = auto()
463 Library = auto()
464 Context = auto()
465 Package = auto()
466 Entity = auto()
468 Configuration = auto()
469 Component = auto()
470
471 DeclaredIn = auto()
472 Order = auto()
473 Reference = auto()
474 Implementation = auto()
475 Instantiation = auto()
476
477 SourceFile = Document | DeclaredIn
478 CompileOrder = Document | Order
479
480 LibraryClause = Library | Reference
481 UseClause = Package | Reference
482 ContextReference = Context | Reference
483
484 EntityImplementation = Entity | Implementation
485 PackageImplementation = Package | Implementation
486
487 EntityInstantiation = Entity | Instantiation
488 ComponentInstantiation = Component | Instantiation
489 ConfigurationInstantiation = Configuration | Instantiation
490
491 PackageInstantiation = Package | Instantiation
492
494@export
495@unique
496class ObjectGraphVertexKind(Flag):
497 """
498 A ``ObjectGraphVertexKind`` is an enumeration and represents the kind of vertex in the object graph.
499 """
500 Type = auto()
501 Subtype = auto()
502
503 Constant = auto()
504 DeferredConstant = auto()
505 Variable = auto()
506 Signal = auto()
507 File = auto()
508
509 Alias = auto()
510
512@export
513@unique
514class ObjectGraphEdgeKind(Flag):
515 """
516 A ``ObjectGraphEdgeKind`` is an enumeration and represents the kind of edge in the object graph.
517 """
518 BaseType = auto()
519 Subtype = auto()
520
521 ReferenceInExpression = auto()
522
524@export
525class Design(ModelEntity, AllowBlackboxMixin):
526 """
527 A ``Design`` represents set of VHDL libraries as well as all loaded and analysed source files (see :class:`~pyVHDLModel.Document`).
528
529 It's the root of this code document-object-model (CodeDOM). It contains at least one VHDL library (see :class:`~pyVHDLModel.Library`). When the design is
530 analysed (see :meth:`Analyze`), multiple graph data structures will be created and populated with vertices and edges. As a first result, the design's compile
531 order and hierarchy can be iterated. As a second result, the design's *top-level* is identified and referenced from the design (see :attr:`TopLevel`).
532
533 The *design* contains references to the following graphs:
534
535 * :attr:`DependencyGraph`
536 * :attr:`CompileOrderGraph`
537 * :attr:`HierarchyGraph`
538 * :attr:`ObjectGraph`
539 """
540 _name: Nullable[str] #: Name of the design.
541 _libraries: dict[str, Library] #: List of all libraries defined for a design.
542 _documents: list[Document] #: List of all documents loaded for a design.
543 _documentsByPath: dict[Path, Document] #: The documents loaded for a design, indexed by path.
544 _dependencyGraph: Graph #: The graph of all dependencies in the designs.
545 _compileOrderGraph: Graph #: A graph derived from dependency graph containing the order of documents for compilation.
546 _hierarchyGraph: Graph #: A graph derived from dependency graph containing the design hierarchy.
547 _objectGraph: Graph #: The graph of all types and objects in the design.
548 _toplevel: Union[Entity, Configuration] #: When computed, the toplevel design unit is cached in this field.
549
550 def __init__(
551 self,
552 name: Nullable[str] = None,
553 allowBlackbox: bool = False
554 ) -> None:
555 """
556 Initialize a VHDL design.
557
558 :param name: Name of the design.
559 :param allowBlackbox: Specify if blackboxes are allowed in this design.
560 """
...
575
576 @readonly
577 def Name(self) -> Nullable[str]:
578 """
579 Read-only property to access the design's name (:attr:`_name`).
580
581 :returns: The name of the design.
582 """
...
584
585 @readonly
586 def Libraries(self) -> dict[str, Library]:
587 """
588 Read-only property to access the dictionary of library names and VHDL libraries (:attr:`_libraries`).
589
590 :returns: A dictionary of library names and VHDL libraries.
591 """
...
593
594 @readonly
595 def Documents(self) -> list[Document]:
596 """
597 Read-only property to access the list of all documents (VHDL source files) loaded for this design (:attr:`_documents`).
598
599 :returns: A list of all documents.
600 """
...
602
603 @readonly
604 def CompileOrderGraph(self) -> Graph:
605 """
606 Read-only property to access the compile-order graph (:attr:`_compileOrderGraph`).
607
608 :returns: Reference to the compile-order graph.
609 """
...
611
612 @readonly
613 def DependencyGraph(self) -> Graph:
614 """
615 Read-only property to access the dependency graph (:attr:`_dependencyGraph`).
616
617 :returns: Reference to the dependency graph.
618 """
...
620
621 @readonly
622 def HierarchyGraph(self) -> Graph:
623 """
624 Read-only property to access the hierarchy graph (:attr:`_hierarchyGraph`).
625
626 :returns: Reference to the hierarchy graph.
627 """
...
629
630 @readonly
631 def ObjectGraph(self) -> Graph:
632 """
633 Read-only property to access the object graph (:attr:`_objectGraph`).
634
635 :returns: Reference to the object graph.
636 """
...
638
639 @readonly
640 def TopLevel(self) -> Union[Entity, Configuration]:
641 """
642 Read-only property to access the design's *top-level* (:attr:`_toplevel`).
643
644 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``
645 is added to :attr:`_hierarchyGraph` referencing that single element. In addition, the result is cached in :attr:`_toplevel`.
646
647 :returns: Reference to the design's *top-level*.
648 :raises VHDLModelException: If the hierarchy graph is not yet computed from dependency graph.
649 :raises VHDLModelException: If there is more than one *top-level*.
650 """
...
667
668 def LoadStdLibrary(self) -> Library:
669 """
670 Load the predefined VHDL library ``std`` into the design.
671
672 This will create a virtual source code file ``std.vhdl`` and register VHDL design units of library ``std`` to that file.
673
674 :returns: The library object of library ``std``.
675 """
...
687
688 def LoadIEEELibrary(self, flavor: Nullable[IEEEFlavor] = None) -> Library:
689 """
690 Load the predefined VHDL library ``ieee`` into the design.
691
692 This will create a virtual source code file ``ieee.vhdl`` and register VHDL design units of library ``ieee`` to that file.
693
694 :param flavor: Select the IEEE library flavor: IEEE, Synopsys, MentorGraphics.
695 :returns: The library object of library ``ieee``.
696 """
...
708
709 def AddLibrary(self, library: Library) -> None:
710 """
711 Add a VHDL library to the design.
712
713 Ensure the libraries name doesn't collide with existing libraries in the design. |br|
714 If ok, set the libraries parent reference to the design.
715
716 :param library: Library object to loaded.
717 :raises LibraryExistsInDesignError: If the library already exists in the design.
718 :raises LibraryRegisteredToForeignDesignError: If library is already used by a different design.
719 """
...
729
730 def RemoveLibrary(self, library: Library) -> None:
731 """
732 Remove a VHDL library from the design.
733
734 The library is detached: its parent is cleared. Its design units stay design units of the library, so the library
735 can be added to a design again (:meth:`AddLibrary`).
736
737 :param library: The VHDL library to remove.
738 :raises ValueError: If parameter 'library' is ``None``.
739 :raises TypeError: If parameter 'library' is not of type :class:`Library`.
740 :raises NotAChildError: If parameter 'library' is not a library of this design.
741 :raises LibraryInUseError: If documents of this design still use the library.
742
743 .. seealso::
744
745 :meth:`AddLibrary`
746 |rarr| Add a VHDL library to the design.
747 :meth:`RemoveDocument`
748 |rarr| Remove a document from the design.
749 """
...
777
778 def GetLibrary(self, libraryName: str) -> Library:
779 """
780 Return an (existing) VHDL library object of name ``libraryName``.
781
782 If the requested VHDL library doesn't exist, a new VHDL library with that name will be created.
783
784 :param libraryName: Name of the requested VHDL library.
785 :returns: The VHDL library object.
786 """
...
795
796 def GetEntity(self, libraryName: str, entityName: str) -> Entity:
797 """
798 Return the entity named ``entityName`` from the library named ``libraryName``.
799
800 The lookup is case-insensitive. Nothing is created, if the library or entity doesn't exist.
801
802 :param libraryName: Name of the library containing the entity.
803 :param entityName: Name of the requested entity.
804 :returns: The entity.
805 :raises ValueError: If parameter 'libraryName' is None or empty.
806 :raises TypeError: If parameter 'libraryName' is not of type :class:`str`.
807 :raises ValueError: If parameter 'entityName' is None or empty.
808 :raises TypeError: If parameter 'entityName' is not of type :class:`str`.
809 :raises LibraryNotFoundError: If the library doesn't exist in the design.
810 :raises EntityNotFoundError: If the entity doesn't exist in the library.
811 """
...
840
841 def SearchEntity(self, entityName: str) -> tuple[Entity, ...]:
842 """
843 Return all entities named ``entityName`` from the libraries of the design.
844
845 The search is case-insensitive. Each entity references its library by
846 :attr:`~pyVHDLModel.DesignUnit.DesignUnit.Library`.
847
848 :param entityName: Name of the searched entity.
849 :returns: Tuple of entities in the order of the design's libraries, empty if no library contains one.
850 :raises ValueError: If parameter 'entityName' is None or empty.
851 :raises TypeError: If parameter 'entityName' is not of type :class:`str`.
852 """
...
868
869 def GetPackage(self, libraryName: str, packageName: str) -> Package:
870 """
871 Return the package named ``packageName`` from the library named ``libraryName``.
872
873 The lookup is case-insensitive. Nothing is created, if the library or package doesn't exist.
874
875 :param libraryName: Name of the library containing the package.
876 :param packageName: Name of the requested package.
877 :returns: The package.
878 :raises ValueError: If parameter 'libraryName' is None or empty.
879 :raises TypeError: If parameter 'libraryName' is not of type :class:`str`.
880 :raises ValueError: If parameter 'packageName' is None or empty.
881 :raises TypeError: If parameter 'packageName' is not of type :class:`str`.
882 :raises LibraryNotFoundError: If the library doesn't exist in the design.
883 :raises PackageNotFoundError: If the package doesn't exist in the library.
884 """
...
913
914 def SearchPackage(self, packageName: str) -> tuple[Package, ...]:
915 """
916 Return all packages named ``packageName`` from the libraries of the design.
917
918 The search is case-insensitive. Each package references its library by
919 :attr:`~pyVHDLModel.DesignUnit.DesignUnit.Library`.
920
921 :param packageName: Name of the searched package.
922 :returns: Tuple of packages in the order of the design's libraries, empty if no library contains one.
923 :raises ValueError: If parameter 'packageName' is None or empty.
924 :raises TypeError: If parameter 'packageName' is not of type :class:`str`.
925 """
...
941
942 def GetConfiguration(self, libraryName: str, configurationName: str) -> Configuration:
943 """
944 Return the configuration named ``configurationName`` from the library named ``libraryName``.
945
946 The lookup is case-insensitive. Nothing is created, if the library or configuration doesn't exist.
947
948 :param libraryName: Name of the library containing the configuration.
949 :param configurationName: Name of the requested configuration.
950 :returns: The configuration.
951 :raises ValueError: If parameter 'libraryName' is None or empty.
952 :raises TypeError: If parameter 'libraryName' is not of type :class:`str`.
953 :raises ValueError: If parameter 'configurationName' is None or empty.
954 :raises TypeError: If parameter 'configurationName' is not of type :class:`str`.
955 :raises LibraryNotFoundError: If the library doesn't exist in the design.
956 :raises ConfigurationNotFoundError: If the configuration doesn't exist in the library.
957 """
...
986
987 def SearchConfiguration(self, configurationName: str) -> tuple[Configuration, ...]:
988 """
989 Return all configurations named ``configurationName`` from the libraries of the design.
990
991 The search is case-insensitive. Each configuration references its library by
992 :attr:`~pyVHDLModel.DesignUnit.DesignUnit.Library`.
993
994 :param configurationName: Name of the searched configuration.
995 :returns: Tuple of configurations in the order of the design's libraries, empty if no library
996 contains one.
997 :raises ValueError: If parameter 'configurationName' is None or empty.
998 :raises TypeError: If parameter 'configurationName' is not of type :class:`str`.
999 """
...
1015
1016 def GetContext(self, libraryName: str, contextName: str) -> Context:
1017 """
1018 Return the context named ``contextName`` from the library named ``libraryName``.
1019
1020 The lookup is case-insensitive. Nothing is created, if the library or context doesn't exist.
1021
1022 :param libraryName: Name of the library containing the context.
1023 :param contextName: Name of the requested context.
1024 :returns: The context.
1025 :raises ValueError: If parameter 'libraryName' is None or empty.
1026 :raises TypeError: If parameter 'libraryName' is not of type :class:`str`.
1027 :raises ValueError: If parameter 'contextName' is None or empty.
1028 :raises TypeError: If parameter 'contextName' is not of type :class:`str`.
1029 :raises LibraryNotFoundError: If the library doesn't exist in the design.
1030 :raises ContextNotFoundError: If the context doesn't exist in the library.
1031 """
...
1060
1061 def SearchContext(self, contextName: str) -> tuple[Context, ...]:
1062 """
1063 Return all contexts named ``contextName`` from the libraries of the design.
1064
1065 The search is case-insensitive. Each context references its library by
1066 :attr:`~pyVHDLModel.DesignUnit.DesignUnit.Library`.
1067
1068 :param contextName: Name of the searched context.
1069 :returns: Tuple of contexts in the order of the design's libraries, empty if no library contains one.
1070 :raises ValueError: If parameter 'contextName' is None or empty.
1071 :raises TypeError: If parameter 'contextName' is not of type :class:`str`.
1072 """
...
1088
1090 def AddDocument(self, document: Document, library: Library) -> None:
1091 """
1092 Add a document (VHDL source file) to the design and register all embedded design units to the given VHDL library.
1093
1094 All checks are done, before the design, the document or the library is changed.
1095
1096 .. rubric:: Algorithm
1097
1098 1. Check the document isn't a document of a design, and the design contains no document of the same path.
1099 2. Check none of the document's entities, architectures, packages, package bodies, configurations and contexts
1100 exists in the library.
1101 3. Add the document to the design and set the document's library.
1102 4. Add the document's entities, architectures, packages, package bodies, configurations and contexts to the
1103 library and update their library membership.
1104
1105 :param document: The VHDL source code file.
1106 :param library: The VHDL library used to register the embedded design units to.
1107 :raises ValueError: If parameter 'document' is ``None``.
1108 :raises TypeError: If parameter 'document' is not of type :class:`Document`.
1109 :raises AlreadyInDesignError: If parameter 'document' is already a document of a design.
1110 :raises DuplicateDocumentError: If the design already contains a document of the same path.
1111 :raises ValueError: If parameter 'library' is ``None``.
1112 :raises TypeError: If parameter 'library' is not of type :class:`Library`.
1113 :raises LibraryNotRegisteredError: If the given VHDL library is not a library in the design.
1114 :raises EntityExistsInLibraryError: If the processed entity's name is already existing in the VHDL library.
1115 :raises ArchitectureExistsInLibraryError: If the processed architecture's name is already existing in the VHDL library.
1116 :raises PackageExistsInLibraryError: If the processed package's name is already existing in the VHDL library.
1117 :raises PackageBodyExistsError: If the processed package body's name is already existing in the VHDL library.
1118 :raises ConfigurationExistsInLibraryError: If the processed configuration's name is already existing in the VHDL library.
1119 :raises ContextExistsInLibraryError: If the processed context's name is already existing in the VHDL library.
1120
1121 .. seealso::
1122
1123 :meth:`RemoveDocument`
1124 |rarr| Remove a document from the design.
1125 """
...
1215
1216 def RemoveDocument(self, document: Document) -> None:
1217 """
1218 Remove a document (VHDL source file) from the design.
1219
1220 The document is detached: its parent and library are cleared. Its entities, architectures, packages, package bodies,
1221 configurations and contexts leave the library, and their parent is cleared. The design units stay design units of
1222 the document, so the document can be added to a design again.
1223
1224 :param document: The VHDL source code file.
1225 :raises ValueError: If parameter 'document' is ``None``.
1226 :raises TypeError: If parameter 'document' is not of type :class:`Document`.
1227 :raises NotAChildError: If parameter 'document' is not a document of this design.
1228
1229 .. seealso::
1230
1231 :meth:`AddDocument`
1232 |rarr| Add a document to the design.
1233 """
...
1285
1286 def IterateDesignUnits(self, filter: DesignUnitKind = DesignUnitKind.All) -> Generator[DesignUnit, None, None]:
1287 """
1288 Iterate all design units in the design.
1289
1290 A union of :class:`DesignUnitKind` values can be given to filter the returned result for suitable design units.
1291
1292 .. rubric:: Algorithm
1293
1294 1. Iterate all VHDL libraries.
1295
1296 1. Iterate all contexts in that library.
1297 2. Iterate all packages in that library.
1298 3. Iterate all package bodies in that library.
1299 4. Iterate all entites in that library.
1300 5. Iterate all architectures in that library.
1301 6. Iterate all configurations in that library.
1302
1303 :param filter: An enumeration with possibly multiple flags to filter the returned design units.
1304 :returns: A generator to iterate all matched design units in the design.
1305
1306 .. seealso::
1307
1308 :meth:`pyVHDLModel.Library.IterateDesignUnits`
1309 Iterate all design units in the library.
1310 :meth:`pyVHDLModel.Document.IterateDesignUnits`
1311 Iterate all design units in the document.
1312 """
...
1315
1316 def Analyze(self) -> None:
1317 """
1318 Analyze the whole design.
1319
1320 The analysis can be repeated, e.g. after the design was changed: the previous analysis is reset first.
1321
1322 .. rubric:: Algorithm
1323
1324 1. Reset a previous analysis. |br|
1325 |rarr| :meth:`ResetAnalysis`
1326 2. Analyze dependencies of design units. |br|
1327 This will also yield the design hierarchy and the compiler order.
1328 3. Analyze dependencies of types and objects.
1329
1330 .. seealso::
1331
1332 :meth:`ResetAnalysis`
1333 Reset everything an analysis derived.
1334
1335 :meth:`AnalyzeDependencies`
1336 Analyze the dependencies of design units.
1337
1338 :meth:`AnalyzeObjects`
1339 Analyze the dependencies of types and objects.
1340
1341 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
1342 :class:`~pyTooling.Warning.WarningCollector` collects the
1343 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
1344 """
...
1348
1349 def ResetAnalysis(self) -> None:
1350 """
1351 Reset everything an analysis (:meth:`Analyze`) derived, so the design can be analyzed again.
1352
1353 Everything built by the user is kept: libraries, documents, design units, declarations and the declarations in
1354 namespaces. Lookup tables built by indexing (e.g. :meth:`IndexPackages`) are kept too, as indexing again yields
1355 the same lookup tables. Resetting a design, which wasn't analyzed, changes nothing.
1356
1357 .. rubric:: Algorithm
1358
1359 1. Delete the dependency, compile-order, hierarchy and object graph (:meth:`~pyTooling.Graph.Graph.Delete`), so
1360 their vertices and edges are freed at once, replace them by empty graphs, and forget the top-level.
1361 2. Clear the references to vertices of all libraries, documents and design units.
1362 3. Clear the references of all design units: referenced libraries, packages and contexts, the symbols of library
1363 clauses, use clauses and context references, and the items imported into namespaces.
1364 4. Unlink architectures from entities and package bodies from packages: an entity's architectures, a package's
1365 body, the symbols referencing the entity or package, and the link to the parent namespace.
1366 5. Unlink package instantiations from their generic package: the symbol and the components copied from it.
1367 6. Unbind all components: their entity and blackbox state.
1368 7. Clear the symbols of entity and component instantiations.
1369 """
...
1433
1434 def AnalyzeDependencies(self) -> None:
1435 """
1436 Analyze the dependencies of design units.
1437
1438 .. rubric:: Algorithm
1439
1440 1. Create all vertices of the dependency graph by iterating all design units in all libraries. |br|
1441 |rarr| :meth:`CreateDependencyGraph`
1442 2. Create the compile order graph. |br|
1443 |rarr| :meth:`CreateCompileOrderGraph`
1444 3. Index all packages. |br|
1445 |rarr| :meth:`IndexPackages`
1446 4. Index all entities. |br|
1447 |rarr| :meth:`IndexEntities`
1448 5. Index all architectures. |br|
1449 |rarr| :meth:`IndexArchitectures`
1450 6. Link all contexts |br|
1451 |rarr| :meth:`LinkContexts`
1452 7. Link all architectures. |br|
1453 |rarr| :meth:`LinkArchitectures`
1454 8. Link all package bodies. |br|
1455 |rarr| :meth:`LinkPackageBodies`
1456 9. Link all package instances. |br|
1457 |rarr| :meth:`LinkPackageInstances`
1458 10. Link all library references. |br|
1459 |rarr| :meth:`LinkLibraryReferences`
1460 11. Link all package references. |br|
1461 |rarr| :meth:`LinkPackageReferences`
1462 12. Link all context references. |br|
1463 |rarr| :meth:`LinkContextReferences`
1464 13. Link all components. |br|
1465 |rarr| :meth:`LinkComponents`
1466 14. Link all instantiations. |br|
1467 |rarr| :meth:`LinkInstantiations`
1468 15. Create the hierarchy graph. |br|
1469 |rarr| :meth:`CreateHierarchyGraph`
1470 16. Compute the compile order. |br|
1471 |rarr| :meth:`ComputeCompileOrder`
1472
1473 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
1474 :class:`~pyTooling.Warning.WarningCollector` collects the
1475 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
1476 """
...
1496
1497 def AnalyzeObjects(self) -> None:
1498 """
1499 Analyze the dependencies of types and objects.
1500
1501 .. rubric:: Algorithm
1502
1503 1. Index all entities. |br|
1504 |rarr| :meth:`IndexEntities`
1505 2. Index all package bodies. |br|
1506 |rarr| :meth:`IndexPackageBodies`
1507 3. Import objects. |br|
1508 |rarr| :meth:`ImportObjects`
1509 4. Create the type and object graph. |br|
1510 |rarr| :meth:`CreateTypeAndObjectGraph`
1511
1512 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
1513 :class:`~pyTooling.Warning.WarningCollector` collects the
1514 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
1515 """
...
1521
1522 def CreateDependencyGraph(self) -> None:
1523 """
1524 Create all vertices of the dependency graph by iterating all design units in all libraries.
1525
1526 This method will purely create a sea of vertices without any linking between vertices. The edges will be created later by other methods. |br|
1527 See :meth:`AnalyzeDependencies` for these methods and their algorithmic order.
1528
1529 Each vertex has the following properties:
1530
1531 * The vertex' ID is the design unit's identifier.
1532 * The vertex' value references the design unit.
1533 * A key-value-pair called ``kind`` denotes the vertex's kind as an enumeration value of type :class:`DependencyGraphVertexKind`.
1534 * A key-value-pair called ``predefined`` denotes if the referenced design unit is a predefined language entity.
1535
1536 .. rubric:: Algorithm
1537
1538 1. Iterate all libraries in the design.
1539
1540 * Create a vertex for that library and reference the library by the vertex' value field. |br|
1541 In return, set the library's :attr:`~pyVHDLModel.Library._dependencyVertex` field to reference the created vertex.
1542
1543 1. Iterate all contexts in that library.
1544
1545 * Create a vertex for that context and reference the context by the vertex' value field. |br|
1546 In return, set the context's :attr:`~pyVHDLModel.DesignUnit.Context._dependencyVertex` field to reference the created vertex.
1547
1548 2. Iterate all packages in that library.
1549
1550 * Create a vertex for that package and reference the package by the vertex' value field. |br|
1551 In return, set the package's :attr:`~pyVHDLModel.DesignUnit.Package._dependencyVertex` field to reference the created vertex.
1552
1553 3. Iterate all package bodies in that library.
1554
1555 * Create a vertex for that package body and reference the package body by the vertex' value field. |br|
1556 In return, set the package body's :attr:`~pyVHDLModel.DesignUnit.PackageBody._dependencyVertex` field to reference the created vertex.
1557
1558 4. Iterate all entities in that library.
1559
1560 * Create a vertex for that entity and reference the entity by the vertex' value field. |br|
1561 In return, set the entity's :attr:`~pyVHDLModel.DesignUnit.Entity._dependencyVertex` field to reference the created vertex.
1562
1563 5. Iterate all architectures in that library.
1564
1565 * Create a vertex for that architecture and reference the architecture by the vertex' value field. |br|
1566 In return, set the architecture's :attr:`~pyVHDLModel.DesignUnit.Architecture._dependencyVertex` field to reference the created vertex.
1567
1568 6. Iterate all configurations in that library.
1569
1570 * Create a vertex for that configuration and reference the configuration by the vertex' value field. |br|
1571 In return, set the configuration's :attr:`~pyVHDLModel.DesignUnit.Configuration._dependencyVertex` field to reference the created vertex.
1572 """
...
1617
1618 def CreateCompileOrderGraph(self) -> None:
1619 """
1620 Create a compile-order graph with bidirectional references to the dependency graph.
1621
1622 Add vertices representing a document (VHDL source file) to the dependency graph. Each "document" vertex in dependency graph is copied into the compile-order
1623 graph and bidirectionally referenced.
1624
1625 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
1626 document relationship.
1627
1628 Each added vertex has the following properties:
1629
1630 * The vertex' ID is the document's filename.
1631 * The vertex' value references the document.
1632 * A key-value-pair called ``kind`` denotes the vertex's kind as an enumeration value of type :class:`DependencyGraphVertexKind`.
1633 * A key-value-pair called ``predefined`` does not exist.
1634
1635 .. rubric:: Algorithm
1636
1637 1. Iterate all documents in the design.
1638
1639 * Create a vertex for that document with the document's path as vertex ID and reference the document by the
1640 vertex' value field. |br|
1641 In return, set the documents's :attr:`~pyVHDLModel.Document._dependencyVertex` field to reference the created vertex.
1642 * Copy the vertex from dependency graph to compile-order graph and link both vertices bidirectionally. |br|
1643 In addition, set the documents's :attr:`~pyVHDLModel.Document._dependencyVertex` field to reference the copied vertex.
1644
1645 * Add a key-value-pair called ``compileOrderVertex`` to the dependency graph's vertex.
1646 * Add a key-value-pair called ``dependencyVertex`` to the compiler-order graph's vertex.
1647
1648 1. Iterate the documents design units and create an edge from the design unit's corresponding dependency vertex to the documents corresponding
1649 dependency vertex. This expresses a "design unit is located in document" relation.
1650
1651 * Add a key-value-pair called `kind`` denoting the edge's kind as an enumeration value of type :class:`DependencyGraphEdgeKind`.
1652 """
...
1669
1670 def ImportObjects(self) -> None:
1671 def _ImportObjects(package: Package) -> None:
...
1688
...
1696
1697 def CreateTypeAndObjectGraph(self) -> None:
1698 def _HandlePackage(package) -> None:
...
1770
1771 def _LinkSymbolsInExpression(expression, namespace: Namespace, typeVertex: Vertex) -> None:
...
1787
1788 def _LinkItems(package: Package) -> None:
...
1833
...
1843
1844 def LinkContexts(self) -> None:
1845 """
1846 Resolves and links all items (library clauses, use clauses and nested context references) in contexts.
1847
1848 It iterates all contexts in the design. Therefore, the library of the context is used as the working library. By
1849 default, the working library is implicitly referenced in :data:`_referencedLibraries`. In addition, a new empty
1850 dictionary is created in :data:`_referencedPackages` and :data:`_referencedContexts` for that working library.
1851
1852 At first, all library clauses are resolved (a library clause my have multiple library reference symbols). For each
1853 referenced library an entry in :data:`_referencedLibraries` is generated and new empty dictionaries in
1854 :data:`_referencedPackages` and :data:`_referencedContexts` for that working library. In addition, a vertex in the
1855 dependency graph is added for that relationship.
1856
1857 At second, all use clauses are resolved (a use clause my have multiple package member reference symbols). For each
1858 referenced package,
1859 """
...
1933
1934 def LinkArchitectures(self) -> None:
1935 """
1936 Link all architectures to corresponding entities in all libraries.
1937
1938 .. rubric:: Algorithm
1939
1940 1. Iterate all libraries:
1941
1942 1. Iterate all architecture groups (grouped per entity symbol's name).
1943 |rarr| :meth:`pyVHDLModel.Library.LinkArchitectures`
1944
1945 * Check if entity symbol's name exists as an entity in this library.
1946
1947 1. For each architecture in the same architecture group:
1948
1949 * Add architecture to entities architecture dictionary :attr:`pyVHDLModel.DesignUnit.Entity._architectures`.
1950 * Assign found entity to architecture's entity symbol :attr:`pyVHDLModel.DesignUnit.Architecture._entity`
1951 * Set parent namespace of architecture's namespace to the entitie's namespace.
1952 * Add an edge in the dependency graph from the architecture's corresponding dependency vertex to the entity's corresponding dependency vertex.
1953
1954 .. seealso::
1955
1956 :meth:`LinkPackageBodies`
1957 Link all package bodies to corresponding packages in all libraries.
1958 :meth:`LinkPackageInstances`
1959 Link all package instances to corresponding generic packages in all libraries.
1960 """
...
1963
1964 def LinkPackageBodies(self) -> None:
1965 """
1966 Link all package bodies to corresponding packages in all libraries.
1967
1968 .. rubric:: Algorithm
1969
1970 1. Iterate all libraries:
1971
1972 1. Iterate all package bodies.
1973 |rarr| :meth:`pyVHDLModel.Library.LinkPackageBodies`
1974
1975 * Check if package body symbol's name exists as a package in this library.
1976 * Add package body to package :attr:`pyVHDLModel.DesignUnit.Package._packageBody`.
1977 * Assign found package to package body's package symbol :attr:`pyVHDLModel.DesignUnit.PackageBody._package`
1978 * Set parent namespace of package body's namespace to the package's namespace.
1979 * Add an edge in the dependency graph from the package body's corresponding dependency vertex to the package's corresponding dependency vertex.
1980
1981 .. seealso::
1982
1983 :meth:`LinkArchitectures`
1984 Link all architectures to corresponding entities in all libraries.
1985 :meth:`LinkPackageInstances`
1986 Link all package instances to corresponding generic packages in all libraries.
1987 """
...
1990
1991 def LinkPackageInstances(self) -> None:
1992 """
1993 Link all package instances to corresponding generic packages in all libraries.
1994
1995 .. rubric:: Algorithm
1996
1997 1. Iterate all libraries:
1998
1999 1. Iterate all package instances.
2000 |rarr| :meth:`pyVHDLModel.Library.LinkPackageInstances`
2001
2002 .. todo::
2003
2004 * Check if package instance's symbol's name exists as a generic package in this library.
2005 * Add generic package to package instance :attr:`pyVHDLModel.DesignUnit.Package._packageBody`.
2006 * Assign found package to package body's package symbol :attr:`pyVHDLModel.DesignUnit.PackageBody._package`
2007 * Set parent namespace of package body's namespace to the package's namespace.
2008 * Add an edge in the dependency graph from the package body's corresponding dependency vertex to the package's corresponding dependency vertex.
2009
2010 .. seealso::
2011
2012 :meth:`LinkArchitectures`
2013 Link all architectures to corresponding entities in all libraries.
2014 :meth:`LinkPackageBodies`
2015 Link all package bodies to corresponding packages in all libraries.
2016 """
...
2019
2020 def LinkLibraryReferences(self) -> None:
2021 """
2022 Link all library references (library clause) to the matching VHDL library.
2023
2024 .. rubric:: Algorithm
2025
2026 1. Iterate all design units with contexts:
2027
2028 * If the design unit is a primary unit:
2029
2030 1. Iterate all library identifiers in ``DEFAULT_LIBRARIES`` (``std``):
2031
2032 * Get the referenced library by name from the design.
2033 * Add an entry in the design unit's ``_referencedLibraries`` dictionary referencing the referenced library.
2034 * Add an empty dictionary in the design unit's ``_referencedPackages`` dictionary.
2035 * Add an empty dictionary in the design unit's ``_referencedContexts`` dictionary.
2036 * Add an edge in the dependency graph from design unit to the referenced library.
2037
2038 2. Get the design unit's library:
2039
2040 * Add an entry in the design unit's ``_referencedLibraries`` dictionary referencing the referenced library.
2041 * Add an empty dictionary in the design unit's ``_referencedPackages`` dictionary.
2042 * Add an empty dictionary in the design unit's ``_referencedContexts`` dictionary.
2043 * Add an edge in the dependency graph from design unit to the referenced library.
2044
2045 * If the design unit is a secondary unit:
2046
2047 * If design unit is an architecture, get the corresponding entity's referenced libraries.
2048 * If design unit is a package body, get the corresponding package's referenced libraries.
2049 * Otherwise, raise an exception
2050
2051 For every referenced library create new dictionary entries in the design unit's ``_referencedLibraries``.
2052
2053 2. Iterate every library reference (library clause) in the design unit:
2054
2055 * Iterate every library symbol within the library reference:
2056
2057 * Get the library identifier from the symbol.
2058 * Continue the inner loop, if identifier is ``work``.
2059 * Get the referenced library from the design or raise an exception.
2060 * Update the library symbol's target with the referenced library.
2061 * Add an entry in the design unit's ``_referencedLibraries`` dictionary referencing the referenced library.
2062 * Add an empty dictionary in the design unit's ``_referencedPackages`` dictionary.
2063 * Add an empty dictionary in the design unit's ``_referencedContexts`` dictionary.
2064 * Add an edge in the dependency graph from design unit to the referenced library.
2065
2066 .. seealso::
2067
2068 :meth:`LinkPackageReferences`
2069 Link *use clause*.
2070 :meth:`LinkContextReferences`
2071 Link *context clause*.
2072 :meth:`AnalyzeDependencies`
2073 Analyze dependencies and link relations.
2074 """
...
2137
2138 def LinkPackageReferences(self) -> None:
2139 """
2140 Link all package references (use clause) to the matching packages.
2141
2142 .. rubric:: Algorithm
2143
2144 1. Iterate all design units with contexts:
2145
2146 * If the design unit is a primary unit:
2147
2148 * If primary unit isn't package ``std.standard``:
2149
2150 1. Iterate all library, packages tuples in ``DEFAULT_PACKAGES`` (``std``: [``standard``]):
2151
2152 * Raise an exception, if library isn't listed in design unit's ``_referencedLibraries``.
2153 * For every package in packages:
2154
2155 * Get the referenced package by library name and package name from the design.
2156 * Add an entry in the design unit's ``_referencedPackages`` dictionary referencing the referenced package.
2157 * Add an edge in the dependency graph from design unit to the referenced package.
2158
2159 * If the design unit is a secondary unit:
2160
2161 * If design unit is an architecture, get the corresponding entity's referenced packages.
2162 * If design unit is a package body, get the corresponding package's referenced packages.
2163 * Otherwise, raise an exception
2164
2165 For every referenced package create new dictionary entries in the design unit's ``_referencedPackages``.
2166
2167 2. Iterate every package reference (use clause) in the design unit:
2168
2169 * Iterate every package symbol within the package reference:
2170
2171 1. Get the library identifier from the symbol.
2172 2. Get the package identifier from the symbol.
2173 3. Resolve library:
2174
2175 * If library name is ``work``, get library from design unit.
2176 * If library name is not in design unit's ``_referencedLibraries``, raise an exception.
2177 * Otherwise, lookup library by name in design.
2178
2179 4. Resolve package:
2180
2181 * Lookup package by name in library.
2182
2183 5. Update design unit:
2184
2185 * Update the package symbol's target with the referenced package.
2186 * Add an entry in the design unit's ``_referencedPackages`` dictionary referencing the referenced package.
2187 * Add an edge in the dependency graph from design unit to the referenced package.
2188
2189 6. Import public package members.
2190
2191 * If package symbol is a ``AllPackageMembersReferenceSymbol``:
2192
2193 * Iterate all components within the referenced package and import each component into the design unit's
2194 namespace.
2195
2196 .. todo:: Other elements are not implemented.
2197
2198 * If package symbol is a ``PackageMemberReferenceSymbol``
2199
2200 .. todo:: Not implemented.
2201
2202 * Otherwise, raise an exception.
2203
2204 .. seealso::
2205
2206 :meth:`LinkLibraryReferences`
2207 Link *library clause*.
2208 :meth:`LinkContextReferences`
2209 Link *context clause*.
2210 :meth:`AnalyzeDependencies`
2211 Analyze dependencies and link relations.
2212 """
...
2307
2308 def LinkContextReferences(self) -> None:
2309 """
2310 Link all context references (context clause) to the matching context.
2311
2312 .. rubric:: Algorithm
2313
2314 1. Iterate all design units:
2315
2316 * Iterate all context references in the design unit:
2317
2318 * Iterate each context symbol within the context reference.
2319
2320 1. Get the library identifier from the symbol.
2321 2. Get the context identifier from the symbol.
2322 3. Resolve library:
2323
2324 * If library name is ``work``, get library from design unit.
2325 * If library name is not in design unit's ``_referencedLibraries``, raise an exception.
2326 * Otherwise, lookup library by name in design.
2327
2328 4. Resolve context:
2329
2330 * Lookup context by name in library.
2331
2332 5. Update design unit:
2333
2334 * Update the context symbol's target with the referenced context.
2335 * Add an entry in the design unit's ``_referencedContexts`` dictionary referencing the referenced context.
2336 * Add an edge in the dependency graph from design unit to the referenced context.
2337
2338 2. Iterate all context vertices in the dependency graph (``_dependencyGraph``) in topological order:
2339
2340 * Get the context from the context vertex.
2341 * Iterate all predecessor vertices (design unit vertices) of the context vertex:
2342
2343 1. Get the design unit from design unit vertex.
2344 2. Iterate referenced libraries of the context:
2345
2346 * Add an entry in the design unit's ``_referencedLibraries`` dictionary referencing the referenced library.
2347 * Add an empty dictionary in the design unit's ``_referencedPackages`` dictionary.
2348
2349 3. Iterate referenced packages of the context:
2350
2351 * Raise an exception if package name is already listed in ``_referencedPackages``.
2352 * Add an entry in the design unit's ``_referencedPackages`` dictionary referencing the referenced package.
2353
2354 .. seealso::
2355
2356 :meth:`LinkLibraryReferences`
2357 Link *library clause*.
2358 :meth:`LinkPackageReferences`
2359 Link *use clause*.
2360 :meth:`AnalyzeDependencies`
2361 Analyze dependencies and link relations.
2362 """
...
2412
2413 def LinkComponents(self) -> None:
2414 """
2415 Link components to matching entities found in same VHDL library.
2416
2417 .. rubric:: Algorithm
2418
2419 1. Iterate all design units with component declarations (packages and architectures):
2420
2421 1. Iterate all component declarations in a package or architecture:
2422
2423 * Check if an entity with matching name can be found in the VHDL library the package is declared within. If
2424 found, set the component's entity reference to that entity, otherwise check if blackboxes are allowed for
2425 that component. If so, mark the component as a blackbox, otherwise, raise an exception.
2426
2427 2. Iterate concurrent statements with declaration regions (block statements, generate statements) if the design
2428 unit is an architecture:
2429
2430 * If the statement is an :class:`IfGenerateStatement`:
2431
2432 1. Iterate declared components in the :class:`IfGenerateBranch`.
2433 2. Iterate declared components in each :class:`ElIfGenerateBranch`.
2434 3. Iterate declared components in the :class:`ElseGenerateBranch` if it exists.
2435
2436 * If the statement is an :class:`ForGenerateStatement`:
2437
2438 1. Iterate declared components.
2439
2440 * If the statement is an :class:`CaseGenerateStatement`:
2441
2442 1. Iterate declared components.
2443 2. Iterate
2444
2445 :raises VHDLModelException: If no entity is found for a component, which doesn't allow blackboxes.
2446
2447 .. seealso::
2448
2449 :meth:`LinkInstantiations`
2450 Link instantiations to components and entities.
2451 :meth:`AnalyzeDependencies`
2452 Analyze dependencies in a design (calls this method).
2453 """
...
2468
2469 def _IterateComponents(self) -> Generator[tuple[Library, Component], None, None]:
2470 """
2471 Iterate all components of packages and architectures, including the components declared in blocks and generate
2472 statements nested in architectures.
2473
2474 :returns: A generator to iterate tuples of the library of the design unit and a component.
2475 """
2476 def iterateStatements(concurrent: ConcurrentStatementsMixin) -> Generator[Component, None, None]:
2477 """
2478 Nested function for recursion.
2479
2480 :param concurrent: The language construct containing concurrent statements.
2481 :returns: A generator to iterate the components declared in the nested statements.
2482 """
...
2504
2505 def iterateDeclaredItems(declarationRegion: ConcurrentDeclarationRegionMixin) -> Generator[Component, None, None]:
2506 """
2507 Nested function iterating the components declared in a declaration region.
2508
2509 :param declarationRegion: The declaration region.
2510 :returns: A generator to iterate the declared components.
2511 """
...
2515
...
2524
2525 def LinkInstantiations(self) -> None:
...
2594
2595 def IndexPackages(self) -> None:
2596 """
2597 Index all declared items in all packages in all libraries.
2598
2599 .. rubric:: Algorithm
2600
2601 1. Iterate all libraries:
2602
2603 1. Iterate all packages |br|
2604 |rarr| :meth:`pyVHDLModel.Library.IndexPackages`
2605
2606 * Index all declared items in that package. |br|
2607 |rarr| :meth:`pyVHDLModel.DesignUnit.Package.IndexDeclaredItems`
2608
2609 .. seealso::
2610
2611 :meth:`IndexPackageBodies`
2612 Index all declared items in all package bodies in all libraries.
2613 :meth:`IndexEntities`
2614 Index all declared items in all entities in all libraries.
2615 :meth:`IndexArchitectures`
2616 Index all declared items in all architectures in all libraries.
2617
2618 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
2619 :class:`~pyTooling.Warning.WarningCollector` collects the
2620 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
2621 """
...
2624
2625 def IndexPackageBodies(self) -> None:
2626 """
2627 Index all declared items in all packages in all libraries.
2628
2629 .. rubric:: Algorithm
2630
2631 1. Iterate all libraries:
2632
2633 1. Iterate all packages |br|
2634 |rarr| :meth:`pyVHDLModel.Library.IndexPackageBodies`
2635
2636 * Index all declared items in that package body. |br|
2637 |rarr| :meth:`pyVHDLModel.DesignUnit.PackageBody.IndexDeclaredItems`
2638
2639 .. seealso::
2640
2641 :meth:`IndexPackages`
2642 Index all declared items in all packages in all libraries.
2643 :meth:`IndexEntities`
2644 Index all declared items in all entities in all libraries.
2645 :meth:`IndexArchitectures`
2646 Index all declared items in all architectures in all libraries.
2647
2648 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
2649 :class:`~pyTooling.Warning.WarningCollector` collects the
2650 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
2651 """
...
2654
2655 def IndexEntities(self) -> None:
2656 """
2657 Index all declared items in all packages in all libraries.
2658
2659 .. rubric:: Algorithm
2660
2661 1. Iterate all libraries:
2662
2663 1. Iterate all packages |br|
2664 |rarr| :meth:`pyVHDLModel.Library.IndexEntities`
2665
2666 * Index all declared items in that entity. |br|
2667 |rarr| :meth:`pyVHDLModel.DesignUnit.Entity.IndexDeclaredItems`
2668
2669 .. seealso::
2670
2671 :meth:`IndexPackages`
2672 Index all declared items in all packages in all libraries.
2673 :meth:`IndexPackageBodies`
2674 Index all declared items in all package bodies in all libraries.
2675 :meth:`IndexArchitectures`
2676 Index all declared items in all architectures in all libraries.
2677
2678 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
2679 :class:`~pyTooling.Warning.WarningCollector` collects the
2680 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
2681 """
...
2684
2685 def IndexArchitectures(self) -> None:
2686 """
2687 Index all declared items in all packages in all libraries.
2688
2689 .. rubric:: Algorithm
2690
2691 1. Iterate all libraries:
2692
2693 1. Iterate all packages |br|
2694 |rarr| :meth:`pyVHDLModel.Library.IndexArchitectures`
2695
2696 * Index all declared items in that architecture. |br|
2697 |rarr| :meth:`pyVHDLModel.DesignUnit.Architecture.IndexDeclaredItems`
2698
2699 .. seealso::
2700
2701 :meth:`IndexPackages`
2702 Index all declared items in all packages in all libraries.
2703 :meth:`IndexPackageBodies`
2704 Index all declared items in all package bodies in all libraries.
2705 :meth:`IndexEntities`
2706 Index all declared items in all entities in all libraries.
2707
2708 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
2709 :class:`~pyTooling.Warning.WarningCollector` collects the
2710 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
2711 """
...
2714
2715 def CreateHierarchyGraph(self) -> None:
2716 """
2717 Create the hierarchy graph from dependency graph.
2718
2719 .. rubric:: Algorithm
2720
2721 1. Iterate all vertices corresponding to entities and architectures in the dependency graph:
2722
2723 * Copy these vertices to the hierarchy graph and create a bidirectional linking. |br|
2724 In addition, set the referenced design unit's :attr:`~pyVHDLModel.Document._hierarchyVertex` field to reference the copied vertex.
2725
2726 * Add a key-value-pair called ``hierarchyVertex`` to the dependency graph's vertex.
2727 * Add a key-value-pair called ``dependencyVertex`` to the hierarchy graph's vertex.
2728
2729 2. Iterate all architectures ...
2730
2731 .. todo:: Design::CreateHierarchyGraph describe algorithm
2732
2733 1. Iterate all outbound edges
2734
2735 .. todo:: Design::CreateHierarchyGraph describe algorithm
2736 """
...
2762
2763 def ComputeCompileOrder(self) -> None:
2764 def predicate(edge: Edge) -> bool:
...
2771
...
2791
2792 def IterateDocumentsInCompileOrder(self) -> Generator[Document, None, None]:
2793 """
2794 Iterate all document in compile-order.
2795
2796 .. rubric:: Algorithm
2797
2798 * Check if compile-order graph was populated with vertices and its vertices are linked by edges.
2799
2800 1. Iterate compile-order graph in topological order. |br|
2801 :meth:`pyTooling.Graph.Graph.IterateTopologically`
2802
2803 * yield the compiler-order vertex' referenced document.
2804
2805 :returns: A generator to iterate all documents in compile-order in the design.
2806 :raises VHDLModelException: If compile-order was not computed.
2807
2808 .. seealso::
2809
2810 .. todo:: missing text
2811
2812 :meth:`pyVHDLModel.Design.ComputeCompileOrder`
2813
2814 """
...
2820
2821 def GetUnusedDesignUnits(self) -> list[DesignUnit]:
...
2823
2824 def __repr__(self) -> str:
2825 """
2826 Formats a representation of the design.
2827
2828 **Format:** ``Document: 'my_design'``
2829
2830 :returns: String representation of the design.
2831 """
...
2833
2834 __str__ = __repr__
2835
2837@export
2838class Library(ModelEntity, NamedEntityMixin, DocumentedEntityMixin, AllowBlackboxMixin):
2839 """
2840 A ``Library`` represents a VHDL library. It contains all *primary* and *secondary* design units.
2841
2842 .. seealso::
2843
2844 * :class:`Predefined library <pyVHDLModel.Predefined.PredefinedLibrary>`
2845 """
2846
2847 _contexts: dict[str, Context] #: Dictionary of all contexts defined in a library.
2848 _configurations: dict[str, Configuration] #: Dictionary of all configurations defined in a library.
2849 _entities: dict[str, Entity] #: Dictionary of all entities defined in a library.
2850 _architectures: dict[str, dict[str, Architecture]] #: Dictionary of all architectures defined in a library.
2851 _packages: dict[str, Package] #: Dictionary of all packages defined in a library.
2852 _packageBodies: dict[str, PackageBody] #: Dictionary of all package bodies defined in a library.
2853
2854 _dependencyVertex: Vertex #: Reference to the vertex in the dependency graph representing the library. |br| This reference is set by :meth:`~pyVHDLModel.Design.CreateDependencyGraph`.
2855
2856 def __init__(
2857 self,
2858 identifier: str,
2859 documentation: Nullable[str] = None,
2860 allowBlackbox: Nullable[bool] = None,
2861 parent: Nullable[ModelEntity] = None
2862 ) -> None:
2863 """
2864 Initialize a VHDL library.
2865
2866 :param identifier: Name of the VHDL library.
2867 :param documentation: Documentation of this VHDL library, if the caller has one to supply.
2868 :param allowBlackbox: Specify if blackboxes are allowed in this design.
2869 :param parent: The parent model entity (design) of this VHDL library.
2870 """
...
2884
2885 @property
2886 def Documentation(self) -> Nullable[str]:
2887 """
2888 Property to access the library's documentation (:attr:`_documentation`).
2889
2890 .. hint::
2891
2892 Unlike every other documented entity, a library's documentation cannot come from VHDL source:
2893 the language has no library declaration to attach a comment to. It is therefore settable, so a
2894 caller can supply one from elsewhere - a compile-order file, a project description, ...
2895
2896 :returns: Associated documentation of this VHDL library.
2897 """
...
2899
2900 @Documentation.setter
2901 def Documentation(self, documentation: Nullable[str]) -> None:
...
2903
2904 @readonly
2905 def Contexts(self) -> dict[str, Context]:
2906 """
2907 Read-only property to access the dictionary of all context declarations in this library (:attr:`_contexts`).
2908
2909 :returns: Dictionary of all contexts, indexed by normalized identifier.
2910 """
...
2912
2913 @readonly
2914 def Configurations(self) -> dict[str, Configuration]:
2915 """
2916 Read-only property to access the dictionary of all configuration declarations in this library (:attr:`_configurations`).
2917
2918 :returns: Dictionary of all configurations, indexed by normalized identifier.
2919 """
...
2921
2922 @readonly
2923 def Entities(self) -> dict[str, Entity]:
2924 """
2925 Read-only property to access the dictionary of all entity declarations in this library (:attr:`_entities`).
2926
2927 :returns: Dictionary of all entities, indexed by normalized identifier.
2928 """
...
2930
2931 @readonly
2932 def Architectures(self) -> dict[str, dict[str, Architecture]]:
2933 """
2934 Read-only property to access the dictionary of all architecture declarations in this library (:attr:`_architectures`).
2935
2936 :returns: Dictionary of all architectures, indexed by normalized entity identifier, then by normalized
2937 architecture identifier.
2938 """
...
2940
2941 @readonly
2942 def Packages(self) -> dict[str, Package]:
2943 """
2944 Read-only property to access the dictionary of all package declarations in this library (:attr:`_packages`).
2945
2946 :returns: Dictionary of all packages, indexed by normalized identifier.
2947 """
...
2949
2950 @readonly
2951 def PackageBodies(self) -> dict[str, PackageBody]:
2952 """
2953 Read-only property to access the dictionary of all package body declarations in this library (:attr:`_packageBodies`).
2954
2955 :returns: Dictionary of all package bodies, indexed by normalized identifier.
2956 """
...
2958
2959 @readonly
2960 def DependencyVertex(self) -> Vertex:
2961 """
2962 Read-only property to access the corresponding dependency vertex (:attr:`_dependencyVertex`).
2963
2964 The dependency vertex references this library by its value field.
2965
2966 :returns: The corresponding dependency vertex.
2967 """
...
2969
2970 def IterateDesignUnits(self, filter: DesignUnitKind = DesignUnitKind.All) -> Generator[DesignUnit, None, None]:
2971 """
2972 Iterate all design units in the library.
2973
2974 A union of :class:`DesignUnitKind` values can be given to filter the returned result for suitable design units.
2975
2976 .. rubric:: Algorithm
2977
2978 1. Iterate all contexts in that library.
2979 2. Iterate all packages in that library.
2980 3. Iterate all package bodies in that library.
2981 4. Iterate all entities in that library.
2982 5. Iterate all architectures in that library.
2983 6. Iterate all configurations in that library.
2984
2985 :param filter: An enumeration with possibly multiple flags to filter the returned design units.
2986 :returns: A generator to iterate all matched design units in the library.
2987
2988 .. seealso::
2989
2990 :meth:`pyVHDLModel.Design.IterateDesignUnits`
2991 Iterate all design units in the design.
2992 :meth:`pyVHDLModel.Document.IterateDesignUnits`
2993 Iterate all design units in the document.
2994 """
...
3019
3027 def LinkArchitectures(self) -> None:
3028 """
3029 Link all architectures to corresponding entities.
3030
3031 .. rubric:: Algorithm
3032
3033 1. Iterate all architecture groups (grouped per entity symbol's name).
3034
3035 * Check if entity symbol's name exists as an entity in this library.
3036
3037 1. For each architecture in the same architecture group:
3038
3039 * Add architecture to entities architecture dictionary :attr:`pyVHDLModel.DesignUnit.Entity._architectures`.
3040 * Assign found entity to architecture's entity symbol :attr:`pyVHDLModel.DesignUnit.Architecture._entity`
3041 * Set parent namespace of architecture's namespace to the entitie's namespace.
3042 * Add an edge in the dependency graph from the architecture's corresponding dependency vertex to the entity's corresponding dependency vertex.
3043
3044 :raises VHDLModelException: If entity name doesn't exist.
3045 :raises VHDLModelException: If architecture name already exists for entity.
3046
3047 .. seealso::
3048
3049 :meth:`LinkPackageBodies`
3050 Link all package bodies to corresponding packages.
3051 :meth:`LinkPackageInstances`
3052 Link all package instances to corresponding generic packages.
3053 """
...
3074
3075 def LinkPackageBodies(self) -> None:
3076 """
3077 Link all package bodies to corresponding packages.
3078
3079 .. rubric:: Algorithm
3080
3081 1. Iterate all package bodies.
3082
3083 * Check if package body symbol's name exists as a package in this library.
3084 * Add package body to package :attr:`pyVHDLModel.DesignUnit.Package._packageBody`.
3085 * Assign found package to package body's package symbol :attr:`pyVHDLModel.DesignUnit.PackageBody._package`
3086 * Set parent namespace of package body's namespace to the package's namespace.
3087 * Add an edge in the dependency graph from the package body's corresponding dependency vertex to the package's corresponding dependency vertex.
3088
3089 :raises VHDLModelException: If package name doesn't exist.
3090
3091 .. seealso::
3092
3093 :meth:`LinkArchitectures`
3094 Link all architectures to corresponding entities.
3095 :meth:`LinkPackageInstances`
3096 Link all package instances to corresponding generic packages.
3097 """
...
3110
3111 def LinkPackageInstances(self) -> None:
3112 """
3113 Link all package instances to corresponding generic packages.
3114
3115 .. rubric:: Algorithm
3116
3117 1. Iterate all package instances.
3118
3119 .. todo::
3120
3121 * Check if package body symbol's name exists as a package in this library.
3122 * Add package body to package :attr:`pyVHDLModel.DesignUnit.Package._packageBody`.
3123 * Assign found package to package body's package symbol :attr:`pyVHDLModel.DesignUnit.PackageBody._package`
3124 * Set parent namespace of package body's namespace to the package's namespace.
3125 * Add an edge in the dependency graph from the package body's corresponding dependency vertex to the package's corresponding dependency vertex.
3126
3127 :raises VHDLModelException: If generic package name doesn't exist.
3128
3129 .. seealso::
3130
3131 :meth:`LinkArchitectures`
3132 Link all architectures to corresponding entities.
3133 :meth:`LinkPackageBodies`
3134 Link all package bodies to corresponding packages.
3135 """
...
3173
3174 def IndexPackages(self) -> None:
3175 """
3176 Index declared items in all packages.
3177
3178 .. rubric:: Algorithm
3179
3180 1. Iterate all packages:
3181
3182 * Index all declared items. |br|
3183 |rarr| :meth:`pyVHDLModel.DesignUnit.Package.IndexDeclaredItems`
3184
3185 .. seealso::
3186
3187 :meth:`IndexPackageBodies`
3188 Index all declared items in a package body.
3189 :meth:`IndexEntities`
3190 Index all declared items in an entity.
3191 :meth:`IndexArchitectures`
3192 Index all declared items in an architecture.
3193
3194 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
3195 :class:`~pyTooling.Warning.WarningCollector` collects the
3196 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
3197 """
...
3201
3202 def IndexPackageBodies(self) -> None:
3203 """
3204 Index declared items in all package bodies.
3205
3206 .. rubric:: Algorithm
3207
3208 1. Iterate all package bodies:
3209
3210 * Index all declared items. |br|
3211 |rarr| :meth:`pyVHDLModel.DesignUnit.PackageBody.IndexDeclaredItems`
3212
3213 .. seealso::
3214
3215 :meth:`IndexPackages`
3216 Index all declared items in a package.
3217 :meth:`IndexEntities`
3218 Index all declared items in an entity.
3219 :meth:`IndexArchitectures`
3220 Index all declared items in an architecture.
3221
3222 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
3223 :class:`~pyTooling.Warning.WarningCollector` collects the
3224 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
3225 """
...
3228
3229 def IndexEntities(self) -> None:
3230 """
3231 Index declared items in all entities.
3232
3233 .. rubric:: Algorithm
3234
3235 1. Iterate all entities:
3236
3237 * Index all declared items. |br|
3238 |rarr| :meth:`pyVHDLModel.DesignUnit.Entity.IndexDeclaredItems`
3239
3240 .. seealso::
3241
3242 :meth:`IndexPackages`
3243 Index all declared items in a package.
3244 :meth:`IndexPackageBodies`
3245 Index all declared items in a package body.
3246 :meth:`IndexArchitectures`
3247 Index all declared items in an architecture.
3248
3249 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
3250 :class:`~pyTooling.Warning.WarningCollector` collects the
3251 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
3252 """
...
3255
3256 def IndexArchitectures(self) -> None:
3257 """
3258 Index declared items in all architectures.
3259
3260 .. rubric:: Algorithm
3261
3262 1. Iterate all architectures:
3263
3264 * Index all declared items. |br|
3265 |rarr| :meth:`pyVHDLModel.DesignUnit.Architecture.IndexDeclaredItems`
3266
3267 .. seealso::
3268
3269 :meth:`IndexPackages`
3270 Index all declared items in a package.
3271 :meth:`IndexPackageBodies`
3272 Index all declared items in a package body.
3273 :meth:`IndexEntities`
3274 Index all declared items in an entity.
3275
3276 :raises UnhandledCriticalWarningError: If an identifier is declared twice in a declarative region and no
3277 :class:`~pyTooling.Warning.WarningCollector` collects the
3278 :exc:`~pyVHDLModel.Exception.DuplicateDeclarationWarning`.
3279 """
...
3284
3285 def __repr__(self) -> str:
3286 """
3287 Formats a representation of the library.
3288
3289 **Format:** ``Library: 'my_library'``
3290
3291 :returns: String representation of the library.
3292 """
...
3294
3295 __str__ = __repr__
3296
3298@export
3299class Document(ModelEntity, DocumentedEntityMixin):
3300 """A ``Document`` represents a sourcefile. It contains *primary* and *secondary* design units."""
3301
3302 _path: Path #: Path to the document.
3303 _vhdlVersion: VHDLVersion #: VHDL version used for analyzing this source file.
3304 _library: Library #: VHDL library used for analyzing the source file's content into.
3305 _designUnits: list[DesignUnit] #: List of all design units defined in a document.
3306 _contexts: dict[str, Context] #: Dictionary of all contexts defined in a document.
3307 _configurations: dict[str, Configuration] #: Dictionary of all configurations defined in a document.
3308 _entities: dict[str, Entity] #: Dictionary of all entities defined in a document.
3309 _architectures: dict[str, dict[str, Architecture]] #: Dictionary of all architectures defined in a document.
3310 _packages: dict[str, Package] #: Dictionary of all packages defined in a document.
3311 _packageBodies: dict[str, PackageBody] #: Dictionary of all package bodies defined in a document.
3312 _verificationUnits: dict[str, VerificationUnit] #: Dictionary of all PSL verification units defined in a document.
3313 _verificationProperties: dict[str, VerificationProperty] #: Dictionary of all PSL verification properties defined in a document.
3314 _verificationModes: dict[str, VerificationMode] #: Dictionary of all PSL verification modes defined in a document.
3315
3316 _dependencyVertex: Vertex #: Reference to the vertex in the dependency graph representing the document. |br| This reference is set by :meth:`~pyVHDLModel.Design.CreateCompileOrderGraph`.
3317 _compileOrderVertex: Vertex #: Reference to the vertex in the compile-order graph representing the document. |br| This reference is set by :meth:`~pyVHDLModel.Design.CreateCompileOrderGraph`.
3318
3319 def __init__(
3320 self,
3321 path: Path,
3322 documentation: Nullable[str] = None,
3323 vhdlVersion: VHDLVersion = VHDLVersion.VHDL2008,
3324 library: Nullable[Library] = None,
3325 parent: Nullable[ModelEntity] = None
3326 ) -> None:
3327 """
3328 Initializes a VHDL document.
3329
3330 :param path: Path to the document.
3331 :param documentation: The documentation comment associated with this declaration.
3332 :param vhdlVersion: VHDL version used for analyzing this source file.
3333 :param library: VHDL library used for analyzing the source file's content into.
3334 :param parent: The parent model entity of this entity.
3335 :raises ValueError: If parameter 'path' is None.
3336 :raises TypeError: If parameter 'path' is not of type :class:`~pathlib.Path`.
3337 """
...
3364
3365 def Visit(self, visitor: Visitor) -> None:
3366 """
3367 Walk this document and its design units with a visitor.
3368
3369 :param visitor: The visitor receiving the events.
3370 """
...
3376
3377 def _AddEntity(self, item: Entity) -> None:
3378 """
3379 Add an entity to the document's lists of design units.
3380
3381 :param item: Entity object to be added to the document.
3382 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.Entity`.
3383 :raises VHDLModelException: If entity name already exists in document.
3384 """
...
3398
3401 def _AddArchitecture(self, item: Architecture) -> None:
3402 """
3403 Add an architecture to the document's lists of design units.
3404
3405 :param item: Architecture object to be added to the document.
3406 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.Architecture`.
3407 :raises VHDLModelException: If architecture name already exists for the referenced entity name in document.
3408 """
...
3430
3433 def _AddPackage(self, item: Package) -> None:
3434 """
3435 Add a package to the document's lists of design units.
3436
3437 :param item: Package object to be added to the document.
3438 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.Package`.
3439 :raises VHDLModelException: If package name already exists in document.
3440 """
...
3454
3457 def _AddPackageBody(self, item: PackageBody) -> None:
3458 """
3459 Add a package body to the document's lists of design units.
3460
3461 :param item: Package body object to be added to the document.
3462 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.PackageBody`.
3463 :raises VHDLModelException: If package body name already exists in document.
3464 """
...
3478
3481 def _AddContext(self, item: Context) -> None:
3482 """
3483 Add a context to the document's lists of design units.
3484
3485 :param item: Context object to be added to the document.
3486 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.Context`.
3487 :raises VHDLModelException: If context name already exists in document.
3488 """
...
3502
3505 def _AddConfiguration(self, item: Configuration) -> None:
3506 """
3507 Add a configuration to the document's lists of design units.
3508
3509 :param item: Configuration object to be added to the document.
3510 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.Configuration`.
3511 :raises VHDLModelException: If configuration name already exists in document.
3512 """
...
3526
3529 def _AddVerificationUnit(self, item: VerificationUnit) -> None:
...
3542
3545 def _AddVerificationProperty(self, item: VerificationProperty) -> None:
...
3558
3561 def _AddVerificationMode(self, item: VerificationMode) -> None:
...
3574
3577 def _AddDesignUnit(self, item: DesignUnit) -> None:
3578 """
3579 Add a design unit to the document's lists of design units.
3580
3581 :param item: Configuration object to be added to the document.
3582 :raises TypeError: If parameter 'item' is not of type :class:`~pyVHDLModel.DesignUnit.DesignUnit`.
3583 :raises ValueError: If parameter 'item' is an unknown :class:`~pyVHDLModel.DesignUnit.DesignUnit`.
3584 :raises VHDLModelException: If configuration name already exists in document.
3585 """
...
3613
3614 def AddDesignUnit(self, designUnit: DesignUnit) -> None:
3615 """
3616 Add a design unit at the end of the document.
3617
3618 The design unit's document is set to this document. If the document is registered in a design
3619 (:meth:`Design.AddDocument`), the design unit enters the document's library too.
3620
3621 :param designUnit: The design unit to add.
3622 :raises ValueError: If parameter 'designUnit' is ``None``.
3623 :raises TypeError: If parameter 'designUnit' is not of type
3624 :class:`~pyVHDLModel.DesignUnit.DesignUnit`.
3625 :raises AlreadyInDesignError: If parameter 'designUnit' is already a design unit of a document.
3626 :raises DuplicateDesignUnitError: If the document contains a design unit of the same kind and identifier.
3627 :raises EntityExistsInLibraryError: If the library already contains an entity of the same identifier.
3628 :raises ArchitectureExistsInLibraryError: If the library already contains an architecture of the same identifier
3629 for the same entity.
3630 :raises PackageExistsInLibraryError: If the library already contains a package of the same identifier.
3631 :raises PackageBodyExistsError: If the library already contains a package body of the same identifier.
3632 :raises ConfigurationExistsInLibraryError: If the library already contains a configuration of the same identifier.
3633 :raises ContextExistsInLibraryError: If the library already contains a context of the same identifier.
3634
3635 .. seealso::
3636
3637 :meth:`InsertDesignUnit`
3638 |rarr| Insert a design unit at a position of the document.
3639 :meth:`RemoveDesignUnit`
3640 |rarr| Remove a design unit from the document.
3641 """
...
3643
3644 def InsertDesignUnit(self, index: int, designUnit: DesignUnit) -> None:
3645 """
3646 Insert a design unit at a position of the document.
3647
3648 The design units of a document are in source order. The design unit's document is set to this document. If the
3649 document is registered in a design (:meth:`Design.AddDocument`), the design unit enters the document's library too:
3650 the library becomes its parent. PSL verification units, properties and modes enter no library.
3651
3652 :param index: Position, from ``0`` (first) to the number of design units (append).
3653 A negative index counts from the end, as for :meth:`list.insert`.
3654 :param designUnit: The design unit to insert.
3655 :raises ValueError: If parameter 'index' is ``None``.
3656 :raises TypeError: If parameter 'index' is not of type :class:`int`.
3657 :raises ValueError: If parameter 'index' is out of range.
3658 :raises ValueError: If parameter 'designUnit' is ``None``.
3659 :raises TypeError: If parameter 'designUnit' is not of type
3660 :class:`~pyVHDLModel.DesignUnit.DesignUnit`.
3661 :raises AlreadyInDesignError: If parameter 'designUnit' is already a design unit of a document.
3662 :raises DuplicateDesignUnitError: If the document contains a design unit of the same kind and identifier.
3663 :raises EntityExistsInLibraryError: If the library already contains an entity of the same identifier.
3664 :raises ArchitectureExistsInLibraryError: If the library already contains an architecture of the same identifier
3665 for the same entity.
3666 :raises PackageExistsInLibraryError: If the library already contains a package of the same identifier.
3667 :raises PackageBodyExistsError: If the library already contains a package body of the same identifier.
3668 :raises ConfigurationExistsInLibraryError: If the library already contains a configuration of the same identifier.
3669 :raises ContextExistsInLibraryError: If the library already contains a context of the same identifier.
3670
3671 .. seealso::
3672
3673 :meth:`AddDesignUnit`
3674 |rarr| Add a design unit at the end of the document.
3675 :meth:`RemoveDesignUnit`
3676 |rarr| Remove a design unit from the document.
3677 """
...
3782
3783 def RemoveDesignUnit(self, designUnit: DesignUnit) -> None:
3784 """
3785 Remove a design unit from the document.
3786
3787 The design unit is detached: its document is cleared. If the document is registered in a design
3788 (:meth:`Design.AddDocument`), the design unit leaves the document's library too, and its parent is cleared. The
3789 design unit itself is unchanged and can be added to another document, or inserted at another position.
3790
3791 :param designUnit: The design unit to remove.
3792 :raises ValueError: If parameter 'designUnit' is ``None``.
3793 :raises TypeError: If parameter 'designUnit' is not of type :class:`~pyVHDLModel.DesignUnit.DesignUnit`.
3794 :raises NotAChildError: If parameter 'designUnit' is not a design unit of this document.
3795
3796 .. seealso::
3797
3798 :meth:`AddDesignUnit`
3799 |rarr| Add a design unit at the end of the document.
3800 :meth:`InsertDesignUnit`
3801 |rarr| Insert a design unit at a position of the document.
3802 """
...
3869
3870 @readonly
3871 def Path(self) -> Path:
3872 """
3873 Read-only property to access the document's path (:attr:`_path`).
3874
3875 :returns: The path of this document.
3876 """
...
3878
3879 @readonly
3880 def VHDLVersion(self) -> VHDLVersion:
3881 """
3882 Read-only property to access the document's VHDL version (:attr:`_vhdlVersion`).
3883
3884 :returns: VHDL version used to analyze this VHDL file.
3885 """
...
3887
3889 @readonly
3890 def Library(self) -> Library:
3891 """
3892 Read-only property to access the document's VHDL library (:attr:`_library`).
3893
3894 :returns: VHDL library used to analyze the VHDL file's design units into.
3895 """
...
3897
3904 @readonly
3905 def DesignUnits(self) -> list[DesignUnit]:
3906 """
3907 Read-only property to access a list of all design units declarations found in this document (:attr:`_designUnits`).
3908
3909 :returns: List of all design units.
3910 """
...
3912
3913 @readonly
3914 def Contexts(self) -> dict[str, Context]:
3915 """
3916 Read-only property to access the dictionary of all context declarations in this document (:attr:`_contexts`).
3917
3918 :returns: Dictionary of all contexts, indexed by normalized identifier.
3919 """
...
3921
3922 @readonly
3923 def Configurations(self) -> dict[str, Configuration]:
3924 """
3925 Read-only property to access the dictionary of all configuration declarations in this document (:attr:`_configurations`).
3926
3927 :returns: Dictionary of all configurations, indexed by normalized identifier.
3928 """
...
3930
3931 @readonly
3932 def Entities(self) -> dict[str, Entity]:
3933 """
3934 Read-only property to access the dictionary of all entity declarations in this document (:attr:`_entities`).
3935
3936 :returns: Dictionary of all entities, indexed by normalized identifier.
3937 """
...
3939
3940 @readonly
3941 def Architectures(self) -> dict[str, dict[str, Architecture]]:
3942 """
3943 Read-only property to access the dictionary of all architecture declarations in this document (:attr:`_architectures`).
3944
3945 :returns: Dictionary of all architectures, indexed by normalized entity identifier, then by normalized
3946 architecture identifier.
3947 """
...
3949
3950 @readonly
3951 def Packages(self) -> dict[str, Package]:
3952 """
3953 Read-only property to access the dictionary of all package declarations in this document (:attr:`_packages`).
3954
3955 :returns: Dictionary of all packages, indexed by normalized identifier.
3956 """
...
3958
3959 @readonly
3960 def PackageBodies(self) -> dict[str, PackageBody]:
3961 """
3962 Read-only property to access the dictionary of all package body declarations in this document (:attr:`_packageBodies`).
3963
3964 :returns: Dictionary of all package bodies, indexed by normalized identifier.
3965 """
...
3967
3968 @readonly
3969 def VerificationUnits(self) -> dict[str, VerificationUnit]:
3970 """
3971 Read-only property to access the dictionary of all verification unit declarations in this document (:attr:`_verificationUnits`).
3972
3973 :returns: Dictionary of all verification units, indexed by normalized identifier.
3974 """
...
3976
3977 @readonly
3978 def VerificationProperties(self) -> dict[str, VerificationProperty]:
3979 """
3980 Read-only property to access the dictionary of all verification property declarations in this document (:attr:`_verificationProperties`).
3981
3982 :returns: Dictionary of all verification properties, indexed by normalized identifier.
3983 """
...
3985
3986 @readonly
3987 def VerificationModes(self) -> dict[str, VerificationMode]:
3988 """
3989 Read-only property to access the dictionary of all verification mode declarations in this document (:attr:`_verificationModes`).
3990
3991 :returns: Dictionary of all verification mode declarations, indexed by normalized identifier.
3992 """
...
3994
3995 @readonly
3996 def CompileOrderVertex(self) -> Vertex:
3997 """
3998 Read-only property to access the corresponding compile-order vertex (:attr:`_compileOrderVertex`).
3999
4000 The compile-order vertex references this document by its value field.
4001
4002 :returns: The corresponding compile-order vertex.
4003 """
...
4005
4006 def IterateDesignUnits(self, filter: DesignUnitKind = DesignUnitKind.All) -> Generator[DesignUnit, None, None]:
4007 """
4008 Iterate all design units in the document.
4009
4010 A union of :class:`DesignUnitKind` values can be given to filter the returned result for suitable design units.
4011
4012 .. rubric:: Algorithm
4013
4014 * If contexts are selected in the filter:
4015
4016 1. Iterate all contexts in that library.
4017
4018 * If packages are selected in the filter:
4019
4020 1. Iterate all packages in that library.
4021
4022 * If package bodies are selected in the filter:
4023
4024 1. Iterate all package bodies in that library.
4025
4026 * If entites are selected in the filter:
4027
4028 1. Iterate all entites in that library.
4029
4030 * If architectures are selected in the filter:
4031
4032 1. Iterate all architectures in that library.
4033
4034 * If configurations are selected in the filter:
4035
4036 1. Iterate all configurations in that library.
4037
4038 :param filter: An enumeration with possibly multiple flags to filter the returned design units.
4039 :returns: A generator to iterate all matched design units in the document.
4040
4041 .. seealso::
4042
4043 :meth:`pyVHDLModel.Design.IterateDesignUnits`
4044 Iterate all design units in the design.
4045 :meth:`pyVHDLModel.Library.IterateDesignUnits`
4046 Iterate all design units in the library.
4047 """
...
4072
4080 def __repr__(self) -> str:
4081 """
4082 Formats a representation of the document.
4083
4084 **Format:** ``Document: 'path/to/file.vhdl'``
4085
4086 :returns: String representation of the document.
4087 """
...
4089
4090 __str__ = __repr__