Using pva_top simulator#
Overview#
PVA top is a simulator of a single PVA unit (two VPUs). It can model each VPU with cycle level accuracy, and runs R5 firmware similar to that used in a production setting. The API to submit to the simulator is identical to that used for native and target SOC build modes. The process to use the simulator consists of:
Build an application with
-DPVA_BUILD_MODE=SIM.Launch the simulator with
pva-sdk-2.8-sim.While the simulator is running, launch the application built earlier. It will execute on the simulator.
(Optional) Connect chessde debugger to the simulator.
The pva_top simulator can be slow, especially for the cycle-accurate model. Applications which take milliseconds on hardware will take minutes on the simulator. However, it provides unparalleled visibility of the hardware state.
Pre-requisites#
In order to use the pva_top simulator, some additional Ubuntu packages need to be installed on your build machine:
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install tcsh libc6-dev-i386 libice-dev:i386 default-jre:i386 libelf-dev
A Synopsys VDK license is required. User needs to export the following environment variables:
export LM_LICENSE_FILE=<PATH_TO_LICENSE_FILE>
# Alternatively to LM_LICENSE_FILE, SNPSLMD_LICENSE_FILE can be set:
export SNPSLMD_LICENSE_FILE=<TCP_PORT>@<LICENSE_SERVER>
export PVA_VDK_PATH=<path to synopsys VDK install directory>
export PVA_GEN2_ASIP_PATH=<path to synopsys ASIP tools, required if using Orin>
export PVA_GEN3_ASIP_PATH=<path to synopsys ASIP tools, required if using Thor>
Usage#
Building#
To build a PVA application for the pva_top simulator, use the CMake argument -DPVA_BUILD_MODE=SIM.
It is recommended to use a clean build directory.
For example, when in a directory containing a PVA SDK CMakeLists.txt:
mkdir build_sim && cd build_sim
cmake -DPVA_BUILD_MODE=SIM ..
make j8
Running#
Before running your program, you need to launch the pva_top simulator. A system-wide command is installed
for this purpose, pva-sdk-2.8-sim.
Usage is as follows:
source envsetup.sh
pva-sdk-2.8-sim
Note
envsetup.sh is a script distributed with PVA SDK internal releases. See above for a list of important
environment variables when using the simulator.
This will launch the simulator in CLI mode. The command pva-sdk-2.8-sim accepts multiple options:
To launch with vpexplorer GUI, the optional argument
-gmay be passed topva-sdk-2.8-sim. The GUI can be used to inspect memory, pause the simulation, set breakpoints, and inspect register values.By default,
pva-sdk-2.8-simwill launch the cycle-accurate simulator. To launch the instruction accurate simulator (which is a fast but less accurate model of the hardware), the optional argument-imay be passed.By default,
pva-sdk-2.8-simwill launch the Orin version of the simulator. The Thor version can be specified with-p=GEN3or by settingPVA_GENenvironment variable toGEN3. Your application should be run in an environment with matchingPVA_GENenvironment variable set.
To see the full list of options:
pva-sdk-2.8-sim --help
Once the simulator has launched, it will take a few seconds to boot the PVA.
When it is ready, you will see the following message in the log:
[pva_top_plugin] R5 boot successful!
[pva_top_plugin] Waiting on client...
At this point, you will be able to run the program you have built and it will connect to the simulator.
Attaching debugger#
With a simulator running, the chessde debugger may be connected to set breakpoints, step through instructions, inspect registers, inspect memories etc.
By default, PVA SDK build scripts create .prx files which can be used with chessde. These can be found in your build output directory.
Once you have launched chessde with one of these .prx files, you should choose to connect a debugger as ‘Client’.
If the simulator is running, you will need to choose which VPU you’d like to connect to.
Note
When debugging with the simulator, it may be useful to use the host API to specify a static VPU core for execution
After this, you should launch the application you wish to debug. After some time loading, you will see the chessde GUI will display your program’s disassembly, and allow you to resume the simulation.
Note
Refer chessde manual for further information on debugging with this tool