1 |
22 |
antanguay |
|
2 |
|
|
/**
|
3 |
|
|
* packet class file for 10 GE MAC Core.
|
4 |
|
|
* The file holds packet class according to specs
|
5 |
|
|
* @file: packet.sv
|
6 |
|
|
* @author: Pratik Mahajan
|
7 |
|
|
* @par Contact: pratik@e-pigeonpost.com
|
8 |
|
|
* @par Company: NA (UCSC systemverilog for adv. verification course)
|
9 |
|
|
*
|
10 |
|
|
* @version:
|
11 |
|
|
* $LastChangedRevision$
|
12 |
|
|
* @par Last Changed Date:
|
13 |
|
|
* $LastChangedDate$
|
14 |
|
|
* @par Last Changed By:
|
15 |
|
|
* $LastChangedBy$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Packet class to represent packet for ethernet MAC core as per specs.
|
21 |
|
|
* Class declaration and related methods
|
22 |
|
|
* @class: packet
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
class packet;
|
26 |
|
|
|
27 |
|
|
rand bit [7:0] packetData [8]; ///< random data variable used to send data in DUT
|
28 |
|
|
bit [7:0] receivedData [8]; ///< placeholder variable for received data from DUT -- can't be same as packetData since transmission and reception can be full-duplex
|
29 |
|
|
bit [2:0] packetLengthModulus; ///< modulus to report number of octates in last word of communication
|
30 |
|
|
bit startOfPacket;
|
31 |
|
|
bit endOfPacket;
|
32 |
|
|
bit packetValid;
|
33 |
|
|
|
34 |
|
|
bit transmitFIFOFull;
|
35 |
|
|
bit receiveReadEnable;
|
36 |
|
|
bit receiveError;
|
37 |
|
|
bit receiveAvailable;
|
38 |
|
|
|
39 |
|
|
static bit [15:0] transmitPktId;
|
40 |
|
|
static bit [15:0] receivePktId;
|
41 |
|
|
|
42 |
|
|
typeOfPkt pktClassPktType;
|
43 |
|
|
|
44 |
|
|
//`define printData { packetData[7], packetData[6], packetData[5], packetData[4], packetData[3], packetData[2], packetData[1], packetData[0] }
|
45 |
|
|
|
46 |
|
|
//`define printReceipt { receivedData [7], receivedData[6], receivedData[5], receivedData[4], receivedData[3], receivedData[2], receivedData[1], receivedData[0] }
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* Constructor for packet class.
|
50 |
|
|
* It simply increments count of packet id depending on type of packet
|
51 |
|
|
* @param typeOfPkt: input type to count number of packets sent / received.
|
52 |
|
|
* @return : NA (creates objects and returns handle)
|
53 |
|
|
*/
|
54 |
|
|
function new (input int pktClassPktType = NONE);
|
55 |
|
|
if (pktClassPktType == TRANSMIT)
|
56 |
|
|
transmitPktId++;
|
57 |
|
|
|
58 |
|
|
if (pktClassPktType == RECEIVE)
|
59 |
|
|
receivePktId++;
|
60 |
|
|
endfunction // new
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* Print function for packet class.
|
64 |
|
|
* prints relevant information for each frame transfered
|
65 |
|
|
* @param: NA
|
66 |
|
|
* @return: NA
|
67 |
|
|
*/
|
68 |
|
|
function void print (input int pktClassPktType = NONE);
|
69 |
|
|
if (pktClassPktType == TRANSMIT)
|
70 |
|
|
$display (" [Time %0t ps] SOP = %b, Transmitted Data = %x, EOP = %b, Modulus = %h ", $time, startOfPacket, `transmitData, endOfPacket, packetLengthModulus);
|
71 |
|
|
if (pktClassPktType == RECEIVE)
|
72 |
|
|
$display (" [Time %0t ps] SOP = %b, Received Data = %x, EOP = %b, Modulus = %h ", $time, startOfPacket, `receivedData, endOfPacket, packetLengthModulus);
|
73 |
|
|
endfunction: print
|
74 |
|
|
|
75 |
|
|
endclass // packet
|