Getting Objects by Relationship - 2020.2 English

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

Document ID
UG894
Release Date
2021-03-30
Version
2020.2 English

There are times when you will need to find objects that are related to other objects in the design. For instance, selecting all of the nets connected to the pins of a specific cell, or all of the cells connected to a specific net. The Vivado Design Suite provides the ability to traverse the elements of the design through their various relationships to one another. This is accomplished through the use of the -of_objects option supported by many of the get_* commands. Getting Objects by Relationship illustrates the relationship of objects in the in-memory design.

Figure 1. Vivado Design Suite Object Relationships

Note: This image is intended to be representative, and is not a complete map of all objects and relationships in the Vivado Design Suite database.

The Help message for each of the get_* commands that supports the -of_objects option lists the related objects that can be traversed:

get_cells -of_objects {pins, timing paths, nets, bels or sites}
get_clocks -of_objects {nets, ports, or pins}
get_nets -of_objects {pins, ports, cells, timing paths or clocks}
get_pins -of_objects {cells, nets, bel pins, timing paths or clocks}
get_ports -of_objects {nets, instances, sites, clocks, timing paths, io standards, io 
banks, package pins}

With the -of_objects option, getting the list of all pin objects attached to a list of net objects becomes very simple:

get_pins -of_objects [get_nets -hier]

To only get the list of drivers for those nets you just need to use the -filter option:

get_pins -of [get_nets -hier] -filter {DIRECTION == OUT}
Note: If an empty list of objects is passed through -of_objects, then the get_* command returns an empty Tcl list.

You can also get the list of pins from a list of cells, or a list of cells from a list of nets and so on.

Figure 2. Traversing Objects by Relationship

Using Getting Objects by Relationship as an illustration, the following example gets the clock pin from instance a1, then works its way outward and upward through the hierarchy. It gets the net connected to that pin, and gets the pins connected to that net, then gets the nets connected to those pins, and finally gets the pins connected to those nets.

get_pins -of [get_nets -of [get_pins -of [get_nets -of [get_pins A/a1/clk]]]]
A/a2/clk A/clk A/a1/clk B/clk

Notice that the last get_pins command returns the clock pin of hierarchical module B, B/clk, along with the other pins that have already been returned. However, to cross the hierarchy, and return the primitive pins on the clock net object, you can use the -leaf option of the get_pins command. The following example shows what is returned when -leaf is used:

get_pins -leaf -of [get_nets -of [get_pins -of [get_nets -of [get_pins A/a1/clk]]]]
B/b1/data_reg/C A/a2/data_reg/C A/a1/data_reg/C B/b2/data_reg/C