From b81220ec09efd08de59f749d65cf300499cd4065 Mon Sep 17 00:00:00 2001 From: Thomas Cenova Date: Mon, 29 Jul 2024 09:20:19 -0400 Subject: [PATCH 1/3] Fixing bug where namespace elements were added with non-normalized identifier. This caused issues where elements would not be found if identifier and normalizedIdentifier did not match. --- pyVHDLModel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyVHDLModel/__init__.py b/pyVHDLModel/__init__.py index 323a7e7b..91e9e9ca 100644 --- a/pyVHDLModel/__init__.py +++ b/pyVHDLModel/__init__.py @@ -1016,7 +1016,7 @@ def _ImportObjects(package: Package) -> None: for referencedLibrary in package._referencedPackages.values(): for referencedPackage in referencedLibrary.values(): for declaredItem in referencedPackage._declaredItems: - package._namespace._elements[declaredItem._identifier] = declaredItem + package._namespace._elements[declaredItem._normalizedIdentifier] = declaredItem for libraryName in ("std", "ieee"): for package in self.GetLibrary(libraryName).IterateDesignUnits(filter=DesignUnitKind.Package): # type: Package From 38891136de7488926b24b5bf416972c9f5ce3e06 Mon Sep 17 00:00:00 2001 From: Thomas Cenova Date: Mon, 29 Jul 2024 09:31:14 -0400 Subject: [PATCH 2/3] Fixing issue where if a declaredItem has multiple identifiers (like constants), then this code would fail. Adding a check to see if the _normalizedIdentifiers attr exists, and if so add a entry for each identifier --- pyVHDLModel/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyVHDLModel/__init__.py b/pyVHDLModel/__init__.py index 91e9e9ca..dccf6321 100644 --- a/pyVHDLModel/__init__.py +++ b/pyVHDLModel/__init__.py @@ -1016,7 +1016,11 @@ def _ImportObjects(package: Package) -> None: for referencedLibrary in package._referencedPackages.values(): for referencedPackage in referencedLibrary.values(): for declaredItem in referencedPackage._declaredItems: - package._namespace._elements[declaredItem._normalizedIdentifier] = declaredItem + if hasattr(declaredItem, "_normalizedIdentifiers"): + for normalizedIdentifier in declaredItem._normalizedIdentifiers: + package._namespace._elements[normalizedIdentifier] = declaredItem + else: + package._namespace._elements[declaredItem._normalizedIdentifier] = declaredItem for libraryName in ("std", "ieee"): for package in self.GetLibrary(libraryName).IterateDesignUnits(filter=DesignUnitKind.Package): # type: Package From 5cbcc96e756eefb15fd8d8408736e658482743f0 Mon Sep 17 00:00:00 2001 From: Thomas Cenova Date: Mon, 29 Jul 2024 11:51:57 -0400 Subject: [PATCH 3/3] Swap to using isinstance of mixins per review. Co-authored-by: Patrick Lehmann --- pyVHDLModel/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyVHDLModel/__init__.py b/pyVHDLModel/__init__.py index dccf6321..60371e18 100644 --- a/pyVHDLModel/__init__.py +++ b/pyVHDLModel/__init__.py @@ -1016,11 +1016,13 @@ def _ImportObjects(package: Package) -> None: for referencedLibrary in package._referencedPackages.values(): for referencedPackage in referencedLibrary.values(): for declaredItem in referencedPackage._declaredItems: - if hasattr(declaredItem, "_normalizedIdentifiers"): + if isinstance(declaredItem, MultipleNamedEntityMixin): for normalizedIdentifier in declaredItem._normalizedIdentifiers: package._namespace._elements[normalizedIdentifier] = declaredItem - else: + elif isinstance(declaredItem, NamedEntityMixin): package._namespace._elements[declaredItem._normalizedIdentifier] = declaredItem + else: + raise VHDLModelException(f"Unexpected declared item.") for libraryName in ("std", "ieee"): for package in self.GetLibrary(libraryName).IterateDesignUnits(filter=DesignUnitKind.Package): # type: Package