Technical data

when
CR-228 ModelSim Commands ModelSim EE/SE Command Reference
Examples
The when command below instructs the simulator to display the value of item c
in binary format when there is a clock event, the clock is 1, and the value of b is
01100111, and then to stop.
when -label when1 {clkevent and clk=1 and b = 01100111} {
echo Signal c is [exa -bin c]"
stop}
The when command below is labeled a and will cause VSIM to echo the
message b changed whenever the value of the item b changes.
when -label a b {echo b changed}
The multi-line when command below does not use a label and has two conditions.
When the conditions are met, an echo
(CR-75) and a stop (CR-152) command will
be executed.
when {b = 1
and c /= 0 } {
echo b is 1 and c is not 0
stop
}
Batch mode simulations (see How to use checkpoint/restore (E-438)) are often
structured as "run until condition X is true," rather than "run for X time"
simulations. The multi-line when command below sets a done condition and
executes an echo
(CR-75) and a stop (CR-152) command when the condition is
reached.
Ending the simulation with the stop command
The simulation will not stop (even if a quit -f command is used) unless a stop
command is executed. To exit the simulation and quit ModelSim, use an approach
like the following:
when {/done_condition == 1} {echo "End condition reached"
if [bathc_mode] {
set DoneConditionReached 1
stop }
}
run 1000 us
if {$DoneConditionReached == 1} {
quit -f
}