Skip to content

Commit d22f7dd

Browse files
committed
Enabled VHDL-2019 for GHDL >= 6.0.0.
Note that VUnit log location support based on call_path is deactivated as this is yet to be supported by GHDL.
1 parent ae8ba6e commit d22f7dd

4 files changed

Lines changed: 37 additions & 21 deletions

File tree

docs/news.d/1177.feature.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enabled VHDL-2019 for GHDL >= 6.0.0.
2+
3+
Note that VUnit log location support based on call_path is deactivated as this is yet to be supported by GHDL.

tests/unit/test_ghdl_interface.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def test_assertion_on_unknown_backend(self, check_output):
138138
self.assertRaises(AssertionError, GHDLInterface.determine_backend, "prefix")
139139

140140
@mock.patch("vunit.sim_if.check_output", autospec=True, return_value="") # pylint: disable=no-self-use
141-
def test_compile_project_2008(self, check_output):
141+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
142+
def test_compile_project_2008(self, determine_version, check_output):
142143
simif = GHDLInterface(prefix="prefix", output_path="")
143144
write_file("file.vhd", "")
144145

@@ -160,7 +161,8 @@ def test_compile_project_2008(self, check_output):
160161
)
161162

162163
@mock.patch("vunit.sim_if.check_output", autospec=True, return_value="") # pylint: disable=no-self-use
163-
def test_compile_project_2002(self, check_output):
164+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
165+
def test_compile_project_2002(self, determine_version, check_output):
164166
simif = GHDLInterface(prefix="prefix", output_path="")
165167
write_file("file.vhd", "")
166168

@@ -182,7 +184,8 @@ def test_compile_project_2002(self, check_output):
182184
)
183185

184186
@mock.patch("vunit.sim_if.check_output", autospec=True, return_value="") # pylint: disable=no-self-use
185-
def test_compile_project_93(self, check_output):
187+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
188+
def test_compile_project_93(self, determine_version, check_output):
186189
simif = GHDLInterface(prefix="prefix", output_path="")
187190
write_file("file.vhd", "")
188191

@@ -204,7 +207,8 @@ def test_compile_project_93(self, check_output):
204207
)
205208

206209
@mock.patch("vunit.sim_if.check_output", autospec=True, return_value="") # pylint: disable=no-self-use
207-
def test_compile_project_extra_flags(self, check_output):
210+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
211+
def test_compile_project_extra_flags(self, determine_version, check_output):
208212
simif = GHDLInterface(prefix="prefix", output_path="")
209213
write_file("file.vhd", "")
210214

@@ -228,7 +232,8 @@ def test_compile_project_extra_flags(self, check_output):
228232
env=simif.get_env(),
229233
)
230234

231-
def test_elaborate_e_project(self):
235+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
236+
def test_elaborate_e_project(self, determine_version):
232237
design_unit = Entity("tb_entity", file_name=str(Path("tempdir") / "file.vhd"))
233238
design_unit.original_file_name = str(Path("tempdir") / "other_path" / "original_file.vhd")
234239
design_unit.generic_names = ["runner_cfg", "tb_path"]
@@ -258,7 +263,8 @@ def test_elaborate_e_project(self):
258263
],
259264
)
260265

261-
def test_compile_project_verilog_error(self):
266+
@mock.patch.object(GHDLInterface, "determine_version", return_value=5.0)
267+
def test_compile_project_verilog_error(self, determine_version):
262268
simif = GHDLInterface(prefix="prefix", output_path="")
263269
write_file("file.v", "")
264270

vunit/builtins.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,10 @@ def _add_osvvm(self):
448448

449449
library.add_source_files(file_name, preprocessors=[])
450450

451-
def _add_vhdl_logging(self):
451+
def _add_vhdl_logging(self, use_external_log):
452452
"""
453453
Add logging functionality
454454
"""
455-
456455
use_call_paths = self._simulator_class.supports_vhdl_call_paths() and (
457456
self._vhdl_standard in VHDL.STD_2019.and_later
458457
)
@@ -467,6 +466,10 @@ def _add_vhdl_logging(self):
467466
if base_file_name.startswith("location_pkg-body"):
468467
continue
469468

469+
if (base_file_name == "common_log_pkg-body.vhd") and use_external_log:
470+
self._add_files(Path(use_external_log))
471+
continue
472+
470473
standards = set()
471474
for standard in VHDL.STANDARDS:
472475
standard_name = str(standard)
@@ -504,7 +507,7 @@ def add_vhdl_builtins(self, external=None, use_external_log=None):
504507
})
505508
"""
506509
self._add_data_types(external=external)
507-
self._add_vhdl_logging()
510+
self._add_vhdl_logging(use_external_log)
508511
self._add_files(VHDL_PATH / "*.vhd")
509512
for path in (
510513
"core",
@@ -516,14 +519,6 @@ def add_vhdl_builtins(self, external=None, use_external_log=None):
516519
):
517520
self._add_files(VHDL_PATH / path / "src" / "*.vhd")
518521

519-
logging_files = glob(str(VHDL_PATH / "logging" / "src" / "*.vhd"))
520-
for logging_file in logging_files:
521-
if logging_file.endswith("common_log_pkg-body.vhd") and use_external_log:
522-
self._add_files(Path(use_external_log))
523-
continue
524-
525-
self._add_files(Path(logging_file))
526-
527522

528523
def osvvm_is_installed():
529524
"""

vunit/sim_if/ghdl.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def __init__( # pylint: disable=too-many-arguments
119119
self._vhdl_standard = None
120120
self._coverage_test_dirs = set() # For gcov
121121
self._coverage_files = set() # For --coverage
122+
self._version = self.determine_version(self.find_prefix())
122123

123124
def has_valid_exit_code(self): # pylint: disable=arguments-differ
124125
"""
@@ -184,6 +185,13 @@ def determine_version(cls, prefix):
184185
).group(1)
185186
)
186187

188+
@classmethod
189+
def supports_vhdl_call_paths(cls):
190+
"""
191+
Returns True when this simulator supports VHDL-2019 call paths
192+
"""
193+
return False
194+
187195
@classmethod
188196
def supports_vhdl_package_generics(cls):
189197
"""
@@ -246,17 +254,21 @@ def compile_source_file_command(self, source_file):
246254
LOGGER.error("Unknown file type: %s", source_file.file_type)
247255
raise CompileError
248256

249-
@staticmethod
250-
def _std_str(vhdl_standard):
257+
def _std_str(self, vhdl_standard):
251258
"""
252259
Convert standard to format of GHDL command line flag
253260
"""
254-
if vhdl_standard == VHDL.STD_2002:
255-
return "02"
261+
if vhdl_standard == VHDL.STD_2019:
262+
if self._version >= 6.0:
263+
return "19"
264+
raise ValueError("VHDL-2019 requires GHDL >=6.0.0.")
256265

257266
if vhdl_standard == VHDL.STD_2008:
258267
return "08"
259268

269+
if vhdl_standard == VHDL.STD_2002:
270+
return "02"
271+
260272
if vhdl_standard == VHDL.STD_1993:
261273
return "93"
262274

0 commit comments

Comments
 (0)