Step-2: Writing the traffic generator - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
XD100
Release Date
2023-11-29
Version
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 data and save it somewhere, or process it in a function.

Here, the PL datamovers are replaced with traffic generators and any PL-interface with AIE is replaced via ETG interface with AIE i.e. interfaced with the input port of the interpolator (in_interpolator), output port of the interpolator (out_interpolator), input port of the classifier and the output port of the classifier (out_classifier). You can go inside TrafficGenerator/ folder for the script analysis in Python, Matlab and C++.

Python

Python

1. Instantiating the XTLM Utilies

You can create the sender and receiver objects for the AIE that will make sure to instantiate the XTLM utilies for IPC based communication while sending or receiving the traffic. See lines 7-13.

    in_interpolator = aie_input_plio("in_interpolator", 'int16')
    out_interpolator = aie_output_plio("out_interpolator", 'int16')
    in_classifier = aie_input_plio("in_classifier", '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 Writing Traffic Generators in Python

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. See lines 37 and 58 in the script TrafficGenerator/Python/xtg_aie.py. The API expects data values’ list as the first parameter and TLAST value as the second.

in_interpolator.send_data(in_interpolator_data, True)
in_classifier.send_data(in_classifier_data, True)

Here the first parameter in_interpolator_data is the list of int16 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.

out_classifier_data = out_classifier.receive_data_with_size(1024)
out_interpolator_data = out_interpolator.receive_data_with_size(1024)

This API is a blocking API and it will wait till specified data i.e. 4096 bytes is received in four iterations at the output port. Once received the specified data size, you can see the data values in the out_classifier_data and out_interpolator_data list.

Once the data is received in the list, you can dump it in a file for comparing with the golden output or you can process the data further into some other function based on the application. The output of the interpolator is dumped into a file and can be validated against the golden data(interpolator_golden.txt). The output of the classifier is validated against the golden output (golden.txt).

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

Matlab