General Purpose C++ API - 2023.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2023-12-13
Version
2023.2 English

Here is the list of general purpose APIs that can be used with custom user-defined datatypes. With these API you can send and receive data in the form of byte_arrays only. You must convert your custom datatype to byte_arrays prior to transport, and convert the received value back to your custom datatype for use by your application. Conversion API are provided as described below.

Instantiating Classes to Send or Receive Data
xtlm_ipc::axis_master   input_port(std::string name)
xtlm_ipc::axis_slave      output_port(std::string name)

Parameters:
  name → string matching the AXI4-Stream interface 
send_data()
Tip: The general purpose API expects data in the form of byte_array only. To convert it from a user data type, use the conversion API such as uInt16ToByteArray described below.
send_data(data, tlast)
creates a non-blocking call to send data

Parameters: 
  RETURNS nothing
  data → std::vector<char>
  tlast → boolean value, can be true or false
receive_data()
Tip: The general purpose API expects data in the form of byte_array only. To convert it into a user readable format with data types after receiving it, use the conversion API such as byteArrayTouInt16 described below.
receive_data(data)
creates a blocking call to receive data

Parameters:
  RETURNS the received data as a byte_array
  data → std::vector<char>

The following example creates an empty vector for data and receives data:

std::vector<char> recv_data; 
output.receive_data(<recv_data>)
receive_data_with_size()
receive_data_with_size(data, data_size)
creates a blocking call to receive a specified amount of data

Parameters:
  RETURNS the received data as a byte_array
  data → std::vector<char>
  data_size -> integer value indicating the amount of data in bytes to receive

Note: data_size is specified in bytes

The following example creates an empty vector for data and receives data:

std::vector<char> recv_data; 
output.receive_data_with_size(<recv_data>, 1024)
receive_data_on_tlast()
receive_data_on_tlast(data)
creates a blocking call returning data after receiving tlast packet

Parameters:
  RETURNS the received data as a byte_array
  data → std::vector<char>

Note: The datatype must be specified during object instantiation

The following example creates an empty vector for data and receives data on the TLAST signal:

std::vector<char> recv_data; 
output.receive_data_on_tlast(<recv_data>)
Table 1. Byte_Array Conversion API
API Description

byte_array = input_port.uInt8ToByteArray(user_list)

byte_array = input_port.uInt16ToByteArray(user_list)

byte_array = input_port.uInt32ToByteArray(user_list)

byte_array = input_port.uInt64ToByteArray(user_list)

byte_array = input_port.int8ToByteArray(user_list)

byte_array = input_port.int16ToByteArray(user_list)

byte_array = input_port.int32ToByteArray(user_list)

byte_array = input_port.int64ToByteArray(user_list)

byte_array = input_port.floatToByteArray(user_list)

byte_array = input_port.doubleToByteArray(user_list)

byte_array = input_port.bfloat16ToByteArray(user_list)

Convert the specified data type to byte_array value to send the data
byte_array = input_port.uInt64ToByteArray(user_list)

Parameters:
  Returns list of specified data type converted from byte_array
  user_list → std::vector<T> 
  // T is the data type present in function signature. 
  // For example in byteArrayToFloat user_list is a vector of type float
  byte_array → list created using create_byte_array or conversion APIs

user_list = output_port.byteArrayTouInt8(byte_array)

user_list = output_port.byteArrayTouInt16(byte_array)

user_list = output_port.byteArrayTouInt32(byte_array)

user_list = output_port.byteArrayTouInt64(byte_array)

user_list = output_port.byteArrayToInt8(byte_array)

user_list = output_port.byteArrayToInt16(byte_array)

user_list = output_port.byteArrayToInt32(byte_array)

user_list = output_port.byteArrayToInt64(byte_array)

user_list = output_port.byteArrayToFloat(byte_array)

user_list = output_port.byteArrayToDouble(byte_array)

user_list = output_port.byteArrayToBfloat16(byte_array)

Convert the byte_array value to the specified data type after receiving
user_list = output_port.byteArrayTouInt16(byte_array)

Parameters:
  Returns list of specified data type converted from byte_array
  byte_array → list created using create_byte_array or conversion APIs
  user_list → std::vector<T> 
  // T is the data type present in function signature. 
  // For example in byteArrayToFloat user_list is a vector of type float