diff --git a/vunit/ghdl_interface.py b/vunit/ghdl_interface.py index dd31d6831..ff9183e16 100644 --- a/vunit/ghdl_interface.py +++ b/vunit/ghdl_interface.py @@ -18,7 +18,8 @@ from vunit.ostools import Process from vunit.simulator_interface import (SimulatorInterface, ListOfStringOption, - StringOption) + StringOption, + BooleanOption) from vunit.exceptions import CompileError LOGGER = logging.getLogger(__name__) @@ -41,6 +42,7 @@ class GHDLInterface(SimulatorInterface): ListOfStringOption("ghdl.sim_flags"), ListOfStringOption("ghdl.elab_flags"), StringOption("ghdl.gtkwave_script.gui"), + BooleanOption("ghdl.elab_e") ] @staticmethod @@ -187,31 +189,35 @@ def compile_vhdl_file_command(self, source_file): cmd += [source_file.name] return cmd - def _get_sim_command(self, config, output_path): + def _get_command(self, config, output_path, ghdl_e): """ Return GHDL simulation command """ cmd = [join(self._prefix, self.executable)] - cmd += ['--elab-run'] + + if ghdl_e: + cmd += ['-e'] + else: + cmd += ['--elab-run'] + cmd += ['--std=%s' % self._std_str(self._vhdl_standard)] cmd += ['--work=%s' % config.library_name] cmd += ['--workdir=%s' % self._project.get_library(config.library_name).directory] cmd += ['-P%s' % lib.directory for lib in self._project.get_libraries()] - if self._has_output_flag(): cmd += ['-o', join(output_path, "%s-%s" % (config.entity_name, config.architecture_name))] cmd += config.sim_options.get("ghdl.elab_flags", []) cmd += [config.entity_name, config.architecture_name] - cmd += config.sim_options.get("ghdl.sim_flags", []) - - for name, value in config.generics.items(): - cmd += ['-g%s=%s' % (name, value)] - cmd += ['--assert-level=%s' % config.vhdl_assert_stop_level] + if not ghdl_e: + cmd += config.sim_options.get("ghdl.sim_flags", []) + for name, value in config.generics.items(): + cmd += ['-g%s=%s' % (name, value)] + cmd += ['--assert-level=%s' % config.vhdl_assert_stop_level] + if config.sim_options.get("disable_ieee_warnings", False): + cmd += ["--ieee-asserts=disable"] - if config.sim_options.get("disable_ieee_warnings", False): - cmd += ["--ieee-asserts=disable"] return cmd def simulate(self, # pylint: disable=too-many-locals @@ -227,12 +233,14 @@ def simulate(self, # pylint: disable=too-many-locals if not exists(script_path): os.makedirs(script_path) - cmd = self._get_sim_command(config, script_path) + ghdl_e = elaborate_only and config.sim_options.get("ghdl.elab_e", False) + + cmd = self._get_command(config, script_path, ghdl_e) - if elaborate_only: + if elaborate_only and not ghdl_e: cmd += ["--no-run"] - if self._gtkwave_fmt is not None: + if self._gtkwave_fmt is not None and not ghdl_e: data_file_name = join(script_path, "wave.%s" % self._gtkwave_fmt) if exists(data_file_name): diff --git a/vunit/test/unit/test_ghdl_interface.py b/vunit/test/unit/test_ghdl_interface.py index 7a817ea6a..071d6a843 100644 --- a/vunit/test/unit/test_ghdl_interface.py +++ b/vunit/test/unit/test_ghdl_interface.py @@ -8,7 +8,6 @@ Test the GHDL interface """ - import unittest from os.path import join, dirname, exists import os @@ -18,6 +17,8 @@ from vunit.project import Project from vunit.ostools import renew_path, write_file from vunit.exceptions import CompileError +from vunit.test.unit.test_test_bench import Entity +from vunit.configuration import Configuration class TestGHDLInterface(unittest.TestCase): @@ -154,6 +155,32 @@ def test_compile_project_extra_flags(self, check_output): # pylint: disable=no- [join("prefix", 'ghdl'), '-a', '--workdir=lib_path', '--work=lib', '--std=08', '-Plib_path', 'custom', 'flags', 'file.vhd'], env=simif.get_env()) + def test_elaborate_e_project(self): + design_unit = Entity('tb_entity', file_name=join("tempdir", "file.vhd")) + design_unit.original_file_name = join("tempdir", "other_path", "original_file.vhd") + design_unit.generic_names = ["runner_cfg", "tb_path"] + + config = Configuration("name", design_unit, sim_options={"ghdl.elab_e": True}) + + simif = GHDLInterface(prefix="prefix", output_path="") + simif._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 + + self.assertEqual( + simif._get_command(config, join('output_path', 'ghdl'), True), # pylint: disable=protected-access + [ + join('prefix', 'ghdl'), + '-e', + '--std=08', + '--work=lib', + '--workdir=lib_path', + '-Plib_path', + '-o', join('output_path', 'ghdl', 'tb_entity-arch'), + 'tb_entity', 'arch' + ] + ) + def test_compile_project_verilog_error(self): simif = GHDLInterface(prefix="prefix", output_path="") write_file("file.v", "") diff --git a/vunit/test_suites.py b/vunit/test_suites.py index e544d5f23..1204d8211 100644 --- a/vunit/test_suites.py +++ b/vunit/test_suites.py @@ -165,9 +165,8 @@ def run(self, output_path, read_output): sim_ok = self._simulate(output_path) if self._elaborate_only: - for name in self._test_cases: - results[name] = PASSED if sim_ok else FAILED - return results + status = PASSED if sim_ok else FAILED + return dict((name, status) for name in self._test_cases) results = self._read_test_results(file_name=get_result_file_name(output_path)) diff --git a/vunit/ui.py b/vunit/ui.py index d4d080d90..5e4f6f915 100644 --- a/vunit/ui.py +++ b/vunit/ui.py @@ -191,6 +191,10 @@ Extra simulation flags passed to ``ghdl --elab-run``. Must be a list of strings. +``ghdl.elab_e`` + With ``--elaborate``, execute ``ghdl -e`` instead of ``ghdl --elab-run --no-run``. + Must be a boolean. + ``ghdl.gtkwave_script.gui`` A user defined TCL-file that is sourced after the design has been loaded in the GUI. For example this can be used to configure the waveform viewer. Must be a string.