def packets_write(dut, axis_writer, axilite_writer, axilite_reader, pkts, latencies, inter_packet_times): """Apply packets on DuT input.""" # start the module yield axilite_writer.write(CPUREG_OFFSET_CTRL_ACTIVE, 0x1) # wait a little bit yield wait_n_cycles(dut.clk, 10) # iterate over all packets for i, pkt in enumerate(pkts): # convert packet to AXI4-Stream data (tdata, tkeep) = packet_to_axis_data(pkt, AXIS_BIT_WIDTH) # include latency and inter-packet time in last TUSER word tuser = len(tdata) * [0] tuser[-1] = latencies[i] | (1 << 24) | (inter_packet_times[i] << 25) # write data yield axis_writer.write(tdata, tkeep, tuser) # wait random number of cycles before applying the next packet yield wait_n_cycles(dut.clk, random.randint(0, 10)) # stop the module yield axilite_writer.write(CPUREG_OFFSET_CTRL_ACTIVE, 0x0)
def packets_write(dut, axis_writer, pkts): """Apply packets on DuT input.""" for (pkt, inter_packet_cycles) in pkts: # convert pkt to AXI4-Stream data (tdata, tkeep) = packet_to_axis_data(pkt, AXIS_BIT_WIDTH) # insert inter-packet time in TUSER signal for first transfer word tuser = [inter_packet_cycles] # write AXI4-Stream data (do not insert idle gaps) yield axis_writer.write(tdata, tkeep, tuser, False)
def packets_write(dut, axis_writer, pkts): """Apply packets on DuT input.""" # iterate over all packets for pkt in pkts: # convert packet to AXI4-Stream data (tdata, tkeep) = packet_to_axis_data(pkt, AXIS_BIT_WIDTH) # apply data yield axis_writer.write(tdata, tkeep) # wait a random number of cycles before writing next packet yield wait_n_cycles(dut.clk156, randint(0, 10))
def frames_write(dut, axis_writer, frames): """Apply generated frames on DuT input.""" # iterate over frames for frame in frames: # convert frame to AXI4-Stream data (tdata, tkeep) = packet_to_axis_data(frame, AXIS_BIT_WIDTH) # write frame yield axis_writer.write(tdata, tkeep, []) # wait a random number of cycles before writing next frame yield wait_n_cycles(dut.clk, randint(0, 10))
def packets_write(dut, axis_writer, pkts, latencies, inter_packet_times): """Apply packets on DuT input.""" # iterate over all packets for i, pkt in enumerate(pkts): # convert packet to AXI4-Stream data (tdata, tkeep) = packet_to_axis_data(pkt, DATAPATH_BIT_WIDTH) # include latency and inter-packet time in last TUSER word tuser = len(tdata) * [0] tuser[-1] = latencies[i] | (1 << 24) | (inter_packet_times[i] << 25) # write data yield axis_writer.write(tdata, tkeep, tuser) # wait random number of cycles before writing the next packet yield wait_n_cycles(dut.clk, randint(0, 10))
def packets_write(dut, axis_writer, pkts): """Apply packets on DuT input.""" # iterate over all packets for pkt in pkts: # convert packet to axi stream data (tdata, tkeep) = packet_to_axis_data(pkt, AXIS_BIT_WIDTH) # if TLAST is low, TUSER input must be zero. for the last AXI4-Stream # transfer of the packet, TUSER is set to a predetermined random value tuser = len(tdata) * [0] tuser[-1] = TUSER_LSB # write data on AXI4-Stream slave interface yield axis_writer.write(tdata, tkeep, tuser) # wait a random number of cycles before applying next packet yield wait_n_cycles(dut.clk156, randint(0, 100))