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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [lsu_excpctl.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: lsu_excpctl.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
/*
24
/* ========== Copyright Header Begin ==========================================
25
*
26
* OpenSPARC T1 Processor File: sys.h
27
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
28
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
29
*
30
* The above named program is free software; you can redistribute it and/or
31
* modify it under the terms of the GNU General Public
32
* License version 2 as published by the Free Software Foundation.
33
*
34
* The above named program is distributed in the hope that it will be
35
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
37
* General Public License for more details.
38
*
39
* You should have received a copy of the GNU General Public
40
* License along with this work; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
42
*
43
* ========== Copyright Header End ============================================
44
*/
45
// -*- verilog -*-
46
////////////////////////////////////////////////////////////////////////
47
/*
48
//
49
// Description:         Global header file that contain definitions that
50
//                      are common/shared at the systme level
51
*/
52
////////////////////////////////////////////////////////////////////////
53
//
54
// Setting the time scale
55
// If the timescale changes, JP_TIMESCALE may also have to change.
56
`timescale      1ps/1ps
57
 
58
//
59
// JBUS clock
60
// =========
61
//
62
 
63
 
64
 
65
// Afara Link Defines
66
// ==================
67
 
68
// Reliable Link
69
 
70
 
71
 
72
 
73
// Afara Link Objects
74
 
75
 
76
// Afara Link Object Format - Reliable Link
77
 
78
 
79
 
80
 
81
 
82
 
83
 
84
 
85
 
86
 
87
// Afara Link Object Format - Congestion
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
 
96
 
97
 
98
 
99
// Afara Link Object Format - Acknowledge
100
 
101
 
102
 
103
 
104
 
105
 
106
 
107
 
108
 
109
 
110
 
111
// Afara Link Object Format - Request
112
 
113
 
114
 
115
 
116
 
117
 
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
// Afara Link Object Format - Message
130
 
131
 
132
 
133
// Acknowledge Types
134
 
135
 
136
 
137
 
138
// Request Types
139
 
140
 
141
 
142
 
143
 
144
// Afara Link Frame
145
 
146
 
147
 
148
//
149
// UCB Packet Type
150
// ===============
151
//
152
 
153
 
154
 
155
 
156
 
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
//
170
// UCB Data Packet Format
171
// ======================
172
//
173
 
174
 
175
 
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
// Size encoding for the UCB_SIZE_HI/LO field
204
// 000 - byte
205
// 001 - half-word
206
// 010 - word
207
// 011 - double-word
208
// 111 - quad-word
209
 
210
 
211
 
212
 
213
 
214
 
215
 
216
//
217
// UCB Interrupt Packet Format
218
// ===========================
219
//
220
 
221
 
222
 
223
 
224
 
225
 
226
 
227
 
228
 
229
 
230
//`define UCB_THR_HI             9      // (6) cpu/thread ID shared with
231
//`define UCB_THR_LO             4             data packet format
232
//`define UCB_PKT_HI             3      // (4) packet type shared with
233
//`define UCB_PKT_LO             0      //     data packet format
234
 
235
 
236
 
237
 
238
 
239
 
240
 
241
//
242
// FCRAM Bus Widths
243
// ================
244
//
245
 
246
 
247
 
248
 
249
 
250
 
251
//
252
// ENET clock periods
253
// ==================
254
//
255
 
256
 
257
 
258
 
259
//
260
// JBus Bridge defines
261
// =================
262
//
263
 
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
//
275
// PCI Device Address Configuration
276
// ================================
277
//
278
 
279
 
280
 
281
 
282
 
283
 
284
 
285
 
286
 
287
 
288
 
289
 
290
 
291
 
292
 
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
/*
302
/* ========== Copyright Header Begin ==========================================
303
*
304
* OpenSPARC T1 Processor File: lsu.h
305
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
306
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
307
*
308
* The above named program is free software; you can redistribute it and/or
309
* modify it under the terms of the GNU General Public
310
* License version 2 as published by the Free Software Foundation.
311
*
312
* The above named program is distributed in the hope that it will be
313
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
314
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
315
* General Public License for more details.
316
*
317
* You should have received a copy of the GNU General Public
318
* License along with this work; if not, write to the Free Software
319
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
320
*
321
* ========== Copyright Header End ============================================
322
*/
323
 
324
 
325
 
326
 
327
 
328
 
329
 
330
 
331
//`define STB_PCX_WY_HI   107
332
//`define STB_PCX_WY_LO   106
333
 
334
 
335
 
336
 
337
 
338
 
339
 
340
 
341
 
342
 
343
 
344
 
345
 
346
 
347
 
348
 
349
 
350
 
351
 
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
 
381
 
382
 
383
 
384
 
385
 
386
 
387
 
388
 
389
 
390
 
391
 
392
 
393
 
394
 
395
 
396
 
397
 
398
 
399
 
400
 
401
 
402
 
403
 
404
 
405
 
406
 
407
 
408
 
409
 
410
 
411
 
412
 
413
 
414
 
415
 
416
// TLB Tag and Data Format
417
 
418
 
419
 
420
 
421
 
422
 
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
 
448
 
449
 
450
 
451
 
452
 
453
 
454
 
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462
 
463
 
464
 
465
 
466
 
467
 
468
 
469
 
470
 
471
 
472
 
473
 
474
 
475
 
476
 
477
 
478
// I-TLB version - lsu_tlb only.
479
 
480
 
481
 
482
 
483
 
484
 
485
 
486
 
487
 
488
 
489
 
490
 
491
 
492
 
493
 
494
 
495
 
496
 
497
 
498
 
499
 
500
 
501
 
502
 
503
// Invalidate Format
504
//addr<5:4>=00
505
 
506
 
507
 
508
 
509
 
510
 
511
 
512
 
513
 
514
 
515
 
516
 
517
 
518
 
519
 
520
 
521
 
522
//addr<5:4>=01
523
 
524
 
525
 
526
 
527
 
528
 
529
 
530
 
531
 
532
 
533
 
534
 
535
 
536
 
537
 
538
 
539
 
540
//addr<5:4>=10
541
 
542
 
543
 
544
 
545
 
546
 
547
 
548
 
549
 
550
 
551
 
552
 
553
 
554
 
555
 
556
 
557
 
558
//addr<5:4>=11
559
 
560
 
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
 
575
 
576
// cpuid - 4b
577
 
578
 
579
 
580
// CPUany, addr<5:4>=00,10
581
 
582
 
583
 
584
 
585
 
586
// CPUany, addr<5:4>=01,11
587
 
588
 
589
 
590
 
591
// CPUany, addr<5:4>=01,11
592
 
593
 
594
 
595
 
596
// DTAG parity error Invalidate
597
 
598
 
599
 
600
 
601
// CPX BINIT STORE
602
 
603
 
604
module lsu_excpctl ( /*AUTOARG*/
605
   // Outputs
606
   so, lsu_exu_st_dtlb_perr_g, lsu_ffu_st_dtlb_perr_g,
607
   lsu_defr_trp_taken_g, lsu_tlu_defr_trp_taken_g,
608
   lsu_mmu_defr_trp_taken_g, lsu_st_dtlb_perr_g,
609
   lsu_dmmu_sfsr_trp_wr, lsu_dsfsr_din_g, lsu_tlb_perr_ld_rq_kill_w,
610
   lsu_spu_early_flush_g, lsu_local_early_flush_g,
611
   lsu_tlu_early_flush_w, lsu_tlu_early_flush2_w, lsu_ttype_vld_m2,
612
   lsu_ttype_vld_m2_bf1, lsu_ifu_flush_pipe_w, lsu_exu_flush_pipe_w,
613
   lsu_mmu_flush_pipe_w, lsu_ffu_flush_pipe_w, lsu_tlu_wtchpt_trp_g,
614
   lsu_tlu_dmmu_miss_g, lsu_tlu_misalign_addr_ldst_atm_m,
615
   lsu_tlu_daccess_excptn_g, lsu_tlu_daccess_prot_g,
616
   lsu_tlu_priv_action_g, lsu_ifu_tlb_data_su, lsu_ifu_tlb_data_ue,
617
   lsu_ifu_tlb_tag_ue, lsu_tlu_ttype_m2, lsu_tlu_ttype_vld_m2,
618
   stb_cam_sqsh_msk, stb_cam_hit_bf, stb_cam_hit_bf1,
619
   tte_data_perror_unc, asi_tte_data_perror, asi_tte_tag_perror,
620
   // Inputs
621
   rclk, si, se, grst_l, arst_l, tlb_rd_tte_data_ebit,
622
   tlb_rd_tte_data_pbit, tlb_rd_tte_data_nfobit,
623
   tlb_rd_tte_data_wbit, tlb_cam_hit, tlb_pgnum_b39,
624
   lsu_ldst_va_b39_m, lsu_sun4r_va_m_l, lsu_sun4r_pgsz_b2t0_e,
625
   lsu_sun4v_pgsz_b2t0_e, tlu_early_flush_pipe_w, ifu_lsu_flush_w,
626
   ifu_lsu_nceen, lsu_tlb_asi_data_perr_g, lsu_tlb_asi_tag_perr_g,
627
   stb_state_vld0, stb_state_vld1, stb_state_vld2, stb_state_vld3,
628
   ifu_tlu_thrid_e, tlu_lsu_priv_trap_m, tlu_lsu_pstate_priv,
629
   st_inst_vld_e, ld_inst_vld_e, ifu_lsu_alt_space_e, lsu_ldst_va_m,
630
   hpv_priv_m, hpstate_en_m, stb_cam_hit, dtlb_bypass_m,
631
   lsu_alt_space_m, atomic_m, ldst_dbl_m, fp_ldst_m, lda_internal_m,
632
   sta_internal_m, cam_real_m, data_rd_vld_g, tag_rd_vld_g,
633
   ldst_sz_m, asi_internal_m, rd_only_ltlb_asi_e, wr_only_ltlb_asi_e,
634
   dfill_tlb_asi_e, ifill_tlb_asi_e, nofault_asi_m, as_if_user_asi_m,
635
   atomic_asi_m, phy_use_ec_asi_m, phy_byp_ec_asi_m, quad_asi_m,
636
   binit_quad_asi_m, blk_asi_m, recognized_asi_m, strm_asi_m,
637
   mmu_rd_only_asi_m, rd_only_asi_m, wr_only_asi_m, unimp_asi_m,
638
   lsu_nonalt_nucl_access_m, va_wtchpt_cmp_en_m,
639
   lsu_va_match_b47_b32_m, lsu_va_match_b31_b3_m,
640
   va_wtchpt_msk_match_m, ifu_tlu_inst_vld_m,
641
   exu_tlu_misalign_addr_jmpl_rtn_m, exu_tlu_va_oor_m,
642
   tlu_dsfsr_flt_vld, tlu_lsu_pstate_cle, tlu_lsu_pstate_am,
643
   lsu_excpctl_asi_state_m, lsu_tlu_nonalt_ldst_m,
644
   lsu_squash_va_oor_m, lsu_tlu_xslating_ldst_m, lsu_tlu_ctxt_sel_m,
645
   lsu_tlu_write_op_m, lsu_memref_m, lsu_flsh_inst_m,
646
   tte_data_parity_error, tte_tag_parity_error
647
   );
648
 
649
 
650
   input rclk;
651
   input si;
652
   input se;
653
   input grst_l;
654
   input arst_l;
655
   output so;
656
 
657
   //=================================================================
658
   // input from tlb
659
//   input [`STLB_DATA_NFO:`STLB_DATA_W] tlb_rd_tte_data ; // tte data from tlb
660
   input  tlb_rd_tte_data_ebit;
661
   input  tlb_rd_tte_data_pbit;
662
   input  tlb_rd_tte_data_nfobit;
663
   input  tlb_rd_tte_data_wbit;
664
 
665
 
666
   input                               tlb_cam_hit;
667
   input                               tlb_pgnum_b39;
668
//   input                               tlb_rd_tte_data_locked ;    // lock bit from tte
669
   //=================================================================
670
 
671
   input        lsu_ldst_va_b39_m ;
672
   input        lsu_sun4r_va_m_l ;
673
   input [2:0]   lsu_sun4r_pgsz_b2t0_e ;
674
   input [2:0]   lsu_sun4v_pgsz_b2t0_e ;
675
 
676
   input         tlu_early_flush_pipe_w;
677
   input         ifu_lsu_flush_w;
678
   input [3:0]   ifu_lsu_nceen ;             // uncorrectible error enable 
679
 
680
   input        lsu_tlb_asi_data_perr_g ;
681
   input        lsu_tlb_asi_tag_perr_g ;
682
 
683
   input [7:0]  stb_state_vld0 ;  // valid bits - stb0
684
   input [7:0]   stb_state_vld1 ;  // valid bits - stb1
685
   input [7:0]  stb_state_vld2 ;  // valid bits - stb2
686
   input [7:0]  stb_state_vld3 ;  // valid bits - stb3
687
 
688
   input [1:0]  ifu_tlu_thrid_e ; // thread-id.
689
 
690
   input        tlu_lsu_priv_trap_m ;   // daccess-excp in tlu
691
 
692
   output       lsu_exu_st_dtlb_perr_g ;
693
   output       lsu_ffu_st_dtlb_perr_g ;
694
 
695
   output       lsu_defr_trp_taken_g ;
696
   output       lsu_tlu_defr_trp_taken_g ;
697
   output       lsu_mmu_defr_trp_taken_g ;
698
 
699
   output [3:0]  lsu_st_dtlb_perr_g ;
700
 
701
   output [3:0]  lsu_dmmu_sfsr_trp_wr;      // sfsr wr based on trap.
702
   output [23:0] lsu_dsfsr_din_g;
703
 
704
 
705
   output lsu_tlb_perr_ld_rq_kill_w ;
706
   output lsu_spu_early_flush_g;
707
   output lsu_local_early_flush_g;   //to lsu
708
 
709
//   output lsu_dctl_early_flush_w;
710
   output lsu_tlu_early_flush_w;
711
   output lsu_tlu_early_flush2_w;
712
 
713
   output lsu_ttype_vld_m2;
714
   output lsu_ttype_vld_m2_bf1;
715
 
716
 
717
//   output     lsu_stbctl_flush_pipe_w ;
718
//   output     lsu_stbrwctl_flush_pipe_w ;
719
   //output lsu_flush_pipe_w;
720
   output lsu_ifu_flush_pipe_w;
721
   output lsu_exu_flush_pipe_w;
722
   output lsu_mmu_flush_pipe_w;
723
   output lsu_ffu_flush_pipe_w;
724
 
725
   output lsu_tlu_wtchpt_trp_g ;        // watchpt trap has occurred.
726
   output lsu_tlu_dmmu_miss_g;
727
   output lsu_tlu_misalign_addr_ldst_atm_m ; // mem_addr unaligned
728
//   output lsu_tlu_priv_violtn_g;
729
   wire   lsu_tlu_priv_violtn_g;
730
   output lsu_tlu_daccess_excptn_g;
731
   output lsu_tlu_daccess_prot_g;
732
   output lsu_tlu_priv_action_g;
733
//   output lsu_tlu_tte_ebit_g;
734
//   output lsu_tlu_spec_access_epage_g;
735
//   output lsu_tlu_uncache_atomic_g;
736
//   output lsu_tlu_illegal_asi_action_g;
737
//   output lsu_tlu_flt_ld_nfo_pg_g;
738
 
739
   //output lsu_tlu_asi_rd_unc;
740
 
741
   output lsu_ifu_tlb_data_su ;   // specific to st ue
742
   output lsu_ifu_tlb_data_ue ;   // dtlb data asi rd parity error ; now ld ue
743
   output lsu_ifu_tlb_tag_ue ;    // dtlb tag asi rd parity error
744
 
745
output [8:0]            lsu_tlu_ttype_m2;
746
output                  lsu_tlu_ttype_vld_m2;
747
 
748
   output  [7:0]   stb_cam_sqsh_msk ;  // squash spurious hits
749
 
750
   output       stb_cam_hit_bf;           // buffered stb_cam_hit for qctl1.
751
   output       stb_cam_hit_bf1;                // buffered stb_cam_hit for stb_rwctl, dctl.
752
 
753
   input [3:0]          tlu_lsu_pstate_priv ;
754
//   input [3:0]          tlu_lsu_hpv_priv;
755
//   input [3:0]          tlu_lsu_hpstate_en;
756
 
757
 
758
   input                st_inst_vld_e;
759
   input                ld_inst_vld_e;
760
   input                ifu_lsu_alt_space_e;        // alternate space ld/st
761
 
762
   //interface between lsu_dctldp
763
   input [7:0]          lsu_ldst_va_m;
764
 
765
   //interface between lsu_excpctl and lsu_dctl
766
 
767
   output               tte_data_perror_unc;
768
   //output               tte_data_perror_corr;
769
   output               asi_tte_data_perror ;
770
   output               asi_tte_tag_perror ;
771
 
772
 
773
   input hpv_priv_m;
774
   input hpstate_en_m;
775
 
776
   input                stb_cam_hit ;
777
 
778
   input                dtlb_bypass_m;
779
 
780
   input                lsu_alt_space_m;
781
   input                atomic_m;
782
//   input                atomic_g;
783
   input                ldst_dbl_m;
784
   input                fp_ldst_m;
785
//   input                lsu_inst_vld_w;
786
   input                lda_internal_m;
787
   input                sta_internal_m;
788
   input                cam_real_m;
789
//   input                va_wtchpt_match;
790
 
791
   input                data_rd_vld_g;
792
   input                tag_rd_vld_g;
793
   input [1:0]          ldst_sz_m;
794
   input                asi_internal_m;
795
 
796
//   input                dfill_thread0;
797
//   input                dfill_thread1;
798
//   input                dfill_thread2;
799
//   input                dfill_thread3;
800
 
801
   wire                ld_inst_vld_unflushed;
802
   wire                st_inst_vld_unflushed;
803
//   input                flsh_inst_g;
804
//   input                unc_err_trap_g;
805
 
806
   //asi decode
807
   input                rd_only_ltlb_asi_e;
808
   input                wr_only_ltlb_asi_e;
809
   input                dfill_tlb_asi_e;
810
   input                ifill_tlb_asi_e;
811
 
812
   input                nofault_asi_m;
813
   input                as_if_user_asi_m;
814
 
815
   input                atomic_asi_m;
816
   input                phy_use_ec_asi_m;
817
   input                phy_byp_ec_asi_m;
818
//   input                tlb_byp_asi_m;
819
   input                quad_asi_m;
820
   input                binit_quad_asi_m;
821
   input                blk_asi_m;
822
//   input                blk_cmt_asi_m;
823
   input                recognized_asi_m;
824
   input                strm_asi_m;
825
   input                mmu_rd_only_asi_m;
826
   input                rd_only_asi_m;
827
   input                wr_only_asi_m;
828
   input                unimp_asi_m;
829
   input                lsu_nonalt_nucl_access_m ;
830
 
831
   input    va_wtchpt_cmp_en_m;    //from dctl
832
   input    lsu_va_match_b47_b32_m;        //from qdp1
833
   input    lsu_va_match_b31_b3_m;         //from qdp1
834
 
835
   input    va_wtchpt_msk_match_m; //from dctldp
836
 
837
   input                ifu_tlu_inst_vld_m ;
838
 
839
input           exu_tlu_misalign_addr_jmpl_rtn_m;// misaligned addr - jmpl or return addr
840
input           exu_tlu_va_oor_m;               // ??? - to be used in sfsr
841
input [3:0]     tlu_dsfsr_flt_vld;
842
input [3:0]      tlu_lsu_pstate_cle ;       // current little endian
843
input [3:0]      tlu_lsu_pstate_am ;        // address mask
844
input  [7:0]    lsu_excpctl_asi_state_m ;   // ASI State + imm asi
845
input           lsu_tlu_nonalt_ldst_m ; // non-alternate load or store // FORCE
846
input           lsu_squash_va_oor_m ;   // squash va_oor for mem-op. // FORCE
847
input           lsu_tlu_xslating_ldst_m ;// xslating ldst,atomic etc // FORCE
848
input   [2:0]   lsu_tlu_ctxt_sel_m;           // context selected:0-p,1-s,2-n // FORCE
849
input           lsu_tlu_write_op_m; // FORCE
850
input           lsu_memref_m ;
851
input           lsu_flsh_inst_m ;
852
 
853
 
854
input    tte_data_parity_error ;
855
input    tte_tag_parity_error ;
856
 
857
wire    other_flush_pipe_w ;
858
wire    defr_trp_taken ;
859
wire    defr_trp_taken_m, defr_trp_taken_byp, defr_trp_taken_m_din ;
860
wire    tlb_tte_vld_m, tlb_tte_vld_g ;
861
wire    priv_pg_usr_mode_m, priv_pg_usr_mode_g, priv_pg_usr_mode;
862
wire    nfo_pg_nonnfo_asi_m, nfo_pg_nonnfo_asi_g, nfo_pg_nonnfo_asi;
863
wire    spec_access_epage_m, spec_access_epage_g, spec_access_epage ;
864
wire    nonwr_pg_st_access;
865
 
866
//=========================================================================================
867
// MISCELLANEOUS
868
//=========================================================================================
869
 
870
   wire       clk;
871
   assign     clk = rclk;
872
   wire       reset;
873
 
874
   wire       dbb_reset_l;
875
 
876
    dffrl_async rstff(.din (grst_l),
877
                        .q   (dbb_reset_l),
878
                        .clk (clk), .se(se), .si(), .so(),
879
                        .rst_l (arst_l));
880
 
881
   assign reset = ~dbb_reset_l ;
882
 
883
bw_u1_buf_30x UZsize_stb_cam_hit_bf1  (.a(stb_cam_hit),   .z(stb_cam_hit_bf1));  //to dctl, stb_rwctl
884
bw_u1_buf_30x UZsize_stb_cam_hit_bf   (.a(stb_cam_hit),   .z(stb_cam_hit_bf ));  //to qctl1
885
 
886
wire                ld_inst_vld_m;
887
wire                st_inst_vld_m;
888
 
889
dff #(2) inst_vld_stgm (
890
   .din ({ld_inst_vld_e, st_inst_vld_e}),
891
   .q   ({ld_inst_vld_m, st_inst_vld_m}),
892
   .clk    (clk),
893
   .se     (se),       .si (),          .so ()
894
);
895
 
