Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase

Model Technology Inc.


Using Parameters with DO files

You can increase the flexibility of DO files using parameters. Parameters specify values that are passed to the corresponding parameters $1 through $9 in the macro file. For example,

do testfile design.vhd 127 

If the macro file testfile contains the line bp $1 $2, this command would place a breakpoint in the source file named design.vhd at line 127.

There is no limit on the number of parameters that can be passed to macros, but only nine values are visible at one time. You can use the shift command to see the other parameters.

Useful commands for handling breakpoints and errors

If you are executing a macro when your simulation hits a breakpoint or causes a run-time error, ModelSim interrupts the macro and returns control to the command line. The following commands may be useful for handling such events. (Any other legal command may be executed as well.)

command
result
run -continue
continue as if the breakpoint had not been executed, completes the run that was interrupted
continue running the macro
specify a command to run when you hit a breakpoint within a macro
specify a command to run when an error is encountered during elaboration
specify a command to run when an error is encountered within a macro
get a traceback of nested macro calls when a macro is interrupted
terminate a macro once the macro has been interrupted or paused
cause the macro to be interrupted, the macro can be resumed by entering a resume command via the command line
control echoing of macro commands to the Main window transcript


Note: You can also set the OnErrorDefaultAction Tcl variable (see "Preference variables located in Tcl files" ) in the pref.tcl file to dictate what action ModelSim takes when an error occurs.

Error action in DO files

If a command in a macro returns an error, ModelSim does the following:

  1. If an onerror command has been set in the macro script, ModelSim executes that command.
  2. If no onerror command has been specified in the script, ModelSim checks the
    OnErrorDefaultAction Tcl variable. If the variable is defined, it will be invoked.
  3. If neither 1 or 2 is true, the macro aborts.

Using the Tcl source command with DO files

Either the do command or Tcl source command can execute a DO file, but they behave differently.

With the source command, the DO file is executed exactly as if the commands in it were typed in by hand at the prompt. Each time a breakpoint is hit the Source window is updated to show the breakpoint. This behavior could be inconvenient with a large DO file containing many breakpoints.

When a do command is interrupted by an error or breakpoint, it does not update any windows, and keeps the DO file "locked". This keeps the Source window from flashing, scrolling, and moving the arrow when a complex DO file is executed. Typically an onbreak resume command is used to keep the macro running as it hits breakpoints. Add an onbreak abort command to the DO file if you want to exit the macro and update the Source window.

See also

See the do command. Also see the DOPATH variable for adding a DO file path to your environment.


Model Technology Inc.
Model Technology Incorporated
Voice: (503) 641-1340
Fax: (503)526-5410
www.model.com
sales@model.com
Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase