Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / verilog / tlb_sync / itlb_rd.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: itlb_rd.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 ============================================
35`ifdef CORE_0
36
37module itlb_rd_c0 (
38
39 mytg,
40 itlb_pipe_d0,
41 itlb_pipe_d1,
42 itlb_pipe_d2,
43 itlb_pipe_d3
44);
45
46// common defines
47`include "tlb_sync.vh"
48
49parameter WIDTH = `TLB_FIFO_WIDTH;
50
51input mytg;
52input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
53input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
54input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
55input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
56`ifndef GATESIM
57
58reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
59reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
60reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
61reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
62reg [1:0] tid_e;
63reg [1:0] tid_m;
64reg [1:0] tid_b;
65
66wire [1:0] tid_d;
67wire inst_d;
68wire inst_b;
69wire [47:0] pc_b;
70
71reg [2:0] mycid;
72reg [5:0] mytnum;
73wire [5:0] newtnum;
74wire [2:0] newtid;
75wire [(`TS_WIDTH-1):0] ts_b;
76reg [(`TS_WIDTH-1):0] tstamp;
77reg ready;
78integer junk;
79
80initial begin // {
81 ready = 0;
82 @(posedge `SPC0.l2clk) ;
83 @(posedge `SPC0.l2clk) ;
84 ready = `PARGS.tlb_sync_on;
85 mycid = 0;
86end //}
87
88assign newtid = ((mytg*4) + tid_b);
89assign newtnum = (mycid * 8) + newtid;
90
91//----------------------------------------------------------
92// DUT probes
93
94assign tid_d = mytg ? `SPC0.dec.dec_tid1_d :
95 `SPC0.dec.dec_tid0_d;
96
97assign inst_d = mytg ? `SPC0.dec.dec_decode1_d :
98 `SPC0.dec.dec_decode0_d;
99
100assign inst_b = mytg ? |(`PROBES0.select_pc_b[7:4]) :
101 |(`PROBES0.select_pc_b[3:0]);
102
103assign pc_b = mytg ? `PROBES0.pc_1_b :
104 `PROBES0.pc_0_b;
105
106assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
107
108`ifdef TLB_FIFO_WIDE
109wire [7:0] ifu_err_vect;
110wire ifu_err_vld;
111assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
112assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
113`endif
114
115//----------------------------------------------------------
116// Initialize pipeline
117initial begin // {
118
119 @ (posedge `SPC0.l2clk);
120 // Initialize pipeline
121 itlb_pipe_d = 0;
122 itlb_pipe_e = 0;
123 itlb_pipe_m = 0;
124 itlb_pipe_b = 0;
125 tid_e = 0;
126 tid_m = 0;
127 tid_b = 0;
128
129end // }
130
131//----------------------------------------------------------
132// Combo logic
133always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
134 case (tid_d)
135 2'b00: itlb_pipe_d = itlb_pipe_d0;
136 2'b01: itlb_pipe_d = itlb_pipe_d1;
137 2'b10: itlb_pipe_d = itlb_pipe_d2;
138 2'b11: itlb_pipe_d = itlb_pipe_d3;
139 endcase
140end // }
141
142//----------------------------------------------------------
143// Pipeline registers
144// Send Command to NAS
145
146always @ (posedge `SPC0.l2clk & ready) begin // {
147
148 tstamp = `TOP.core_cycle_cnt - 1;
149
150 // if POR|WMR, then no TLBread
151 if (`TOP.in_reset_core) begin // {
152
153 // flush pipeline during reset
154 itlb_pipe_e <= 0;
155 itlb_pipe_m <= 0;
156 itlb_pipe_b <= 0;
157
158 tid_e <= 0;
159 tid_m <= 0;
160 tid_b <= 0;
161
162 end // }
163 else begin // {
164
165 //---------------------------------
166 // Pipeline signals
167 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
168 itlb_pipe_m <= itlb_pipe_e;
169 itlb_pipe_b <= itlb_pipe_m;
170
171 tid_e <= inst_d ? tid_d : 0;
172 tid_m <= tid_e;
173 tid_b <= tid_m;
174
175 //---------------------------------
176 // ITLBREAD
177
178 if (inst_b) begin // {
179 if (ts_b==0) begin // {
180 `PR_ERROR ("tlb_sync", `ERROR,
181 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
182 mycid,newtid);
183 end // }
184 else begin // {
185 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
186 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
187 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
188
189 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core0[newtid]) begin // {
190 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
191 mycid,newtid,newtnum,ts_b,pc_b);
192 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
193
194 //--------------------
195 if (`PARGS.show_tlb_on) begin // {
196 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
197 mycid,newtid,pc_b,ts_b*`TOP.core_period);
198 end //}
199
200 end //}
201
202 end // }
203 end // }
204 end // in_reset}
205
206end // always}
207
208//----------------------------------------------------------
209`endif
210endmodule
211
212`endif
213`ifdef CORE_1
214
215module itlb_rd_c1 (
216
217 mytg,
218 itlb_pipe_d0,
219 itlb_pipe_d1,
220 itlb_pipe_d2,
221 itlb_pipe_d3
222);
223
224// common defines
225`include "tlb_sync.vh"
226
227parameter WIDTH = `TLB_FIFO_WIDTH;
228
229input mytg;
230input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
231input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
232input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
233input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
234`ifndef GATESIM
235
236reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
237reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
238reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
239reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
240reg [1:0] tid_e;
241reg [1:0] tid_m;
242reg [1:0] tid_b;
243
244wire [1:0] tid_d;
245wire inst_d;
246wire inst_b;
247wire [47:0] pc_b;
248
249reg [2:0] mycid;
250reg [5:0] mytnum;
251wire [5:0] newtnum;
252wire [2:0] newtid;
253wire [(`TS_WIDTH-1):0] ts_b;
254reg [(`TS_WIDTH-1):0] tstamp;
255reg ready;
256integer junk;
257
258initial begin // {
259 ready = 0;
260 @(posedge `SPC1.l2clk) ;
261 @(posedge `SPC1.l2clk) ;
262 ready = `PARGS.tlb_sync_on;
263 mycid = 1;
264end //}
265
266assign newtid = ((mytg*4) + tid_b);
267assign newtnum = (mycid * 8) + newtid;
268
269//----------------------------------------------------------
270// DUT probes
271
272assign tid_d = mytg ? `SPC1.dec.dec_tid1_d :
273 `SPC1.dec.dec_tid0_d;
274
275assign inst_d = mytg ? `SPC1.dec.dec_decode1_d :
276 `SPC1.dec.dec_decode0_d;
277
278assign inst_b = mytg ? |(`PROBES1.select_pc_b[7:4]) :
279 |(`PROBES1.select_pc_b[3:0]);
280
281assign pc_b = mytg ? `PROBES1.pc_1_b :
282 `PROBES1.pc_0_b;
283
284assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
285
286`ifdef TLB_FIFO_WIDE
287wire [7:0] ifu_err_vect;
288wire ifu_err_vld;
289assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
290assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
291`endif
292
293//----------------------------------------------------------
294// Initialize pipeline
295initial begin // {
296
297 @ (posedge `SPC1.l2clk);
298 // Initialize pipeline
299 itlb_pipe_d = 0;
300 itlb_pipe_e = 0;
301 itlb_pipe_m = 0;
302 itlb_pipe_b = 0;
303 tid_e = 0;
304 tid_m = 0;
305 tid_b = 0;
306
307end // }
308
309//----------------------------------------------------------
310// Combo logic
311always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
312 case (tid_d)
313 2'b00: itlb_pipe_d = itlb_pipe_d0;
314 2'b01: itlb_pipe_d = itlb_pipe_d1;
315 2'b10: itlb_pipe_d = itlb_pipe_d2;
316 2'b11: itlb_pipe_d = itlb_pipe_d3;
317 endcase
318end // }
319
320//----------------------------------------------------------
321// Pipeline registers
322// Send Command to NAS
323
324always @ (posedge `SPC1.l2clk & ready) begin // {
325
326 tstamp = `TOP.core_cycle_cnt - 1;
327
328 // if POR|WMR, then no TLBread
329 if (`TOP.in_reset_core) begin // {
330
331 // flush pipeline during reset
332 itlb_pipe_e <= 0;
333 itlb_pipe_m <= 0;
334 itlb_pipe_b <= 0;
335
336 tid_e <= 0;
337 tid_m <= 0;
338 tid_b <= 0;
339
340 end // }
341 else begin // {
342
343 //---------------------------------
344 // Pipeline signals
345 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
346 itlb_pipe_m <= itlb_pipe_e;
347 itlb_pipe_b <= itlb_pipe_m;
348
349 tid_e <= inst_d ? tid_d : 0;
350 tid_m <= tid_e;
351 tid_b <= tid_m;
352
353 //---------------------------------
354 // ITLBREAD
355
356 if (inst_b) begin // {
357 if (ts_b==0) begin // {
358 `PR_ERROR ("tlb_sync", `ERROR,
359 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
360 mycid,newtid);
361 end // }
362 else begin // {
363 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
364 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
365 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
366
367 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core1[newtid]) begin // {
368 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
369 mycid,newtid,newtnum,ts_b,pc_b);
370 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
371
372 //--------------------
373 if (`PARGS.show_tlb_on) begin // {
374 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
375 mycid,newtid,pc_b,ts_b*`TOP.core_period);
376 end //}
377
378 end //}
379
380 end // }
381 end // }
382 end // in_reset}
383
384end // always}
385
386//----------------------------------------------------------
387`endif
388endmodule
389
390`endif
391`ifdef CORE_2
392
393module itlb_rd_c2 (
394
395 mytg,
396 itlb_pipe_d0,
397 itlb_pipe_d1,
398 itlb_pipe_d2,
399 itlb_pipe_d3
400);
401
402// common defines
403`include "tlb_sync.vh"
404
405parameter WIDTH = `TLB_FIFO_WIDTH;
406
407input mytg;
408input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
409input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
410input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
411input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
412`ifndef GATESIM
413
414reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
415reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
416reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
417reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
418reg [1:0] tid_e;
419reg [1:0] tid_m;
420reg [1:0] tid_b;
421
422wire [1:0] tid_d;
423wire inst_d;
424wire inst_b;
425wire [47:0] pc_b;
426
427reg [2:0] mycid;
428reg [5:0] mytnum;
429wire [5:0] newtnum;
430wire [2:0] newtid;
431wire [(`TS_WIDTH-1):0] ts_b;
432reg [(`TS_WIDTH-1):0] tstamp;
433reg ready;
434integer junk;
435
436initial begin // {
437 ready = 0;
438 @(posedge `SPC2.l2clk) ;
439 @(posedge `SPC2.l2clk) ;
440 ready = `PARGS.tlb_sync_on;
441 mycid = 2;
442end //}
443
444assign newtid = ((mytg*4) + tid_b);
445assign newtnum = (mycid * 8) + newtid;
446
447//----------------------------------------------------------
448// DUT probes
449
450assign tid_d = mytg ? `SPC2.dec.dec_tid1_d :
451 `SPC2.dec.dec_tid0_d;
452
453assign inst_d = mytg ? `SPC2.dec.dec_decode1_d :
454 `SPC2.dec.dec_decode0_d;
455
456assign inst_b = mytg ? |(`PROBES2.select_pc_b[7:4]) :
457 |(`PROBES2.select_pc_b[3:0]);
458
459assign pc_b = mytg ? `PROBES2.pc_1_b :
460 `PROBES2.pc_0_b;
461
462assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
463
464`ifdef TLB_FIFO_WIDE
465wire [7:0] ifu_err_vect;
466wire ifu_err_vld;
467assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
468assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
469`endif
470
471//----------------------------------------------------------
472// Initialize pipeline
473initial begin // {
474
475 @ (posedge `SPC2.l2clk);
476 // Initialize pipeline
477 itlb_pipe_d = 0;
478 itlb_pipe_e = 0;
479 itlb_pipe_m = 0;
480 itlb_pipe_b = 0;
481 tid_e = 0;
482 tid_m = 0;
483 tid_b = 0;
484
485end // }
486
487//----------------------------------------------------------
488// Combo logic
489always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
490 case (tid_d)
491 2'b00: itlb_pipe_d = itlb_pipe_d0;
492 2'b01: itlb_pipe_d = itlb_pipe_d1;
493 2'b10: itlb_pipe_d = itlb_pipe_d2;
494 2'b11: itlb_pipe_d = itlb_pipe_d3;
495 endcase
496end // }
497
498//----------------------------------------------------------
499// Pipeline registers
500// Send Command to NAS
501
502always @ (posedge `SPC2.l2clk & ready) begin // {
503
504 tstamp = `TOP.core_cycle_cnt - 1;
505
506 // if POR|WMR, then no TLBread
507 if (`TOP.in_reset_core) begin // {
508
509 // flush pipeline during reset
510 itlb_pipe_e <= 0;
511 itlb_pipe_m <= 0;
512 itlb_pipe_b <= 0;
513
514 tid_e <= 0;
515 tid_m <= 0;
516 tid_b <= 0;
517
518 end // }
519 else begin // {
520
521 //---------------------------------
522 // Pipeline signals
523 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
524 itlb_pipe_m <= itlb_pipe_e;
525 itlb_pipe_b <= itlb_pipe_m;
526
527 tid_e <= inst_d ? tid_d : 0;
528 tid_m <= tid_e;
529 tid_b <= tid_m;
530
531 //---------------------------------
532 // ITLBREAD
533
534 if (inst_b) begin // {
535 if (ts_b==0) begin // {
536 `PR_ERROR ("tlb_sync", `ERROR,
537 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
538 mycid,newtid);
539 end // }
540 else begin // {
541 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
542 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
543 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
544
545 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core2[newtid]) begin // {
546 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
547 mycid,newtid,newtnum,ts_b,pc_b);
548 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
549
550 //--------------------
551 if (`PARGS.show_tlb_on) begin // {
552 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
553 mycid,newtid,pc_b,ts_b*`TOP.core_period);
554 end //}
555
556 end //}
557
558 end // }
559 end // }
560 end // in_reset}
561
562end // always}
563
564//----------------------------------------------------------
565`endif
566endmodule
567
568`endif
569`ifdef CORE_3
570
571module itlb_rd_c3 (
572
573 mytg,
574 itlb_pipe_d0,
575 itlb_pipe_d1,
576 itlb_pipe_d2,
577 itlb_pipe_d3
578);
579
580// common defines
581`include "tlb_sync.vh"
582
583parameter WIDTH = `TLB_FIFO_WIDTH;
584
585input mytg;
586input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
587input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
588input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
589input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
590`ifndef GATESIM
591
592reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
593reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
594reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
595reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
596reg [1:0] tid_e;
597reg [1:0] tid_m;
598reg [1:0] tid_b;
599
600wire [1:0] tid_d;
601wire inst_d;
602wire inst_b;
603wire [47:0] pc_b;
604
605reg [2:0] mycid;
606reg [5:0] mytnum;
607wire [5:0] newtnum;
608wire [2:0] newtid;
609wire [(`TS_WIDTH-1):0] ts_b;
610reg [(`TS_WIDTH-1):0] tstamp;
611reg ready;
612integer junk;
613
614initial begin // {
615 ready = 0;
616 @(posedge `SPC3.l2clk) ;
617 @(posedge `SPC3.l2clk) ;
618 ready = `PARGS.tlb_sync_on;
619 mycid = 3;
620end //}
621
622assign newtid = ((mytg*4) + tid_b);
623assign newtnum = (mycid * 8) + newtid;
624
625//----------------------------------------------------------
626// DUT probes
627
628assign tid_d = mytg ? `SPC3.dec.dec_tid1_d :
629 `SPC3.dec.dec_tid0_d;
630
631assign inst_d = mytg ? `SPC3.dec.dec_decode1_d :
632 `SPC3.dec.dec_decode0_d;
633
634assign inst_b = mytg ? |(`PROBES3.select_pc_b[7:4]) :
635 |(`PROBES3.select_pc_b[3:0]);
636
637assign pc_b = mytg ? `PROBES3.pc_1_b :
638 `PROBES3.pc_0_b;
639
640assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
641
642`ifdef TLB_FIFO_WIDE
643wire [7:0] ifu_err_vect;
644wire ifu_err_vld;
645assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
646assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
647`endif
648
649//----------------------------------------------------------
650// Initialize pipeline
651initial begin // {
652
653 @ (posedge `SPC3.l2clk);
654 // Initialize pipeline
655 itlb_pipe_d = 0;
656 itlb_pipe_e = 0;
657 itlb_pipe_m = 0;
658 itlb_pipe_b = 0;
659 tid_e = 0;
660 tid_m = 0;
661 tid_b = 0;
662
663end // }
664
665//----------------------------------------------------------
666// Combo logic
667always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
668 case (tid_d)
669 2'b00: itlb_pipe_d = itlb_pipe_d0;
670 2'b01: itlb_pipe_d = itlb_pipe_d1;
671 2'b10: itlb_pipe_d = itlb_pipe_d2;
672 2'b11: itlb_pipe_d = itlb_pipe_d3;
673 endcase
674end // }
675
676//----------------------------------------------------------
677// Pipeline registers
678// Send Command to NAS
679
680always @ (posedge `SPC3.l2clk & ready) begin // {
681
682 tstamp = `TOP.core_cycle_cnt - 1;
683
684 // if POR|WMR, then no TLBread
685 if (`TOP.in_reset_core) begin // {
686
687 // flush pipeline during reset
688 itlb_pipe_e <= 0;
689 itlb_pipe_m <= 0;
690 itlb_pipe_b <= 0;
691
692 tid_e <= 0;
693 tid_m <= 0;
694 tid_b <= 0;
695
696 end // }
697 else begin // {
698
699 //---------------------------------
700 // Pipeline signals
701 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
702 itlb_pipe_m <= itlb_pipe_e;
703 itlb_pipe_b <= itlb_pipe_m;
704
705 tid_e <= inst_d ? tid_d : 0;
706 tid_m <= tid_e;
707 tid_b <= tid_m;
708
709 //---------------------------------
710 // ITLBREAD
711
712 if (inst_b) begin // {
713 if (ts_b==0) begin // {
714 `PR_ERROR ("tlb_sync", `ERROR,
715 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
716 mycid,newtid);
717 end // }
718 else begin // {
719 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
720 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
721 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
722
723 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core3[newtid]) begin // {
724 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
725 mycid,newtid,newtnum,ts_b,pc_b);
726 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
727
728 //--------------------
729 if (`PARGS.show_tlb_on) begin // {
730 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
731 mycid,newtid,pc_b,ts_b*`TOP.core_period);
732 end //}
733
734 end //}
735
736 end // }
737 end // }
738 end // in_reset}
739
740end // always}
741
742//----------------------------------------------------------
743`endif
744endmodule
745
746`endif
747`ifdef CORE_4
748
749module itlb_rd_c4 (
750
751 mytg,
752 itlb_pipe_d0,
753 itlb_pipe_d1,
754 itlb_pipe_d2,
755 itlb_pipe_d3
756);
757
758// common defines
759`include "tlb_sync.vh"
760
761parameter WIDTH = `TLB_FIFO_WIDTH;
762
763input mytg;
764input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
765input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
766input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
767input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
768`ifndef GATESIM
769
770reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
771reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
772reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
773reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
774reg [1:0] tid_e;
775reg [1:0] tid_m;
776reg [1:0] tid_b;
777
778wire [1:0] tid_d;
779wire inst_d;
780wire inst_b;
781wire [47:0] pc_b;
782
783reg [2:0] mycid;
784reg [5:0] mytnum;
785wire [5:0] newtnum;
786wire [2:0] newtid;
787wire [(`TS_WIDTH-1):0] ts_b;
788reg [(`TS_WIDTH-1):0] tstamp;
789reg ready;
790integer junk;
791
792initial begin // {
793 ready = 0;
794 @(posedge `SPC4.l2clk) ;
795 @(posedge `SPC4.l2clk) ;
796 ready = `PARGS.tlb_sync_on;
797 mycid = 4;
798end //}
799
800assign newtid = ((mytg*4) + tid_b);
801assign newtnum = (mycid * 8) + newtid;
802
803//----------------------------------------------------------
804// DUT probes
805
806assign tid_d = mytg ? `SPC4.dec.dec_tid1_d :
807 `SPC4.dec.dec_tid0_d;
808
809assign inst_d = mytg ? `SPC4.dec.dec_decode1_d :
810 `SPC4.dec.dec_decode0_d;
811
812assign inst_b = mytg ? |(`PROBES4.select_pc_b[7:4]) :
813 |(`PROBES4.select_pc_b[3:0]);
814
815assign pc_b = mytg ? `PROBES4.pc_1_b :
816 `PROBES4.pc_0_b;
817
818assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
819
820`ifdef TLB_FIFO_WIDE
821wire [7:0] ifu_err_vect;
822wire ifu_err_vld;
823assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
824assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
825`endif
826
827//----------------------------------------------------------
828// Initialize pipeline
829initial begin // {
830
831 @ (posedge `SPC4.l2clk);
832 // Initialize pipeline
833 itlb_pipe_d = 0;
834 itlb_pipe_e = 0;
835 itlb_pipe_m = 0;
836 itlb_pipe_b = 0;
837 tid_e = 0;
838 tid_m = 0;
839 tid_b = 0;
840
841end // }
842
843//----------------------------------------------------------
844// Combo logic
845always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
846 case (tid_d)
847 2'b00: itlb_pipe_d = itlb_pipe_d0;
848 2'b01: itlb_pipe_d = itlb_pipe_d1;
849 2'b10: itlb_pipe_d = itlb_pipe_d2;
850 2'b11: itlb_pipe_d = itlb_pipe_d3;
851 endcase
852end // }
853
854//----------------------------------------------------------
855// Pipeline registers
856// Send Command to NAS
857
858always @ (posedge `SPC4.l2clk & ready) begin // {
859
860 tstamp = `TOP.core_cycle_cnt - 1;
861
862 // if POR|WMR, then no TLBread
863 if (`TOP.in_reset_core) begin // {
864
865 // flush pipeline during reset
866 itlb_pipe_e <= 0;
867 itlb_pipe_m <= 0;
868 itlb_pipe_b <= 0;
869
870 tid_e <= 0;
871 tid_m <= 0;
872 tid_b <= 0;
873
874 end // }
875 else begin // {
876
877 //---------------------------------
878 // Pipeline signals
879 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
880 itlb_pipe_m <= itlb_pipe_e;
881 itlb_pipe_b <= itlb_pipe_m;
882
883 tid_e <= inst_d ? tid_d : 0;
884 tid_m <= tid_e;
885 tid_b <= tid_m;
886
887 //---------------------------------
888 // ITLBREAD
889
890 if (inst_b) begin // {
891 if (ts_b==0) begin // {
892 `PR_ERROR ("tlb_sync", `ERROR,
893 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
894 mycid,newtid);
895 end // }
896 else begin // {
897 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
898 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
899 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
900
901 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core4[newtid]) begin // {
902 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
903 mycid,newtid,newtnum,ts_b,pc_b);
904 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
905
906 //--------------------
907 if (`PARGS.show_tlb_on) begin // {
908 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
909 mycid,newtid,pc_b,ts_b*`TOP.core_period);
910 end //}
911
912 end //}
913
914 end // }
915 end // }
916 end // in_reset}
917
918end // always}
919
920//----------------------------------------------------------
921`endif
922endmodule
923
924`endif
925`ifdef CORE_5
926
927module itlb_rd_c5 (
928
929 mytg,
930 itlb_pipe_d0,
931 itlb_pipe_d1,
932 itlb_pipe_d2,
933 itlb_pipe_d3
934);
935
936// common defines
937`include "tlb_sync.vh"
938
939parameter WIDTH = `TLB_FIFO_WIDTH;
940
941input mytg;
942input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
943input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
944input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
945input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
946`ifndef GATESIM
947
948reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
949reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
950reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
951reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
952reg [1:0] tid_e;
953reg [1:0] tid_m;
954reg [1:0] tid_b;
955
956wire [1:0] tid_d;
957wire inst_d;
958wire inst_b;
959wire [47:0] pc_b;
960
961reg [2:0] mycid;
962reg [5:0] mytnum;
963wire [5:0] newtnum;
964wire [2:0] newtid;
965wire [(`TS_WIDTH-1):0] ts_b;
966reg [(`TS_WIDTH-1):0] tstamp;
967reg ready;
968integer junk;
969
970initial begin // {
971 ready = 0;
972 @(posedge `SPC5.l2clk) ;
973 @(posedge `SPC5.l2clk) ;
974 ready = `PARGS.tlb_sync_on;
975 mycid = 5;
976end //}
977
978assign newtid = ((mytg*4) + tid_b);
979assign newtnum = (mycid * 8) + newtid;
980
981//----------------------------------------------------------
982// DUT probes
983
984assign tid_d = mytg ? `SPC5.dec.dec_tid1_d :
985 `SPC5.dec.dec_tid0_d;
986
987assign inst_d = mytg ? `SPC5.dec.dec_decode1_d :
988 `SPC5.dec.dec_decode0_d;
989
990assign inst_b = mytg ? |(`PROBES5.select_pc_b[7:4]) :
991 |(`PROBES5.select_pc_b[3:0]);
992
993assign pc_b = mytg ? `PROBES5.pc_1_b :
994 `PROBES5.pc_0_b;
995
996assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
997
998`ifdef TLB_FIFO_WIDE
999wire [7:0] ifu_err_vect;
1000wire ifu_err_vld;
1001assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
1002assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
1003`endif
1004
1005//----------------------------------------------------------
1006// Initialize pipeline
1007initial begin // {
1008
1009 @ (posedge `SPC5.l2clk);
1010 // Initialize pipeline
1011 itlb_pipe_d = 0;
1012 itlb_pipe_e = 0;
1013 itlb_pipe_m = 0;
1014 itlb_pipe_b = 0;
1015 tid_e = 0;
1016 tid_m = 0;
1017 tid_b = 0;
1018
1019end // }
1020
1021//----------------------------------------------------------
1022// Combo logic
1023always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
1024 case (tid_d)
1025 2'b00: itlb_pipe_d = itlb_pipe_d0;
1026 2'b01: itlb_pipe_d = itlb_pipe_d1;
1027 2'b10: itlb_pipe_d = itlb_pipe_d2;
1028 2'b11: itlb_pipe_d = itlb_pipe_d3;
1029 endcase
1030end // }
1031
1032//----------------------------------------------------------
1033// Pipeline registers
1034// Send Command to NAS
1035
1036always @ (posedge `SPC5.l2clk & ready) begin // {
1037
1038 tstamp = `TOP.core_cycle_cnt - 1;
1039
1040 // if POR|WMR, then no TLBread
1041 if (`TOP.in_reset_core) begin // {
1042
1043 // flush pipeline during reset
1044 itlb_pipe_e <= 0;
1045 itlb_pipe_m <= 0;
1046 itlb_pipe_b <= 0;
1047
1048 tid_e <= 0;
1049 tid_m <= 0;
1050 tid_b <= 0;
1051
1052 end // }
1053 else begin // {
1054
1055 //---------------------------------
1056 // Pipeline signals
1057 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
1058 itlb_pipe_m <= itlb_pipe_e;
1059 itlb_pipe_b <= itlb_pipe_m;
1060
1061 tid_e <= inst_d ? tid_d : 0;
1062 tid_m <= tid_e;
1063 tid_b <= tid_m;
1064
1065 //---------------------------------
1066 // ITLBREAD
1067
1068 if (inst_b) begin // {
1069 if (ts_b==0) begin // {
1070 `PR_ERROR ("tlb_sync", `ERROR,
1071 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
1072 mycid,newtid);
1073 end // }
1074 else begin // {
1075 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
1076 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
1077 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
1078
1079 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core5[newtid]) begin // {
1080 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
1081 mycid,newtid,newtnum,ts_b,pc_b);
1082 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
1083
1084 //--------------------
1085 if (`PARGS.show_tlb_on) begin // {
1086 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
1087 mycid,newtid,pc_b,ts_b*`TOP.core_period);
1088 end //}
1089
1090 end //}
1091
1092 end // }
1093 end // }
1094 end // in_reset}
1095
1096end // always}
1097
1098//----------------------------------------------------------
1099`endif
1100endmodule
1101
1102`endif
1103`ifdef CORE_6
1104
1105module itlb_rd_c6 (
1106
1107 mytg,
1108 itlb_pipe_d0,
1109 itlb_pipe_d1,
1110 itlb_pipe_d2,
1111 itlb_pipe_d3
1112);
1113
1114// common defines
1115`include "tlb_sync.vh"
1116
1117parameter WIDTH = `TLB_FIFO_WIDTH;
1118
1119input mytg;
1120input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
1121input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
1122input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
1123input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
1124`ifndef GATESIM
1125
1126reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
1127reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
1128reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
1129reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
1130reg [1:0] tid_e;
1131reg [1:0] tid_m;
1132reg [1:0] tid_b;
1133
1134wire [1:0] tid_d;
1135wire inst_d;
1136wire inst_b;
1137wire [47:0] pc_b;
1138
1139reg [2:0] mycid;
1140reg [5:0] mytnum;
1141wire [5:0] newtnum;
1142wire [2:0] newtid;
1143wire [(`TS_WIDTH-1):0] ts_b;
1144reg [(`TS_WIDTH-1):0] tstamp;
1145reg ready;
1146integer junk;
1147
1148initial begin // {
1149 ready = 0;
1150 @(posedge `SPC6.l2clk) ;
1151 @(posedge `SPC6.l2clk) ;
1152 ready = `PARGS.tlb_sync_on;
1153 mycid = 6;
1154end //}
1155
1156assign newtid = ((mytg*4) + tid_b);
1157assign newtnum = (mycid * 8) + newtid;
1158
1159//----------------------------------------------------------
1160// DUT probes
1161
1162assign tid_d = mytg ? `SPC6.dec.dec_tid1_d :
1163 `SPC6.dec.dec_tid0_d;
1164
1165assign inst_d = mytg ? `SPC6.dec.dec_decode1_d :
1166 `SPC6.dec.dec_decode0_d;
1167
1168assign inst_b = mytg ? |(`PROBES6.select_pc_b[7:4]) :
1169 |(`PROBES6.select_pc_b[3:0]);
1170
1171assign pc_b = mytg ? `PROBES6.pc_1_b :
1172 `PROBES6.pc_0_b;
1173
1174assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
1175
1176`ifdef TLB_FIFO_WIDE
1177wire [7:0] ifu_err_vect;
1178wire ifu_err_vld;
1179assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
1180assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
1181`endif
1182
1183//----------------------------------------------------------
1184// Initialize pipeline
1185initial begin // {
1186
1187 @ (posedge `SPC6.l2clk);
1188 // Initialize pipeline
1189 itlb_pipe_d = 0;
1190 itlb_pipe_e = 0;
1191 itlb_pipe_m = 0;
1192 itlb_pipe_b = 0;
1193 tid_e = 0;
1194 tid_m = 0;
1195 tid_b = 0;
1196
1197end // }
1198
1199//----------------------------------------------------------
1200// Combo logic
1201always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
1202 case (tid_d)
1203 2'b00: itlb_pipe_d = itlb_pipe_d0;
1204 2'b01: itlb_pipe_d = itlb_pipe_d1;
1205 2'b10: itlb_pipe_d = itlb_pipe_d2;
1206 2'b11: itlb_pipe_d = itlb_pipe_d3;
1207 endcase
1208end // }
1209
1210//----------------------------------------------------------
1211// Pipeline registers
1212// Send Command to NAS
1213
1214always @ (posedge `SPC6.l2clk & ready) begin // {
1215
1216 tstamp = `TOP.core_cycle_cnt - 1;
1217
1218 // if POR|WMR, then no TLBread
1219 if (`TOP.in_reset_core) begin // {
1220
1221 // flush pipeline during reset
1222 itlb_pipe_e <= 0;
1223 itlb_pipe_m <= 0;
1224 itlb_pipe_b <= 0;
1225
1226 tid_e <= 0;
1227 tid_m <= 0;
1228 tid_b <= 0;
1229
1230 end // }
1231 else begin // {
1232
1233 //---------------------------------
1234 // Pipeline signals
1235 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
1236 itlb_pipe_m <= itlb_pipe_e;
1237 itlb_pipe_b <= itlb_pipe_m;
1238
1239 tid_e <= inst_d ? tid_d : 0;
1240 tid_m <= tid_e;
1241 tid_b <= tid_m;
1242
1243 //---------------------------------
1244 // ITLBREAD
1245
1246 if (inst_b) begin // {
1247 if (ts_b==0) begin // {
1248 `PR_ERROR ("tlb_sync", `ERROR,
1249 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
1250 mycid,newtid);
1251 end // }
1252 else begin // {
1253 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
1254 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
1255 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
1256
1257 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core6[newtid]) begin // {
1258 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
1259 mycid,newtid,newtnum,ts_b,pc_b);
1260 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
1261
1262 //--------------------
1263 if (`PARGS.show_tlb_on) begin // {
1264 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
1265 mycid,newtid,pc_b,ts_b*`TOP.core_period);
1266 end //}
1267
1268 end //}
1269
1270 end // }
1271 end // }
1272 end // in_reset}
1273
1274end // always}
1275
1276//----------------------------------------------------------
1277`endif
1278endmodule
1279
1280`endif
1281`ifdef CORE_7
1282
1283module itlb_rd_c7 (
1284
1285 mytg,
1286 itlb_pipe_d0,
1287 itlb_pipe_d1,
1288 itlb_pipe_d2,
1289 itlb_pipe_d3
1290);
1291
1292// common defines
1293`include "tlb_sync.vh"
1294
1295parameter WIDTH = `TLB_FIFO_WIDTH;
1296
1297input mytg;
1298input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d0;
1299input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d1;
1300input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d2;
1301input [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d3;
1302`ifndef GATESIM
1303
1304reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_d;
1305reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_e;
1306reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_m;
1307reg [(`TLB_FIFO_WIDTH-1):0] itlb_pipe_b;
1308reg [1:0] tid_e;
1309reg [1:0] tid_m;
1310reg [1:0] tid_b;
1311
1312wire [1:0] tid_d;
1313wire inst_d;
1314wire inst_b;
1315wire [47:0] pc_b;
1316
1317reg [2:0] mycid;
1318reg [5:0] mytnum;
1319wire [5:0] newtnum;
1320wire [2:0] newtid;
1321wire [(`TS_WIDTH-1):0] ts_b;
1322reg [(`TS_WIDTH-1):0] tstamp;
1323reg ready;
1324integer junk;
1325
1326initial begin // {
1327 ready = 0;
1328 @(posedge `SPC7.l2clk) ;
1329 @(posedge `SPC7.l2clk) ;
1330 ready = `PARGS.tlb_sync_on;
1331 mycid = 7;
1332end //}
1333
1334assign newtid = ((mytg*4) + tid_b);
1335assign newtnum = (mycid * 8) + newtid;
1336
1337//----------------------------------------------------------
1338// DUT probes
1339
1340assign tid_d = mytg ? `SPC7.dec.dec_tid1_d :
1341 `SPC7.dec.dec_tid0_d;
1342
1343assign inst_d = mytg ? `SPC7.dec.dec_decode1_d :
1344 `SPC7.dec.dec_decode0_d;
1345
1346assign inst_b = mytg ? |(`PROBES7.select_pc_b[7:4]) :
1347 |(`PROBES7.select_pc_b[3:0]);
1348
1349assign pc_b = mytg ? `PROBES7.pc_1_b :
1350 `PROBES7.pc_0_b;
1351
1352assign ts_b = itlb_pipe_b[(`TS_WIDTH-1):0];
1353
1354`ifdef TLB_FIFO_WIDE
1355wire [7:0] ifu_err_vect;
1356wire ifu_err_vld;
1357assign ifu_err_vect = itlb_pipe_b[`TLB_FIFO_WIDTH-2:`TLB_FIFO_WIDTH-9];
1358assign ifu_err_vld = itlb_pipe_b[`TLB_FIFO_WIDTH-1];
1359`endif
1360
1361//----------------------------------------------------------
1362// Initialize pipeline
1363initial begin // {
1364
1365 @ (posedge `SPC7.l2clk);
1366 // Initialize pipeline
1367 itlb_pipe_d = 0;
1368 itlb_pipe_e = 0;
1369 itlb_pipe_m = 0;
1370 itlb_pipe_b = 0;
1371 tid_e = 0;
1372 tid_m = 0;
1373 tid_b = 0;
1374
1375end // }
1376
1377//----------------------------------------------------------
1378// Combo logic
1379always @ (tid_d or itlb_pipe_d0 or itlb_pipe_d1 or itlb_pipe_d2 or itlb_pipe_d3) begin // {
1380 case (tid_d)
1381 2'b00: itlb_pipe_d = itlb_pipe_d0;
1382 2'b01: itlb_pipe_d = itlb_pipe_d1;
1383 2'b10: itlb_pipe_d = itlb_pipe_d2;
1384 2'b11: itlb_pipe_d = itlb_pipe_d3;
1385 endcase
1386end // }
1387
1388//----------------------------------------------------------
1389// Pipeline registers
1390// Send Command to NAS
1391
1392always @ (posedge `SPC7.l2clk & ready) begin // {
1393
1394 tstamp = `TOP.core_cycle_cnt - 1;
1395
1396 // if POR|WMR, then no TLBread
1397 if (`TOP.in_reset_core) begin // {
1398
1399 // flush pipeline during reset
1400 itlb_pipe_e <= 0;
1401 itlb_pipe_m <= 0;
1402 itlb_pipe_b <= 0;
1403
1404 tid_e <= 0;
1405 tid_m <= 0;
1406 tid_b <= 0;
1407
1408 end // }
1409 else begin // {
1410
1411 //---------------------------------
1412 // Pipeline signals
1413 itlb_pipe_e <= inst_d ? itlb_pipe_d : 0;
1414 itlb_pipe_m <= itlb_pipe_e;
1415 itlb_pipe_b <= itlb_pipe_m;
1416
1417 tid_e <= inst_d ? tid_d : 0;
1418 tid_m <= tid_e;
1419 tid_b <= tid_m;
1420
1421 //---------------------------------
1422 // ITLBREAD
1423
1424 if (inst_b) begin // {
1425 if (ts_b==0) begin // {
1426 `PR_ERROR ("tlb_sync", `ERROR,
1427 "C%0d T%0d nas_probes/select_pc_b is asserted, but there is not a valid instruction in B stage for this thread.",
1428 mycid,newtid);
1429 end // }
1430 else begin // {
1431 // Must suppress PLI_ITLBREAD messages if th_check_enable=0.
1432 // This is required since the bench stops sending SSTEPs after th_check_enable=0 (on good/bad trap).
1433 // So, Bench must also stop sending ITLBREADs. Without SSTEPs, Riesling will not pop any ITLBREADs.
1434
1435 if (`PARGS.nas_check_on && `PARGS.tlb_sync_on && `PARGS.th_check_enable[newtnum] && `TOP.tlb_sync.nas_pipe_enabled_core7[newtid]) begin // {
1436 `PR_INFO ("pli_tlb", `INFO, "C%0d T%0d PLI_ITLBREAD tid=%d ts=%0d pc=%h",
1437 mycid,newtid,newtnum,ts_b,pc_b);
1438 junk = $sim_send(`PLI_ITLBREAD, newtnum,ts_b);
1439
1440 //--------------------
1441 if (`PARGS.show_tlb_on) begin // {
1442 $display ("SHOW_TLB: ITLB_READ C%0d T%0d pc=%h ts=%0d",
1443 mycid,newtid,pc_b,ts_b*`TOP.core_period);
1444 end //}
1445
1446 end //}
1447
1448 end // }
1449 end // }
1450 end // in_reset}
1451
1452end // always}
1453
1454//----------------------------------------------------------
1455`endif
1456endmodule
1457
1458`endif
1459//----------------------------------------------------------
1460//----------------------------------------------------------