Skip to content

Commit

Permalink
feat: add boolean GHDL option ghdl.elab_e, to execute 'ghdl -e'
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Apr 14, 2019
1 parent 8bbc4c8 commit 3dea5ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
36 changes: 22 additions & 14 deletions vunit/ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions vunit/test_suites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 3dea5ac

Please sign in to comment.