OpenCores
URL https://opencores.org/ocsvn/s1_core/s1_core/trunk

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [tlu_tdp.v] - Blame information for rev 95

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: tlu_tdp.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21
///////////////////////////////////////////////////////////////////////
22
/*
23
//      Description:    Trap Datapath
24
*/
25
////////////////////////////////////////////////////////////////////////
26
// Global header file includes
27
////////////////////////////////////////////////////////////////////////
28
// system level definition file which contains the /*
29
/* ========== Copyright Header Begin ==========================================
30
*
31
* OpenSPARC T1 Processor File: sys.h
32
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
34
*
35
* The above named program is free software; you can redistribute it and/or
36
* modify it under the terms of the GNU General Public
37
* License version 2 as published by the Free Software Foundation.
38
*
39
* The above named program is distributed in the hope that it will be
40
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
41
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42
* General Public License for more details.
43
*
44
* You should have received a copy of the GNU General Public
45
* License along with this work; if not, write to the Free Software
46
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
47
*
48
* ========== Copyright Header End ============================================
49
*/
50
// -*- verilog -*-
51
////////////////////////////////////////////////////////////////////////
52
/*
53
//
54
// Description:         Global header file that contain definitions that
55
//                      are common/shared at the systme level
56
*/
57
////////////////////////////////////////////////////////////////////////
58
//
59
// Setting the time scale
60
// If the timescale changes, JP_TIMESCALE may also have to change.
61
`timescale      1ps/1ps
62
 
63
//
64
// JBUS clock
65
// =========
66
//
67
 
68
 
69
 
70
// Afara Link Defines
71
// ==================
72
 
73
// Reliable Link
74
 
75
 
76
 
77
 
78
// Afara Link Objects
79
 
80
 
81
// Afara Link Object Format - Reliable Link
82
 
83
 
84
 
85
 
86
 
87
 
88
 
89
 
90
 
91
 
92
// Afara Link Object Format - Congestion
93
 
94
 
95
 
96
 
97
 
98
 
99
 
100
 
101
 
102
 
103
 
104
// Afara Link Object Format - Acknowledge
105
 
106
 
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
// Afara Link Object Format - Request
117
 
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
 
134
// Afara Link Object Format - Message
135
 
136
 
137
 
138
// Acknowledge Types
139
 
140
 
141
 
142
 
143
// Request Types
144
 
145
 
146
 
147
 
148
 
149
// Afara Link Frame
150
 
151
 
152
 
153
//
154
// UCB Packet Type
155
// ===============
156
//
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
//
175
// UCB Data Packet Format
176
// ======================
177
//
178
 
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
// Size encoding for the UCB_SIZE_HI/LO field
209
// 000 - byte
210
// 001 - half-word
211
// 010 - word
212
// 011 - double-word
213
// 111 - quad-word
214
 
215
 
216
 
217
 
218
 
219
 
220
 
221
//
222
// UCB Interrupt Packet Format
223
// ===========================
224
//
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232
 
233
 
234
 
235
//`define UCB_THR_HI             9      // (6) cpu/thread ID shared with
236
//`define UCB_THR_LO             4             data packet format
237
//`define UCB_PKT_HI             3      // (4) packet type shared with
238
//`define UCB_PKT_LO             0      //     data packet format
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
//
247
// FCRAM Bus Widths
248
// ================
249
//
250
 
251
 
252
 
253
 
254
 
255
 
256
//
257
// ENET clock periods
258
// ==================
259
//
260
 
261
 
262
 
263
 
264
//
265
// JBus Bridge defines
266
// =================
267
//
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
 
279
//
280
// PCI Device Address Configuration
281
// ================================
282
//
283
 
284
 
285
 
286
 
287
 
288
 
289
 
290
 
291
 
292
 
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
 
305
 
306
                             // time scale definition
307
 
308
////////////////////////////////////////////////////////////////////////
309
// Local header file includes / local defines
310
////////////////////////////////////////////////////////////////////////
311
/*
312
/* ========== Copyright Header Begin ==========================================
313
*
314
* OpenSPARC T1 Processor File: tlu.h
315
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
316
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
317
*
318
* The above named program is free software; you can redistribute it and/or
319
* modify it under the terms of the GNU General Public
320
* License version 2 as published by the Free Software Foundation.
321
*
322
* The above named program is distributed in the hope that it will be
323
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
324
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
325
* General Public License for more details.
326
*
327
* You should have received a copy of the GNU General Public
328
* License along with this work; if not, write to the Free Software
329
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
330
*
331
* ========== Copyright Header End ============================================
332
*/
333
// ifu trap types
334
 
335
 
336
 
337
 
338
 
339
 
340
 
341
 
342
 
343
 
344
 
345
 
346
 
347
 
348
 
349
 
350
//
351
// modified for hypervisor support
352
//
353
 
354
 
355
 
356
 
357
 
358
 
359
 
360
 
361
 
362
 
363
 
364
 
365
 
366
 
367
 
368
 
369
 
370
 
371
 
372
 
373
 
374
 
375
 
376
 
377
//
378
 
379
 
380
// modified due to bug 2588
381
// `define      TSA_PSTATE_VRANGE2_LO 16 
382
 
383
 
384
//
385
 
386
 
387
 
388
 
389
 
390
 
391
 
392
 
393
 
394
 
395
 
396
//
397
// added due to Niagara SRAMs methodology
398
// The following defines have been replaced due
399
// the memory macro replacement from:
400
// bw_r_rf32x144 -> 2x bw_r_rf32x80
401
/*
402
`define TSA_MEM_WIDTH     144
403
`define TSA_HTSTATE_HI    142 //  3 bits
404
`define TSA_HTSTATE_LO    140
405
`define TSA_TPC_HI        138 // 47 bits
406
`define TSA_TPC_LO         92
407
`define TSA_TNPC_HI        90 // 47 bits
408
`define TSA_TNPC_LO        44
409
`define TSA_TSTATE_HI      40 // 29 bits
410
`define TSA_TSTATE_LO      12
411
`define TSA_TTYPE_HI        8 //  9 bits
412
`define TSA_TTYPE_LO        0
413
`define TSA_MEM_CWP_LO     12
414
`define TSA_MEM_CWP_HI     14
415
`define TSA_MEM_PSTATE_LO  15
416
`define TSA_MEM_PSTATE_HI  22
417
`define TSA_MEM_ASI_LO     23
418
`define TSA_MEM_ASI_HI     30
419
`define TSA_MEM_CCR_LO     31
420
`define TSA_MEM_CCR_HI     38
421
`define TSA_MEM_GL_LO      39
422
`define TSA_MEM_GL_HI      40
423
*/
424
 
425
 
426
 
427
 
428
 
429
 
430
 
431
 
432
 
433
 
434
 
435
//
436
 
437
 
438
 
439
 
440
 
441
 
442
 
443
 
444
 
445
 
446
 
447
// HPSTATE position definitions within wsr
448
 
449
 
450
 
451
 
452
 
453
 
454
// TSTATE postition definitions within wsr
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462
// modified due to bug 2588
463
 
464
 
465
// added for bug 2584 
466
 
467
 
468
 
469
 
470
//
471
 
472
 
473
 
474
 
475
 
476
 
477
 
478
//
479
// tick_cmp and stick_cmp definitions
480
 
481
 
482
 
483
 
484
 
485
//
486
// PIB WRAP
487
 
488
 
489
 
490
// HPSTATE postition definitions
491
 
492
 
493
 
494
 
495
 
496
 
497
// HTBA definitions
498
 
499
 
500
 
501
 
502
// TBA definitions
503
 
504
 
505
 
506
 
507
 
508
 
509
 
510
 
511
 
512
 
513
 
514
 
515
 
516
 
517
 
518
 
519
 
520
 
521
 
522
 
523
//
524
// added for the hypervisor support
525
 
526
 
527
// modified due to bug 2588
528
 
529
 
530
 
531
 
532
 
533
 
534
 
535
 
536
 
537
 
538
 
539
 
540
 
541
 
542
 
543
 
544
//
545
// compressed PSTATE WSR definitions
546
 
547
 
548
 
549
 
550
 
551
 
552
 
553
 
554
 
555
 
556
 
557
 
558
 
559
 
560
//
561
// ASI_QUEUE for hypervisor
562
// Queues are: CPU_MONODO
563
//             DEV_MONODO
564
//             RESUMABLE_ERROR
565
//             NON_RESUMABLE_ERROR
566
//
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
// for address range checking
575
 
576
 
577
 
578
 
579
 
580
 
581
 
582
 
583
 
584
 
585
 
586
 
587
 
588
 
589
 
590
 
591
//
592
// Niagara scratch-pads
593
// VA address of 0x20 and 0x28 are exclusive to hypervisor
594
// 
595
 
596
 
597
 
598
 
599
 
600
 
601
 
602
//
603
// range checking 
604
 
605
 
606
 
607
 
608
 
609
 
610
 
611
// PIB related definitions
612
// Bit definition for events
613
 
614
 
615
 
616
 
617
 
618
 
619
 
620
 
621
 
622
// 
623
// PIB related definitions
624
// PCR and PIC address definitions
625
 
626
 
627
 
628
// 
629
// PCR bit definitions
630
 
631
 
632
 
633
 
634
 
635
 
636
 
637
//
638
 
639
 
640
 
641
 
642
 
643
 
644
 
645
 
646
 
647
// PIC definitions
648
 
649
 
650
 
651
 
652
 
653
 
654
 
655
 
656
// PIC  mask bit position definitions
657
 
658
 
659
 
660
 
661
 
662
 
663
 
664
 
665
 
666
 
667
// added define from sparc_tlu_int.v 
668
 
669
 
670
 
671
 
672
 
673
 
674
 
675
 
676
 
677
 
678
//
679
// shadow scan related definitions 
680
 
681
// modified due to logic redistribution
682
// `define TCL_SSCAN_WIDTH 12 
683
 
684
 
685
 
686
 
687
 
688
// `define TCL_SSCAN_LO 51 
689
 
690
 
691
 
692
 
693
// 
694
// position definitions - TDP
695
 
696
 
697
 
698
 
699
 
700
 
701
// 
702
// position definitions - TCL
703
 
704
 
705
 
706
 
707
// 
708
// To speedup POR for verification purposes
709
 
710
 
711
//FPGA_SYN enables all FPGA related modifications
712
 
713
 
714
 
715
 
716
 
717
module tlu_tdp (/*AUTOARG*/
718
   // Outputs
719
   tlu_pib_rsr_data_e, tlu_restore_pc_w1, tlu_restore_npc_w1, tlu_partial_trap_pc_w1,
720
   tsa_wdata, tlu_int_pstate_ie, local_pstate_ie, tlu_ifu_pstate_pef,
721
   tlu_lsu_pstate_cle, tlu_lsu_pstate_priv, tlu_int_redmode, tlu_lsu_redmode,
722
   tlu_sscan_test_data,
723
   // modified for bug 1767
724
   tlu_pstate_am, tlu_sftint_id,
725
   // added for timing
726
   // modfied for hypervisor support
727
   tlu_dnrtry_global_g, tlu_tick_incr_din, tlu_exu_rsr_data_m,
728
   tlu_hpstate_priv, local_hpstate_priv, local_hpstate_enb, local_pstate_priv,
729
   tlu_hpstate_enb, tlu_hintp, tlu_por_rstint_g, tcl_hpstate_priv, tcl_hpstate_enb,
730
   tlu_trap_hpstate_enb, tlu_hpstate_tlz, tlu_asi_state_e, tlu_hpstate_ibe,
731
   so,
732
   // Inputs
733
   tsa_rdata, tlu_wsr_data_w, lsu_tlu_rsr_data_e, tlu_ibrkpt_trap_w2,
734
   // reset was modified to abide to the Niagara reset methodology
735
   rclk, tlu_rst, tlu_thrd_wsel_w2, ifu_lsu_imm_asi_d, // tm_l, 
736
   tlu_final_ttype_w2, tlu_pstate_din_sel0, tlu_pstate_din_sel1,
737
   tlu_pstate_din_sel2, tlu_pstate_din_sel3, ifu_lsu_imm_asi_vld_d,
738
   lsu_asi_reg0, lsu_asi_reg1, lsu_asi_reg2, lsu_asi_reg3,
739
   exu_tlu_ccr0_w, exu_tlu_ccr1_w, exu_tlu_ccr2_w, exu_tlu_ccr3_w,
740
   exu_tlu_cwp0, exu_tlu_cwp1, exu_tlu_cwp2, exu_tlu_cwp3, tlu_trap_cwp_en,
741
   tlu_pc_new_w, tlu_npc_new_w, tlu_sftint_en_l_g, tlu_sftint_mx_sel,
742
   tlu_set_sftint_l_g, tlu_wr_tsa_inst_w2,  tlu_clr_sftint_l_g,
743
   tlu_wr_sftint_l_g, tlu_sftint_penc_sel, tlu_tba_en_l, tlu_tick_en_l,
744
   tlu_tickcmp_sel, tlu_tickcmp_en_l, // tlu_retry_inst_m, tlu_done_inst_m, 
745
   tlu_update_pc_l_w, tlu_tl_gt_0_w2, pib_pich_wrap, // tlu_dnrtry_inst_m_l, 
746
   tlu_select_tba_w2, tlu_select_redmode, tlu_update_pstate_l_w2, tlu_pil,
747
   tlu_trp_lvl, tlu_tick_npt, tlu_thrd_rsel_e, tlu_tick_incr_dout,
748
   tlu_rdpr_mx1_sel, tlu_rdpr_mx2_sel, tlu_rdpr_mx3_sel, tlu_rdpr_mx4_sel,
749
   tlu_hpstate_din_sel0, tlu_hpstate_din_sel1, tlu_pc_mxsel_w2,
750
   tlu_hpstate_din_sel2, tlu_hpstate_din_sel3, tlu_update_hpstate_l_w2,
751
   tlu_htba_en_l, tlu_rdpr_mx5_sel, tlu_rdpr_mx6_sel, pib_picl_wrap,
752
   tlu_rdpr_mx7_sel, tlu_htickcmp_intdis, tlu_stickcmp_en_l, tlu_htickcmp_en_l,
753
   tlu_gl_lvl0, tlu_gl_lvl1, tlu_gl_lvl2, tlu_gl_lvl3, tlu_wr_hintp_g,
754
   tlu_set_hintp_sel_g, ctu_sscan_tid, si, se
755
   );
756
 
757
/*AUTOINPUT*/
758
// Beginning of automatic inputs (from unused autoinst inputs)
759
// End of automatics
760
input   [134-1:0] tsa_rdata;                // rd data for tsa.
761
input   [4-1:0] tlu_por_rstint_g;
762
//
763
// modified for timing
764
input   [64-1:0] tlu_wsr_data_w; // pr/st data from irf.
765
 
766
input   [7:0]    lsu_tlu_rsr_data_e;     // lsu sr/pr read data
767
 
768
input           rclk;                   // clock
769
//
770
// reset was removed to abide to the Niagara reset methodology 
771
input tlu_rst;                             // unit-reset
772
input [4-1:0] tlu_thrd_wsel_w2;// thread requiring tsa write.
773
input [9-1:0]    tlu_final_ttype_w2;        // selected ttype - g
774
input tlu_ibrkpt_trap_w2;       // instruction brkpt trap 
775
input tlu_trap_hpstate_enb;     // mode indicator for the trapped thrd 
776
input tlu_wr_tsa_inst_w2;       // write state inst
777
input [1:0]  tlu_pstate_din_sel0; // sel source of tsa wdata
778
input [1:0]  tlu_pstate_din_sel1; // sel source of tsa wdata
779
input [1:0]  tlu_pstate_din_sel2; // sel source of tsa wdata
780
input [1:0]  tlu_pstate_din_sel3; // sel source of tsa wdata
781
input [8-1:0] lsu_asi_reg0; // asi state - thread0
782
input [8-1:0] lsu_asi_reg1; // asi state - thread1
783
input [8-1:0] lsu_asi_reg2; // asi state - thread2
784
input [8-1:0] lsu_asi_reg3; // asi state - thread3
785
input [8-1:0] ifu_lsu_imm_asi_d; // asi state value from imm 
786
input ifu_lsu_imm_asi_vld_d; // valid asi state value from imm
787
 
788
input [3:0]       tlu_tickcmp_sel;  // select src for tickcmp
789
input [3:0]       tlu_tickcmp_en_l; // tick cmp reg write enable
790
input        tlu_tick_en_l;        // tick reg write enable
791
 
792
// overflow for the pic registers - lvl15 int 
793
// input  [`TLU_THRD_NUM-1:0] pib_pic_wrap; 
794
input  [4-1:0] pib_pich_wrap;
795
input  [4-1:0] pib_picl_wrap;
796
 
797
input [7:0]  exu_tlu_ccr0_w;  // ccr - thread0
798
input [7:0]  exu_tlu_ccr1_w;  // ccr - thread1
799
input [7:0]  exu_tlu_ccr2_w;  // ccr - thread2
800
input [7:0]  exu_tlu_ccr3_w;  // ccr - thread3
801
// input [2:0]  exu_tlu_cwp0_w;  // cwp - thread0
802
// input [2:0]  exu_tlu_cwp1_w;  // cwp - thread1
803
// input [2:0]  exu_tlu_cwp2_w;  // cwp - thread2
804
// input [2:0]  exu_tlu_cwp3_w;  // cwp - thread3
805
input [2:0]  exu_tlu_cwp0;  // cwp - thread0
806
input [2:0]  exu_tlu_cwp1;  // cwp - thread1
807
input [2:0]  exu_tlu_cwp2;  // cwp - thread2
808
input [2:0]  exu_tlu_cwp3;  // cwp - thread3
809
// added for bug3499
810
input [4-1:0] tlu_trap_cwp_en;
811
// modified due to bug 3017
812
// input [47:0] ifu_tlu_pc_m;     // pc
813
// input [47:0] ifu_tlu_npc_m;   // npc
814
// modified due to redistribution of logic
815
// input [48:0] ifu_tlu_pc_m;     // pc
816
// input [48:0] ifu_tlu_npc_m;   // npc
817
input [48:0] tlu_pc_new_w;         // pc
818
input [48:0] tlu_npc_new_w;   // npc
819
 
820
input [3:0]       tlu_sftint_en_l_g; // wr enable for sftint regs.
821
input [3:0]       tlu_sftint_mx_sel; // mux select for sftint regs 
822
input        tlu_set_sftint_l_g;       // set sftint
823
input        tlu_clr_sftint_l_g;       // clr sftint
824
input        tlu_wr_sftint_l_g;        // wr to sftin (asr 16)
825
//
826
// removed due to sftint recode
827
// input [3:0]   tlu_sftint_lvl14_int;  // sftint lvl 14 plus tick int
828
input [3:0]       tlu_sftint_penc_sel;
829
input [3:0]       tlu_tba_en_l;             // tba reg write enable
830
// logic moved to tlu_misctl
831
// input                 tlu_retry_inst_m;         // valid retry inst
832
// input                 tlu_done_inst_m;          // valid done inst
833
// input                 tlu_dnrtry_inst_m;        // valid done/retry inst - g
834
// input                 tlu_dnrtry_inst_m_l;      // valid done/retry inst - g
835
// input [3:0]   tlu_update_pc_l_m;        // update pc or npc for a thread
836
input [3:0]       tlu_update_pc_l_w;        // update pc or npc for a thread
837
// modified due to timing
838
// input                 tlu_self_boot_rst_g;
839
// input                 tlu_tl_gt_0_g;            // trp lvl gt then 0
840
// input                 tlu_select_tba_g;
841
// input tlu_select_htba_g;   // choosing htba for forming trappc/trapnpc 
842
// input tlu_self_boot_rst_w2;
843
// added for one-hot mux problem
844
input [2:0] tlu_pc_mxsel_w2;
845
input tlu_tl_gt_0_w2;     // trp lvl gt then 0
846
input tlu_select_tba_w2;
847
input [4-1:0] tlu_update_pstate_l_w2; // pstate write enable
848
input [4-1:0] tlu_thrd_rsel_e; // read select for threaded regs
849
input [3:0] tlu_pil;     // mx'ed pil
850
input [2:0] tlu_trp_lvl; // mx'ed trp lvl
851
 
852
input tlu_select_redmode;
853
input tlu_tick_npt;       // npt bit of tick
854
 
855
input [64-4:0] tlu_tick_incr_dout;
856
//
857
// added and/or modified for hypervisor support
858
input [1:0] tlu_hpstate_din_sel0; // sel source of tsa wdata
859
input [1:0] tlu_hpstate_din_sel1; // sel source of tsa wdata
860
input [1:0] tlu_hpstate_din_sel2; // sel source of tsa wdata
861
input [1:0] tlu_hpstate_din_sel3; // sel source of tsa wdata
862
input [4-1:0] tlu_stickcmp_en_l; // stick cmp reg write enable
863
input [4-1:0] tlu_htickcmp_en_l; // htick cmp reg write enable
864
input [4-1:0] tlu_wr_hintp_g;    // wr control for hintp regs.
865
input [4-1:0] tlu_set_hintp_sel_g; // set control for hintp regs.
866
input [4-1:0] tlu_htba_en_l;     // htba reg write enable
867
input [4-1:0] tlu_update_hpstate_l_w2; // hpstate write enable
868
input tlu_htickcmp_intdis; // int. disable bit of htick-cmp
869
input [2-1:0] tlu_gl_lvl0; // global register value t0 
870
input [2-1:0] tlu_gl_lvl1; // global register value t1 
871
input [2-1:0] tlu_gl_lvl2; // global register value t2 
872
input [2-1:0] tlu_gl_lvl3; // global register value t3 
873
// mux select to read the new ASR registers
874
input [3:1] tlu_rdpr_mx1_sel;
875
input [3:1] tlu_rdpr_mx2_sel;
876
input [2:1] tlu_rdpr_mx3_sel;
877
input [2:1] tlu_rdpr_mx4_sel;
878
input [3:1] tlu_rdpr_mx5_sel;
879
input [2:0] tlu_rdpr_mx6_sel;
880
input [3:0] tlu_rdpr_mx7_sel;
881
//
882
input [4-1:0] ctu_sscan_tid;
883
input [64-1:0] tlu_pib_rsr_data_e; // rsr data from pib 
884
 
885
input si; // scan-in
886
input se; // scan-en
887
 
888
/*AUTOOUTPUT*/
889
// Beginning of automatic outputs (from unused autoinst outputs)
890
// End of automatics
891
//
892
// modified due to bug 3017
893
output [48:0] tlu_restore_pc_w1;  // trap pc or pc on retry.
894
output [48:0] tlu_restore_npc_w1; // trap pc or pc on retry.
895
output [33:0] tlu_partial_trap_pc_w1;
896
// the tlu_exu_rsr_data_e will become obsolete, to be removed
897
// added for timing
898
// output [`TLU_ASR_DATA_WIDTH-1:0] tlu_exu_rsr_data_e; // rsr data to exu 
899
output [64-1:0] tlu_exu_rsr_data_m; // rsr data to exu 
900
// modified due to timing violations
901
// output [`TLU_ASR_DATA_WIDTH-1:0] tlu_pib_rsr_data_e; // trap pc or pc on retry.
902
//
903
// modified for hypervisor support
904
output [136-1:0] tsa_wdata; // wr data for tsa.
905
//
906
output [4-1:0] tlu_int_pstate_ie;   // interrupt enable
907
output [4-1:0] local_pstate_ie;   // interrupt enable
908
output [4-1:0] tlu_ifu_pstate_pef;  // fp enable
909
output [4-1:0] tlu_lsu_pstate_cle;  // current little endian
910
output [4-1:0] tlu_lsu_pstate_priv; // privilege mode
911
output [4-1:0] tlu_int_redmode;    // redmode
912
output [4-1:0] tlu_lsu_redmode;    // redmode
913
// modified for bug 1767
914
// output   [1:0] tlu_pstate0_mmodel; // mem. model - thread0
915
// output   [1:0] tlu_pstate1_mmodel; // mem. model - thread1
916
// output   [1:0] tlu_pstate2_mmodel; // mem. model - thread2
917
// output   [1:0] tlu_pstate3_mmodel; // mem. model - thread3
918
// output   [3:0] tlu_pstate_tle;         // trap little endian
919
// output [`TLU_THRD_NUM-1:0] tlu_pstate_cle;  // current little endian
920
// output [`TLU_THRD_NUM-1:0] tlu_pstate_priv; // privilege mode
921
output [4-1:0] tlu_pstate_am;   // address mask
922
//
923
// removed for bug 2187
924
// output [`TLU_THRD_NUM-1:0] tlu_sftint_lvl14;
925
output [4-1:0] tlu_hpstate_priv; // hypervisor privilege 
926
output [4-1:0] tlu_hpstate_enb;  // hypervisor lite enb  
927
output [4-1:0] tlu_hpstate_tlz;  // hypervisor tlz 
928
output [4-1:0] tlu_hpstate_ibe;  // hypervisor instruction brkpt 
929
output [4-1:0] local_hpstate_priv; // hypervisor privilege       
930
output [4-1:0] tcl_hpstate_priv; // hypervisor privilege 
931
output [4-1:0] local_pstate_priv;  // pstate privilege   
932
output [4-1:0] local_hpstate_enb;  // hypervisor lite enb        
933
output [4-1:0] tcl_hpstate_enb;  // hypervisor lite enb  
934
output [3:0] tlu_sftint_id;
935
// output       tlu_tick_match; // tick to tick cmp match
936
// output       tlu_stick_match;        // stick to tick cmp match
937
// output       tlu_htick_match;        // htick to tick cmp match
938
// output [`TLU_ASR_DATA_WIDTH-1:0] tlu_tick_incr_din;
939
output [64-3:0] tlu_tick_incr_din;
940
//
941
// modified for hypervisor support
942
// output       [2:0]   tlu_restore_globals; // restored global regs
943
//
944
output [2-1:0] tlu_dnrtry_global_g; // restored globals 
945
output [4-1:0]     tlu_hintp;
946
// 
947
// current asi state 
948
output [8-1:0] tlu_asi_state_e;
949
//
950
// modified due to race key word limitation
951
// output [62:0] tlu_sscan_test_data;
952
output [51-1:0] tlu_sscan_test_data;
953
output            so; // scan-out;
954
 
