Skip to content

Commit

Permalink
Merge pull request VUnit#564 from felixn/master
Browse files Browse the repository at this point in the history
Add .init_files.before_run hook (related to issue VUnit#562)
  • Loading branch information
kraigher authored Oct 10, 2019
2 parents 3de8d22 + 779dc71 commit a2f189f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vunit/modelsim_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ModelSimInterface(VsimSimulatorMixin, SimulatorInterface): # pylint: disa
ListOfStringOption("modelsim.vsim_flags"),
ListOfStringOption("modelsim.vsim_flags.gui"),
ListOfStringOption("modelsim.init_files.after_load"),
ListOfStringOption("modelsim.init_files.before_run"),
StringOption("modelsim.init_file.gui"),
]

Expand Down Expand Up @@ -312,6 +313,10 @@ def _create_run_function():
}
proc _vunit_run {} {
if {[_vunit_source_init_files_before_run]} {
return true
}
proc on_break {} {
resume
}
Expand Down
5 changes: 5 additions & 0 deletions vunit/rivierapro_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RivieraProInterface(VsimSimulatorMixin, SimulatorInterface):
ListOfStringOption("rivierapro.vsim_flags"),
ListOfStringOption("rivierapro.vsim_flags.gui"),
ListOfStringOption("rivierapro.init_files.after_load"),
ListOfStringOption("rivierapro.init_files.before_run"),
StringOption("rivierapro.init_file.gui"),
]

Expand Down Expand Up @@ -323,6 +324,10 @@ def _create_run_function():
}
proc _vunit_run {} {
if {[_vunit_source_init_files_before_run]} {
return true
}
proc on_break {} {
resume
}
Expand Down
16 changes: 16 additions & 0 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@
``modelsim.init_files.after_load``
A list of user defined DO/TCL-files that is sourced after the design has been loaded.
They will be executed during ``vunit_load``, after the top level has been loaded
using the ``vsim`` command.
During script evaluation the ``vunit_tb_path`` variable is defined
as the path of the folder containing the test bench.
Must be a list of strings.
``modelsim.init_files.before_run``
A list of user defined DO/TCL-files that is sourced before the simulation is run.
They will be executed at the start of ``vunit_run`` (and therefore also re-executed
by ``vunit_restart``).
Must be a list of strings.
``modelsim.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.
Expand All @@ -158,10 +166,18 @@
``rivierapro.init_files.after_load``
A list of user defined DO/TCL-files that is sourced after the design has been loaded.
They will be executed during ``vunit_load``, after the top level has been loaded
using the ``vsim`` command.
During script evaluation the ``vunit_tb_path`` variable is defined
as the path of the folder containing the test bench.
Must be a list of strings.
``rivierapro.init_files.before_run``
A list of user defined DO/TCL-files that is sourced before the simulation is run.
They will be executed at the start of ``vunit_run`` (and therefore also re-executed
by ``vunit_restart``).
Must be a list of strings.
``rivierapro.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.
Expand Down
15 changes: 15 additions & 0 deletions vunit/vsim_simulator_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def _create_common_script(self,
"""
tcl += self._create_init_files_after_load(config)
tcl += self._create_init_files_before_run(config)
tcl += self._create_load_function(test_suite_name, config, script_path)
tcl += get_is_test_suite_done_tcl(get_result_file_name(output_path))
tcl += self._create_run_function()
Expand Down Expand Up @@ -200,6 +201,20 @@ def _create_init_files_after_load(self, config):
tcl += "}\n"
return tcl

def _create_init_files_before_run(self, config):
"""
Create the _vunit_source_init_files_before_run function which sources the user defined TCL file in
simulator_name.init_files.before_run
"""
opt_name = self.name + ".init_files.before_run"
init_files = config.sim_options.get(opt_name, [])
tcl = "proc _vunit_source_init_files_before_run {} {\n"
for init_file in init_files:
tcl += self._source_tcl_file(init_file, config, opt_name)
tcl += " return 0\n"
tcl += "}\n"
return tcl

def _create_user_init_function(self, config):
"""
Create the vunit_user_init function which sources the user defined TCL file in
Expand Down

0 comments on commit a2f189f

Please sign in to comment.