Exporting a Block Design to a Tcl Script in the IDE - 2023.2 English

Vivado Design Suite User Guide: Designing IP Subsystems Using IP Integrator (UG994)

Document ID
UG994
Release Date
2023-10-18
Version
2023.2 English
To convert a block design to a Tcl script in the IDE, do the following:
  1. Create a project and a new block design in the Vivado IDE as described in Creating a Block Design. When the block design is complete, your canvas contains a design like the example in the following figure.

  2. With the block design open, select File > Export > Export Block Design, as shown in the following figure.

  3. Specify the name and location of the Tcl file in the Export Block Design dialog box, shown in the following figure.

    Alternatively, you can type the write_bd_tcl command in the Tcl Console:

    write_bd_tcl <path to file>/<filename>.tcl

    This creates a Tcl file that can be sourced to re-create the block design.

    CAUTION:
    Only parameters changed by the user are written out in this Tcl file. The default parameters of a IP, as well as the tool changed parameters after parameter propagation, are not written out.

Block Design layout information is not written out by default. Instead, you can use an optional -include_layout switch with the Tcl command to write out the layout information of blocks within a block design.

write_bd_tcl -include_layout <path to file>/<filename>.tcl

This Tcl file has embedded information about the version of the Vivado tools in which it was created, and, consequently this design cannot be used across different releases of the Vivado Design Suite. The Tcl file also contains information about the IP present in the block design, their configuration, and the connectivity.

CAUTION:
Use the script produced by write_bd_tcl in the release in which it was created only. The script is not intended for use in other versions of the Vivado Design Suite.

The write_bd_tcl command also provides with the ability to write out Tcl scripts for hierarchical blocks only. This could be useful in situations where a sub-block or hierarchy of a design needs to be reused in some other block design. As an example, looking at the following figure, you want to write out the Tcl script for generating the contents of the hierarchical block, hier_mig.

Figure 1. Writing Out Tcl for a Hierarchy

This could be done by using the -hier_blk switch with the write_bd_tcl Tcl command. For example:

write_bd_tcl -hier_blks [get_bd_cells /hier_mig] ./mig_hierarchy.tcl

The Tcl script generated from the command above can then be sourced in another block design to create the same hierarchy. In the Tcl Console, type:

source ./mig_hierarchy.tcl

When this Tcl procedure executes you see the following at the end of the Tcl procedure (in the Tcl console):

##################################################################
# Available Tcl procedures to recreate hierarchical blocks:
#    create_hier_cell_hier_mig parentCell nameHier
##################################################################

Now, use the template suggested above in the Tcl Console:

create_hier_cell_hier_mig / my_new_hierarchy

And the new hierarchical block, called my_new_hierarchy, is created in the block design as shown in the following figure.

Figure 2. Exported Block Design

The Tcl script created using the write_bd_tcl command can then be sourced in a project to re-create the block design by typing source <path to file>/<filename>.tcl.

If custom IP are present in the block design, the Tcl script created using write_bd_tcl contains a pre-check to ensure that the IP repository containing the custom IP have been added to the project prior to creating the block design. If the custom IP repository is not added to the project, then the error message similar to the following will be seen when the Tcl file is sourced:

ERROR: [BD_TCL-115] The following IPs are not found in the IP Catalog:
  xilinx.com:user:config_mb:1.0

Resolution: Please add the repository containing the IP(s) to the project.

As per the error message, the IP repository should be added to the Project before sourcing this Tcl file. IP Repository can be added as described in Managing Repositories in Vivado Design Suite User Guide: Designing with IP (UG896).