Getting Objects By Name - 2020.2 English

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

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

Most designs are made up of a series of blocks or modules connected in some hierarchical fashion. Whether the design is crafted from the bottom-up, or the top-down, or from the middle out, searching the design hierarchy to locate a specific object is a common task.

Figure 1. Searching the Design Hierarchy

By default, the get_* commands only return objects from the top-level of the design. You can use the current_instance command before using the get_* commands to scope the design object queries to a specific hierarchical instance of the design. To move the scope back to the top-level of the design, you simply have to use the current_instance command with no argument.

As an example, Getting Objects By Name shows a hierarchical design where the modules A and B are instantiated at the top-level. Module A includes the a1 and a2 hierarchical instances, and module B includes the b1 and b2 hierarchical instances. Each of a1, a2, b1, and b2 has leaf cells (unisim instances) inside, as indicated in the figure.

# Set the current instance of the design to module B.
current_instance B 
get_cells * ; # Returns b1 and b2, cells found in the level of the current instance.
get_nets * ; # Returns nets from module B, the current instance.
# Reset the current instance to the top-level of the design.
current_instance 
get_cells * ; # Returns A and B, located at the top-level of the design.

Although the get_* commands only search the top level, or the level of the current instance, you can specify a search pattern that includes a hierarchical instance name relative to the current instance. By default, the current instance is set to the top-level of the design. To query the instance b1 from the top level, you can specify the following name pattern:

get_cells B/b1 ; # Search the top-level for an instance with a hierarchical name.