Tcl Programming/Modelsim

TCL SCRIPT FOR MODELSIM USERS

I tried to find a TCL script, which helps in compilation and simulation of Modelsim programs and has both GUI and single letter commands but I didn't find any.

Later I learned TCL and wrote a small script for Modelsim users, which makes icons on the Modelsim GUI. Just by clicking on the icons your project files will get compiled, simulated and so on.

The icons and its description are


·compile c is for compilation, simulation, add wave and run, simply do everything

·com-restart r does compilation and restarts the already run code, we do this whenever we change code and want to compile and execute it

·Quitsim q quits the simulation

·QuitModel sim Q quits Modelsim


You can do all the afore said things just by clicking on the icon as we use 'save' and 'open'-like icons in general GUI.

And also you can do these things just by typing c, r, q & Q (defined above) on the command prompt, only one letter will do.

For these things, you just have to execute one command on the command prompt of Modelsim after opening Modelsim:

source filename.tcl


TCL CODE:

proc c  {} {
    '''''vcom counter.vhd  ''''' # add  your files here then delete this comment 
    '''''vcom countertb.vhd  '''''  
    echo "---------------COMPILATION IS OVER--------------------------"
    '''''vsim work.countertb'''''
    echo "---------------STARTED SIMULATION---------------------------"
    add wave *
    run -all
}

proc r  {} {
    '''''vcom counter.vhd'''''  # add  your files here then delete this comment
    '''''vcom countertb.vhd'''''   
    echo "---------------COMPILATION IS OVER--------------------------"
    restart
    echo "---------------SIMULATION IS RESTARTED----------------------"    
    run -all
}
proc q  {} {
 quit -sim
}

proc Q  {} {
 quit -force
}



button .compile -command c -text "Compile"

button .compile_restart  -command r -text "Com-Restart"

button .quitsim -command q       -text "QuitSim"

button .quitmodelsim -command Q   -text "QuitModelsim"


pack .compile -side left

pack .compile_restart -side left

pack .quitsim -side right

pack .quitmodelsim -side right


This is a very generic code suited for all projects of Modelsim but unfortunately only Modelsim DE and Questa sim supports button command you just have to change the bold and italic font statements(.vhd files). These statements are for files of a counter project here. So you have to replace those counter example files with your project files.


Then save your file as script.tcl (file with .tcl extension) and execute the file with “source “ command as said above.


Now your GUI and single letter commands are ready to simplify your work.

For any assistance contact: mohan@tataelxsi.co.in