From 369ccef065df8c0bbcb53780646c78b8d625bc15 Mon Sep 17 00:00:00 2001 From: Markus Leiter Date: Wed, 19 Jun 2024 19:09:44 +0200 Subject: [PATCH] add vunit_tb_name for modelsim, riviera and activehdl --- docs/py/opts.rst | 7 +++++++ vunit/sim_if/activehdl.py | 5 ++++- vunit/sim_if/vsim_simulator_mixin.py | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/py/opts.rst b/docs/py/opts.rst index 8c15576f7..c782ab69d 100644 --- a/docs/py/opts.rst +++ b/docs/py/opts.rst @@ -123,6 +123,7 @@ The following simulation options are known. using the ``vsim`` command. During script evaluation the ``vunit_tb_path`` variable is defined as the path of the folder containing the test bench. + Additionally, the ``vunit_tb_name`` variable is defined as the name of the test bench. Must be a list of strings. ``modelsim.init_files.before_run`` @@ -136,6 +137,7 @@ The following simulation options are known. For example this can be used to configure the waveform viewer. During script evaluation the ``vunit_tb_path`` variable is defined as the path of the folder containing the test bench. + Additionally, the ``vunit_tb_name`` variable is defined as the name of the test bench. Must be a string. ``rivierapro.vsim_flags`` @@ -153,6 +155,7 @@ The following simulation options are known. using the ``vsim`` command. During script evaluation the ``vunit_tb_path`` variable is defined as the path of the folder containing the test bench. + Additionally, the ``vunit_tb_name`` variable is defined as the name of the test bench. Must be a list of strings. ``rivierapro.init_files.before_run`` @@ -166,6 +169,7 @@ The following simulation options are known. For example this can be used to configure the waveform viewer. During script evaluation the ``vunit_tb_path`` variable is defined as the path of the folder containing the test bench. + Additionally, the ``vunit_tb_name`` variable is defined as the name of the test bench. Must be a string. ``activehdl.vsim_flags`` @@ -180,6 +184,9 @@ The following simulation options are known. ``activehdl.init_file.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. + During script evaluation the ``vunit_tb_path`` variable is defined + as the path of the folder containing the test bench. + Additionally, the ``vunit_tb_name`` variable is defined as the name of the test bench. Must be a string. ``ghdl.elab_flags`` diff --git a/vunit/sim_if/activehdl.py b/vunit/sim_if/activehdl.py index 1881d17c2..6cd809cdf 100644 --- a/vunit/sim_if/activehdl.py +++ b/vunit/sim_if/activehdl.py @@ -458,7 +458,8 @@ def _create_batch_script(common_file_name, load_only=False): def _create_gui_script(self, common_file_name, config): """ - Create the user facing script which loads common functions and prints a help message + Create the user facing script which loads common functions and prints a help message. + Also defines the vunit_tb_path and the vunit_tb_name variable. """ tcl = "" @@ -473,6 +474,8 @@ def _create_gui_script(self, common_file_name, config): init_file = config.sim_options.get(self.name + ".init_file.gui", None) if init_file is not None: + tcl += f'set vunit_tb_name {config.design_unit_name}\n' + tcl += f'set vunit_tb_path {fix_path(str(Path(config.tb_path).resolve()))}\n' tcl += f'source "{fix_path(str(Path(init_file).resolve()))!s}"\n' tcl += "vunit_help\n" diff --git a/vunit/sim_if/vsim_simulator_mixin.py b/vunit/sim_if/vsim_simulator_mixin.py index c68c80cb2..9e5ba95a1 100644 --- a/vunit/sim_if/vsim_simulator_mixin.py +++ b/vunit/sim_if/vsim_simulator_mixin.py @@ -233,9 +233,12 @@ def _source_tcl_file(file_name, config, message): """ Create TCL to source a file and catch errors Also defines the vunit_tb_path variable as the config.tb_path + and the vunit_tb_name variable as the config.design_unit_name + """ template = """ set vunit_tb_path "%s" + set vunit_tb_name "%s" set file_name "%s" puts "Sourcing file ${file_name} from %s" if {[catch {source ${file_name}} error_msg]} { @@ -246,6 +249,7 @@ def _source_tcl_file(file_name, config, message): """ tcl = template % ( fix_path(str(Path(config.tb_path).resolve())), + fix_path(str(Path(config.design_unit_name).resolve())), fix_path(str(Path(file_name).resolve())), message, )