Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuPioMRdStr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuPioMRdStr.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 ============================================
35class PioMRdPEUStr extends PioBasePEUStr {
36
37
38 // ******************************************************************
39 // The Test Environment objects need to execute the strategy.
40 // ******************************************************************
41 protected PEUTestEnv _env;
42 protected integer _errQueue;
43
44
45 // ******************************************************************
46 // TLP Fields - These fields will be randomized using the parameters
47 // in the following section, and obeying the constraints defined
48 // within this class.
49 //
50 // Request & Completion Field Pairs
51 // ******************************************************************
52 protected bit [1:0] _format_req;
53 protected bit [1:0] _format_cpl;
54 protected bit [4:0] _type_req;
55 protected bit [4:0] _type_cpl;
56
57 protected bit [2:0] _tc;
58
59 protected bit _td_req;
60 protected bit _td_cpl;
61 protected bit _ep_req;
62 protected bit _ep_cpl;
63
64 protected bit [1:0] _attr;
65 protected rand bit [9:0] _len_req;
66 protected bit [9:0] _len_cpl;
67 protected bit [15:0] _req_id;
68 protected bit [7:0] _tag;
69 protected rand bit [31:0] _addr_lsb;
70 protected rand bit [31:0] _addr_msb;
71
72 protected rand bit [3:0] _last_dwbe;
73 protected rand bit [3:0] _first_dwbe;
74
75 protected bit [15:0] _cpl_id;
76 protected bit [2:0] _cpl_status;
77 protected bit _bcm;
78 protected bit [11:0] _byte_count;
79 protected bit [6:0] _lower_addr;
80 protected integer _data;
81
82 protected bit [PEC_PCI__HDR] reqHdr;
83 protected bit [PEC_PCI__HDR] cplHdr;
84 protected bit [PEC_PCI__HDR] urHdr;
85
86 // ******************************************************************
87 // The following constraint is used to generate the correct values
88 // for the TLP.
89 // ******************************************************************
90 constraint generate_tlp {
91
92 this._len_req in {this._len_min : this._len_max};
93
94 this._addr_msb in {this._addr_msb_min : this._addr_msb_max};
95
96 this._addr_lsb in {this._addr_lsb_min : this._addr_lsb_max};
97 (this._addr_lsb[5:2] + this._len_req) <= 16;
98
99 this._first_dwbe >= this._first_dwbe_min;
100 this._first_dwbe <= this._first_dwbe_max;
101 if (this._len_req > 10'h_001)
102 this._first_dwbe != 4'b_0000;
103 if (((this._len_req == 10'h_002) && (this._addr_lsb[2] != 1'b_0)) ||
104 (this._len_req >= 10'h_003))
105 this._first_dwbe in { 4'b_1111, 4'b_1110, 4'b_1100, 4'b_1000 };
106
107 this._last_dwbe >= this._last_dwbe_min;
108 this._last_dwbe <= this._last_dwbe_max;
109 if (this._len_req == 10'h_001) this._last_dwbe == 4'b_0000;
110 if (this._len_req > 10'h_001) this._last_dwbe != 4'b_0000;
111 if (((this._len_req == 10'h_002) && (this._addr_lsb[2] != 1'b_0)) ||
112 (this._len_req >= 10'h_003))
113 this._last_dwbe in { 4'b_1111, 4'b_0111, 4'b_0011, 4'b_0001 };
114 }
115
116
117 // ******************************************************************
118 // Constructor
119 // ******************************************************************
120 public task new(PEUTestEnv a_env, (integer a_errQueue = 'bx));
121
122 // ******************************************************************
123 // Sets the packet parameters
124 // ******************************************************************
125 public task SetPacketParams();
126
127 // ******************************************************************
128 // Execute the strategy. Drive a TLP into the ILU, and expect it out
129 // of the PEU.
130 // ******************************************************************
131 public task Execute();
132}
133
134
135
136//-------------------------------------------------------------------
137// Method Name:
138// Description:
139//-------------------------------------------------------------------
140task PioMRdPEUStr::new(PEUTestEnv a_env, (integer a_errQueue = 'bx)) {
141
142
143 super.new(a_env);
144 this._env = a_env;
145 this._errQueue = a_errQueue;
146}
147
148
149
150//-------------------------------------------------------------------
151// Method Name:
152// Description:
153//-------------------------------------------------------------------
154task PioMRdPEUStr::SetPacketParams() {
155
156 integer pass_constrain = 0;
157 this._env.allocRdTag(this._tag);
158
159
160 this._type_req = PEC_PCI__TYPE_MEM;
161 this._type_cpl = PEC_PCI__TYPE_CPL;
162 this._tc = 3'b_000;
163 this._td_req = 1'b_0;
164 this._ep_req = 1'b_0;
165 this._attr = 2'b_00;
166 this._req_id = 16'h_0000;
167
168
169 this._cpl_id = urandom_range(this._cpl_id_max, this._cpl_id_min);
170 this._data = urandom_range(this._data_max, this._data_min);
171
172
173 randcase {
174 this._format_req_prob_3dw : this._format_req = PEC_PCI__FMT_NO_DATA_3DW;
175 this._format_req_prob_4dw : this._format_req = PEC_PCI__FMT_NO_DATA_4DW;
176 }
177
178 randcase {
179 this._td_cpl_prob_false : this._td_cpl = 1'b_0;
180 this._td_cpl_prob_true : this._td_cpl = 1'b_1;
181 }
182
183 randcase {
184 this._ep_cpl_prob_false : this._ep_cpl = 1'b_0;
185 this._ep_cpl_prob_true : this._ep_cpl = 1'b_1;
186 }
187
188 randcase {
189 this._cpl_status_prob_sc : this._cpl_status = PEC_PCI__CPL_STATUS_SC;
190 this._cpl_status_prob_ur : this._cpl_status = PEC_PCI__CPL_STATUS_UR;
191 this._cpl_status_prob_crs : this._cpl_status = PEC_PCI__CPL_STATUS_CRS;
192 this._cpl_status_prob_ca : this._cpl_status = PEC_PCI__CPL_STATUS_CA;
193 this._cpl_status_prob_rsvd1 : this._cpl_status = PEC_PCI__CPL_STATUS_RSVD1;
194 this._cpl_status_prob_rsvd2 : this._cpl_status = PEC_PCI__CPL_STATUS_RSVD2;
195 this._cpl_status_prob_rsvd3 : this._cpl_status = PEC_PCI__CPL_STATUS_RSVD3;
196 this._cpl_status_prob_rsvd4 : this._cpl_status = PEC_PCI__CPL_STATUS_RSVD4;
197 }
198
199 randcase {
200 this._bcm_prob_false : this._bcm = 1'b_0;
201 this._bcm_prob_true : this._bcm = 1'b_1;
202 }
203
204// 8/19/06 Fu: bypass randomize
205#ifdef N2_FC
206 while (!pass_constrain)
207 {
208 this._len_req = urandom_range(this._len_max, this._len_min);
209 this._addr_lsb = urandom_range(this._addr_lsb_max, this._addr_lsb_min);
210 this._addr_msb = urandom_range(this._addr_msb_max, this._addr_msb_min);
211
212 pass_constrain = ((this._addr_lsb[5:2] + this._len_req) <= 16) ? 1 : 0;
213 printf ("GATE DEBUG RANDOMIZE: addr_msb = %x, addr_lsb = %x, len = %x\n", _addr_msb, _addr_lsb, _len_req);
214
215 }
216
217 pass_constrain = 0;
218 while (!pass_constrain)
219 {
220 this._first_dwbe = urandom_range(this._first_dwbe_max, this._first_dwbe_min);
221 pass_constrain = 1;
222 if (this._len_req > 10'h_001)
223 if (this._first_dwbe == 4'b_0000) pass_constrain = 0;
224 if (((this._len_req == 10'h_002) && (this._addr_lsb[2] != 1'b_0)) ||
225 (this._len_req >= 10'h_003))
226 if ((_first_dwbe != 4'b1111) && (_first_dwbe != 4'b1110) && (_first_dwbe != 4'b1100) && (_first_dwbe != 4'b1000)) pass_constrain = 0;
227 printf ("GATE DEBUG RANDOMIZE: first_dwbe = %x\n", _first_dwbe);
228 }
229
230 pass_constrain = 0;
231 while (!pass_constrain)
232 {
233 this._last_dwbe = urandom_range(this._last_dwbe_max, this._last_dwbe_min);
234 pass_constrain = 1;
235 if (this._len_req == 10'h_001)
236 if (this._last_dwbe != 4'b_0000) pass_constrain = 0;
237 if (this._len_req > 10'h_001)
238 if (this._last_dwbe == 4'b_0000) pass_constrain = 0;
239 if (((this._len_req == 10'h_002) && (this._addr_lsb[2] != 1'b_0)) ||
240 (this._len_req >= 10'h_003))
241 if ((_last_dwbe != 4'b1111) && (_last_dwbe != 4'b0111) && (_last_dwbe != 4'b0011) && (_last_dwbe != 4'b0001)) pass_constrain = 0;
242 printf ("GATE DEBUG RANDOMIZE: last_dwbe = %x\n", _last_dwbe);
243 }
244//
245#else
246
247 if( this.randomize() != OK ) {
248 _env.Report.report(RTYP_TEST_ERROR,"PioMRdPEUStr::SetPacketParams - randomize failure \n" );
249 }
250#endif
251
252 this._format_cpl = (this._cpl_status === PEC_PCI__CPL_STATUS_SC) ?
253 PEC_PCI__FMT_DATA_3DW : PEC_PCI__FMT_NO_DATA_3DW;
254
255 this._len_cpl = (this._cpl_status === PEC_PCI__CPL_STATUS_SC) ?
256 this._len_req : 10'h_000;
257
258
259 this._byte_count =
260 {this._first_dwbe, this._last_dwbe} =?= {4'b_1111, 4'b_0000} ? 12'h_004 :
261 {this._first_dwbe, this._last_dwbe} =?= {4'b_1101, 4'b_0000} ? 12'h_004 :
262 {this._first_dwbe, this._last_dwbe} =?= {4'b_1011, 4'b_0000} ? 12'h_004 :
263 {this._first_dwbe, this._last_dwbe} =?= {4'b_1001, 4'b_0000} ? 12'h_004 :
264 {this._first_dwbe, this._last_dwbe} =?= {4'b_0111, 4'b_0000} ? 12'h_003 :
265 {this._first_dwbe, this._last_dwbe} =?= {4'b_0101, 4'b_0000} ? 12'h_003 :
266 {this._first_dwbe, this._last_dwbe} =?= {4'b_1110, 4'b_0000} ? 12'h_003 :
267 {this._first_dwbe, this._last_dwbe} =?= {4'b_1010, 4'b_0000} ? 12'h_003 :
268 {this._first_dwbe, this._last_dwbe} =?= {4'b_0011, 4'b_0000} ? 12'h_002 :
269 {this._first_dwbe, this._last_dwbe} =?= {4'b_0110, 4'b_0000} ? 12'h_002 :
270 {this._first_dwbe, this._last_dwbe} =?= {4'b_1100, 4'b_0000} ? 12'h_002 :
271 {this._first_dwbe, this._last_dwbe} =?= {4'b_0001, 4'b_0000} ? 12'h_001 :
272 {this._first_dwbe, this._last_dwbe} =?= {4'b_0010, 4'b_0000} ? 12'h_001 :
273 {this._first_dwbe, this._last_dwbe} =?= {4'b_0100, 4'b_0000} ? 12'h_001 :
274 {this._first_dwbe, this._last_dwbe} =?= {4'b_1000, 4'b_0000} ? 12'h_001 :
275 {this._first_dwbe, this._last_dwbe} =?= {4'b_0000, 4'b_0000} ? 12'h_001 :
276 {this._first_dwbe, this._last_dwbe} =?= {4'b_xxx1, 4'b_1xxx} ? 4 * this._len_req - 0 :
277 {this._first_dwbe, this._last_dwbe} =?= {4'b_xxx1, 4'b_01xx} ? 4 * this._len_req - 1 :
278 {this._first_dwbe, this._last_dwbe} =?= {4'b_xx10, 4'b_1xxx} ? 4 * this._len_req - 1 :
279 {this._first_dwbe, this._last_dwbe} =?= {4'b_xxx1, 4'b_001x} ? 4 * this._len_req - 2 :
280 {this._first_dwbe, this._last_dwbe} =?= {4'b_xx10, 4'b_01xx} ? 4 * this._len_req - 2 :
281 {this._first_dwbe, this._last_dwbe} =?= {4'b_x100, 4'b_1xxx} ? 4 * this._len_req - 2 :
282 {this._first_dwbe, this._last_dwbe} =?= {4'b_xxx1, 4'b_0001} ? 4 * this._len_req - 3 :
283 {this._first_dwbe, this._last_dwbe} =?= {4'b_xx10, 4'b_001x} ? 4 * this._len_req - 3 :
284 {this._first_dwbe, this._last_dwbe} =?= {4'b_x100, 4'b_01xx} ? 4 * this._len_req - 3 :
285 {this._first_dwbe, this._last_dwbe} =?= {4'b_1000, 4'b_1xxx} ? 4 * this._len_req - 3 :
286 {this._first_dwbe, this._last_dwbe} =?= {4'b_xx10, 4'b_0001} ? 4 * this._len_req - 4 :
287 {this._first_dwbe, this._last_dwbe} =?= {4'b_x100, 4'b_001x} ? 4 * this._len_req - 4 :
288 {this._first_dwbe, this._last_dwbe} =?= {4'b_1000, 4'b_01xx} ? 4 * this._len_req - 4 :
289 {this._first_dwbe, this._last_dwbe} =?= {4'b_x100, 4'b_0001} ? 4 * this._len_req - 5 :
290 {this._first_dwbe, this._last_dwbe} =?= {4'b_1000, 4'b_001x} ? 4 * this._len_req - 5 :
291 {this._first_dwbe, this._last_dwbe} =?= {4'b_1000, 4'b_0001} ? 4 * this._len_req - 6 :
292 12'h_xxx;
293
294
295 this._lower_addr =
296 this._first_dwbe =?= 4'b_0000 ? ({this._addr_lsb[6:2], 2'b_00}) :
297 this._first_dwbe =?= 4'b_xxx1 ? ({this._addr_lsb[6:2], 2'b_00}) :
298 this._first_dwbe =?= 4'b_xx10 ? ({this._addr_lsb[6:2], 2'b_01}) :
299 this._first_dwbe =?= 4'b_x100 ? ({this._addr_lsb[6:2], 2'b_10}) :
300 this._first_dwbe =?= 4'b_1000 ? ({this._addr_lsb[6:2], 2'b_11}) :
301 7'h_xx;
302
303
304 reqHdr [PEC_PCI__HDR] = {128{1'b_0}};
305 reqHdr [PEC_PCI__FMT] = this._format_req;
306 reqHdr [PEC_PCI__TYPE] = this._type_req;
307 reqHdr [PEC_PCI__TC] = this._tc;
308 reqHdr [PEC_PCI__TD] = this._td_req;
309 reqHdr [PEC_PCI__EP] = this._ep_req;
310 reqHdr [PEC_PCI__ATTR] = this._attr;
311 reqHdr [PEC_PCI__LEN] = this._len_req;
312 reqHdr [PEC_PCI__REQ_ID] = this._req_id;
313 reqHdr [PEC_PCI__TLP_TAG] = this._tag;
314 reqHdr [PEC_PCI__LAST_DWBE] = this._last_dwbe;
315 reqHdr [PEC_PCI__FIRST_DWBE] = this._first_dwbe;
316 reqHdr [PEC_PCI__ADDR] = (this._format_req[0] === 1'b1) ?
317 ({this._addr_msb, this._addr_lsb[31:2], 2'b_00}) :
318 ({this._addr_lsb[31:2], 2'b_00, 32'h_0000_0000});
319
320 cplHdr [PEC_PCI__HDR] = {128{1'b_0}};
321 cplHdr [PEC_PCI__FMT] = this._format_cpl;
322 cplHdr [PEC_PCI__TYPE] = this._type_cpl;
323 cplHdr [PEC_PCI__TC] = this._tc;
324 cplHdr [PEC_PCI__TD] = this._td_cpl;
325 cplHdr [PEC_PCI__EP] = this._ep_cpl;
326 cplHdr [PEC_PCI__ATTR] = this._attr;
327 cplHdr [PEC_PCI__LEN] = this._len_cpl;
328 cplHdr [PEC_PCI__CPL_ID] = this._cpl_id;
329 cplHdr [PEC_PCI__CPL_STATUS] = this._cpl_status;
330 cplHdr [PEC_PCI__BCM] = this._bcm;
331 cplHdr [PEC_PCI__BYTECOUNT] = this._byte_count;
332 cplHdr [PEC_PCI__CPL_REQ_ID] = this._req_id;
333 cplHdr [PEC_PCI__CPL_TAG] = this._tag;
334 cplHdr [PEC_PCI__LOWADDR] = this._lower_addr;
335
336 urHdr [PEC_PCI__HDR] = {128{1'b_0}};
337 urHdr [PEC_PCI__FMT] = this._format_cpl;
338 urHdr [PEC_PCI__TYPE] = this._type_cpl;
339 urHdr [PEC_PCI__TC] = this._tc;
340 urHdr [PEC_PCI__TD] = this._td_cpl;
341 urHdr [PEC_PCI__EP] = this._ep_cpl;
342 urHdr [PEC_PCI__ATTR] = this._attr;
343 urHdr [PEC_PCI__LEN] = this._len_cpl;
344 urHdr [PEC_PCI__CPL_ID] = this._cpl_id;
345 urHdr [PEC_PCI__CPL_STATUS] = PEC_PCI__CPL_STATUS_UR;
346 urHdr [PEC_PCI__BCM] = this._bcm;
347 urHdr [PEC_PCI__BYTECOUNT] = this._byte_count;
348 urHdr [PEC_PCI__CPL_REQ_ID] = this._req_id;
349 urHdr [PEC_PCI__CPL_TAG] = this._tag;
350 urHdr [PEC_PCI__LOWADDR] = this._lower_addr;
351
352}
353
354task PioMRdPEUStr::Execute() {
355
356 SetPacketParams();
357
358 this._env.driveILU(reqHdr, 0, 0);
359
360
361 this._env.expectPCIE(reqHdr, 0);
362
363 if ( (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) ||
364 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) ||
365 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) ||
366 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) {
367 this._env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlCplSt ); //Malformed Completion TLP - Reserved completion status (%u).
368 }
369
370 //
371 repeat( urandom_range( _env.Scenario.ilupeuPioMRdCplDelayMax, _env.Scenario.ilupeuPioMRdCplDelayMin)) @(posedge CLOCK);
372
373 if ( this._ep_cpl && super.f_abortErrTlp )
374 this._env.drivePCIE(cplHdr, this._data, *, *, *, 1);
375 else
376 this._env.drivePCIE(cplHdr, this._data);
377
378
379 if ((this._cpl_status === PEC_PCI__CPL_STATUS_CA) ||
380 (this._cpl_status === PEC_PCI__CPL_STATUS_UR) ||
381 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) ||
382 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) ||
383 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) ||
384 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) {
385
386 this._env.expectILU(urHdr, this._data);
387 mailbox_put(this._errQueue, e_ERR_oe_ruc);
388 mailbox_put(this._errQueue, cplHdr );
389 }
390
391 else if (this._cpl_status === PEC_PCI__CPL_STATUS_CRS) {
392
393 // Nothing pops out here.
394 this._env.waitIngressLatency(cplHdr);
395 mailbox_put(this._errQueue, e_ERR_ue_mfp);
396 mailbox_put(this._errQueue, cplHdr );
397 }
398
399 else if (this._ep_cpl === 1'b_1) {
400
401 repeat(2) @(posedge CLOCK);
402 cplHdr [PEC_PCI__EP] = 0;
403 this._env.drivePCIE(cplHdr, this._data);
404 this._env.expectILU(cplHdr, this._data);
405 if ( this._errQueue != 0 )
406 {
407 //N2 - Add checking of request header
408
409// mailbox_put( this._errQueue, e_ERR_none );
410// mailbox_put( this._errQueue, -1 );
411// mailbox_put( this._errQueue, reqHdr );
412 mailbox_put(this._errQueue, e_ERR_ue_pp);
413 cplHdr [PEC_PCI__EP] = 1;
414 mailbox_put(this._errQueue, cplHdr);
415 }
416 }
417
418 else {
419
420 this._env.expectILU(cplHdr, this._data);
421 }
422
423
424 this._env.freePioTag(this._tag);
425}
426