Version: Vitis 2024.1
Table of Contents
Introduction
Versal™ adaptive SoCs combine programmable logic (PL), processing system (PS), and AI Engines with leading-edge memory and interfacing technologies to deliver powerful heterogeneous acceleration for any application. The hardware and software are targeted for programming and optimization by data scientists and software and hardware developers. A host of tools, software, libraries, IP, middleware, and frameworks enable Versal adaptive SoCs to support all industry-standard design flows.
Objectives
After completing this tutorial, you should be able to:
Use Verilog or System Verilog modules to drive traffic in and out of an ADF graph running in the AIE Simulator.
Create a setup for Verilog/SV based traffic generator running with AIEsim or x86sim process.
Integrate your own RTL running in external process with AIEsim or x86sim process.
Run the external Verilog/System Verilog based traffic generator with XSIM as well as other third party simulators.
Use python-based automation to generate AMD Vivado™ Design Suite TCL scripts and aie instantiable module for your external testbench.
*Note: Note: External Traffic Generators provides only the PL stream traffic injection and recording capabilities for AI Engine Simulation without any expectation of Cycle Accuracy or Cycle Locked simulation.
IMPORTANT: Before beginning the tutorial make sure you have installed the Vitis 2024.1 software. The Vitis release includes all the embedded base platforms including the VCK190 base platform that is used in this tutorial. In addition, ensure you have downloaded the Common Images for Embedded Vitis Platforms from this link: https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-platforms/2024.1.html. The common image package contains a prebuilt Linux kernel and root file system that can be used with the Versal board for embedded design development using Vitis.
Before starting this tutorial run the following steps:
Go to the directory where you have unzipped the Versal Common Image package.
In a Bash shell run the
/Common Images Dir/xilinx-versal-common-v2024.1/environment-setup-cortexa72-cortexa53-xilinx-linux
script. This script sets up theSDKTARGETSYSROOT
andCXX
variables. If the script is not present, you must run the/Common Images Dir/xilinx-versal-common-v2024.1/sdk.sh
.Set up your
ROOTFS
, andIMAGE
to point to therootfs.ext4
andImage
files located in the/Common Images Dir/xilinx-versal-common-v2024.1
directory.Set up your
PLATFORM_REPO_PATHS
environment variable to$XILINX_VITIS/lin64/Vitis/2024.1/base_platforms/
.
This tutorial targets VCK190 production board for 2024.1 version.
Documentation
Explore AI Engine Architecture
Traffic Generator
Installing the Tools
Versal Adaptive SoC AI Engine Programming Environment (UG1076)
Tutorial Overview
Section 1: Overview of the design that will be used in this tutorial.
Section 2: How to integrate external RTL (Verilog/SV) based traffic generator with AIE.
Section 3: Launch the external process with AIEsim process.
Section 4: External RTL simulation in XSIM and other third party simulator support.
Section 5: More on Traffic Generators.
Section 1: Overview of the Design that Will be Used in this Tutorial
The following figure gives an overview of how the data will flow through this example design.
The following table gives a brief overview of all the functionalities involved.
Name | Type | Functionality |
---|---|---|
Interpolator | AIE Kernel | Interpolate using two samples by taking in 128 cint16 samples block as input and producing 256 cint16 samples block as an output. |
Polar Clip | User RTL | Performs threshold detection and clipping. |
Classifier | AIE Kernel | Does some simple classification as per complex plane and produces plane numbers (from 0 to 3) based on the complex value. |
There are two AIE kernels communicating with the user RTL block. The AIE kernels have four PLIOs, two being file I/Os i.e., in_interpolator
and out_classifier
and the other two being external I/Os i.e., out_interpolator
and in_classifier
responsible for propagating traffic in/out of the AIE kernels from the external process running the user RTL block.
Directory Structure
19-aie_external_io_sv
|- images
|- data
|- user_rtl
|-aie
| - kernels
|-my_top.v
This example contains Verilog design (user RTL code) in the ext_rtl
folder. The external Verilog testbench is present at the top named as my_top.v
.
Section 2: How to Integrate External RTL (Verilog/SV) Based Traffic Generator with AIE
To establish the connection between the RTL and the AIE kernel’s external PLIOs, the XTLM_IPC SystemC modules are required for the interface between an RTL and AIE kernel and these stubs are present inside external aie wrapper stub module which includes all the XTLM IPC modules and needs to be instantiated in the external testbench to establish the connection as mentioned in the following figure. The axi_stream connections from the RTL kernel are made to the stub which transfers the data to AIE kernel and vice versa as seen in following figure.
Generating AIE Wrapper Stub Module
The AIE wrapper stubs will be generated based on the external PLIO declarations in the ADF graph. You need to follow below steps for generating these stubs for the AIE.
Perform the ADF graph compilation to generate
scsim_config.json
file that resides inWork/config/scsim_config.json
directory. This config file contains information on the PLIOs declared in the graph.v++ -c --mode aie --platform=$(PLATFORM) --aie.pl-freq 500 --aie.adf-api-log-level 3 --include=./aie --output=graph.json aie/graph.cpp
or
make compile PLATFORM=$PLATFORM_REPO_PATHS/xilinx_vck190_base_202310_1/xilinx_vck190_base_202310_1.xpfm
Using this config file as argument to the
gen_aie_wrapper.py
script, you can autogenerate Verilog stub modules based on ext PLIO declared in ADF Graph.python3 ${XILINX_VITIS}/data/emulation/scripts/gen_aie_wrapper.py -json Work/config/scsim_config.json --mode <wrapper/vivado>
Tip: The python script is available in the Vitis install area as mentioned in above path. There are two modes for the script i.e.,
wrapper
andvivado
mode. By default, the script runs in Vivado mode. If run withwrapper
mode, it only generatesaie_wrapper_ext_tb.v
.For x86simulation, you will have to manually write this wrapper as
scsim_config.json
is not available for x86sim flow.
The name of the instance stubs must be identical to the name of the corresponding external PLIOs in graph.h (”in_classifier” and “out_interpolator” as mentioned below), and these name of the instances in graph.h
will be reflected in the generated aie_wrapper_ext_tb.v
file.
pl_in0 = adf::input_plio::create("in_classifier",adf::plio_32_bits);
out0 = adf::output_plio::create("out_interpolator",adf::plio_32_bits);
After step 2, you can see aie_wrapper_ext_tb.v
is generated that has instances of sim_ipc_axis modules that can be directly instantiated in your external testbench.
Adding User RTL and External Testbench
The design used in this tutorial has polar_clip
user RTL located inside user_rtl/
directory and the external testbench as my_top.v
.
Instantiating aie wrapper in the External Testbench
The aie wrapper module (aie_wrapper_ext_tb.v
) needs to be instantiated in the external testbench (my_top.v
or my_top.sv
). You can open my_top.v
and see the aie_wrapper instantiation.
The aiesim expects data to be in beats instead of transaction. So, you need to keep tlast at high (1'b1
) all the time in my_top.v as follows:
Note: You can add
timescale
directive as per your requirement inaie_wrapper_ext_tb.v
.
Generating sim_ipc_axis IPs for Vivado Project
By default, the python script generates aie_wrapper_ext_tb_ip.tcl
and aie_wrapper_ext_tb_proj.tcl
along with the wrapper Verilog file as mentioned in above section.
There are two ways to proceed based on the existence of the Vivado project. This tutorial can be run using aie_wrapper_ext_tb_proj.tcl
if there is no available project already created using Vivado. If you have your Vivado project, use the IP flow i.e., aie_wrapper_ext_tb_ip.tcl
.
If you have already created a Vivado project, this Tcl script can be used for generating required sim_ipc_axis IPs. From within the existing Vivado project, inside the Tcl console source
aie_wrapper_ext_tb_ip.tcl
. In the Vivado Tcl console, run the following command:source <absolute_path>/aie_wrapper_ext_tb_ip.tcl
You need to ensure that project directory and aie_wrapper_ext_tb_ip.tcl
directory are the same. If aie_wrapper_ext_tb_ip.tcl
is in another directory, provide appropriate path while sourcing it.
This tcl script is responsible for generating sim_ipc_axis IPs in Vivado project.
After sourcing the tcl file, you will see hierarchy created in sim_1 fileset under Simulation_sources.
You can add the required files and directories for your project as mentioned in the following figure:
You will see the updated hierarchy in Vivado.
If a Vivado project is not created, use
aie_wrapper_ext_tb_proj.tcl
. You need to updateaie_wrapper_ext_tb_proj.tcl
for the choice of simulator you want to use. Set line no. 19 to the choice of simulator xsim/questa/VCS/xcelium/riviera. If SIMULATOR is set to “xsim”, comment out line no. 21 to 38. For other third party simulators, you need to update the required paths for SIMULATOR_GCC_PATH, SIMULATOR_CLIBS_PATH and INSTALL_BIN_PATH. For more details on how to set the third party simulators, please refer Vivado Design Suite User Guide: Logic Simulation (UG900).
On the terminal, run the following command:
source vivado/vitis
vivado -mode batch -source aie_wrapper_ext_tb_proj.tcl
On sourcing aie_wrapper_ext_tb_proj.tcl
, it will generate export_sim
directory. The export_sim
directory has sub-directories with scripts required for using with other simulators. This Tcl script internally sources aie_wrapper_ext_tb_ip.tcl
.
These scripts contains only sim_ipc_axis modules. So, it is your responsibility to add any extra required RTL modules and options in the scripts.
You can modify and directly include desired user RTL inside the aie_wrapper_ext_tb_proj.tcl
as seen in the following figure:
Section 3: Launch the external process with AIEsim process
After completing section 2, once required scripts are generated, you can launch the external process as follows:
If already inside the Vivado project, once the project hierarchy is updated after adding the required sources as mentioned in section 2, you can run the simulation as folows:
Parallelly, you can run the aiesimulator on your Linux terminal using the following command.
aiesimulator --pkg-dir Work --profile
Once both external process and AIEsim process are launched, you can start seeing traffic propagating to and from the user RTL as per the following waveform:
If outside the Vivado project, once the export_sim directory is generated with required simulation scripts, you can traverse inside XSIM directory and run
<top_module_name>.sh
script to launch the RTL simulation. Also, parallelly launch the AIEsimulator process as already mentioned. The name of the simulator script is based on the name of the top module which is aie_wrapper in this tutorial. The<top_module_name>.sh
script is generated for every simulator that can be used to launch the simulation process. You can find the simulator scripts generated in below path.export_sim/xsim/<top_module_name>.sh
Update aie_wrapper.sh
script line no. 72 to launch XSIM
in GUI mode by adding --gui
flag.
Go inside the desired simulator directory and trigger the simulator script (aie_wrapper.sh
) to launch the simulation.
Also, update the generated cmd.tcl
file (line no. 11) to run the simulation for desired timestamp or run all
so that traffic can be analyzed. You can manually terminate the simulation once traffic is seen propagating between PL-AIE and you have analyzed the same.
When simulation is launched, you can see the traffic propagating to and from the user RTL.
Section 4: External RTL simulation in XSIM and Other Third Party Simulator Support
The external RTL simulation is supported for XSIM and all other third party simulators. You can find the respective simulator scripts generated inside the export_sim
directory as per the following directory structure.
export_sim/<simulator_name>/<top_module_name>.sh
Once you finish to analyze the traffic from PL to AIE and AIE to PL, the AIE simulator and RTL simulation should be manually terminated. No Pass/Fail check is done.
Section 5: More on Traffic Generators
This tutorial talks about Verilog/SV based traffic generators and users can also try C-based/Python based traffic generators with AIE. For more details, please refer the tutorial 16-external-traffic-generator-aie
You can also integrate traffic generators with AIE flows i.e., AIEsim/x86sim or emulation flows i.e., SW emulation or HW emulation. For more details, refer Adding-Traffic-Generators-to-Your-Design.
Summary
In this tutorial, you learned how to drive traffic from external Verilog/System-Verilog traffic generators/testbenches to the AIE simulator. For the same, you need to make the appropriate port connections between the AIE kernels, the aie wrapper stubs (for internally connecting XTLM IPC stubs) and the RTL kernel.
To read more about the use of Vitis in the AI Engine flow, see Versal Adaptive SoC AI Engine Programming Environment Chapter 14: Generating Traffic for Simulation and Emulation (UG1076).
Note - Supported simulators are Xsim and all the third party simulators (Questa/Riviera/Xcelium/VCS).
Note - You must provide the simulator installer path, gcc path and clibs path in
aie_wrapper_ext_tb_proj.tcl
script based on the choice of third party simulator.
Support
GitHub issues will be used for tracking requests and bugs. For questions, go to forums.xilinx.com.
Copyright © 2020–2024 Advanced Micro Devices, Inc