See SDAccel™ Development Environment 2019.1 Tutorials |
The Vitis™ compiler creates kernel objects from the source code, links the kernels with the targeted shell, and runs the assembled design through the Vivado® tool implementation flows. It generates the platform file (xclbin) needed to program the FPGA-based acceleration cards. Sometimes, it is essential to use the advanced Vivado synthesis and implementation options to achieve your desired results, including timing closure.
This tutorial shows you how to control the Vivado tool flows to implement your project and guides you through the steps in the command line flow.
The Vitis core development kit provides two methods to control the Vivado tool flow:
-
When compiling or linking for a system build, you can pass Vivado synthesis and implementation options using config files.
NOTE: It can take hours to complete a system run.
-
If your application has already been compiled, then you can:
- Optimize the design with the Vivado Design Suite.
- Generate a new routed checkpoint.
- Reuse this checkpoint to generate a new platform file (xclbin).
This tutorial uses:
- BASH Linux shell commands
- 2019.2 Vitis core development kit release and the xilinx_u200_xdma_201830_2 platform. If necessary, it can be easily ported to other versions and platforms.
IMPORTANT:
- Before running any of the examples, make sure you have installed the Vitis core development kit as described in Installation.
- If you run applications on Xilinx® Alveo™ Data Center accelerator cards, ensure the card and software drivers have been correctly installed by following the instructions in the Getting Started with Alveo Data Center Accelerator Cards Guide (UG1301).
- Before running this lab, you must be familiar with the Essential Concepts for Building and Running the Accelerated Application tutorial.
- To access the reference files, enter the following into a terminal:
git clone https://github.com/Xilinx/Vitis-Tutorials
. - Navigate to the
controlling-vivado-impl
directory, and then accessreference-files/run
directory.
NOTE: In this tutorial, run all instructions from the
reference-files/run
directory.
The –-xp
switch is paired with parameters to configure the Vivado tools. For instance, the --xp
switch can configure optimization, placement, and timing, or set up emulation and compile options. In the command line flow, parameters are specified as param:<param_name>=<value>
, where:
param
: Required keyword.param_name
: Name of a parameter to apply.value
: Appropriate value for the parameter.
In this section, you will use the following configurations as examples to see the flow to control Vivado synthesis and implementation:
-
Completely flatten hierarchy during RTL synthesis (specify FLATTEN_HIERARCHY=full).
--xp vivado_prop:run.my_rm_synth_1.{STEPS.SYNTH_DESIGN.ARGS.FLATTEN_HIERARCHY}={full}
-
Use the NoTimingRelaxation directive during the routing step (DIRECTIVE=NoTimingRelaxation).
--xp vivado_prop:run.impl_1.{STEPS.ROUTE_DESIGN.ARGS.DIRECTIVE}={NoTimingRelaxation}
In this lab, -–xp
command options are provided in an design.cfg
file with each option specified on a separate line without the --xp
switch.
For a full list of parameters and valid values, refer to the Vitis Environment Reference Materials.
-
Before running any of the examples, ensure you have set up the Vitis core development kit by running these commands:
#setup Xilinx Vitis tools, XILINX_VITIS and XILINX_VIVADO will be set in this step. source <VITIS install path>/settings64.sh. for example: source /opt/Xilinx/Vitis/2019.2/settings64.sh #Setup runtime. XILINX_XRT will be set in this step source /opt/xilinx/xrt/setup.sh
-
Compile kernel with the Vitis compiler and link it into the platform file (xclbin) with the
--xp
command options.v++ -t hw --config design.cfg -c -k apply_watermark -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xo' '../src/krnl_watermarking.cl' v++ -t hw -s --config design.cfg -R2 -l -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xclbin' apply_watermark.hw.xilinx_u200_xdma_201830_2.xo
-
Open the
design.cfg
file and get familiar with different options. The following list describes some of the command options.Command Options Descriptions
-t hw
: Target system runplatform=xilinx_u200_xdma_201830_2
: Target the xilinx_u200 platformdebug=1
: Generate debug infomax_memory_ports=apply_watermark
: Generate one AXI4 interface for one port-c
: Compile the kernel-k apply_watermark
: Name the kernel../src/krnl_watermarking.cl
: Specify source filessp=apply_watermark_1.m_axi_gmem0:DDR[0]
: Specify DDR bank connection--config design.cfg
: Set the Vivado Synthesis and Implementation options-R2
: Set Report Level to 2 to generate DCPs for each implementation step-l
: Link the kernelnk=apply_watermark:1:apply_watermark_1
: Specify kernel instance number and name
-
To check that the Vivado synthesis and implementation options are applied, open
_x/logs/link/vivado.log
, and search for flatten_hierarchy and NoTimingRelaxation. You will find following lines indicating that the options have taken effect:- Command:
synth_design -top pfm_dynamic -part xcu200-fsgd2104-2-e -flatten_hierarchy full -mode out_of_context
- Command:
route_design -directive NoTimingRelaxation
- Command:
If your application has already been compiled for a system run, you can optimize the implementation result with various Vivado tool techniques to achieve your goal, such as achieving timing closure. After optimization, write the routed design back to checkpoint file (DCP), and then reuse this checkpoint to finalize a new implementation.
NOTE: Ensure that the Vitis core development kit and Vivado environment versions match between different iterations.
In the optimization stage, Vivado tool techniques apply. For information on Vivado tool usage and optimization, refer to the Vivado Design Suite Implementation User Guide (UG904) and UltraFast Design Methodology Guide for the Vivado Design Suite (UG949).
For example, you might run the Vivado tool in batch mode with a Tcl script, where the Tcl script reads DCP, does optimization, and writes routed DCP.
From the /reference-file/run
folder, run the following command.
#make sure you have successfully setup Vitis/Vivado environments as previous part shows.
vivado -mode batch -source opt.tcl
The opt.tcl
file displays the following:
#DCP files in different stages of Vivado have been written by v++ linker automatically with option "-R2"
open_checkpoint ./_x/link/vivado/vpl/prj/prj.runs/impl_1/pfm_top_wrapper_routed.dcp
#Run post-route physical optimization
phys_opt_design -directive AggressiveExplore
write_checkpoint -force ./_x/link/vivado/routed.dcp
Next, reuse the routed.dcp
checkpoint file generated by the opt.tcl
script to generate a new platform file (xclbin). To do this, add the --reuse_impl
option to the v++
command.
v++ -t hw --config design.cfg -l -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xclbin' apply_watermark.hw.xilinx_u200_xdma_201830_2.xo --reuse_impl ./_x/link/vivado/routed.dcp
From the message in the console, you can see that the steps to generate the implemented design have been skipped, and the bitstream generation starts.
INFO: [VPL 60-251] Hardware accelerator integration...
Starting FPGA bitstream generation.
The following section summarizes all the steps to control Vivado tools implementation with the v++
command, optimize design with the Vivado tools, and reuse implemented dcp to generate the platform file. You might use it as a quick reference for commands.
-
Set up the core development kit and working directory.
#setup Xilinx Vitis tools, XILINX_VITIS and XILINX_VIVADO will be set in this step. source <Vitis install path>/settings64.sh. for example: source /opt/Xilinx/Vitis/2019.2/settings64.sh #Setup runtime. XILINX_XRT will be set in this step source /opt/xilinx/xrt/setup.sh
-
Generate the platform file (xclbin) with
v++
commands.v++ -t hw --config design.cfg -c -k apply_watermark -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xo' '../src/krnl_watermarking.cl' v++ -t hw -s --config design.cfg -R2 -l -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xclbin' apply_watermark.hw.xilinx_u200_xdma_201830_2.xo
-
Optimize the design with the Vivado tool and rewrite the routed DCP.
vivado -mode batch -source opt.tcl
-
Reuse the routed DCP to generate the platform file (xclbin).
v++ -t hw --config design.cfg -l -o'apply_watermark.hw.xilinx_u200_xdma_201830_2.xclbin' apply_watermark.hw.xilinx_u200_xdma_201830_2.xo --reuse_impl ./_x/link/vivado/routed.dcp
-
This tutorial has provided host code to make it complete to run though various flows. The following commands are references to build the host and run the application.
#Generate the host executable. g++ -I$XILINX_XRT/include/ -I$XILINX_VIVADO/include/ -Wall -O0 -g -std=c++11 -L$XILINX_XRT/lib/ -lOpenCL -lpthread -lrt -lstdc++ -o 'host' '../src/host.cpp' #Please set correct XCL_EMULATION_MODE manually if running sw_emu and hw_emu modes ./host apply_watermark.hw.xilinx_u200_xdma_201830_2.xclbin ../src/inputImage.bmp ../src/golden.bmp
This tutorial illustrated how to use the v++
command --xp
option to control Vivado synthesis and implementation, using a simple example to optimize the design with the Vivado tool. It then showed the steps to reuse implemented DCP to generate the platform file (xclbin), skipping the intermediate steps to generate the implemented design.
To run through all flows, the host code and its building commands are also provided for reference.
Copyright© 2019 Xilinx