896
dff #(2) inst_vld_stgg (
897
   .din ({ld_inst_vld_m, st_inst_vld_m}),
898
   .q   ({ld_inst_vld_unflushed, st_inst_vld_unflushed}),
899
   .clk    (clk),
900
   .se     (se),       .si (),          .so ()
901
);
902
 
903
wire    tlu_priv_trap_g ;
904
dff #(1) tprivtrp_g (
905
   .din (tlu_lsu_priv_trap_m),
906
   .q   (tlu_priv_trap_g),
907
   .clk    (clk),
908
   .se     (se),       .si (),          .so ()
909
);
910
 
911
 
912
//=========================================================================================
913
//  Thread Staging
914
//=========================================================================================
915
 
916
wire [1:0] thrid_m, thrid_g ;
917
dff #(2)  tid_stgm (
918
        .din    (ifu_tlu_thrid_e[1:0]),
919
        .q      (thrid_m[1:0]),
920
        .clk    (clk),
921
        .se     (se),       .si (),          .so ()
922
        );
923
 
924
wire    thread0_m, thread1_m, thread2_m, thread3_m;
925
 
926
assign  thread0_m = ~thrid_m[1] & ~thrid_m[0] ;
927
assign  thread1_m = ~thrid_m[1] &  thrid_m[0] ;
928
assign  thread2_m =  thrid_m[1] & ~thrid_m[0] ;
929
assign  thread3_m =  thrid_m[1] &  thrid_m[0] ;
930
 
