Objects or lists of objects should be cached in Tcl variables so they can be reused later.
For example, if the same list of nets is going to be reused multiple times in the script, it does not make sense to do the same query over and over. Although the Tcl commands in the Vivado tools have been implemented efficiently, every Tcl query goes back and forth between the Tcl interpreter and the lower level C++ code of the application. This C++/Tcl interface consumes runtime that should be avoided when possible.
Use the different filtering capabilities of the Vivado tools as often as
possible. Tools such as effective search pattern definition,
-of_objects
option, the -filter
option, and the
filter
command can reduce run-time. Those features have been
implemented at a very low level in the application, and are very efficient in terms of
runtime and memory.
By caching the results of a general query, a list of objects can be post-processed using the filter
command to create a sub-list of objects. You can also use standard Tcl list commands to parse the results assigned to the Tcl variable without accessing the in-memory design unless necessary.
set allCells [get_cells * -hier]
lsort $allCells ; # Returns a sort ordered list of all cells
filter $allCells {IS_PRIMITIVE} ; # Returns only the primitive cells
filter $allCells {!IS_PRIMITIVE} ; # Returns non-primitive cells