You are on page 1of 4

The basics of using the Advanced Timing Tcl Scripting Commands

Problem
This article explains the basics of using the Advanced Timing Tcl Scripting Commands. These commands can be used in combination with each other to report and query database
objects based on specified criteria.

Solution
This article describes the Advanced Timing Tcl Scripting Commands. What these commands are used for is explained with simple examples, for each category of similar commands. For
specifics on syntax, refer to the Advanced Timing Tcl Scripting Commands chapter in the Encounter/Innovus/Tempus Text Command Reference.

This article focuses on the usage of the following command types under this category:

all_* commands
get_* commands
Property commands
Collection commands

all_* commands
The all_* commands return a collection of all the items of a specific type. Several of the commands (marked with a (f)) provide options to filter the collection based on certain
properties:

all_connected all_fanin all_outputs (f) all_fanout


all_inputs (f) all_instances all_registers (f)

Examples of using the all_* commands:

Set all the clocks to propagated mode


set_propagated_clock [all_clocks]

Report the worst timing path that begins at a register and ends at an output port
report_timing -from [all_registers] -to [all_outputs]

Store a collection of pins that fanout from a specific port


set clk1Fanout [all_fanout -from clk1 -pin_levels 1]

get_* commands
The get_* commands return a collection of items filtered by name pattern or object type. Additionally, you can use the -filter option for most of the get_* commands to filter the
collection by property value. For more information, see the description of the get_property command in the EDI System Text Command Reference.

The filter_expression for the -filter option can be created by combining several object properties using the following relational and logical
operators: >, <, ==, !=, <=, >=, &&, ||, =~, !~, AND and OR. You also can use parentheses to create expressions.

get_arcs get_cells get_clocks get_designs


get_generated_clocks get_lib_arcs get_lib_cell get_lib_pins
get_ports get_pins get_path_groups get_libs
get_nets get_object_name

Examples of using the get_* commands:

Return a collection of all the input ports (same as running [all_inputs])


get_ports -filter "direction==in"

Return a collection of pins that match */D


get_pins -hier -filter "hierarchical_name =~ */D"

Return a collection of the libraries a cell belongs to


get_lib_cells INVXL

Property commands
The list_property command lists the properties for the different object types. When the list_property command is run without arguments, it lists all the properties for all object
types.

Use the -type option to list properties for a specific object type. Legal option types
are: cell, clock, design, lib, lib_cell, lib_pin, lib_timing_arc, net, path_group, pin, port, timing_arc, timing_path and timing_point. Here is an example:

encounter> list_property -type lib_timing_arc


object_type : lib_timing_arc
=================================================
property | return_type
-------------------------------------------------

from_lib_pin | collection
mode | string
object_type | string
sdf_cond | string
timing_type | string
to_lib_pin | collection
when | string

The get_property command returns the value of the specified property. For a list of all the properties, see the description of the get_property command in the EDI System Text
Command Reference.

Usage:

get_property var_name property [-clock clock_name] [-view view_name]


Example: Report the clock period of clk1

get_property [get_clocks clk1] period

Another example: User can obtain clock net name using get_property command.

In this command clk01 is the sdc clock defined in timing constraint file. User can find the corresponding clock net.

get_object_name [index_collection [get_nets -of [get_property [get_clocks clk01] sources]] 0]

Note: The report_property command returns the properties and their values for a specified object.

Example: Report the properties for clock clk1

report_property [get_clocks clk1]

For timing-related properties such as properties for timing arcs, paths and points, run report_timing -collection. This returns the results in a collection of timing paths.

Example:

Report the timing and store the top 10 paths as a collection in the variable $paths
set paths [report_timing -collection -max_paths 10]

Filter $paths to include only those paths with slack between -0.806ns and 0ns
set newPaths [filter_collection $paths {(slack > -0.806 && slack < 0.0)}]

Collection commands
Lastly, once you have the collection defined, you can manipulate, filter, cycle through and query it using the collection-related commands:

add_to_collection append_to_collection compare_collections copy_collection


filter_collection foreach_in_collection index_collection query_objects
remove_from_collection sizeof_collection sort_collection

Examples:

List the contents of a collection


query_objects $collectionName

Cycle through the items of a collection


foreach_in_collection iCell [get_cells *] {
Puts "Cell = [get_property $iCell hierarchical_name]"
}

By default, Advanced Timing Tcl commands like get_cells that display the collection objects, list only the first 100 objects in a collection. This default behavior cab be changed by using
the timing_collection_result_display_limit global. When set to an integer value, all the commands such as, get_cells, add_to_collection, query_objects, and so
on, which display the collection objects in the output report will be impacted. (Default value is 100).

