Search code examples
tclcommand-line-argumentsmodelsim

Quit Modelsim from command line on error


I am using a .do file which is used by GUI and by .tcl in command line (vsim -c) for simulating in Modelsim 10.3c

exec vsim -c -do DoFile.do

What I need is: If an error happens, modelsim should be quit and return to the .tcl. Otherwise it should simulate the project.

If I put the line onerror { quit -f } in my .do file the GUI is quit at the first error. So, this is not comfortable.

I didn't manage to use onerror (warning: onerror command for use within macro) or $error (unknown variable) inside tcl


Solution

  • I have found a work around. I create a file in the .tcl and put the following lines into the .do scripts:

    if [file exists ../Command_Line_Enable.txt] {
         onerror { quit -f }
    }
    

    So, if that file is not generated the GUI will not exit.