VUnit / vunit

VUnit is a unit testing framework for VHDL/SystemVerilog
http://vunit.github.io/
Other
722 stars 260 forks source link

Add vunit_tb_name tcl variable and vunit_tb_path for Active-HDL #1033

Closed maleiter closed 3 months ago

maleiter commented 3 months ago

The main usage of the sim options .init_file.gui is loading the correct wave file. To load the correct wave file, the vunit_tb_path variable is defined during script evaluation. That variable points to the directory that contains the testbench.

If a user wants to load different wave files for different test benches located in the same directory, the name of the testbench is needed.

This PR adds the name of the test bench as a tcl variable called vunit_tb_name for modelsim, riviera and active-hdl. This PR also adds the vunit_tb_path for active-hdl.

Example usage for Active-HDL

tb.set_sim_option("activehdl.init_file.gui", "activehdl_gui.do")

activehdl_gui.do:

global wavefile
set wavefile ${vunit_tb_path}/${vunit_tb_name}_wave.do

# try to source a wave file with the name of the design unit
if { [file exists ${wavefile}] } {
    puts "loading wave from '${wavefile}'."
    do ${wavefile}
} else {
    puts "No Wave file found in the testbench directory. If you save a wave as '${vunit_tb_name}_wave.do', it will be loaded automatically next time."
}
maleiter commented 3 months ago

@LarsAsplund Since my changes were based on a former version of #1032, I had to rebase and force-push everything. It's ready now :)

LarsAsplund commented 3 months ago

Thanks!