TCL Inside EDA Tools
Collections and querying the design
Plain TCL is the foundation. Inside a tool like Design Compiler or PrimeTime, the real power is the tool commands that hand you pieces of the design to work on. Those pieces come as collections.
Collections, not lists
When you ask a tool for objects, it returns a collection: a tool-managed group of design objects (cells, pins, ports, clocks). It looks like a list but is handled with its own commands, because a real design can have millions of objects and the tool keeps them efficiently.
# get_* commands return collections of design objects
set ffs [get_cells -hier -filter "is_sequential==true"]
set dpins [get_pins core/data_reg*/D]
set clks [get_clocks]
puts "Flip-flop count: [sizeof_collection $ffs]"Walking a collection
Use foreach_in_collection, not plain foreach, to loop over the objects a tool returns.
foreach_in_collection clk [get_clocks] {
set name [get_attribute $clk name]
set period [get_attribute $clk period]
puts "Clock $name has period $period"
}A small but real example
Put it together: report every clock and flag any with a tight period.
foreach_in_collection clk [get_clocks] {
set name [get_attribute $clk name]
set period [get_attribute $clk period]
if {$period < 2.0} {
puts "FAST clock $name : $period ns"
}
}the pattern is always the same: a get_* command returns a collection, get_attribute reads a property off an object, and foreach_in_collection walks them. Learn those three and you can query any design in any Synopsys-style tool.
do not use ordinary list commands (lindex, llength, foreach) on a collection. Use the collection commands (sizeof_collection, index_collection, foreach_in_collection). Mixing them up is the most common scripting error for newcomers to EDA TCL.