Skip to content

Commit

Permalink
Added vunit_tb_name for modelsim, riviera and activehdl
Browse files Browse the repository at this point in the history
  • Loading branch information
maleiter committed Jun 21, 2024
1 parent 70e101c commit 810ec8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/py/opts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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``
Expand All @@ -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``
Expand All @@ -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``
Expand All @@ -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``
Expand Down
5 changes: 4 additions & 1 deletion vunit/sim_if/activehdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions vunit/sim_if/vsim_simulator_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]} {
Expand All @@ -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,
)
Expand Down

0 comments on commit 810ec8a

Please sign in to comment.