get_property and Sorted Lists - 2022.2 English

Vivado Design Suite User Guide: Using Tcl Scripting (UG894)

Document ID
UG894
Release Date
2022-10-19
Version
2022.2 English

The list of elements (strings or objects) returned by get_property is ordered based on the input list of objects. It also has the same number of elements. This property can be used to iterate with the Tcl command foreach through multiple lists at once.

Inefficient code:

set cells [get_cells -hier -filter {...}]
foreach cell $cells {
  set loc [get_property LOC $cell]
  ...
}

In the code above, the command get_property LOC $cell is executed for each cell inside the collection $cells.

Efficient code:

set cells [get_cells -hier -filter {...}]
foreach cell $cells loc [get_property LOC $cells] {
  ...
}

In the code above, the command get_property LOC $cells is executed only once which improves the runtime significantly when a long list of objects is processed. This is possible because the list returned by get_property has the same number of elements as the Tcl list $cells and the returned elements are in the same order as the input list.