Professional Documents
Culture Documents
July - 2018
Course Objectives
4
Why bother TCL in Tempus / Innovus?
❑ Tempus and Innovus command interface (shell) speaks, listens and understands TCL
❑ The nature of command syntax (including Tempus commands)
❑ TCL provides the necessary programing constructs for scripting in Tempus and Innovus
❑ TCL helps code designer context to get more specific results from Tempus and Innovus
commands
NOTE: Tempus output used as example references. However this applies equally for Innovus.
Save TCL commands in a file and source it in Tempus shell or nest inside another
tempus prompt > source design_info.tcl
# This is a comment
cmd1 arg arg arg ...
cmd2 arg arg arg ... # This is a bad comment - Error
cmd3 arg arg arg ...; # This is a good comment
◆ Wildcard support : Asterisk (*) and question mark (?) for pattern matching on objects such as
variables and strings
Asterisk (*) – match any sequence of characters in an object names
Question mark (?) – match any single character in object names
❑ Each occurrence of [<command>] is replaced with the value returned from the last command
executed in <commands>
◆ Except where [] are escaped (\[ and \])
◆ Command name and arguments case sensitive (clk and CLK are different names)
set b 8 8
set a [expr $b+2] 10
puts “Delay: [set a] ns” Delay: 10 ns
❑Arrays
❑ Each element is a variable with name/value pair
❑Collection
❑ Tempus data type to group design elements such as ports, nets, instances, pins, clocks, timing
paths, timing arcs, registers etc.
Command Description
Command Description
join Joins list elements into a string
lappend Appends elements to a list
lsearch Searches for a match in a list for a regular expression
bits 7 6 5 4 3 2 1 0
0000 0111 (7)
Tempus 1> set a 0x07 AND 0000 0100 (4) Read bit 2
0x07 0000 0100 (4)
Tempus 2> expr $a & 0x04
4 0000 0111 (7)
OR 0000 1000 (8) Set bit 3 to 1
Tempus 3> set a [expr $a | 0x08]
15 0000 1111 (15)
Tempus 4> set a_neg [expr ~$a + 1] INV 0000 1111 (15) Change the sign (2
-15 1111 0000 (-16) 's complement)
+ 0000 0001 (1)
1111 0001 (-15) NB: Equivalent to
set a_neg -$a
5 is Odd
Use glob command to generate list of filenames matching one or more patterns
glob pattern1 pattern2 pattern3 ...
tempus 1> set timing_libs [glob *.lib]
slow.lib fast.lib tsmc_40.lib …
Use cd and pwd commands to change directory and name of current working directory respectively
© 2019 Cadence Design Systems, Inc. All rights reserved. 27
TCL – Basic file commands
Use open command to open a file and get a handle to it
access_mode
r : READ_ONLY r+ : READ+WRITE
w : WRITE_ONLY w+ : READ+WRITE
a : APPEND_TO_FILE a+ : READ+APPEND_TO_FILE
Returns a file ID string to identify the file for further interaction with it
Use close command to cease interaction with the file
close $file_id
Example:
set fid [open “test.sdc” w+]
# write something to it and/or read from it
close $fid
© 2019 Cadence Design Systems, Inc. All rights reserved. 28
TCL – reading from / writing to a file
Use puts command to write data into a file
puts $file_handle var
D Q
A
u1
B Y
CK
Clock Port Net Cell Pin Cell Net Pin Net Port
Internal database consists of several classes of objects such as ports, cells, nets, pins, clocks
© 2019 Cadence Design Systems, Inc. All rights reserved. 33
Collection – The object container
Makes a group of objects available to Tcl interface for database access
❑ Homogenous collection contains only one type of objects
Homogeneous
Index 0 1 2 3 4 5 6 7 8
Heterogeneous
Index end-8 end-7 end-6 end-5 end-4 end-3 end-2 end-1 end
© 2019 Cadence Design Systems, Inc. All rights reserved. 34
Tempus/Innovus Object Class Catalogue
Object Class Description Command(s) to create object collection
get_object_name collection
❑ Returns TCL list of strings holding object names in a collection
❑ The output can be saved in a variable or used implicitly with nested commands
tempus 1> query_objects [get_ports in*]
in0 in1 in2 in3 in4
tempus 2> get_object_name [get_ports scan_*]
scan_in scan_out scan_mode
© 2019 Cadence Design Systems, Inc. All rights reserved. 36
Counting objects in a collection
size_of_collection collection
❑ Returns the number of objects in a collection
❑ Returns 0 for empty collection (empty string)
❑ More efficient that manually iteration and counting of elements
❑ Creates a new collection from base collection by removing reference elements specified as Tcl list
/ one of the Tempus collections
❑ -intersect generates intersection of base collection elements with second collection of objects
or list
❑ Creates a new collection including only those objects from base_collection that match the
expression specified by filter_expression or an empty collection in case of no match
❑ get_* commands that provide a –filter option filters out before including in the collection, so
more efficient
❑ -nocase can be used only with –regexp
defined(property-name)
:Returns 1 if the property is defined for the objects
❑ With –regexp option =~ and !~ you can use any kind of Tcl regular expressions
Property Value Data type Property Value Data type Property Value Data type
object_type
pin
port
cell
net
clock
lib_cell
lib_pin
design
lib
timing_path
timing_point
timing_arc
path_group
lib_timing_arc
si_victim
si_attacker
pg_pin
pg_net
© 2019 Cadence Design Systems, Inc. All rights reserved. 50
Report the property value pair of a Design Object
report_property [-property_list <property list>] \
{<collection> | <list_of_collections>}
% proc average { n1 n2 n3 n4 } {
Without return set sum [expr {($n1+$n2+$n3+$n4)/4.0}]
Variables n1, n2, n3, n4
the procedure returns return $sum and sum are available only
the value returned by
the last executed } INSIDE the procedure, i.e.,
they are local variables
command
Make the array a global variable and access inside the procedure
Use array set to convert a Tcl list into an array
Use array get to extract values from the array
define_proc_arguments plot_waveform \
–info “plot graphically the waveforms as reported by report_delay_calculation” \
-define_args {\
{-file "" "" string required} \
{-gnuplot_file "" "" string optional} \
{-gnuplot_cmd_file "" "" string optional} }