955
/*AUTOWIRE*/
956
// Beginning of automatic wires (for undeclared instantiated-module outputs)
957
// End of automatics
958
//
959
// local reset was added to abide to the Niagara reset methodology 
960
wire        local_rst; // local reset
961
wire        se_l; // testmode_l replacement 
962
//
963
// rdpr muxe outputs
964
wire [64-1:0] tlu_rdpr_mx1_out;
965
wire [3:0]  tlu_rdpr_mx2_out;
966
wire [17-1:0]  tlu_rdpr_mx3_out;
967
wire [48-1:0]  tlu_rdpr_mx4_out;
968
// 
969
// constructing one-hot selects
970
wire rdpr_mx1_onehot_sel, rdpr_mx2_onehot_sel;
971
wire rdpr_mx3_onehot_sel, rdpr_mx4_onehot_sel;
972
wire rdpr_mx5_onehot_sel, rdpr_mx6_onehot_sel;
973
//
974
wire  [32:0] true_tba0,true_tba1,true_tba2,true_tba3;
975
wire  [60:0] true_tick;
976
// modified due to bug 3017
977
wire  [48:0] true_pc0,true_pc1,true_pc2,true_pc3;
978
// wire  [47:0] sscan_pc; 
979
wire  [51-1:0] sscan_data_test0;
980
wire  [51-1:0] sscan_data_test1;
981
wire  [51-1:0] sscan_data_test2;
982
wire  [51-1:0] sscan_data_test3;
983
wire  [51-1:0] tdp_sscan_test_data;
984
wire  [4-1:0] sscan_tid_sel;
985
wire  [48:0] true_npc0,true_npc1,true_npc2,true_npc3;
986
// wire  [47:0] true_npc0,true_npc1,true_npc2,true_npc3;
987
// wire  [47:0] true_pc0,true_pc1,true_pc2,true_pc3;
988
// wire  [47:0] sscan_pc; 
989
// wire  [47:0] normal_trap_pc, normal_trap_npc;
990
//
991
// modified for hypervisor support
992
wire [136-1:0] trap_tsa_wdata;
993
wire [136-1:0] trap0_tsa_wdata,trap1_tsa_wdata;
994
wire [136-1:0] trap2_tsa_wdata,trap3_tsa_wdata;
995
wire [136-1:0] wrpr_tsa_wdata;
996
wire [136-1:0] tsa_wdata;
997
wire [48-1:0]  tstate_rdata;
998
wire [1:0]  tstate_dummy_zero;
999
wire [29-1:0]   compose_tstate;
1000
wire [4-1:0]  compose_htstate;
1001
wire [2-1:0]   global_rdata;
1002
// wire [`TLU_ASR_DATA_WIDTH-1:0] wsr_data_w;   
1003
wire [17-1:0] wsr_data_w;
1004
// reduced width to 48 due to lint violations
1005
wire [47:0] wsr_data_w2;
1006
//
1007
// modified for bug 3017
1008
// wire  [47:2] trap_pc0,trap_pc1,trap_pc2,trap_pc3;
1009
// wire  [47:2] trap_npc0,trap_npc1,trap_npc2,trap_npc3;
1010
wire  [48:2] trap_pc0,trap_pc1,trap_pc2,trap_pc3;
1011
wire  [48:2] trap_npc0,trap_npc1,trap_npc2,trap_npc3;
1012
wire   [7:0] trap_ccr0,trap_ccr1,trap_ccr2,trap_ccr3;
1013
wire   [7:0] trap_asi0,trap_asi1,trap_asi2,trap_asi3;
1014
wire   [2:0] trap_cwp0,trap_cwp1,trap_cwp2,trap_cwp3;
1015
wire   [2:0] tlu_cwp0,tlu_cwp1,tlu_cwp2,tlu_cwp3;
1016
wire   [8-1:0] imm_asi_e;
1017
wire   [8-1:0] asi_state_reg_e;
1018
wire   [8-1:0] asi_state_final_e;
1019
wire   imm_asi_vld_e;
1020
//
1021
// modified due to tickcmp, stickcmp and sftint cleanup
1022
// wire  [15:0] sftint0, sftint1, sftint2, sftint3;
1023
// wire  [15:1] sftint_set_din, sftint_clr_din, sftint_wr_din;
1024
wire  [17-1:0] sftint0, sftint1, sftint2, sftint3;
1025
wire  [17-1:0] sftint_set_din, sftint_clr_din, sftint_wr_din;
1026
wire [17-1:0] sftint_din;
1027
wire [17-1:0] sftint;
1028
wire [4-1:0] sftint_b0_din;
1029
wire [4-1:0] sftint_b0_en;
1030
wire [4-1:0] sftint_b15_din;
1031
wire [4-1:0] sftint_b15_en;
1032
wire [4-1:0] sftint_b16_din;
1033
wire [4-1:0] sftint_b16_en;
1034
wire [4-1:0] sftint_lvl14;
1035
wire [3:0] sftin_din_mxsel;
1036
// recoded for one-hot problem during reset
1037
// wire sftint_sel_onehot_g;
1038
//
1039
// added for PIB support
1040
wire         tcmp0_clk, tcmp1_clk;
1041
wire         tcmp2_clk, tcmp3_clk;
1042
wire [14:0]  sftint_penc_din;
1043
wire         sftint0_clk,sftint1_clk;
1044
wire         sftint2_clk,sftint3_clk;
1045
// 
1046
wire [32:0] tba_data;
1047
wire [32:0] tba_rdata;
1048
wire [33:0] tlu_rstvaddr_base;
1049
wire [34-1:0] htba_data;
1050
wire        tba0_clk,tba1_clk,tba2_clk,tba3_clk;
1051
// modified for bug 3017
1052
// wire [46:0] tsa_pc_m,tsa_npc_m;
1053
// wire [48:0] dnrtry_pc,dnrtry_npc;
1054
wire [48:0] restore_pc_w2;
1055
wire [48:0] restore_npc_w2;
1056
// wire [48:0]  pc_new, npc_new;
1057
// wire [48:0]  pc_new_w, npc_new_w;
1058
wire [33:0] partial_trap_pc_w2;
1059
wire        pc0_clk,pc1_clk,pc2_clk,pc3_clk;
1060
// wire [`TLU_TSA_WIDTH-1:0] tsa_data_m;
1061
wire [64-1:0] true_tickcmp0, true_tickcmp1;
1062
wire [64-1:0] true_tickcmp2, true_tickcmp3;
1063
wire [64-1:0] tickcmp_rdata;
1064
wire [4-1:0] tickcmp_intdis_din;
1065
wire [4-1:0] tickcmp_intdis_en;
1066
wire [4-1:0] tickcmp_int;
1067
wire [4-1:0] tlu_set_hintp_g;
1068
wire [4-1:0] tlu_hintp_en_l_g;
1069
wire tlu_htick_match;   // htick to tick cmp match
1070
wire tick_match;
1071
wire [64-4:0] tickcmp_data;
1072
wire [64-2:2] tick_din;
1073
// reg   [`TLU_ASR_DATA_WIDTH-1:0] tlu_rsr_data_e;
1074
wire [12-1:0] true_pstate0,true_pstate1;
1075
wire [12-1:0] true_pstate2,true_pstate3;
1076
// wire [`TLU_THRD_NUM-1:0] tlu_pstate_priv; // privilege mode
1077
// added for hypervisor support 
1078
wire [8-1:0] trap_pstate0,trap_pstate1;
1079
wire [8-1:0] trap_pstate2,trap_pstate3;
1080
//
1081
// wire [`PSTATE_TRUE_WIDTH-1:0] dnrtry_pstate;
1082
// wire [`PSTATE_TRUE_WIDTH-1:0] dnrtry_pstate_m;       
1083
// wire [`PSTATE_TRUE_WIDTH-1:0] wsr_data_pstate_g;     
1084
wire [6-1:0] dnrtry_pstate_m;
1085
wire [6-1:0] dnrtry_pstate_g;
1086
wire [6-1:0] dnrtry_pstate_w2;
1087
// removed for timing
1088
// wire [`WSR_PSTATE_VR_WIDTH-1:0] wsr_data_pstate_g;
1089
wire [6-1:0] wsr_data_pstate_w2;
1090
//
1091
// modified for bug 1767
1092
//wire [`PSTATE_TRUE_WIDTH-1:0] ntrap_pstate;
1093
// wire [`PSTATE_TRUE_WIDTH-1:0] ntrap_pstate0;
1094
// wire [`PSTATE_TRUE_WIDTH-1:0] ntrap_pstate1;
1095
// wire [`PSTATE_TRUE_WIDTH-1:0] ntrap_pstate2;
1096
// wire [`PSTATE_TRUE_WIDTH-1:0] ntrap_pstate3;
1097
wire [6-1:0] ntrap_pstate0;
1098
wire [6-1:0] ntrap_pstate1;
1099
wire [6-1:0] ntrap_pstate2;
1100
wire [6-1:0] ntrap_pstate3;
1101
// modified for bug 2161 and 2584
1102
wire pstate_priv_set, hpstate_priv_set;
1103
wire [4-1:0] pstate_priv_thrd_set;
1104
// wire [`TLU_THRD_NUM-1:0] pstate_priv_update_g;
1105
wire [4-1:0] pstate_priv_update_w2;
1106
// wire [`TLU_THRD_NUM-1:0] hpstate_dnrtry_priv_g;
1107
wire [4-1:0] hpstate_dnrtry_priv_w2;
1108
wire [4-1:0] hpstate_enb_set;
1109
wire [4-1:0] hpstate_ibe_set;
1110
wire [4-1:0] hpstate_tlz_set;
1111
// wire [`TLU_THRD_NUM-1:0] hpstate_priv_update_g;
1112
wire [4-1:0] hpstate_priv_update_w2;
1113
//
1114
// removed for bug 2588
1115
// wire [1:0] tlu_select_mmodel0;
1116
// wire [1:0] tlu_select_mmodel1;
1117
// wire [1:0] tlu_select_mmodel2;
1118
// wire [1:0] tlu_select_mmodel3;
1119
wire [4-1:0] tlu_select_tle;
1120
wire [4-1:0] tlu_select_cle;
1121
// wire [1:0] tlu_pstate0_mmodel;       // mem. model - thread0
1122
// wire [1:0] tlu_pstate1_mmodel;       // mem. model - thread1
1123
// wire [1:0] tlu_pstate2_mmodel;       // mem. model - thread2
1124
// wire [1:0] tlu_pstate3_mmodel;       // mem. model - thread3
1125
wire [4-1:0] tlu_pstate_tle; // trap little endian
1126
//
1127
// modified for bug 1575
1128
// wire [`PSTATE_TRUE_WIDTH-1:0]        restore_pstate;
1129
// wire [`PSTATE_TRUE_WIDTH-1:0]        restore_pstate0;
1130
// wire [`PSTATE_TRUE_WIDTH-1:0]        restore_pstate1;
1131
// wire [`PSTATE_TRUE_WIDTH-1:0]        restore_pstate2; 
1132
// wire [`PSTATE_TRUE_WIDTH-1:0]        restore_pstate3;
1133
wire [6-1:0]     restore_pstate0;
1134
wire [6-1:0]     restore_pstate1;
1135
wire [6-1:0]     restore_pstate2;
1136
wire [6-1:0]     restore_pstate3;
1137
wire [6-1:0]     restore_pstate0_w3;
1138
wire [6-1:0]     restore_pstate1_w3;
1139
wire [6-1:0]     restore_pstate2_w3;
1140
wire [6-1:0]     restore_pstate3_w3;
1141
wire tlu_pstate_nt_sel0, tlu_pstate_nt_sel1;
1142
wire tlu_pstate_nt_sel2, tlu_pstate_nt_sel3;
1143
wire tlu_pstate_wsr_sel0, tlu_pstate_wsr_sel1;
1144
wire tlu_pstate_wsr_sel2, tlu_pstate_wsr_sel3;
1145
wire hpstate_redmode;
1146
wire pstate0_clk,pstate1_clk,pstate2_clk,pstate3_clk;
1147
 
1148
//
1149
// added or modified for hypervisor support
1150
// wire [2:0]   global_sel;     
1151
wire stcmp0_clk, stcmp1_clk, stcmp2_clk, stcmp3_clk;
1152
wire htcmp0_clk, htcmp1_clk, htcmp2_clk, htcmp3_clk;
1153
wire tlu_hpstate_hnt_sel0, tlu_hpstate_hnt_sel1;
1154
wire tlu_hpstate_hnt_sel2, tlu_hpstate_hnt_sel3;
1155
wire tlu_hpstate_wsr_sel0, tlu_hpstate_wsr_sel1;
1156
wire tlu_hpstate_wsr_sel2, tlu_hpstate_wsr_sel3;
1157
wire pc_bit15_sel;
1158
wire htba0_clk,htba1_clk,htba2_clk,htba3_clk;
1159
wire hpstate0_clk,hpstate1_clk,hpstate2_clk,hpstate3_clk;
1160
wire hintp0_clk,hintp1_clk,hintp2_clk,hintp3_clk;
1161
wire hintp_rdata;
1162
wire [4-1:0]       hintp_din;
1163
// added or modified due to stickcmp clean-up
1164
// wire [`TLU_ASR_DATA_WIDTH-2:0] stickcmp_rdata;
1165
// wire [`TLU_ASR_DATA_WIDTH-2:0] true_stickcmp0, true_stickcmp1;
1166
// wire [`TLU_ASR_DATA_WIDTH-2:0] true_stickcmp2, true_stickcmp3;
1167
wire [64-1:0] stickcmp_rdata;
1168
wire [64-1:0] true_stickcmp0, true_stickcmp1;
1169
wire [64-1:0] true_stickcmp2, true_stickcmp3;
1170
wire [4-1:0] stickcmp_intdis_din;
1171
wire [4-1:0] stickcmp_intdis_en;
1172
wire [4-1:0] stickcmp_int;
1173
wire stick_match;
1174
wire [64-4:0] stickcmp_data;
1175
//
1176
wire [64-2:0] htickcmp_rdata;
1177
wire [64-4:0] htickcmp_data;
1178
wire [64-2:0] true_htickcmp0, true_htickcmp1;
1179
wire [64-2:0] true_htickcmp2, true_htickcmp3;
1180
wire [5-1:0]  true_hpstate0,true_hpstate1;
1181
wire [5-1:0]  true_hpstate2,true_hpstate3;
1182
wire [5-1:0]  true_hpstate;
1183
wire [4-1:0]  tsa_dnrtry_hpstate_m;
1184
wire [4-1:0]  tsa_dnrtry_hpstate_g;
1185
wire [4-1:0]  tsa_dnrtry_hpstate_w2;
1186
// wire [`TLU_HPSTATE_WIDTH-1:0]  dnrtry_hpstate0_g, dnrtry_hpstate1_g; 
1187
wire [5-1:0]  dnrtry_hpstate0_w2, dnrtry_hpstate1_w2;
1188
// wire [`TLU_HPSTATE_WIDTH-1:0]  dnrtry_hpstate2_g, dnrtry_hpstate3_g; 
1189
wire [5-1:0]  dnrtry_hpstate2_w2, dnrtry_hpstate3_w2;
1190
// wire [`TLU_HPSTATE_WIDTH-1:0]  hntrap_hpstate0_g, hntrap_hpstate1_g; 
1191
wire [5-1:0]  hntrap_hpstate0_w2, hntrap_hpstate1_w2;
1192
// wire [`TLU_HPSTATE_WIDTH-1:0]  hntrap_hpstate2_g, hntrap_hpstate3_g; 
1193
wire [5-1:0]  hntrap_hpstate2_w2, hntrap_hpstate3_w2;
1194
wire [5-1:0]  wsr_data_hpstate_w2;
1195
wire [5-1:0]  restore_hpstate0, restore_hpstate1;
1196
wire [5-1:0]  restore_hpstate2, restore_hpstate3;
1197
wire [34-1:0]       true_htba0, true_htba1;
1198
wire [34-1:0]       true_htba2, true_htba3;
1199
wire [2-1:0]   dnrtry_global_m;
1200
wire [64-1:0] tlu_rdpr_mx5_out;
1201
wire [17-1:0]       tlu_rdpr_mx6_out;
1202
wire [64-1:0] tlu_rdpr_mx7_out;
1203
wire [64-1:0] tlu_exu_rsr_data_e;
1204
wire clk;
1205
//
1206
//=========================================================================================
1207
// create local reset
1208
 
1209
assign local_rst = tlu_rst;
1210
assign se_l = ~se;
1211
 
1212
// clock rename
1213
assign clk = rclk;
1214
 
1215
//=========================================================================================
1216
// Design Notes :
1217
// HTSTATE-            4 (ENB from HPSTATE is not saved)        
1218
// TPC-               47 (48-2)VA+(1)VA_HOLE
1219
// TNPC-                  47 (48-2)VA+(1)VA_HOLE
1220
// TSTATE.GL-      2 (Only two significant bits are saved)
1221
// TSTATE.CCR-     8
1222
// TSTATE.ASI-     8
1223
// TSTATE.PSTATE-  8 (RED, IG, MG and AG bits are not used)
1224
// TSTATE.CWP-     3
1225
// TRAPTYPE-       9
1226
//========================================================
1227
// Total         136
1228
 
1229
//=========================================================================================
1230
//      Timing Diagram  
1231
//=========================================================================================
1232
 
1233
 
1234
// WRITE TO TSA and other trap related registers.
1235
//      |       |       |               |               |
1236
//      |E      |M      |       W       |       W2      | Integer
1237
//      |       |       | exceptions    | push tsa      |
1238
//      |       |       | reported      | xmit pc       |
1239
//      |       |       |               |               |
1240
//      |E      |M      |       G       |       W2      | Long-Latency
1241
//      |       |       | exceptions    |               |
1242
//      |       |       | reported      | push tsa      |
1243
//      |       |       |               | xmit pc       |
1244
 
1245
//=========================================================================================
1246
//      Generate TSA Control and Data
1247
//=========================================================================================
1248
 
1249
// modified for bug 3017
1250
assign  trap_pc0[48:2] =  true_pc0[48:2];
1251
assign  trap_pc1[48:2] =  true_pc1[48:2];
1252
assign  trap_pc2[48:2] =  true_pc2[48:2];
1253
assign  trap_pc3[48:2] =  true_pc3[48:2];
1254
 
1255
assign  trap_npc0[48:2] = true_npc0[48:2];
1256
assign  trap_npc1[48:2] = true_npc1[48:2];
1257
assign  trap_npc2[48:2] = true_npc2[48:2];
1258
assign  trap_npc3[48:2] = true_npc3[48:2];
1259
 
1260
assign  trap_ccr0[7:0] = exu_tlu_ccr0_w[7:0];
1261
assign  trap_ccr1[7:0] = exu_tlu_ccr1_w[7:0];
1262
assign  trap_ccr2[7:0] = exu_tlu_ccr2_w[7:0];
1263
assign  trap_ccr3[7:0] = exu_tlu_ccr3_w[7:0];
1264
 
1265
// assign       trap_cwp0[2:0] = exu_tlu_cwp0_w[2:0];
1266
// assign       trap_cwp1[2:0] = exu_tlu_cwp1_w[2:0];
1267
// assign       trap_cwp2[2:0] = exu_tlu_cwp2_w[2:0];
1268
// assign       trap_cwp3[2:0] = exu_tlu_cwp3_w[2:0];
1269
//
1270
// added for bug 3695
1271
dff #(3) dff_tlu_cwp0 (
1272
    .din (exu_tlu_cwp0[2:0]),
1273
    .q   (tlu_cwp0[2:0]),
1274
    .clk (clk),
1275
    .se  (se),
1276
    .si  (),
1277
    .so  ()
1278
);
1279
 
1280
dff #(3) dff_tlu_cwp1 (
1281
    .din (exu_tlu_cwp1[2:0]),
1282
    .q   (tlu_cwp1[2:0]),
1283
    .clk (clk),
1284
    .se  (se),
1285
    .si  (),
1286
    .so  ()
1287
);
1288
 
1289
dff #(3) dff_tlu_cwp2 (
1290
    .din (exu_tlu_cwp2[2:0]),
1291
    .q   (tlu_cwp2[2:0]),
1292
    .clk (clk),
1293
    .se  (se),
1294
    .si  (),
1295
    .so  ()
1296
);
1297
 
1298
dff #(3) dff_tlu_cwp3 (
1299
    .din (exu_tlu_cwp3[2:0]),
1300
    .q   (tlu_cwp3[2:0]),
1301
    .clk (clk),
1302
    .se  (se),
1303
    .si  (),
1304
    .so  ()
1305
);
1306
// 
1307
// modified for bug 3499 and 3695
1308
dffe #(3) dffe_trap_cwp0 (
1309
    // .din (exu_tlu_cwp0[2:0]),
1310
    .din (tlu_cwp0[2:0]),
1311
    .q   (trap_cwp0[2:0]),
1312
    .en  (tlu_trap_cwp_en[0]),
1313
    .clk (clk),
1314
    .se  (se),
1315
    .si  (),
1316
    .so  ()
1317
);
1318
 
1319
dffe #(3) dffe_trap_cwp1 (
1320
    // .din (exu_tlu_cwp1[2:0]),
1321
    .din (tlu_cwp1[2:0]),
1322
    .q   (trap_cwp1[2:0]),
1323
    .en  (tlu_trap_cwp_en[1]),
1324
    .clk (clk),
1325
    .se  (se),
1326
    .si  (),
1327
    .so  ()
1328
);
1329
 
1330
dffe #(3) dffe_trap_cwp2 (
1331
    // .din (exu_tlu_cwp2[2:0]),
1332
    .din (tlu_cwp2[2:0]),
1333
    .q   (trap_cwp2[2:0]),
1334
    .en  (tlu_trap_cwp_en[2]),
1335
    .clk (clk),
1336
    .se  (se),
1337
    .si  (),
1338
    .so  ()
1339
);
1340
 
1341
dffe #(3) dffe_trap_cwp3 (
1342
    // .din (exu_tlu_cwp3[2:0]),
1343
    .din (tlu_cwp3[2:0]),
1344
    .q   (trap_cwp3[2:0]),
1345
    .en  (tlu_trap_cwp_en[3]),
1346
    .clk (clk),
1347
    .se  (se),
1348
    .si  (),
1349
    .so  ()
1350
);
1351
 
1352
assign  trap_asi0[7:0] = lsu_asi_reg0[7:0];
1353
assign  trap_asi1[7:0] = lsu_asi_reg1[7:0];
1354
assign  trap_asi2[7:0] = lsu_asi_reg2[7:0];
1355
assign  trap_asi3[7:0] = lsu_asi_reg3[7:0];
1356
// 
1357
// staging the immediate asi
1358
 
1359
dff #(8) dff_imm_asi_e (
1360
    .din (ifu_lsu_imm_asi_d[8-1:0]),
1361
    .q   (imm_asi_e[8-1:0]),
1362
    .clk (clk),
1363
    .se  (se),
1364
    .si  (),
1365
    .so  ()
1366
);
1367
 
1368
dffr dffr_imm_asi_vld_e (
1369
     .din (ifu_lsu_imm_asi_vld_d),
1370
     .q   (imm_asi_vld_e),
1371
     .clk (clk),
1372
         .rst (local_rst),
1373
     .se  (se),
1374
     .si  (),
1375
     .so  ()
1376
);
1377
//
1378
// generating the current asi state
1379
mux4ds  #(8) mx_tlu_asi_state_e (
1380
        .in0    (lsu_asi_reg0[8-1:0]),
1381
        .in1    (lsu_asi_reg1[8-1:0]),
1382
        .in2    (lsu_asi_reg2[8-1:0]),
1383
        .in3    (lsu_asi_reg3[8-1:0]),
1384
        .sel0   (tlu_thrd_rsel_e[0]),
1385
        .sel1   (tlu_thrd_rsel_e[1]),
1386
        .sel2   (tlu_thrd_rsel_e[2]),
1387
        .sel3   (tlu_thrd_rsel_e[3]),
1388
        // modified due to bug 2442
1389
        // .dout   (tlu_asi_state_e[`TLU_ASI_STATE_WIDTH-1:0])
1390
        .dout   (asi_state_reg_e[8-1:0])
1391
);
1392
//
1393
// added for bug 2442
1394
// generating the current asi state
1395
mux2ds #(8) mx_asi_state_final_e (
1396
       .in0  (imm_asi_e[8-1:0]),
1397
           .in1  (asi_state_reg_e[8-1:0]),
1398
       .sel0 (imm_asi_vld_e),
1399
           .sel1 (~imm_asi_vld_e),
1400
       .dout (asi_state_final_e[8-1:0])
1401
);
1402
 
1403
assign tlu_asi_state_e[8-1:0] =
1404
           asi_state_final_e[8-1:0];