931
wire thread0_g, thread1_g, thread2_g, thread3_g ;
932
dff #(4)  tid_stgg (
933
        .din    ({thread0_m, thread1_m, thread2_m, thread3_m}),
934
        .q      ({thread0_g, thread1_g, thread2_g, thread3_g}),
935
        .clk    (clk),
936
        .se     (se),       .si (),          .so ()
937
        );
938
 
939
//=========================================================================================
940
//  INST_VLD_W GENERATION
941
//=========================================================================================
942
 
943
 
944
assign  thrid_g[0] = thread1_g | thread3_g ;
945
assign  thrid_g[1] = thread2_g | thread3_g ;
946
 
947
wire    flush_w_inst_vld_m ;
948
wire    lsu_inst_vld_w ;
949
wire    lsu_flush_pipe_w;
950
assign  flush_w_inst_vld_m =
951
        ifu_tlu_inst_vld_m &
952
        ~(lsu_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
953
 
954
dff  stgw_ivld (
955
        .din    (flush_w_inst_vld_m),
956
        .q      (lsu_inst_vld_w),
957
        .clk    (clk),
958
        .se     (se),       .si (),          .so ()
959
        );
960
 
961
//========================================================================
962
//      Miscellaneous
963
//========================================================================
964
 
965
 
966
// Moved to excpctl from stb_rwctl as excpctl is closer to stb-cam.
967
mux4ds  #(8) stbvld_mx (
968
  .in0  (~stb_state_vld0[7:0]),
969
  .in1  (~stb_state_vld1[7:0]),
970
  .in2  (~stb_state_vld2[7:0]),
971
  .in3  (~stb_state_vld3[7:0]),
972
  .sel0 (thread0_g),
973
  .sel1 (thread1_g),
974
  .sel2 (thread2_g),
975
  .sel3 (thread3_g),
976
  .dout (stb_cam_sqsh_msk[7:0])
977
);
978
 
979
//========================================================================
980
//  Exception Handling Begin
981
//========================================================================
982
 
983
//va watch point
984
   wire va_match_g;
985
   wire va_wtchpt_msk_match_g;
986
 
987
 
988
wire    va_wtchpt_en_m ;
989
 
990
assign  va_wtchpt_en_m =
991
va_wtchpt_cmp_en_m &
992
(((~asi_internal_m & recognized_asi_m) & lsu_alt_space_m) | ~lsu_alt_space_m) // Bug5226
993
& (ld_inst_vld_m | st_inst_vld_m) & //bug 3681
994
 ~(hpv_priv_m & hpstate_en_m)  // ECO 4178
995
& ~cam_real_m ;                // ECO 5470 (TO_2_0)
996
 
997
//bug6480   
998
   wire lsu_va_match_m;
999
   wire pstate_am_m ;
1000
 
1001
assign lsu_va_match_m = ((lsu_va_match_b47_b32_m & lsu_va_match_b31_b3_m) & ~pstate_am_m) |
1002
                          (lsu_va_match_b31_b3_m & pstate_am_m);
1003
 
1004
dff #(3)  stgwtch_g (
1005
        .din    ({va_wtchpt_en_m,
1006
                  lsu_va_match_m,
1007
                  va_wtchpt_msk_match_m}),
1008
        .q      ({va_wtchpt_en_g,
1009
                  va_match_g,
1010
                  va_wtchpt_msk_match_g}),
1011
        .clk    (clk),
1012
        .se     (se),       .si (),          .so ()
1013
        );
1014
 
1015
 
1016
// These signals will eventually generate exceptions.
1017
   wire va_wtchpt_match;
1018
 
1019
assign  va_wtchpt_match =
1020
        va_match_g &  va_wtchpt_msk_match_g & lsu_inst_vld_w & va_wtchpt_en_g;
1021
 
1022
assign  lsu_tlu_wtchpt_trp_g = va_wtchpt_match ;
1023
 
1024
 
1025
// tlb related exceptions/errors
1026
wire  tlb_daccess_excptn_e, tlb_daccess_excptn_m ;
1027
wire  tlb_daccess_excptn_e_d1;
1028
wire    tlb_illgl_pgsz_m ;
1029
 
1030
assign  tlb_daccess_excptn_e  =
1031
  ((rd_only_ltlb_asi_e &  st_inst_vld_e)  |
1032
   (wr_only_ltlb_asi_e &  ld_inst_vld_e)) & ifu_lsu_alt_space_e   ;
1033
 
1034
dff  #(1) tlbex_stgm (
1035
        .din    ({tlb_daccess_excptn_e}),
1036
        .q      ({tlb_daccess_excptn_e_d1}),
1037
        .clk    (clk),
1038
        .se     (se),       .si (),          .so ()
1039
        );
1040
 
1041
assign tlb_daccess_excptn_m = tlb_daccess_excptn_e_d1 | tlb_illgl_pgsz_m;
1042
 
1043
wire pstate_priv_m;
1044
//wire pstate_priv;
1045
 
1046
mux4ds  #(1) pstate_priv_m_mux (
1047
        .in0    (tlu_lsu_pstate_priv[0]),
1048
        .in1    (tlu_lsu_pstate_priv[1]),
1049
        .in2    (tlu_lsu_pstate_priv[2]),
1050
        .in3    (tlu_lsu_pstate_priv[3]),
1051
        .sel0   (thread0_m),
1052
        .sel1   (thread1_m),
1053
        .sel2   (thread2_m),
1054
        .sel3   (thread3_m),
1055
        .dout   (pstate_priv_m)
1056
);
1057
 
1058
//dff #(1)  priv_stgg (
1059
//        .din    (pstate_priv_m),
1060
//        .q      (pstate_priv),
1061
//        .clk    (clk),
1062
//        .se     (se),       .si (),          .so ()
1063
//        );
1064
 
1065
// privilege violation - priv page accessed in user mode
1066
//timing 
1067
//assign  priv_pg_usr_mode =  // data access exception; TT=h30
1068
//  (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~(pstate_priv | hpv_priv) & tlb_rd_tte_data_pbit ;
1069
 
1070
//SC2   wire hpv_priv_m;
1071
 
1072
   assign priv_pg_usr_mode_m = (ld_inst_vld_m | st_inst_vld_m) & ~(pstate_priv_m | hpv_priv_m);
1073
 
1074
dff #(1) priv_pg_usr_mode_stgg  (
1075
        .din    (priv_pg_usr_mode_m),
1076
        .q      (priv_pg_usr_mode_g),
1077
        .clk    (clk),
1078
        .se     (se),       .si (),          .so ()
1079
        );
1080
 
1081
   assign priv_pg_usr_mode = priv_pg_usr_mode_g & tlb_rd_tte_data_pbit ;
1082
 
1083
// protection violation - store to a page that does not have write permission
1084
//timing
1085
//assign  nonwr_pg_st_access =  // data access protection; TT=h33
1086
//  st_inst_vld_unflushed   & 
1087
//  ~tlb_rd_tte_data_wbit & ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
1088
//   //lsu_dtlb_bypass_g) ; // W=1 in bypass mode - In bypass mode this trap will never happen !!!
1089
 
1090
   assign nonwr_pg_st_access = ~tlb_rd_tte_data_wbit & st_inst_vld_unflushed & tlb_tte_vld_g;
1091
 
1092
wire  daccess_prot ;
1093
assign  daccess_prot = nonwr_pg_st_access  ;
1094
    //((~lsu_dtlb_bypass_g & tlb_cam_hit_g) | (tlb_byp_asi_g & lsu_alt_space_g)) ;
1095
 
1096
// access to a page marked with the nfo with an asi other than nfo asi.
1097
//timing
1098
//assign  nfo_pg_nonnfo_asi  =  // data access exception; TT=h30
1099
//  (ld_inst_vld_unflushed | st_inst_vld_unflushed) &   // any access
1100
//  ((~nofault_asi_g & lsu_alt_space_g) | ~lsu_alt_space_g) // in alternate space or not
1101
//  & tlb_rd_tte_data_nfobit ;
1102
 
1103
assign nfo_pg_nonnfo_asi_m = (ld_inst_vld_m | st_inst_vld_m) &
1104
                             ((~nofault_asi_m & lsu_alt_space_m) | ~lsu_alt_space_m) ;
1105
 
1106
dff #(1) nfo_pg_nonnfo_asi_stgg   (
1107
        .din    (nfo_pg_nonnfo_asi_m),
1108
        .q      (nfo_pg_nonnfo_asi_g),
1109
        .clk    (clk),
1110
        .se     (se),       .si (),          .so ()
1111
        );
1112
assign    nfo_pg_nonnfo_asi = nfo_pg_nonnfo_asi_g & tlb_rd_tte_data_nfobit ;
1113
 
1114
// as_if_usr asi accesses priv page.
1115
//timing
1116
//assign  as_if_usr_priv_pg  =  // data access exception; TT=h30
1117
//  (ld_inst_vld_unflushed | st_inst_vld_unflushed) & as_if_user_asi_g & lsu_alt_space_g & 
1118
//      tlb_rd_tte_data_pbit ;
1119
 
1120
   wire   as_if_usr_priv_pg_m, as_if_usr_priv_pg_g, as_if_usr_priv_pg;
1121
   assign as_if_usr_priv_pg_m = (ld_inst_vld_m | st_inst_vld_m) & as_if_user_asi_m & lsu_alt_space_m;
1122
 
1123
dff #(1) as_if_usr_priv_pg_stgg   (
1124
        .din    (as_if_usr_priv_pg_m),
1125
        .q      (as_if_usr_priv_pg_g),
1126
        .clk    (clk),
1127
        .se     (se),       .si (),          .so ()
1128
        );
1129
   assign  as_if_usr_priv_pg =  as_if_usr_priv_pg_g & tlb_rd_tte_data_pbit ;
1130
 
1131
// non-cacheable address - iospace PA[39] = 1 
1132
// atomic access to non-cacheable space.
1133
   wire    atm_access_w_nc, atomic_g;
1134
 
1135
dff #(1) atm_stgg (
1136
        .din    (atomic_m),
1137
        .q      (atomic_g),
1138
        .clk    (clk),
1139
        .se     (se),       .si (),          .so ()
1140
        );
1141
 
1142
 
1143
assign  atm_access_w_nc = atomic_g & tlb_pgnum_b39 ; // io space 
1144
 
1145
// atomic inst with unsupported asi.
1146
//timing
1147
//assign  atm_access_unsup_asi = atomic_g & ~atomic_asi_g & lsu_alt_space_g ;
1148
   wire atm_access_unsup_asi_m, atm_access_unsup_asi;
1149
 
1150
assign  atm_access_unsup_asi_m = atomic_m & ~atomic_asi_m & lsu_alt_space_m;
1151
 
1152
dff #(1) atm_access_unsup_asi_stgg   (
1153
        .din    (atm_access_unsup_asi_m),
1154
        .q      (atm_access_unsup_asi),
1155
        .clk    (clk),
1156
        .se     (se),       .si (),          .so ()
1157
        );
1158
 
1159
 
1160
//timing
1161
//assign  tlb_tte_vld_g = ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
1162
 
1163
wire    dmmu_va_oor_m ;
1164
assign  tlb_tte_vld_m = ~dtlb_bypass_m & tlb_cam_hit &
1165
                        ~((unimp_asi_m | asi_internal_m | ~recognized_asi_m) &
1166
                                lsu_alt_space_m) & // Bug 3541,5186
1167
                        ~dmmu_va_oor_m ; // Bug 5070
1168
 
