Step-4: Writing the External Traffic Generator - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
Release Date
2023.2 English

The overall goal of the external traffic generator is to send or receive data to or from the AI Engine array through a specific port. The sender can generate data on the fly or read it from a file. The receiver can keep the data and save it somewhere, or process it in a function. This example design implements sender and receiver as external sources.

Here, the external traffic generators have taken the place of the PL data movers mm2s and s2mm respectively i.e. interfaced with the input port of the interpolator (in_interpolator) and the output port of the classifier (out_classifier). You can go inside TrafficGenerator/ for the script analysis in Python, MATLAB and CPP.



1. Instantiating the XTLM Utilies

You need to create the sender and receiver objects for the AIE input PLIO/output PLIO that will make sure to instantiate the XTLM utilities for IPC based communication while sending or receiving the traffic. Open the script inside TrafficGenerator/Python/ for the script analysis.

in_interpolator = aie_input_plio("in_interpolator", 'int16')
out_classifier = aie_output_plio("out_classifier", 'int32')

Here the first parameter in_interpolator is a string value that should match PLIO names in the graph PLIO constructors. The second parameter is the AIE kernel datatype with which sender/receiver is interfaced. For more details on datatype mapping in Python based external traffic generators, see

2. Transmitting the data using send_data (data_val, tlast) API

You can prepare the list of data values and send them using send_data API call. The API expects data values in the list as the first parameter and TLAST value to be driven as the second.

in_interpolator.send_data(in_interpolator_data, True)

Here the first parameter in_interpolator_data is the list of cint16 (16-bit) real and imag values expected by the AIE kernel. The second parameter is the TLAST value as True

3. Receiving the data using receive_data_with_size API(expected_data_size)

In order to get the received data values from the classifier, use receive_data_with_size(exp_data_size) API call. This API needs expected data size (in bytes) as an argument. The classifier expects total 4096 bytes of data in 4 iterations i.e. 1024 bytes each time receive data is called.

out_classifier_data = out_classifier.receive_data_with_size(1024)

This API is a blocking API and it will wait till expected bytes is received at the output port.

For more details on Python based APIs, refer Writing Traffic Generators in Python