Next you will examine the AXI Streaming transactions required to interact with the traffic generators. The provided python script performs these steps for you if you would like to provide only a numpy array. Having a better understanding of the underlying transactions can be helpful and that is what will be explained in detail now.
In the code snippet below on lines 1 to 5 the byte array to be sent needs to be broken into pieces equal to the width of the PLIO interface. Because the PLIO interface width is commonly identified with units of bits (PLIO32/64/128 are 32, 64, and 128 bits wide) the width of the transaction in bytes is divided by 8.
1 #Determine number of transactions based on
2 ## packet length and PLIO WIDTH
3 NumBytesToSend = len(iq_data_as_bytes)
4 NumBytesPerBeat = self.plio_width//8
5 NumTrans = NumBytesToSend//NumBytesPerBeat
On line 5 you see that by dividing the PLIO width in bytes by the total number of bytes you can compute how many “TVALID” transactions.
7 for i in range(NumTrans):
8
9 payload = xtlm_ipc.axi_stream_packet()
10
11 data2send = iq_data_as_bytes[(i*NumBytesPerBeat):(i*NumBytesPerBeat)+NumBytesPerBeat]
12 #Grab a "chunk" of the byte array of size PLIO
13
14 payload.data_length = NumBytesPerBeat
15 payload.data =data2send
Here you see lines 7-15 containing a for loop construction. Each iteration of the loop creates an axi_stream packet object and populates all of its elements. The data is broken into appropriately sized chunks of NumBytesPerBeat.
19 if(i == NumTrans-1):
20 payload.tlast = True
21 else:
22 payload.tlast = False
23
24
25 self.in0_util.b_transport(payload)
Finally, lines 19-25 contain the handling of the TLast as well as the actual transmission of the full payload object using the b_transport()
method.
For more information see: UG761 AXI Reference Guide.