1169
dff #(1) tlb_tte_vld_stgg   (
1170
        .din    (tlb_tte_vld_m),
1171
        .q      (tlb_tte_vld_g),
1172
        .clk    (clk),
1173
        .se     (se),       .si (),          .so ()
1174
        );
1175
 
1176
wire  pg_with_ebit_m, pg_with_ebit_g, pg_with_ebit  ;
1177
//timing   
1178
//assign        pg_with_ebit = 
1179
//      (tlb_rd_tte_data_ebit & tlb_tte_vld_g)  | // tte
1180
//        (lsu_dtlb_bypass_g & ~(phy_use_ec_asi_g & lsu_alt_space_g)) | // regular bypass 
1181
//        (tlb_byp_asi_g & ~phy_use_ec_asi_g & lsu_alt_space_g) ; // phy_byp
1182
 
1183
assign  pg_with_ebit_m =
1184
        (dtlb_bypass_m & ~(phy_use_ec_asi_m & lsu_alt_space_m) &
1185
        (lsu_ldst_va_b39_m & ~pstate_am_m)) |
1186
        // regular bypass // Bug 4296,5050 related.
1187
        (dtlb_bypass_m & (phy_byp_ec_asi_m & lsu_alt_space_m)) ; // phy_byp
1188
 
1189
dff #(1) pg_with_ebit_stgg   (
1190
        .din    (pg_with_ebit_m),
1191
        .q      (pg_with_ebit_g),
1192
        .clk    (clk),
1193
        .se     (se),       .si (),          .so ()
1194
        );
1195
assign  pg_with_ebit = (tlb_rd_tte_data_ebit & tlb_tte_vld_g)  | // tte  
1196
                              pg_with_ebit_g;
1197
 
1198
//timing
1199
//assign  spec_access_epage = 
1200
//  ((ld_inst_vld_unflushed & nofault_asi_g & lsu_alt_space_g) |  // spec load
1201
//  flsh_inst_g) & // flush inst
1202
//  pg_with_ebit ; // page with side effects
1203
////  tlb_rd_tte_data_ebit ; // page with side effects
1204
 
1205
assign  spec_access_epage_m =
1206
// Bug 5166
1207
((ld_inst_vld_m & ~atomic_m) & nofault_asi_m & lsu_alt_space_m);   // spec load
1208
dff #(1) spec_access_epage_stgg   (
1209
        .din    (spec_access_epage_m),
1210
        .q      (spec_access_epage_g),
1211
        .clk    (clk),
1212
        .se     (se),       .si (),          .so ()
1213
        );
1214
// remove flsh_inst_g ??   
1215
//assign spec_access_epage = (spec_access_epage_g  | flsh_inst_g) & pg_with_ebit;
1216
assign spec_access_epage = (spec_access_epage_g) & pg_with_ebit;
1217
 
1218
 
1219
   wire quad_asi_non_ldstda_m;
1220
   // covers regular quad asi AND binit. 
1221
   assign quad_asi_non_ldstda_m =
1222
        quad_asi_m & lsu_alt_space_m &
1223
                ((~ldst_dbl_m & ld_inst_vld_m) | // only lddbl should use
1224
                (fp_ldst_m & (ld_inst_vld_m | st_inst_vld_m))) ; // float should not use
1225
 
1226
   wire true_quad_non_ldda_m ;
1227
   // catches case where st or non-ldd uses asi
1228
   assign true_quad_non_ldda_m =
1229
        (quad_asi_m & ~binit_quad_asi_m) & lsu_alt_space_m &
1230
  ((~ldst_dbl_m & ld_inst_vld_m) | st_inst_vld_m) ;
1231
 
1232
wire  blk_asi_non_ldstdfa_m ;
1233
 
1234
assign  blk_asi_non_ldstdfa_m = blk_asi_m & lsu_alt_space_m &
1235
     ~(ldst_dbl_m & fp_ldst_m) & (ld_inst_vld_m | st_inst_vld_m) ;
1236
 
1237
// trap on illegal asi
1238
wire  illegal_asi_trap_m, illegal_asi_trap_g, illegal_asi_trap_m_d1 ;
1239
 
1240
assign  illegal_asi_trap_m =
1241
((ld_inst_vld_m | st_inst_vld_m) & lsu_alt_space_m & ~recognized_asi_m) |
1242
((ld_inst_vld_m | st_inst_vld_m) & asi_internal_m & fp_ldst_m & lsu_alt_space_m) | // Bug 4382
1243
blk_asi_non_ldstdfa_m |
1244
quad_asi_non_ldstda_m |
1245
true_quad_non_ldda_m  ;
1246
 
1247
dff #(1) illegal_asi_trap_stgg   (
1248
        .din    (illegal_asi_trap_m),
1249
        .q      (illegal_asi_trap_m_d1),
1250
        .clk    (clk),
1251
        .se     (se),       .si (),          .so ()
1252
        );
1253
   //need lsu_inst_vld_w ??
1254
//   assign illegal_asi_trap_g = illegal_asi_trap_m_d1 & lsu_inst_vld_w;
1255
   assign illegal_asi_trap_g = illegal_asi_trap_m_d1;
1256
 
1257
wire wr_to_strm_sync_m ;
1258
//timing
1259
//assign        wr_to_strm_sync =       
1260
//  strm_asi & ((ldst_va_g[7:0] == 8'hA0) | (ldst_va_g[7:0] == 8'h68)) &
1261
//  st_inst_vld_unflushed & lsu_alt_space_g ;
1262
 
