async def run_test(dut, data_in=None, codec=None, backpressure_inserter=None): dut.m_axis_tready <= 0 #dut.log.setLevel(logging.DEBUG) """ Setup testbench and run a test. """ clock = Clock(dut.axis_aclk, 10, units="ns") # Create a 10ns period clock on port clk cocotb.fork(clock.start()) # Start the clock tb = PadderTB(dut, codec, False) # Debug=False await tb.reset() dut.m_axis_tready <= 1 if backpressure_inserter is not None: tb.backpressure.start(backpressure_inserter()) # Send in the packets for transaction in data_in(): tb.s_axis.bus.tuser <= BinaryValue(80 * '0' + little_endian_codec(codec) + 32 * '0') await tb.s_axis.send(transaction, tuser=get_bytes(16, random_data())) # Wait for last transmission await RisingEdge(dut.axis_aclk) while not (dut.m_axis_tlast.value and dut.m_axis_tvalid.value and dut.m_axis_tready.value): await RisingEdge(dut.axis_aclk) for _ in range(3): await RisingEdge(dut.axis_aclk) dut._log.info("DUT testbench finished!") raise tb.scoreboard.result
def random_packet_sizes(min_size=1, max_size=150, npackets=10): """random string data of a random length""" for i in range(npackets): yield get_bytes(random.randint(min_size, max_size), random_data())
def random_hash(npackets=5): """random string data of a random length""" for _ in range(npackets): yield get_bytes(64, random_data())
def random_word(size=4): yield get_bytes(size, random_data())
def random_message(blocks512 ,min_blocks=1, max_blocks=4, npackets=4): """random string data of a random length""" if blocks512>>1: max_blocks = int(max_blocks/2) if(max_blocks == 0): max_blocks = 1 mult_blocks = 2 else: mult_blocks = 1 for _ in range(npackets): yield get_bytes(BLOCK_BYTE_WIDTH*mult_blocks*random.randint(min_blocks, max_blocks), random_data())