1405
//
1406
// thread 0
1407
assign trap_pstate0 = {
1408
       true_pstate0[9:8],
1409
       2'b0, true_pstate0[4:1]};
1410
//
1411
// modified due to hpstate.ibe addition
1412
assign trap0_tsa_wdata[135:132] =
1413
       {true_hpstate0[5-1],
1414
        true_hpstate0[4-2:0]};
1415
//
1416
// modified for bug 3017
1417
//
1418
assign trap0_tsa_wdata[131:85] =
1419
           trap_pc0[48:2];
1420
//
1421
assign trap0_tsa_wdata[84:38] =
1422
           trap_npc0[48:2];
1423
//
1424
assign trap0_tsa_wdata[37:36] =
1425
       tlu_gl_lvl0[2-1:0];
1426
//
1427
assign trap0_tsa_wdata[35:28] =
1428
       trap_ccr0[8-1:0];
1429
//
1430
assign trap0_tsa_wdata[27:20] =
1431
       trap_asi0[8-1:0];
1432
//
1433
assign trap0_tsa_wdata[19:12] =
1434
       trap_pstate0[8-1:0];
1435
//
1436
assign trap0_tsa_wdata[11:9] =
1437
       trap_cwp0[3-1:0];
1438
//
1439
assign trap0_tsa_wdata[8:0] =
1440
       tlu_final_ttype_w2[9-1:0];
1441
//
1442
// thread 1
1443
assign trap_pstate1 = {
1444
       true_pstate1[9:8],
1445
       2'b0, true_pstate1[4:1]};
1446
//
1447
// modified due to hpstate.ibe addition
1448
assign trap1_tsa_wdata[135:132] =
1449
       {true_hpstate1[5-1],
1450
        true_hpstate1[4-2:0]};
1451
//
1452
assign trap1_tsa_wdata[131:85] =
1453
           trap_pc1[48:2];
1454
//
1455
assign trap1_tsa_wdata[84:38] =
1456
           trap_npc1[48:2];
1457
//
1458
assign trap1_tsa_wdata[37:36] =
1459
       tlu_gl_lvl1[2-1:0];
1460
//
1461
assign trap1_tsa_wdata[35:28] =
1462
       trap_ccr1[8-1:0];
1463
//
1464
assign trap1_tsa_wdata[27:20] =
1465
       trap_asi1[8-1:0];
1466
//
1467
assign trap1_tsa_wdata[19:12] =
1468
       trap_pstate1[8-1:0];
1469
//
1470
assign trap1_tsa_wdata[11:9] =
1471
       trap_cwp1[3-1:0];
1472
//
1473
assign trap1_tsa_wdata[8:0] =
1474
       tlu_final_ttype_w2[9-1:0];
1475
//
1476
// thread 2
1477
assign trap_pstate2 = {
1478
       true_pstate2[9:8],
1479
       2'b0, true_pstate2[4:1]};
1480
//
1481
// modified due to hpstate.ibe addition
1482
assign trap2_tsa_wdata[135:132] =
1483
       {true_hpstate2[5-1],
1484
        true_hpstate2[4-2:0]};
1485
//
1486
assign trap2_tsa_wdata[131:85] =
1487
           trap_pc2[48:2];
1488
//
1489
assign trap2_tsa_wdata[84:38] =
1490
           trap_npc2[48:2];
1491
//
1492
assign trap2_tsa_wdata[37:36] =
1493
       tlu_gl_lvl2[2-1:0];
1494
//
1495
assign trap2_tsa_wdata[35:28] =
1496
       trap_ccr2[8-1:0];
1497
//
1498
assign trap2_tsa_wdata[27:20] =
1499
       trap_asi2[8-1:0];
1500
//
1501
assign trap2_tsa_wdata[19:12] =
1502
       trap_pstate2[8-1:0];
1503
//
1504
assign trap2_tsa_wdata[11:9] =
1505
       trap_cwp2[3-1:0];
1506
//
1507
assign trap2_tsa_wdata[8:0] =
1508
       tlu_final_ttype_w2[9-1:0];
1509
//
1510
// thread 3
1511
assign trap_pstate3 = {
1512
       true_pstate3[9:8],
1513
       2'b0, true_pstate3[4:1]};
1514
//
1515
// modified due to hpstate.ibe addition
1516
assign trap3_tsa_wdata[135:132] =
1517
       {true_hpstate3[5-1],
1518
        true_hpstate3[4-2:0]};
1519
//
1520
assign trap3_tsa_wdata[131:85] =
1521
           trap_pc3[48:2];
1522
//
1523
assign trap3_tsa_wdata[84:38] =
1524
           trap_npc3[48:2];
1525
//
1526
assign trap3_tsa_wdata[37:36] =
1527
       tlu_gl_lvl3[2-1:0];
1528
//
1529
assign trap3_tsa_wdata[35:28] =
1530
       trap_ccr3[8-1:0];
1531
//
1532
assign trap3_tsa_wdata[27:20] =
1533
       trap_asi3[8-1:0];
1534
//
1535
assign trap3_tsa_wdata[19:12] =
1536
       trap_pstate3[8-1:0];
1537
//
1538
assign trap3_tsa_wdata[11:9] =
1539
       trap_cwp3[3-1:0];
1540
//
1541
assign trap3_tsa_wdata[8:0] =
1542
       tlu_final_ttype_w2[9-1:0];
1543
//
1544
// modified for timing: tlu_thrd_wsel_g -> tlu_thrd_wsel_w2
1545
 
1546
 
1547
 
1548
 
1549
mux4ds  #(136) tsawdsel (
1550
        .in0    (trap0_tsa_wdata[136-1:0]),
1551
        .in1    (trap1_tsa_wdata[136-1:0]),
1552
        .in2    (trap2_tsa_wdata[136-1:0]),
1553
        .in3    (trap3_tsa_wdata[136-1:0]),
1554
        .sel0   (tlu_thrd_wsel_w2[0]),
1555
        .sel1   (tlu_thrd_wsel_w2[1]),
1556
        .sel2   (tlu_thrd_wsel_w2[2]),
1557
        .sel3   (tlu_thrd_wsel_w2[3]),
1558
        .dout   (trap_tsa_wdata[136-1:0])
1559
);
1560
 // !`ifdef FPGA_SYN_1THREAD
1561
 
1562
//
1563
// modified for timing and lint violations
1564
// assign wsr_data_w[`TLU_ASR_DATA_WIDTH-1:0] = 
1565
//            tlu_wsr_data_w[`TLU_ASR_DATA_WIDTH-1:0];
1566
assign wsr_data_w[17-1:0] =
1567
           tlu_wsr_data_w[17-1:0];
1568
// 
1569
// added for timing
1570
// reduced width to 48 due to lint violations
1571
dff #(48) dff_wsr_data_w2 (
1572
    .din (tlu_wsr_data_w[47:0]),
1573
    .q   (wsr_data_w2[47:0]),
1574
    .clk (clk),
1575
    .se  (se),
1576
    .si  (),
1577
    .so  ()
1578
);
1579
//
1580
// extracting the relevant data for tstate from the WSR to be written
1581
// modified due to timing changes
1582
assign compose_tstate[29-1:0] =
1583
          {wsr_data_w2[41:40],
1584
       wsr_data_w2[39:32],
1585
       wsr_data_w2[31:24],
1586
       wsr_data_w2[17:16],
1587
       2'b0,
1588
       wsr_data_w2[12:9],
1589
       wsr_data_w2[2:0]};
1590
//
1591
// extracting the relevant data from hstate from the WSR to be written
1592
assign compose_htstate[4-1:0] =
1593
          {wsr_data_w2[10],
1594
       wsr_data_w2[5],
1595
           wsr_data_w2[2],
1596
           wsr_data_w2[0]};
1597
 
1598
// htstate
1599
assign  wrpr_tsa_wdata[135:132]=
1600
        compose_htstate[4-1:0];
1601
// 
1602
// modified for bug 3017 
1603
// pc
1604
assign wrpr_tsa_wdata[131:85]=
1605
       {1'b0, wsr_data_w2[47:2]};
1606
// npc
1607
assign wrpr_tsa_wdata[84:38]=
1608
       {1'b0, wsr_data_w2[47:2]};
1609
// tstate data
1610
assign wrpr_tsa_wdata[37:9]=
1611
       compose_tstate[29-1:0];
1612
// ttype data
1613
assign wrpr_tsa_wdata[8:0]=
1614
       wsr_data_w2[9-1:0];
1615
 
1616
mux2ds #(136) tsawdata_sel (
1617
       .in0    ({trap_tsa_wdata[136-1:0]}),
1618
           .in1    ({wrpr_tsa_wdata[136-1:0]}),
1619
       .sel0   (~tlu_wr_tsa_inst_w2),
1620
       .sel1    (tlu_wr_tsa_inst_w2),
1621
       .dout   ({tsa_wdata[136-1:0]})
1622
);
1623
 
1624
//=========================================================================================
1625
//      SOFT INTERRUPT for Threads
1626
//=========================================================================================
1627
 
1628
// Assumption is that softint state is unknown after reset.
1629
// TICK_INT will be maintained separately. What is the relative order of
1630
// setting and clearing this bit ? What takes precedence ?
1631
//
1632
// modified for bug 2204
1633
// recoded due to one-hot problem during reset
1634
 
1635
 
1636
 
1637
 
1638
 
1639
mux4ds #(17) mx_sftint (
1640
        .in0  (sftint0[17-1:0]),
1641
        .in1  (sftint1[17-1:0]),
1642
        .in2  (sftint2[17-1:0]),
1643
        .in3  (sftint3[17-1:0]),
1644
        .sel0 (tlu_sftint_mx_sel[0]),
1645
        .sel1 (tlu_sftint_mx_sel[1]),
1646
        .sel2 (tlu_sftint_mx_sel[2]),
1647
        .sel3 (tlu_sftint_mx_sel[3]),
1648
        .dout (sftint[17-1:0])
1649
);
1650
 // !`ifdef FPGA_SYN_1THREAD
1651
 
1652
/*
1653
assign sftint_sel_onehot_g =
1654
           ~tlu_sftint_en_l_g[0] | (&tlu_sftint_en_l_g[3:1]);
1655
 
1656
mux4ds #(`SFTINT_WIDTH) mx_sftint (
1657
        .in0  (sftint0[`SFTINT_WIDTH-1:0]),
1658
        .in1  (sftint1[`SFTINT_WIDTH-1:0]),
1659
        .in2  (sftint2[`SFTINT_WIDTH-1:0]),
1660
        .in3  (sftint3[`SFTINT_WIDTH-1:0]),
1661
        .sel0 (sftint_sel_onehot_g),
1662
        .sel1 (~tlu_sftint_en_l_g[1]),
1663
        .sel2 (~tlu_sftint_en_l_g[2]),
1664
        .sel3 (~tlu_sftint_en_l_g[3]),
1665
        .dout (sftint[`SFTINT_WIDTH-1:0])
1666
);
1667
*/
1668
 
1669
assign  sftint_set_din[17-1:0] =
1670
            (wsr_data_w[17-1:0] | sftint[17-1:0]);
1671
assign  sftint_clr_din[17-1:0] =
1672
            (~wsr_data_w[17-1:0] & sftint[17-1:0]);
1673
assign  sftint_wr_din[17-1:0]  =
1674
            wsr_data_w[17-1:0];
1675
 
1676
// consturcting the mux select for the sftin_din mux
1677
 
1678
assign sftin_din_mxsel[0] = ~tlu_set_sftint_l_g;
1679
assign sftin_din_mxsel[1] = ~tlu_clr_sftint_l_g;
1680
assign sftin_din_mxsel[2] = ~tlu_wr_sftint_l_g;
1681
assign sftin_din_mxsel[3] =
1682
           tlu_set_sftint_l_g & tlu_clr_sftint_l_g & tlu_wr_sftint_l_g;
1683
 
1684
mux4ds #(17) mx_sftint_din (
1685
        .in0  (sftint_set_din[17-1:0]),
1686
        .in1  (sftint_clr_din[17-1:0]),
1687
        .in2  (sftint_wr_din[17-1:0]),
1688
        .in3  (sftint[17-1:0]),
1689
        .sel0 (sftin_din_mxsel[0]),
1690
        .sel1 (sftin_din_mxsel[1]),
1691
        .sel2 (sftin_din_mxsel[2]),
1692
        .sel3 (sftin_din_mxsel[3]),
1693
        .dout (sftint_din[17-1:0])
1694
);
1695
 
1696
 
1697
 
1698
 
1699
 
1700
 
1701
 
1702
 
1703
 
1704
 
1705
 
1706
 
1707
 
1708
 
1709
 
1710
 
1711
 
1712
 
1713
 
1714
 
1715
 
1716
 
1717
 
1718
 
1719
 
1720
 
1721
 
1722
 
1723
 
1724
 
1725
 
1726
 
1727
 
1728
 
1729
 
1730
 
1731
 
1732
 
1733
 
1734
 
1735
//              
1736
// added for PIB support - modified to make inst count precise
1737
assign sftint_b15_din[0] =
1738
           (pib_picl_wrap[0] | pib_pich_wrap[0] | sftint_din[15]);
1739
assign sftint_b15_din[1] =
1740
           (pib_picl_wrap[1] | pib_pich_wrap[1] | sftint_din[15]);
1741
assign sftint_b15_din[2] =
1742
           (pib_picl_wrap[2] | pib_pich_wrap[2] | sftint_din[15]);
1743
assign sftint_b15_din[3] =
1744
           (pib_picl_wrap[3] | pib_pich_wrap[3] | sftint_din[15]);
1745
 
1746
assign sftint_b15_en[0] =
1747
           (pib_picl_wrap[0] | pib_pich_wrap[0] | ~tlu_sftint_en_l_g[0]);
1748
assign sftint_b15_en[1] =
1749
           (pib_picl_wrap[1] | pib_pich_wrap[1] | ~tlu_sftint_en_l_g[1]);
1750
assign sftint_b15_en[2] =
1751
           (pib_picl_wrap[2] | pib_pich_wrap[2] | ~tlu_sftint_en_l_g[2]);
1752
assign sftint_b15_en[3] =
1753
           (pib_picl_wrap[3] | pib_pich_wrap[3] | ~tlu_sftint_en_l_g[3]);
1754
//              
1755
// added due to sftint spec change 
1756
// tickcmp interrupts
1757
assign sftint_b0_din[0] = (tickcmp_int[0] | sftint_din[0]);
1758
assign sftint_b0_din[1] = (tickcmp_int[1] | sftint_din[0]);
1759
assign sftint_b0_din[2] = (tickcmp_int[2] | sftint_din[0]);
1760
assign sftint_b0_din[3] = (tickcmp_int[3] | sftint_din[0]);
1761
 
1762
assign sftint_b0_en[0] = (tickcmp_int[0] | ~tlu_sftint_en_l_g[0]);
1763
assign sftint_b0_en[1] = (tickcmp_int[1] | ~tlu_sftint_en_l_g[1]);
1764
assign sftint_b0_en[2] = (tickcmp_int[2] | ~tlu_sftint_en_l_g[2]);
1765
assign sftint_b0_en[3] = (tickcmp_int[3] | ~tlu_sftint_en_l_g[3]);
1766
//
1767
// stickcmp interrupts
1768
assign sftint_b16_din[0] = (stickcmp_int[0] | sftint_din[16]);
1769
assign sftint_b16_din[1] = (stickcmp_int[1] | sftint_din[16]);
1770
assign sftint_b16_din[2] = (stickcmp_int[2] | sftint_din[16]);
1771
assign sftint_b16_din[3] = (stickcmp_int[3] | sftint_din[16]);
1772
 
1773
assign sftint_b16_en[0] = (stickcmp_int[0] | ~tlu_sftint_en_l_g[0]);
1774
assign sftint_b16_en[1] = (stickcmp_int[1] | ~tlu_sftint_en_l_g[1]);
1775
assign sftint_b16_en[2] = (stickcmp_int[2] | ~tlu_sftint_en_l_g[2]);
1776
assign sftint_b16_en[3] = (stickcmp_int[3] | ~tlu_sftint_en_l_g[3]);
1777
 
1778
// modified for sftint spec change - special treatments for bit 0, 15 and 16 
1779
//
1780
// thread 0
1781
 
1782
dffre #(14) dffr_sftint0 (
1783
    .din (sftint_din[14:1]),
1784
    .q   (sftint0[14:1]),
1785
    .en (~(tlu_sftint_en_l_g[0])), .clk(clk),
1786
    .rst (local_rst),
1787
    .se  (se),
1788
    .si  (),
1789
    .so  ()
1790
);
1791
 
1792
 
1793
 
1794
 
1795
 
1796
 
1797
 
1798
 
1799
 
1800
 
1801
 
1802
dffre dffre_sftint0_b0 (
1803
    .din (sftint_b0_din[0]),
1804
    .q   (sftint0[0]),
1805
    .clk (clk),
1806
    .rst (local_rst),
1807
    .en  (sftint_b0_en[0]),
1808
    .se  (se),
1809
    .si  (),
1810
    .so  ()
1811
);
1812
 
1813
dffre dffre_sftint0_b15 (
1814
    .din (sftint_b15_din[0]),
1815
    .q   (sftint0[15]),
1816
    .clk (clk),
1817
    .rst (local_rst),
1818
    .en  (sftint_b15_en[0]),
1819
    .se  (se),
1820
    .si  (),
1821
    .so  ()
1822
);
1823
 
1824
dffre dffre_sftint0_b16 (
1825
    .din (sftint_b16_din[0]),
1826
    .q   (sftint0[16]),
1827
    .clk (clk),
1828
    .rst (local_rst),
1829
    .en  (sftint_b16_en[0]),
1830
    .se  (se),
1831
    .si  (),
1832
    .so  ()
1833
);
1834
//
1835
// thread 1
1836
 
1837
dffre #(14) sftint1ff (
1838
    .din (sftint_din[14:1]),
1839
    .q   (sftint1[14:1]),
1840
    .en (~(tlu_sftint_en_l_g[1])), .clk(clk),
1841
    .rst (local_rst),
1842
    .se  (se),
1843
    .si  (),
1844
    .so  ()
1845
);
1846
 
1847
 
1848
 
1849
 
1850
 
1851
 
1852
 
1853
 
1854
 
1855
 
1856
 
1857
 
1858
dffre dffre_sftint1_b0 (
1859
    .din (sftint_b0_din[1]),
1860
    .q   (sftint1[0]),
1861
    .clk (clk),
1862
    .rst (local_rst),
1863
    .en  (sftint_b0_en[1]),
1864
    .se  (se),
1865
    .si  (),
1866
    .so  ()
1867
);
1868
 
1869
dffre dffre_sftint1_b15 (
1870
    .din (sftint_b15_din[1]),
1871
    .q   (sftint1[15]),
1872
    .clk (clk),
1873
    .rst (local_rst),
1874
    .en  (sftint_b15_en[1]),
1875
    .se  (se),
1876
    .si  (),
1877
    .so  ()
1878
);
1879
 
1880
dffre dffre_sftint1_b16 (
1881
    .din (sftint_b16_din[1]),
1882
    .q   (sftint1[16]),
1883
    .clk (clk),
1884
    .rst (local_rst),
1885
    .en  (sftint_b16_en[1]),
1886
    .se  (se),
1887
    .si  (),
1888
    .so  ()
1889
);
1890
//
1891
// thread 2
1892
 
1893
dffre #(14) sftint2ff (
1894
    .din (sftint_din[14:1]),
1895
    .q   (sftint2[14:1]),
1896
    .en (~(tlu_sftint_en_l_g[2])), .clk(clk),
1897
    .rst (local_rst),
1898
    .se  (se),
1899
    .si  (),
1900
    .so  ()
1901
);
1902
 
1903
 
1904
 
1905
 
1906
 
1907
 
1908
 
1909
 
1910
 
1911
 
1912
 
1913
 
1914
dffre dffre_sftint2_b0 (
1915
    .din (sftint_b0_din[2]),
1916
    .q   (sftint2[0]),
1917
    .clk (clk),
1918
    .rst (local_rst),
1919
    .en  (sftint_b0_en[2]),
1920
    .se  (se),
1921
    .si  (),
1922
    .so  ()
1923
);
1924
 
1925
dffre dffre_sftint2_b15 (
1926
    .din (sftint_b15_din[2]),
1927
    .q   (sftint2[15]),
1928
    .clk (clk),
1929
    .rst (local_rst),
1930
    .en  (sftint_b15_en[2]),
1931
    .se  (se),
1932
    .si  (),
1933
    .so  ()
1934
);
1935
 
1936
dffre dffre_sftint2_b16 (
1937
    .din (sftint_b16_din[2]),
1938
    .q   (sftint2[16]),
1939
    .clk (clk),
1940
    .rst (local_rst),
1941
    .en  (sftint_b16_en[2]),
1942
    .se  (se),
1943
    .si  (),
1944
    .so  ()
1945
);
1946
//
1947
// thread 3
1948
 
1949
dffre #(14) sftint3ff (
1950
    .din (sftint_din[14:1]),
1951
    .q   (sftint3[14:1]),
1952
    .en (~(tlu_sftint_en_l_g[3])), .clk(clk),
1953
    .rst (local_rst),
1954
    .se  (se),
1955
    .si  (),
1956
    .so  ()
1957
);
1958
 
1959
 
1960
 
1961
 
1962
 
1963
 
1964
 
1965
 
1966
 
1967
 
1968
 
1969
 
1970
dffre dffre_sftint3_b0 (
1971
    .din (sftint_b0_din[3]),
1972
    .q   (sftint3[0]),
1973
    .clk (clk),
1974
    .rst (local_rst),
1975
    .en  (sftint_b0_en[3]),
1976
    .se  (se),
1977
    .si  (),
1978
    .so  ()
1979
);
1980
 
1981
dffre dffre_sftint3_b15 (
1982
    .din (sftint_b15_din[3]),
1983
    .q   (sftint3[15]),
1984
    .clk (clk),
1985
    .rst (local_rst),
1986
    .en  (sftint_b15_en[3]),
1987
    .se  (se),
1988
    .si  (),
1989
    .so  ()
1990
);
1991
 
1992
dffre dffre_sftint3_b16 (
1993
    .din (sftint_b16_din[3]),
1994
    .q   (sftint3[16]),
1995
    .clk (clk),
1996
    .rst (local_rst),
1997
    .en  (sftint_b16_en[3]),
1998
    .se  (se),
1999
    .si  (),
2000
    .so  ()
2001
);
2002
// 
2003
// Datapath priority encoder.
2004
assign sftint_lvl14[0] =
2005
           sftint0[0] | sftint0[16] |
2006
           sftint0[14];
2007
assign sftint_lvl14[1] =
2008
           sftint1[0] | sftint1[16] |
2009
           sftint1[14];
2010
assign sftint_lvl14[2] =
2011
           sftint2[0] | sftint2[16] |
2012
           sftint2[14];
2013
assign sftint_lvl14[3] =
2014
           sftint3[0] | sftint3[16] |
2015
           sftint3[14];
2016
//
2017
// modified to ensure one-hot mux check
2018
 
2019
 
2020
 
2021
 
2022
 
2023
mux4ds #(17-2) mx_sftint_penc_din (
2024
    .in0  ({sftint0[15],sftint_lvl14[0],sftint0[13:1]}),
2025
    .in1  ({sftint1[15],sftint_lvl14[1],sftint1[13:1]}),
2026
    .in2  ({sftint2[15],sftint_lvl14[2],sftint2[13:1]}),
2027
    .in3  ({sftint3[15],sftint_lvl14[3],sftint3[13:1]}),
2028
    .sel0 (tlu_sftint_penc_sel[0]),
2029
    .sel1 (tlu_sftint_penc_sel[1]),
2030
    .sel2 (tlu_sftint_penc_sel[2]),
2031
    .sel3 (tlu_sftint_penc_sel[3]),
2032
    .dout (sftint_penc_din[14:0])
2033
);
2034
 // !`ifdef FPGA_SYN_1THREAD
2035
 
2036
tlu_prencoder16 prencoder16 (
2037
                        .din    (sftint_penc_din[14:0]),
2038
                        .dout   (tlu_sftint_id[3:0])
2039
                );
2040
 
2041
//wire  [15:0]  sftint_rdata;
2042
//
2043
// modified for hypervisor support
2044
// adding the SM bit
2045
wire [17-1:0]    sftint_rdata;
2046
// modified due to spec change
2047
/*
2048
mux4ds #(`SFTINT_WIDTH) sftint_mx_rsel (
2049
    .in0  ({tlu_stick_int[0],sftint0[15:1],tlu_tick_int[0]}),
2050
    .in1  ({tlu_stick_int[1],sftint1[15:1],tlu_tick_int[1]}),
2051
    .in2  ({tlu_stick_int[2],sftint2[15:1],tlu_tick_int[2]}),
2052
    .in3  ({tlu_stick_int[3],sftint3[15:1],tlu_tick_int[3]}),
2053
    .sel0 (tlu_thrd_rsel_e[0]),
2054
    .sel1 (tlu_thrd_rsel_e[1]),
2055
    .sel2 (tlu_thrd_rsel_e[2]),
2056
    .sel3 (tlu_thrd_rsel_e[3]),
2057
    .dout (sftint_rdata[16:0])
2058
);
2059
*/
2060
 
2061
 
2062
 
2063
 
2064
mux4ds #(17) sftint_mx_rsel (
2065
    .in0  (sftint0[17-1:0]),
2066
    .in1  (sftint1[17-1:0]),
2067
    .in2  (sftint2[17-1:0]),
2068
    .in3  (sftint3[17-1:0]),
2069
    .sel0 (tlu_thrd_rsel_e[0]),
2070
    .sel1 (tlu_thrd_rsel_e[1]),
2071
    .sel2 (tlu_thrd_rsel_e[2]),
2072
    .sel3 (tlu_thrd_rsel_e[3]),
2073
    .dout (sftint_rdata[16:0])
2074
);
2075
 // !`ifdef FPGA_SYN_1THREAD
2076
 
2077
//=========================================================================================
2078
//      TBA for Threads
2079
//=========================================================================================
2080
 
2081
// Lower 15 bits are read as zero and ignored when written.
2082
 
2083
 
2084
 
2085
 
2086
 
2087
 
2088
 
2089
 
2090
 
2091
 
2092
 
2093
 
2094
 
2095
 
2096
 
2097
 
2098
 
2099
 
2100
 
2101
 
2102
 
2103
 
2104
 
2105
 
2106
 
2107
 
2108
 
2109
 
2110
 
2111
 
2112
 
2113
 
2114
 
2115
 
2116
 
2117
 
2118
 
2119
 
2120
 
2121
 
2122
 
2123
// THREAD0
2124
 
2125
 
2126
dffe #(33) tba0 (
2127
    .din (tlu_wsr_data_w[47:15]),
2128
    .q   (true_tba0[32:0]),
2129
    .en (~(tlu_tba_en_l[0])), .clk(clk),
2130
    .se  (se),
2131
    .si  (),
2132
    .so  ()
2133
);
2134
 
2135
 
2136
 
2137
 
2138
 
2139
 
2140
 
2141
 
2142
 
2143
 
2144
 
2145
// THREAD1
2146
 
2147
 
2148
dffe #(33) tba1 (
2149
    .din (tlu_wsr_data_w[47:15]),
2150
    .q  (true_tba1[32:0]),
2151
    .en (~(tlu_tba_en_l[1])), .clk(clk),
2152
    .se  (se),
2153
    .si  (),
2154
    .so  ()
2155
);
2156
 
2157
 
2158
 
2159
 
2160
 
2161
 
2162
 
2163
 
2164
 
2165
 
2166
 
2167
// THREAD2
2168
 
2169
 
2170
dffe #(33) tba2 (
2171
    .din (tlu_wsr_data_w[47:15]),
2172
    .q   (true_tba2[32:0]),
2173
    .en (~(tlu_tba_en_l[2])), .clk(clk),
2174
    .se  (se),
2175
    .si  (),
2176
    .so  ()
2177
);
2178
 
2179
 
2180
 
2181
 
2182
 
2183
 
2184
 
2185
 
2186
 
2187
 
2188
 
2189
// THREAD3
2190
 
2191
 
2192
dffe #(33) tba3 (
2193
    .din (tlu_wsr_data_w[47:15]),
2194
    .q  (true_tba3[32:0]),
2195
    .en (~(tlu_tba_en_l[3])), .clk(clk),
2196
    .se  (se),
2197
    .si  (),
2198
    .so  ()
2199
);
2200
 
2201
 
2202
 
2203
 
2204
 
2205
 
2206
 
2207
 
2208
 
2209
 
2210
 
2211
// tba_data is for traps specifically
2212
// modified for timing 
2213
 
