Step 4: Test the Platform - 2024.1 English

Vitis Tutorials: Platform Creation (XD101)

Document ID
Release Date
2024.1 English

In this step, you build a simple vadd application and run hardware emulation to test the platform. Follow the instructions in Versal platform creation tutorial-Step3 along with the following modifications.

You need to run Application1 on the above page. After creating the vadd system project, make the following changes.

  1. Open up the krnl_vadd.cpp file under the src folder of the vadd_kernels project. Add the following header files at the beginning of this file. These are used to support the AXIS data type and HLS stream data type.

#include "ap_int.h"
#include "ap_axi_sdata.h"
  1. Define a type named pkt before the kernel function definition.

typedef ap_axis<15, 0, 0, 0> pkt;
  1. In this design, the data from the DDS IP is not processed. It is only passed on to the DDR. To do that, add a function similar to the following:

static void dss_process( int *wave, hls::stream<pkt> &s_in) {
    for (int i = 0; i < 1024; i++) 
        #pragma HLS PIPELINE II = 1
        pkt value =;
        wave[i] =;
  1. Add two ports into the top level function. The dds_in port is an AXI4-Stream type and the wave_out port is an AXI-MM type.

void krnl_vadd(uint32_t* in1, uint32_t* in2, uint32_t* out, int size, int *wave_out, hls::stream<pkt> &dds_in) 
  1. Declare the two ports added in step4 in the krnl_vadd function.

#pragma HLS INTERFACE m_axi port = wave_out bundle = gmem2
#pragma HLS INTERFACE axis port = dds_in
  1. Add one line to call the dss_process function in the krnl_vadd function.


Now the kernel code modification is complete. Save your work and close the file.

Note: For the complete modification code reference on the vadd kernel, see kernel code modifications.

  1. To direct the Vitis linker to correctly link the kernel’s AXI stream port with the corresponding interface of the platform, create a configuration file called system.cfg and add the following lines to it.

stream_connect = AXIS:krnl_vadd_1.dds_in

This command indicates the connections between two AXI4-Stream ports. The name before the colon must be the master interface while the latter is the name of the slave interface. In this design, the AXIS sptag from platform represents the AXI master side therefore we put it in the front. Here you just need to specify the sptag that was defined during platform creation and the Vitis linker detects it automatically.

The system_cfg file is put under the vadd_system_hw_link project. You can choose other locations but just make sure that you point to it correctly in the binary container settings.

Specify the config file in binary container settings:

missing image

  1. Now modify the host code to read back the data from the DDR. Open up the vadd.cpp file under the src folder of the vadd project and modify the following items.

    a. Add header files.

    #include "ap_int.h"
    #include <stdio.h>

    b. Create a new cl_mem buffer for the DDS output data.

    cl::Buffer buffer_waveout(context, CL_MEM_WRITE_ONLY, 1024*sizeof(int));

    c. Bond the buffer with the kernel.


    d. Map the host buffer with the device buffer.

    int *ptr_waveout = (int *) q.enqueueMapBuffer (buffer_waveout , CL_TRUE , CL_MAP_READ , 0, 1024*sizeof(int));

    e. Read the data from the DDR.


    f. Save the data into a file. The data is left shifted by 17 bits because the DDS compiler IP output is 16-bit signed data and the host buffer 32-bit integer data. This is to remove the extra signed bits and keep the actual payload data.

     FILE *fp_dout;
     for (int i = 0; i < 1024; i++) {

    g. Unmap the buffer.

    q.enqueueUnmapMemObject(buffer_waveout , ptr_waveout);

    Note: For the complete modification code reference on the vadd host application, see host code modifications.

  2. Now run emulation on the modified vadd application. Follow the instructions in Versal platform creation tutorial-Step3 Emulation.

  3. After the ‘Test Passed’ pop-up appears in the console window, copy the generated wave_out.txt file from the QEMU target. First, launch the XSCT console window from AMD menu if you have not already done so.

Connect to the tcf target using the following command:

connect -host -port 1440

Copy the wave_out.txt file from the tcf target to the host machine using the following command:

tfile copy -to-host /run/media/mmcblk0p1/wave_out.txt $(YOUR_DIR)/wave_out.txt

The wave_out.txt file will be copied over to $(YOUR_DIR). Choose a tool to plot the data. A possible option is the tool gnuplot which is an open source tool and easy to use it to print out the sine wave.

missing image