1 |
22 |
antanguay |
/**
|
2 |
|
|
* 10 GE MAC Core verification environment file.
|
3 |
|
|
* @file: env.sv
|
4 |
|
|
* @author: Pratik Mahajan
|
5 |
|
|
* @par Contact: pratik@e-pigeonpost.com
|
6 |
|
|
* @par Company: UCSC (SV 1896 Systemverilog for advanced verification course)
|
7 |
|
|
*
|
8 |
|
|
* @version: $LastChangedRevision$
|
9 |
|
|
* @par Last Changed Date:
|
10 |
|
|
* $LastChangedDate$
|
11 |
|
|
* @par Last Changed By:
|
12 |
|
|
* $LastChangedBy$
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* Environment class to contain all test components viz. driver, monitor and scoreboard.
|
17 |
|
|
* Environment instantiates driver, monitor and scoreboard, acts as a intermediatery
|
18 |
|
|
* between all of them.
|
19 |
|
|
* @class env
|
20 |
|
|
* @par
|
21 |
|
|
*/
|
22 |
|
|
|
23 |
|
|
class env;
|
24 |
|
|
|
25 |
|
|
driver macCoreDriver; ///< handle for driver type object to send data to MAC Core.
|
26 |
|
|
monitor macCoreMonitor; ///< handle for monitor type object to collect data from MAC Core.
|
27 |
|
|
scoreboard macCoreScoreboard;
|
28 |
|
|
|
29 |
|
|
mailbox driver2Scoreboard;
|
30 |
|
|
mailbox monitor2Scoreboard;
|
31 |
|
|
|
32 |
|
|
virtual macCoreInterface virtualMacCoreInterfaceDriver; ///< virtual interface to connect driver type object to MAC core RTL
|
33 |
|
|
virtual macCoreInterface virtualMacCoreInterfaceMonitor; ///< virtual interface to connect monitor type object to MAC core RTL
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* Constructor for environment class.
|
37 |
|
|
* Main purpose of the constructor is to connect virtual interfaces to respective objects
|
38 |
|
|
* and pass down proper parameters to scoreboard for checking
|
39 |
|
|
* @param driverVirtualInterface to connect interface with driver object
|
40 |
|
|
* @param monitorVirtualInterface to connect interface with monitor object
|
41 |
|
|
* @return: NA (returns handle and creates object of type environment class
|
42 |
|
|
*/
|
43 |
|
|
function new ( virtual macCoreInterface driverVirtualInterface,
|
44 |
|
|
virtual macCoreInterface monitorVirtualInterface );
|
45 |
|
|
|
46 |
|
|
this.virtualMacCoreInterfaceDriver = driverVirtualInterface;
|
47 |
|
|
this.virtualMacCoreInterfaceMonitor = monitorVirtualInterface;
|
48 |
|
|
|
49 |
|
|
driver2Scoreboard = new ();
|
50 |
|
|
monitor2Scoreboard = new ();
|
51 |
|
|
|
52 |
|
|
macCoreDriver = new (virtualMacCoreInterfaceDriver, driver2Scoreboard);
|
53 |
|
|
macCoreMonitor = new (virtualMacCoreInterfaceMonitor, monitor2Scoreboard);
|
54 |
|
|
|
55 |
|
|
macCoreScoreboard = new (driver2Scoreboard, monitor2Scoreboard);
|
56 |
|
|
|
57 |
|
|
endfunction // new
|
58 |
|
|
|
59 |
|
|
/**
|
60 |
|
|
* Init task for all testcases to initialize MAC core with pre simulation configuration.
|
61 |
|
|
* Main purpose of the task is to initialize all inputs of simple Tx Rx interface of MAC to 0
|
62 |
|
|
*/
|
63 |
|
|
task init ();
|
64 |
|
|
virtualMacCoreInterfaceMonitor.clockingTxRx.receiveReadEnable <= 0;
|
65 |
|
|
|
66 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.transmitData <= 0;
|
67 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.transmitValid <= 0;
|
68 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.transmitStartOfPacket <= 0;
|
69 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.transmitEndOfPacket <= 0;
|
70 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.transmitPacketLengthModulus <= 0;
|
71 |
|
|
|
72 |
|
|
endtask // init
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* Reset task for all testcases to put MAC Core through particular reset consitions
|
76 |
|
|
*/
|
77 |
|
|
task reset ();
|
78 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.rstTxRxInterface_n <= 0;
|
79 |
|
|
virtualMacCoreInterfaceDriver.clockingXGMIIRx.rstXGMIIInterfaceRx_n <= 0;
|
80 |
|
|
virtualMacCoreInterfaceDriver.clockingXGMIITx.rstXGMIIInterfaceTx_n <= 0;
|
81 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.rstWishboneInterface <= 0;
|
82 |
|
|
|
83 |
|
|
repeat (10) @(virtualMacCoreInterfaceDriver.clockingTxRx);
|
84 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.rstTxRxInterface_n <= 1;
|
85 |
|
|
virtualMacCoreInterfaceDriver.clockingXGMIIRx.rstXGMIIInterfaceRx_n <= 1;
|
86 |
|
|
virtualMacCoreInterfaceDriver.clockingXGMIITx.rstXGMIIInterfaceTx_n <= 1;
|
87 |
|
|
virtualMacCoreInterfaceDriver.clockingTxRx.rstWishboneInterface <= 1;
|
88 |
|
|
|
89 |
|
|
endtask // reset
|
90 |
|
|
|
91 |
|
|
/**
|
92 |
|
|
* Run task for all testcases to start simulating / executing instructions / consuming time.
|
93 |
|
|
* Main purpose of the task is to instantiate send_packet and collect_packet and call scoreboard checking if available
|
94 |
|
|
*/
|
95 |
|
|
task run (int noOfPackets = 10, int lengthOfFrame = 60);
|
96 |
|
|
|
97 |
|
|
fork
|
98 |
|
|
for (int i = 0; i < noOfPackets; i++)
|
99 |
|
|
begin
|
100 |
|
|
@(virtualMacCoreInterfaceDriver.clockingTxRx)
|
101 |
|
|
$display ("=========Sending Packet #%0d============ at time %0t\n", i, $time);
|
102 |
|
|
macCoreDriver.send_packet(lengthOfFrame);
|
103 |
|
|
end
|
104 |
|
|
for (int i = 0; i < noOfPackets; i++)
|
105 |
|
|
begin
|
106 |
|
|
wait (virtualMacCoreInterfaceMonitor.clockingTxRx.receiveAvailable == 1'b1);
|
107 |
|
|
$display ("========Collecting Packet #%0d===========\n", i);
|
108 |
|
|
macCoreMonitor.collect_packet();
|
109 |
|
|
end
|
110 |
|
|
join
|
111 |
|
|
|
112 |
|
|
endtask // run
|
113 |
|
|
|
114 |
|
|
task validate (int noOfPackets = 10, int lengthOfFrame = 60);
|
115 |
|
|
|
116 |
|
|
for (int i = 0; i < noOfPackets; i++)
|
117 |
|
|
begin
|
118 |
|
|
for (int j = 0; j < lengthOfFrame; j += 8)
|
119 |
|
|
begin
|
120 |
|
|
int bytesInFrame;
|
121 |
|
|
|
122 |
|
|
if ( (j+8) > lengthOfFrame) bytesInFrame = lengthOfFrame % 8;
|
123 |
|
|
else bytesInFrame = 0;
|
124 |
|
|
macCoreScoreboard.compare (driver2Scoreboard, monitor2Scoreboard, bytesInFrame);
|
125 |
|
|
end
|
126 |
|
|
end
|
127 |
|
|
endtask // validate
|
128 |
|
|
|
129 |
|
|
endclass // env
|