2214
 
2215
 
2216
 
2217
 
2218
 
2219
 
2220
mux4ds #(33) mux_tba_data (
2221
       .in0  (true_tba0[32:0]),
2222
       .in1  (true_tba1[32:0]),
2223
       .in2  (true_tba2[32:0]),
2224
       .in3  (true_tba3[32:0]),
2225
       .sel0 (tlu_thrd_wsel_w2[0]),
2226
       .sel1 (tlu_thrd_wsel_w2[1]),
2227
       .sel2 (tlu_thrd_wsel_w2[2]),
2228
       .sel3 (tlu_thrd_wsel_w2[3]),
2229
       .dout (tba_data[32:0])
2230
);
2231
 
2232
/*
2233
mux4ds #(33) tba_mx (
2234
       .in0  (true_tba0[32:0]),
2235
       .in1  (true_tba1[32:0]),
2236
       .in2  (true_tba2[32:0]),
2237
       .in3  (true_tba3[32:0]),
2238
       .sel0 (tlu_thrd_rsel_g[0]),
2239
       .sel1 (tlu_thrd_rsel_g[1]),
2240
       .sel2 (tlu_thrd_rsel_g[2]),
2241
       .sel3 (tlu_thrd_rsel_g[3]),
2242
       .dout (tba_data[32:0])
2243
);
2244
*/
2245
// tba_rdata is for read of tba regs specifically.
2246
mux4ds #(33) tba_mx_rsel (
2247
       .in0  (true_tba0[32:0]),
2248
       .in1  (true_tba1[32:0]),
2249
       .in2  (true_tba2[32:0]),
2250
       .in3  (true_tba3[32:0]),
2251
       .sel0 (tlu_thrd_rsel_e[0]),
2252
       .sel1 (tlu_thrd_rsel_e[1]),
2253
       .sel2 (tlu_thrd_rsel_e[2]),
2254
       .sel3 (tlu_thrd_rsel_e[3]),
2255
       .dout (tba_rdata[32:0])
2256
);
2257
 // !`ifdef FPGA_SYN_1THREAD
2258
 
2259
// added for hypervisor support
2260
//
2261
// HTBA write - constructing clocks  
2262
 
2263
 
2264
 
2265
 
2266
 
2267
 
2268
 
2269
 
2270
 
2271
 
2272
 
2273
 
2274
 
2275
 
2276
 
2277
 
2278
 
2279
 
2280
 
2281
 
2282
 
2283
 
2284
 
2285
 
2286
 
2287
 
2288
 
2289
 
2290
 
2291
 
2292
 
2293
 
2294
 
2295
 
2296
 
2297
 
2298
 
2299
 
2300
 
2301
//
2302
// HTBA write - writing the registers
2303
// lower 14 bits of HTBA are reserved, therefore, not stored
2304
//
2305
// Thread 0
2306
 
2307
dffe #(34) dff_true_htba0 (
2308
    .din (tlu_wsr_data_w[47:14]),
2309
    .q   (true_htba0[34-1:0]),
2310
    .en (~(tlu_htba_en_l[0])), .clk(clk),
2311
    .se  (se),
2312
    .si  (),
2313
    .so  ()
2314
);
2315
 
2316
 
2317
 
2318
 
2319
 
2320
 
2321
 
2322
 
2323
 
2324
 
2325
//
2326
// Thread 1
2327
 
2328
dffe #(34) dff_true_htba1 (
2329
    .din (tlu_wsr_data_w[47:14]),
2330
    .q   (true_htba1[34-1:0]),
2331
    .en (~(tlu_htba_en_l[1])), .clk(clk),
2332
    .se  (se),
2333
    .si  (),
2334
    .so  ()
2335
);
2336
 
2337
 
2338
 
2339
 
2340
 
2341
 
2342
 
2343
 
2344
 
2345
 
2346
//
2347
// Thread 2
2348
 
2349
dffe #(34) dff_true_htba2 (
2350
    .din (tlu_wsr_data_w[47:14]),
2351
    .q   (true_htba2[34-1:0]),
2352
    .en (~(tlu_htba_en_l[2])), .clk(clk),
2353
    .se  (se),
2354
    .si  (),
2355
    .so  ()
2356
);
2357
 
2358
 
2359
 
2360
 
2361
 
2362
 
2363
 
2364
 
2365
 
2366
 
2367
//
2368
// Thread 3
2369
 
2370
dffe #(34) dff_true_htba3 (
2371
    .din (tlu_wsr_data_w[47:14]),
2372
    .q   (true_htba3[34-1:0]),
2373
    .en (~(tlu_htba_en_l[3])), .clk(clk),
2374
    .se  (se),
2375
    .si  (),
2376
    .so  ()
2377
);
2378
 
2379
 
2380
 
2381
 
2382
 
2383
 
2384
 
2385
 
2386
 
2387
 
2388
//
2389
// constructing the rdata for HTBA
2390
wire [34-1:0] htba_rdata;
2391
 
2392
 
2393
 
2394
 
2395
 
2396
 
2397
mux4ds #(34) mux_htba_rdata (
2398
       .in0  (true_htba0[34-1:0]),
2399
       .in1  (true_htba1[34-1:0]),
2400
       .in2  (true_htba2[34-1:0]),
2401
       .in3  (true_htba3[34-1:0]),
2402
       .sel0 (tlu_thrd_rsel_e[0]),
2403
       .sel1 (tlu_thrd_rsel_e[1]),
2404
       .sel2 (tlu_thrd_rsel_e[2]),
2405
       .sel3 (tlu_thrd_rsel_e[3]),
2406
       .dout (htba_rdata[34-1:0])
2407
);
2408
//
2409
// selecting the htba base address to use 
2410
// modified for timing
2411
mux4ds #(34) mux_htba_data (
2412
       .in0  (true_htba0[34-1:0]),
2413
       .in1  (true_htba1[34-1:0]),
2414
       .in2  (true_htba2[34-1:0]),
2415
       .in3  (true_htba3[34-1:0]),
2416
       .sel0 (tlu_thrd_wsel_w2[0]),
2417
       .sel1 (tlu_thrd_wsel_w2[1]),
2418
       .sel2 (tlu_thrd_wsel_w2[2]),
2419
       .sel3 (tlu_thrd_wsel_w2[3]),
2420
       .dout (htba_data[34-1:0])
2421
);
2422
 // !`ifdef FPGA_SYN_1THREAD
2423
 
2424
/*
2425
mux4ds #(`TLU_HTBA_WIDTH) mux_htba_data (
2426
       .in0  (true_htba0[`TLU_HTBA_WIDTH-1:0]),
2427
       .in1  (true_htba1[`TLU_HTBA_WIDTH-1:0]),
2428
       .in2  (true_htba2[`TLU_HTBA_WIDTH-1:0]),
2429
       .in3  (true_htba3[`TLU_HTBA_WIDTH-1:0]),
2430
       .sel0 (tlu_thrd_rsel_g[0]),
2431
       .sel1 (tlu_thrd_rsel_g[1]),
2432
       .sel2 (tlu_thrd_rsel_g[2]),
2433
       .sel3 (tlu_thrd_rsel_g[3]),
2434
       .dout (htba_data[`TLU_HTBA_WIDTH-1:0])
2435
);
2436
*/
2437
//=========================================================================================
2438
//      TICKS for Threads
2439
//=========================================================================================
2440
 
2441
// npt needs to be muxed into read !!!
2442
 
2443
 
2444
// THREAD0,1,2,3
2445
 
2446
mux2ds #(61) tick_sel (
2447
       .in0  (tlu_wsr_data_w[62:2]),
2448
           .in1  (tlu_tick_incr_dout[60:0]),
2449
       .sel0 (~tlu_tick_en_l),
2450
           .sel1 ( tlu_tick_en_l),
2451
       .dout (tick_din[62:2])
2452
);
2453
// 
2454
// modified due to the switch to the soft macro
2455
// assign       tlu_tick_incr_din[`TLU_ASR_DATA_WIDTH-1:0] = 
2456
//         {3'b000,true_tick[60:0]};
2457
assign  tlu_tick_incr_din[64-3:0] =
2458
         {1'b0,true_tick[60:0]};
2459
 
2460
// Does not need enable as either in increment or update state
2461
dff #(61) tick0123 (
2462
    .din (tick_din[62:2]),
2463
    .q  (true_tick[60:0]),
2464
    .clk (clk),
2465
    .se  (se),
2466
    .si (),
2467
    .so ()
2468
);
2469
 
2470
//=========================================================================================
2471
//      TICK COMPARE  for Threads
2472
//=========================================================================================
2473
 
2474
 
2475
 
2476
 
2477
 
2478
 
2479
 
2480
 
2481
 
2482
 
2483
 
2484
 
2485
 
2486
 
2487
 
2488
 
2489
 
2490
 
2491
 
2492
 
2493
 
2494
 
2495
 
2496
 
2497
 
2498
 
2499
 
2500
 
2501
 
2502
 
2503
 
2504
 
2505
 
2506
 
2507
 
2508
 
2509
 
2510
 
2511
 
2512
 
2513
 
2514
// thread 0
2515
// added or modified due to tickcmp clean-up
2516
assign tickcmp_intdis_din[0] =
2517
           tlu_wsr_data_w[63] | local_rst |
2518
           tlu_por_rstint_g[0];
2519
// added and modified for bug 4763
2520
assign tickcmp_intdis_en[0] =
2521
           ~tlu_tickcmp_en_l[0] | local_rst | tlu_por_rstint_g[0];
2522
 
2523
dffe dffe_tickcmp_intdis0 (
2524
    .din (tickcmp_intdis_din[0]),
2525
        .q   (true_tickcmp0[63]),
2526
    .en  (tickcmp_intdis_en[0]),
2527
    .clk (clk),
2528
    .se  (se),
2529
    .si  (),
2530
    .so  ()
2531
);
2532
 
2533
 
2534
dffe #(64-1) tickcmp0 (
2535
    .din (tlu_wsr_data_w[64-2:0]),
2536
        .q   (true_tickcmp0[64-2:0]),
2537
    .en (~(tlu_tickcmp_en_l[0])), .clk(clk),
2538
    .se  (se),
2539
    .si  (),
2540
    .so  ()
2541
);
2542
 
2543
 
2544
 
2545
 
2546
 
2547
 
2548
 
2549
 
2550
 
2551
 
2552
 
2553
// thread 1
2554
// added or modified due to tickcmp clean-up
2555
assign tickcmp_intdis_din[1] =
2556
           tlu_wsr_data_w[63] | local_rst |
2557
           tlu_por_rstint_g[1];
2558
// added and modified for bug 4763
2559
assign tickcmp_intdis_en[1] =
2560
           ~tlu_tickcmp_en_l[1] | local_rst | tlu_por_rstint_g[1];
2561
 
2562
dffe dffe_tickcmp_intdis1 (
2563
    .din (tickcmp_intdis_din[1]),
2564
        .q   (true_tickcmp1[63]),
2565
    .en  (tickcmp_intdis_en[1]),
2566
    .clk (clk),
2567
    .se  (se),
2568
    .si  (),
2569
    .so  ()
2570
);
2571
 
2572
 
2573
dffe #(64-1) tickcmp1 (
2574
    .din (tlu_wsr_data_w[64-2:0]),
2575
        .q   (true_tickcmp1[64-2:0]),
2576
    .en (~(tlu_tickcmp_en_l[1])), .clk(clk),
2577
    .se  (se),
2578
    .si  (),
2579
    .so  ()
2580
);
2581
 
2582
 
2583
 
2584
 
2585
 
2586
 
2587
 
2588
 
2589
 
2590
 
2591
 
2592
// thread 2
2593
// added or modified due to tickcmp clean-up
2594
assign tickcmp_intdis_din[2] =
2595
           tlu_wsr_data_w[63] | local_rst |
2596
           tlu_por_rstint_g[2];
2597
// added and modified for bug 4763
2598
assign tickcmp_intdis_en[2] =
2599
           ~tlu_tickcmp_en_l[2] | local_rst | tlu_por_rstint_g[2];
2600
 
2601
dffe dffe_tickcmp_intdis2 (
2602
    .din (tickcmp_intdis_din[2]),
2603
        .q   (true_tickcmp2[63]),
2604
    .en  (tickcmp_intdis_en[2]),
2605
    .clk (clk),
2606
    .se  (se),
2607
    .si  (),
2608
    .so  ()
2609
);
2610
 
2611
 
2612
dffe #(64-1) tickcmp2 (
2613
    .din (tlu_wsr_data_w[64-2:0]),
2614
        .q   (true_tickcmp2[64-2:0]),
2615
    .en (~(tlu_tickcmp_en_l[2])), .clk(clk),
2616
    .se  (se),
2617
    .si  (),
2618
    .so  ()
2619
);
2620
 
2621
 
2622
 
2623
 
2624
 
2625
 
2626
 
2627
 
2628
 
2629
 
2630
 
2631
// thread 3
2632
// added or modified due to tickcmp clean-up
2633
assign tickcmp_intdis_din[3] =
2634
           tlu_wsr_data_w[63] | local_rst |
2635
           tlu_por_rstint_g[3];
2636
// added and modified for bug 4763
2637
assign tickcmp_intdis_en[3] =
2638
           ~tlu_tickcmp_en_l[3] | local_rst | tlu_por_rstint_g[3];
2639
 
2640
dffe dffe_tickcmp_intdis3 (
2641
    .din (tickcmp_intdis_din[3]),
2642
        .q   (true_tickcmp3[63]),
2643
    .en  (tickcmp_intdis_en[3]),
2644
    .clk (clk),
2645
    .se  (se),
2646
    .si  (),
2647
    .so  ()
2648
);
2649
 
2650
 
2651
dffe #(64-1) tickcmp3 (
2652
    .din (tlu_wsr_data_w[64-2:0]),
2653
        .q   (true_tickcmp3[64-2:0]),
2654
    .en (~(tlu_tickcmp_en_l[3])), .clk(clk),
2655
    .se  (se),
2656
    .si  (),
2657
    .so  ()
2658
);
2659
 
2660
 
2661
 
2662
 
2663
 
2664
 
2665
 
2666
 
2667
 
2668
 
2669
 
2670
// Select 1/4 sources. Assume compare is independent of read
2671
// and thus needs separate mux
2672
 
2673
 
2674
 
2675
 
2676
 
2677
mux4ds #(64-3) tcmp_mx_sel (
2678
       .in0  (true_tickcmp0[64-2:2]),
2679
       .in1  (true_tickcmp1[64-2:2]),
2680
       .in2  (true_tickcmp2[64-2:2]),
2681
       .in3  (true_tickcmp3[64-2:2]),
2682
       .sel0 (tlu_tickcmp_sel[0]),
2683
       .sel1 (tlu_tickcmp_sel[1]),
2684
       .sel2 (tlu_tickcmp_sel[2]),
2685
       .sel3 (tlu_tickcmp_sel[3]),
2686
       .dout (tickcmp_data[64-4:0])
2687
);
2688
 
2689
// mux for read
2690
mux4ds #(64) tcmp_mx_rsel (
2691
       .in0  (true_tickcmp0[64-1:0]),
2692
       .in1  (true_tickcmp1[64-1:0]),
2693
       .in2  (true_tickcmp2[64-1:0]),
2694
       .in3  (true_tickcmp3[64-1:0]),
2695
       .sel0 (tlu_thrd_rsel_e[0]),
2696
       .sel1 (tlu_thrd_rsel_e[1]),
2697
       .sel2 (tlu_thrd_rsel_e[2]),
2698
       .sel3 (tlu_thrd_rsel_e[3]),
2699
       .dout (tickcmp_rdata[64-1:0])
2700
);
2701
 // !`ifdef FPGA_SYN_1THREAD
2702
 
2703
//
2704
// evaluate for tickcmp match
2705
assign tick_match =
2706
           (tickcmp_data[60:0] ==
2707
            true_tick[60:0]);
2708
//
2709
// moved from tlu_tcl
2710
assign  tickcmp_int[0] =
2711
            tick_match & ~true_tickcmp0[63] & tlu_tickcmp_sel[0];
2712
assign  tickcmp_int[1] =
2713
            tick_match & ~true_tickcmp1[63] & tlu_tickcmp_sel[1];
2714
assign  tickcmp_int[2] =
2715
            tick_match & ~true_tickcmp2[63] & tlu_tickcmp_sel[2];
2716
assign  tickcmp_int[3] =
2717
            tick_match & ~true_tickcmp3[63] & tlu_tickcmp_sel[3];
2718
 
2719
//=========================================================================================
2720
//      STICK COMPARE  for Threads
2721
//=========================================================================================
2722
// added for hypervisor support
2723
 
2724
 
2725
 
2726
 
2727
 
2728
 
2729
 
2730
 
2731
 
2732
 
2733
 
2734
 
2735
 
2736
 
2737
 
2738
 
2739
 
2740
 
2741
 
2742
 
2743
 
2744
 
2745
 
2746
 
2747
 
2748
 
2749
 
2750
 
2751
 
2752
 
2753
 
2754
 
2755
 
2756
 
2757
 
2758
 
2759
 
2760
 
2761
 
2762
 
2763
 
2764
// thread 0
2765
// added or modified due to stickcmp clean-up
2766
assign stickcmp_intdis_din[0] = tickcmp_intdis_din[0];
2767
// added and modified for bug 4763
2768
assign stickcmp_intdis_en[0] =
2769
           ~tlu_stickcmp_en_l[0] | local_rst | tlu_por_rstint_g[0];
2770
 
2771
dffe dffe_stickcmp_intdis0 (
2772
    .din (stickcmp_intdis_din[0]),
2773
        .q   (true_stickcmp0[63]),
2774
    .en  (stickcmp_intdis_en[0]),
2775
    .clk (clk),
2776
    .se  (se),
2777
    .si  (),
2778
    .so  ()
2779
);
2780
 
2781
 
2782
dffe #(64-1) stickcmp0 (
2783
    .din (tlu_wsr_data_w[64-2:0]),
2784
        .q   (true_stickcmp0[64-2:0]),
2785
    .en (~(tlu_stickcmp_en_l[0])), .clk(clk),
2786
    .se  (se),
2787
    .si  (),
2788
    .so  ()
2789
);
2790
 
2791
 
2792
 
2793
 
2794
 
2795
 
2796
 
2797
 
2798
 
2799
 
2800
 
2801
// thread 1
2802
// added or modified due to stickcmp clean-up
2803
assign stickcmp_intdis_din[1] = tickcmp_intdis_din[1];
2804
// added and modified for bug 4763
2805
assign stickcmp_intdis_en[1] =
2806
           ~tlu_stickcmp_en_l[1] | local_rst | tlu_por_rstint_g[1];
2807
 
2808
dffe dffe_stickcmp_intdis1 (
2809
    .din (stickcmp_intdis_din[1]),
2810
        .q   (true_stickcmp1[63]),
2811
    .en  (stickcmp_intdis_en[1]),
2812
    .clk (clk),
2813
    .se  (se),
2814
    .si  (),
2815
    .so  ()
2816
);
2817
 
2818
 
2819
dffe #(64-1) stickcmp1 (
2820
    .din (tlu_wsr_data_w[64-2:0]),
2821
        .q   (true_stickcmp1[64-2:0]),
2822
    .en (~(tlu_stickcmp_en_l[1])), .clk(clk),
2823
    .se  (se),
2824
    .si  (),
2825
    .so  ()
2826
);
2827
 
2828
 
2829
 
2830
 
2831
 
2832
 
2833
 
2834
 
2835
 
2836
 
2837
 
2838
// thread 2
2839
// added or modified due to stickcmp clean-up
2840
assign stickcmp_intdis_din[2] = tickcmp_intdis_din[2];
2841
// added for bug 4763
2842
assign stickcmp_intdis_en[2] =
2843
           ~tlu_stickcmp_en_l[2] | local_rst | tlu_por_rstint_g[2];
2844
 
2845
dffe dffe_stickcmp_intdis2 (
2846
    .din (stickcmp_intdis_din[2]),
2847
        .q   (true_stickcmp2[63]),
2848
    .en  (stickcmp_intdis_en[2]),
2849
    .clk (clk),
2850
    .se  (se),
2851
    .si  (),
2852
    .so  ()
2853
);
2854
 
2855
 
2856
dffe #(64-1) stickcmp2 (
2857
    .din (tlu_wsr_data_w[64-2:0]),
2858
        .q   (true_stickcmp2[64-2:0]),
2859
    .en (~(tlu_stickcmp_en_l[2])), .clk(clk),
2860
    .se  (se),
2861
    .si  (),
2862
    .so  ()
2863
);
2864
 
2865
 
2866
 
2867
 
2868
 
2869
 
2870
 
2871
 
2872
 
2873
 
2874
 
2875
// thread 3
2876
// added or modified due to stickcmp clean-up
2877
assign stickcmp_intdis_din[3] = tickcmp_intdis_din[3];
2878
// added and modified for bug 4763
2879
assign stickcmp_intdis_en[3] =
2880
           ~tlu_stickcmp_en_l[3] | local_rst | tlu_por_rstint_g[3];
2881
 
2882
dffe dffe_stickcmp_intdis3 (
2883
    .din (stickcmp_intdis_din[3]),
2884
        .q   (true_stickcmp3[63]),
2885
    .en  (stickcmp_intdis_en[3]),
2886
    .clk (clk),
2887
    .se  (se),
2888
    .si  (),
2889
    .so  ()
2890
);
2891
 
2892
 
2893
dffe #(64-1) stickcmp3 (
2894
    .din (tlu_wsr_data_w[64-2:0]),
2895
        .q   (true_stickcmp3[64-2:0]),
2896
    .en (~(tlu_stickcmp_en_l[3])), .clk(clk),
2897
    .se  (se),
2898
    .si  (),
2899
    .so  ()
2900
);
2901
 
2902
 
2903
 
2904
 
2905
 
2906
 
2907
 
2908
 
2909
 
2910
 // !`ifdef FPGA_SYN_CLK_DFF
2911
 
2912
// Select 1/4 sources. Assume compare is independent of read
2913
// and thus needs separate mux
2914
 
2915
 
2916
 
2917
 
2918
 
2919
 
2920
mux4ds #(64-3) mux_stickcmp_data (
2921
       .in0  (true_stickcmp0[64-2:2]),
2922
       .in1  (true_stickcmp1[64-2:2]),
2923
       .in2  (true_stickcmp2[64-2:2]),
2924
       .in3  (true_stickcmp3[64-2:2]),
2925
       .sel0 (tlu_tickcmp_sel[0]),
2926
       .sel1 (tlu_tickcmp_sel[1]),
2927
       .sel2 (tlu_tickcmp_sel[2]),
2928
       .sel3 (tlu_tickcmp_sel[3]),
2929
       .dout (stickcmp_data[64-4:0])
2930
);
2931
//
2932
// mux for read
2933
mux4ds #(64) mux_stickcmp_rdata (
2934
       .in0  (true_stickcmp0[64-1:0]),
2935
       .in1  (true_stickcmp1[64-1:0]),
2936
       .in2  (true_stickcmp2[64-1:0]),
2937
       .in3  (true_stickcmp3[64-1:0]),
2938
       .sel0 (tlu_thrd_rsel_e[0]),
2939
       .sel1 (tlu_thrd_rsel_e[1]),
2940
       .sel2 (tlu_thrd_rsel_e[2]),
2941
       .sel3 (tlu_thrd_rsel_e[3]),
2942
       .dout (stickcmp_rdata[64-1:0])
2943
);
2944
 // !`ifdef FPGA_SYN_1THREAD
2945
 
2946
//
2947
// evaluate for stickcmp match
2948
assign stick_match =
2949
           (stickcmp_data[60:0] ==
2950
            true_tick[60:0]);
2951
//
2952
// moved from tlu_tcl
2953
assign  stickcmp_int[0] =
2954
            stick_match & ~true_stickcmp0[63] & tlu_tickcmp_sel[0];
2955
assign  stickcmp_int[1] =
2956
            stick_match & ~true_stickcmp1[63] & tlu_tickcmp_sel[1];
2957
assign  stickcmp_int[2] =
2958
            stick_match & ~true_stickcmp2[63] & tlu_tickcmp_sel[2];
2959
assign  stickcmp_int[3] =
2960
            stick_match & ~true_stickcmp3[63] & tlu_tickcmp_sel[3];
2961
 
2962
//=========================================================================================
2963
//      HTICK COMPARE  for Threads
2964
//=========================================================================================
2965
// added for hypervisor support
2966
 
2967
 
2968
 
2969
 
2970
 
2971
 
2972
 
2973
 
2974
 
2975
 
2976
 
2977
 
2978
 
2979
 
2980
 
2981
 
2982
 
2983
 
2984
 
2985
 
2986
 
2987
 
2988
 
2989
 
2990
 
2991
 
2992
 
2993
 
2994
 
2995
 
2996
 
2997
 
2998
 
2999
 
3000
 
3001
 
3002
 
3003
 
3004
 
3005
 
3006
 
3007
// THREAD0
3008
 
3009
dffe #(64-1) htickcmp0 (
3010
    .din (tlu_wsr_data_w[64-2:0]),
3011
        .q   (true_htickcmp0[64-2:0]),
3012
    .en (~(tlu_htickcmp_en_l[0])), .clk(clk),
3013
    .se  (se),
3014
    .si  (),
3015
    .so  ()
3016
);
3017
 
3018
 
3019
 
3020
 
3021
 
3022
 
3023
 
3024
 
3025
 
3026
 
3027
 
3028
// THREAD1
3029
 
3030
dffe #(64-1) htickcmp1 (
3031
    .din (tlu_wsr_data_w[64-2:0]),
3032
        .q   (true_htickcmp1[64-2:0]),
3033
    .en (~(tlu_htickcmp_en_l[1])), .clk(clk),
3034
    .se  (se),
3035
    .si  (),
3036
    .so  ()
3037
);
3038
 
3039
 
3040
 
3041
 
3042
 
3043
 
3044
 
3045
 
3046
 
3047
 
3048
 
3049
// THREAD2
3050
 
3051
dffe #(64-1) htickcmp2 (
3052
    .din (tlu_wsr_data_w[64-2:0]),
3053
        .q   (true_htickcmp2[64-2:0]),
3054
    .en (~(tlu_htickcmp_en_l[2])), .clk(clk),
3055
    .se  (se),
3056
    .si  (),
3057
    .so  ()
3058
);
3059
 
3060
 
3061
 
3062
 
3063
 
3064
 
3065
 
3066
 
3067
 
3068
 
3069
 
3070
// THREAD3
3071
 
