Targeting Hardware Emulation - 2023.2 English

Vitis Tutorials: Getting Started (XD098)

Document ID
XD098
Release Date
2023-11-13
Version
2023.2 English

To build for hardware emulation, enter the following commands to setup the target build directory:

cd <Path to the cloned repo>/Getting_Started/Vitis/example/zcu102
mkdir hw_emu
cp xrt.ini hw_emu
cp run_hw_emu.sh hw_emu

Then, after changing into the target build directory, enter the following commands to build the host application and device binary:

$CXX -g -std=c++17 -Wall -O0 -fmessage-length=0 ../../src/host.cpp -o ./app.exe -I$SYSROOT/usr/include/xrt -LSYSROOT/usr/lib -lxrt_coreutil -pthread --sysroot=$SYSROOT
v++ -c --mode hls --platform xilinx_zcu102_base_202320_1 --config ./zcu102_hls.cfg --work_dir hw_emu
v++ -l -t hw_emu --platform xilinx_zcu102_base_202320_1 --config ../src/zcu102.cfg ./hw_emu/vadd.xo -o ./hw_emu/vadd.xclbin
cd hw_emu
v++ -p -t hw_emu --platform xilinx_zcu102_base_202320_1 --config ../src/zcu102.cfg ./vadd.xclbin --package.out_dir ./package --package.rootfs ${ROOTFS}/rootfs.ext4 \
--package.sd_file ${ROOTFS}/Image --package.sd_file ./xrt.ini --package.sd_file ./app.exe --package.sd_file ./vadd.xclbin --package.sd_file ./run_hw_emu.sh

Building for hardware emulation takes more time than for software emulation, but still much less than when targeting the hardware accelerator card. Notice that the v++ -c --mode hls command replaces the v++ -c -k vadd command from the software emulation flow. After the build process completes, you can launch the hardware emulation run by using the launch script generated during the packaging step.

cd hw_emu
./package/launch_hw_emu.sh 

When Linux has finished booting, enter the following commands at the QEMU command prompt to run the example program:

cd /run/media/mmcblk0p1
export XCL_EMULATION_MODE=hw_emu
./app.exe

You should see messages that say TEST PASSED indicating that the run completed successfully.

Running the application in the QEMU generates some report files during the run. These files and reports are the results of the run process targeting the software emulation build. You will be taking a closer look at some of these files in Part 5 of this tutorial. To examine these files later, you must retrieve them from the QEMU environment and copy them into your local system. You can do this using the scp command as described in Running Emulation on an Embedded Processor Platform.

This command must be run from a Linux shell, outside of the QEMU environment. For example:

scp -P 1440 root@127.0.0.1:/run/media/mmcblk0p1/xrt.run_summary ./xrt.run_summary

Press Ctrl+a x to exit QEMU and return to your bash shell.

TIP: If you have trouble exiting the QEMU environment, you can use kill -9 <qemu_pid> to kill the process from another terminal window.