0
votes

I run Modelsim in the cmd from a python program. I use the following code which call a tcl script which run the modelsim:

os.system("vsim -c -do top_tb_simulate_reg.tcl " )

The tcl script contain the following:

vsim -voptargs="+acc" +UVM_TESTNAME=test_name +UVM_MAX_QUIT_COUNT=1 +UVM_VERBOSITY=UVM_LOW \
    -t 1ps -L unisims_verm -L generic_baseblocks_v2_1_0 -L axi_infrastructure_v1_1_0 \
    -L dds_compiler_v6_0_12 -lib xil_defaultlib xil_defaultlib.girobo2_tb_top \
    xil_defaultlib.glbl

I want that the value of the +UVM_TESTNAME will be an argument which I passed from the cmd when I execute:

os.system("vsim -c -do top_tb_simulate_reg.tcl " )

How can I do it?

I tried the following with no succees:

Python script:

os.system("vsim -c -do top_tb_simulate_reg.tcl axi_rd_only_test" )

Simulation file (tcl script)

vsim -voptargs="+acc" +UVM_TESTNAME=$argv +UVM_MAX_QUIT_COUNT=1 +UVM_VERBOSITY=UVM_LOW \
    -t 1ps -L unisims_verm -L generic_baseblocks_v2_1_0 -L axi_infrastructure_v1_1_0 \
    -L dds_compiler_v6_0_12 -lib xil_defaultlib xil_defaultlib.girobo2_tb_top \
    xil_defaultlib.glbl

I got the following error:

# ** Error: (vsim-3170) Could not find 'C:/raft/raftortwo/girobo2/ver/sim/work.axi_rd_only_test'.
2
You should say what the error messages were. Or we could play “guess the problem with a blindfold on”… - Donal Fellows
You may dump everything (vsim command, tcl script and its arguments into a temporary shell script - created on the fly) and do an os.system('foo.sh'). - Sharad

2 Answers

1
votes

The problem is that the vsim binary is doing its own processing of the arguments, and that is interfering. While yes, you can probably find a way around this by reading the vsim documentation, the simplest way around this is to pass values via environment variables. They're inherited by a process from its parent process, and are fine for passing most things. (The exception are security tokens, which should always be passed in files with correctly-set permissions, rather than either environment variables or command-line arguments.)

In your python code:

# Store the value in the *inheritable* environment
os.environ["MY_TEST_CASE"] = "axi_rd_only_test"

# Do the call; the environment gets passed over behind the scenes
os.system("vsim -c -do top_tb_simulate_reg.tcl " )

In your tcl code:

# Read out of the inherited environment
set name $env(MY_TEST_CASE)

# Use it! (Could do this as one line, but that's hard to read)
vsim -voptargs="+acc" +UVM_TESTNAME=$name +UVM_MAX_QUIT_COUNT=1 +UVM_VERBOSITY=UVM_LOW \
    -t 1ps -L unisims_verm -L generic_baseblocks_v2_1_0 -L axi_infrastructure_v1_1_0 \
    -L dds_compiler_v6_0_12 -lib xil_defaultlib xil_defaultlib.girobo2_tb_top \
    xil_defaultlib.glbl
0
votes

Late to the party but I found a great workaround for your obstacle. The do command within Modelsim's TCL instance does accept parameters. See command reference.

vsim -c -do filename.tcl can't take parameters, but you can use vsim -c -do "do filename.tcl params".

In your case this translates to os.system('vsim -c -do "do top_tb_simulate_reg.tcl axi_rd_only_test"'). Your .tcl script will find the parameter passed through the variable $1.

I hope to helps anyone!