SerialLite II IP Core User Guide

ID 683179
Date 7/13/2021
Public
Document Table of Contents

4.4.6. Example Testbench – Verilog HDL

Because there is no Atlantic to Atlantic score-boarding, the demonstration testbench focuses on passing error-free data rather than errored data. Any error condition that involves dropped or errored packets, must be handled in the testbench by setting proper expectations

To allow for easy modification of the demonstration testbench, its main section is marked by start–end tags:

//SERIALLITE2_TB_MAIN_START 
//SERIALLITE2_TB_MAIN_END
Note: This example testbench may not match your testbench exactly.
Table 46.  Example of a Demonstration TestbenchThe table shows and explains a demonstration testbench main section example, allowing you to easily modify the testbench. You can change the packet size, port address, number of packets, and so on, or force certain behavior.
Main Section Comments

//SERIALLITE2_TB_MAIN_START

Start of the testbench main section; the only section intended to be modified.

integer pkt_cnt_dat_dut; integer pkt_cnt_pri_dut; integer pkt_cnt_dat_sis; integer pkt_cnt_pri_sis;

Declare packet counters.

//--------------------------------------------------------- //Define the number of packets / streaming bytes to be sent //--------------------------------------------------------- integer packets_to_send; initial packets_to_send = 5; integer streaming_bytes; initial streaming_bytes = 1500; //---------------------------------------------------------

Defines the number of packets (5) or streaming bytes (1,500) to be sent.

initial begin #1;

Main initial block.

exp_tc_cnt = 1;

Sets expectation for the number of test cases (checks); this number must match the number of tc_start/tc_end pairs in the testbench, otherwise the testbench is declared INCOMPLETE.

err_limit = 0;

Sets expectation for the number of errors.

tc_start(`TBID);

Testcase start.

wait (reset_n == 1);

Waiting for the reset to complete; the reset is asserted in a separate initial block.

// initialize packet counters

 

pkt_cnt_dat_dut = packets_to_send;

Sets the number of packets to be sent to the regular data port of the DUT IP core.

pkt_cnt_pri_dut = packets_to_send;

Sets the number of packets to be sent to the high priority port of the DUT IP core.

pkt_cnt_dat_sis = packets_to_send;

Sets the number of packets to be sent to the regular data port of the SISTER IP core.

pkt_cnt_pri_sis = packets_to_send;

Sets the number of packets to be sent to the high priority port of the SISTER IP core.

wait (linked_up == 1);

Wait for DUT and SISTER to go into link-up.

fork

Launch multiple send packet loops in parallel.

begin ////////////////////////////////////////////// // Generate RDP packets for DUT ////////////////////////////////////////////// @(posedge trefclk);

agen_dat_dut.verbose(1);

agen_dat_dut.ipg(0,5); amon_dat_sis.verbose(1);

fork

while (pkt_cnt_dat_dut > 0) begin : send_loop_dat_dut

integer size;

integer err;

reg [7:0]

addr; addr = $dist_uniform(seed,0,255);

size = $dist_uniform(seed,1,1024);

err = $dist_uniform(seed,0,1);

agen_dat_dut.send_packet(addr,size,err);

reset_watchdog_timer;

pkt_cnt_dat_dut = pkt_cnt_dat_dut - 1;

end

begin

fork amon_dat_sis.wait_all_packets(packets_to_send); join

end

join

end

Send regular data packets (on Atlantic interface) to the DUT.

AGEN and AMON instantiations are set to display verbose messages.

Set AGEN to insert random inner packet gaps.

Launch two processes in parallel:

- Send regular data packets to the DUT.

Define packet size, error, address.

Packet address is a random number from 0 to 255.

Packet size is a random number from 1 to 1,024.

Packet err is a random number from 0 to 1.

Call the AGEN send packet task (regular data, DUT).

Reset watchdog with every packet being sent.

Repeat this loop pkt_cnt_dat_dut times.

- Wait for the other side (Atlantic interface of the SISTER) to receive all these packets.

begin ///////////////////////////////////////////// / // Generate HPP priority packets for SISTER ///////////////////////////////////////////// /

agen_pri_sis.verbose(1);

agen_pri_sis.ipg(0,5);

amon_pri_dut.verbose(1);

fork

while ( pkt_cnt_pri_sis > 0 ) begin : send_loop_pri_sis

integer size;

integer err;

reg [3:0] addr;

addr = $dist_uniform(seed,0,15);

size = $dist_uniform(seed,1,780);

err = ( $dist_uniform(seed,0,8) == 4 ) ? 1'b1 : 1'b0;

agen_pri_sis.send_packet(addr,size,err);

reset_watchdog_timer;

pkt_cnt_pri_sis = pkt_cnt_pri_sis - 1;

end

begin

amon_pri_dut.wait_all_packets(packets_to_send );

end

join

end

Send high priority packets (on Atlantic interface) to the SISTER IP core.

AGEN and AMON instantiations are set to display verbose messages.

Set AGEN to insert random inner packet gaps.

Launch two processes in parallel:

- Send high priority packets to the SISTER.

Define packet size, error, address.

Packet address is a random number from 0 to 15.

Packet size is a random number from 1 to 780.

Packet err is a random number from 0 to 1.

Call the AGEN send packet task (high priority, SISTER).

Reset watchdog with every packet being sent.

Repeat this loop pkt_cnt_pri_sis times.

- Wait for the other side (Atlantic interface of the DUT) to receive all these packets.

join

 

tc_end(`TBID);

exit;

end

All loops must finish (receive all packets) before exiting.

endmodule

End of test case.

Main initial block end.

//SERIALLITE2_TB_MAIN_END

End of testbench main section.