Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / verilog / err_random / vuaderr.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: vuaderr.v
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 ============================================
35module vuaderr(L2_INT_RST);
36
37parameter PSMPL = 3;
38parameter s0 = 0,s1 = 1;
39input L2_INT_RST;
40
41reg [39:0] address;
42reg [38:0] vld_dirty, usaloc, buffer;
43reg [8:0] index;
44reg [3:0]bit_pos;
45reg [39:0]cnt;
46reg [1:0] cs,ns;
47reg vd_inject_err,ua_inject_err,vd_inject_ue,ua_inject_ue,trph;
48integer i;
49wire [39:0] arbdp_addr_c1;
50wire [6:0] vd_ecc_c1,ua_ecc_c1;
51wire [15:0] valid_c1,dirty_c1,used_c1,alloc_c1;
52wire inst_vld_c2_prev,vuad_vlddir_no_bypass_c1,vuad_usaloc_no_bypass_c1,arb_inst_diag_c1;
53wire take_eer,take_retry;
54
55assign arbdp_addr_c1 = tb_top.cpu.l2t0.arbadr.arbdp_addr_c1_1;
56assign inst_vld_c2_prev = tb_top.cpu.l2t0.arb.inst_vld_c2_prev;
57assign vuad_vlddir_no_bypass_c1=tb_top.cpu.l2t0.vlddir.mux_valid_dirty_c1_sel0;
58assign arb_inst_diag_c1 = tb_top.cpu.l2t0.arb.arb_inst_diag_c1;
59assign vd_ecc_c1 = tb_top.cpu.l2t0.vlddir.vuad_array_rd_data_c1[38:32];
60assign valid_c1 = tb_top.cpu.l2t0.vlddir.valid_c1;
61assign dirty_c1 = tb_top.cpu.l2t0.vlddir.dirty_c1;
62assign vuad_usaloc_no_bypass_c1 = tb_top.cpu.l2t0.usaloc.vuad_usaloc_mux_used_and_alloc_comb_sel5;
63assign ua_ecc_c1 = tb_top.cpu.l2t0.usaloc.vuad_array_rd_data_c1[77:71];
64assign used_c1 = tb_top.cpu.l2t0.usaloc.used_c1;
65assign alloc_c1 = tb_top.cpu.l2t0.usaloc.alloc_c1;
66
67assign take_retry = tb_top.cpu.spc0.tlu.trl0.take_ret;
68assign take_eer = tb_top.cpu.spc0.tlu.trl0.take_eer; // For Hw Corr
69
70initial begin
71 if($test$plusargs("PREFICE_VD_INJECT"))
72 begin
73 $display("MSA1: forcing_err\n");
74 @(posedge tb_top.cpu.l2t0.arbdec.pf_ice_qual);
75 $display("MSA2: forcing_err\n");
76 @(posedge tb_top.cpu.l2t0.arbdec.pf_ice_qual);
77 $display("MSA3: forcing_err\n");
78 @(posedge tb_top.cpu.l2t0.arbdec.pf_ice_qual);
79 @(posedge tb_top.cpu.l2t0.arbdec.pf_ice_qual);
80 @(posedge tb_top.cpu.l2t0.arbdec.pf_ice_qual);
81 $display("BAS: force the valid bits\n");
82 @(posedge tb_top.cpu.l2clk);
83 $display("BAS: force the valid bits\n");
84 force tb_top.cpu.l2t0.vlddir.valid_c2[15:0] = 16'h0000;
85 force tb_top.cpu.l2t0.vlddir.vlddir_vuad_valid_c2[15:0] = 16'h0000;
86 @(posedge tb_top.cpu.l2clk);
87 release tb_top.cpu.l2t0.vlddir.valid_c2[15:0];
88 @(negedge tb_top.cpu.l2clk);
89 release tb_top.cpu.l2t0.vlddir.vlddir_vuad_valid_c2[15:0];
90 $display("BAS: release the valid bits\n");
91 end
92end
93
94initial
95begin
96//=================================
97// Initialize the variables used in here
98//=================================
99
100 vd_inject_err = 0;
101 ua_inject_err = 0;
102 vd_inject_ue = 0;
103 ua_inject_ue = 0;
104 trph = 0;
105 i = 0;
106 bit_pos = 2;
107
108//=========================================
109// Check if forcing variables are changed by verargs
110//=========================================
111
112if($test$plusargs("L2VD_CE_ERR_INJECT"))
113 begin
114 vd_inject_err = 1;
115 `PR_ALWAYS("l2err_injector", `ALWAYS, "L2 VD Err injector enabled");
116 end
117else if($test$plusargs("L2UA_CE_ERR_INJECT"))
118 begin
119 ua_inject_err = 1;
120 `PR_ALWAYS("l2err_injector", `ALWAYS, "L2 UA Err injector enabled");
121 end
122
123if($test$plusargs("L2VD_UE_INJECT"))
124 begin
125 vd_inject_ue = 1;
126 `PR_ALWAYS("l2err_injector", `ALWAYS, "L2 VD Err injector enabled");
127 end
128else if($test$plusargs("L2UA_UE_INJECT"))
129 begin
130 ua_inject_ue = 1;
131 `PR_ALWAYS("l2err_injector", `ALWAYS, "L2 UA Err injector enabled");
132 end
133
134
135end
136
137/*
138always @(posedge tb_top.cpu.l2clk)
139begin
140 if(`TOP.gOutOfBoot[63:0] === `TOP.verif_args.finish_mask[63:0] )
141 begin
142 if(bit_pos == 4'b1111)
143 bit_pos <= 2;
144 else
145 bit_pos <= bit_pos + 1;
146 end
147end */
148
149//Sequential part of stmc...
150//To not inject in traphandler
151always @(posedge tb_top.cpu.l2clk)
152begin
153if(ua_inject_ue || vd_inject_ue || vd_inject_err || ua_inject_err)
154begin
155 if(!L2_INT_RST) cs <= s0;
156 else cs <= ns;
157end
158end
159
160//combo logic
161always @(s0 or s1 or take_eer or take_retry or cs or ua_inject_ue or vd_inject_ue or vd_inject_err or ua_inject_err)
162begin
163trph <= 0;
164if(ua_inject_ue || vd_inject_ue || vd_inject_err || ua_inject_err)
165begin
166 case(cs)
167 s0:
168 begin
169 if ( take_eer == 0) ns <= s0;
170 else if (take_eer == 1) begin ns <= s1; trph<= 1;end
171 end
172 s1:
173 begin
174 if (take_retry == 0)begin ns <= s1; trph <= 1; end
175 else if (take_retry == 1) begin ns <= s0;trph<=0;end
176 end
177 endcase
178//$display("In Combo Logic take_retry=%d,take_eer=%d,trph=%d,ns=%d",take_retry,take_eer,trph,ns);
179end
180end //end combo logic
181
182always @(posedge tb_top.cpu.l2clk)
183begin
184
185if(!L2_INT_RST)
186begin
187bit_pos <= 2;
188end
189else
190begin
191i<=0;
192if((`TOP.gOutOfBoot[63:0] === `TOP.verif_args.finish_mask[63:0]) && ( vd_inject_err == 1 || vd_inject_ue == 1) && !trph)
193begin
194
195 #(PSMPL)
196//$display("Before if inst_vld_c2_prev=%d,vuad_vlddir_no_bypass_c1=%d,arb_inst_diag_c1=%d, bit_pos = %b",inst_vld_c2_prev,vuad_vlddir_no_bypass_c1,arb_inst_diag_c1,bit_pos);
197
198
199 if(inst_vld_c2_prev && vuad_vlddir_no_bypass_c1 && !arb_inst_diag_c1 && bit_pos[3] != 1)
200
201
202 begin
203
204//$display("After if inst_vld_c2_prev=%d,vuad_vlddir_no_bypass_c1=%d,arb_inst_diag_c1=%d",inst_vld_c2_prev,vuad_vlddir_no_bypass_c1,arb_inst_diag_c1);
205 address <= arbdp_addr_c1; // C1 signal
206 if($test$plusargs("L2PM_fourbank"))
207 index = address[16:8];
208 else if($test$plusargs("L2PM_twobank"))
209 index <= address[15:7];
210 else index <= address[17:9];
211
212 vld_dirty= {vd_ecc_c1,valid_c1,dirty_c1};
213 cnt <= ({$random(`PARGS.seed)} % 39);
214//$display("address=%h,index=%h,vld_dirty=%d,i=%d",address,index,vld_dirty,i);
215 vld_dirty[cnt] <= vld_dirty[cnt] ^ 1'b1;
216 if(vd_inject_ue) vld_dirty[cnt+1] <= vld_dirty[cnt+1] ^ 1'b1;
217 @(posedge tb_top.cpu.l2clk);
218 #(PSMPL)
219 SetVldDirtyVuadArrayC2(i, vld_dirty);
220 if(vd_inject_err) `PR_ALWAYS("l2err_injector", `ALWAYS,"VUAD CE injected (VD) in bank%d, Index%d, bit%dflipped (address = %x)\n\n", i, index, cnt, address);
221 else `PR_ALWAYS("l2err_injector", `ALWAYS,"VUAD UE injected (VD) in bank%d, Index%d, bit%dflipped (address = %x)\n\n", i, index, cnt, address);
222 @(posedge tb_top.cpu.l2clk);
223 #(PSMPL)
224 ReleaseVldDirtyVuadArrayC2(i);
225
226 end // if(inst_vld_c2_prev && vuad_vlddir_no_bypass_c1 && !arb_inst_diag_c1)
227 bit_pos <= bit_pos + 1;
228 @(posedge tb_top.cpu.l2clk);
229 end // OutOf Boot
230
231end //else of if(!L2_INT_RST)
232
233end //always @(posedge tb_top.cpu.l2clk)
234
235
236
237/*** end of VD error injection**/
238
239/*** Start of UA error injection**/
240
241always @(posedge tb_top.cpu.l2clk)
242begin
243
244if(!L2_INT_RST)
245begin
246end
247else
248begin
249i = 0;
250if((`TOP.gOutOfBoot[63:0] === `TOP.verif_args.finish_mask[63:0] ) && ( ua_inject_err == 1 || ua_inject_ue == 1) && !trph)
251begin
252
253 #(PSMPL)
254
255 //if(.$array_rd_en){ // This is a PX2 signal
256 //repeat(2)@(posedge tb_top.cpu.l2clk);
257 if(inst_vld_c2_prev && vuad_usaloc_no_bypass_c1 && !arb_inst_diag_c1 && bit_pos[3] != 1)
258 begin
259
260 address = arbdp_addr_c1; // C1 signal
261 if($test$plusargs("L2PM_fourbank"))
262 index = address[16:8];
263 else if($test$plusargs("L2PM_twobank"))
264 index <= address[15:7];
265 else index <= address[17:9];
266
267
268 usaloc = {ua_ecc_c1, used_c1, alloc_c1};
269 cnt =({$random(`PARGS.seed)} % 39);
270 usaloc[cnt] = usaloc[cnt] ^ 1'b1;
271 if(ua_inject_ue) usaloc[cnt+1] = usaloc[cnt+1] ^ 1'b1;
272 @(posedge tb_top.cpu.l2clk);
273 #(PSMPL)
274 SetUsAlocVuadArrayC2(i, usaloc);
275 if(ua_inject_err) `PR_ALWAYS("l2err_injector", `ALWAYS,"VUAD CE injected (UA) in Bank 0, Index%d, bit%d flipped (address = %x)\n\n", index, cnt, address);
276 else `PR_ALWAYS("l2err_injector", `ALWAYS,"VUAD UE injected (UA) in Bank 0, Index%d, bit%d flipped (address = %x)\n\n", index, cnt, address);
277 @(posedge tb_top.cpu.l2clk);
278 #(PSMPL)
279 ReleaseUsalocVuadArrayC2(i);
280 buffer[cnt] = buffer[cnt] ^ 1'b1;
281
282 end //if(inst_vld_c2_prev && vuad_usaloc_no_bypass_c1 && !arb_inst_diag_c1)
283 @(posedge tb_top.cpu.l2clk);
284end //OutOfBOOT
285end ////else of if(!L2_INT_RST)
286
287end //always @(posedge tb_top.cpu.l2clk)
288
289
290//Tasks Used By Error Injector
291
292task SetVldDirtyVuadArrayC2;
293input bank;
294input [38:0] value;
295integer bank;
296reg [38:0] value;
297begin
298 case (bank)
299 0: begin
300 force tb_top.cpu.l2t0.vlddir.vd_ecc_c2[6:0] = value[38:32];
301 force tb_top.cpu.l2t0.vlddir.valid_c2[15:0] = value[31:16];
302 force tb_top.cpu.l2t0.vlddir.dirty_c2[15:0] = value[15:0];
303 end
304 1: begin
305 force tb_top.cpu.l2t1.vlddir.vd_ecc_c2[6:0] = value[38:32];
306 force tb_top.cpu.l2t1.vlddir.valid_c2[15:0] = value[31:16];
307 force tb_top.cpu.l2t1.vlddir.dirty_c2[15:0] = value[15:0];
308 end
309 2: begin
310 force tb_top.cpu.l2t2.vlddir.vd_ecc_c2[6:0] = value[38:32];
311 force tb_top.cpu.l2t2.vlddir.valid_c2[15:0] = value[31:16];
312 force tb_top.cpu.l2t2.vlddir.dirty_c2[15:0] = value[15:0];
313 end
314 3: begin
315 force tb_top.cpu.l2t3.vlddir.vd_ecc_c2[6:0] = value[38:32];
316 force tb_top.cpu.l2t3.vlddir.valid_c2[15:0] = value[31:16];
317 force tb_top.cpu.l2t3.vlddir.dirty_c2[15:0] = value[15:0];
318 end
319 4: begin
320 force tb_top.cpu.l2t4.vlddir.vd_ecc_c2[6:0] = value[38:32];
321 force tb_top.cpu.l2t4.vlddir.valid_c2[15:0] = value[31:16];
322 force tb_top.cpu.l2t4.vlddir.dirty_c2[15:0] = value[15:0];
323 end
324 5: begin
325 force tb_top.cpu.l2t5.vlddir.vd_ecc_c2[6:0] = value[38:32];
326 force tb_top.cpu.l2t5.vlddir.valid_c2[15:0] = value[31:16];
327 force tb_top.cpu.l2t5.vlddir.dirty_c2[15:0] = value[15:0];
328 end
329 6: begin
330 force tb_top.cpu.l2t6.vlddir.vd_ecc_c2[6:0] = value[38:32];
331 force tb_top.cpu.l2t6.vlddir.valid_c2[15:0] = value[31:16];
332 force tb_top.cpu.l2t6.vlddir.dirty_c2[15:0] = value[15:0];
333 end
334 7: begin
335 force tb_top.cpu.l2t7.vlddir.vd_ecc_c2[6:0] = value[38:32];
336 force tb_top.cpu.l2t7.vlddir.valid_c2[15:0] = value[31:16];
337 force tb_top.cpu.l2t7.vlddir.dirty_c2[15:0] = value[15:0];
338 end
339 endcase
340// force tb_top.force_vd = 1'b1;
341end
342endtask
343
344task ReleaseVldDirtyVuadArrayC2;
345input bank;
346integer bank;
347begin
348 case (bank)
349 0: begin
350 release tb_top.cpu.l2t0.vlddir.vd_ecc_c2[6:0];
351 release tb_top.cpu.l2t0.vlddir.valid_c2[15:0];
352 release tb_top.cpu.l2t0.vlddir.dirty_c2[15:0];
353 end
354 1: begin
355 release tb_top.cpu.l2t1.vlddir.vd_ecc_c2[6:0];
356 release tb_top.cpu.l2t1.vlddir.valid_c2[15:0];
357 release tb_top.cpu.l2t1.vlddir.dirty_c2[15:0];
358 end
359 2: begin
360 release tb_top.cpu.l2t2.vlddir.vd_ecc_c2[6:0];
361 release tb_top.cpu.l2t2.vlddir.valid_c2[15:0];
362 release tb_top.cpu.l2t2.vlddir.dirty_c2[15:0];
363 end
364 3: begin
365 release tb_top.cpu.l2t3.vlddir.vd_ecc_c2[6:0];
366 release tb_top.cpu.l2t3.vlddir.valid_c2[15:0];
367 release tb_top.cpu.l2t3.vlddir.dirty_c2[15:0];
368 end
369 4: begin
370 release tb_top.cpu.l2t4.vlddir.vd_ecc_c2[6:0];
371 release tb_top.cpu.l2t4.vlddir.valid_c2[15:0];
372 release tb_top.cpu.l2t4.vlddir.dirty_c2[15:0];
373 end
374 5: begin
375 release tb_top.cpu.l2t5.vlddir.vd_ecc_c2[6:0];
376 release tb_top.cpu.l2t5.vlddir.valid_c2[15:0];
377 release tb_top.cpu.l2t5.vlddir.dirty_c2[15:0];
378 end
379 6: begin
380 release tb_top.cpu.l2t6.vlddir.vd_ecc_c2[6:0];
381 release tb_top.cpu.l2t6.vlddir.valid_c2[15:0];
382 release tb_top.cpu.l2t6.vlddir.dirty_c2[15:0];
383 end
384 7: begin
385 release tb_top.cpu.l2t7.vlddir.vd_ecc_c2[6:0];
386 release tb_top.cpu.l2t7.vlddir.valid_c2[15:0];
387 release tb_top.cpu.l2t7.vlddir.dirty_c2[15:0];
388 end
389 endcase
390 // force tb_top.force_vd = 1'b0;
391end
392endtask
393
394
395task SetUsAlocVuadArrayC2;
396input bank;
397input value;
398integer bank;
399reg [38:0] value;
400begin
401 case (bank)
402 0: begin
403 force tb_top.cpu.l2t0.usaloc.ua_ecc_c2[6:0] = value[38:32];
404 force tb_top.cpu.l2t0.usaloc.used_c2[15:0] = value[31:16];
405 force tb_top.cpu.l2t0.usaloc.alloc_c2[15:0] = value[15:0];
406 end
407 1: begin
408 force tb_top.cpu.l2t1.usaloc.ua_ecc_c2[6:0] = value[38:32];
409 force tb_top.cpu.l2t1.usaloc.used_c2[15:0] = value[31:16];
410 force tb_top.cpu.l2t1.usaloc.alloc_c2[15:0] = value[15:0];
411 end
412 2: begin
413 force tb_top.cpu.l2t2.usaloc.ua_ecc_c2[6:0] = value[38:32];
414 force tb_top.cpu.l2t2.usaloc.used_c2[15:0] = value[31:16];
415 force tb_top.cpu.l2t2.usaloc.alloc_c2[15:0] = value[15:0];
416 end
417 3: begin
418 force tb_top.cpu.l2t3.usaloc.ua_ecc_c2[6:0] = value[38:32];
419 force tb_top.cpu.l2t3.usaloc.used_c2[15:0] = value[31:16];
420 force tb_top.cpu.l2t3.usaloc.alloc_c2[15:0] = value[15:0];
421 end
422 4: begin
423 force tb_top.cpu.l2t4.usaloc.ua_ecc_c2[6:0] = value[38:32];
424 force tb_top.cpu.l2t4.usaloc.used_c2[15:0] = value[31:16];
425 force tb_top.cpu.l2t4.usaloc.alloc_c2[15:0] = value[15:0];
426 end
427 5: begin
428 force tb_top.cpu.l2t5.usaloc.ua_ecc_c2[6:0] = value[38:32];
429 force tb_top.cpu.l2t5.usaloc.used_c2[15:0] = value[31:16];
430 force tb_top.cpu.l2t5.usaloc.alloc_c2[15:0] = value[15:0];
431 end
432 6: begin
433 force tb_top.cpu.l2t6.usaloc.ua_ecc_c2[6:0] = value[38:32];
434 force tb_top.cpu.l2t6.usaloc.used_c2[15:0] = value[31:16];
435 force tb_top.cpu.l2t6.usaloc.alloc_c2[15:0] = value[15:0];
436 end
437 7: begin
438 force tb_top.cpu.l2t7.usaloc.ua_ecc_c2[6:0] = value[38:32];
439 force tb_top.cpu.l2t7.usaloc.used_c2[15:0] = value[31:16];
440 force tb_top.cpu.l2t7.usaloc.alloc_c2[15:0] = value[15:0];
441 end
442 endcase
443 // force tb_top.force_ua = 1'b1;
444end
445endtask
446
447
448task ReleaseUsalocVuadArrayC2;
449input bank;
450integer bank;
451begin
452 case (bank)
453 0: begin
454 release tb_top.cpu.l2t0.usaloc.ua_ecc_c2[6:0];
455 release tb_top.cpu.l2t0.usaloc.used_c2[15:0];
456 release tb_top.cpu.l2t0.usaloc.alloc_c2[15:0];
457 end
458 1: begin
459 release tb_top.cpu.l2t1.usaloc.ua_ecc_c2[6:0];
460 release tb_top.cpu.l2t1.usaloc.used_c2[15:0];
461 release tb_top.cpu.l2t1.usaloc.alloc_c2[15:0];
462 end
463 2: begin
464 release tb_top.cpu.l2t2.usaloc.ua_ecc_c2[6:0];
465 release tb_top.cpu.l2t2.usaloc.used_c2[15:0];
466 release tb_top.cpu.l2t2.usaloc.alloc_c2[15:0];
467 end
468 3: begin
469 release tb_top.cpu.l2t3.usaloc.ua_ecc_c2[6:0];
470 release tb_top.cpu.l2t3.usaloc.used_c2[15:0];
471 release tb_top.cpu.l2t3.usaloc.alloc_c2[15:0];
472 end
473 4: begin
474 release tb_top.cpu.l2t4.usaloc.ua_ecc_c2[6:0];
475 release tb_top.cpu.l2t4.usaloc.used_c2[15:0];
476 release tb_top.cpu.l2t4.usaloc.alloc_c2[15:0];
477 end
478 5: begin
479 release tb_top.cpu.l2t5.usaloc.ua_ecc_c2[6:0];
480 release tb_top.cpu.l2t5.usaloc.used_c2[15:0];
481 release tb_top.cpu.l2t5.usaloc.alloc_c2[15:0];
482 end
483 6: begin
484 release tb_top.cpu.l2t6.usaloc.ua_ecc_c2[6:0];
485 release tb_top.cpu.l2t6.usaloc.used_c2[15:0];
486 release tb_top.cpu.l2t6.usaloc.alloc_c2[15:0];
487 end
488 7: begin
489 release tb_top.cpu.l2t7.usaloc.ua_ecc_c2[6:0];
490 release tb_top.cpu.l2t7.usaloc.used_c2[15:0];
491 release tb_top.cpu.l2t7.usaloc.alloc_c2[15:0];
492 end
493 endcase
494end
495endtask
496
497
498
499endmodule