1263
assign  wr_to_strm_sync_m =     // Bug 5742
1264
  strm_asi_m & (lsu_ldst_va_m[7:0] == 8'hA0) & st_inst_vld_m & lsu_alt_space_m ;
1265
 
1266
/*dff #(1) wr_to_strm_sync_stgg   (
1267
        .din    (wr_to_strm_sync_m),
1268
        .q      (wr_to_strm_sync),
1269
        .clk    (clk),
1270
        .se     (se),       .si (),          .so ()
1271
        );*/
1272
 
1273
 
1274
// HPV Changes 
1275
// Push back into previous stage.
1276
// qualification with hpv_priv and hpstate_en required to ensure hypervisor
1277
// is not trying to access.
1278
//SC2   wire hpv_priv_e;
1279
 
1280
//SC2 mux4ds  #(1) hpv_priv_e_mux (
1281
//SC2        .in0    (tlu_lsu_hpv_priv[0]),
1282
//SC2        .in1    (tlu_lsu_hpv_priv[1]),
1283
//SC2        .in2    (tlu_lsu_hpv_priv[2]),
1284
//SC2        .in3    (tlu_lsu_hpv_priv[3]),
1285
//SC2        .sel0   (thread0_e),  
1286
//SC2        .sel1   (thread1_e),
1287
//SC2        .sel2   (thread2_e),  
1288
//SC2        .sel3   (thread3_e),
1289
//SC2       .dout   (hpv_priv_e)
1290
//SC2);
1291
 
1292
//SC2   wire hpstate_en_e;
1293
 
1294
//SC2 mux4ds  #(1) hpstate_en_e_mux (
1295
//SC2        .in0    (tlu_lsu_hpstate_en[0]),
1296
//SC2        .in1    (tlu_lsu_hpstate_en[1]),
1297
//SC2        .in2    (tlu_lsu_hpstate_en[2]),
1298
//SC2        .in3    (tlu_lsu_hpstate_en[3]),
1299
//SC2        .sel0   (thread0_e),  
1300
//SC2        .sel1   (thread1_e),
1301
//SC2        .sel2   (thread2_e),  
1302
//SC2        .sel3   (thread3_e),
1303
//SC2        .dout   (hpstate_en_e)
1304
//SC2);
1305
//SC2   wire hpstate_en_m;
1306
 
1307
//SC2 dff #(2) hpv_stgm (
1308
//SC2        .din    ({hpv_priv_e, hpstate_en_e}),
1309
//SC2        .q         ({hpv_priv_m, hpstate_en_m}),
1310
//SC2        .clk    (clk),
1311
//SC2        .se     (se),       .si (),          .so ()
1312
//SC2        );
1313
//SC2   wire hpv_priv, hpstate_en;
1314
 
1315
 
1316
//SC2 dff #(2) hpv_stgg (
1317
//SC2        .din    ({hpv_priv_m, hpstate_en_m}),
1318
//SC2        .q         ({hpv_priv,   hpstate_en}),
1319
//SC2        .clk    (clk),
1320
//SC2        .se     (se),       .si (),          .so ()
1321
//SC2        );
1322
 
1323
/*assign  priv_action = (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~lsu_asi_state[7] &
1324
      ~pstate_priv & ~(hpv_priv & hpstate_en) & lsu_alt_space_g ;*/
1325
// Generate a stage earlier
1326
   wire priv_action_m, priv_action;
1327
 
1328
assign  priv_action_m = (ld_inst_vld_m | st_inst_vld_m) &
1329
        ((~lsu_excpctl_asi_state_m[7] & lsu_alt_space_m) |      // alt_space
1330
        lsu_nonalt_nucl_access_m) &             // non-alt space - nucleus ctxt
1331
      ~pstate_priv_m & ~(hpv_priv_m & hpstate_en_m) ;
1332
 
1333
/*assign  priv_action_m = (ld_inst_vld_m | st_inst_vld_m) & ~lsu_excpctl_asi_state_m[7] &
1334
      ~pstate_priv_m & ~(hpv_priv_m & hpstate_en_m) & lsu_alt_space_m ;*/
1335
 
1336
dff  pact_stgg (
1337
        .din    (priv_action_m),
1338
        .q      (priv_action),
1339
        .clk    (clk),
1340
        .se     (se),       .si (),          .so ()
1341
        );
1342
 
1343
// Take data_access exception if supervisor uses hypervisor asi  
1344
   wire hpv_asi_range_m;
1345
   wire spv_use_hpv_m ;
1346
//timing
1347
//assign  hpv_asi_range =
1348
//                    ~lsu_asi_state[7] & (
1349
//                         (~lsu_asi_state[6] & lsu_asi_state[5] & lsu_asi_state[4]) | // 0x3?
1350
//                         ( lsu_asi_state[6]));  
1351
 
1352
assign  hpv_asi_range_m =
1353
                         ~lsu_excpctl_asi_state_m[7] & (
1354
                         (~lsu_excpctl_asi_state_m[6] & lsu_excpctl_asi_state_m[5] & lsu_excpctl_asi_state_m[4]) | // 0x3?
1355
                         ( lsu_excpctl_asi_state_m[6]));                                   // 0x4?,5?,6?,7?
1356
 
1357
// Take data_access exception if supervisor uses hypervisor asi
1358
 
1359
assign  spv_use_hpv_m = (ld_inst_vld_m | st_inst_vld_m) &
1360
                         hpv_asi_range_m &
1361
                         pstate_priv_m & ~hpv_priv_m & lsu_alt_space_m ;
1362
 
1363
// EARLY TRAPS
1364
 
1365
// memory address not aligned
1366
wire  qw_align_addr,blk_align_addr ;
1367
wire  hw_align_addr,wd_align_addr,dw_align_addr;
1368
 
1369
assign  hw_align_addr = ~lsu_ldst_va_m[0] ;         // half-word addr
1370
assign  wd_align_addr = ~lsu_ldst_va_m[1] & ~lsu_ldst_va_m[0] ;     // word addr
1371
assign  dw_align_addr = ~lsu_ldst_va_m[2] & ~lsu_ldst_va_m[1] & ~lsu_ldst_va_m[0] ; // dw addr
1372
assign  qw_align_addr = ~lsu_ldst_va_m[3] & ~lsu_ldst_va_m[2] & ~lsu_ldst_va_m[1] & ~lsu_ldst_va_m[0] ; // qw addr
1373
assign  blk_align_addr =
1374
~lsu_ldst_va_m[5] & ~lsu_ldst_va_m[4] & ~lsu_ldst_va_m[3] &
1375
~lsu_ldst_va_m[2] & ~lsu_ldst_va_m[1] & ~lsu_ldst_va_m[0] ; // 64B aligned addr for block ld/st
1376
 
1377
wire  hw_size,wd_size,dw_size;
1378
 
1379
//assign  byte_size = ~ldst_sz_m[1] &  ~ldst_sz_m[0] ; // byte size    
1380
assign  hw_size = ~ldst_sz_m[1] &  ldst_sz_m[0] ; // half-word size 
1381
assign  wd_size =  ldst_sz_m[1] & ~ldst_sz_m[0] ; // word size
1382
assign  dw_size =  ldst_sz_m[1] &  ldst_sz_m[0] ; // double-word size
1383
 
1384
wire  mem_addr_not_align ;
1385
 
1386
assign  mem_addr_not_align
1387
  = (((hw_size & ~hw_align_addr) | // half-word check
1388
    (wd_size & ~wd_align_addr)  | // word check
1389
    (dw_size & ~dw_align_addr)  | // double word check
1390
    //((quad_asi_m | binit_quad_asi_m) & lsu_alt_space_m & ldst_dbl_m & ~qw_align_addr) | // quad word check
1391
    (blk_asi_m & lsu_alt_space_m & fp_ldst_m & ldst_dbl_m & ~blk_align_addr)) & // 64B blk ld/st check
1392
    //(blk_asi_m & lsu_alt_space_m & blk_asi_m & ~blk_align_addr)) & // 64B blk ld/st check
1393
    (ld_inst_vld_m | st_inst_vld_m)) |
1394
    // check only for loads 
1395
    (((quad_asi_m | binit_quad_asi_m) & lsu_alt_space_m & ldst_dbl_m & ~qw_align_addr) & ld_inst_vld_m) ; // quad word check
1396
 
1397
// To be removed !! Now supported for both ld and st thru unimp_asi.
1398
//wire  blkst_cmt_daccess_excp_m ;
1399
//assign        blkst_cmt_daccess_excp_m =
1400
//    (blk_cmt_asi_m & lsu_alt_space_m & fp_ldst_m & ldst_dbl_m & st_inst_vld_m) ;
1401
 
1402
   wire    stdf_maddr_not_align, lddf_maddr_not_align ;
1403
 
1404
assign  stdf_maddr_not_align
1405
    = st_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr
1406
      & ~((blk_asi_m | quad_asi_m) & lsu_alt_space_m);
1407
 
1408
assign  lddf_maddr_not_align
1409
    = ld_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr
1410
      & ~((blk_asi_m | quad_asi_m) & lsu_alt_space_m);
1411
 
1412
// internal asi access by ld/st other than ldxa/stxa/lddfa/stdfa.
1413
wire  asi_internal_non_xdw ;
1414
 
1415
assign  asi_internal_non_xdw
1416
    = (st_inst_vld_m | ld_inst_vld_m) & lsu_alt_space_m & asi_internal_m  &
1417
      ~(dw_size & (~ldst_dbl_m | fp_ldst_m)) ; //bug4149;
1418
 
1419
 
1420
// asi related
1421
// rd-only mmu asi requiring va decode.
1422
wire    mmu_rd_only_asi_wva_m ;
1423
assign  mmu_rd_only_asi_wva_m =
1424
        ((lsu_excpctl_asi_state_m[7:0]==8'h58) & (
1425
                (lsu_ldst_va_m[7:0] == 8'h00) |  // dtag_target
1426
                (lsu_ldst_va_m[7:0] == 8'h20))) |        // dsync_far
1427
        ((lsu_excpctl_asi_state_m[7:0]==8'h50) &
1428
                (lsu_ldst_va_m[7:0] == 8'h00)) ;         // itag_target
1429
 
1430
wire  wr_to_rd_only_asi, rd_of_wr_only_asi, unimp_asi_used;
1431
 
1432
assign  wr_to_rd_only_asi =
1433
        ((mmu_rd_only_asi_wva_m |// mmu with non-unique asi
1434
        mmu_rd_only_asi_m |     // mmu with unique asi
1435
        rd_only_asi_m)          // non mmu
1436
         &  st_inst_vld_m & lsu_alt_space_m) |
1437
        wr_to_strm_sync_m ;     // Bug 5399
1438
 
1439
assign  rd_of_wr_only_asi = wr_only_asi_m &  ld_inst_vld_m & lsu_alt_space_m ;
1440
assign  unimp_asi_used = unimp_asi_m &  (ld_inst_vld_m | st_inst_vld_m) & lsu_alt_space_m ;
1441
 
1442
   wire asi_related_trap_m ; // asi_related_trap_g;
1443
 
1444
assign  asi_related_trap_m = wr_to_rd_only_asi | rd_of_wr_only_asi | unimp_asi_used | asi_internal_non_xdw ;
1445
 
1446
// Illegal page size for tlb fill
1447
 
1448
wire    [2:0]    pgszr_m,pgszv_m ;
1449
dff #(6)   pgsz_stgm (
1450
        .din    ({lsu_sun4r_pgsz_b2t0_e[2:0],lsu_sun4v_pgsz_b2t0_e[2:0]}),
1451
        .q      ({pgszr_m[2:0],pgszv_m[2:0]}),
1452
        .clk    (clk),
1453
        .se     (se),       .si (),          .so ()
1454
        );
1455
 
1456
wire    [2:0]    pgsz_m ;
1457
 
1458
assign  pgsz_m[2:0] = lsu_sun4r_va_m_l ? pgszv_m[2:0] : pgszr_m[2:0] ;
1459
 
1460
wire    illgl_pgsz_m ;
1461
assign  illgl_pgsz_m =
1462
        (~pgsz_m[2] &  pgsz_m[1] & ~pgsz_m[0]) | // 010 ; 512K
1463
        ( pgsz_m[2] & ~pgsz_m[1] & ~pgsz_m[0]) | // 100 ; 32M
1464
        ( pgsz_m[2] &  pgsz_m[1] & ~pgsz_m[0]) | // 110 ; 2G
1465
        ( pgsz_m[2] &  pgsz_m[1] &  pgsz_m[0]) ; // 111 ; 16G
1466
 
1467
wire    ifill_tlb_asi_m,dfill_tlb_asi_m ;
1468
dff #(2)   idfill_stgm (
1469
        .din    ({ifill_tlb_asi_e,dfill_tlb_asi_e}),
1470
        .q      ({ifill_tlb_asi_m,dfill_tlb_asi_m}),
1471
        .clk    (clk),
1472
        .se     (se),       .si (),          .so ()
1473
        );
1474
 
1475
assign  tlb_illgl_pgsz_m =
1476
        (ifill_tlb_asi_m | dfill_tlb_asi_m) & st_inst_vld_m & lsu_alt_space_m & illgl_pgsz_m ;
1477
 
1478
wire  [8:0] early_ttype_m,early_ttype_g ;
1479
wire    early_trap_vld_m, early_trap_vld_g ;
1480
assign  early_trap_vld_m =
1481
                        stdf_maddr_not_align | lddf_maddr_not_align |
1482
                        mem_addr_not_align ;
1483
 
1484
wire    lsu_tlu_misalign_addr_ldst_atm_m ;
1485
assign  lsu_tlu_misalign_addr_ldst_atm_m = early_trap_vld_m ;
1486
 
1487
// mux select order must be maintained
1488
assign  early_ttype_m[8:0] =
1489
      stdf_maddr_not_align ? 9'h036 :
1490
        lddf_maddr_not_align ? 9'h035 :
1491
           mem_addr_not_align ?  9'h034 : 9'hxxx ;
1492
 
1493
dff #(10)   etrp_stgg (
1494
        .din    ({early_ttype_m[8:0],early_trap_vld_m}),
1495
        .q      ({early_ttype_g[8:0],early_trap_vld_g}),
1496
        .clk    (clk),
1497
        .se     (se),       .si (),          .so ()
1498
        );
1499
 
1500
wire daccess_excptn_early_m, daccess_excptn_early_g ;
1501
 
1502
wire atm_access_w_nc_byp_m,atm_access_w_nc_byp_g ;
1503
assign atm_access_w_nc_byp_m =
1504
atomic_m & dtlb_bypass_m & (lsu_ldst_va_b39_m & ~pstate_am_m) ;
1505
                                                //Bug 5050
1506
 
1507
dff   atmbyp_stgg (
1508
        .din    (atm_access_w_nc_byp_m),
1509
        .q      (atm_access_w_nc_byp_g),
1510
        .clk    (clk),
1511
        .se     (se),       .si (),          .so ()
1512
        );
1513
 
1514
assign daccess_excptn_early_m =
1515
    asi_related_trap_m | tlb_daccess_excptn_m |
1516
    spv_use_hpv_m |
1517
    atm_access_w_nc_byp_m ; // Bug 4281.
1518
 
1519
dff  #(1) dearly_stgg (
1520
        .din    (daccess_excptn_early_m),
1521
        .q      (daccess_excptn_early_g),
1522
        .clk    (clk),
1523
        .se     (se),       .si (),          .so ()
1524
        );
1525
 
1526
   wire daccess_excptn;
1527
 
1528
assign  daccess_excptn =
1529
    (priv_pg_usr_mode | as_if_usr_priv_pg | nfo_pg_nonnfo_asi |
1530
      atm_access_w_nc ) & tlb_tte_vld_g |
1531
      illegal_asi_trap_g | daccess_excptn_early_g | atm_access_unsup_asi | //bug4622
1532
        spec_access_epage ;
1533
 
1534
   wire [3:0] lsu_nceen_d1;
1535
dff #(4)  nceen_d1_ff (
1536
        .din    (ifu_lsu_nceen[3:0]),
1537
        .q      (lsu_nceen_d1[3:0]),
1538
        .clk    (clk),
1539
        .se     (se),       .si (),          .so ()
1540
        );
1541
 
1542
wire nceen_pipe_g ;
1543
assign  nceen_pipe_g =
1544
  (thread0_g & lsu_nceen_d1[0]) | (thread1_g & lsu_nceen_d1[1]) |
1545
  (thread2_g & lsu_nceen_d1[2]) | (thread3_g & lsu_nceen_d1[3]) ;
1546
 
1547
 // correctible dtlb data parity error on cam will cause dmmu miss.
1548
// prefetch will rely on the ld_inst_vld/st_inst_vld not being asserted
1549
// to prevent mmu_miss from being signalled if prefetch does not translate.
1550
// Timing Change : Remove data perror from dmmu_miss ; to be treated as disrupting trap.
1551
   wire dmmu_miss_m, dmmu_miss_m_d1;
1552
 
1553
assign dmmu_miss_m =
1554
  ~tlb_cam_hit & ~dtlb_bypass_m &
1555
  (ld_inst_vld_m | st_inst_vld_m) &
1556
  ~(lda_internal_m | sta_internal_m | early_trap_vld_m) ;
1557
 
1558
dff #(1)  dmmu_miss_stgg (
1559
        .din    (dmmu_miss_m),
1560
        .q      (dmmu_miss_m_d1),
1561
        .clk    (clk),
1562
        .se     (se),       .si (),          .so ()
1563
        );
1564
//need lsu_inst_vld_w ??
1565
   wire dmmu_miss_g;
1566
 
1567
   assign dmmu_miss_g = dmmu_miss_m_d1 & lsu_inst_vld_w;
1568
 
1569
 
1570
wire [8:0] dmiss_type ;
1571
   wire    cam_real_g;
1572
 
1573
dff #(1) cam_real_stgg (
1574
   .din (cam_real_m),
1575
   .q   (cam_real_g),
1576
   .clk    (clk),
1577
   .se     (se),       .si (),          .so ()
1578
   );
1579
 assign        dmiss_type[8:0] = cam_real_g ? 9'h03f : 9'h068 ;
1580
 
1581
// two wtchpt matches
1582
//assign  lsu_tlu_ttype_m2[8:0] = 
1583
//  early_trap_vld_g ? early_ttype_g[8:0] : 
1584
//    priv_action ? 9'h037 : 
1585
//      va_wtchpt_match ? 9'h062 :
1586
//        daccess_excptn ? 9'h030 : 
1587
//          dmmu_miss_g ? dmiss_type[8:0] :  // dmmu_miss
1588
//            daccess_error ? 9'h032 : 
1589
//              daccess_prot ? 9'h06c :
1590
//                    spubyp_trap_active_g ? {3'b000,spubyp_ttype[5:0]} : // should be no other tttype to compare to. 
1591
//                  9'bx_xxxx_xxxx ;
1592
 
1593
wire early_trap_vld_sel, priv_action_sel, va_wtchpt_match_sel, daccess_excptn_sel, dmmu_miss_sel,
1594
     daccess_prot_sel ;
1595
 
1596
// Need to maintain this order in selects. Based on priority of traps    
1597
   assign early_trap_vld_sel = early_trap_vld_g;
1598
   assign priv_action_sel = ~early_trap_vld_sel & priv_action;
1599
   assign va_wtchpt_match_sel = ~early_trap_vld_sel & ~priv_action_sel & va_wtchpt_match;
1600
   assign daccess_excptn_sel = ~early_trap_vld_sel & ~priv_action_sel & ~va_wtchpt_match_sel &
1601
                               daccess_excptn;
1602
   assign dmmu_miss_sel = ~early_trap_vld_sel & ~priv_action_sel & ~va_wtchpt_match_sel &
1603
                          ~daccess_excptn_sel & dmmu_miss_g;
1604
 
1605
   assign daccess_prot_sel = ~early_trap_vld_sel & ~priv_action_sel & ~va_wtchpt_match_sel &
1606
                             ~daccess_excptn_sel & ~dmmu_miss_sel & daccess_prot;
1607
 
1608
assign  lsu_tlu_ttype_m2[8:0] =
1609
          ({9{early_trap_vld_sel}}     &  early_ttype_g[8:0]) |
1610
          ({9{priv_action_sel}}        &  9'h037            ) |
1611
          ({9{va_wtchpt_match_sel}}    &  9'h062            ) |
1612
          ({9{daccess_excptn_sel}}     &  9'h030            ) |
1613
          ({9{dmmu_miss_sel}}          &  dmiss_type[8:0]   ) |
1614
          ({9{daccess_prot_sel}}       &  9'h06c            ) ;
1615
 
1616
assign  lsu_tlu_ttype_vld_m2 =  dmmu_miss_g | daccess_excptn | daccess_prot |
1617
        priv_action | early_trap_vld_g  |
1618
              va_wtchpt_match ;
1619
 
1620
assign lsu_ttype_vld_m2 = lsu_tlu_ttype_vld_m2 | defr_trp_taken ;  //to stb_rwctl
1621
 
1622
assign lsu_ttype_vld_m2_bf1 =    lsu_ttype_vld_m2; //to dctl, qctl1
1623
 
1624
wire    squash_priority_g ; // Bug 4678
1625
assign  squash_priority_g = priv_action | early_trap_vld_g | va_wtchpt_match ;
1626
 
1627
assign  lsu_tlu_dmmu_miss_g = dmmu_miss_g & ~squash_priority_g ;
1628
assign  lsu_tlu_priv_violtn_g = (priv_pg_usr_mode | as_if_usr_priv_pg) & tlb_tte_vld_g ;
1629
wire    dmmu_va_oor_g ;
1630
assign  lsu_tlu_daccess_excptn_g =
1631
(daccess_excptn | dmmu_va_oor_g  // Bug 5036
1632
| tlu_priv_trap_g) & ~squash_priority_g ;
1633
 
1634
// prioritize daccess_excptn higher than daccess_prot. This may
1635
// be a critical path which needs to be resolved -> qual. now
1636
// in mmu.
1637
//assign  lsu_tlu_daccess_prot_g = daccess_prot ;
1638
   wire daccess_prot_g;
1639
assign  daccess_prot_g = daccess_prot &
1640
        ~(tlu_priv_trap_g | daccess_excptn | squash_priority_g) ;
1641
assign  lsu_tlu_daccess_prot_g = daccess_prot & ~squash_priority_g ; // Bug 5336.
1642
assign  lsu_tlu_priv_action_g = priv_action ;
1643
//assign  lsu_tlu_tte_ebit_g = tlb_rd_tte_data_ebit & tlb_tte_vld_g ;
1644
wire    lsu_tlu_tte_ebit_g;
1645
assign  lsu_tlu_tte_ebit_g = pg_with_ebit ;
1646
//assign  lsu_tlu_spec_access_epage_g = spec_access_epage & tlb_tte_vld_g ; // page with side effects
1647
wire    lsu_tlu_spec_access_epage_g ;
1648
assign  lsu_tlu_spec_access_epage_g = spec_access_epage ; // page with side effects
1649
wire    lsu_tlu_uncache_atomic_g;
1650
assign  lsu_tlu_uncache_atomic_g =
1651
        (atm_access_w_nc & tlb_tte_vld_g) |
1652
        (atm_access_w_nc_byp_g) ;
1653
// Define illegal asi actions
1654
// see sfsr description - excludes cases where 02 and 04 are set for ftype !!!
1655
wire lsu_tlu_flt_ld_nfo_pg_g;
1656
assign  lsu_tlu_flt_ld_nfo_pg_g = nfo_pg_nonnfo_asi & tlb_tte_vld_g ;
1657
 
1658
wire illgl_asi_action_pre_m,illgl_asi_action_pre_g ;
1659
assign  illgl_asi_action_pre_m = asi_related_trap_m | tlb_daccess_excptn_m | illegal_asi_trap_m | spv_use_hpv_m ; // bug 4181; //bug3660        
1660
 
1661
dff  illglasi_g (
1662
        .din    (illgl_asi_action_pre_m),
1663
        .q      (illgl_asi_action_pre_g),
1664
        .clk    (clk),
1665
        .se     (se),       .si (),          .so ()
1666
        );
1667
 
1668
wire lsu_tlu_illegal_asi_action_g;
1669
assign  lsu_tlu_illegal_asi_action_g =
1670
atm_access_unsup_asi | (illgl_asi_action_pre_g) & // Bug 4825
1671
~(lsu_tlu_spec_access_epage_g | lsu_tlu_uncache_atomic_g) ;
1672
//(illgl_asi_action_pre_g | (atm_access_unsup_asi)) & 
1673
//~(lsu_tlu_spec_access_epage_g | lsu_tlu_uncache_atomic_g) ;
1674
 
1675
//=========================================================================================
1676
//  Generate Flush Pipe
1677
//=========================================================================================
1678
 
1679
 
1680
assign  other_flush_pipe_w =
1681
tlu_early_flush_pipe_w | (lsu_tlu_ttype_vld_m2 & lsu_inst_vld_w) |
1682
defr_trp_taken ;        // deferred trap.
1683
assign  lsu_ifu_flush_pipe_w = other_flush_pipe_w ;
1684
assign  lsu_exu_flush_pipe_w = other_flush_pipe_w ;
1685
assign  lsu_mmu_flush_pipe_w = other_flush_pipe_w ;
1686
assign  lsu_ffu_flush_pipe_w = other_flush_pipe_w ;
1687
 
1688
 
1689
assign  lsu_flush_pipe_w = other_flush_pipe_w | ifu_lsu_flush_w ;
1690
 
1691
//assign        lsu_qctl1_flush_pipe_w = lsu_flush_pipe_w ;
1692
//assign        lsu_stbctl_flush_pipe_w = lsu_flush_pipe_w ;
1693
//assign        lsu_stbrwctl_flush_pipe_w = lsu_flush_pipe_w ;
1694
 
1695
//=========================================================================================
1696
//  Early Traps to SPU
1697
//=========================================================================================
1698
 
1699
// detect st to ma/strm sync - data-access exception.
1700
//wire  st_to_sync_dexcp_m ;
1701
// qual with alt_space not required - spu will do it.
1702
//assign        st_to_sync_dexcp_m = // Bug 5704
1703
//strm_asi_m & ((lsu_ldst_va_m[7:0] == 8'ha0) | (lsu_ldst_va_m[7:0] == 8'h68)) & st_inst_vld_m ;  
1704
 
1705
wire    early_flush_m ;
1706
 
1707
assign  early_flush_m =
1708
        (atomic_m & lsu_alt_space_m) |  // Bug 4650 - alt-space atomics should flush.
1709
        priv_action_m           |
1710
        early_trap_vld_m        |       // mem-addr-not-aligned.
1711
        illegal_asi_trap_m      |       // for fp non use of internal asi.
1712
        //st_to_sync_dexcp_m    |       // Bug 5742
1713
        //wr_to_strm_sync_m     |       // Bug 5890 - redundant - make room.
1714
        defr_trp_taken_m_din    |       // Bug 5890
1715
        daccess_excptn_early_m  ;
1716
        /*asi_related_trap_m    |       // Bug 2592
1717
        spv_use_hpv_m       |
1718
        wr_to_strm_sync_m;*/
1719
 
1720
 
1721
dff  eflushspu_g (
1722
        .din    (early_flush_m),
1723
        .q      (lsu_spu_early_flush_g),
1724
        .clk    (clk),
1725
        .se     (se),       .si (),          .so ()
1726
        );
1727
 
1728
dff  eflushspu2_g (
1729
        .din    (early_flush_m),
1730
        .q      (lsu_local_early_flush_g),
1731
        .clk    (clk),
1732
        .se     (se),       .si (),          .so ()
1733
        );
1734
 
1735
dff  eflushtlu_g (
1736
        .din    (early_flush_m),
1737
        .q      (lsu_tlu_early_flush_w),
1738
        .clk    (clk),
1739
        .se     (se),       .si (),          .so ()
1740
        );
1741
 
1742
dff  eflushtlu2_g (
1743
        .din    (early_flush_m),
1744
        .q      (lsu_tlu_early_flush2_w),
1745
        .clk    (clk),
1746
        .se     (se),       .si (),          .so ()
1747
        );
1748
 
1749
 
1750
//=========================================================================================
1751
//  Parity Error Checking
1752
//=========================================================================================
1753
 
1754
// DTLB Parity Errors. 
1755
// ASI read of Tag/Data :
1756
//  - uncorrectible error
1757
//  - logging occurs on read.
1758
//  - precise trap is taken when ldxa completes if nceen set.
1759
//  - if not set then ldxa is allowed to complete.
1760
// CAM Read of Tag/Data :
1761
//  - correctible if locked bit not set.
1762
//    - takes disrupting trap later.
1763
//  - uncorrectible if locked bit set.
1764
//  - both are treated as precise traps.
1765
//  - if errors not enabled, then load completes as if hit in L1.
1766
// ** TLB error will cause a trap which will preclude concurrent dcache,dtag  **
1767
// ** parity errors.                **
1768
 
1769
// cam related tte data parity error - error assumed correctible if locked
1770
// bit is not set. Will cause a dmmu_miss for correction.
1771
// qualify with cam_hit ??
1772
wire  tte_data_perror_unc ;
1773
 
1774
assign  lsu_tlb_perr_ld_rq_kill_w =
1775
        //tte_data_perror_corr | (tte_data_perror_unc & nceen_pipe_g) ;
1776
        (tte_data_perror_unc & nceen_pipe_g) ;
1777
 
1778
// correctible dtlb errors no longer supported.
1779
/*assign  tte_data_perror_corr =
1780
  tte_data_parity_error & ~tlb_rd_tte_data_locked & tlb_tte_vld_g &
1781
  (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w ;*/
1782
 
1783
// caused for both locked and unlocked entries.
1784
assign  tte_data_perror_unc  =
1785
  //tte_data_parity_error &  tlb_rd_tte_data_locked & tlb_tte_vld_g & 
1786
  tte_data_parity_error &  tlb_tte_vld_g &
1787
  (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w &
1788
  ~lsu_flush_pipe_w ;
1789
 
1790
// Asi rd parity error detection
1791
wire  asi_tte_data_perror,asi_tte_tag_perror ;
1792
 
1793
assign  asi_tte_data_perror =
1794
  tte_data_parity_error & data_rd_vld_g ;
1795
// For data tte read, both tag and data arrays are read.
1796
// Parity error on asi read of tag should not be reported.
1797
assign  asi_tte_tag_perror =
1798
  tte_tag_parity_error & tag_rd_vld_g & ~data_rd_vld_g ;
1799
 
1800
wire    st_dtlb_perror ;
1801
assign  st_dtlb_perror =   tte_data_parity_error &  tlb_tte_vld_g &
1802
   st_inst_vld_unflushed & lsu_inst_vld_w ;
1803
 // ~lsu_flush_pipe_w ;
1804
 
1805
wire    cancel_err_flush ;
1806
assign  cancel_err_flush = // Bug 5165
1807
((priv_pg_usr_mode | nfo_pg_nonnfo_asi |
1808
atm_access_w_nc) & tlb_tte_vld_g) | // bug6052/eco6620
1809
spec_access_epage |
1810
nonwr_pg_st_access ;
1811
 
1812
// Bug 6877
1813
wire squash_err ;
1814
assign squash_err =
1815
// assume always higher priority. BE - share common terms elsewhere.
1816
tlu_early_flush_pipe_w | defr_trp_taken | ifu_lsu_flush_w |
1817
// isolate to daccess_excptn/daccess_prot as per Bug 5165.
1818
(lsu_tlu_ttype_vld_m2 & ~(daccess_excptn_sel | daccess_prot_sel)) |
1819
((daccess_excptn_sel | daccess_prot_sel) & ~cancel_err_flush) ;
1820
 
1821
wire    tlb_data_su_g ;
1822
assign  tlb_data_su_g =   st_dtlb_perror & ~atomic_g &
1823
  ~squash_err ;
1824
  //~(lsu_flush_pipe_w & ~cancel_err_flush) ; // Bug 6877
1825
 
1826
wire    ld_dtlb_perror ;
1827
assign  ld_dtlb_perror =   tte_data_parity_error &  tlb_tte_vld_g &
1828
  ld_inst_vld_unflushed  & lsu_inst_vld_w &
1829
  ~squash_err ;
1830
 
1831
wire  tlb_data_ue_g ;
1832
assign  tlb_data_ue_g =
1833
        ld_dtlb_perror |        // synchronous to pipe - xslate ; ue is for ld now.
1834
        lsu_tlb_asi_data_perr_g ; // asychronous to pipe - asi rd
1835
 
1836
/* Simplify for Bug 5888.
1837
wire    st_noatom_dtlb_perr ; // atomics not represented.
1838
assign  st_noatom_dtlb_perr = st_dtlb_perror & ~lsu_flush_pipe_w & ~atomic_g ;
1839
wire    st_noatom_dtlb_perr_en ;
1840
assign  st_noatom_dtlb_perr_en = st_noatom_dtlb_perr & nceen_pipe_g ; */
1841
wire    st_noatom_dtlb_perr_en ;
1842
wire    st_dtlb_perr_en ;
1843
assign  st_noatom_dtlb_perr_en = st_dtlb_perr_en & ~atomic_g ;
1844
 
1845
// rm corr err. reporting
1846
dff  #(3) terr_stgd1 (
1847
        .din    ({tlb_data_su_g,tlb_data_ue_g,lsu_tlb_asi_tag_perr_g}),
1848
        //.din    ({st_noatom_dtlb_perr,tlb_data_ue_g,lsu_tlb_asi_tag_perr_g}),
1849
        .q      ({lsu_ifu_tlb_data_su,lsu_ifu_tlb_data_ue,lsu_ifu_tlb_tag_ue}),
1850
        .clk    (clk),
1851
        .se     (se),       .si (),          .so ()
1852
        );
1853
 
1854
// If st dtlb parity error detected, then need to invalidate st in stb.
1855
// Considered unrecoverable for the thread itself.
1856
 
1857
assign  st_dtlb_perr_en = st_dtlb_perror & ~lsu_flush_pipe_w & nceen_pipe_g ;
1858
 
1859
// Kill will happen for atomics also.
1860
//assign        lsu_exu_st_dtlb_perr_g = st_dtlb_perr_en ;
1861
assign  lsu_exu_st_dtlb_perr_g = st_noatom_dtlb_perr_en ; // Bug 5888
1862
 
1863
assign  lsu_ffu_st_dtlb_perr_g = st_noatom_dtlb_perr_en ; // Bug 5910/ECO 6529
1864
 
1865
assign  lsu_st_dtlb_perr_g[0] = st_dtlb_perr_en & thread0_g ;
1866
assign  lsu_st_dtlb_perr_g[1] = st_dtlb_perr_en & thread1_g ;
1867
assign  lsu_st_dtlb_perr_g[2] = st_dtlb_perr_en & thread2_g ;
1868
assign  lsu_st_dtlb_perr_g[3] = st_dtlb_perr_en & thread3_g ;
1869
 
1870
//==========================================================================
1871
// DEFERRED TRAP DUE TO STORE 
1872
//==========================================================================
1873
 
1874
// Cases :
1875
// defr_trp_m=1,ifu_flush_w=0. 
1876
//      - defr_trp is generated.
1877
//      - next inst will not take redundant deferred trap as
1878
//      its inst_vld will be annulled by trap flush.
1879
// defr_trp_m=1,ifu_flush_w=1. 
1880
//      - defr_trp is generated. TLU annuls.
1881
//      - Other units see redundant defr_trp flush ORed with ifu_flush_w.
1882
//      - next inst will not take redundant deferred trap as
1883
//      its inst_vld will be annulled by ifu_flush_w .
1884
 
1885
 
1886
// Log Deferred trap. Take on next available inst from thread.
1887
// Inst vld must be qualified with flush.
1888
 
1889
wire    st_defr_trp_en0,st_defr_trp_en1,st_defr_trp_en2,st_defr_trp_en3 ;
1890
wire    st_defr_trp0,st_defr_trp1,st_defr_trp2,st_defr_trp3 ;
1891
 
1892
assign  st_defr_trp_en0 = st_noatom_dtlb_perr_en & thread0_g ;
1893
assign  st_defr_trp_en1 = st_noatom_dtlb_perr_en & thread1_g ;
1894
assign  st_defr_trp_en2 = st_noatom_dtlb_perr_en & thread2_g ;
1895
assign  st_defr_trp_en3 = st_noatom_dtlb_perr_en & thread3_g ;
1896
 
1897
wire    stpend_rst0_m,stpend_rst1_m,stpend_rst2_m,stpend_rst3_m;
1898
wire    stpend_rst0_w,stpend_rst1_w,stpend_rst2_w,stpend_rst3_w;
1899
wire    stpend_rst0,stpend_rst1,stpend_rst2,stpend_rst3;
1900
assign  stpend_rst0_m = reset |
1901
((st_defr_trp0 | st_defr_trp_en0) & thread0_m & flush_w_inst_vld_m);
1902
assign  stpend_rst1_m = reset |
1903
((st_defr_trp1 | st_defr_trp_en1) & thread1_m & flush_w_inst_vld_m);
1904
assign  stpend_rst2_m = reset |
1905
((st_defr_trp2 | st_defr_trp_en2) & thread2_m & flush_w_inst_vld_m);
1906
assign  stpend_rst3_m = reset |
1907
((st_defr_trp3 | st_defr_trp_en3) & thread3_m & flush_w_inst_vld_m);
1908
 
1909
// Postphone reset by a cycle - 4916
1910
dff #(4)  stpend_d1 (
1911
           .din    ({stpend_rst3_m,stpend_rst2_m,stpend_rst1_m,stpend_rst0_m}),
1912
           .q      ({stpend_rst3_w,stpend_rst2_w,stpend_rst1_w,stpend_rst0_w}),
1913
           .clk    (clk),
1914
           .se     (se),       .si (),          .so ()
1915
           );
1916
 
1917
// Prevent reset if inst is flushed by ifu.
1918
assign  stpend_rst3 = stpend_rst3_w & ~ifu_lsu_flush_w ;
1919
assign  stpend_rst2 = stpend_rst2_w & ~ifu_lsu_flush_w ;
1920
assign  stpend_rst1 = stpend_rst1_w & ~ifu_lsu_flush_w ;
1921
assign  stpend_rst0 = stpend_rst0_w & ~ifu_lsu_flush_w ;
1922
 
1923
dffre #(1)  deftrp_t0 (
1924
           .din    (st_defr_trp_en0),
1925
           .q      (st_defr_trp0),
1926
           .rst    (stpend_rst0),
1927
           .en     (st_defr_trp_en0),
1928
           .clk    (clk),
1929
           .se     (se),       .si (),          .so ()
1930
           );
1931
 
1932
dffre #(1)  deftrp_t1 (
1933
           .din    (st_defr_trp_en1),
1934
           .q      (st_defr_trp1),
1935
           .rst    (stpend_rst1),
1936
           .en     (st_defr_trp_en1),
1937
           .clk    (clk),
1938
           .se     (se),       .si (),          .so ()
1939
           );
1940
 
1941
dffre #(1)  deftrp_t2 (
1942
           .din    (st_defr_trp_en2),
1943
           .q      (st_defr_trp2),
1944
           .rst    (stpend_rst2),
1945
           .en     (st_defr_trp_en2),
1946
           .clk    (clk),
1947
           .se     (se),       .si (),          .so ()
1948
           );
1949
 
1950
dffre #(1)  deftrp_t3 (
1951
           .din    (st_defr_trp_en3),
1952
           .q      (st_defr_trp3),
1953
           .rst    (stpend_rst3),
1954
           .en     (st_defr_trp_en3),
1955
           .clk    (clk),
1956
           .se     (se),       .si (),          .so ()
1957
           );
