Reputation: 384
I want to make a script, which can be executed from shell like: ./myscript -test1 or tclsh myscript.tcl -test1
I want it to open ModelSim, compile units, load a desired testbench, run simulation. Name of the test would be a parameter. I've already made macro files (.do) containing modelsim commands to compile & simulate desired units (+adding signals to waveform). I'm asking because scripting isn't my area of expertise.
So here's my questions:
How to ,,tell'' Modelsim (at startup) to do the commands in specified file?
Is TCL the language i'm looking for // is it doable in TCL? If so, which commands should i make familiar with?
Or maybe shell script is sufficient and i should look for specific Modelsim commands in reference manual?
Thanks for you time!
EDIT: Posting little example i've made for everyone to use. Usage: ./foo.tcl testname
#!/usr/bin/tclsh
# params
set testname [lindex $argv 0]
set testlist {test1 test2 test3}
# run vsim test $testname
if { [ lsearch $testlist $testname ] >= 0 } {
puts "Test found. Executing..."
open "|vsim -do $testname "
} else { puts "Test not found on the list!" }
Upvotes: 4
Views: 13485
Reputation: 138
If you create a .tcl script (.do files can run QuestaSim/ModelSim commands and tcl commands), you can do everything you want to do, include running other .do/.tcl files. For example:
ModelSim/QuestaSim Command Line:
just like what you are used to...
$: do MyDoFile.do
...instead use a Tcl file, which could call out your .do files:
$: source ./MyDirectory/MyTCLScript.tcl
Within that MyTCLScript.tcl you can have literally the following:
Within
MyTCLScript.tcl
:... #Use tabs for aliases source ./MyDirectory/OtherDirectory/OtherTCLScript.tcl MyAlias1 MyAlias2 do ./MyDoFile.do ...
Finally, to let you use commands to run single testbenches and the sort, I suggest looking at Tcl documentation on aliases. Here is an example though:
Within
OtherTCLScript.tcl
:... alias MyAlias1 { eval <command><command flags> } alias MyAlias2 { eval <command><command flags> } ...
Sources: 1. Experience 2. Questa SIM User's Manual
Upvotes: 1
Reputation: 3421
You can launch vsim
with arbitrary commands using the -do <arg>
command line option. The argument can either be a filename of a .do file containing arbitrary Tcl code or a string of Tcl commands ("run -all; quit" is useful for non-interactive command line mode with -c
).
Tcl is a full featured scripting language. It can handle any automation task you need to accomplish. Ultimately you cannot escape Tcl with Modelsim since almost everything runs through it internally. I would recommend you piece together what you need in a .do file and run that using the -do
option.
Upvotes: 5