From 9cdb9c96ca0b4662d8f056b585b1d02d25921c46 Mon Sep 17 00:00:00 2001 From: umarcor Date: Sun, 14 Apr 2019 07:34:25 +0200 Subject: [PATCH] feat: add boolean GHDL option ghdl.elab_e, to execute 'ghdl -e' --- vunit/ghdl_interface.py | 36 ++++++++++++++++++++++-------------- vunit/test_suites.py | 7 +++---- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/vunit/ghdl_interface.py b/vunit/ghdl_interface.py index 18e8bae5f1..cddb6f31a3 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 @@ -181,31 +183,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 @@ -221,12 +227,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 = config.sim_options.get("ghdl.elab_e", False) + + cmd = self._get_command(config, script_path, ghdl_e) if elaborate_only: 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): @@ -247,7 +255,7 @@ def simulate(self, # pylint: disable=too-many-locals except Process.NonZeroExitCode: status = False - if self._gui and not elaborate_only: + if self._gui and not elaborate_only and not ghdl_e: cmd = ["gtkwave"] + shlex.split(self._gtkwave_args) + [data_file_name] init_file = config.sim_options.get(self.name + ".gtkwave_script.gui", None) diff --git a/vunit/test_suites.py b/vunit/test_suites.py index 295e7dcdef..2fa7779ee3 100644 --- a/vunit/test_suites.py +++ b/vunit/test_suites.py @@ -164,10 +164,9 @@ 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 + if self._elaborate_only or self._config.sim_options.get("ghdl.elab_e", False): + 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))