Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2ctx / N2PIOPEUCtx.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: N2PIOPEUCtx.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 "PEC.vri"
37//#include "PECCtx.vri"
38//#include "PECTestEnv.vri"
39//
40//#include "PioBasePECStr.vrh"
41//
42//#include "PioMWrPECStr.vrh"
43//#include "PioMRdPECStr.vrh"
44//#include "PioCfgIOWrPECStr.vrh"
45//#include "PioCfgIORdPECStr.vrh"
46
47
48
49class PIOPEUCtx extends PEUCtxBase {
50
51
52 // ******************************************************************
53 // The Test Environment objects need to execute the context.
54 // ******************************************************************
55 local PEUTestEnv _env;
56
57
58 // ******************************************************************
59 // Context Control Fields - These fields are randomized using the
60 // Randomiztion Parameters in the following section, and the
61 // ******************************************************************
62 local PECPIOType _PIOType;
63
64
65 // ******************************************************************
66 // Randomization Parameters - These parameters are set by the user
67 // prior to executing the context. These fields are used as
68 // constraints for the previous Context Control Parameters.
69 // ******************************************************************
70 public PECParamMode _PIOType_mode = e_random_all;
71 public PECPIOType _PIOType_fixed = e_PIOMWr;
72 public integer _PIOType_MWr = 1;
73 public integer _PIOType_MRd = 1;
74 public integer _PIOType_CfgIOWr = 1;
75 public integer _PIOType_CfgIORd = 1;
76
77
78 // ******************************************************************
79 // Constraint Parameters - These parameters are used to set the
80 // randomization constraints in the selected strategy.
81 // ******************************************************************
82 public PECParamMode _format_req_mode = e_random_all;
83 public integer _format_req_fixed = 3;
84 public integer _format_req_prob_4dw = 50;
85 public integer _format_req_prob_3dw = 50;
86 //N2 parameters to be able to select between PIO Cfg and IO in test
87 public integer _type_req_prob_cfg0 = 1;
88 public integer _type_req_prob_cfg1 = 1;
89 public integer _type_req_prob_io = 1;
90
91 public PECParamMode _td_cpl_mode = e_random_all;
92 public PECBool _td_cpl_fixed = e_false;
93 public integer _td_cpl_prob_false = 50;
94 public integer _td_cpl_prob_true = 50;
95
96 public PECParamMode _ep_cpl_mode = e_random_all;
97 public PECBool _ep_cpl_fixed = e_false;
98 public integer _ep_cpl_prob_false = 50;
99 public integer _ep_cpl_prob_true = 50;
100
101 public PECParamMode _len_mode = e_random_all;
102 public bit [9:0] _len_fixed = 1;
103 public bit [9:0] _len_min = 1;
104 public bit [9:0] _len_max = 4; //N2 supports 8 byte PIO write, 16 byte PIO read. // 16;
105
106 public PECParamMode _req_id_mode = e_random_all;
107 public bit [15:0] _req_id_fixed = 0;
108 public bit [15:0] _req_id_min = 0;
109 public bit [15:0] _req_id_max = 65535;
110
111 public PECParamMode _addr_lsb_mode = e_random_all;
112 public bit [31:0] _addr_lsb_fixed = 32'h_0000_0000;
113 public bit [31:0] _addr_lsb_min = 32'h_0000_0000;
114 public bit [31:0] _addr_lsb_max = 32'h_FFFF_FFFF;
115
116 public PECParamMode _first_dwbe_mode = e_random_all;
117 public bit [3:0] _first_dwbe_fixed = 4'b_1111;
118 public bit [3:0] _first_dwbe_min = 4'b_0000;
119 public bit [3:0] _first_dwbe_max = 4'b_1111;
120
121 public PECParamMode _last_dwbe_mode = e_random_all;
122 public bit [3:0] _last_dwbe_fixed = 4'b_1111;
123 public bit [3:0] _last_dwbe_min = 4'b_0000;
124 public bit [3:0] _last_dwbe_max = 4'b_1111;
125
126 public PECParamMode _cpl_id_mode = e_random_all;
127 public bit [15:0] _cpl_id_fixed = 0;
128 public bit [15:0] _cpl_id_min = 0;
129 public bit [15:0] _cpl_id_max = 65535;
130
131 public PECParamMode _cpl_status_mode = e_random_all;
132 public bit [3:0] _cpl_status_fixed = PEC_PCI__CPL_STATUS_SC;
133 public integer _cpl_status_prob_sc = 1;
134 public integer _cpl_status_prob_ur = 0;
135 public integer _cpl_status_prob_crs = 0;
136 public integer _cpl_status_prob_ca = 0;
137 public integer _cpl_status_prob_rsvd1 = 0;
138 public integer _cpl_status_prob_rsvd2 = 0;
139 public integer _cpl_status_prob_rsvd3 = 0;
140 public integer _cpl_status_prob_rsvd4 = 0;
141
142 public PECParamMode _bcm_mode = e_random_all;
143 public PECBool _bcm_fixed = e_false;
144 public bit _bcm_prob_false = 50;
145 public bit _bcm_prob_true = 50;
146
147
148
149
150 // ******************************************************************
151 // Constructor
152 // ******************************************************************
153 public task new(PEUTestEnv a_env);
154
155
156 // ******************************************************************
157 // Methods required to execute the Context.
158 // ******************************************************************
159 protected function CTStrategyBase ProvideStrategy();
160 protected function CTStrategyBase FinalizeParms(CTStrategyBase S);
161}
162
163
164
165//-------------------------------------------------------------------
166// Method Name:
167// Description:
168//-------------------------------------------------------------------
169task PIOPEUCtx::new(PEUTestEnv a_env) {
170
171 super.new("PIO Context", a_env);
172 this._env = a_env;
173}
174
175
176
177//-------------------------------------------------------------------
178// Method Name:
179// Description:
180//-------------------------------------------------------------------
181function CTStrategyBase PIOPEUCtx::ProvideStrategy() {
182
183
184 PEUStrBase sNull;
185 PioMWrPEUStr sMWr;
186 PioMRdPEUStr sMRd;
187 PioCfgIOWrPEUStr sCfgIOWr;
188 PioCfgIORdPEUStr sCfgIORd;
189
190
191
192 // ******************************************************************
193 // Determine the PIO Type, based on the PIO Type Mode.
194 // ******************************************************************
195 if (super.StratStop === 1'b1) {
196
197 sNull = new(this._env);
198 ProvideStrategy = sNull;
199 }
200
201
202 else if (this._PIOType_mode === e_random) {
203
204 randcase {
205
206 this._PIOType_MWr : { sMWr = new(this._env); ProvideStrategy = sMWr; }
207 this._PIOType_MRd : { sMRd = new(this._env); ProvideStrategy = sMRd; }
208 this._PIOType_CfgIOWr : { sCfgIOWr = new(this._env); ProvideStrategy = sCfgIOWr; }
209 this._PIOType_CfgIORd : { sCfgIORd = new(this._env); ProvideStrategy = sCfgIORd; }
210 }
211 }
212
213
214 else if (this._PIOType_mode === e_fixed) {
215
216 case (this._PIOType_fixed) {
217
218 e_PIOMWr : { sMWr = new(this._env); ProvideStrategy = sMWr; }
219 e_PIOMRd : { sMRd = new(this._env); ProvideStrategy = sMRd; }
220 e_PIOCfgIOWr : { sCfgIOWr = new(this._env); ProvideStrategy = sCfgIOWr; }
221 e_PIOCfgIORd : { sCfgIORd = new(this._env); ProvideStrategy = sCfgIORd; }
222
223 default : error("Invalid PIOType_fixed\n");
224 }
225 }
226
227 else if (this._PIOType_mode === e_random_all) {
228
229 randcase {
230
231 1 : { sMWr = new(this._env); ProvideStrategy = sMWr; }
232 1 : { sMRd = new(this._env); ProvideStrategy = sMRd; }
233 1 : { sCfgIOWr = new(this._env); ProvideStrategy = sCfgIOWr; }
234 1 : { sCfgIORd = new(this._env); ProvideStrategy = sCfgIORd; }
235 }
236 }
237
238 else {
239
240 error("Invalid PIOType_mode\n");
241 }
242}
243
244
245
246//-------------------------------------------------------------------
247// Method Name:
248// Description:
249//-------------------------------------------------------------------
250function CTStrategyBase PIOPEUCtx::FinalizeParms(CTStrategyBase S) {
251
252
253 PioBasePEUStr strategy;
254
255
256 if (cast_assign(strategy, S, CHECK) === 0) {
257
258 FinalizeParms = S;
259 return;
260 }
261
262
263
264 // ******************************************************************
265
266 // ******************************************************************
267 if (this._format_req_mode === e_random) {
268
269 strategy._format_req_prob_4dw = this._format_req_prob_4dw;
270 strategy._format_req_prob_3dw = this._format_req_prob_3dw;
271 }
272
273 else if (this._format_req_mode === e_fixed) {
274
275 strategy._format_req_prob_4dw = (this._format_req_fixed === 4) ? 100 : 0;
276 strategy._format_req_prob_3dw = (this._format_req_fixed === 3) ? 100 : 0;
277 }
278
279 else if (this._format_req_mode === e_random_all) {
280
281 strategy._format_req_prob_4dw = 50;
282 strategy._format_req_prob_3dw = 50;
283 }
284
285 else
286 error("Invalid Format Request Mode\n");
287
288
289
290 // ******************************************************************
291
292 // ******************************************************************
293 if (this._td_cpl_mode === e_random) {
294
295 strategy._td_cpl_prob_true = this._td_cpl_prob_true;
296 strategy._td_cpl_prob_false = this._td_cpl_prob_false;
297 }
298
299 else if (this._td_cpl_mode === e_fixed) {
300
301 strategy._td_cpl_prob_true = (this._td_cpl_fixed === e_true) ? 100 : 0;
302 strategy._td_cpl_prob_false = (this._td_cpl_fixed === e_false) ? 100 : 0;
303 }
304
305 else if (this._td_cpl_mode === e_random_all) {
306
307 strategy._td_cpl_prob_true = 50;
308 strategy._td_cpl_prob_false = 50;
309 }
310
311 else
312 error("Invalid TD Completion Mode\n");
313
314
315
316 // ******************************************************************
317
318 // ******************************************************************
319 if (this._ep_cpl_mode === e_random) {
320
321 strategy._ep_cpl_prob_true = this._ep_cpl_prob_true;
322 strategy._ep_cpl_prob_false = this._ep_cpl_prob_false;
323 }
324
325 else if (this._ep_cpl_mode === e_fixed) {
326
327 strategy._ep_cpl_prob_true = (this._ep_cpl_fixed === e_true) ? 100 : 0;
328 strategy._ep_cpl_prob_false = (this._ep_cpl_fixed === e_false) ? 100 : 0;
329 }
330
331 else if (this._ep_cpl_mode === e_random_all) {
332
333 strategy._ep_cpl_prob_true = 50;
334 strategy._ep_cpl_prob_false = 50;
335 }
336
337 else
338 error("Invalid EP Completion Mode\n");
339
340
341
342 // ******************************************************************
343
344 // ******************************************************************
345 if (this._len_mode === e_random) {
346
347 strategy._len_min = this._len_min;
348 strategy._len_max = this._len_max;
349 }
350
351 else if (this._len_mode === e_fixed) {
352
353 strategy._len_min = this._len_fixed;
354 strategy._len_max = this._len_fixed;
355 }
356
357 else if (this._len_mode === e_random_all) {
358
359 strategy._len_min = 10'h_001;
360 strategy._len_max = 10'h_004;
361 }
362
363 else
364 error ("Invalid Length Mode\n");
365
366
367
368 // ******************************************************************
369
370 // ******************************************************************
371 if (this._req_id_mode === e_random) {
372
373 strategy._req_id_min = this._req_id_min;
374 strategy._req_id_max = this._req_id_max;
375 }
376
377 else if (this._req_id_mode === e_fixed) {
378
379 strategy._req_id_min = this._req_id_fixed;
380 strategy._req_id_max = this._req_id_fixed;
381 }
382
383 else if (this._req_id_mode === e_random_all) {
384
385 strategy._req_id_min = 16'h_0000;
386 strategy._req_id_max = 16'h_FFFF;
387 }
388
389 else
390 error ("Invalid Requestor ID Mode\n");
391
392
393
394 // ******************************************************************
395
396 // ******************************************************************
397 if (this._addr_lsb_mode === e_random) {
398
399 strategy._addr_lsb_min = this._addr_lsb_min;
400 strategy._addr_lsb_max = this._addr_lsb_max;
401 }
402
403 else if (this._addr_lsb_mode === e_fixed) {
404
405 strategy._addr_lsb_min = this._addr_lsb_fixed;
406 strategy._addr_lsb_max = this._addr_lsb_fixed;
407 }
408
409 else if (this._addr_lsb_mode === e_random_all) {
410
411 strategy._addr_lsb_min = 32'h_0000_0000;
412 strategy._addr_lsb_max = 32'h_FFFF_FFFF;
413 }
414
415 else
416 error ("Invalid Address Mode\n");
417
418
419
420 // ******************************************************************
421
422 // Enables.
423 // ******************************************************************
424 if (this._first_dwbe_mode === e_random) {
425
426 strategy._first_dwbe_min = this._first_dwbe_min;
427 strategy._first_dwbe_max = this._first_dwbe_max;
428 }
429
430 else if (this._first_dwbe_mode === e_fixed) {
431
432 strategy._first_dwbe_min = this._first_dwbe_fixed;
433 strategy._first_dwbe_max = this._first_dwbe_fixed;
434 }
435
436 else if (this._first_dwbe_mode === e_random_all) {
437
438 strategy._first_dwbe_min = 4'h_0;
439 strategy._first_dwbe_max = 4'h_F;
440 }
441
442 else
443 error ("Invalid First Double Word Byte Enable Mode\n");
444
445
446
447 // ******************************************************************
448
449 // Enables.
450 // ******************************************************************
451 if (this._last_dwbe_mode === e_random) {
452
453 strategy._last_dwbe_min = this._last_dwbe_min;
454 strategy._last_dwbe_max = this._last_dwbe_max;
455 }
456
457 else if (this._last_dwbe_mode === e_fixed) {
458
459 strategy._last_dwbe_min = this._last_dwbe_fixed;
460 strategy._last_dwbe_max = this._last_dwbe_fixed;
461 }
462
463 else if (this._last_dwbe_mode === e_random_all) {
464
465 strategy._last_dwbe_min = 4'h_0;
466 strategy._last_dwbe_max = 4'h_F;
467 }
468
469 else
470 error ("Invalid Last Double Word Byte Enable Mode\n");
471
472
473
474 // ******************************************************************
475
476 // ******************************************************************
477 if (this._cpl_id_mode === e_random) {
478
479 strategy._cpl_id_min = this._cpl_id_min;
480 strategy._cpl_id_max = this._cpl_id_max;
481 }
482
483 else if (this._cpl_id_mode === e_fixed) {
484
485 strategy._cpl_id_min = this._cpl_id_fixed;
486 strategy._cpl_id_max = this._cpl_id_fixed;
487 }
488
489 else if (this._cpl_id_mode === e_random_all) {
490
491 strategy._cpl_id_min = 16'h_0000;
492 strategy._cpl_id_max = 16'h_FFFF;
493 }
494
495 else
496 error ("Invalid Completor ID Mode\n");
497
498
499
500 // ******************************************************************
501
502 // ******************************************************************
503 if (this._cpl_status_mode === e_random) {
504
505 strategy._cpl_status_prob_sc = this._cpl_status_prob_sc;
506 strategy._cpl_status_prob_ur = this._cpl_status_prob_ur;
507 strategy._cpl_status_prob_crs = this._cpl_status_prob_crs;
508 strategy._cpl_status_prob_ca = this._cpl_status_prob_ca;
509 strategy._cpl_status_prob_rsvd1 = this._cpl_status_prob_rsvd1;
510 strategy._cpl_status_prob_rsvd2 = this._cpl_status_prob_rsvd2;
511 strategy._cpl_status_prob_rsvd3 = this._cpl_status_prob_rsvd3;
512 strategy._cpl_status_prob_rsvd4 = this._cpl_status_prob_rsvd4;
513 }
514
515 else if (this._cpl_status_mode === e_fixed) {
516
517 strategy._cpl_status_prob_sc =
518 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_SC) ? 1 : 0;
519
520 strategy._cpl_status_prob_ur =
521 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_UR) ? 1 : 0;
522
523 strategy._cpl_status_prob_crs =
524 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_CRS) ? 1 : 0;
525
526 strategy._cpl_status_prob_ca =
527 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_CA) ? 1 : 0;
528
529 strategy._cpl_status_prob_rsvd1 =
530 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_RSVD1) ? 1 : 0;
531
532 strategy._cpl_status_prob_rsvd2 =
533 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_RSVD2) ? 1 : 0;
534
535 strategy._cpl_status_prob_rsvd3 =
536 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_RSVD3) ? 1 : 0;
537
538 strategy._cpl_status_prob_rsvd4 =
539 (this._cpl_status_fixed === PEC_PCI__CPL_STATUS_RSVD4) ? 1 : 0;
540 }
541
542 else if (this._cpl_status_mode === e_random_all) {
543
544 strategy._cpl_status_prob_sc = 5;
545 strategy._cpl_status_prob_ur = 1;
546 strategy._cpl_status_prob_crs = 5;
547 strategy._cpl_status_prob_ca = 5;
548 strategy._cpl_status_prob_rsvd1 = 1;
549 strategy._cpl_status_prob_rsvd2 = 1;
550 strategy._cpl_status_prob_rsvd3 = 1;
551 strategy._cpl_status_prob_rsvd4 = 1;
552 }
553
554 else
555 error("Invalid Completion Status Mode\n");
556
557
558
559 // ******************************************************************
560
561 // ******************************************************************
562 if (this._bcm_mode === e_random) {
563
564 strategy._bcm_prob_true = this._bcm_prob_true;
565 strategy._bcm_prob_false = this._bcm_prob_false;
566 }
567
568 else if (this._bcm_mode === e_fixed) {
569
570 strategy._bcm_prob_true = (this._bcm_fixed === e_true) ? 100 : 0;
571 strategy._bcm_prob_false = (this._bcm_fixed === e_false) ? 100 : 0;
572 }
573
574 else if (this._bcm_mode === e_random_all) {
575
576 strategy._bcm_prob_true = 50;
577 strategy._bcm_prob_false = 50;
578 }
579
580 else
581 error("Invalid Byte Count Modifier (BCM) Mode\n");
582
583 //Set Cfg or IO type since test can specify
584 strategy._type_req_prob_cfg0 = this._type_req_prob_cfg0;
585 strategy._type_req_prob_cfg1 = this._type_req_prob_cfg1;
586 strategy._type_req_prob_io = this._type_req_prob_io;
587
588
589
590 FinalizeParms = strategy;
591}