Example 2
This next example shows a complete Tcl script that restores multiple Wave windows to their state in a previous simulation, including signals listed, geometry, and screen position. It also adds buttons to the Main window toolbar to ease management of the wave files. This example works in ModelSim SE only.
## This file contains procedures to manage multiple wave files. ## Source this file from the command line or as a startup script. ## source <path>/wave_mgr.tcl ## add_wave_buttons ## Add wave management buttons to the main toolbar (new, save and load) ## new_wave ## Dialog box creates a new wave window with the user provided name ## named_wave <name> ## Creates a new wave window with the specified title ## save_wave <file-root> ## Saves name, window location and contents for all open ## wave windows ## Creates <file-root><n>.do file for each window where <n> is 1 ## to the number of windows. Default file-root is "wave". Also ## creates windowSet.do file that contains title and geometry info. ## load_wave <file-root> ## Opens and loads wave windows for all files matching <file-root><n>.do ## where <n> are the numbers from 1-9. Default <file-root> is "wave". ## Also runs windowSet.do file if it exists. ## Add wave management buttons to the main toolbar proc add_wave_buttons {} { _add_menu main controls right SystemMenu SystemWindowFrame {Load Waves} load_wave _add_menu main controls right SystemMenu SystemWindowFrame {Save Waves} save_wave _add_menu main controls right SystemMenu SystemWindowFrame {New Wave} new_wave } ## Simple Dialog requests name of new wave window. Defaults to Wave<n> proc new_wave {} { global dialog_prompt vsimPriv set defaultName "Wave[llength $vsimPriv(WaveWindows)]" set dialog_prompt(result) $defaultName set windowName [GetValue . "Create Named Wave Window:" ] ## Debug puts "Window name: $windowName\n"; if {$windowName == "{}"} { set windowName "" } if {$windowName != ""} { named_wave $windowName } else { named_wave $defaultName } } ## Creates a new wave window with the provided name (defaults to "Wave") proc named_wave {{name "Wave"}} { global vsimPriv view -new wave set newWave [lindex $vsimPriv(WaveWindows) [expr [llength \ $vsimPriv(WaveWindows)] - 1]] wm title $newWave $name } ## Writes out format of all wave windows, stores geometry and title info in ## windowSet.do file. Removes any extra files with the same fileroot. ## Default file name is wave<n> starting from 1. proc save_wave {{fileroot "wave"}} { global vsimPriv set n 1 set fileId [open windowSet_$fileroot.do w 755] foreach w $vsimPriv(WaveWindows) { echo "Saving: [wm title $w]" set filename $fileroot$n.do write format wave -window $w $filename puts $fileId "wm title $w \"[wm title $w]\"" puts $fileId "wm geometry $w [wm geometry $w]" puts $fileId "mtiGrid_colconfig $w.grid name -width \ [mtiGrid_colcget $w.grid name -width]" puts $fileId "mtiGrid_colconfig $w.grid value -width \ [mtiGrid_colcget $w.grid value -width]" flush $fileId incr n } if {![catch {glob $fileroot\[$n-9\].do}]} { foreach f [lsort [glob $fileroot\[$n-9\].do]] { echo "Removing: $f" exec rm $f } } } ## Provide file root argument and load_wave restores all saved widows. ## Default file root is "wave". proc load_wave {{fileroot "wave"}} { global vsimPriv foreach f [lsort [glob $fileroot\[1-9\].do]] { echo "Loading: $f" view -new wave do $f } if {[file exists windowSet_$fileroot.do]} { do windowSet_$fileroot.do } }
Model Technology Incorporated Voice: (503) 641-1340 Fax: (503)526-5410 www.model.com sales@model.com |