3072
dffe #(64-1) htickcmp3 (
3073
    .din (tlu_wsr_data_w[64-2:0]),
3074
        .q   (true_htickcmp3[64-2:0]),
3075
    .en (~(tlu_htickcmp_en_l[3])), .clk(clk),
3076
    .se  (se),
3077
    .si  (),
3078
    .so  ()
3079
);
3080
 
3081
 
3082
 
3083
 
3084
 
3085
 
3086
 
3087
 
3088
 
3089
 
3090
 
3091
 
3092
// Select 1/4 sources. Assume compare is independent of read
3093
// and thus needs separate mux
3094
 
3095
 
3096
 
3097
 
3098
 
3099
mux4ds #(64-3) mux_htickcmp_data (
3100
       .in0  (true_htickcmp0[64-2:2]),
3101
       .in1  (true_htickcmp1[64-2:2]),
3102
       .in2  (true_htickcmp2[64-2:2]),
3103
       .in3  (true_htickcmp3[64-2:2]),
3104
       .sel0 (tlu_tickcmp_sel[0]),
3105
       .sel1 (tlu_tickcmp_sel[1]),
3106
       .sel2 (tlu_tickcmp_sel[2]),
3107
       .sel3 (tlu_tickcmp_sel[3]),
3108
       .dout (htickcmp_data[64-4:0])
3109
);
3110
//
3111
// mux for read
3112
mux4ds #(64-1) mux_htickcmp_rdata (
3113
       .in0  (true_htickcmp0[64-2:0]),
3114
       .in1  (true_htickcmp1[64-2:0]),
3115
       .in2  (true_htickcmp2[64-2:0]),
3116
       .in3  (true_htickcmp3[64-2:0]),
3117
       .sel0 (tlu_thrd_rsel_e[0]),
3118
       .sel1 (tlu_thrd_rsel_e[1]),
3119
       .sel2 (tlu_thrd_rsel_e[2]),
3120
       .sel3 (tlu_thrd_rsel_e[3]),
3121
       .dout (htickcmp_rdata[64-2:0])
3122
);
3123
 // !`ifdef FPGA_SYN_1THREAD
3124
 
3125
//
3126
// evaluate for htickcmp match
3127
assign tlu_htick_match =
3128
           (htickcmp_data[60:0] ==
3129
            true_tick[60:0]);
3130
//
3131
//=========================================================================================
3132
// HINTP REG for Threads
3133
//=========================================================================================
3134
// added for hypervisor support
3135
// modified for timing
3136
// creating clocks for accessing the hintp regs
3137
assign tlu_hintp_en_l_g[0] =
3138
           ~(tlu_set_hintp_g[0] | tlu_wr_hintp_g[0]);
3139
assign tlu_hintp_en_l_g[1] =
3140
           ~(tlu_set_hintp_g[1] | tlu_wr_hintp_g[1]);
3141
assign tlu_hintp_en_l_g[2] =
3142
           ~(tlu_set_hintp_g[2] | tlu_wr_hintp_g[2]);
3143
assign tlu_hintp_en_l_g[3] =
3144
           ~(tlu_set_hintp_g[3] | tlu_wr_hintp_g[3]);
3145
 
3146
 
3147
 
3148
 
3149
 
3150
 
3151
 
3152
 
3153
 
3154
 
3155
 
3156
 
3157
 
3158
 
3159
 
3160
 
3161
 
3162
 
3163
 
3164
 
3165
 
3166
 
3167
 
3168
 
3169
 
3170
 
3171
 
3172
 
3173
 
3174
 
3175
 
3176
 
3177
 
3178
 
3179
 
3180
 
3181
 
3182
 
3183
 
3184
 
3185
// 
3186
// setting the value of hintp registers
3187
//
3188
// Thread 0
3189
// added for timing
3190
assign tlu_set_hintp_g[0] =
3191
           tlu_set_hintp_sel_g[0] & tlu_htick_match;
3192
 
3193
// modified to reflect the physical implementation
3194
// assign hintp_din[0] = 
3195
//            (tlu_set_hintp_g[0])? tlu_set_hintp_g[0]: wsr_data_w[0]; 
3196
 
3197
mux2ds mx_hintp_din_0 (
3198
       .in0  (tlu_set_hintp_g[0]),
3199
           .in1  (wsr_data_w[0]),
3200
       .sel0 (tlu_set_hintp_g[0]),
3201
           .sel1 (~tlu_set_hintp_g[0]),
3202
       .dout (hintp_din[0])
3203
);
3204
 
3205
 
3206
dffre dffr_hintp0 (
3207
     .din (hintp_din[0]),
3208
     .q   (tlu_hintp[0]),
3209
     .en (~(tlu_hintp_en_l_g[0])), .clk(clk),
3210
         .rst (local_rst),
3211
     .se  (se),
3212
     .si  (),
3213
     .so  ()
3214
);
3215
 
3216
 
3217
 
3218
 
3219
 
3220
 
3221
 
3222
 
3223
 
3224
 
3225
 
3226
 
3227
// Thread 1
3228
// added for timing
3229
assign tlu_set_hintp_g[1] =
3230
           tlu_set_hintp_sel_g[1] & tlu_htick_match;
3231
 
3232
// modified to reflect the physical implementation
3233
// assign hintp_din[1] = 
3234
//            (tlu_set_hintp_g[1])? tlu_set_hintp_g[1]: wsr_data_w[0]; 
3235
 
3236
mux2ds mx_hintp_din_1 (
3237
       .in0  (tlu_set_hintp_g[1]),
3238
           .in1  (wsr_data_w[0]),
3239
       .sel0 (tlu_set_hintp_g[1]),
3240
           .sel1 (~tlu_set_hintp_g[1]),
3241
       .dout (hintp_din[1])
3242
);
3243
 
3244
 
3245
dffre dffr_hintp1 (
3246
     .din (hintp_din[1]),
3247
     .q   (tlu_hintp[1]),
3248
     .en (~(tlu_hintp_en_l_g[1])), .clk(clk),
3249
         .rst (local_rst),
3250
     .se  (se),
3251
     .si  (),
3252
     .so  ()
3253
);
3254
 
3255
 
3256
 
3257
 
3258
 
3259
 
3260
 
3261
 
3262
 
3263
 
3264
 
3265
 
3266
// Thread 2
3267
// added for timing
3268
assign tlu_set_hintp_g[2] =
3269
           tlu_set_hintp_sel_g[2] & tlu_htick_match;
3270
 
3271
// modified to reflect the physical implementation
3272
// assign hintp_din[2] = 
3273
//            (tlu_set_hintp_g[2])? tlu_set_hintp_g[2]: wsr_data_w[0]; 
3274
 
3275
mux2ds mx_hintp_din_2 (
3276
       .in0  (tlu_set_hintp_g[2]),
3277
           .in1  (wsr_data_w[0]),
3278
       .sel0 (tlu_set_hintp_g[2]),
3279
           .sel1 (~tlu_set_hintp_g[2]),
3280
       .dout (hintp_din[2])
3281
);
3282
 
3283
 
3284
dffre dffr_hintp2 (
3285
     .din (hintp_din[2]),
3286
     .q   (tlu_hintp[2]),
3287
     .en (~(tlu_hintp_en_l_g[2])), .clk(clk),
3288
         .rst (local_rst),
3289
     .se  (se),
3290
     .si  (),
3291
     .so  ()
3292
);
3293
 
3294
 
3295
 
3296
 
3297
 
3298
 
3299
 
3300
 
3301
 
3302
 
3303
 
3304
 
3305
// Thread 3
3306
// added for timing
3307
assign tlu_set_hintp_g[3] =
3308
           tlu_set_hintp_sel_g[3] & tlu_htick_match;
3309
 
3310
// modified to reflect the physical implementation
3311
// assign hintp_din[3] = 
3312
//            (tlu_set_hintp_g[3])? tlu_set_hintp_g[3]: wsr_data_w[0]; 
3313
 
3314
mux2ds mx_hintp_din_3 (
3315
       .in0  (tlu_set_hintp_g[3]),
3316
           .in1  (wsr_data_w[0]),
3317
       .sel0 (tlu_set_hintp_g[3]),
3318
           .sel1 (~tlu_set_hintp_g[3]),
3319
       .dout (hintp_din[3])
3320
);
3321
 
3322
 
3323
dffre dffr_hintp3 (
3324
     .din (hintp_din[3]),
3325
     .q   (tlu_hintp[3]),
3326
     .en (~(tlu_hintp_en_l_g[3])), .clk(clk),
3327
         .rst (local_rst),
3328
     .se  (se),
3329
     .si  (),
3330
     .so  ()
3331
);
3332
 
3333
 
3334
 
3335
 
3336
 
3337
 
3338
 
3339
 
3340
 
3341
 
3342
 
3343
 
3344
//=========================================================================================
3345
//      DONE/RETRY 
3346
//=========================================================================================
3347
 
3348
// PC/nPC will be updated by pc/npc from IFU,
3349
// OR, Done/Retry which reads TSA in E stage. Execution of Done/Retry will
3350
// put pc/npc temporarily in bypass flop which will then update actual pc/npc
3351
// in g. Update of pc/npc by inst_in_w or done/retry thus becomes aligned.
3352
// recoded due to lint violations - individualized the components
3353
/*
3354
dff #(`TLU_TSA_WIDTH) poptsa_m (
3355
    .din (tsa_rdata[`TLU_TSA_WIDTH-1:0]),
3356
        .q   (tsa_data_m[`TLU_TSA_WIDTH-1:0]),
3357
    .clk (clk),
3358
    .se  (se),
3359
    .si  (),
3360
    .so  ()
3361
);
3362
//
3363
// added, modified for hypervisor and timing
3364
assign dnrtry_pstate_m =
3365
       {2'b0,  // old IG, MG - replaced by global register
3366
        tsa_data_m[`TSA_PSTATE_VRANGE2_HI:`TSA_PSTATE_VRANGE2_LO],
3367
        2'b0,  // memory model has been change to TSO only - bug 2588
3368
        1'b0,  // old RED - replaced by hpstate.red
3369
        tsa_data_m[`TSA_PSTATE_VRANGE1_HI:`TSA_PSTATE_VRANGE1_LO],
3370
        1'b0}; // old AG - replaced by global register
3371
 
3372
dff #(12) dff_pstate_g (
3373
    .din (dnrtry_pstate_m[`PSTATE_TRUE_WIDTH-1:0]),
3374
        .q   (dnrtry_pstate[`PSTATE_TRUE_WIDTH-1:0]),
3375
    .clk (clk),
3376
    .se  (se),
3377
    .si  (),
3378
    .so  ()
3379
    );
3380
*/
3381
// recoded due to lint violation
3382
 
3383
dff #(6) dff_dnrtry_pstate_m (
3384
    .din ({tsa_rdata[19:18],
3385
           tsa_rdata[15:12]}),
3386
        .q   (dnrtry_pstate_m[6-1:0]),
3387
    .clk (clk),
3388
    .se  (se),
3389
    .si  (),
3390
    .so  ()
3391
);
3392
 
3393
dff #(6) dff_pstate_g (
3394
    .din (dnrtry_pstate_m[6-1:0]),
3395
        .q   (dnrtry_pstate_g[6-1:0]),
3396
    .clk (clk),
3397
    .se  (se),
3398
    .si  (),
3399
    .so  ()
3400
);
3401
 
3402
dff #(6) dff_pstate_w2 (
3403
    .din (dnrtry_pstate_g[6-1:0]),
3404
        .q   (dnrtry_pstate_w2[6-1:0]),
3405
    .clk (clk),
3406
    .se  (se),
3407
    .si  (),
3408
    .so  ()
3409
);
3410
// assign dnrtry_pstate_m[`WSR_PSTATE_VR_WIDTH-1:0] = 
3411
//        {tsa_data_m[`TSA_PSTATE_VRANGE2_HI:`TSA_PSTATE_VRANGE2_LO],
3412
//         tsa_data_m[`TSA_PSTATE_VRANGE1_HI:`TSA_PSTATE_VRANGE1_LO]}; 
3413
// 
3414
// reading hpstate from tsa for recovery
3415
// recoded due to lint violations
3416
 
3417
dff #(4) dff_tsa_dnrtry_hpstate_m (
3418
    // .din (tsa_rdata[`TLU_HTSTATE_HI:`TLU_HTSTATE_LO]), 
3419
    .din (tsa_rdata[133:130]),
3420
        .q   (tsa_dnrtry_hpstate_m[4-1:0]),
3421
    .clk (clk),
3422
    .se  (se),
3423
    .si  (),
3424
    .so  ()
3425
);
3426
 
3427
dff #(4) dff_tsa_dnrtry_hpstate_g (
3428
//     .din (tsa_data_m[`TLU_HTSTATE_HI:`TLU_HTSTATE_LO]),
3429
    .din (tsa_dnrtry_hpstate_m[4-1:0]),
3430
        .q   (tsa_dnrtry_hpstate_g[4-1:0]),
3431
    .clk (clk),
3432
    .se  (se),
3433
    .si  (),
3434
    .so  ()
3435
);
3436
// 
3437
// added for timing
3438
dff #(4) dff_tsa_dnrtry_hpstate_w2 (
3439
    .din (tsa_dnrtry_hpstate_g[4-1:0]),
3440
        .q   (tsa_dnrtry_hpstate_w2[4-1:0]),
3441
    .clk (clk),
3442
    .se  (se),
3443
    .si  (),
3444
    .so  ()
3445
);
3446
 
3447
// reading value of original global registers from tsa for recovery
3448
// recoded due to lint cleanup
3449
// assign dnrtry_global_m = tsa_data_m[`TLU_GL_HI:`TLU_GL_LO];
3450
 
3451
dff #(2) dff_dnrtry_global_m (
3452
    .din (tsa_rdata[37:36]),
3453
        .q   (dnrtry_global_m[2-1:0]),
3454
    .clk (clk),
3455
    .se  (se),
3456
    .si  (),
3457
    .so  ()
3458
);
3459
 
3460
dff #(2) dff_global_g (
3461
    .din (dnrtry_global_m[2-1:0]),
3462
        .q   (tlu_dnrtry_global_g[2-1:0]),
3463
    .clk (clk),
3464
    .se  (se),
3465
    .si  (),
3466
    .so  ()
3467
);
3468
//
3469
/* logic moved to tlu_misctl
3470
// added due to lint violations
3471
dff #(47) dff_tsa_pc_m (
3472
    .din (tsa_rdata[`TLU_PC_HI:`TLU_PC_LO]),
3473
        .q   (tsa_pc_m[46:0]),
3474
    .clk (clk),
3475
    .se  (se),
3476
    .si  (),
3477
    .so  ()
3478
);
3479
 
3480
dff #(47) dff_tsa_npc_m (
3481
    .din (tsa_rdata[`TLU_NPC_HI:`TLU_NPC_LO]),
3482
        .q   (tsa_npc_m[46:0]),
3483
    .clk (clk),
3484
    .se  (se),
3485
    .si  (),
3486
    .so  ()
3487
);
3488
 
3489
// pstate may have to be staged by an additional cycle.
3490
assign dnrtry_pc[48:0]  = {tsa_pc_m[46:0],2'b00};
3491
assign dnrtry_npc[48:0] = {tsa_npc_m[46:0],2'b00};
3492
*/
3493
 
3494
//=========================================================================================
3495
//      PC/nPC
3496
//=========================================================================================
3497
 
3498
// TRUE PC/NPC. AN INSTRUCTION'S PC/NPC IS VISIBLE IN W2.
3499
// F:S:D:E:M:G:W2
3500
// Modified by Done/Retry and inst
3501
 
3502
/* logic moved to tlu_misctl
3503
// On done, npc will become pc.
3504
// modified due to bug 3017
3505
// pc width increase from 48 -> 49 bits
3506
mux3ds #(49) finalpc_sel_m (
3507
       .in0  (dnrtry_pc[48:0]),
3508
           .in1  (dnrtry_npc[48:0]),
3509
           .in2  (ifu_tlu_pc_m[48:0]),
3510
       .sel0 (tlu_retry_inst_m),
3511
           .sel1 (tlu_done_inst_m),
3512
           .sel2 (tlu_dnrtry_inst_m_l),
3513
       .dout (pc_new[48:0])
3514
);
3515
// On done, npc will stay npc. The valid to the IFU will
3516
// not be signaled along with npc for a done.
3517
// modified due to bug 3017
3518
// pc width increase from 48 -> 49 bits
3519
mux2ds #(49) finalnpc_sel_m (
3520
       .in0  (dnrtry_npc[48:0]),
3521
       .in1  (ifu_tlu_npc_m[48:0]),
3522
       .sel0 (~tlu_dnrtry_inst_m_l),
3523
       .sel1 (tlu_dnrtry_inst_m_l),
3524
       .dout (npc_new[48:0])
3525
);
3526
 
3527
dff #(49) dff_pc_new_w (
3528
    .din (pc_new[48:0]),
3529
    .q   (pc_new_w[48:0]),
3530
    .clk (clk),
3531
    .se  (se),
3532
    .si  (),
3533
    .so  ()
3534
);
3535
 
3536
dff #(49) dff_npc_new_w (
3537
    .din (npc_new[48:0]),
3538
    .q   (npc_new_w[48:0]),
3539
    .clk (clk),
3540
    .se  (se),
3541
    .si  (),
3542
    .so  ()
3543
);
3544
*/
3545
//
3546
 
3547
 
3548
 
3549
 
3550
 
3551
 
3552
 
3553
 
3554
 
3555
 
3556
 
3557
 
3558
 
3559
 
3560
 
3561
 
3562
 
3563
 
3564
 
3565
 
3566
 
3567
 
3568
 
3569
 
3570
 
3571
 
3572
 
3573
 
3574
 
3575
 
3576
 
3577
 
3578
 
3579
 
3580
 
3581
 
3582
 
3583
 
3584
 
3585
//
3586
// modified for bug 3017 
3587
// all pc width has been increased from 48 -> 49 bits
3588
// Thread 0
3589
//
3590
 
3591
dffe #(49) pc0_true (
3592
    .din (tlu_pc_new_w[48:0]),
3593
    .q   (true_pc0[48:0]),
3594
    .en (~(tlu_update_pc_l_w[0])), .clk(clk),
3595
    .se  (se),
3596
    .si  (),
3597
    .so  ()
3598
);
3599
 
3600
 
3601
 
3602
 
3603
 
3604
 
3605
 
3606
 
3607
 
3608
 
3609
 
3610
// update_pc will be used for both pc and npc - in this case
3611
// npc will contain gibberish but it's okay. 
3612
// modified to avert area growth 
3613
 
3614
dffe #(49) npc0_true (
3615
    .din (tlu_npc_new_w[48:0]),
3616
    .q  (true_npc0[48:0]),
3617
    .en (~(tlu_update_pc_l_w[0])), .clk(clk),
3618
    .se  (se),
3619
    .si  (),
3620
    .so  ()
3621
);
3622
 
3623
 
3624
 
3625
 
3626
 
3627
 
3628
 
3629
 
3630
 
3631
 
3632
//
3633
// THREAD1
3634
//
3635
 
3636
dffe #(49) pc1_true (
3637
    .din (tlu_pc_new_w[48:0]),
3638
    .q   (true_pc1[48:0]),
3639
    .en (~(tlu_update_pc_l_w[1])), .clk(clk),
3640
    .se  (se),
3641
    .si  (),
3642
    .so  ()
3643
);
3644
 
3645
 
3646
 
3647
 
3648
 
3649
 
3650
 
3651
 
3652
 
3653
 
3654
 
3655
// update_pc will be used for both pc and npc - in this case
3656
// npc will contain gibberish but it's okay. 
3657
 
3658
dffe #(49) npc1_true (
3659
    .din (tlu_npc_new_w[48:0]),
3660
    .q   (true_npc1[48:0]),
3661
    .en (~(tlu_update_pc_l_w[1])), .clk(clk),
3662
    .se  (se),
3663
    .si  (),
3664
    .so  ()
3665
);
3666
 
3667
 
3668
 
3669
 
3670
 
3671
 
3672
 
3673
 
3674
 
3675
 
3676
//
3677
// THREAD2
3678
//
3679
 
3680
dffe #(49) pc2_true (
3681
    .din (tlu_pc_new_w[48:0]),
3682
    .q   (true_pc2[48:0]),
3683
    .en (~(tlu_update_pc_l_w[2])), .clk(clk),
3684
    .se  (se),
3685
    .si  (),
3686
    .so  ()
3687
);
3688
 
3689
 
3690
 
3691
 
3692
 
3693
 
3694
 
3695
 
3696
 
3697
 
3698
 
3699
// update_pc will be used for both pc and npc - in this case
3700
// npc will contain gibberish but it's okay. 
3701
 
3702
dffe #(49) npc2_true (
3703
    .din (tlu_npc_new_w[48:0]),
3704
    .q   (true_npc2[48:0]),
3705
    .en (~(tlu_update_pc_l_w[2])), .clk(clk),
3706
    .se  (se),
3707
    .si  (),
3708
    .so  ()
3709
);
3710
 
3711
 
3712
 
3713
 
3714
 
3715
 
3716
 
3717
 
3718
 
3719
 
3720
//
3721
// THREAD3
3722
//
3723
 
3724
dffe #(49) pc3_true (
3725
    .din (tlu_pc_new_w[48:0]),
3726
    .q   (true_pc3[48:0]),
3727
    .en (~(tlu_update_pc_l_w[3])), .clk(clk),
3728
    .se  (se),
3729
    .si  (),
3730
    .so  ()
3731
);
3732
 
3733
 
3734
 
3735
 
3736
 
3737
 
3738
 
3739
 
3740
 
3741
 
3742
 
3743
// update_pc will be used for both pc and npc - in this case
3744
// npc will contain gibberish but it's okay. 
3745
 
3746
dffe #(49) npc3_true (
3747
    .din (tlu_npc_new_w[48:0]),
3748
    .q   (true_npc3[48:0]),
3749
    .en (~(tlu_update_pc_l_w[3])), .clk(clk),
3750
    .se  (se),
3751
    .si  (),
3752
    .so  ()
3753
);
3754
 
3755
 
3756
 
3757
 
3758
 
3759
 
3760
 
3761
 
3762
 
3763
 
3764
 
3765
//=========================================================================================
3766
//      Generating Trap Vector
3767
//=========================================================================================
3768
// 
3769
// Normal Trap Processing.
3770
mux2ds mux_pc_bit15_sel (
3771
    .in0  (tlu_tl_gt_0_w2),
3772
    .in1  (htba_data[0]),
3773
    .sel0  (~tlu_trap_hpstate_enb),
3774
    .sel1  (tlu_trap_hpstate_enb),
3775
    .dout (pc_bit15_sel)
3776
);
3777
//
3778
// modified to help speed up simulation time
3779
//
3780
assign tlu_rstvaddr_base[33:0] = 34'h3_ffff_c000;
3781
mux3ds #(34) nrmlpc_sel_w2 (
3782
       .in0  (tlu_rstvaddr_base[33:0]),
3783
           .in1  ({tba_data[32:0], tlu_tl_gt_0_w2}),
3784
           .in2  ({htba_data[33:1], pc_bit15_sel}),
3785
       .sel0 (tlu_pc_mxsel_w2[0]),
3786
           .sel1 (tlu_pc_mxsel_w2[1]),
3787
           .sel2 (tlu_pc_mxsel_w2[2]),
3788
       .dout (partial_trap_pc_w2[33:0])
3789
);
3790
 
3791
assign tlu_partial_trap_pc_w1[33:0] = partial_trap_pc_w2[33:0];
3792
 
3793
// restore pc/npc select
3794
// true pc muxed into restore pc; previously restore_pcx was muxed in.
3795
// modified due to bug 3017
3796
 
3797
 
3798
 
3799
 
3800
 
3801
mux4ds  #(98) trprsel (
3802
        .in0    ({true_pc0[48:0],true_npc0[48:0]}),
3803
        .in1    ({true_pc1[48:0],true_npc1[48:0]}),
3804
        .in2    ({true_pc2[48:0],true_npc2[48:0]}),
3805
        .in3    ({true_pc3[48:0],true_npc3[48:0]}),
3806
        .sel0   (tlu_thrd_wsel_w2[0]),
3807
        .sel1   (tlu_thrd_wsel_w2[1]),
3808
        .sel2   (tlu_thrd_wsel_w2[2]),
3809
        .sel3   (tlu_thrd_wsel_w2[3]),
3810
        .dout   ({restore_pc_w2[48:0],restore_npc_w2[48:0]})
3811
);
3812
 // !`ifdef FPGA_SYN_1THREAD
3813
 
3814
//
3815
// the matching of the w1 and w2 is intentional
3816
assign tlu_restore_pc_w1[48:0]  = restore_pc_w2[48:0];
3817
assign tlu_restore_npc_w1[48:0] = restore_npc_w2[48:0];
3818
 
3819
//=========================================================================================
3820
//      TAP PC OBSERVABILITY
3821
//=========================================================================================
3822
//
3823
// modified due to spec change
3824
// shadow scan 
3825
// thread 0 data
3826
assign sscan_data_test0[51-1:0] =
3827
           {true_hpstate0[2:0],
3828
            true_pstate0[2],
3829
            true_pstate0[1],
3830
            true_pc0[47:2]};
3831
//
3832
// thread 1 data
3833
assign sscan_data_test1[51-1:0] =
3834
           {true_hpstate1[2:0],
3835
            true_pstate1[2],
3836
            true_pstate1[1],
3837
            true_pc1[47:2]};
3838
//
3839
// thread 2 data
3840
assign sscan_data_test2[51-1:0] =
3841
           {true_hpstate2[2:0],
3842
            true_pstate2[2],
3843
            true_pstate2[1],
3844
            true_pc2[47:2]};
3845
//
3846
// thread 3 data
3847
assign sscan_data_test3[51-1:0] =
3848
           {true_hpstate3[2:0],
3849
            true_pstate3[2],
3850
            true_pstate3[1],
3851
            true_pc3[47:2]};
3852
//
3853
 
3854
 
3855
 
3856
 
3857
mux4ds #(51) mx_sscan_test_data (
3858
       .in0  (sscan_data_test0[51-1:0]),
3859
       .in1  (sscan_data_test1[51-1:0]),
3860
       .in2  (sscan_data_test2[51-1:0]),
3861
       .in3  (sscan_data_test3[51-1:0]),
3862
       .sel0 (sscan_tid_sel[0]),
3863
       .sel1 (sscan_tid_sel[1]),
3864
       .sel2 (sscan_tid_sel[2]),
3865
       .sel3 (sscan_tid_sel[3]),
