Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sim_opt 'ghdl.elab_e' to run 'ghdl -e' instead of 'ghdl --elab-run --no-run' #467

Merged
merged 7 commits into from
Apr 16, 2019
Merged
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
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 @@ -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
Expand All @@ -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):
Expand Down
29 changes: 28 additions & 1 deletion vunit/test/unit/test_ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Test the GHDL interface
"""


import unittest
from os.path import join, dirname, exists
import os
Expand All @@ -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):
Expand Down Expand Up @@ -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", "")
Expand Down
5 changes: 2 additions & 3 deletions vunit/test_suites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

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