Modelsim Tips & Tricks

In this article we will see how to create a simple Tcl script that tests for certain values on a signal and then adds bookmarks that zoom the Wave window when that value exists. Bookmarks allow you to save a particular zoom range and scroll position in the Wave window. The Tcl script also creates buttons in the Main window that call these bookmarks.

1. Create the script.
a. In a text editor, open a new file and enter the following lines:

proc add_wave_zoom {stime num} {
echo "Bookmarking wave $num"
bookmark add wave "bk$num" "[expr $stime - 50] [expr $stime + 100]" 0
add button "$num" [list bookmark goto wave bk$num]
}

These commands do the following:
• Create a new procedure called "add_wave_zoom" that has two arguments, stime and num.
• Create a bookmark with a zoom range from the current simulation time minus 50 time units to the current simulation time plus 100 time units.
• Add a button to the Main window that calls the bookmark.
b. Now add these lines to the bottom of the script:
Assuming:
You have a RTL counter module with a bus called count..

add wave -r /*
when {clk'event and clk="1"} {
echo "Count is [exa count]"
if {[exa count]== "00100111"} {
add_wave_zoom $now 1
} elseif {[exa count]== "01000111"} {
add_wave_zoom $now 2
}
}

These commands do the following:
• Add all signals to the Wave window.
• Use a when statement to identify when clk transitions to 1.
• Examine the value of count at those transitions and add a bookmark if it is a certain value.

Post a Comment

0 Comments