© Synopsys 2012 1
Verdi3 NPI Training FSDB Model
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
• FSDB Model Introduction
• NPI Commands
• Case Study
© Synopsys 2012 4
Overview
• FSDB Model Introduction
• NPI Commands
• Case Study
© Synopsys 2012 5
FSDB Model Introduction
• The NPI FSDB model lets users read the FSDB file with a set of
convenient Tcl commands or C APIs
– Users can get signal values in the FSDB with this model
– Database accessing performance and programming usability are both
considered in this model
What is FSDB Model?
© Synopsys 2012 6
FSDB Model Introduction General Flow of Using FSDB Model
Open an FSDB file
Get signal handles
Create vct handles
Traverse vc
Close the FSDB file
npi_fsdb_open npi_fsdb_iter_top_scope
npi_fsdb_parent_scope
npi_fsdb_iter_child_scope
npi_fsdb_iter_sig
npi_fdsb_sig_scope
npi_fsdb_iter_member
npi_fsdb_parent_sig
npi_fsdb_sig_by_name
npi_fsdb_scope_by_name npi_fsdb_create_vct
npi_fsdb_goto_time
npi_fsdb_goto_first
npi_fsdb_goto_next
npi_fsdb_goto_prev
npi_fsdb_vct_time
npi_fsdb_value
npi_fsdb_close
© Synopsys 2012 7
Overview
• FSDB Model Introduction
• NPI Commands
• Case Study
© Synopsys 2012 8
NPI Commands
• npi_fsdb_open –name fsdb_file_name
– Open an FSDB file and return the FSDB file handle to the caller
• npi_fsdb_close –file fsdb_file_handle
– Close an FSDB file, perform the necessary clean up jobs, and then free
memory
• Example:
”demo.fsdb“file_nameset%
% set file_hdl [npi_fsdb_open –name $file_name]
% npi_fsdb_close –file $file_hdl
Open and Close FSDB Files
© Synopsys 2012 9
NPI Commands
• npi_fsdb_scope_by_name –file fsdb_file_hdl –name scope_name
–scope scope_handle
– Get a scope handle with the specified name
• npi_fsdb_parent_scope –scope scope_handle
– Get the parent scope of the target scope
• npi_fsdb_sig_scope –sig signal_handle
– Get the scope handle for the corresponding scope that contains this
signal
Get Scopes from FSDB (1/2)
© Synopsys 2012 10
NPI Commands
• Example:
% set file_hdl [npi_fsdb_open –name”rtl.fsdb”]
% set scope [npi_fsdb_scope_by_name -file $file_hdl -name "system.i_cpu.i_ALUB" -scope ""]
% set scope_name [npi_fsdb_scope_property_str -scope $scope -type npiFsdbScopeName]
% set signal [npi_fsdb_sig_by_name -file $file_hdl -name "carry" -scope $scope]
% set sig_scope [npi_fsdb_sig_scope -sig $signal]
% set parent_scope_hdl [npi_fsdb_parent_scope –scope $sig_scope]
Get Scopes from FSDB (2/2)
Get the FSDB file handle
Get the scope handle: system.i_cpu.i_ALUB
Get the scope name: i_ALUB
Get the signal: system.i_cpu.i_ALUB.carry
Get the scope handle that the signal (carry) belongs to; the scope is i_ALUB
Get the parent scope: i_cpu
© Synopsys 2012 11
NPI Commands
• npi_fsdb_iter_top_scope –file fsdb_file_hdl
– Get an iterator for the top scopes
• npi_fsdb_iter_child_scope –scope scope_handle
– Get an iterator for the child scopes
• npi_fsdb_iter_scope_next –iter scope_iterator
– Get the next scope handle of the iterator
• npi_fsdb_iter_scope_stop –iter scope_iterator
– Free the scope iterator
Iterate Scopes (1/2)
© Synopsys 2012 12
NPI Commands
• Example:
% set file_hdl [npi_fsdb_open –name”rtl.fsdb”]
% set top_scope_itr [npi_fsdb_iter_top_scope -file $file_hdl]
% set top_scope_hdl [npi_fsdb_iter_scope_next -iter $top_scope_itr]
% set top_scope_name [npi_fsdb_scope_property_str -scope $top_scope_hdl -
type npiFsdbScopeName]
% set child_scope_itr [npi_fsdb_iter_child_scope -scope $top_scope_hdl]
% set child_scope_hdl [npi_fsdb_iter_scope_next -iter $child_scope_itr]
% set child_scope_name [npi_fsdb_scope_property_str -scope $child_scope_hdl -type npiFsdbScopeName]
% npi_fsdb_iter_scope_stop -iter $child_scope_itr
Iterate Scopes (2/2)
Create the iterator
for top scopes
Iterate $top_scope_itr to get the scope handle: system
Get the scope name: system
Create the iterator for child scopes under system
Iterate $child_scope_itr to get the scope handle: i_cpu
Get the scope name: i_cpu
Close the iterator
$child_scope_itr
© Synopsys 2012 13
NPI Commands
• npi_fsdb_sig_by_name –file $file_hdl –name signal_name
–scope scope_handle
– Get a signal handle with the specified name
• npi_fsdb_parent_parent –sig signal_handle
– Get the parent signal of the target signal
– For example, signal data[0]’sparentisdata (data[7:0])
• Example:
% set ALU_0 [npi_fsdb_sig_by_name -file $file_hdl -name {ALU[0]} -
scope $sig_scope]
% set ALU_parent [npi_fsdb_parent_sig -sig $ALU_0]
Get Signals
Get the handle for signal ALU[0]
Get the handle for parent signal ALU
© Synopsys 2012 14
NPI Commands
• npi_fsdb_iter_sig –scope scope_handle
– Get an iterator of signals declared inside the scope
• npi_fsdb_iter_member –sig signal_handle
– Get an iterator of signal members
– NOTE: only struct, union, and array types can be iterated
• npi_fsdb_iter_sig_next –iter signal_iterator
– Get the next signal handle of the iterator
• npi_fsdb_iter_sig_stop –iter signal_iterator
– Free the signal iterator
Iterate Signals
© Synopsys 2012 15
NPI Commands
set file_hdl [npi_fsdb_open -name "sv.fsdb"]
set ALUB_scope [npi_fsdb_scope_by_name -file $file_hdl -name "system.i_cpu.i_ALUB" -scope ""]
set sig_itr [npi_fsdb_iter_sig -scope $ALUB_scope]
while { [set sig_hdl [npi_fsdb_iter_sig_next -iter $sig_itr]] != ""} {
set sig_name [npi_fsdb_sig_property_str -sig $sig_hdl -type npiFsdbSigName]
puts "sig: $sig_name“
if {[npi_fsdb_sig_property -sig $sig_hdl -type npiFsdbSigHasMember] == 1} {
puts "$sig_name has member"
set member_itr [npi_fsdb_iter_member -sig $sig_hdl]
while { [set member_hdl [npi_fsdb_iter_sig_next -iter $member_itr]] != ""} {
set member_name [npi_fsdb_sig_property_str -sig $member_hdl -type npiFsdbSigName]
puts "$sig_name 's member is $member_name"
}
}
}
Iterate Signals - Example
Iterate all signals under ALUB
scope and output signal name
If the signal has members, iterate members
and output member signal names
sig: IR
sig: IDB
sig: PC
sig: CH
sig: alu_mode
…
sig: T3
sig: alu_operand
alu_operand has member
alu_operand 's member is alu_operand.a
alu_operand 's member is alu_operand.b
alu_operand 's member is alu_operand.cin
The result in console
© Synopsys 2012 16
NPI Commands
• npi_fsdb_min_time –file file_handle
– Get the minimum simulation time of the FSDB file
• npi_fsdb_max_time –file file_handle
– Get the maximum simulation time of the FSDB file
• npi_fsdb_file_property_str –type file_property –file file_handle
– Get the string property value of a file object
• npi_fsdb_scope_property_str –type scope_property –scope
scope_handle
– Get the string property value of a scope object
Get Properties (1/2)
© Synopsys 2012 17
NPI Commands
• npi_fsdb_sig_property –type signal_property –sig signal_handle
– Get the boolean/integer property value of a signal object
• npi_fsdb_sig_property_str –type signal_property –sig
signal_handle
– Get the string property value of a signal object
• NOTE: find available file_property, scope_property, and
signal_property arguments for the –type option in the FSDB Model
Traverse Model chapter of the VIA Command Reference Manual
Get Properties (2/2)
© Synopsys 2012 18
NPI Commands Get Properties - Example
-> name
str: npiFsdbSigName
-> fullName
str: npiFsdbSigFullName
-> isReal
bool: npiFsdbSigIsReal
-> hasMember
bool: npiFsdbSigHasMember
-> leftRange
int: npiFsdbSigLeftRange
-> rightRange
int: npiFsdbSigRightRange
-> rangeSize
int: npiFsdbSigRangeSize
npi_fsdb_sig_scope()
npi_fsdb_iter_member()
npi_fsdb_iter_sig()
npiFsdbSigHandle npiFsdbSigHandle
npiFsdbScopeHandle
npi_fsdb_parent_sig()
• % set file_hdl [npi_fsdb_open -name“rtl.fsdb"]
• % set sig_hdl [npi_fsdb_sig_by_name -file $file_hdl -name system.i_cpu.ALU -scope””]
• % set sig_name [npi_fsdb_sig_property_str -type npiFsdbSigFullName -sig $sig_hdl]
• % set sig_size [npi_fsdb_sig_property -type npiFsdbSigRangeSize -sig $sig_hdl]
Get the signal full name: system.i_cpu.ALU
Get the signal range: 8
© Synopsys 2012 19
NPI Commands
• What is vct (Value Change Time)? – You can treat it as the cursor time in nWave
• npi_fsdb_create_vct –sig signal_handle – Create a vct handle for a specific signal
– NOTE: A signal can have more than one vct handle at the same time
• npi_fsdb_goto_time –vct vct_handle –time time – Change the index of the vct handle to the last vc at the specified time
• npi_fsdb_goto_first –vct vct_handle – Move the index of the vct handle to the first value change if possible
• npi_fsdb_goto_next –vct vct_handle – Increase the index of the vct handle if possible
• npi_fsdb_goto_prev –vct vct_handle – Decrease the index of the vct handle if possible
Create vct Handles and Get Values (1/2)
© Synopsys 2012 20
NPI Commands
• npi_fsdb_vct_time –vct vct_handle
– Get the current time of the vct handle
• npi_fsdb_release_vct –vct vct_handle
– Free the vct object
• npi_fsdb_unload_vc –file file_handle
– Unload value changes from memory that are already loaded
– NOTE: A value change will be unloaded from memory if all traverse
handles related to it are released (by npi_fsdb_release_vct)
Create vct Handles and Get Values (2/2)
© Synopsys 2012 21
NPI Commands
% set file_hdl [npi_fsdb_open -name“rtl.fsdb”]
% set sig_hdl [npi_fsdb_sig_by_name -file $file_hdl -name system.i_cpu.ALU -scope””]
% set vct_hdl [npi_fsdb_create_vct –sig $sig_hdl]
% npi_fsdb_goto_time –vct $vct_hdl –time 500
% set value [npi_fsdb_vct_value -vct $vct_hdl -format npiFsdbDecStrVal]
% npi_fsdb_goto_next -vct $vct_hdl
% set value [npi_fsdb_vct_value -vct $vct_hdl -format npiFsdbDecStrVal]
Create vct Handles and Get Values - Example
Change time to 500,
get the value 2
Change to next value change,
get the value 0
Create the
vct handle
© Synopsys 2012 22
Overview
• FSDB Model Introduction
• NPI Commands
• Case Study
© Synopsys 2012 23
Case Study
• Requirement:
– Traverse a given signal, and list all value changes with time and value
• Execute the script:
% verdi –play list_value.tcl &
– See following two slides for the content of list_value.tcl file
– The results should be:
Overview
Time = 0, value = xxxxxxxx
Time = 25, value = 00000000
Time = 350, value = xxxxxxxx
Time = 400, value = 00000100
Time = 500, value = 00110100
Time = 800, value = 01010101
Time = 1100, value = 00101000
Time = 1200, value = 00100000
Time = 1550, value = 01010101
…
© Synopsys 2012 24
Case Study
set file_name “rtl.fsdb"
set sig_name “system.i_cpu.data"
set file_hdl [npi_fsdb_open -name $file_name]
if { $file_hdl != "" } {
set min_time [npi_fsdb_min_time -file $file_hdl] set max_time [npi_fsdb_max_time -file $file_hdl]
set scale_unit [npi_fsdb_file_property_str -file $file_hdl -type npiFsdbFileScaleUnit]
puts "Time range: $min_time ~ $max_time"
puts "Scale unit: $scale_unit"
set sig_hdl [npi_fsdb_sig_by_name -file $file_hdl -name $sig_name -scope ""]
if { $sig_hdl != "" } {
set vct_hdl [npi_fsdb_create_vct -sig $sig_hdl]
Script (1/2)
Specify the FSDB file and signal name
Open the FSDB file,
get information for
min/max time and time unit
Get signal handle by the given signal name
Create a vct handle (the cursor time handle)
© Synopsys 2012 25
Case Study
npi_fsdb_goto_first -vct $vct_hdl
set vct_time [npi_fsdb_vct_time -vct $vct_hdl]
set vct_val [npi_fsdb_vct_value -vct $vct_hdl -format npiFsdbBinStrVal]
puts "Time = $vct_time, value = $vct_val"
while { [npi_fsdb_goto_next -vct $vct_hdl] != 0 } {
set vct_time [npi_fsdb_vct_time -vct $vct_hdl]
set vct_val [npi_fsdb_vct_value -vct $vct_hdl -format npiFsdbBinStrVal]
puts "Time = $vct_time, value = $vct_val"
}
}
npi_fsdb_close -file $file_hdl
}
Script (2/2) Go to the first value change,
and print out time and value
Traverse value changes to the last one;
print out time and value for each change
Close the FSDB file