Altera SerialLite II IP Core User Manual

Page 103

Advertising
background image

Chapter 5: Testbench

5–17

Example Testbench – Verilog HDL

January 2014

Altera Corporation

SerialLite II MegaCore Function

User Guide

Table 5–12

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.

1

This example testbench may not match your testbench exactly.

Table 5–12. Example of a Demonstration Testbench (Part 1 of 5)

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 MegaCore function.

pkt_cnt_pri_dut = packets_to_send;

Sets the number of packets to be sent to the high priority
port of the DUT MegaCore function.

pkt_cnt_dat_sis = packets_to_send;

Sets the number of packets to be sent to the regular data
port of the SISTER MegaCore function.

pkt_cnt_pri_sis = packets_to_send;

Sets the number of packets to be sent to the high priority
port of the SISTER MegaCore function.

wait (linked_up == 1);

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

Advertising