3866
       .dout (tdp_sscan_test_data[51-1:0])
3867
);
3868
 // !`ifdef FPGA_SYN_1THREAD
3869
 
3870
assign sscan_tid_sel[4-1:0] = ctu_sscan_tid[4-1:0];
3871
 
3872
assign tlu_sscan_test_data[51-1:0] =
3873
          tdp_sscan_test_data[51-1:0];
3874
 
3875
//=========================================================================================
3876
//      PSTATE for Threads
3877
//=========================================================================================
3878
 
3879
// pstate needs to be updated on a trap. Assume for now that only non-RED state instruction
3880
// related traps are handled.
3881
 
3882
// Normal traps, non-red mode.
3883
assign pstate_priv_set = tlu_select_tba_w2 | local_rst | tlu_select_redmode;
3884
//
3885
assign pstate_priv_thrd_set[0] = pstate_priv_set | ~true_hpstate0[3];
3886
assign pstate_priv_thrd_set[1] = pstate_priv_set | ~true_hpstate1[3];
3887
assign pstate_priv_thrd_set[2] = pstate_priv_set | ~true_hpstate2[3];
3888
assign pstate_priv_thrd_set[3] = pstate_priv_set | ~true_hpstate3[3];
3889
//
3890
// modified for bug 3349
3891
assign pstate_priv_update_w2[0] =
3892
       ~(tlu_update_pstate_l_w2[0] &
3893
        (true_hpstate0[3] | tlu_update_hpstate_l_w2[0])) |
3894
        (~wsr_data_w2[11] & tlu_hpstate_din_sel0[1]);
3895
assign pstate_priv_update_w2[1] =
3896
       ~(tlu_update_pstate_l_w2[1] &
3897
        (true_hpstate1[3] | tlu_update_hpstate_l_w2[1])) |
3898
        (~wsr_data_w2[11] & tlu_hpstate_din_sel1[1]);
3899
assign pstate_priv_update_w2[2] =
3900
       ~(tlu_update_pstate_l_w2[2] &
3901
        (true_hpstate2[3] | tlu_update_hpstate_l_w2[2])) |
3902
        (~wsr_data_w2[11] & tlu_hpstate_din_sel2[1]);
3903
assign pstate_priv_update_w2[3] =
3904
       ~(tlu_update_pstate_l_w2[3] &
3905
        (true_hpstate3[3] | tlu_update_hpstate_l_w2[3])) |
3906
        (~wsr_data_w2[11] & tlu_hpstate_din_sel3[1]);
3907
//
3908
assign hpstate_priv_update_w2[0] =
3909
       ~(tlu_update_hpstate_l_w2[0] &
3910
        (true_hpstate0[3] | tlu_update_pstate_l_w2[0]));
3911
assign hpstate_priv_update_w2[1] =
3912
       ~(tlu_update_hpstate_l_w2[1] &
3913
        (true_hpstate1[3] | tlu_update_pstate_l_w2[1]));
3914
assign hpstate_priv_update_w2[2] =
3915
       ~(tlu_update_hpstate_l_w2[2] &
3916
        (true_hpstate2[3] | tlu_update_pstate_l_w2[2]));
3917
assign hpstate_priv_update_w2[3] =
3918
       ~(tlu_update_hpstate_l_w2[3] &
3919
        (true_hpstate3[3] | tlu_update_pstate_l_w2[3]));
3920
//
3921
// added for bug 2161 and modified for bug 2161
3922
assign hpstate_enb_set[0] = true_hpstate0[3] & ~(local_rst | tlu_select_redmode);
3923
assign hpstate_enb_set[1] = true_hpstate1[3] & ~(local_rst | tlu_select_redmode);
3924
assign hpstate_enb_set[2] = true_hpstate2[3] & ~(local_rst | tlu_select_redmode);
3925
assign hpstate_enb_set[3] = true_hpstate3[3] & ~(local_rst | tlu_select_redmode);
3926
 
3927
// added for hpstate.ibe ECO 
3928
// modified due to timing - tlu_ibrkpt_trap_g has been delayed one stage to tlu_ibrkpt_trap_w2
3929
assign hpstate_ibe_set[0] =
3930
           true_hpstate0[4] & ~(local_rst | tlu_select_redmode | tlu_ibrkpt_trap_w2);
3931
assign hpstate_ibe_set[1] =
3932
           true_hpstate1[4] & ~(local_rst | tlu_select_redmode | tlu_ibrkpt_trap_w2);
3933
assign hpstate_ibe_set[2] =
3934
           true_hpstate2[4] & ~(local_rst | tlu_select_redmode | tlu_ibrkpt_trap_w2);
3935
assign hpstate_ibe_set[3] =
3936
           true_hpstate3[4] & ~(local_rst | tlu_select_redmode | tlu_ibrkpt_trap_w2);
3937
//
3938
// added due to TLZ spec change 
3939
// modified for bug 3505
3940
assign hpstate_tlz_set[0] = true_hpstate0[0] & ~(local_rst | tlu_select_redmode);
3941
assign hpstate_tlz_set[1] = true_hpstate1[0] & ~(local_rst | tlu_select_redmode);
3942
assign hpstate_tlz_set[2] = true_hpstate2[0] & ~(local_rst | tlu_select_redmode);
3943
assign hpstate_tlz_set[3] = true_hpstate3[0] & ~(local_rst | tlu_select_redmode);
3944
//
3945
// thread 0
3946
assign tlu_select_tle[0] =
3947
           tlu_pstate_tle[0] & ~(tlu_select_redmode);
3948
// modified for timing and bug 3417 
3949
assign tlu_select_cle[0] =
3950
           tlu_select_tle[0] &
3951
          (tlu_select_tba_w2 | ~true_hpstate0[3]);
3952
//         tlu_select_tle[0] & tlu_select_tba_w2; 
3953
//
3954
// modified for timing and width cleanup
3955
/*
3956
assign  ntrap_pstate0[`PSTATE_TRUE_WIDTH-1:0] =
3957
    {2'b0,  // tlu_select_int_global - replaced by gl register
3958
                // tlu_select_mmu_global - replaced by gl register
3959
         tlu_select_cle[0], // cle<-tle, or 0
3960
         tlu_select_tle[0], // keep old tle, or 0
3961
     2'b0,
3962
     1'b0,  // tlu_select_redmode - replaced by hpstate.red
3963
         1'b1,  // fp turned on
3964
         1'b0,  // address masking turned off
3965
         pstate_priv_thrd_set[0], // enter priv mode for priv traps
3966
         1'b0,  // interrupts disabled
3967
         1'b0}; // tlu_select_alt_global - replaced by gl register
3968
*/
3969
assign  ntrap_pstate0[6-1:0] =
3970
    {tlu_select_cle[0], // cle<-tle, or 0        
3971
         tlu_select_tle[0], // keep old tle, or 0
3972
         1'b1,  // fp turned on
3973
         1'b0,  // address masking turned off
3974
         pstate_priv_thrd_set[0], // enter priv mode for priv traps
3975
         1'b0}; // interrupts disabled
3976
//
3977
// thread 1
3978
assign tlu_select_tle[1] =
3979
           tlu_pstate_tle[1] & ~(tlu_select_redmode);
3980
// modified for timing and bug 3417 
3981
assign tlu_select_cle[1] =
3982
           tlu_select_tle[1] &
3983
          (tlu_select_tba_w2 | ~true_hpstate1[3]);
3984
//           tlu_select_tle[1] & tlu_select_tba_w2;
3985
//
3986
// modified due to timing
3987
/*
3988
assign  ntrap_pstate1[`PSTATE_TRUE_WIDTH-1:0] =
3989
    {2'b0,  // tlu_select_int_global - replaced by gl register
3990
                // tlu_select_mmu_global - replaced by gl register
3991
         tlu_select_cle[1], // cle<-tle, or 0
3992
         tlu_select_tle[1], // keep old tle, or 0
3993
     2'b0,
3994
     1'b0,  // tlu_select_redmode - replaced by hpstate.red
3995
         1'b1,  // fp turned on
3996
         1'b0,  // address masking turned off
3997
         pstate_priv_thrd_set[1], // enter priv mode for priv traps
3998
         1'b0,  // interrupts disabled
3999
         1'b0}; // tlu_select_alt_global - replaced by gl register
4000
*/
4001
assign  ntrap_pstate1[6-1:0] =
4002
    {tlu_select_cle[1], // cle<-tle, or 0       
4003
         tlu_select_tle[1], // keep old tle, or 0
4004
         1'b1,  // fp turned on
4005
         1'b0,  // address masking turned off
4006
         pstate_priv_thrd_set[1], // enter priv mode for priv traps
4007
         1'b0}; // interrupts disabled// 
4008
//
4009
// thread 2
4010
assign tlu_select_tle[2] =
4011
           tlu_pstate_tle[2] & ~(tlu_select_redmode);
4012
// modified for timing and bug 3417 
4013
assign tlu_select_cle[2] =
4014
           tlu_select_tle[2] &
4015
          (tlu_select_tba_w2 | ~true_hpstate2[3]);
4016
//           tlu_select_tle[2] & tlu_select_tba_w2; 
4017
//
4018
// modified for timing and width cleanup
4019
/*
4020
assign  ntrap_pstate2[`PSTATE_TRUE_WIDTH-1:0] =
4021
    {2'b0,  // tlu_select_int_global - replaced by gl register
4022
                // tlu_select_mmu_global - replaced by gl register
4023
         tlu_select_cle[2], // cle<-tle, or 0
4024
         tlu_select_tle[2], // keep old tle, or 0
4025
     2'b0,
4026
     1'b0,  // tlu_select_redmode - replaced by hpstate.red
4027
         1'b1,  // fp turned on
4028
         1'b0,  // address masking turned off
4029
         pstate_priv_thrd_set[2], // enter priv mode for priv traps
4030
         1'b0,  // interrupts disabled
4031
         1'b0}; // tlu_select_alt_global - replaced by gl register
4032
*/
4033
assign  ntrap_pstate2[6-1:0] =
4034
    {tlu_select_cle[2], // cle<-tle, or 0       
4035
         tlu_select_tle[2], // keep old tle, or 0
4036
         1'b1,  // fp turned on
4037
         1'b0,  // address masking turned off
4038
         pstate_priv_thrd_set[2], // enter priv mode for priv traps
4039
         1'b0}; // interrupts disabled// 
4040
//
4041
// thread 3
4042
assign tlu_select_tle[3] =
4043
           tlu_pstate_tle[3] & ~(tlu_select_redmode);
4044
// modified for timing and bug 3417 
4045
assign tlu_select_cle[3] =
4046
           tlu_select_tle[3] &
4047
          (tlu_select_tba_w2 | ~true_hpstate3[3]);
4048
//           tlu_select_tle[3] & tlu_select_tba_w2;
4049
//
4050
// modified for timing
4051
/*
4052
assign  ntrap_pstate3[`PSTATE_TRUE_WIDTH-1:0] =
4053
    {2'b0,  // tlu_select_int_global - replaced by gl register
4054
                // tlu_select_mmu_global - replaced by gl register
4055
         tlu_select_cle[3], // cle<-tle, or 0
4056
         tlu_select_tle[3], // keep old tle, or 0
4057
     2'b0,
4058
     1'b0,  // tlu_select_redmode - replaced by hpstate.red
4059
         1'b1,  // fp turned on
4060
         1'b0,  // address masking turned off
4061
         pstate_priv_thrd_set[3], // enter priv mode for priv traps
4062
         1'b0,  // interrupts disabled
4063
         1'b0}; // tlu_select_alt_global - replaced by gl register
4064
*/
4065
assign  ntrap_pstate3[6-1:0] =
4066
    {tlu_select_cle[3], // cle<-tle, or 0       
4067
         tlu_select_tle[3], // keep old tle, or 0
4068
         1'b1,  // fp turned on
4069
         1'b0,  // address masking turned off
4070
         pstate_priv_thrd_set[3], // enter priv mode for priv traps
4071
         1'b0}; // interrupts disabled// 
4072
 
4073
// Clock Enable Buffers
4074
//
4075
 
4076
 
4077
 
4078
 
4079
 
4080
 
4081
 
4082
 
4083
 
4084
 
4085
 
4086
 
4087
 
4088
 
4089
 
4090
 
4091
 
4092
 
4093
 
4094
 
4095
 
4096
 
4097
 
4098
 
4099
 
4100
 
4101
 
4102
 
4103
 
4104
 
4105
 
4106
 
4107
 
4108
 
4109
 
4110
 
4111
 
4112
 
4113
 
4114
//
4115
// added for hypervisor support 
4116
// clock enable buffers for updating the hpstate registers
4117
//
4118
 
4119
 
4120
 
4121
 
4122
 
4123
 
4124
 
4125
 
4126
 
4127
 
4128
 
4129
 
4130
 
4131
 
4132
 
4133
 
4134
 
4135
 
4136
 
4137
 
4138
 
4139
 
4140
 
4141
 
4142
 
4143
 
4144
 
4145
 
4146
 
4147
 
4148
 
4149
 
4150
 
4151
 
4152
 
4153
 
4154
 
4155
 
4156
 
4157
// assign the initial value of hpstate.red mode
4158
//
4159
// modified for bug 1893
4160
// assign hpstate_redmode = 
4161
//            (local_rst)? 1'b1: tlu_select_redmode;
4162
assign hpstate_redmode =
4163
           local_rst | (~local_rst & tlu_select_redmode);
4164
// 
4165
// extracting hpstate from wsr_data
4166
//
4167
// modified for timing tlu_wsr_data_w -> wsr_data_w2
4168
assign wsr_data_hpstate_w2[5-1:0] =
4169
     {wsr_data_w2[10],
4170
      wsr_data_w2[11],
4171
      wsr_data_w2[5],
4172
      wsr_data_w2[2],
4173
      wsr_data_w2[0]
4174
     };
4175
//
4176
// added or modified for hypervisor support
4177
// modified due to timing
4178
/*
4179
assign wsr_data_pstate_g[`PSTATE_TRUE_WIDTH-1:0] =
4180
    {2'b0,  // old IG, MG - replaced by global register
4181
     tlu_wsr_data_w[`PSTATE_VRANGE2_HI:`PSTATE_VRANGE2_LO],
4182
     2'b0,  // memory model has been change to TSO only - bug 2588
4183
     1'b0,  // old red, - replaced by hpstate.red
4184
     tlu_wsr_data_w[`PSTATE_VRANGE1_HI:`PSTATE_VRANGE1_LO],
4185
     1'b0};  // old AG - replaced by global register
4186
 
4187
assign wsr_data_pstate_g[`WSR_PSTATE_VR_WIDTH-1:0] =
4188
       {tlu_wsr_data_w[`PSTATE_VRANGE2_HI:`PSTATE_VRANGE2_LO],
4189
        tlu_wsr_data_w[`PSTATE_VRANGE1_HI:`PSTATE_VRANGE1_LO]};
4190
*/
4191
assign wsr_data_pstate_w2[6-1:0] =
4192
       {wsr_data_w2[9:8],
4193
        wsr_data_w2[4:1]};
4194
//
4195
// THREAD0
4196
// added for bug 1575
4197
// modified for bug 2584
4198
// assign tlu_pstate_nt_sel0 = ~|(tlu_pstate_din_sel0[1:0]);
4199
assign tlu_pstate_nt_sel0 =
4200
          ~(tlu_pstate_din_sel0[0] | tlu_pstate_wsr_sel0);
4201
// 
4202
// modified for bug 3349
4203
assign tlu_pstate_wsr_sel0 =
4204
           tlu_pstate_din_sel0[1] |
4205
           (~(true_hpstate0[3] & wsr_data_w2[11]) &
4206
              tlu_hpstate_din_sel0[1]);
4207
//            (~true_hpstate0[`HPSTATE_ENB] & tlu_hpstate_din_sel0[1]);
4208
 
4209
mux3ds #(6) mux_restore_pstate0(
4210
       .in0  (dnrtry_pstate_w2[6-1:0]),
4211
           .in1  (wsr_data_pstate_w2[6-1:0]),
4212
           .in2  (ntrap_pstate0[6-1:0]),
4213
       .sel0 (tlu_pstate_din_sel0[0]),
4214
           .sel1 (tlu_pstate_wsr_sel0),
4215
           .sel2 (tlu_pstate_nt_sel0),
4216
       .dout (restore_pstate0[6-1:0])
4217
);
4218
 
4219
 
4220
dffe #(6-1) dff_restore_pstate0_w3 (
4221
    .din ({restore_pstate0[5:3-1],
4222
           restore_pstate0[0]}),
4223
    .q   ({restore_pstate0_w3[5:3-1],
4224
           restore_pstate0_w3[0]}),
4225
    .en (~(tlu_update_pstate_l_w2[0])), .clk(clk),
4226
    .se  (se),
4227
    .si  (),
4228
    .so  ()
4229
);
4230
 
4231
 
4232
 
4233
 
4234
 
4235
 
4236
 
4237
 
4238
 
4239
 
4240
 
4241
 
4242
//
4243
dffe dffe_pstate0_priv (
4244
    .din (restore_pstate0[1]),
4245
    .q   (restore_pstate0_w3[1]),
4246
    .en  (pstate_priv_update_w2[0]),
4247
    .clk (clk),
4248
    .se  (se),
4249
    .si  (),
4250
    .so  ()
4251
);
4252
//
4253
// true_pstate0 assignments
4254
assign true_pstate0[12-1:0] =
4255
           {2'b0, // tlu_select_int_global - replaced by gl register
4256
                  // tlu_select_mmu_global - replaced by gl register 
4257
            restore_pstate0_w3[5:4],
4258
            2'b0, // fixed mmodel - TSO
4259
            1'b0, // redmode - replaced by hpstate.red
4260
            restore_pstate0_w3[3:0],
4261
            1'b0}; // tlu_select_alt_global - replaced by gl register 
4262
//
4263
// modified for timing
4264
/*
4265
mux3ds #(9) mux_restore_pstate0(
4266
       .in0  (dnrtry_pstate[`PSTATE_TRUE_WIDTH-3:1]),
4267
           .in1  (wsr_data_pstate_g[`PSTATE_TRUE_WIDTH-3:1]),
4268
           .in2  (ntrap_pstate0[`PSTATE_TRUE_WIDTH-3:1]),
4269
       .sel0 (tlu_pstate_din_sel0[0]),
4270
       // modified for bug 2584
4271
           // .sel1 (tlu_pstate_din_sel0[1]),
4272
           .sel1 (tlu_pstate_wsr_sel0),
4273
           .sel2 (tlu_pstate_nt_sel0),
4274
       .dout (restore_pstate0[`PSTATE_TRUE_WIDTH-3:1])
4275
);
4276
 
4277
dff #(`PSTATE_TRUE_WIDTH) pstate0_1 (
4278
    .din (restore_pstate0[`PSTATE_TRUE_WIDTH-1:0]),
4279
        .q   (true_pstate0[`PSTATE_TRUE_WIDTH-1:0]),
4280
    .clk (pstate0_clk),
4281
    .se  (se),
4282
    .si  (),
4283
    .so  ()
4284
 );
4285
//
4286
dff #(`PSTATE_TRUE_WIDTH-1) dff_true_pstate0 (
4287
    .din ({restore_pstate0[`PSTATE_TRUE_WIDTH-1:3],
4288
           restore_pstate0[1:0]}),
4289
    .q   ({true_pstate0[`PSTATE_TRUE_WIDTH-1:3],
4290
           true_pstate0[1:0]}),
4291
    .clk (pstate0_clk),
4292
    .se  (se),
4293
    .si  (),
4294
    .so  ()
4295
);
4296
//
4297
dffe dffe_pstate0_priv (
4298
    .din (restore_pstate0[`PSTATE_PRIV]),
4299
    .q   (true_pstate0[`PSTATE_PRIV]),
4300
    .en  (pstate_priv_update_g[0]),
4301
    .clk (clk),
4302
    .se  (se),
4303
    .si  (),
4304
    .so  ()
4305
);
4306
// modified for hypervisor support
4307
assign restore_pstate0[11:10] = 2'b0;
4308
assign restore_pstate0[0]     = 1'b0;
4309
//
4310
// modified to reflect the physical implementation
4311
// assign hpstate_dnrtry_priv_w2[0] =
4312
           (true_hpstate0[`HPSTATE_ENB])?
4313
            tsa_dnrtry_hpstate_w2[`HPSTATE_PRIV] :
4314
            dnrtry_pstate_w2[`WSR_PSTATE_VR_PRIV];
4315
*/
4316
mux2ds mx_hpstate_dnrtry_priv_w2_0 (
4317
       .in0  (tsa_dnrtry_hpstate_w2[1]),
4318
           .in1  (dnrtry_pstate_w2[1]),
4319
       .sel0 (true_hpstate0[3]),
4320
           .sel1 (~true_hpstate0[3]),
4321
       .dout (hpstate_dnrtry_priv_w2[0])
4322
);
4323
//
4324
assign dnrtry_hpstate0_w2[5-1:0] =
4325
       {tsa_dnrtry_hpstate_w2[4-1],
4326
        true_hpstate0[3],
4327
        tsa_dnrtry_hpstate_w2[2],
4328
        hpstate_dnrtry_priv_w2[0],
4329
        tsa_dnrtry_hpstate_w2[0]};
4330
 
4331
// added for bug 3747
4332
assign hpstate_priv_set = ~(tlu_select_tba_w2) | tlu_select_redmode;
4333
//
4334
// constructing the hpstate for hyper-privileged traps 
4335
//
4336
assign hntrap_hpstate0_w2[5-1:0] =
4337
       {hpstate_ibe_set[0],
4338
        hpstate_enb_set[0],
4339
        hpstate_redmode, // Redmode bit
4340
        // modified for bug 3747
4341
        hpstate_priv_set, // hyper-privileged bit
4342
        hpstate_tlz_set[0]}; // TLZ interrupt bit 
4343
 
4344
assign tlu_hpstate_hnt_sel0 =
4345
       ~(tlu_hpstate_din_sel0[0] | tlu_hpstate_wsr_sel0);
4346
//
4347
assign tlu_hpstate_wsr_sel0 =
4348
           tlu_hpstate_din_sel0[1] |
4349
           (~true_hpstate0[3] & tlu_pstate_din_sel0[1]);
4350
 
4351
mux3ds #(5) mux_restore_hpstate0(
4352
       .in0  (dnrtry_hpstate0_w2[5-1:0]),
4353
           .in1  (wsr_data_hpstate_w2[5-1:0]),
4354
           .in2  (hntrap_hpstate0_w2[5-1:0]),
4355
       .sel0 (tlu_hpstate_din_sel0[0]),
4356
       .sel1 (tlu_hpstate_wsr_sel0),
4357
           .sel2 (tlu_hpstate_hnt_sel0),
4358
       .dout (restore_hpstate0[5-1:0])
4359
);
4360
//
4361
// need to initialize hpstate.enb = 0
4362
// need to initialize hpstate.ibe = 0
4363
// modified due to the addition of hpstate.ibe
4364
 
4365
dffre #(2) dffr_true_hpst0_enb_ibe (
4366
    .din (restore_hpstate0[5-1:5-2]),
4367
        .q   (true_hpstate0[5-1:5-2]),
4368
    .rst (local_rst),
4369
    .en (~(tlu_update_hpstate_l_w2[0])), .clk(clk),
4370
    .se  (se),
4371
    .si  (),
4372
    .so  ()
4373
 );
4374
 
4375
 
4376
 
4377
 
4378
 
4379
 
4380
 
4381
 
4382
 
4383
 
4384
 
4385
//
4386
 
4387
dffe #(2) dff_true_hpstate0 (
4388
    .din ({restore_hpstate0[2],
4389
           restore_hpstate0[0]}),
4390
    .q   ({true_hpstate0[2],
4391
           true_hpstate0[0]}),
4392
    .en (~(tlu_update_hpstate_l_w2[0])), .clk(clk),
4393
    .se  (se),
4394
    .si  (),
4395
    .so  ()
4396
);
4397
 
4398
 
4399
 
4400
 
4401
 
4402
 
4403
 
4404
 
4405
 
4406
 
4407
 
4408
 
4409
//
4410
dffe dffe_hpstate0_priv (
4411
    .din (restore_hpstate0[1]),
4412
    .q   (true_hpstate0[1]),
4413
    .en  (hpstate_priv_update_w2[0]),
4414
    .clk (clk),
4415
    .se  (se),
4416
    .si  (),
4417
    .so  ()
4418
);
4419
 
4420
assign tlu_ifu_pstate_pef[0]   = true_pstate0[4];
4421
assign tlu_lsu_pstate_cle[0]   = true_pstate0[9];
4422
assign tlu_lsu_pstate_priv[0]  = true_pstate0[2];
4423
assign tlu_int_pstate_ie[0]    = true_pstate0[1];
4424
assign local_pstate_ie[0]      = true_pstate0[1];
4425
// assign tlu_pstate_cle[0]        = true_pstate0[`PSTATE_CLE];
4426
assign tlu_pstate_tle[0]            = true_pstate0[8];
4427
// assign tlu_pstate_priv[0]       = true_pstate0[`PSTATE_PRIV];
4428
assign local_pstate_priv[0]    = true_pstate0[2];
4429
assign tlu_pstate_am[0]     = true_pstate0[3];
4430
assign tlu_int_redmode[0] = true_hpstate0[2];
4431
assign tlu_lsu_redmode[0] = true_hpstate0[2];
4432
// 
4433
// hypervisor privilege indicator
4434
assign tlu_hpstate_priv[0]   = true_hpstate0[1];
4435
assign local_hpstate_priv[0] = true_hpstate0[1];
4436
assign tcl_hpstate_priv[0]   = true_hpstate0[1];
4437
//
4438
// hypervisor lite mode selector
4439
assign tlu_hpstate_enb[0]   = true_hpstate0[3];
4440
assign local_hpstate_enb[0] = true_hpstate0[3];
4441
assign tcl_hpstate_enb[0]   = true_hpstate0[3];
4442
 
4443
// hypervisor tlz indicator
4444
assign tlu_hpstate_tlz[0] = true_hpstate0[0];
4445
 
4446
// hypervisor instruction breakpt enable 
4447
assign tlu_hpstate_ibe[0] = true_hpstate0[4];
4448
 
4449
 
4450
 
4451
 
4452
 
4453
 
4454
 
4455
 
4456
 
4457
 
4458
 
4459
 
4460
 
4461
 
4462
 
4463
 
4464
 
4465
 
4466
 
4467
 
4468
 
4469
 
4470
 
