Skip to content

Commit

Permalink
Fixes #1026.
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Jun 24, 2024
1 parent 76e9732 commit 802d259
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
20 changes: 20 additions & 0 deletions vunit/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@ def set_post_check(self, value):
for config in configs.values():
config.post_check = value

@staticmethod
def _check_architectures(design_unit):
"""
Check that an entity which has been classified as a VUnit test bench
has exactly one architecture. Raise RuntimeError otherwise.
"""
if design_unit.is_entity:
if not design_unit.architecture_names:
raise RuntimeError(f"Test bench '{design_unit.name!s}' has no architecture.")

if len(design_unit.architecture_names) > 1:
archs = ", ".join(
f"{name!s}:{Path(fname).name!s}" for name, fname in sorted(design_unit.architecture_names.items())
)
raise RuntimeError(
"Test bench not allowed to have multiple architectures. " f"Entity {design_unit.name!s} has {archs}"
)

def add_config( # pylint: disable=too-many-arguments
self,
name,
Expand All @@ -276,6 +294,8 @@ def add_config( # pylint: disable=too-many-arguments
if name in (DEFAULT_NAME, ""):
raise ValueError(f"Illegal configuration name {name!r}. Must be non-empty string")

self._check_architectures(self.design_unit)

for configs in self.get_configuration_dicts():
if name in configs:
raise RuntimeError(f"Configuration name {name!s} already defined")
Expand Down
18 changes: 0 additions & 18 deletions vunit/test/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,6 @@ def get_default_config(self):
raise RuntimeError(f"Test bench {self.library_name!s}.{self.name!s} has individually configured tests")
return self._configs[DEFAULT_NAME]

@staticmethod
def _check_architectures(design_unit):
"""
Check that an entity which has been classified as a VUnit test bench
has exactly one architecture. Raise RuntimeError otherwise.
"""
if design_unit.is_entity:
if not design_unit.architecture_names:
raise RuntimeError(f"Test bench '{design_unit.name!s}' has no architecture.")

if len(design_unit.architecture_names) > 1:
archs = ", ".join(
f"{name!s}:{Path(fname).name!s}" for name, fname in sorted(design_unit.architecture_names.items())
)
raise RuntimeError(
"Test bench not allowed to have multiple architectures. " f"Entity {design_unit.name!s} has {archs}"
)

def create_tests(self, simulator_if, elaborate_only, test_list=None):
"""
Create all test cases from this test bench
Expand Down

0 comments on commit 802d259

Please sign in to comment.