1958
 
1959
// Deferred trap can be taken on any instruction.
1960
// Selection is based on next thread available.
1961
 
1962
//instruction n+2, and the following...
1963
 
1964
assign  defr_trp_taken_m =
1965
        //ifu_tlu_inst_vld_m & (
1966
        flush_w_inst_vld_m & (  // <= rely of flush by defr-trp to clear
1967
                                // pended defr-trp
1968
        (st_defr_trp0 & thread0_m) |
1969
        (st_defr_trp1 & thread1_m) |
1970
        (st_defr_trp2 & thread2_m) |
1971
        (st_defr_trp3 & thread3_m)) ;
1972
 
1973
assign defr_trp_taken_byp =
1974
        //ifu_tlu_inst_vld_m & (
1975
        flush_w_inst_vld_m & (
1976
        (st_defr_trp_en0 & thread0_m) |
1977
        (st_defr_trp_en1 & thread1_m) |
1978
        (st_defr_trp_en2 & thread2_m) |
1979
        (st_defr_trp_en3 & thread3_m) );
1980
 
1981
 
1982
assign defr_trp_taken_m_din = defr_trp_taken_m |  defr_trp_taken_byp;
1983
 
1984
dff #(1) defr_trp_taken_stgg (
1985
     .din (defr_trp_taken_m_din),