4471
// THREAD 1
4472
assign tlu_pstate_nt_sel1 =
4473
          ~(tlu_pstate_din_sel1[0] | tlu_pstate_wsr_sel1);
4474
//
4475
// modified for bug 3349
4476
assign tlu_pstate_wsr_sel1 =
4477
              tlu_pstate_din_sel1[1] |
4478
           (~(true_hpstate1[3] & wsr_data_w2[11]) &
4479
              tlu_hpstate_din_sel1[1]);
4480
//            (~true_hpstate1[`HPSTATE_ENB] & tlu_hpstate_din_sel1[1]);
4481
 
4482
mux3ds #(6) mux_restore_pstate1(
4483
       .in0  (dnrtry_pstate_w2[6-1:0]),
4484
           .in1  (wsr_data_pstate_w2[6-1:0]),
4485
           .in2  (ntrap_pstate1[6-1:0]),
4486
       .sel0 (tlu_pstate_din_sel1[0]),
4487
           .sel1 (tlu_pstate_wsr_sel1),
4488
           .sel2 (tlu_pstate_nt_sel1),
4489
       .dout (restore_pstate1[6-1:0])
4490
);
4491
 
4492
 
4493
dffe #(6-1) dff_restore_pstate1_w3 (
4494
    .din ({restore_pstate1[5:3-1],
4495
           restore_pstate1[0]}),
4496
    .q   ({restore_pstate1_w3[5:3-1],
4497
           restore_pstate1_w3[0]}),
4498
    .en (~(tlu_update_pstate_l_w2[1])), .clk(clk),
4499
    .se  (se),
4500
    .si  (),
4501
    .so  ()
4502
);
4503
 
4504
 
4505
 
4506
 
4507
 
4508
 
4509
 
4510
 
4511
 
4512
 
4513
 
4514
 
4515
//
4516
dffe dffe_pstate1_priv (
4517
    .din (restore_pstate1[1]),
4518
    .q   (restore_pstate1_w3[1]),
4519
    .en  (pstate_priv_update_w2[1]),
4520
    .clk (clk),
4521
    .se  (se),
4522
    .si  (),
4523
    .so  ()
4524
);
4525
//
4526
// modified to reflect the physical implementation
4527
/*
4528
assign hpstate_dnrtry_priv_w2[1] =
4529
           (true_hpstate1[`HPSTATE_ENB])?
4530
            tsa_dnrtry_hpstate_w2[`HPSTATE_PRIV] :
4531
            dnrtry_pstate_w2[`WSR_PSTATE_VR_PRIV];
4532
*/
4533
mux2ds mx_hpstate_dnrtry_priv_w2_1 (
4534
       .in0  (tsa_dnrtry_hpstate_w2[1]),
4535
           .in1  (dnrtry_pstate_w2[1]),
4536
       .sel0 (true_hpstate1[3]),
4537
           .sel1 (~true_hpstate1[3]),
4538
       .dout (hpstate_dnrtry_priv_w2[1])
4539
);
4540
//
4541
assign dnrtry_hpstate1_w2[5-1:0] =
4542
       {tsa_dnrtry_hpstate_w2[4-1],
4543
        true_hpstate1[3],
4544
        tsa_dnrtry_hpstate_w2[2],
4545
        hpstate_dnrtry_priv_w2[1],
4546
        tsa_dnrtry_hpstate_w2[0]};
4547
//
4548
// true_pstate1 assignments
4549
assign true_pstate1[12-1:0] =
4550
           {2'b0, // tlu_select_int_global - replaced by gl register
4551
                  // tlu_select_mmu_global - replaced by gl register 
4552
            restore_pstate1_w3[5:4],
4553
            2'b0, // fixed mmodel - TSO
4554
            1'b0, // redmode - replaced by hpstate.red
4555
            restore_pstate1_w3[3:0],
4556
            1'b0}; // tlu_select_alt_global - replaced by gl register 
4557
//
4558
// modified for timing
4559
/*
4560
mux3ds #(9) mux_restore_pstate1(
4561
       .in0  (dnrtry_pstate[`PSTATE_TRUE_WIDTH-3:1]),
4562
           .in1  (wsr_data_pstate_g[`PSTATE_TRUE_WIDTH-3:1]),
4563
           .in2  (ntrap_pstate1[`PSTATE_TRUE_WIDTH-3:1]),
4564
       .sel0 (tlu_pstate_din_sel1[0]),
4565
       // modified for bug 2584
4566
           // .sel1 (tlu_pstate_din_sel1[1]),
4567
           .sel1 (tlu_pstate_wsr_sel1),
4568
           .sel2 (tlu_pstate_nt_sel1),
4569
       .dout (restore_pstate1[`PSTATE_TRUE_WIDTH-3:1])
4570
);
4571
 
4572
`ifdef FPGA_SYN_CLK_DFF
4573
dffe #(`PSTATE_TRUE_WIDTH) pstate1_1 (
4574
    .din (restore_pstate1[`PSTATE_TRUE_WIDTH-1:0]),
4575
        .q   (true_pstate1[`PSTATE_TRUE_WIDTH-1:0]),
4576
    .en (~(tlu_update_pstate_l_w2[1])), .clk(clk),
4577
    .se  (se),
4578
    .si  (),
4579
    .so  ()
4580
    );
4581
`else
4582
dff #(`PSTATE_TRUE_WIDTH) pstate1_1 (
4583
    .din (restore_pstate1[`PSTATE_TRUE_WIDTH-1:0]),
4584
        .q   (true_pstate1[`PSTATE_TRUE_WIDTH-1:0]),
4585
    .clk (pstate1_clk),
4586
    .se  (se),
4587
    .si  (),
4588
    .so  ()
4589
    );
4590
`endif
4591
//
4592
`ifdef FPGA_SYN_CLK_DFF
4593
dffe #(`PSTATE_TRUE_WIDTH-1) dff_true_pstate1 (
4594
    .din ({restore_pstate1[`PSTATE_TRUE_WIDTH-1:3],
4595
           restore_pstate1[1:0]}),
4596
    .q   ({true_pstate1[`PSTATE_TRUE_WIDTH-1:3],
4597
           true_pstate1[1:0]}),
4598
    .en (~(tlu_update_pstate_l_w2[1])), .clk(clk),
4599
    .se  (se),
4600
    .si  (),
4601
    .so  ()
4602
);
4603
`else
4604
dff #(`PSTATE_TRUE_WIDTH-1) dff_true_pstate1 (
4605
    .din ({restore_pstate1[`PSTATE_TRUE_WIDTH-1:3],
4606
           restore_pstate1[1:0]}),
4607
    .q   ({true_pstate1[`PSTATE_TRUE_WIDTH-1:3],
4608
           true_pstate1[1:0]}),
4609
    .clk (pstate1_clk),
4610
    .se  (se),
4611
    .si  (),
4612
    .so  ()
4613
);
4614
`endif
4615
//
4616
dffe dffe_pstate1_priv (
4617
    .din (restore_pstate1[`PSTATE_PRIV]),
4618
    .q   (true_pstate1[`PSTATE_PRIV]),
4619
    .en  (pstate_priv_update_g[1]),
4620
    .clk (clk),
4621
    .se  (se),
4622
    .si  (),
4623
    .so  ()
4624
);
4625
//
4626
// modified for hypervisor support
4627
assign restore_pstate1[11:10] = 2'b0;
4628
assign restore_pstate1[0]     = 1'b0;
4629
*/
4630
//
4631
// constructing the hpstate for hyper-privileged traps 
4632
//
4633
assign hntrap_hpstate1_w2[5-1:0] =
4634
       {hpstate_ibe_set[1],
4635
        hpstate_enb_set[1],
4636
        hpstate_redmode,  // Redmode bit
4637
        hpstate_priv_set, // hyper-privileged bit
4638
        hpstate_tlz_set[1]}; // TLZ interrupt bit 
4639
//
4640
assign tlu_hpstate_hnt_sel1 =
4641
       ~(tlu_hpstate_din_sel1[0] | tlu_hpstate_wsr_sel1);
4642
//
4643
assign tlu_hpstate_wsr_sel1 =
4644
           tlu_hpstate_din_sel1[1] |
4645
           (~true_hpstate1[3] & tlu_pstate_din_sel1[1]);
4646
 
4647
mux3ds #(5) mux_restore_hpstate1 (
4648
       .in0  (dnrtry_hpstate1_w2[5-1:0]),
4649
           .in1  (wsr_data_hpstate_w2[5-1:0]),
4650
           .in2  (hntrap_hpstate1_w2[5-1:0]),
4651
       .sel0 (tlu_hpstate_din_sel1[0]),
4652
       .sel1 (tlu_hpstate_wsr_sel1),
4653
           .sel2 (tlu_hpstate_hnt_sel1),
4654
       .dout (restore_hpstate1[5-1:0])
4655
);
4656
 
4657
// need to initialize hpstate.enb = 0
4658
// need to initialize hpstate.ibe = 0
4659
// modified due to the addition of hpstate.ibe
4660
 
4661
dffre #(2) dffr_true_hpst1_enb_ibe (
4662
    .din (restore_hpstate1[5-1:5-2]),
4663
        .q   (true_hpstate1[5-1:5-2]),
4664
    .rst (local_rst),
4665
    .en (~(tlu_update_hpstate_l_w2[1])), .clk(clk),
4666
    .se  (se),
4667
    .si  (),
4668
    .so  ()
4669
);
4670
 
4671
 
4672
 
4673
 
4674
 
4675
 
4676
 
4677
 
4678
 
4679
 
4680
 
4681
//
4682
 
4683
dffe #(2) dff_true_hpstate1 (
4684
    .din ({restore_hpstate1[2],
4685
           restore_hpstate1[0]}),
4686
    .q   ({true_hpstate1[2],
4687
           true_hpstate1[0]}),
4688
    .en (~(tlu_update_hpstate_l_w2[1])), .clk(clk),
4689
    .se  (se),
4690
    .si  (),
4691
    .so  ()
4692
);
4693
 
4694
 
4695
 
4696
 
4697
 
4698
 
4699
 
4700
 
4701
 
4702
 
4703
 
4704
 
4705
//
4706
dffe dffe_hpstate1_priv (
4707
    .din (restore_hpstate1[1]),
4708
    .q   (true_hpstate1[1]),
4709
    .en  (hpstate_priv_update_w2[1]),
4710
    .clk (clk),
4711
    .se  (se),
4712
    .si  (),
4713
    .so  ()
4714
);
4715
 
4716
assign tlu_ifu_pstate_pef[1]   = true_pstate1[4];
4717
assign tlu_lsu_pstate_cle[1]   = true_pstate1[9];
4718
assign tlu_lsu_pstate_priv[1]  = true_pstate1[2];
4719
assign tlu_int_pstate_ie[1]    = true_pstate1[1];
4720
assign local_pstate_ie[1]      = true_pstate1[1];
4721
// assign tlu_pstate_cle[1]        = true_pstate1[`PSTATE_CLE];
4722
assign tlu_pstate_tle[1]           = true_pstate1[8];
4723
// assign tlu_pstate_priv[1]       = true_pstate1[`PSTATE_PRIV];
4724
assign local_pstate_priv[1]    = true_pstate1[2];
4725
assign tlu_pstate_am[1]            = true_pstate1[3];
4726
// assign tlu_pstate1_mmodel[1:0] = true_pstate1[`PSTATE_MM_HI:`PSTATE_MM_LO];
4727
//
4728
assign tlu_int_redmode[1] = true_hpstate1[2];
4729
assign tlu_lsu_redmode[1] = true_hpstate1[2];
4730
// 
4731
// hypervisor privilege indicator
4732
assign tlu_hpstate_priv[1]   = true_hpstate1[1];
4733
assign local_hpstate_priv[1] = true_hpstate1[1];
4734
assign tcl_hpstate_priv[1]   = true_hpstate1[1];
4735
//
4736
// hypervisor lite mode selector
4737
assign tlu_hpstate_enb[1]   = true_hpstate1[3];
4738
assign local_hpstate_enb[1] = true_hpstate1[3];
4739
assign tcl_hpstate_enb[1]   = true_hpstate1[3];
4740
 
4741
// hypervisor tlz indicator
4742
assign tlu_hpstate_tlz[1] = true_hpstate1[0];
4743
 
4744
// hypervisor instruction breakpt enable 
4745
assign tlu_hpstate_ibe[1] = true_hpstate1[4];
4746
 
4747
// THREAD2
4748
// added for bug 1575
4749
// modified for bug 2584
4750
// assign tlu_pstate_nt_sel2 = ~|(tlu_pstate_din_sel2[1:0]);
4751
assign tlu_pstate_nt_sel2 =
4752
          ~(tlu_pstate_din_sel2[0] | tlu_pstate_wsr_sel2);
4753
// 
4754
// modified for bug 3349
4755
assign tlu_pstate_wsr_sel2 =
4756
           tlu_pstate_din_sel2[1] |
4757
           (~(true_hpstate2[3] & wsr_data_w2[11]) &
4758
              tlu_hpstate_din_sel2[1]);
4759
//            (~true_hpstate2[`HPSTATE_ENB] & tlu_hpstate_din_sel2[1]);
4760
 
4761
mux3ds #(6) mux_restore_pstate2(
4762
       .in0  (dnrtry_pstate_w2[6-1:0]),
4763
           .in1  (wsr_data_pstate_w2[6-1:0]),
4764
           .in2  (ntrap_pstate2[6-1:0]),
4765
       .sel0 (tlu_pstate_din_sel2[0]),
4766
           .sel1 (tlu_pstate_wsr_sel2),
4767
           .sel2 (tlu_pstate_nt_sel2),
4768
       .dout (restore_pstate2[6-1:0])
4769
);
4770
 
4771
 
4772
dffe #(6-1) dff_restore_pstate2_w3 (
4773
    .din ({restore_pstate2[5:3-1],
4774
           restore_pstate2[0]}),
4775
    .q   ({restore_pstate2_w3[5:3-1],
4776
           restore_pstate2_w3[0]}),
4777
    .en (~(tlu_update_pstate_l_w2[2])), .clk(clk),
4778
    .se  (se),
4779
    .si  (),
4780
    .so  ()
4781
);
4782
 
4783
 
4784
 
4785
 
4786
 
4787
 
4788
 
4789
 
4790
 
4791
 
4792
 
4793
 
4794
//
4795
dffe dffe_pstate2_priv (
4796
    .din (restore_pstate2[1]),
4797
    .q   (restore_pstate2_w3[1]),
4798
    .en  (pstate_priv_update_w2[2]),
4799
    .clk (clk),
4800
    .se  (se),
4801
    .si  (),
4802
    .so  ()
4803
);
4804
//
4805
// true_pstate2 assignments
4806
assign true_pstate2[12-1:0] =
4807
           {2'b0, // tlu_select_int_global - replaced by gl register
4808
                  // tlu_select_mmu_global - replaced by gl register 
4809
            restore_pstate2_w3[5:4],
4810
            2'b0, // fixed mmodel - TSO
4811
            1'b0, // redmode - replaced by hpstate.red
4812
            restore_pstate2_w3[3:0],
4813
            1'b0}; // tlu_select_alt_global - replaced by gl register 
4814
//
4815
// modified for timing
4816
/*
4817
mux3ds #(9) mux_restore_pstate2(
4818
       .in0  (dnrtry_pstate[`PSTATE_TRUE_WIDTH-3:1]),
4819
           .in1  (wsr_data_pstate_g[`PSTATE_TRUE_WIDTH-3:1]),
4820
           .in2  (ntrap_pstate2[`PSTATE_TRUE_WIDTH-3:1]),
4821
       .sel0 (tlu_pstate_din_sel2[0]),
4822
       // modified for bug 2584
4823
           // .sel1 (tlu_pstate_din_sel2[1]),
4824
           .sel1 (tlu_pstate_wsr_sel2),
4825
           .sel2 (tlu_pstate_nt_sel2),
4826
       .dout (restore_pstate2[`PSTATE_TRUE_WIDTH-3:1])
4827
);
4828
 
4829
`ifdef FPGA_SYN_CLK_DFF
4830
dffe #(`PSTATE_TRUE_WIDTH) pstate2_1 (
4831
    .din (restore_pstate2[`PSTATE_TRUE_WIDTH-1:0]),
4832
        .q   (true_pstate2[`PSTATE_TRUE_WIDTH-1:0]),
4833
    .en (~(tlu_update_pstate_l_w2[2])), .clk(clk),
4834
    .se  (se),
4835
    .si  (),
4836
    .so  ()
4837
);
4838
`else
4839
dff #(`PSTATE_TRUE_WIDTH) pstate2_1 (
4840
    .din (restore_pstate2[`PSTATE_TRUE_WIDTH-1:0]),
4841
        .q   (true_pstate2[`PSTATE_TRUE_WIDTH-1:0]),
4842
    .clk (pstate2_clk),
4843
    .se  (se),
4844
    .si  (),
4845
    .so  ()
4846
);
4847
`endif
4848
//
4849
`ifdef FPGA_SYN_CLK_DFF
4850
dffe #(`PSTATE_TRUE_WIDTH-1) dff_true_pstate2 (
4851
    .din ({restore_pstate2[`PSTATE_TRUE_WIDTH-1:3],
4852
           restore_pstate2[1:0]}),
4853
    .q   ({true_pstate2[`PSTATE_TRUE_WIDTH-1:3],
4854
           true_pstate2[1:0]}),
4855
    .en (~(tlu_update_pstate_l_w2[2])), .clk(clk),
4856
    .se  (se),
4857
    .si  (),
4858
    .so  ()
4859
);
4860
`else
4861
dff #(`PSTATE_TRUE_WIDTH-1) dff_true_pstate2 (
4862
    .din ({restore_pstate2[`PSTATE_TRUE_WIDTH-1:3],
4863
           restore_pstate2[1:0]}),
4864
    .q   ({true_pstate2[`PSTATE_TRUE_WIDTH-1:3],
4865
           true_pstate2[1:0]}),
4866
    .clk (pstate2_clk),
4867
    .se  (se),
4868
    .si  (),
4869
    .so  ()
4870
);
4871
`endif
4872
//
4873
dffe dffe_pstate2_priv (
4874
    .din (restore_pstate2[`PSTATE_PRIV]),
4875
    .q   (true_pstate2[`PSTATE_PRIV]),
4876
    .en  (pstate_priv_update_g[2]),
4877
    .clk (clk),
4878
    .se  (se),
4879
    .si  (),
4880
    .so  ()
4881
);
4882
//
4883
// modified for hypervisor support
4884
assign restore_pstate2[11:10] = 2'b0;
4885
assign restore_pstate2[0]     = 1'b0;
4886
// modified to reflect the physical implementation
4887
// restructing the hpstate for done/retry instructions
4888
//
4889
assign hpstate_dnrtry_priv_w2[2] =
4890
           (true_hpstate2[`HPSTATE_ENB])?
4891
            tsa_dnrtry_hpstate_w2[`HPSTATE_PRIV] :
4892
            dnrtry_pstate_w2[`WSR_PSTATE_VR_PRIV];
4893
*/
4894
mux2ds mx_hpstate_dnrtry_priv_w2_2 (
4895
       .in0  (tsa_dnrtry_hpstate_w2[1]),
4896
           .in1  (dnrtry_pstate_w2[1]),
4897
       .sel0 (true_hpstate2[3]),
4898
           .sel1 (~true_hpstate2[3]),
4899
       .dout (hpstate_dnrtry_priv_w2[2])
4900
);
4901
//
4902
assign dnrtry_hpstate2_w2[5-1:0] =
4903
       {tsa_dnrtry_hpstate_w2[4-1],
4904
        true_hpstate2[3],
4905
        tsa_dnrtry_hpstate_w2[2],
4906
        hpstate_dnrtry_priv_w2[2],
4907
        tsa_dnrtry_hpstate_w2[0]};
4908
//
4909
// constructing the hpstate for hyper-privileged traps 
4910
//
4911
assign hntrap_hpstate2_w2[5-1:0] =
4912
       {hpstate_ibe_set[2],
4913
        hpstate_enb_set[2],
4914
        hpstate_redmode,  // Redmode bit
4915
        hpstate_priv_set, // hyper-privileged bit
4916
        hpstate_tlz_set[2]}; // TLZ interrupt bit 
4917
//
4918
assign tlu_hpstate_hnt_sel2 =
4919
       ~(tlu_hpstate_din_sel2[0] | tlu_hpstate_wsr_sel2);
4920
//
4921
assign tlu_hpstate_wsr_sel2 =
4922
           tlu_hpstate_din_sel2[1] |
4923
           (~true_hpstate2[3] & tlu_pstate_din_sel2[1]);
4924
 
4925
mux3ds #(5) mux_restore_hpstate2 (
4926
       .in0  (dnrtry_hpstate2_w2[5-1:0]),
4927
           .in1  (wsr_data_hpstate_w2[5-1:0]),
4928
           .in2  (hntrap_hpstate2_w2[5-1:0]),
4929
       .sel0 (tlu_hpstate_din_sel2[0]),
4930
           .sel1 (tlu_hpstate_wsr_sel2),
4931
           .sel2 (tlu_hpstate_hnt_sel2),
4932
       .dout (restore_hpstate2[5-1:0])
4933
);
4934
//
4935
// need to initialize hpstate.enb = 0
4936
// need to initialize hpstate.ibe = 0
4937
// modified due to the addition of hpstate.ibe
4938
 
4939
dffre #(2) dffr_true_hpst2_enb_ibe (
4940
    .din (restore_hpstate2[5-1:5-2]),
4941
        .q   (true_hpstate2[5-1:5-2]),
4942
    .rst (local_rst),
4943
    .en (~(tlu_update_hpstate_l_w2[2])), .clk(clk),
4944
    .se  (se),
4945
    .si  (),
4946
    .so  ()
4947
);
4948
 
4949
 
4950
 
4951
 
4952
 
4953
 
4954
 
4955
 
4956
 
4957
 
4958
 
4959
//
4960
 
4961
dffe #(2) dff_true_hpstate2 (
4962
    .din ({restore_hpstate2[2],
4963
           restore_hpstate2[0]}),
4964
    .q   ({true_hpstate2[2],
4965
           true_hpstate2[0]}),
4966
    .en (~(tlu_update_hpstate_l_w2[2])), .clk(clk),
4967
    .se  (se),
4968
    .si  (),
4969
    .so  ()
4970
);
4971
 
4972
 
4973
 
4974
 
4975
 
4976
 
4977
 
4978
 
4979
 
4980
 
4981
 
4982
 
4983
//
4984
dffe dffe_hpstate2_priv (
4985
    .din (restore_hpstate2[1]),
4986
    .q   (true_hpstate2[1]),
4987
    .en  (hpstate_priv_update_w2[2]),
4988
    .clk (clk),
4989
    .se  (se),
4990
    .si  (),
4991
    .so  ()
4992
);
4993
 
4994
assign tlu_ifu_pstate_pef[2]   = true_pstate2[4];
4995
assign tlu_lsu_pstate_cle[2]   = true_pstate2[9];
4996
assign tlu_lsu_pstate_priv[2]  = true_pstate2[2];
4997
assign tlu_int_pstate_ie[2]    = true_pstate2[1];
4998
assign local_pstate_ie[2]      = true_pstate2[1];
4999
// assign tlu_pstate_cle[2]        = true_pstate2[`PSTATE_CLE];
5000
assign tlu_pstate_tle[2]           = true_pstate2[8];
5001
// assign tlu_pstate_priv[2]       = true_pstate2[`PSTATE_PRIV];
5002
assign local_pstate_priv[2]    = true_pstate2[2];
5003
assign tlu_pstate_am[2]            = true_pstate2[3];
5004
// assign tlu_pstate2_mmodel[1:0] = true_pstate2[`PSTATE_MM_HI:`PSTATE_MM_LO];
5005
//
5006
// modified for hypervisor support
5007
// assign       tlu_int_redmode[2]      = true_pstate2[`PSTATE_RED];
5008
assign tlu_int_redmode[2] = true_hpstate2[2];
5009
assign tlu_lsu_redmode[2] = true_hpstate2[2];
5010
// 
5011
// hypervisor privilege indicator
5012
assign tlu_hpstate_priv[2]   = true_hpstate2[1];
5013
assign local_hpstate_priv[2] = true_hpstate2[1];
5014
assign tcl_hpstate_priv[2]   = true_hpstate2[1];
5015
//
5016
// hypervisor lite mode selector
5017
assign tlu_hpstate_enb[2]   = true_hpstate2[3];
5018
assign local_hpstate_enb[2] = true_hpstate2[3];
5019
assign tcl_hpstate_enb[2]   = true_hpstate2[3];
5020
 
5021
// hypervisor tlz indicator
5022
assign tlu_hpstate_tlz[2] = true_hpstate2[0];
5023
 
5024
// hypervisor instruction breakpt enable 
5025
assign tlu_hpstate_ibe[2] = true_hpstate2[4];
5026
 
5027
// THREAD3
5028
// added for bug 1575
5029
// modified for bug 2584
5030
// assign tlu_pstate_nt_sel3 = ~|(tlu_pstate_din_sel3[1:0]);
5031
assign tlu_pstate_nt_sel3 =
5032
          ~(tlu_pstate_din_sel3[0] | tlu_pstate_wsr_sel3);
5033
//
5034
// modified for bug 3349
5035
assign tlu_pstate_wsr_sel3 =
5036
           tlu_pstate_din_sel3[1] |
5037
           (~(true_hpstate3[3] & wsr_data_w2[11]) &
5038
              tlu_hpstate_din_sel3[1]);
5039
//            (~true_hpstate3[`HPSTATE_ENB] & tlu_hpstate_din_sel3[1]);
5040
//
5041
mux3ds #(6) mux_restore_pstate3(
5042
       .in0  (dnrtry_pstate_w2[6-1:0]),
5043
           .in1  (wsr_data_pstate_w2[6-1:0]),
5044
           .in2  (ntrap_pstate3[6-1:0]),
5045
       .sel0 (tlu_pstate_din_sel3[0]),
5046
           .sel1 (tlu_pstate_wsr_sel3),
5047
           .sel2 (tlu_pstate_nt_sel3),
5048
       .dout (restore_pstate3[6-1:0])
5049
);
5050
 
5051
 
5052
dffe #(6-1) dff_restore_pstate3_w3 (
5053
    .din ({restore_pstate3[5:3-1],
5054
           restore_pstate3[0]}),
5055
    .q   ({restore_pstate3_w3[5:3-1],
5056
           restore_pstate3_w3[0]}),
5057
    .en (~(tlu_update_pstate_l_w2[3])), .clk(clk),
5058
    .se  (se),
5059
    .si  (),
