aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyGHDL/dom/DesignUnit.py26
-rw-r--r--pyGHDL/dom/NonStandard.py3
-rw-r--r--testsuite/pyunit/Current.vhdl17
3 files changed, 35 insertions, 11 deletions
diff --git a/pyGHDL/dom/DesignUnit.py b/pyGHDL/dom/DesignUnit.py
index c905a439d..7f4d8e964 100644
--- a/pyGHDL/dom/DesignUnit.py
+++ b/pyGHDL/dom/DesignUnit.py
@@ -47,6 +47,7 @@ from pydecor import export
from pyVHDLModel.SyntaxModel import (
LibraryClause as VHDLModel_LibraryClause,
UseClause as VHDLModel_UseClause,
+ ContextReference as VHDLModel_ContextReference,
Entity as VHDLModel_Entity,
Architecture as VHDLModel_Architecture,
Package as VHDLModel_Package,
@@ -82,16 +83,16 @@ __all__ = []
@export
class LibraryClause(VHDLModel_LibraryClause, DOMMixin):
- def __init__(self, node: Iir, names: Iterable[Name]):
+ def __init__(self, libraryNode: Iir, names: Iterable[Name]):
super().__init__(names)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, libraryNode)
@export
class UseClause(VHDLModel_UseClause, DOMMixin):
- def __init__(self, node: Iir, names: Iterable[Name]):
+ def __init__(self, useNode: Iir, names: Iterable[Name]):
super().__init__(names)
- DOMMixin.__init__(self, node)
+ DOMMixin.__init__(self, useNode)
@classmethod
def parse(cls, useNode: Iir):
@@ -105,6 +106,23 @@ class UseClause(VHDLModel_UseClause, DOMMixin):
@export
+class ContextReference(VHDLModel_ContextReference, DOMMixin):
+ def __init__(self, contextNode: Iir, names: Iterable[Name]):
+ super().__init__(names)
+ DOMMixin.__init__(self, contextNode)
+
+ @classmethod
+ def parse(cls, contextNode: Iir):
+ from pyGHDL.dom._Translate import GetNameFromNode
+
+ contexts = [GetNameFromNode(nodes.Get_Selected_Name(contextNode))]
+ for context in utils.chain_iter(nodes.Get_Context_Reference_Chain(contextNode)):
+ contexts.append(GetNameFromNode(nodes.Get_Selected_Name(context)))
+
+ return cls(contextNode, contexts)
+
+
+@export
class Entity(VHDLModel_Entity, DOMMixin):
def __init__(
self,
diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py
index b59efeacb..1cd98b4fa 100644
--- a/pyGHDL/dom/NonStandard.py
+++ b/pyGHDL/dom/NonStandard.py
@@ -74,6 +74,7 @@ from pyGHDL.dom.DesignUnit import (
PackageInstantiation,
LibraryClause,
UseClause,
+ ContextReference,
)
from pyGHDL.dom.PSL import VerificationUnit, VerificationProperty, VerificationMode
@@ -189,6 +190,8 @@ class Document(VHDLModel_Document):
contextNames = []
elif itemKind is nodes.Iir_Kind.Use_Clause:
contextItems.append(UseClause.parse(item))
+ elif itemKind is nodes.Iir_Kind.Context_Reference:
+ contextItems.append(ContextReference.parse(item))
else:
pos = Position.parse(item)
raise DOMException(
diff --git a/testsuite/pyunit/Current.vhdl b/testsuite/pyunit/Current.vhdl
index a835eae40..240c11d5f 100644
--- a/testsuite/pyunit/Current.vhdl
+++ b/testsuite/pyunit/Current.vhdl
@@ -206,6 +206,16 @@ begin
ende: std.env.stop;
end architecture behav;
+context ctx is
+ library osvvm;
+ library axi4_lite, axi4_stream;
+ use osvvm.alert.all;
+ use osvvm.alert.alertid, osvvm.alert.priority;
+end context;
+
+
+context work.ctx;
+
package package_1 is
generic (
BITS : positive
@@ -251,10 +261,3 @@ end package body;
vunit vu (component_1) {
}
-
-context ctx is
- library osvvm;
- library axi4_lite, axi4_stream;
- use osvvm.alert.all;
- use osvvm.alert.alertid, osvvm.alert.priority;
-end context;