1986
     .q   (defr_trp_taken),
1987
     .clk    (clk),
1988
     .se     (se),       .si (),          .so ()
1989
    );
1990
 
1991
assign  lsu_defr_trp_taken_g = defr_trp_taken ;
1992
assign  lsu_tlu_defr_trp_taken_g = defr_trp_taken ;
1993
assign  lsu_mmu_defr_trp_taken_g = defr_trp_taken ;
1994
 
1995
//==========================================================================
1996
// DSFSR/SFAR WR 
1997
//==========================================================================
1998
 
1999
 
2000
 
2001
wire    [3:0]    pstate_cle,pstate_am ;
2002
// flop'n use to prevent timing path.
2003
dff #(8)  cle_stg (
2004
        .din    ({tlu_lsu_pstate_cle[3:0],tlu_lsu_pstate_am[3:0]}),
2005
        .q      ({pstate_cle[3:0],pstate_am[3:0]}),
2006
        .clk    (clk),
2007
        .se     (se),       .si (),          .so ()
2008
        );
2009
 
2010
wire    pstate_cle_m ;
2011
assign  pstate_cle_m =
2012
        (thread0_m & pstate_cle[0]) |
2013
        (thread1_m & pstate_cle[1]) |
2014
        (thread2_m & pstate_cle[2]) |
