Coverage for pyVHDLModel / DesignUnit.py: 70%
334 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 22:37 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 22:37 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2026 Patrick Lehmann - Boetzingen, Germany #
15# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany #
16# #
17# Licensed under the Apache License, Version 2.0 (the "License"); #
18# you may not use this file except in compliance with the License. #
19# You may obtain a copy of the License at #
20# #
21# http://www.apache.org/licenses/LICENSE-2.0 #
22# #
23# Unless required by applicable law or agreed to in writing, software #
24# distributed under the License is distributed on an "AS IS" BASIS, #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
26# See the License for the specific language governing permissions and #
27# limitations under the License. #
28# #
29# SPDX-License-Identifier: Apache-2.0 #
30# ==================================================================================================================== #
31#
32"""
33This module contains parts of an abstract document language model for VHDL.
35Design units are contexts, entities, architectures, packages and their bodies as well as configurations.
36"""
37from typing import List, Dict, Union, Iterable, Optional as Nullable
39from pyTooling.Decorators import export, readonly
40from pyTooling.MetaClasses import ExtendedType
41from pyTooling.Graph import Vertex
43from pyVHDLModel.Common import AllowBlackboxMixin
44from pyVHDLModel.Exception import VHDLModelException
45from pyVHDLModel.Base import ModelEntity, NamedEntityMixin, DocumentedEntityMixin
46from pyVHDLModel.Namespace import Namespace
47from pyVHDLModel.Regions import ConcurrentDeclarationRegionMixin
48from pyVHDLModel.Symbol import Symbol, PackageSymbol, EntitySymbol, LibraryReferenceSymbol
49from pyVHDLModel.Interface import GenericInterfaceItemMixin, PortInterfaceItemMixin
50from pyVHDLModel.Object import DeferredConstant
51from pyVHDLModel.Concurrent import ConcurrentStatement, ConcurrentStatementsMixin
54@export
55class Reference(ModelEntity):
56 """
57 A base-class for all references.
59 .. seealso::
61 * :class:`~pyVHDLModel.DesignUnit.LibraryClause`
62 * :class:`~pyVHDLModel.DesignUnit.UseClause`
63 * :class:`~pyVHDLModel.DesignUnit.ContextReference`
64 """
66 _symbols: List[Symbol]
68 def __init__(self, symbols: Iterable[Symbol], parent: ModelEntity = None) -> None:
69 """
70 Initializes a reference by taking a list of symbols and a parent reference.
72 :param symbols: A list of symbols this reference references to.
73 :param parent: Reference to the logical parent in the model hierarchy.
74 """
75 super().__init__(parent)
77 self._symbols = [s for s in symbols]
79 @readonly
80 def Symbols(self) -> List[Symbol]:
81 """
82 Read-only property to access the symbols this reference references to (:attr:`_symbols`).
84 :returns: A list of symbols.
85 """
86 return self._symbols
89@export
90class LibraryClause(Reference):
91 """
92 Represents a library clause.
94 .. admonition:: Example
96 .. code-block:: VHDL
98 library std, ieee;
99 """
101 @readonly
102 def Symbols(self) -> List[LibraryReferenceSymbol]:
103 """
104 Read-only property to access the symbols this library clause references to (:attr:`_symbols`).
106 :returns: A list of library reference symbols.
107 """
108 return self._symbols
111@export
112class UseClause(Reference):
113 """
114 Represents a use clause.
116 .. admonition:: Example
118 .. code-block:: VHDL
120 use std.text_io.all, ieee.numeric_std.all;
121 """
124@export
125class ContextReference(Reference):
126 """
127 Represents a context reference.
129 .. hint:: It's called *context reference* not *context clause* by the LRM.
131 .. admonition:: Example
133 .. code-block:: VHDL
135 context ieee.ieee_std_context;
136 """
139ContextUnion = Union[
140 LibraryClause,
141 UseClause,
142 ContextReference
143]
146@export
147class DesignUnitWithContextMixin(metaclass=ExtendedType, mixin=True):
148 """
149 A mixin-class for all design units with a context.
150 """
153@export
154class DesignUnit(ModelEntity, NamedEntityMixin, DocumentedEntityMixin):
155 """
156 A base-class for all design units.
158 .. seealso::
160 * :class:`Primary design units <pyVHDLModel.DesignUnit.PrimaryUnit>`
162 * :class:`~pyVHDLModel.DesignUnit.Context`
163 * :class:`~pyVHDLModel.DesignUnit.Entity`
164 * :class:`~pyVHDLModel.DesignUnit.Package`
165 * :class:`~pyVHDLModel.DesignUnit.Configuration`
167 * :class:`Secondary design units <pyVHDLModel.DesignUnit.SecondaryUnit>`
169 * :class:`~pyVHDLModel.DesignUnit.Architecture`
170 * :class:`~pyVHDLModel.DesignUnit.PackageBody`
171 """
173 _document: 'Document' #: The VHDL library, the design unit was analyzed into.
175 # Either written as statements before (e.g. entity, architecture, package, ...), or as statements inside (context)
176 _contextItems: List['ContextUnion'] #: List of all context items (library, use and context clauses).
177 _libraryReferences: List['LibraryClause'] #: List of library clauses.
178 _packageReferences: List['UseClause'] #: List of use clauses.
179 _contextReferences: List['ContextReference'] #: List of context clauses.
181 _referencedLibraries: Dict[str, 'Library'] #: Referenced libraries based on explicit library clauses or implicit inheritance
182 _referencedPackages: Dict[str, Dict[str, 'Package']] #: Referenced packages based on explicit use clauses or implicit inheritance
183 _referencedContexts: Dict[str, 'Context'] #: Referenced contexts based on explicit context references or implicit inheritance
185 _dependencyVertex: Vertex[None, None, str, 'DesignUnit', None, None, None, None, None, None, None, None, None, None, None, None, None] #: Reference to the vertex in the dependency graph representing the design unit. |br| This reference is set by :meth:`~pyVHDLModel.Design.CreateDependencyGraph`.
186 _hierarchyVertex: Vertex[None, None, str, 'DesignUnit', None, None, None, None, None, None, None, None, None, None, None, None, None] #: The vertex in the hierarchy graph
188 _namespace: 'Namespace'
190 def __init__(self, identifier: str, contextItems: Nullable[Iterable[ContextUnion]] = None, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
191 """
192 Initializes a design unit.
194 :param identifier: Identifier (name) of the design unit.
195 :param contextItems: A sequence of library, use or context clauses.
196 :param documentation: Associated documentation of the design unit.
197 :param parent: Reference to the logical parent in the model hierarchy.
198 """
199 super().__init__(parent)
200 NamedEntityMixin.__init__(self, identifier)
201 DocumentedEntityMixin.__init__(self, documentation)
203 self._document = None
205 self._contextItems = []
206 self._libraryReferences = []
207 self._packageReferences = []
208 self._contextReferences = []
210 if contextItems is not None:
211 for item in contextItems:
212 self._contextItems.append(item)
213 if isinstance(item, UseClause):
214 self._packageReferences.append(item)
215 elif isinstance(item, LibraryClause):
216 self._libraryReferences.append(item)
217 elif isinstance(item, ContextReference): 217 ↛ 211line 217 didn't jump to line 211 because the condition on line 217 was always true
218 self._contextReferences.append(item)
220 self._referencedLibraries = {}
221 self._referencedPackages = {}
222 self._referencedContexts = {}
224 self._dependencyVertex = None
225 self._hierarchyVertex = None
227 self._namespace = Namespace(self._normalizedIdentifier)
229 @readonly
230 def Document(self) -> 'Document':
231 return self._document
233 @Document.setter
234 def Document(self, document: 'Document') -> None:
235 self._document = document
237 @property
238 def Library(self) -> 'Library':
239 return self._parent
241 @Library.setter
242 def Library(self, library: 'Library') -> None:
243 self._parent = library
245 @property
246 def ContextItems(self) -> List['ContextUnion']:
247 """
248 Read-only property to access the sequence of all context items comprising library, use and context clauses
249 (:attr:`_contextItems`).
251 :returns: Sequence of context items.
252 """
253 return self._contextItems
255 @property
256 def ContextReferences(self) -> List['ContextReference']:
257 """
258 Read-only property to access the sequence of context clauses (:attr:`_contextReferences`).
260 :returns: Sequence of context clauses.
261 """
262 return self._contextReferences
264 @property
265 def LibraryReferences(self) -> List['LibraryClause']:
266 """
267 Read-only property to access the sequence of library clauses (:attr:`_libraryReferences`).
269 :returns: Sequence of library clauses.
270 """
271 return self._libraryReferences
273 @property
274 def PackageReferences(self) -> List['UseClause']:
275 """
276 Read-only property to access the sequence of use clauses (:attr:`_packageReferences`).
278 :returns: Sequence of use clauses.
279 """
280 return self._packageReferences
282 @property
283 def ReferencedLibraries(self) -> Dict[str, 'Library']:
284 return self._referencedLibraries
286 @property
287 def ReferencedPackages(self) -> Dict[str, 'Package']:
288 return self._referencedPackages
290 @property
291 def ReferencedContexts(self) -> Dict[str, 'Context']:
292 return self._referencedContexts
294 @property
295 def DependencyVertex(self) -> Vertex:
296 """
297 Read-only property to access the corresponding dependency vertex (:attr:`_dependencyVertex`).
299 The dependency vertex references this design unit by its value field.
301 :returns: The corresponding dependency vertex.
302 """
303 return self._dependencyVertex
305 @property
306 def HierarchyVertex(self) -> Vertex:
307 """
308 Read-only property to access the corresponding hierarchy vertex (:attr:`_hierarchyVertex`).
310 The hierarchy vertex references this design unit by its value field.
312 :returns: The corresponding hierarchy vertex.
313 """
314 return self._hierarchyVertex
317@export
318class PrimaryUnit(DesignUnit):
319 """
320 A base-class for all primary design units.
322 .. seealso::
324 * :class:`~pyVHDLModel.DesignUnit.Context`
325 * :class:`~pyVHDLModel.DesignUnit.Entity`
326 * :class:`~pyVHDLModel.DesignUnit.Package`
327 * :class:`~pyVHDLModel.DesignUnit.Configuration`
328 """
331@export
332class SecondaryUnit(DesignUnit):
333 """
334 A base-class for all secondary design units.
336 .. seealso::
338 * :class:`~pyVHDLModel.DesignUnit.Architecture`
339 * :class:`~pyVHDLModel.DesignUnit.PackageBody`
340 """
343@export
344class Context(PrimaryUnit):
345 """
346 Represents a context declaration.
348 A context contains a generic list of all its items (library clauses, use clauses and context references) in
349 :data:`_references`.
351 Furthermore, when a context gets initialized, the item kinds get separated into individual lists:
353 * :class:`~pyVHDLModel.DesignUnit.LibraryClause` |rarr| :data:`_libraryReferences`
354 * :class:`~pyVHDLModel.DesignUnit.UseClause` |rarr| :data:`_packageReferences`
355 * :class:`~pyVHDLModel.DesignUnit.ContextReference` |rarr| :data:`_contextReferences`
357 When :meth:`pyVHDLModel.Design.LinkContexts` got called, these lists were processed and the fields:
359 * :data:`_referencedLibraries` (:pycode:`Dict[libName, Library]`)
360 * :data:`_referencedPackages` (:pycode:`Dict[libName, [pkgName, Package]]`)
361 * :data:`_referencedContexts` (:pycode:`Dict[libName, [ctxName, Context]]`)
363 are populated.
365 .. admonition:: Example
367 .. code-block:: VHDL
369 context ctx is
370 -- ...
371 end context;
372 """
374 _references: List[ContextUnion]
376 def __init__(self, identifier: str, references: Nullable[Iterable[ContextUnion]] = None, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
377 super().__init__(identifier, None, documentation, parent)
379 self._references = []
380 self._libraryReferences = []
381 self._packageReferences = []
382 self._contextReferences = []
384 if references is not None:
385 for reference in references:
386 self._references.append(reference)
387 reference._parent = self
389 if isinstance(reference, LibraryClause):
390 self._libraryReferences.append(reference)
391 elif isinstance(reference, UseClause): 391 ↛ 393line 391 didn't jump to line 393 because the condition on line 391 was always true
392 self._packageReferences.append(reference)
393 elif isinstance(reference, ContextReference):
394 self._contextReferences.append(reference)
395 else:
396 raise VHDLModelException() # FIXME: needs exception message
398 @property
399 def LibraryReferences(self) -> List[LibraryClause]:
400 return self._libraryReferences
402 @property
403 def PackageReferences(self) -> List[UseClause]:
404 return self._packageReferences
406 @property
407 def ContextReferences(self) -> List[ContextReference]:
408 return self._contextReferences
410 def __str__(self) -> str:
411 lib = self._parent._identifier + "?" if self._parent is not None else ""
413 return f"Context: {lib}.{self._identifier}"
416@export
417class Package(PrimaryUnit, DesignUnitWithContextMixin, ConcurrentDeclarationRegionMixin, AllowBlackboxMixin):
418 """
419 Represents a package declaration.
421 .. admonition:: Example
423 .. code-block:: VHDL
425 package pkg is
426 -- ...
427 end package;
428 """
430 _packageBody: Nullable["PackageBody"]
432 _genericItems: List[GenericInterfaceItemMixin]
434 _deferredConstants: Dict[str, DeferredConstant]
435 _components: Dict[str, 'Component']
437 def __init__(
438 self,
439 identifier: str,
440 contextItems: Nullable[Iterable[ContextUnion]] = None,
441 genericItems: Nullable[Iterable[GenericInterfaceItemMixin]] = None,
442 declaredItems: Nullable[Iterable] = None,
443 documentation: Nullable[str] = None,
444 allowBlackbox: Nullable[bool] = None,
445 parent: ModelEntity = None
446 ) -> None:
447 """
448 Initialize a package.
450 :param identifier: Name of the VHDL package.
451 :param contextItems:
452 :param genericItems:
453 :param declaredItems:
454 :param documentation:
455 :param allowBlackbox: Specify if blackboxes are allowed in this design.
456 :param parent: The parent model entity (library) of this VHDL package.
457 """
458 super().__init__(identifier, contextItems, documentation, parent)
459 DesignUnitWithContextMixin.__init__(self)
460 ConcurrentDeclarationRegionMixin.__init__(self, declaredItems)
461 AllowBlackboxMixin.__init__(self, allowBlackbox)
463 self._packageBody = None
465 # TODO: extract to mixin
466 self._genericItems = [] # TODO: convert to dict
467 if genericItems is not None: 467 ↛ 468line 467 didn't jump to line 468 because the condition on line 467 was never true
468 for generic in genericItems:
469 self._genericItems.append(generic)
470 generic._parent = self
472 self._deferredConstants = {}
473 self._components = {}
475 @property
476 def PackageBody(self) -> Nullable["PackageBody"]:
477 return self._packageBody
479 @property
480 def GenericItems(self) -> List[GenericInterfaceItemMixin]:
481 return self._genericItems
483 @property
484 def DeclaredItems(self) -> List:
485 return self._declaredItems
487 @property
488 def DeferredConstants(self):
489 return self._deferredConstants
491 @property
492 def Components(self):
493 return self._components
495 def _IndexOtherDeclaredItem(self, item):
496 if isinstance(item, DeferredConstant):
497 for normalizedIdentifier in item.NormalizedIdentifiers:
498 self._deferredConstants[normalizedIdentifier] = item
499 elif isinstance(item, Component):
500 self._components[item.NormalizedIdentifier] = item
501 else:
502 super()._IndexOtherDeclaredItem(item)
504 def __str__(self) -> str:
505 lib = self._parent._identifier if self._parent is not None else "%"
507 return f"Package: '{lib}.{self._identifier}'"
509 def __repr__(self) -> str:
510 lib = self._parent._identifier if self._parent is not None else "%"
512 return f"{lib}.{self._identifier}"
515@export
516class PackageBody(SecondaryUnit, DesignUnitWithContextMixin, ConcurrentDeclarationRegionMixin):
517 """
518 Represents a package body declaration.
520 .. admonition:: Example
522 .. code-block:: VHDL
524 package body pkg is
525 -- ...
526 end package body;
527 """
529 _package: PackageSymbol
531 def __init__(
532 self,
533 packageSymbol: PackageSymbol,
534 contextItems: Nullable[Iterable[ContextUnion]] = None,
535 declaredItems: Nullable[Iterable] = None,
536 documentation: Nullable[str] = None,
537 parent: ModelEntity = None
538 ) -> None:
539 super().__init__(packageSymbol.Name.Identifier, contextItems, documentation, parent)
540 DesignUnitWithContextMixin.__init__(self)
541 ConcurrentDeclarationRegionMixin.__init__(self, declaredItems)
543 self._package = packageSymbol
544 packageSymbol._parent = self
546 @property
547 def Package(self) -> PackageSymbol:
548 return self._package
550 @property
551 def DeclaredItems(self) -> List:
552 return self._declaredItems
554 def LinkDeclaredItemsToPackage(self) -> None:
555 pass
557 def __str__(self) -> str:
558 lib = self._parent._identifier + "?" if self._parent is not None else ""
560 return f"Package Body: {lib}.{self._identifier}(body)"
562 def __repr__(self) -> str:
563 lib = self._parent._identifier + "?" if self._parent is not None else ""
565 return f"{lib}.{self._identifier}(body)"
568@export
569class Entity(PrimaryUnit, DesignUnitWithContextMixin, ConcurrentDeclarationRegionMixin, ConcurrentStatementsMixin, AllowBlackboxMixin):
570 """
571 Represents an entity declaration.
573 .. admonition:: Example
575 .. code-block:: VHDL
577 entity ent is
578 -- ...
579 end entity;
580 """
582 _genericItems: List[GenericInterfaceItemMixin]
583 _portItems: List[PortInterfaceItemMixin]
585 _architectures: Dict[str, 'Architecture']
587 def __init__(
588 self,
589 identifier: str,
590 contextItems: Nullable[Iterable[ContextUnion]] = None,
591 genericItems: Nullable[Iterable[GenericInterfaceItemMixin]] = None,
592 portItems: Nullable[Iterable[PortInterfaceItemMixin]] = None,
593 declaredItems: Nullable[Iterable] = None,
594 statements: Nullable[Iterable[ConcurrentStatement]] = None,
595 documentation: Nullable[str] = None,
596 allowBlackbox: Nullable[bool] = None,
597 parent: ModelEntity = None
598 ) -> None:
599 super().__init__(identifier, contextItems, documentation, parent)
600 DesignUnitWithContextMixin.__init__(self)
601 ConcurrentDeclarationRegionMixin.__init__(self, declaredItems)
602 ConcurrentStatementsMixin.__init__(self, statements)
603 AllowBlackboxMixin.__init__(self, allowBlackbox)
605 # TODO: extract to mixin
606 self._genericItems = []
607 if genericItems is not None: 607 ↛ 608line 607 didn't jump to line 608 because the condition on line 607 was never true
608 for item in genericItems:
609 self._genericItems.append(item)
610 item._parent = self
612 # TODO: extract to mixin
613 self._portItems = []
614 if portItems is not None: 614 ↛ 615line 614 didn't jump to line 615 because the condition on line 614 was never true
615 for item in portItems:
616 self._portItems.append(item)
617 item._parent = self
619 self._architectures = {}
621 # TODO: extract to mixin for generics
622 @property
623 def GenericItems(self) -> List[GenericInterfaceItemMixin]:
624 return self._genericItems
626 # TODO: extract to mixin for ports
627 @property
628 def PortItems(self) -> List[PortInterfaceItemMixin]:
629 return self._portItems
631 @property
632 def Architectures(self) -> Dict[str, 'Architecture']:
633 return self._architectures
635 def __str__(self) -> str:
636 lib = self._parent._identifier if self._parent is not None else "%"
637 archs = ', '.join(self._architectures.keys()) if self._architectures else "%"
639 return f"Entity: '{lib}.{self._identifier}({archs})'"
641 def __repr__(self) -> str:
642 lib = self._parent._identifier if self._parent is not None else "%"
643 archs = ', '.join(self._architectures.keys()) if self._architectures else "%"
645 return f"{lib}.{self._identifier}({archs})"
648@export
649class Architecture(SecondaryUnit, DesignUnitWithContextMixin, ConcurrentDeclarationRegionMixin, ConcurrentStatementsMixin, AllowBlackboxMixin):
650 """
651 Represents an architecture declaration.
653 .. admonition:: Example
655 .. code-block:: VHDL
657 architecture rtl of ent is
658 -- ...
659 begin
660 -- ...
661 end architecture;
662 """
664 _entity: EntitySymbol
666 def __init__(
667 self,
668 identifier: str,
669 entity: EntitySymbol,
670 contextItems: Nullable[Iterable[Context]] = None,
671 declaredItems: Nullable[Iterable] = None,
672 statements: Iterable['ConcurrentStatement'] = None,
673 documentation: Nullable[str] = None,
674 allowBlackbox: Nullable[bool] = None,
675 parent: ModelEntity = None
676 ) -> None:
677 super().__init__(identifier, contextItems, documentation, parent)
678 DesignUnitWithContextMixin.__init__(self)
679 ConcurrentDeclarationRegionMixin.__init__(self, declaredItems)
680 ConcurrentStatementsMixin.__init__(self, statements)
681 AllowBlackboxMixin.__init__(self, allowBlackbox)
683 self._entity = entity
684 entity._parent = self
686 @property
687 def Entity(self) -> EntitySymbol:
688 return self._entity
690 def __str__(self) -> str:
691 lib = self._parent._identifier if self._parent is not None else "%"
692 ent = self._entity._name._identifier if self._entity is not None else "%"
694 return f"Architecture: {lib}.{ent}({self._identifier})"
696 def __repr__(self) -> str:
697 lib = self._parent._identifier if self._parent is not None else "%"
698 ent = self._entity._name._identifier if self._entity is not None else "%"
700 return f"{lib}.{ent}({self._identifier})"
703@export
704class Component(ModelEntity, NamedEntityMixin, DocumentedEntityMixin, AllowBlackboxMixin):
705 """
706 Represents a configuration declaration.
708 .. admonition:: Example
710 .. code-block:: VHDL
712 component ent is
713 -- ...
714 end component;
715 """
717 _isBlackBox: Nullable[bool] #: Component is a blackbox.
719 _genericItems: List[GenericInterfaceItemMixin]
720 _portItems: List[PortInterfaceItemMixin]
722 _entity: Nullable[Entity]
724 def __init__(
725 self,
726 identifier: str,
727 genericItems: Nullable[Iterable[GenericInterfaceItemMixin]] = None,
728 portItems: Nullable[Iterable[PortInterfaceItemMixin]] = None,
729 documentation: Nullable[str] = None,
730 allowBlackbox: Nullable[bool] = None,
731 parent: ModelEntity = None
732 ) -> None:
733 super().__init__(parent)
734 NamedEntityMixin.__init__(self, identifier)
735 DocumentedEntityMixin.__init__(self, documentation)
736 AllowBlackboxMixin.__init__(self, allowBlackbox)
738 self._isBlackBox = None
739 self._entity = None
741 # TODO: extract to mixin
742 self._genericItems = []
743 if genericItems is not None:
744 for item in genericItems:
745 self._genericItems.append(item)
746 item._parent = self
748 # TODO: extract to mixin
749 self._portItems = []
750 if portItems is not None:
751 for item in portItems:
752 self._portItems.append(item)
753 item._parent = self
755 @property
756 def IsBlackbox(self) -> Nullable[bool]:
757 """
758 Read-only property returning true, if this component is a blackbox (:attr:`_isBlackbox`).
760 If components were not linked to matching entities, this property returns None.
762 :returns: If this component is a blackbox.
763 """
764 return self._isBlackBox
766 @property
767 def GenericItems(self) -> List[GenericInterfaceItemMixin]:
768 return self._genericItems
770 @property
771 def PortItems(self) -> List[PortInterfaceItemMixin]:
772 return self._portItems
774 @property
775 def Entity(self) -> Nullable[Entity]:
776 return self._entity
778 @Entity.setter
779 def Entity(self, value: Entity) -> None:
780 self._entity = value
781 self._isBlackBox = False
783 def __str__(self) -> str:
784 return f"Component: {self._identifier}"
786 def __repr__(self) -> str:
787 if isinstance(self._parent, Package):
788 return f"{self._parent!r}:{self._identifier}"
789 elif isinstance(self._parent, Architecture):
790 return f"{self._parent!r}:{self._identifier}"
793@export
794class Configuration(PrimaryUnit, DesignUnitWithContextMixin):
795 """
796 Represents a configuration declaration.
798 .. admonition:: Example
800 .. code-block:: VHDL
802 configuration cfg of ent is
803 for rtl
804 -- ...
805 end for;
806 end configuration;
807 """
809 def __init__(
810 self,
811 identifier: str,
812 contextItems: Nullable[Iterable[Context]] = None,
813 documentation: Nullable[str] = None,
814 parent: ModelEntity = None
815 ) -> None:
816 super().__init__(identifier, contextItems, documentation, parent)
817 DesignUnitWithContextMixin.__init__(self)
819 def __str__(self) -> str:
820 lib = self._parent._identifier if self._parent is not None else "%"
822 return f"Configuration: {lib}.{self._identifier}"
824 def __repr__(self) -> str:
825 lib = self._parent._identifier if self._parent is not None else "%"
827 return f"{lib}.{self._identifier}"