5060
    .so  ()
5061
);
5062
 
5063
 
5064
 
5065
 
5066
 
5067
 
5068
 
5069
 
5070
 
5071
 
5072
 
5073
 
5074
//
5075
dffe dffe_pstate3_priv (
5076
    .din (restore_pstate3[1]),
5077
    .q   (restore_pstate3_w3[1]),
5078
    .en  (pstate_priv_update_w2[3]),
5079
    .clk (clk),
5080
    .se  (se),
5081
    .si  (),
5082
    .so  ()
5083
);
5084
//
5085
// true_pstate3 assignments
5086
assign true_pstate3[12-1:0] =
5087
           {2'b0, // tlu_select_int_global - replaced by gl register
5088
                  // tlu_select_mmu_global - replaced by gl register 
5089
            restore_pstate3_w3[5:4],
5090
            2'b0, // fixed mmodel - TSO
5091
            1'b0, // redmode - replaced by hpstate.red
5092
            restore_pstate3_w3[3:0],
5093
            1'b0}; // tlu_select_alt_global - replaced by gl register 
5094
//
5095
// modified for timing
5096
/*
5097
mux3ds #(9) mux_restore_pstate3(
5098
       .in0  (dnrtry_pstate[`PSTATE_TRUE_WIDTH-3:1]),
5099
           .in1  (wsr_data_pstate_g[`PSTATE_TRUE_WIDTH-3:1]),
5100
           .in2  (ntrap_pstate3[`PSTATE_TRUE_WIDTH-3:1]),
5101
       .sel0 (tlu_pstate_din_sel3[0]),
5102
       // modified for bug 2584
5103
           // .sel1 (tlu_pstate_din_sel3[1]),
5104
           .sel1 (tlu_pstate_wsr_sel3),
5105
           .sel2 (tlu_pstate_nt_sel3),
5106
       .dout (restore_pstate3[`PSTATE_TRUE_WIDTH-3:1])
5107
);
5108
//
5109
`ifdef FPGA_SYN_CLK_DFF
5110
dffe #(`PSTATE_TRUE_WIDTH) pstate3_1 (
5111
    .din (restore_pstate3[`PSTATE_TRUE_WIDTH-1:0]),
5112
        .q   (true_pstate3[`PSTATE_TRUE_WIDTH-1:0]),
5113
    .en (~(tlu_update_pstate_l_w2[3])), .clk(clk),
5114
    .se  (se),
5115
    .si  (),
5116
    .so  ()
5117
);
5118
`else
5119
dff #(`PSTATE_TRUE_WIDTH) pstate3_1 (
5120
    .din (restore_pstate3[`PSTATE_TRUE_WIDTH-1:0]),
5121
        .q   (true_pstate3[`PSTATE_TRUE_WIDTH-1:0]),
5122
    .clk (pstate3_clk),
5123
    .se  (se),
5124
    .si  (),
5125
    .so  ()
5126
);
5127
`endif
5128
//
5129
`ifdef FPGA_SYN_CLK_DFF
5130
dffe #(`PSTATE_TRUE_WIDTH-1) pstate3_1 (
5131
    .din ({restore_pstate3[`PSTATE_TRUE_WIDTH-1:3],
5132
           restore_pstate3[1:0]}),
5133
    .q   ({true_pstate3[`PSTATE_TRUE_WIDTH-1:3],
5134
           true_pstate3[1:0]}),
5135
    .en (~(tlu_update_pstate_l_w2[3])), .clk(clk),
5136
    .se  (se),
5137
    .si  (),
5138
    .so  ()
5139
);
5140
`else
5141
dff #(`PSTATE_TRUE_WIDTH-1) pstate3_1 (
5142
    .din ({restore_pstate3[`PSTATE_TRUE_WIDTH-1:3],
5143
           restore_pstate3[1:0]}),
5144
    .q   ({true_pstate3[`PSTATE_TRUE_WIDTH-1:3],
5145
           true_pstate3[1:0]}),
5146
    .clk (pstate3_clk),
5147
    .se  (se),
5148
    .si  (),
5149
    .so  ()
5150
);
5151
`endif
5152
//
5153
dffe dffe_pstate3_priv (
5154
    .din (restore_pstate3[`PSTATE_PRIV]),
5155
    .q   (true_pstate3[`PSTATE_PRIV]),
5156
    .en  (pstate_priv_update_g[3]),
5157
    .clk (clk),
5158
    .se  (se),
5159
    .si  (),
5160
    .so  ()
5161
);
5162
//
5163
// modified for hypervisor support
5164
assign restore_pstate3[11:10] = 2'b0;
5165
assign restore_pstate3[0]     = 1'b0;
5166
//
5167
// modified to reflect the physical implementation
5168
assign hpstate_dnrtry_priv_w2[3] =
5169
           (true_hpstate3[`HPSTATE_ENB])?
5170
            tsa_dnrtry_hpstate_w2[`HPSTATE_PRIV] :
5171
            dnrtry_pstate_w2[`WSR_PSTATE_VR_PRIV];
5172
*/
5173
mux2ds mx_hpstate_dnrtry_priv_w2_3 (
5174
       .in0  (tsa_dnrtry_hpstate_w2[1]),
5175
           .in1  (dnrtry_pstate_w2[1]),
5176
       .sel0 (true_hpstate3[3]),
5177
           .sel1 (~true_hpstate3[3]),
5178
       .dout (hpstate_dnrtry_priv_w2[3])
5179
);
5180
//
5181
assign dnrtry_hpstate3_w2[5-1:0] =
5182
       {tsa_dnrtry_hpstate_w2[4-1],
5183
        true_hpstate3[3],
5184
        tsa_dnrtry_hpstate_w2[2],
5185
        hpstate_dnrtry_priv_w2[3],
5186
        tsa_dnrtry_hpstate_w2[0]};
5187
//
5188
// constructing the hpstate for hyper-privileged traps 
5189
//
5190
assign hntrap_hpstate3_w2[5-1:0] =
5191
       {hpstate_ibe_set[3],
5192
        hpstate_enb_set[3],
5193
        hpstate_redmode,  // Redmode bit
5194
        hpstate_priv_set, // hyper-privileged bit
5195
        hpstate_tlz_set[3]}; // TLZ interrupt bit 
5196
 
5197
assign tlu_hpstate_hnt_sel3 =
5198
       ~(tlu_hpstate_din_sel3[0] | tlu_hpstate_wsr_sel3);
5199
//
5200
assign tlu_hpstate_wsr_sel3 =
5201
           tlu_hpstate_din_sel3[1] |
5202
           (~true_hpstate3[3] & tlu_pstate_din_sel3[1]);
5203
 
5204
mux3ds #(5) mux_restore_hpstate3 (
5205
       .in0  (dnrtry_hpstate3_w2[5-1:0]),
5206
           .in1  (wsr_data_hpstate_w2[5-1:0]),
5207
           .in2  (hntrap_hpstate3_w2[5-1:0]),
5208
       .sel0 (tlu_hpstate_din_sel3[0]),
5209
           .sel1 (tlu_hpstate_wsr_sel3),
5210
           .sel2 (tlu_hpstate_hnt_sel3),
5211
       .dout (restore_hpstate3[5-1:0])
5212
);
5213
//
5214
// need to initialize hpstate.enb = 0
5215
// need to initialize hpstate.ibe = 0
5216
// modified due to the addition of hpstate.ibe
5217
 
5218
dffre #(2) dffr_true_hpst3_enb_ibe (
5219
    .din (restore_hpstate3[5-1:5-2]),
5220
        .q   (true_hpstate3[5-1:5-2]),
5221
    .rst (local_rst),
5222
    .en (~(tlu_update_hpstate_l_w2[3])), .clk(clk),
5223
    .se  (se),
5224
    .si  (),
5225
    .so  ()
5226
);
5227
 
5228
 
5229
 
5230
 
5231
 
5232
 
5233
 
5234
 
5235
 
5236
 
5237
 
5238
//
5239
//
5240
 
5241
dffe #(2) dff_true_hpstate3 (
5242
    .din ({restore_hpstate3[2],
5243
           restore_hpstate3[0]}),
5244
    .q   ({true_hpstate3[2],
5245
           true_hpstate3[0]}),
5246
    .en (~(tlu_update_hpstate_l_w2[3])), .clk(clk),
5247
    .se  (se),
5248
    .si  (),
5249
    .so  ()
5250
);
5251
 
5252
 
5253
 
5254
 
5255
 
5256
 
5257
 
5258
 
5259
 
5260
 
5261
 
5262
 
5263
//
5264
dffe dffe_hpstate3_priv (
5265
    .din (restore_hpstate3[1]),
5266
    .q   (true_hpstate3[1]),
5267
    .en  (hpstate_priv_update_w2[3]),
5268
    .clk (clk),
5269
    .se  (se),
5270
    .si  (),
5271
    .so  ()
5272
);
5273
 
5274
assign tlu_ifu_pstate_pef[3]   = true_pstate3[4];
5275
assign tlu_lsu_pstate_cle[3]   = true_pstate3[9];
5276
assign tlu_lsu_pstate_priv[3]  = true_pstate3[2];
5277
assign tlu_int_pstate_ie[3]    = true_pstate3[1];
5278
assign local_pstate_ie[3]      = true_pstate3[1];
5279
// assign tlu_pstate_cle[3]        = true_pstate3[`PSTATE_CLE];
5280
assign tlu_pstate_tle[3]           = true_pstate3[8];
5281
// assign tlu_pstate_priv[3]       = true_pstate3[`PSTATE_PRIV];
5282
assign local_pstate_priv[3]    = true_pstate3[2];
5283
assign tlu_pstate_am[3]            = true_pstate3[3];
5284
// assign tlu_pstate3_mmodel[1:0] = true_pstate3[`PSTATE_MM_HI:`PSTATE_MM_LO];
5285
//
5286
// modified for hypervisor support
5287
// assign       tlu_int_redmode[3]      = true_pstate3[`PSTATE_RED];
5288
assign tlu_int_redmode[3] = true_hpstate3[2];
5289
assign tlu_lsu_redmode[3] = true_hpstate3[2];
5290
// 
5291
// hypervisor privilege indicator
5292
assign tlu_hpstate_priv[3]   = true_hpstate3[1];
5293
assign local_hpstate_priv[3] = true_hpstate3[1];
5294
assign tcl_hpstate_priv[3]   = true_hpstate3[1];
5295
//
5296
// hypervisor lite mode selector
5297
assign tlu_hpstate_enb[3]   = true_hpstate3[3];
5298
assign local_hpstate_enb[3] = true_hpstate3[3];
5299
assign tcl_hpstate_enb[3]   = true_hpstate3[3];
5300
 
5301
// hypervisor tlz indicator
5302
assign tlu_hpstate_tlz[3] = true_hpstate3[0];
5303
 
5304
// hypervisor instruction breakpt enable 
5305
assign tlu_hpstate_ibe[3] = true_hpstate3[4];
5306
 
5307
 // !`ifdef FPGA_SYN_1THREAD
5308
 
5309
// Mux to choose the pstate register to read base on thread
5310
wire [12-1:0] pstate_rdata;
5311
wire [12-1:0] hpstate_rdata;
5312
 
5313
 
5314
 
5315
 
5316
 
5317
 
5318
mux4ds #(12) pstate_mx_sel (
5319
       .in0  (true_pstate0[12-1:0]),
5320
       .in1  (true_pstate1[12-1:0]),
5321
       .in2  (true_pstate2[12-1:0]),
5322
       .in3  (true_pstate3[12-1:0]),
5323
       .sel0 (tlu_thrd_rsel_e[0]),
5324
       .sel1 (tlu_thrd_rsel_e[1]),
5325
       .sel2 (tlu_thrd_rsel_e[2]),
5326
       .sel3 (tlu_thrd_rsel_e[3]),
5327
       .dout (pstate_rdata[12-1:0])
5328
);
5329
//
5330
// added for hypervisor support 
5331
// mux to choose the pstate register to read base on thread
5332
 
5333
mux4ds #(5) hpstate_mx_sel (
5334
       .in0  (true_hpstate0[5-1:0]),
5335
       .in1  (true_hpstate1[5-1:0]),
5336
       .in2  (true_hpstate2[5-1:0]),
5337
       .in3  (true_hpstate3[5-1:0]),
5338
       .sel0 (tlu_thrd_rsel_e[0]),
5339
       .sel1 (tlu_thrd_rsel_e[1]),
5340
       .sel2 (tlu_thrd_rsel_e[2]),
5341
       .sel3 (tlu_thrd_rsel_e[3]),
5342
       .dout (true_hpstate[5-1:0])
5343
);
5344
 // !`ifdef FPGA_SYN_1THREAD
5345
 
5346
// 
5347
// assigned the stored hpstate bits to the ASR positions
5348
//
5349
assign hpstate_rdata[11]  = true_hpstate[3];
5350
assign hpstate_rdata[10]  = true_hpstate[4];
5351
assign hpstate_rdata[5]  = true_hpstate[2];
5352
assign hpstate_rdata[2] = true_hpstate[1];
5353
assign hpstate_rdata[0]  = true_hpstate[0];
5354
//
5355
// grounding the reserved bits
5356
// modified due to the addition of hpstate.ibe 
5357
// assign hpstate_rdata[`WSR_HPSTATE_ENB-1 :`WSR_HPSTATE_RED+1]  = 5'h00; 
5358
assign hpstate_rdata[10-1 :5+1]  = 4'h0;
5359
assign hpstate_rdata[5-1 :2+1] = 2'b00;
5360
assign hpstate_rdata[2-1:0+1]  = 1'b0;
5361
//
5362
// constructing data for htstate
5363
//
5364
wire [12-1:0] htstate_rdata;
5365
 
5366
// assign htstate_rdata[`WSR_HPSTATE_RED]  = tsa_rdata[`TLU_HTSTATE_HI]; 
5367
// assign htstate_rdata[`WSR_HPSTATE_PRIV] = tsa_rdata[`TLU_HTSTATE_HI-1]; 
5368
/* modified due to logic redistribution
5369
assign htstate_rdata[`WSR_HPSTATE_IBE]  = tsa_rdata[`TLU_HTSTATE_HI];
5370
assign htstate_rdata[`WSR_HPSTATE_RED]  = tsa_rdata[`TLU_HTSTATE_HI-1];
5371
assign htstate_rdata[`WSR_HPSTATE_PRIV] = tsa_rdata[`TLU_HTSTATE_HI-2];
5372
assign htstate_rdata[`WSR_HPSTATE_TLZ]  = tsa_rdata[`TLU_HTSTATE_LO];
5373
*/
5374
assign htstate_rdata[10]  = tsa_rdata[133];
5375
assign htstate_rdata[5]  = tsa_rdata[133-1];
5376
assign htstate_rdata[2] = tsa_rdata[133-2];
5377
assign htstate_rdata[0]  = tsa_rdata[130];
5378
//
5379
// grounding the reserved bits
5380
// modified due to addition of hpstate.ibe
5381
// assign htstate_rdata[`RDSR_HPSTATE_WIDTH-1 :`WSR_HPSTATE_RED+1] = 6'h00; 
5382
assign htstate_rdata[12-1] = 1'b0;
5383
assign htstate_rdata[10-1 :5+1]  = 4'h0;
5384
assign htstate_rdata[5-1 :2+1] = 2'b00;
5385
assign htstate_rdata[2-1:0+1]  = 1'b0;
5386
 
5387
//=========================================================================================
5388
//      RDPR - This section has been recoded due to timing
5389
//=========================================================================================
5390
 
5391
// mux data width - 2b
5392
 
5393
 
5394
 
5395
 
5396
 
5397
 
5398
mux4ds #(2) mux_global_rdata (
5399
       .in0  (tlu_gl_lvl0[2-1:0]),
5400
       .in1  (tlu_gl_lvl1[2-1:0]),
5401
       .in2  (tlu_gl_lvl2[2-1:0]),
5402
       .in3  (tlu_gl_lvl3[2-1:0]),
5403
       .sel0 (tlu_thrd_rsel_e[0]),
5404
       .sel1 (tlu_thrd_rsel_e[1]),
5405
       .sel2 (tlu_thrd_rsel_e[2]),
5406
       .sel3 (tlu_thrd_rsel_e[3]),
5407
       .dout (global_rdata[2-1:0])
5408
);
5409
// 
5410
// htickcmp interrupt enable
5411
//
5412
mux4ds #(1) mux_hintp_rdata (
5413
        .in0    (tlu_hintp[0]),
5414
        .in1    (tlu_hintp[1]),
5415
        .in2    (tlu_hintp[2]),
5416
        .in3    (tlu_hintp[3]),
5417
        .sel0   (tlu_thrd_rsel_e[0]),
5418
        .sel1   (tlu_thrd_rsel_e[1]),
5419
        .sel2   (tlu_thrd_rsel_e[2]),
5420
        .sel3   (tlu_thrd_rsel_e[3]),
5421
        .dout   (hintp_rdata)
5422
);
5423
 // !`ifdef FPGA_SYN_1THREAD
5424
 
5425
// 
5426
// tstate.gl - 2b
5427
assign tstate_rdata[41:40] =
5428
       tsa_rdata[37:36];
5429
//
5430
// tstate.ccr - 8b
5431
assign tstate_rdata[39:32] =
5432
       tsa_rdata[35:28];
5433
//
5434
// tstate.asi - 8b
5435
assign tstate_rdata[31:24] =
5436
       tsa_rdata[27:20];
5437
//
5438
// tstate.pstate(valid range 2) - 2b
5439
assign tstate_rdata[17:16] =
5440
       tsa_rdata[19:18];
5441
// 
5442
// added for to please lint 
5443
assign tstate_dummy_zero[1:0] =
5444
       tsa_rdata[18-1:15+1] & 2'b0;
5445
//
5446
// tstate.pstate(valid range 1) - 4b
5447
assign tstate_rdata[12:9] =
5448
       tsa_rdata[15:12];
5449
//
5450
// tstate.cwp - 3b
5451
assign tstate_rdata[2:0] =
5452
       tsa_rdata[11:9];
5453
//
5454
// reserved bits with ASR - assign to  1'b0
5455
assign tstate_rdata[48-1:41+1] =
5456
       6'h00;
5457
assign tstate_rdata[24-1:17+1] =
5458
       6'h00;
5459
assign tstate_rdata[16-1:12+1] =
5460
       {1'b0, tstate_dummy_zero[1:0]};
5461
assign tstate_rdata[9-1:2+1] =
5462
       6'h00;
5463
//
5464
//============================================================================
5465
// new rdpr mux coding due to timing changes 
5466
//============================================================================
5467
//
5468
// added for bug 2332
5469
assign rdpr_mx1_onehot_sel =
5470
           ~(|tlu_rdpr_mx1_sel[3:1]);
5471
// mux1- 64b
5472
mux4ds #(64) rdpr_mx1(
5473
        .in0({tlu_tick_npt,true_tick[60:0], 2'b0}),
5474
        .in1(tickcmp_rdata[64-1:0]),
5475
        .in2(stickcmp_rdata[64-1:0]),
5476
        .in3({tlu_htickcmp_intdis,htickcmp_rdata[64-2:0]}),
5477
        .sel0(rdpr_mx1_onehot_sel),
5478
        .sel1(tlu_rdpr_mx1_sel[1]),
5479
        .sel2(tlu_rdpr_mx1_sel[2]),
5480
        .sel3(tlu_rdpr_mx1_sel[3]),
5481
        .dout(tlu_rdpr_mx1_out[64-1:0])
5482
);
5483
// 
5484
//
5485
// added for bug 2332
5486
assign rdpr_mx2_onehot_sel =
5487
           ~(|tlu_rdpr_mx2_sel[3:1]);
5488
//
5489
// mux2 - 4b 
5490
mux4ds #(4) rdpr_mx2(
5491
        .in0({2'b0,global_rdata[2-1:0]}),
5492
        .in1({3'b0,hintp_rdata}),
5493
        .in2({1'b0,tlu_trp_lvl[2:0]}),
5494
        .in3(tlu_pil[3:0]),
5495
        .sel0(rdpr_mx2_onehot_sel),
5496
        .sel1(tlu_rdpr_mx2_sel[1]),
5497
        .sel2(tlu_rdpr_mx2_sel[2]),
5498
        .sel3(tlu_rdpr_mx2_sel[3]),
5499
        .dout(tlu_rdpr_mx2_out[3:0])
5500
);
5501
//
5502
// added for bug 2332
5503
assign rdpr_mx3_onehot_sel =
5504
           ~(|tlu_rdpr_mx3_sel[2:1]);
5505
//
5506
// mux3 - 17b
5507
mux3ds #(17) rdpr_mx3(
5508
        .in0(sftint_rdata[17-1:0]),
5509
        .in1({5'b0,pstate_rdata[12-1:0]}),
5510
        .in2({5'b0,hpstate_rdata[12-1:0]}),
5511
        .sel0(rdpr_mx3_onehot_sel),
5512
        .sel1(tlu_rdpr_mx3_sel[1]),
5513
        .sel2(tlu_rdpr_mx3_sel[2]),
5514
        .dout(tlu_rdpr_mx3_out[17-1:0])
5515
);
5516
//
5517
// added for bug 2332
5518
assign rdpr_mx4_onehot_sel =
5519
           ~(|tlu_rdpr_mx4_sel[2:1]);
5520
//
5521
// mux4 - 48b 
5522
mux3ds #(48) rdpr_mx4(
5523
        .in0({tsa_rdata[129:84],2'b00}),
5524
        .in1({tsa_rdata[83:38],2'b00}),
5525
        // .in0({tsa_rdata[`TLU_PC_HI-1:`TLU_PC_LO],2'b00}),
5526
        // .in1({tsa_rdata[`TLU_NPC_HI-1:`TLU_NPC_LO],2'b00}),
5527
    .in2(tstate_rdata[48-1:0]),
5528
        .sel0(rdpr_mx4_onehot_sel),
5529
        .sel1(tlu_rdpr_mx4_sel[1]),
5530
        .sel2(tlu_rdpr_mx4_sel[2]),
5531
        .dout(tlu_rdpr_mx4_out[48-1:0])
5532
);
5533
//
5534
// added for bug 2332
5535
assign rdpr_mx5_onehot_sel =
5536
           ~(|tlu_rdpr_mx5_sel[3:1]);
5537
//
5538
// mux5 - 64b 
5539
mux4ds #(64) rdpr_mx5(
5540
        .in0({{16{tba_rdata[33-1]}},
5541
           tba_rdata[33-1:0],15'h0000}),
5542
        .in1({{16{htba_rdata[34-1]}},
5543
           htba_rdata[34-1:0],14'h0000}),
5544
        .in2(tlu_rdpr_mx1_out[64-1:0]),
5545
        .in3(tlu_pib_rsr_data_e[64-1:0]),
5546
        .sel0(rdpr_mx5_onehot_sel),
5547
        .sel1(tlu_rdpr_mx5_sel[1]),
5548
        .sel2(tlu_rdpr_mx5_sel[2]),
5549
        .sel3(tlu_rdpr_mx5_sel[3]),
5550
        .dout(tlu_rdpr_mx5_out[64-1:0])
5551
);
5552
//
5553
// added for bug 2332
5554
assign rdpr_mx6_onehot_sel =
5555
           ~(|tlu_rdpr_mx6_sel[2:0]);
5556
//
5557
// mux6 - 12b 
5558
mux4ds #(17) rdpr_mx6(
5559
        .in0({8'b0,tsa_rdata[8:0]}),  // ttype
5560
        .in1({5'b0,htstate_rdata[12-1:0]}),
5561
        .in2({13'b0,tlu_rdpr_mx2_out[3:0]}),
5562
        .in3({tlu_rdpr_mx3_out[17-1:0]}),
5563
        .sel0(rdpr_mx6_onehot_sel),
5564
        .sel1(tlu_rdpr_mx6_sel[0]),
5565
        .sel2(tlu_rdpr_mx6_sel[1]),
5566
        .sel3(tlu_rdpr_mx6_sel[2]),
5567
        .dout(tlu_rdpr_mx6_out[17-1:0])
5568
);
5569
//
5570
// mux7- 64b
5571
mux4ds #(64) rdpr_mx7(
5572
        .in0({{16{tlu_rdpr_mx4_out[48-1]}},
5573
           tlu_rdpr_mx4_out[48-1:0]}),
5574
        .in1(tlu_rdpr_mx5_out[64-1:0]),
5575
        .in2({47'b0,tlu_rdpr_mx6_out[17-1:0]}),
5576
        .in3({56'b0,lsu_tlu_rsr_data_e[7:0]}),
5577
        .sel0(tlu_rdpr_mx7_sel[0]),
5578
        .sel1(tlu_rdpr_mx7_sel[1]),
5579
        .sel2(tlu_rdpr_mx7_sel[2]),
5580
        .sel3(tlu_rdpr_mx7_sel[3]),
5581
        .dout(tlu_rdpr_mx7_out[64-1:0])
5582
);
5583
/*
5584
mux4ds #(`TLU_ASR_DATA_WIDTH) rdpr_mx7(
5585
        .in0({{16{tlu_rdpr_mx4_out[`RDSR_TSTATE_WIDTH-1]}},
5586
           tlu_rdpr_mx4_out[`RDSR_TSTATE_WIDTH-1:0]}),
5587
        .in1(tlu_rdpr_mx5_out[`TLU_ASR_DATA_WIDTH-1:0]),
5588
        .in2({47'b0,tlu_rdpr_mx6_out[`SFTINT_WIDTH-1:0]}),
5589
        .in3({56'b0,lsu_tlu_rsr_data_e[7:0]}),
5590
        .sel0(tlu_rdpr_mx7_sel[0]),
5591
        .sel1(tlu_rdpr_mx7_sel[1]),
5592
        .sel2(tlu_rdpr_mx7_sel[2]),
5593
        .sel3(tlu_rdpr_mx7_sel[3]),
5594
        .dout(tlu_rdpr_mx7_out[`TLU_ASR_DATA_WIDTH-1:0])
5595
);
5596
*/
5597
//
5598
// drive rsr data to exu
5599
assign tlu_exu_rsr_data_e[64-1:0] =
5600
           tlu_rdpr_mx7_out[64-1:0];
5601
//
5602
// added for timing
5603
dff #(64) dff_tlu_exu_rsr_data_m (
5604
    .din (tlu_exu_rsr_data_e[64-1:0]),
5605
    .q   (tlu_exu_rsr_data_m[64-1:0]),
5606
    .clk (clk),
5607
    .se  (se),
5608
    .si  (),
5609
    .so  ()
5610
);
5611
 
5612
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.