2015
        (thread3_m & pstate_cle[3]);
2016
 
2017
wire    [3:0]    dsfsr_asi_sel_m ;
2018
wire    prim_asi_sel ;
2019
assign  prim_asi_sel =
2020
exu_tlu_misalign_addr_jmpl_rtn_m | (lsu_tlu_nonalt_ldst_m & ~lsu_nonalt_nucl_access_m) ;
2021
assign  dsfsr_asi_sel_m[0] =  // ASI_PRIMARY
2022
                 prim_asi_sel & ~pstate_cle_m;
2023
// Does asi_primary_little make sense for jmpl/return ?
2024
assign  dsfsr_asi_sel_m[1] =  // ASI_PRIMARY_LITTLE
2025
                prim_asi_sel  &  pstate_cle_m;
2026
assign  dsfsr_asi_sel_m[2] =  // ASI_NUCLEUS
2027
                lsu_nonalt_nucl_access_m &  ~pstate_cle_m;
2028
assign  dsfsr_asi_sel_m[3] =  // ASI_NUCLEUS_LITTLE
2029
                lsu_nonalt_nucl_access_m &   pstate_cle_m;
2030
/*assign  dsfsr_asi_sel_m[4] =  // assigned asi
2031
        ~(exu_tlu_misalign_addr_jmpl_rtn_m | lsu_tlu_nonalt_ldst_m);*/
2032
 
2033
wire    [7:0]    asi_state_g ;
2034
// flop'n use to prevent timing path.
2035
dff #(8)  asistate_stgg (
2036
        .din    (lsu_excpctl_asi_state_m[7:0]),
2037
        .q      (asi_state_g[7:0]),
2038
        .clk    (clk),
2039
        .se     (se),       .si (),          .so ()
2040
        );
2041
 
2042
wire    [7:0]    dsfsr_asi_g ;
2043
wire    [3:0]    dsfsr_asi_sel_g ;
2044
 
2045
/*assign dsfsr_asi_g[7:0] =(dsfsr_asi_sel_g[0] ? 8'h80 : 8'h00) |
2046
                         (dsfsr_asi_sel_g[1] ? 8'h88 : 8'h00) |
2047
                         (dsfsr_asi_sel_g[2] ? asi_state_g[7:0] : 8'h00);*/
2048
// Bug 4212 - spec problem
2049
assign dsfsr_asi_g[7:0] =(dsfsr_asi_sel_g[0] ? 8'h80 :
2050
                                (dsfsr_asi_sel_g[1] ? 8'h88 :
2051
                                        (dsfsr_asi_sel_g[2] ? 8'h04 :
2052
                                                (dsfsr_asi_sel_g[3] ?  8'h0C : asi_state_g[7:0]))));
2053
 
2054
assign  pstate_am_m =
2055
        (thread0_m & pstate_am[0]) |
2056
        (thread1_m & pstate_am[1]) |
2057
        (thread2_m & pstate_am[2]) |
2058
        (thread3_m & pstate_am[3]);
2059
 
2060
assign  dmmu_va_oor_m = exu_tlu_va_oor_m & ~pstate_am_m & lsu_memref_m & ~lsu_squash_va_oor_m;
2061
 
2062
wire    [3:0]     dsfsr_flt_vld;
2063
dff #(4)  fltvld_stgd1 (
2064
        .din    (tlu_dsfsr_flt_vld[3:0]),
2065
        .q      (dsfsr_flt_vld[3:0]),
2066
        .clk    (clk),
2067
        .se     (se),       .si (),          .so ()
2068
        );
2069
 
2070
wire    dsfsr_flt_vld_m ;
2071
assign  dsfsr_flt_vld_m =
2072
        (thread0_m & dsfsr_flt_vld[0]) |
2073
        (thread1_m & dsfsr_flt_vld[1]) |
2074
        (thread2_m & dsfsr_flt_vld[2]) |
2075
        (thread3_m & dsfsr_flt_vld[3]);
2076
 
2077
wire    ldst_xslate_g,flsh_inst_g,dsfsr_flt_vld_g,dsfsr_wr_op_g ;
2078
wire    misalign_addr_jmpl_rtn_g,misalign_addr_ldst_atm_g ;
2079
wire    [2:0]    dsfsr_ctxt_sel ;
2080
 
2081
// flop flt_vld and use
2082
dff #(14)  dsfsr_stgg (
2083
        .din    ({dsfsr_asi_sel_m[3:0],dmmu_va_oor_m,// memref_m,
2084
                lsu_tlu_xslating_ldst_m,lsu_flsh_inst_m,lsu_tlu_ctxt_sel_m[2:0],
2085
                dsfsr_flt_vld_m,lsu_tlu_write_op_m,exu_tlu_misalign_addr_jmpl_rtn_m,
2086
                lsu_tlu_misalign_addr_ldst_atm_m}),
2087
        .q      ({dsfsr_asi_sel_g[3:0],dmmu_va_oor_g,ldst_xslate_g,// memref_g,
2088
                flsh_inst_g,dsfsr_ctxt_sel[2:0],dsfsr_flt_vld_g, dsfsr_wr_op_g,
2089
                misalign_addr_jmpl_rtn_g,misalign_addr_ldst_atm_g}),
2090
        .clk    (clk),
2091
        .se     (se),       .si (),          .so ()
2092
        );
2093
 
2094
// To be set only for data_access_exception traps - only one can be
2095
// reported at any time.        
2096
 
2097
wire    [6:0]    dsfsr_ftype_g ;
2098
assign  dsfsr_ftype_g[6] = 1'b0;
2099
assign  dsfsr_ftype_g[5] = dmmu_va_oor_g | lsu_tlu_wtchpt_trp_g;
2100
assign  dsfsr_ftype_g[4] = lsu_tlu_flt_ld_nfo_pg_g;
2101
assign  dsfsr_ftype_g[3] = lsu_tlu_illegal_asi_action_g
2102
                        | tlu_priv_trap_g ; // Bug 4799
2103
//assign  dsfsr_ftype_g[3] = lsu_tlu_illegal_asi_action_g | tlu_mmu_sync_data_excp_g;
2104
assign  dsfsr_ftype_g[2] = (lsu_tlu_uncache_atomic_g & ~atm_access_unsup_asi);
2105
assign  dsfsr_ftype_g[1] = lsu_tlu_spec_access_epage_g;
2106
assign  dsfsr_ftype_g[0] = lsu_tlu_priv_violtn_g;
2107
 
2108
wire    dsfsr_side_effect_g ;
2109
assign  dsfsr_side_effect_g = lsu_tlu_tte_ebit_g & (ldst_xslate_g | flsh_inst_g);
2110
 
2111
// Fault Type based on Priority Encoding of Traps
2112
wire    [6:0]    dsfsr_pe_ftype_g ;
2113
wire    dsfsr_ftype_zero ;
2114
// Is this needed ? Doesn't it default to zero ?
2115
assign  dsfsr_pe_ftype_g[6:0] = dsfsr_ftype_zero ? 7'h00 : dsfsr_ftype_g[6:0];
2116
 
2117
// set to 11 when the access does not have a translating asi.
2118
wire    [1:0]    dsfsr_ctxt_g ;
2119
assign  dsfsr_ctxt_g[1:0] =
2120
        dsfsr_ctxt_sel[0] ? 2'b00 :
2121
                dsfsr_ctxt_sel[1] ? 2'b01 :
2122
                        dsfsr_ctxt_sel[2] ? 2'b10 : 2'b11;
2123
 
2124
 
2125
assign  lsu_dsfsr_din_g[23:0] =
2126
        {dsfsr_asi_g[7:0],
2127
        2'b0,
2128
        dsfsr_pe_ftype_g[6:0],
2129
        dsfsr_side_effect_g,
2130
        dsfsr_ctxt_g[1:0],
2131
        1'b0, // Bug 3323 - Arch change
2132
        //pstate_priv,  
2133
        dsfsr_wr_op_g,  // pipe
2134
        dsfsr_flt_vld_g,
2135
        1'b1};
2136
 
2137
// This is going to be a critical path !!!
2138
// Assume that traps in front-end cause instructions to be no`oped
2139
// further down the pipeline. Thus there is no need to qualify writes
2140
// to dsfsr with writes to isfsr
2141
wire    dsfsr_trp_wr_g ;
2142
wire    dsfsr_trp_wr_pre_m,dsfsr_trp_wr_pre_g ;
2143
 
2144
 
2145
assign  dsfsr_trp_wr_pre_m =
2146
        spv_use_hpv_m   | // Bug 3254 ; add new data-access-excp
2147
        // spec_access_epage_m | // Bug 3515
2148
        priv_action_m |
2149
        exu_tlu_misalign_addr_jmpl_rtn_m |
2150
        lsu_tlu_misalign_addr_ldst_atm_m ;
2151
 
2152
dff   dsfsrtrg_stgg (
2153
        .din    (dsfsr_trp_wr_pre_m),
2154
        .q      (dsfsr_trp_wr_pre_g),
2155
        .clk    (clk),
2156
        .se     (se),       .si (),          .so ()
2157
        );
2158
 
2159
assign  dsfsr_trp_wr_g =
2160
        ((lsu_tlu_priv_violtn_g  |
2161
        lsu_tlu_spec_access_epage_g |   // Bug 3515 - uncomment out.
2162
        lsu_tlu_uncache_atomic_g | lsu_tlu_illegal_asi_action_g |
2163
        lsu_tlu_flt_ld_nfo_pg_g  | dmmu_va_oor_g) |     // data access exceptions                       
2164
        daccess_prot |  // daccess_excptn not excluded.
2165
        lsu_tlu_wtchpt_trp_g     |      // watchpoint trap      
2166
        dsfsr_trp_wr_pre_g |
2167
        tlu_priv_trap_g                 // scratchpad/queue daccess;Bug 4799
2168
        ) &
2169
        lsu_inst_vld_w & ~(ifu_lsu_flush_w | defr_trp_taken) ; // Bug 4444,5196
2170
 
2171
assign  dsfsr_ftype_zero =
2172
        daccess_prot_g | lsu_tlu_priv_action_g | lsu_tlu_wtchpt_trp_g |
2173
        misalign_addr_jmpl_rtn_g | misalign_addr_ldst_atm_g;
2174
 
2175
// terms below can be made common. (grape)
2176
assign  lsu_dmmu_sfsr_trp_wr[0] = dsfsr_trp_wr_g & thread0_g;
2177
assign  lsu_dmmu_sfsr_trp_wr[1] = dsfsr_trp_wr_g & thread1_g;
2178
assign  lsu_dmmu_sfsr_trp_wr[2] = dsfsr_trp_wr_g & thread2_g;
2179
assign  lsu_dmmu_sfsr_trp_wr[3] = dsfsr_trp_wr_g & thread3_g;
2180
 
2181
//==========================================================================
2182
// Exception Handling End
2183
//==========================================================================
2184
 
2185
endmodule // lsu_dctl1
2186
 

powered by: WebSVN 2.1.0

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