General Purpose Python API - 2024.1 English

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

Document ID
UG1393
Release Date
2024-07-03
Version
2024.1 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
The APIs are found in the following library path:
${XILINX_VIVADO}/data/emulation/python/xtlm_ipc_v2/
You need to set PYTHONPATH to point to this library:
export PYTHONPATH=${XILINX_VIVADO}/data/emulation/python/xtlm_ipc_v2/
input_port = axis_master(name)
output_port = axis_slave(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

RETURNS nothing

Parameters:

  • data: list created using create_byte_array() or conversion API described below
  • tlast: boolean value, can be true or false

For example:

input.send_data(data_byte_array, tlast)
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

RETURNS nothing

Parameters:

  • data: a byte array that can be converted with conversion API described below
receive_data_with_size()
receive_data_with_size(data, data_size)
creates a blocking call to receive a specified amount of data

RETURNS a list of specified datatype

Parameters:

  • data: a byte array that can be converted with conversion API described below
  • data_size: integer value indicating the amount of data in bytes to receive
Note: Data size is specified in bytes

For example:

output.receive_data_with_size(<recv_vector>, 512)

Where recv_vector is an empty byte array that gets filled with the data received in the form of a byte array

receive_data_on_tlast()
receive_data_on_tlast(data)
creates a blocking call returning data after receiving tlast packet

RETURNS a list of specified datatype

Parameters:

  • data: a byte array that can be converted with the conversion API described below
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