To display all the elements in the collection, set this global to "-1".

set_global timing_collection_result_display_limit -1

Examples of sample scripts using the commands discussed earlier:


Example #1: Script to report of the endpoints and startpoints slack of top 1000 failing paths

set rpt [report_timing -max_paths 1000 -max_slack 0 -collection]


foreach_in_collection r $rpt { puts "Endpoint: [get_property [get_property $r capturing_point] hierarchical_name] \t Startpoint:
[get_property [get_property $r launching_point] hierarchical_name] \t Slack: [get_property $r slack]" }

Output:
Endpoint: tdigit[7] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_7/CK Slack: -0.727
Endpoint: tdigit_flag Startpoint: DTMF_INST/DIGIT_REG_INST/flag_out_reg/CK Slack: -0.495
Endpoint: tdigit[6] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_6/CK Slack: -0.488
Endpoint: tdigit[5] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_5/CK Slack: -0.409
Endpoint: tdigit[4] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_4/CK Slack: -0.353
Endpoint: tdigit[0] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_0/CK Slack: -0.266
Endpoint: tdigit[3] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_3/CK Slack: -0.218
Endpoint: tdigit[1] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_1/CK Slack: -0.189
Endpoint: tdigit[2] Startpoint: DTMF_INST/DIGIT_REG_INST/digit_out_reg_2/CK Slack: -0.184

Example #2: To get a list of the register sinks for a clock

redirect clock_sink.rpt {
foreach_in_collection ck [all_clocks] {
puts "Clock_Name No_of_register_sinks Sink_list"
puts "#####################################"
puts "[get_object_name $ck] [sizeof_collection [all_registers -clock $ck]] [get_object_name [all_registers -clock $ck]]\n"
}
}

Output:
Clock_Name No_of_register_sinks Sink_list
#####################################
m_spi_clk 23 SPI_INST/spare_200 SPI_INST/spare_201 SPI_INST/spare_202 SPI_INST/spare_203 SPI_INST/spare_204 SPI_INST/spare_205 SPI_

Example #3: To return all the instance pins that are used in the path

set paths [report_timing -collection]


foreach_in_collection path $paths {
Puts ""
set timingPoints [get_property $path timing_points]
foreach_in_collection point $timingPoints {
set pinPtr [get_property $point pin]
set pin [get_object_name $pinPtr]
Puts $pin
}
}

Output:
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/Q
TDSP_CORE_INST/EXECUTE_INST/FE_PSC541_sel_op_a_2_/A
TDSP_CORE_INST/EXECUTE_INST/FE_PSC541_sel_op_a_2_/Z
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/Fn0090D/A
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/Fn0090D/ZN
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/FE_RC_1304_0/A3
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/FE_RC_1304_0/ZN
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/FE_OCPC334_n_2/A
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/FE_OCPC334_n_2/Z
TDSP_CORE_INST/EXECUTE_INST/FE_PSC520_n_650/A
TDSP_CORE_INST/EXECUTE_INST/FE_PSC520_n_650/Z
TDSP_CORE_INST/EXECUTE_INST/n0439D/A
TDSP_CORE_INST/EXECUTE_INST/n0439D/ZN
TDSP_CORE_INST/EXECUTE_INST/p_reg[27]/D

Example #4: Script to report slack and difference between clock arrival time at launch and capture clocks

set a [report_timing -max_paths 4 -collection]


puts ""
puts " Reporting Slack and Skew between paths"
puts ""
puts "\t StartPoint \t\t\t EndPoint \t\t\t Slack \t\t\t Skew"
puts ""

foreach_in_collection i $a {
set StartPoint [get_object_name [get_property $i launching_point]]
set EndPoint [get_object_name [get_property $i capturing_point]]
set l1 [get_property $i launching_clock_latency]
set l2 [get_property $i launching_clock_open_edge_time]
set launchClockTime [expr $l1 + $l2]
set c1 [get_property $i capturing_clock_latency]
set c2 [get_property $i capturing_clock_close_edge_time]
set captureClockTime [expr $c1 + $c2]
set Slack [get_property $i slack]
set Skew [expr $captureClockTime - $launchClockTime]
puts "$StartPoint \t $EndPoint \t $Slack \t $Skew"
}

Output:
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[27]/D -843.802 -0.015
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[30]/D -762.004 -0.015
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[24]/D -684.326 -0.015
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[26]/D -680.548 -0.015

Example #5: Script to report logics between reg-to-reg. This script can be modified for different path groups:

group_path -from [all_registers] -to [all_registers] -name GRP


set a [report_timing -path_group GRP -max_paths 100 -collection]
foreach_in_collection i $a {
set StartPoint [get_object_name [get_property $i launching_point]]
set EndPoint [get_object_name [get_property $i capturing_point]]
set points [get_property $i timing_points]
puts ""
puts "Timing points between $StartPoint and $EndPoint"
puts ""
foreach_in_collection j $points {
set p [get_object_name [get_property $j pin]]
puts $p
}
}

Output:
Timing points between TDSP_CORE_INST/EXECUTE_INST/arp_reg/CP and
RAM_256x16_TEST_INST/RAM_256x16_INST/A[6]TDSP_CORE_INST/EXECUTE_INST/arp_reg/CP

TDSP_CORE_INST/EXECUTE_INST/arp_reg/Q
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/p1929A/S
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/p1929A/Z
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/p1927A/A1
TDSP_CORE_INST/TDSP_CORE_GLUE_INST/p1927A/ZN
DATA_SAMPLE_MUX_INST/p1989A/I1
DATA_SAMPLE_MUX_INST/p1989A/Z
RAM_256x16_TEST_INST/RAM_256x16_INST/A[6]

Example #6: Script to get the intermediate logic between fanout cone of one instance to fanin cone of another instance :

proc intersect_fanin_fanout {x y} {
if {[get_ports -quiet $x] != ""} {
set X [all_fanout -from [get_ports $x]]
} else {
set X [all_fanout -from [get_pins $x]]
}
if {[get_ports -quiet $y] != ""} {
set Y [all_fanin -to [get_ports $y]]
} else {
set Y [all_fanin -to [get_pins $y]]
}
set result [remove_from_collection -intersect $X $Y]
return $result
}

Output:
> intersect_fanin_fanout a1/A b3/Y
a1/A a1/Y a3/A a3/Y b1/B b1/Y b3/A b3/Y
0x2b1

Example #7: Script to find the number of logic levels (combinational) in a timing path or group of timing paths

proc num_of_logicLevel {max_paths} {


set a [report_timing -max_paths $max_paths -collection]
puts "Start Point \t\t\t End Point \t\t\t Instance Count"
foreach_in_collection i $a {
set StartPoint [get_object_name [get_property $i launching_point]]
set EndPoint [get_object_name [get_property $i capturing_point]]
set Size [sizeof_collection [get_property $i timing_points]]
set InstCount [expr $Size/2]
puts "$StartPoint \t $EndPoint \t $InstCount"
}
}

Output:

> num_of_logicLevel 3
Start Point End Point Instance Count
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[27]/D 58
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[30]/D 58
TDSP_CORE_INST/EXECUTE_INST/sel_op_a_reg[2]/CK TDSP_CORE_INST/EXECUTE_INST/p_reg[24]/D 54

Example #8: Script to report worst slack for all clock group

set_global timing_report_group_based_mode true


foreach_in_collection path [sort_collection [report_timing -max_slack 1000000 -collection] path_group] {
set size [sizeof_collection $path]
set path_group [get_property -quiet $path path_group_name]
set wns [get_property -quiet $path slack]
set view [get_property -quiet $path view_name]
puts "Clock group: $path_group View: $view WNS: $wns"
}

Output:
Clock group: ck View: dtmf_view_setup WNS: 4.182
Clock group: gclk View: dtmf_view_setup WNS: 4.746
Clock group: ck View: dtmf_view_hold WNS: 4.588
Clock group: gclk View: dtmf_view_hold WNS: 4.885

Example #9: Script to get the specified pin from all the nets directly connected to an instance

This gets all the nets connected a specified instance, and subsequently filter out if the specified pin is connected to any of these nets.

set inst instName


set pin pinName
get_pins -of_objects [get_nets -of_objects $inst] -leaf -filter "(ref_lib_pin_name==$pin)"

For example: If you set instName as "Inst1" and pinName as "SI", then this returns following.

inst1/SI inst2/SI

This suggests that from all the nets connected with "Inst1", there are 2 pins as "SI" pin.

Example #10: Script to report cell delays above/below a specified value

Use below script to get cell delays above 0.1 value. You can change the value based on your requirement. You can replace ">" with "<" if you need to report cell delay below a
specific value.

foreach_in_collection timing_path [report_timing -collection -max_paths 10000 -max_slack 10] {


foreach_in_collection tp [get_property $timing_path timing_points] {
set delay [get_property $tp delay]
if {$delay > 0.1} {
Puts "[get_property $tp hierarchical_name] [get_property $tp delay]"
}
}
}

Output:

FF2/Q 1.958
FF1/Q 2.019

Refer to the Usage of collections in Innovus & Tempus, version 15.1 and above RAK to understand the collection usage in Tempus and Innovus.

Return to the top of the page

You might also like