Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/news.d/1223.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GHDL: a configuration no longer inherits the generics of other configurations through a shared ``ghdl.sim_flags`` list.
28 changes: 28 additions & 0 deletions tests/unit/test_ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,34 @@ def test_elaborate_e_project(self, determine_version):
],
)

@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
def test_sim_flags_are_not_shared_between_configurations(self, determine_version):
design_unit = Entity("tb_entity", file_name=str(Path("tempdir") / "file.vhd"))
design_unit.generic_names = ["runner_cfg", "a", "b"]

# A configuration added after setting ghdl.sim_flags is a shallow copy and shares the list of flags
default_config = Configuration("default", design_unit)
default_config.set_sim_option("ghdl.sim_flags", ["--ieee-asserts=disable"])
sets_b = default_config.copy()
sets_b.set_generic("b", 1)
sets_a = default_config.copy()
sets_a.set_generic("a", 1)

simif = GHDLInterface(prefix="prefix", output_path="")
simif._vhdl_standard = VHDL.standard("2008") # pylint: disable=protected-access
simif._project = Project() # pylint: disable=protected-access
simif._project.add_library("lib", "lib_path") # pylint: disable=protected-access

def get_generic_flags(config):
cmd = simif._get_command( # pylint: disable=protected-access
config, str(Path("output_path") / "ghdl"), False, False, "tb_entity", None
)
return [flag for flag in cmd if flag.startswith("-g")]

self.assertEqual(get_generic_flags(sets_b), ["-gb=1"])
self.assertEqual(get_generic_flags(sets_a), ["-ga=1"])
self.assertEqual(default_config.sim_options["ghdl.sim_flags"], ["--ieee-asserts=disable"])

@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
def test_prefix_is_a_read_only_property(self, determine_version):
simif = GHDLInterface(prefix="prefix", output_path="")
Expand Down
2 changes: 1 addition & 1 deletion vunit/sim_if/ghdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def _get_command(
else:
cmd += [config.entity_name, config.architecture_name]

sim = config.sim_options.get("ghdl.sim_flags", [])
sim = list(config.sim_options.get("ghdl.sim_flags", []))
sim += hooks.get_flags(self, "run_flags")
for name, value in config.generics.items():
sim += [f"-g{name!s}={value!s}"]
Expand Down
Loading