Defining Tcl Hook Scripts - 2021.2 English

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

Document ID
UG894
Release Date
2021-11-17
Version
2021.2 English

In a Non-Project flow you have the ability to source a Tcl script at any point in the flow, such as before or after running the synth_design command. You can also do this in a project-based flow, using the Vivado IDE, or by using the set_property command to set a property on either a synthesis or implementation run. Tcl hook scripts allow you to run custom Tcl scripts prior to (tcl.pre) and after (tcl.post) synthesis and implementation design runs, or any of the implementation steps.

Whenever you launch a synthesis or implementation run, the Vivado tools use a predefined Tcl script to process a standard design flow based on the selected strategy. Tcl hook scripts let you customize the standard flow, with pre-processors or post-processors. Being able to add Tcl script processing anywhere in a run can be useful. Every step in the design flow has a pre-hook and post-hook capability. Common uses are:

  • Custom reports: timing, power, utilization, or any user-defined Tcl report.
  • Modifying the timing constraints for portions of the flow only.
  • Modifications to netlist, constraint, or device programming.

In the GUI you can specify the Tcl hook scripts to be sourced by using the Change Run Settings command for the design run. Right-click a run in the Design Runs window and select the Change Run Settings from the pop-up menu to open the Design Run Settings dialog box. The tcl.pre and tcl.post options can be used to specify a Tcl hook script.

The Vivado IDE sets a property on the synthesis or implementation run to specify the tcl.pre or tcl.post script to apply before or after the run, as shown in Defining Tcl Hook Scripts. You can also set this property directly on a synthesis or implementation run, either in the Tcl Console or as part of a Tcl script.

Figure 1. Defining Pre and Post Run Tcl Scripts
Page-1 Sheet.2

The properties to set on a synthesis run are:

STEPS.SYNTH_DESIGN.TCL.PRE
STEPS.SYNTH_DESIGN.TCL.POST

For instance, set the following property to have the report.tcl script launched before synthesis is complete:

set_property STEPS.SYNTH_DESIGN.TCL.PRE {C:/Data/report.tcl} [get_runs synth_1]

For an implementation run you can define Tcl scripts before and after each step of the implementation process: Opt Design, Power Opt Design, Place Design, Post-Place Power Opt Design, Phys Opt Design, Route Design and Bitstream generation. The properties for each of these are:

STEPS.OPT_DESIGN.TCL.PRE
STEPS.OPT_DESIGN.TCL.POST
STEPS.POWER_OPT_DESIGN.TCL.PRE
STEPS.POWER_OPT_DESIGN.TCL.POST
STEPS.PLACE_DESIGN.TCL.PRE
STEPS.PLACE_DESIGN.TCL.POST
STEPS.POST_PLACE_POWER_OPT_DESIGN.TCL.PRE
STEPS.POST_PLACE_POWER_OPT_DESIGN.TCL.POST
STEPS.PHYS_OPT_DESIGN.TCL.PRE
STEPS.PHYS_OPT_DESIGN.TCL.POST
STEPS.ROUTE_DESIGN.TCL.PRE
STEPS.ROUTE_DESIGN.TCL.POST
STEPS.WRITE_BITSTREAM.TCL.PRE
STEPS.WRITE_BITSTREAM.TCL.POST
Important: Relative paths within the tcl.pre and tcl.post scripts are relative to the appropriate run directory of the project they are applied to: <project>/<project.runs>/<run_name>. You can use the DIRECTORY property of the current project or current run to define the relative paths in your Tcl hook scripts:
get_property DIRECTORY [current_project] 
get_property DIRECTORY [current_run]