© Synopsys 2012 1
Verdi3 TCL Training
Based on Verdi3 2013.01
© Synopsys 2012 2
Glossary
• VIA = Verdi Interoperability Applications
• NPI = Novas Programming Interface
• Novas KDB = Novas Knowledge Database
• FSDB = Fast Signal Database
• VPI = Verilog Procedural Interface
© Synopsys 2012 3
Overview
• Verdi Tcl Introduction
– Use Tcl in Verdi
– Case Study
• Debug Tcl Scripts
• Labs
© Synopsys 2012 4
Overview
• Verdi Tcl Introduction
– Use Tcl in Verdi
– Case Study
• Debug Tcl Scripts
• Labs
© Synopsys 2012 5
Tcl Introduction
• Automated cause & effect tracing
– Save significant engineering time
– Easy visualization of behavior with time
and structure
• Complete, easy to use environment
– Design knowledge activated viewers
– Waveform, source code, schema, TFV
– Advanced debugger
– State, testbench, assertions, transactions
– Power-aware
– Clock analysis
– Post-layout ECO
• Single portal for multiple languages,
tools and methodologies
– Verilog, VHDL, System Verilog
– Open interface for verification tools
Verdi Technology Background
KDB
Open API Compiler
Verification Tools Designs
FSDB
© Synopsys 2012 6
Tcl Introduction
• What is Tcl?
– Tcl stands for Tool Command Language
– A “String” basis scripting language
– Use source your_script.tcl to execute your Tcl script under tclsh
• What is Tk?
– Tk is an associated toolkit to create window-based interactive
applications using Tcl
Tcl Basic
© Synopsys 2012 7
Tcl Introduction
• Use Tcl to combine Verdi commands to make your own feature to improve efficiency
• Add your new feature, which was created by Tcl scripts, to the Verdi menu command or bind-key
• Use NPI (Novas Programming Interface) to traverse the design without Verdi GUI
What Can You Do in Verdi with Tcl?
© Synopsys 2012 8
Tcl Introduction
• Application of FSDB
– Calculate FSDB results. For example, duty cycles
– Search and sort FSDB results. For example, search for small pulses
• Interoperability with 3rd party tools
– Read 3rd party tool reports and translate into Verdi’s format
• Application of KDB
– Access to Verdi database to do calculations and queries. For example,
extract snake path from the design
Possible Applications in Verdi with Tcl
© Synopsys 2012 9
Tcl Introduction
• Verdi provides Tcl commands for each action in the GUI
• All Tcl commands are categorized by module and have a set prefix
Tcl Command Sets in Verdi
Prefix Module
sys System
deb Debussy (Verdi)
src nTrace
wv nWave
sch nSchema
tfg Temporal Flow View
nMem Memory/MDA
fsm nState
reg nRegister
eco nECO
ta Transaction
sid Siloti
lx ListX
© Synopsys 2012 10
Overview
• Verdi Tcl Introduction
– Use Tcl in Verdi
– Case Study
• Debug Tcl Scripts
• Labs
© Synopsys 2012 11
Use Tcl in Verdi
• In the Command Entry form:
– When you execute any GUI command, the associated Tcl command will be logged in the Command Entry form
– Directly typing the Tcl command in the Command Entry form will execute the Tcl command
– Type source your_script.tcl in the Command Entry form to execute the Tcl script
Execute Tcl in GUI
© Synopsys 2012 12
Use Tcl in Verdi
• Open the Command Entry form:
– Invoke the Preferences form from Tools Preferences
– Go to General folder, enable the Enable TCL Command Entry Form option, the Command Entry form will be opened.
– The setting will be saved into novas.rc, and the Command Entry form will be opened automatically next time you invoke Verdi
Execute Tcl in GUI
© Synopsys 2012 13
Use Tcl in Verdi
• Execute the Tcl script in Verdi command line:
– % Verdi –play your_script.tcl &
– All associated Tcl commands will be saved in ./VerdiLog/Verdi.cmd
– Use –play to execute the Verdi.cmd file can reproduce previous steps
• Automatically source the Tcl script
– By setting NOVAS_AUTO_SOURCE environment variable:
– % setenv NOVAS_AUTO_SOURCE your_script.tcl
– % verdi &
– By modifying the novas.rc resource file:
– Search for TclAutoSource tag in [General] section in the novas.rc file
– Specify your Tcl script for the TclAutoSource tag, for example:
[General]
TclAutoSource = MyTclScript.tcl
Execute Tcl in Command Line
© Synopsys 2012 14
Use Tcl in Verdi
• Register a Tk name for Verdi with –tkname
– % Verdi -tkName <Tk name>
• Add an event callback with triggered reason
– Syntax: AddEventCallback TkAppName CallbackFun Reason async
– Check all available Reason in Introduction Tk Command Client Adding Event Callbacks to Your Tk Application section of the Novas Command Language document (tcl.pdf in <Novas_install>/doc directory)
• NOTE: you can also register a callback with a triggered reason after invoking Verdi, for example: – AddEventCallback [tk appname] AutoLoadSignal
wvCreateWindow 1
– To execute the Tcl procedure AutoLoadSignal when a nWave window is created
– tk appname: returns the name of the application, the application name will be “Verdi” if you source the Tcl script after invoking Verdi
Register Event Callbacks
© Synopsys 2012 15
Overview
• Verdi Tcl Introduction
– Use Tcl in Verdi
– Case Study
• VIA Introduction
• Debug Tcl Scripts
• Labs
© Synopsys 2012 16
Case Study – Verdi Tcl
• Script purpose: – This script generates an nWave session file before exiting and loads last session
when nWave is invoked.
– When select Save and Close Win under File menu on nWave , it generates nWave session file named "<FSDBName>.rc" and "AutoSaveSignal.rc" automatically.
– If there is a file named "AutoSaveSignal.rc" when invoking nWave, it is loaded automatically.
• Usage: % setenv NOVAS_AUTO_SOURCE AutoSave.tcl
% verdi ...
• Output file: <FSDBNAME>.rc
AutoSaveSignal.rc
Script Overview
© Synopsys 2012 17
Case Study – Verdi Tcl
proc AutoSaveSignal {} { global ary
if { [file exists "AutoSaveSignal.rc"] } { file rename -force AutoSaveSignal.rc AutoSaveSignal.rc.bak }
set wid [wvGetCurrentWindow] set fname $ary($wid)
if { $fname != "" } { wvSaveSignal -win $wid "$fname.rc" } wvSaveSignal -win $wid "AutoSaveSignal.rc“
wvCloseWindow -win $wid }
Inherit $ary from GetFileName procedure
Check whether the save file already exists, rename if it exists
$fname: get the FSDB name from GetFileName
procedure. Note it uses $ary($wid) to get the
FSDB name in GetFileName procedure
when there are multiple FSDB files
Save signals to FSDB_name.rc file
Save signals to
AutoSaveSignal.rc file
Close current nWave window
The Script
© Synopsys 2012 18
Case Study – Verdi Tcl
proc AutoLoadSignal {p1 p2} {
if { [file exists "AutoSaveSignal.rc"] } { wvRestoreSignal -win $p2 "AutoSaveSignal.rc" }
qwConfig -type nWave -cmds [list\ {qwAction -name "Save" -text "Save and Close Win“ -tcl
{AutoSaveSignal}}\ {qwAddMenuAction -action "Save" -group "File" -before
"Reload"} ]
}
The Script Note: here the p1 and p2 argument will be:
$P1: wvCreateWindow
$P2: 2a97b46aa8 (the window ID)
Restore the AutoSaveSignal.rc file into nWave if the file already exists
Create a “Save and Close Win” command under File menu,
invoking the command will execute the AutoSaveSignal procedure.
© Synopsys 2012 19
Case Study – Verdi Tcl
proc GetFileName {p1 p2} { global ary set lname "" set wid [wvGetCurrentWindow]
set sid [string last / $p2] set lid [string last . $p2]
set lname [string range $p2 [incr sid] [incr lid -1]] # puts "$p1 $p2 $lname"
set ary($wid) $lname }
AddEventCallback [tk appname] AutoLoadSignal wvCreateWindow 1 AddEventCallback [tk appname] GetFileName wvOpenFSDBFile 1
Get the window ID for
current nWave window
$lname: get the string for
fsdb name without “.fsdb”
Note: here the p1 and p2 argument will be:
P1: wvOpenFSDBFile
P2: /verdi/home/allen_shieh/demo/rtl.fsdb
$sid: get the index for last “/” in $p2
$lid: get the index for last “.” in $p2
To store the fsdb name in
$ary array with $wid index
Register callbacks to:
1. Execute procedure AutoLoadSignal when opening nWave window
2. Execute procedure GetFileName when loading FSDB
The Script
© Synopsys 2012 20
Overview
• Verdi Tcl Introduction
– Use Tcl in Verdi
– Case Study
• Debug Tcl Scripts
• Labs
© Synopsys 2012 21
Debug Tcl Scripts
• Set the environment variable CMD_TRACE to 1 for viewing received
commands
% setenv CMD_TRACE 1
% verdi -play demo_traverse.tcl > tcl_log &
% vi tcl_log
The CMD_TRACE Environment Variable
© Synopsys 2012 22
Debug Tcl Scripts
• The TclPro Debugger is not included in Novas package, download
the software and get the instruction from:
http://www.tcl.tk/software/tclpro/
• Set the path for TclPro Debugger, for example:
% set path= ( /tools/TCL/TclPro1.5/linux-ix86/bin $path )
• Invoke Verdi with –prodebug option and load the Tcl script with –
play option:
% verdi -prodebug -play demo_traverse.tcl
Using TclPro Debugger (1/2)
© Synopsys 2012 23
Debug Tcl Scripts
Using TclPro Debugger (2/2)
Click to set
break point
Run until
break or EOF
Run stops
Variable values
Run stops on this line
© Synopsys 2012 24
Reference
• Novas Command Language:
– <Verdi_install>/doc/tcl.pdf
• NPI Models:
– <Verdi_install>/doc/VIA_NPI.pdf
• Useful web sites:
– Tcl Developer Site: http://www.tcl.tk/
– Tcl Tutorials: http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html
– Tcl Commands: http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
– Tk Commands: http://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm
Get Help from Resources