From aa21c26acbb529aa71dcdfef822486a02a8ceb26 Mon Sep 17 00:00:00 2001 From: umarcor Date: Sat, 20 Apr 2019 18:43:52 +0200 Subject: [PATCH] add method set_objects --- vunit/configuration.py | 12 ++++++++++++ vunit/ghdl_interface.py | 6 +++++- vunit/simulator_factory.py | 3 ++- vunit/ui.py | 24 ++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/vunit/configuration.py b/vunit/configuration.py index 5c16665de..cd987d1f7 100644 --- a/vunit/configuration.py +++ b/vunit/configuration.py @@ -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 @@ -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 diff --git a/vunit/ghdl_interface.py b/vunit/ghdl_interface.py index ef0624c72..9816db128 100644 --- a/vunit/ghdl_interface.py +++ b/vunit/ghdl_interface.py @@ -129,7 +129,7 @@ def supports_vhpi(cls): """ Return if the simulator supports VHPI """ - return cls.determine_backend(cls.find_prefix_from_path()) == "mcode" + return cls.determine_backend(cls.find_prefix_from_path()) != "mcode" def _has_output_flag(self): """ @@ -215,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: diff --git a/vunit/simulator_factory.py b/vunit/simulator_factory.py index b0d71e7bb..09993664c 100644 --- a/vunit/simulator_factory.py +++ b/vunit/simulator_factory.py @@ -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: diff --git a/vunit/ui.py b/vunit/ui.py index 5e4f6f915..2fc991ef4 100644 --- a/vunit/ui.py +++ b/vunit/ui.py @@ -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| @@ -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 @@ -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 @@ -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