Writing Traffic Generators in Python - 2023.2 English

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

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

The following code snippets show the API usage in the context of Python.

You need to set PYTHONPATH as follows:

  • For example, on C Shell:
    setenv PYTHONPATH $XILINX_VIVADO/data/emulation/hw_em/lib/python: $XILINX_VIVADO/data/emulation/ip_utils/xtlm_ipc/xtlm_ipc_v1_0/python
  • Code snippet of Python Master:
    aximm_payload = xtlm_ipc.aximm_packet()
    random_packet(aximm_payload) # Custom function to set AXI Properties randomly
    #Or user can set AXI properties as required
    #aximm_payload.addr = int(random.randint(0, 1000000)*4)
    #aximm_payload.len = random.randint(1, 64)
    #aximm_payload.size = 4
     
    master_util.b_transport(aximm_payload)
    #After this call aximm_payload will have updated response as set by the AXI Slave.
  • Code snippet of Python Slave:
    aximm_payload = slave_util.sample_transaction()
    aximm_payload.resp = random.randint(0,3)
    if not aximm_payload.cmd: #if it is a read transction set Random data
        tot_bytes = aximm_payload.len * aximm_payload.size
        for i in range(0, int(tot_bytes/SIZE_OF_EACH_DATA_IN_BYTES)):
            aximm_payload.data += bytes(bytearray(struct.pack(">I", random.randint(0,60000)))) # Binary data should be aligned with C struct
             
    slave_util.send_resp(aximm_payload)