ScriptingTCL

Practical Exposure to writing TCL with examples

Admin
December 10, 2020
3 min read

Before explaining with the examples, let me clear few things.

⦁ Before going to write the script, first read all the blogs that I have mentioned in the TCL Scripting section. Once you have the problem statement, then understand what your requirement is here and then think how you can get the solution. Now try writing algorithm for the entire bridge between problem statement and solution. Once done with the algorithm, start writing script step by step with the validation over TCL shell or tool that you use.

If you have written one single script then write to me via comment or email. I would be happy to see the change in you. I would be glad to see you learning and writing the TCL Script. If you want to work on advance TCL writing, please let me know, we can further discuss.

⦁ Scripts examples that I am going to mention now can vary from tool to tool as few commands vary when tool is different. Some of the scripts will 100% work on ICC2 and some will work on Innovus w.r.t physical design tools. You can learn to debug the script as this will help you to enhance your debugging skills. Let me know via comment or email if you are looking for any help.

TCL Examples

1. Find out all the nets present in the design having length more than 200 micron.

foreach_in_collection net [get_flat_nets *] {
set dr_len [get_attribute [get_nets $net] dr_length]
if {$dr_len > "300"} {
echo "[get_object_name $net] $dr_len" >> nets_drLength.rpt
}
}

2. Find out the ports present in the design with direction as INPUT.

set OFILE [open ports_in.tcl "w"]
set ports ""

foreach_in_collection port [get_ports * -filter direction==in] {
puts $OFILE [get_object_name [get_ports $port]]
}
close $OFILE

3. Find out the nets present in the design which are data and clock and dump into a file. You may tweak the script according to your need.

set nets *

foreach net $nets {

set net_type [get_attribute [get_nets $net] net_type]
if {$net_type == "clock"} {
echo "[get_object_name $net] $net_type" >> nets_clk.rpt
} else {
echo "[get_object_name $net] $net_type" >> nets_data.rpt
}
}

4. Find out all the flops present in the design with their associated clocks.

set clks [get_object_name [get_clock]]
foreach clk $clks {
all_registers -clock $clk
puts "register count of clock $clk : [sizeof_collection [all_register -clock $clk]]"
}

 

Share the Article