One way to improve runtime is to write code efficiently such that a container is built and a command runs on the entire container versus running the command within a loop on each item that would be part of the container. The following example illustrates this and is similar to that seen in the Creating Custom Design Rules Checks (DRCs) section.
Inefficient code:
foreach bram [get_cells -hier -filter {PRIMITIVE_SUBGROUP == bram}] {
set bwidth [get_property WRITE_WIDTH_B $bram]
if { $bwidth > 36} {
highlight_object -color red [get_cells $bram]
}; # End IF
}; # End FOR
Efficient code:
foreach bram [get_cells -hier -filter {PRIMITIVE_SUBGROUP == bram}] {
set bwidth [get_property WRITE_WIDTH_B $bram]
if { $bwidth > 36} {
lappend bram_list $bram
}; # End IF
}; # End FOR
highlight_object -color red [get_cells $bram_list]
An even more compact and efficient way to code this is to apply the filter as part of the get_cells
command. This removes the need to perform a foreach
loop with individualized checking at the expense of a slightly more complicated filter.
highlight_object -color red [get_cells -hier -filter {PRIMITIVE_SUBGROUP == bram &&
WRITE_WIDTH_B > 36}]