Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fc / vera / stubs / l2_packet.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: l2_packet.vr
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35#include <vera_defines.vrh>
36#include <VeraListProgram.vrh>
37#include <ListMacros.vrh>
38#include "l2_stub_defines.vri"
39#include "std_display_class.vrh"
40
41class l2_packet {
42
43 // Transactor Name
44 string XactorName;
45 StandardDisplay dbg;
46
47 // Data fields: Add any data field related to a transaction
48 protected bit [ADDR_WIDTH-1:0] address; // Address field
49 protected bit [DATA_WIDTH-1:0] data; // Data field
50 protected bit [DATA_WIDTH-1:0] read_data; // Data to be sent back for read dma
51 protected bit [7:0] bytemask; // Which bytes to ignore
52 protected bit [15:0] tag; // Identifying tag needed for response
53 protected bit [3:0] opes; // ordered, posted, error, source (1=DMU, 0=NIU)
54 protected bit ordered; // SIU needs to know if it is ordered
55 protected bit posted; // SIU needs to know if it is posted
56 protected bit error; // Received a parity or UE error
57 protected bit source; // 1=DMU, 0=NIU
58 protected bit [2:0] bank_number; // Which L2 bank the packet goes to
59 protected bit [MAX_TRANSACTIONS:0] id; // Packet ID from the testbench (if needed)
60 protected bit last_packet; // This signifies the end of a group of packets
61
62 task new(string _XactorName, StandardDisplay _dbg);
63
64 // FieldType is a string that indicates which field to set. FieldValue is the actual value
65 // that the packet field will be set to
66 task set(string FieldType,
67 bit [MAX_FIELD_WIDTH-1:0] FieldValue);
68
69 // FieldType is a string that indicates which field to get. FieldValue is the returned value
70 // of the field indicated by FieldType
71 function bit [MAX_FIELD_WIDTH-1:0] get(string FieldType);
72
73 // This function will return a "compressed" expected value using the data fields of the
74 // packet. This task is not part of the Xactor Framework but has to be implemented if the
75 // transactor is going to expect transactions.
76 function bit [MAX_TOTAL_FIELD_WIDTH-1:0] FormExpected();
77
78 // Forms and return a packet object with the necessary information before
79 // it is sent to the drive manager.
80 task FormDriven();
81
82 // Compares two packets and return 1 if the compare operation is successful and 0 otherwise.
83 function bit compare(l2_packet packet);
84
85 // This task will display the contents of the packet. TypeRep is the report type used
86 // when printing the packet through the Report utility.
87 task display(string Message, bit error = 0);
88
89 // This task will reset the fields of the packet
90 task reset();
91
92 function l2_packet copy();
93
94} // end of packet sub-class
95
96MakeVeraList(l2_packet);
97
98 ////////////////////////
99 // Definitions
100 /////////////////
101
102 // This method might not need customization
103 task l2_packet::new(string _XactorName, StandardDisplay _dbg) {
104
105 XactorName = _XactorName; // Name of transactor
106 dbg = _dbg;
107
108 this.reset(); // Reset this packet
109 }
110
111 // FieldType is a string that indicates which field to set. FieldValue is the actual value
112 // that the packet field will be set to
113 // This method needs customization.
114 task l2_packet::set(string FieldType, bit [MAX_FIELD_WIDTH-1:0] FieldValue) {
115
116 case (FieldType) {
117 // CUSTOMIZE
118 // Add a case element for every field of the packet.
119 "address" : address = FieldValue[ADDR_WIDTH-1:0];
120 "data" : data = FieldValue[DATA_WIDTH-1:0];
121 "read_data" : read_data = FieldValue[DATA_WIDTH-1:0];
122 "bytemask" : bytemask = FieldValue[7:0];
123 "tag" : tag = FieldValue[15:0];
124 "opes" : opes = FieldValue[3:0];
125 "ordered" : ordered = FieldValue[0];
126 "posted" : posted = FieldValue[0];
127 "error" : error = FieldValue[0];
128 "source" : source = FieldValue[0];
129 "bank_number" : bank_number = FieldValue[2:0];
130 "id" : id = FieldValue;
131 "last_packet" : last_packet = FieldValue[0];
132 default: dbg.dispmon(XactorName, MON_ERR, psprintf("The field %0s is not defined", FieldType));
133 }
134 }
135
136 // FieldType is a string that indicates which field to get. FieldValue is the returned value
137 // of the field indicated by FieldType
138 // This method needs customization.
139 function bit [MAX_FIELD_WIDTH-1:0] l2_packet::get(string FieldType) {
140
141 case (FieldType) {
142 // CUSTOMIZE
143 // Add a case element for every field of the packet
144 "address" : get = address;
145 "data" : get = data;
146 "read_data" : get = read_data;
147 "bytemask" : get = bytemask;
148 "tag" : get = tag;
149 "opes" : get = opes;
150 "ordered" : get = ordered;
151 "posted" : get = posted;
152 "error" : get = error;
153 "source" : get = source;
154 "bank_number" : get = bank_number;
155 "id" : get = id;
156 "last_packet" : get = last_packet;
157 default : dbg.dispmon(XactorName, MON_ERR, psprintf("The field %0s is not defined", FieldType));
158 }
159 }
160
161 // This function will return a "compressed" expected value using the data fields of the
162 // packet. This task is not part of the Xactor Framework but has to be implemented if the
163 // transactor is going to expect transactions.
164 // This method needs customization.
165 function bit [MAX_TOTAL_FIELD_WIDTH-1:0] l2_packet::FormExpected() {
166
167 FormExpected = {address, data, ordered, posted, error, source, bank_number};
168 }
169
170 // Forms and return a packet object with the necessary information before
171 // it is sent to the drive manager.
172 // This method needs customization.
173 task l2_packet::FormDriven() {
174
175 }
176
177 function bit l2_packet::compare(l2_packet packet) {
178
179 integer i;
180 bit [DATA_WIDTH-1:0] temp_data;
181 bit data_good = 1;
182
183 temp_data = packet.get("data");
184 if (|temp_data[511:256] == 0) {
185 for (i = 0; i < 8; i++) {
186 if (bytemask[i]) {
187 if (temp_data[8*i+7:8*i] !== data[8*i+7:8*i]) {
188 data_good = 0;
189 }
190 }
191 }
192 } else {
193 if (temp_data !== data) {
194 data_good = 0;
195 }
196 }
197
198 if ((packet.get("address") === address) && data_good &&
199 (packet.get("bytemask") === bytemask) && (packet.get("opes") === opes) &&
200 (packet.get("bank_number") === bank_number)) {
201 compare = 1;
202 } else {
203 compare = 0;
204 }
205
206 }
207
208 // This task will display the contents of the packet. TypeRep is the report type used
209 // when printing the packet through the Report utility.
210 // This method needs customization.
211 task l2_packet::display(string message, bit error = 0) {
212
213 if (error) {
214 dbg.dispmon(XactorName, MON_ERR, psprintf("%0s\tAddress: %0h Data: %0h bytemask: %0h Tag: %0h Opes: %0b Bank: %0d\n", message, address, data, bytemask, tag, opes, bank_number));
215 } else {
216 dbg.dispmon(XactorName, MON_ALWAYS, psprintf("%0s\tAddress: %0h Data: %0h bytemask: %0h Tag: %0h Opes: %0b Bank: %0d\n", message, address, data, bytemask, tag, opes, bank_number));
217 }
218 }
219
220 // This task will reset the fields of the packet
221 // This method needs customization.
222 task l2_packet::reset() {
223
224 address = 0;
225 data = 0;
226 read_data = 0;
227 bytemask = 0;
228 tag = 0;
229 opes = 0;
230 ordered = 0;
231 posted = 0;
232 error = 0;
233 source = 0;
234 bank_number = 0;
235 id = 0;
236 last_packet = 1;
237 }
238
239 function l2_packet l2_packet::copy() {
240
241 l2_packet new_pkt = new("Expect", dbg);
242
243 new_pkt.set("address", address);
244 new_pkt.set("data", data);
245 new_pkt.set("read_data", read_data);
246 new_pkt.set("bytemask", bytemask);
247 new_pkt.set("tag", tag);
248 new_pkt.set("opes", opes);
249 new_pkt.set("bank_number", bank_number);
250 new_pkt.set("id", id);
251 new_pkt.set("last_packet", last_packet);
252
253 copy = new_pkt;
254 }
255