for some reason, I need to rebuild foreach_in_collection (SDC command) as "foreach" in tcl.
here's snapshot code:
proc set_disable_timing { argv } { body ... }
proc get_cells { argv } { body ... }
and here has a proc "foreach_in_collection" I try to build like foreach:
proc foreach_in_collection {item collection script } {
foreach collection $collection_list {
uplevel [list set $item $collection]
uplevel 1 $script
}
}
and my source file include one code like
set all_cells [get_cells -hier my_cell*]
foreach_in_collection cell $all_cells {
set_disable_timing $cell
}
but tcl report invalid command "-hier" how to fix issue
It looks like you want
proc foreach_in_collection {item collection script } {
upvar x $item
foreach x $collection {
uplevel $script
}
}
When x
is set to a value in foreach_in_collection, then cell
is set to the same value in the context where foreach_in_collection is called.
Then when you uplevel $script
, that is invoking set_disable_timing with the correct value.