Skip to content
Closed
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
12 changes: 12 additions & 0 deletions vunit/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ def set_generic(self, name, value):
else:
self.generics[name] = value

def set_objects(self, files):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files)

def set_sim_option(self, name, value):
"""
Set sim option
Expand Down Expand Up @@ -199,6 +205,12 @@ def set_generic(self, name, value):
for config in configs.values():
config.set_generic(name, value)

def set_objects(self, files, overwrite=True):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files, overwrite)

def set_sim_option(self, name, value, overwrite=True):
"""
Set sim option
Expand Down
11 changes: 11 additions & 0 deletions vunit/ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def determine_backend(cls, prefix):
print("=============================" + ("=" * 60))
raise AssertionError("No known GHDL back-end could be detected from running 'ghdl --version'")

@classmethod
def supports_vhpi(cls):
"""
Return if the simulator supports VHPI
"""
return cls.determine_backend(cls.find_prefix_from_path()) != "mcode"

def _has_output_flag(self):
"""
Returns if backend supports output flag
Expand Down Expand Up @@ -208,6 +215,10 @@ def _get_command(self, config, output_path, ghdl_e):
cmd += ['-o', join(output_path, "%s-%s" % (config.entity_name,
config.architecture_name))]
cmd += config.sim_options.get("ghdl.elab_flags", [])
objs = config.sim_options.get("objects", [])
if objs:
cmd += ["-Wl," + " ".join(objs)]

cmd += [config.entity_name, config.architecture_name]

if not ghdl_e:
Expand Down
3 changes: 2 additions & 1 deletion vunit/simulator_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def _extract_sim_options(self):
[VHDLAssertLevelOption(),
BooleanOption("disable_ieee_warnings"),
BooleanOption("enable_coverage"),
ListOfStringOption("pli")])
ListOfStringOption("pli"),
ListOfStringOption("objects")])

for sim_class in self.supported_simulators():
for opt in sim_class.sim_options:
Expand Down
9 changes: 8 additions & 1 deletion vunit/simulator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from vunit.color_printer import NO_COLOR_PRINTER


class SimulatorInterface(object):
class SimulatorInterface(object): # pylint: disable=too-many-public-methods
"""
Generic simulator interface
"""
Expand Down Expand Up @@ -145,6 +145,13 @@ def has_valid_exit_code():
"""
return False

@staticmethod
def supports_vhpi():
"""
Return if the simulator supports VHPI
"""
return False

def merge_coverage(self, file_name, args): # pylint: disable=unused-argument, no-self-use
"""
Hook for simulator interface to creating coverage reports
Expand Down
10 changes: 10 additions & 0 deletions vunit/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ def simulator_is(*names):
return SIMULATOR_FACTORY.select_simulator().name in names


def simulator_check(func):
"""
Check some method of the selected simulator
"""
simif = SIMULATOR_FACTORY.select_simulator()
if simif is None:
return False
return func(simif)


def check_report(report_file, tests=None):
"""
Check an XML report_file for the exact occurrence of specific test results
Expand Down
24 changes: 24 additions & 0 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ def set_parameter(self, name, value, allow_empty=False):
for test_bench in check_not_empty(test_benches, allow_empty, "No test benches found"):
test_bench.set_generic(name, value)

def set_objects(self, files, overwrite=True):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files, overwrite=overwrite)

def set_sim_option(self, name, value, allow_empty=False, overwrite=True):
"""
Set simulation option in all |configurations|
Expand Down Expand Up @@ -1199,6 +1205,12 @@ def set_parameter(self, name, value, allow_empty=False):
for test_bench in self.get_test_benches(allow_empty=allow_empty):
test_bench.set_generic(name, value)

def set_objects(self, files, allow_empty=False, overwrite=True):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files, allow_empty=allow_empty, overwrite=overwrite)

def set_sim_option(self, name, value, allow_empty=False, overwrite=True):
"""
Set simulation option within all |configurations| of test benches and tests this library
Expand Down Expand Up @@ -1512,6 +1524,12 @@ def set_parameter(self, name, value):
"""
self._test_bench.set_generic(name, value)

def set_objects(self, files, overwrite=True):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files, overwrite)

def set_sim_option(self, name, value, overwrite=True):
"""
Set simulation option within all |configurations| of this test bench or test cases within it
Expand Down Expand Up @@ -1793,6 +1811,12 @@ def set_parameter(self, name, value):
"""
self._test_case.set_generic(name, value)

def set_objects(self, files, overwrite=True):
"""
Set list of pre-built objects to be linked
"""
self.set_sim_option("objects", files, overwrite)

def set_sim_option(self, name, value, overwrite=True):
"""
Set simulation option within all |configurations| of this test
Expand Down