Writing Traffic Generators in Python - 2022.2 English

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

Document ID
Release Date
2022.2 English

You must also include a traffic generator process while simulating your application to generate data traffic on the I/O traffic generators, or to capture output data from the emulation process. The Xilinx provided Python or C++ library can be used to create the traffic generator code as described below. Also, an application can communicate to multiple I/O interface. It is not necessary to have each instance of I/O utilities to be in a separate process/thread. In case your application demands it, you might consider the non-blocking version APIs (details provided in the following section).

  • For Python, set $PYTHONPATH on the command terminal:
    setenv PYTHONPATH $XILINX_VIVADO/data/emulation/hw_em/lib/python:\
  • Sample Python code to connect with the gt_master instance would look like the following:
    Blocking Send
    from xilinx_xtlm import ipc_axis_master_util
    from xilinx_xtlm import xtlm_ipc
    import struct
    import binascii
    #Instantiating AXI Master Utilities
    master_util = ipc_axis_master_util("gt_master")
    #Create payload
    payload = xtlm_ipc.axi_stream_packet()
    payload.data = "BINARY_DATA" # One way of getting "BINARY_DATA" from integer can be like payload.data = bytes(bytearray(struct.pack("i", int_number))) More info @ https://docs.python.org/3/library/struct.html
    payload.tlast = True #AXI Stream Fields
    #Optional AXI Stream Parameters
    payload.tuser = "OPTIONAL_BINARY_DATA"
    payload.tkeep = "OPTIONAL_BINARY_DATA"
    #Send Transaction
    master_util.disconnect() #Disconnect connection between Python & Emulation
  • Sample Python code to connect with the gt_slave instance would look like the following:
    Blocking Receive
    from xilinx_xtlm import ipc_axis_slave_util
    from xilinx_xtlm import xtlm_ipc
    #Instantiating AXI Slave Utilities
    slave_util = ipc_axis_slave_util("gt_slave")
    #Sample payload (Blocking Call)
    payload = slave_util.sample_transaction()
    slave_util.disconnect() #Disconnect connection between Python & Emulation
  • For non-blocking version APIs in Python, it can be found at: