current_instance - 2024.1 English

Vivado Design Suite Tcl Command Reference Guide (UG835)

Document ID
UG835
Release Date
2024-05-30
Version
2024.1 English

Set or get the current instance

Syntax

current_instance [‑quiet] [‑verbose] [<instance>]

Returns

Instance name

Usage

Name Description
[-quiet] Ignore command errors
[-verbose] Suspend message limits during command execution
[<instance>] Name of instance

Categories

SDC, XDC

Description

Set the current instance in the design hierarchy to the specified instance cell or to the top of the current design. By default, current_instance points to the top module of the current_design, which is not an instantiated cell object. You can also set current_instance to reference an instantiated hierarchical cell in the design.

Important: Since the top module is not an instantiated object, current_instance returns an empty string rather than a design object, when set to the top-level of the current design.

The current design and current instance are the target of most of the commands and design changes you will make. The current design can be defined using the current_design command.

You must specify the <instance> name relative to the currently defined instance, and use the established hierarchy separator to define instance paths. You can determine the current hierarchy separator with the get_hierarchy_separator command.

Use '..' to traverse up the hierarchical instance path when specifying the current instance.

This command returns the name of the design object of the current_instance, or returns nothing when set to the top of current design.

Arguments

-quiet - (Optional) Execute the command quietly, returning no messages from the command. The command also returns TCL_OK regardless of any errors encountered during execution.
Note: Any errors encountered on the command-line, while launching the command, will be returned. Only errors occurring inside the command will be trapped.
-verbose - (Optional) Temporarily override any message limits and return all messages from this command.
Note: Message limits can be defined with the set_msg_config command.

<instance> - (Optional) The name of the instance to be set as the current instance of the current design.

  • The <instance> is specified relative to the presently defined current instance, using the defined hierarchy separator.
  • Use '..' to move up one level of the hierarchy relative to the current instance.
  • If the <instance> argument is omitted, the current instance is reset to the top module in the design hierarchy.
  • If the <instance> is specified as '.' then the name of the current instance is returned, and the instance is not changed.

Examples

The following example sets the current instance to the top module of the current design:

current_instance
   INFO: [Vivado 12-618] Current instance is the top level of design 'netlist_1'.

In this example you have selected an object in the Vivado™ IDE, and you want to set that selected object as the current instance:

current_instance [lindex [get_selected_objects] 0]
Note: get_selected_objects returns a list, even of one object, so you must use lindex to specify an object from that list.

The following example first sets the hierarchy separator character, and then sets the current instance relative to the presently defined current instance:

set_hierarchy_separator |
current_instance ..|cpu_iwb_dat_o|buffer_fifo

The following example returns the name of the presently defined current instance:

current_instance .
cpuEngine|cpu_iwb_dat_o|buffer_fifo