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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [lsu_dctl.v] - Blame information for rev 105

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_dctl.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:  LSU Data Cache Control and Minor Datapath
24
//      - Tag Comparison - hit/miss.
25
*/
26
////////////////////////////////////////////////////////////////////////
27
// Global header file includes
28
////////////////////////////////////////////////////////////////////////
29
// system level definition file which contains the /*
30
/* ========== Copyright Header Begin ==========================================
31
*
32
* OpenSPARC T1 Processor File: sys.h
33
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
35
*
36
* The above named program is free software; you can redistribute it and/or
37
* modify it under the terms of the GNU General Public
38
* License version 2 as published by the Free Software Foundation.
39
*
40
* The above named program is distributed in the hope that it will be
41
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
42
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
43
* General Public License for more details.
44
*
45
* You should have received a copy of the GNU General Public
46
* License along with this work; if not, write to the Free Software
47
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
48
*
49
* ========== Copyright Header End ============================================
50
*/
51
// -*- verilog -*-
52
////////////////////////////////////////////////////////////////////////
53
/*
54
//
55
// Description:         Global header file that contain definitions that
56
//                      are common/shared at the systme level
57
*/
58
////////////////////////////////////////////////////////////////////////
59
//
60
// Setting the time scale
61
// If the timescale changes, JP_TIMESCALE may also have to change.
62
`timescale      1ps/1ps
63
 
64
//
65
// JBUS clock
66
// =========
67
//
68
 
69
 
70
 
71
// Afara Link Defines
72
// ==================
73
 
74
// Reliable Link
75
 
76
 
77
 
78
 
79
// Afara Link Objects
80
 
81
 
82
// Afara Link Object Format - Reliable Link
83
 
84
 
85
 
86
 
87
 
88
 
89
 
90
 
91
 
92
 
93
// Afara Link Object Format - Congestion
94
 
95
 
96
 
97
 
98
 
99
 
100
 
101
 
102
 
103
 
104
 
105
// Afara Link Object Format - Acknowledge
106
 
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
 
117
// Afara Link Object Format - Request
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
 
134
 
135
// Afara Link Object Format - Message
136
 
137
 
138
 
139
// Acknowledge Types
140
 
141
 
142
 
143
 
144
// Request Types
145
 
146
 
147
 
148
 
149
 
150
// Afara Link Frame
151
 
152
 
153
 
154
//
155
// UCB Packet Type
156
// ===============
157
//
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
 
175
//
176
// UCB Data Packet Format
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
 
209
// Size encoding for the UCB_SIZE_HI/LO field
210
// 000 - byte
211
// 001 - half-word
212
// 010 - word
213
// 011 - double-word
214
// 111 - quad-word
215
 
216
 
217
 
218
 
219
 
220
 
221
 
222
//
223
// UCB Interrupt Packet Format
224
// ===========================
225
//
226
 
227
 
228
 
229
 
230
 
231
 
232
 
233
 
234
 
235
 
236
//`define UCB_THR_HI             9      // (6) cpu/thread ID shared with
237
//`define UCB_THR_LO             4             data packet format
238
//`define UCB_PKT_HI             3      // (4) packet type shared with
239
//`define UCB_PKT_LO             0      //     data packet format
240
 
241
 
242
 
243
 
244
 
245
 
246
 
247
//
248
// FCRAM Bus Widths
249
// ================
250
//
251
 
252
 
253
 
254
 
255
 
256
 
257
//
258
// ENET clock periods
259
// ==================
260
//
261
 
262
 
263
 
264
 
265
//
266
// JBus Bridge defines
267
// =================
268
//
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
 
279
 
280
//
281
// PCI Device Address Configuration
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
 
307
          // time scale definition
308
 
309
////////////////////////////////////////////////////////////////////////
310
// Local header file includes / local defines
311
////////////////////////////////////////////////////////////////////////
312
/*
313
/* ========== Copyright Header Begin ==========================================
314
*
315
* OpenSPARC T1 Processor File: lsu.h
316
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
317
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
318
*
319
* The above named program is free software; you can redistribute it and/or
320
* modify it under the terms of the GNU General Public
321
* License version 2 as published by the Free Software Foundation.
322
*
323
* The above named program is distributed in the hope that it will be
324
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
325
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
326
* General Public License for more details.
327
*
328
* You should have received a copy of the GNU General Public
329
* License along with this work; if not, write to the Free Software
330
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
331
*
332
* ========== Copyright Header End ============================================
333
*/
334
 
335
 
336
 
337
 
338
 
339
 
340
 
341
 
342
//`define STB_PCX_WY_HI   107
343
//`define STB_PCX_WY_LO   106
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
 
417
 
418
 
419
 
420
 
421
 
422
 
423
 
424
 
425
 
426
 
427
// TLB Tag and Data Format
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
 
479
 
480
 
481
 
482
 
483
 
484
 
485
 
486
 
487
 
488
 
489
// I-TLB version - lsu_tlb only.
490
 
491
 
492
 
493
 
494
 
495
 
496
 
497
 
498
 
499
 
500
 
501
 
502
 
503
 
504
 
505
 
506
 
507
 
508
 
509
 
510
 
511
 
512
 
513
 
514
// Invalidate Format
515
//addr<5:4>=00
516
 
517
 
518
 
519
 
520
 
521
 
522
 
523
 
524
 
525
 
526
 
527
 
528
 
529
 
530
 
531
 
532
 
533
//addr<5:4>=01
534
 
535
 
536
 
537
 
538
 
539
 
540
 
541
 
542
 
543
 
544
 
545
 
546
 
547
 
548
 
549
 
550
 
551
//addr<5:4>=10
552
 
553
 
554
 
555
 
556
 
557
 
558
 
559
 
560
 
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
 
569
//addr<5:4>=11
570
 
571
 
572
 
573
 
574
 
575
 
576
 
577
 
578
 
579
 
580
 
581
 
582
 
583
 
584
 
585
 
586
 
587
// cpuid - 4b
588
 
589
 
590
 
591
// CPUany, addr<5:4>=00,10
592
 
593
 
594
 
595
 
596
 
597
// CPUany, addr<5:4>=01,11
598
 
599
 
600
 
601
 
602
// CPUany, addr<5:4>=01,11
603
 
604
 
605
 
606
 
607
// DTAG parity error Invalidate
608
 
609
 
610
 
611
 
612
// CPX BINIT STORE
613
 
614
 
615
module lsu_dctl ( /*AUTOARG*/
616
   // Outputs
617
   lsu_tlu_nucleus_ctxt_m, lsu_quad_word_access_g, so, dctl_rst_l,
618
   lsu_tlu_wsr_inst_e, lsu_l2fill_fpld_e, dva_vld_m_bf,
619
   lsu_no_spc_pref, ifu_tlu_flush_fd_w, ifu_tlu_flush_fd2_w,
620
   ifu_tlu_flush_fd3_w, ifu_lsu_flush_w, lsu_tlu_thrid_d,
621
   lsu_diagnstc_data_sel, lsu_diagnstc_va_sel, lsu_err_addr_sel,
622
   dva_bit_wr_en_e, dva_wr_adr_e, lsu_exu_ldst_miss_w2,
623
   lsu_exu_dfill_vld_w2, lsu_ffu_ld_vld, lsu_ld_miss_wb,
624
   lsu_dtlb_bypass_e, ld_pcx_pkt_g, tlb_ldst_cam_vld, ldxa_internal,
625
   lsu_ifu_ldsta_internal_e, lsu_ifu_ldst_cmplt, lsu_ifu_itlb_en,
626
   lsu_ifu_icache_en, lmq_byp_data_en_w2, lmq_byp_data_fmx_sel,
627
   lmq_byp_data_mxsel0, lmq_byp_data_mxsel1, lmq_byp_data_mxsel2,
628
   lmq_byp_data_mxsel3, lmq_byp_ldxa_mxsel0, lmq_byp_ldxa_mxsel1,
629
   lmq_byp_ldxa_mxsel2, lmq_byp_ldxa_mxsel3, lsu_ld_thrd_byp_sel_e,
630
   dcache_byte_wr_en_e, lsu_dcache_wr_vld_e, lsu_ldstub_g,
631
   lsu_swap_g, lsu_tlu_dtlb_done, lsu_exu_thr_m, merge7_sel_byte0_m,
632
   merge7_sel_byte7_m, merge6_sel_byte1_m, merge6_sel_byte6_m,
633
   merge5_sel_byte2_m, merge5_sel_byte5_m, merge4_sel_byte3_m,
634
   merge4_sel_byte4_m, merge3_sel_byte0_m, merge3_sel_byte3_m,
635
   merge3_sel_byte4_m, merge3_sel_byte7_default_m, merge3_sel_byte_m,
636
   merge2_sel_byte1_m, merge2_sel_byte2_m, merge2_sel_byte5_m,
637
   merge2_sel_byte6_default_m, merge2_sel_byte_m, merge0_sel_byte0_m,
638
   merge0_sel_byte1_m, merge0_sel_byte2_m,
639
   merge0_sel_byte3_default_m, merge0_sel_byte4_m,
640
   merge0_sel_byte5_m, merge0_sel_byte6_m,
641
   merge0_sel_byte7_default_m, merge1_sel_byte0_m,
642
   merge1_sel_byte1_m, merge1_sel_byte2_m,
643
   merge1_sel_byte3_default_m, merge1_sel_byte4_m,
644
   merge1_sel_byte5_m, merge1_sel_byte6_m,
645
   merge1_sel_byte7_default_m, merge0_sel_byte_1h_m,
646
   merge1_sel_byte_1h_m, merge1_sel_byte_2h_m, lsu_dtlb_cam_real_e,
647
   lsu_dtagv_wr_vld_e, lsu_dtag_wrreq_x_e, lsu_dtag_index_sel_x_e,
648
   lsu_dtlb_wr_vld_e, lsu_dtlb_tag_rd_e, lsu_dtlb_data_rd_e,
649
   lsu_dtlb_dmp_vld_e, lsu_dtlb_dmp_all_e, lsu_dtlb_rwindex_vld_e,
650
   lsu_dtlb_invalid_all_l_m, lsu_tlu_tlb_ld_inst_m,
651
   lsu_tlu_tlb_st_inst_m, lsu_tlu_tlb_access_tid_m,
652
   lsu_tlb_data_rd_vld_g, lsu_tlb_st_sel_m, lsu_va_wtchpt0_wr_en_l,
653
   lsu_va_wtchpt1_wr_en_l, lsu_va_wtchpt2_wr_en_l,
654
   lsu_va_wtchpt3_wr_en_l, thread0_m, thread1_m, thread2_m,
655
   thread3_m, lsu_dctldp_thread0_m, lsu_dctldp_thread1_m,
656
   lsu_dctldp_thread2_m, lsu_dctldp_thread3_m, thread0_g, thread1_g,
657
   thread2_g, thread3_g, lsu_tlu_nonalt_ldst_m,
658
   lsu_tlu_xslating_ldst_m, lsu_tlu_ctxt_sel_m, lsu_tlu_write_op_m,
659
   lsu_dtlb_addr_mask_l_e, dva_din_e,
660
   lsu_diagnstc_dtagv_prty_invrt_e, lsu_ifu_asi_load,
661
   lsu_ifu_asi_thrid, lsu_ifu_asi_vld, lsu_quad_asi_e,
662
   lsu_local_ldxa_sel_g, lsu_dtag_rsel_m, lsu_tlbop_force_swo,
663
   lsu_atomic_pkt2_bsel_g, lsu_dcache_tag_perror_g,
664
   lsu_dcache_data_perror_g, lsu_ifu_l2_unc_error,
665
   lsu_ifu_l2_corr_error, lsu_ifu_dcache_data_perror,
666
   lsu_ifu_dcache_tag_perror, lsu_ifu_error_tid, lsu_ifu_io_error,
667
   lsu_tlu_squash_va_oor_m, lsu_squash_va_oor_m, tlb_cam_hit_g,
668
   lsu_st_hw_le_g, lsu_st_w_or_dbl_le_g, lsu_st_x_le_g,
669
   lsu_swap_sel_default_g, lsu_swap_sel_default_byte_7_2_g,
670
   lsu_st_rmo_m, lsu_bst_in_pipe_m, lsu_snap_blk_st_m, lsu_blk_st_m,
671
   lsu_blkst_pgnum_m, lsu_ffu_blk_asi_e, lsu_blk_asi_m,
672
   lsu_nonalt_nucl_access_m, dcache_alt_mx_sel_e,
673
   dcache_alt_mx_sel_e_bf, dcache_rvld_e, lsu_dc_iob_access_e,
674
   lsu_ifu_ldst_miss_w, lsu_ifu_dc_parity_error_w2,
675
   lsu_ldst_inst_vld_e, lsu_local_ldxa_tlbrd_sel_g,
676
   lsu_local_diagnstc_tagrd_sel_g, lsu_va_wtchpt_sel_g,
677
   asi_state_wr_thrd, thread0_d, thread1_d, thread2_d, thread3_d,
678
   tlu_lsu_asi_update_g, pctxt_state_wr_thrd, sctxt_state_wr_thrd,
679
   thread_pctxt, thread_sctxt, thread_actxt, thread_default,
680
   thread0_ctxt, thread1_ctxt, thread2_ctxt, thread3_ctxt,
681
   pid_state_wr_en, thread0_e, thread1_e, thread2_e, thread3_e,
682
   dfture_tap_wr_mx_sel, lctl_rst, lsu_ctl_state_wr_en,
683
   lsuctl_ctlbits_wr_en, dfture_tap_rd_en, bist_tap_wr_en,
684
   bistctl_wr_en, bist_ctl_reg_wr_en, mrgn_tap_wr_en, ldiagctl_wr_en,
685
   misc_ctl_sel_din, lsu_asi_sel_fmx1, lsu_asi_sel_fmx2,
686
   tlb_access_en0_g, tlb_access_en1_g, tlb_access_en2_g,
687
   tlb_access_en3_g, tlb_access_sel_thrd0, tlb_access_sel_thrd1,
688
   tlb_access_sel_thrd2, tlb_access_sel_default, mrgnctl_wr_en,
689
   hpv_priv_m, hpstate_en_m, dcache_arry_data_sel_m, dtlb_bypass_m,
690
   lsu_alt_space_m, atomic_m, ldst_dbl_m, fp_ldst_m, lda_internal_m,
691
   sta_internal_m, cam_real_m, data_rd_vld_g, tag_rd_vld_g,
692
   ldst_sz_m, asi_internal_m, rd_only_ltlb_asi_e, wr_only_ltlb_asi_e,
693
   dfill_tlb_asi_e, ifill_tlb_asi_e, nofault_asi_m, as_if_user_asi_m,
694
   atomic_asi_m, phy_use_ec_asi_m, phy_byp_ec_asi_m, quad_asi_m,
695
   binit_quad_asi_m, blk_asi_m, recognized_asi_m, strm_asi_m,
696
   mmu_rd_only_asi_m, rd_only_asi_m, wr_only_asi_m, unimp_asi_m,
697
   va_wtchpt_cmp_en_m, lsu_tlu_async_ttype_vld_w2,
698
   lsu_tlu_async_ttype_w2, lsu_tlu_async_tid_w2, async_tlb_index,
699
   l2fill_vld_m, ld_thrd_byp_mxsel_m, morphed_addr_m,
700
   signed_ldst_byte_m, signed_ldst_hw_m, signed_ldst_w_m,
701
   lsu_tlb_asi_data_perr_g, lsu_tlb_asi_tag_perr_g, lsu_sscan_data,
702
   lsu_ld_inst_vld_g, lsu_dcache_rand, lsu_encd_way_hit,
703
   lsu_way_hit_or, lsu_memref_m, lsu_flsh_inst_m,
704
   lsu_ifu_asi_data_en_l, lsu_dcache_fill_addr_e,
705
   lsu_dcache_fill_addr_e_err, lsu_thread_g, lmq_ldd_vld,
706
   lsu_bist_rsel_way_e, lsu_dcache_fill_way_e, lmq_ld_addr_b3,
707
   lsu_outstanding_rmo_st_max, lsu_dcfill_data_mx_sel_e,
708
   // Inputs
709
   si, se, sehold, rst_tri_en, rclk, grst_l, arst_l,
710
   lsu_diag_va_prty_invrt, dva_svld_e, dva_snp_bit_wr_en_e,
711
   dva_snp_addr_e, lsu_tte_data_cp_g, lsu_l2fill_vld, ld_inst_vld_e,
712
   st_inst_vld_e, ifu_lsu_ldst_fp_e, ldst_sz_e,
713
   lsu_ldst_va_b12_b11_m, lsu_ldst_va_b7_b0_m, ifu_lsu_rd_e,
714
   tlb_cam_hit, ifu_tlu_sraddr_d, ifu_tlu_wsr_inst_d,
715
   ifu_lsu_alt_space_d, tlu_lsu_int_ldxa_vld_w2,
716
   tlu_lsu_int_ld_ill_va_w2, tlu_lsu_ldxa_tid_w2,
717
   ifu_lsu_ldxa_data_vld_w2, ifu_lsu_ldxa_illgl_va_w2,
718
   ifu_lsu_ldxa_tid_w2, ifu_lsu_asi_rd_unc, tlu_lsu_tl_zero,
719
   ifu_lsu_thrid_s, ifu_lsu_ldst_dbl_e, ld_stb_full_raw_w2,
720
   ld_sec_active, ifu_tlu_inst_vld_m, lsu_l2fill_bendian_m,
721
   lmq0_l2fill_fpld, lmq1_l2fill_fpld, lmq2_l2fill_fpld,
722
   lmq3_l2fill_fpld, cache_way_hit_buf1, cache_hit, lmq0_byp_misc_sz,
723
   lmq1_byp_misc_sz, lmq2_byp_misc_sz, lmq3_byp_misc_sz,
724
   lsu_l2fill_sign_extend_m, lsu_l1hit_sign_extend_e,
725
   tlu_lsu_pstate_cle, tlu_lsu_pstate_am, tlb_pgnum, tlb_demap_nctxt,
726
   tlb_demap_pctxt, tlb_demap_sctxt, tlb_demap_actxt,
727
   tlb_demap_thrid, ifu_lsu_casa_e, ifu_lsu_ldstub_e, ifu_lsu_swap_e,
728
   lsu_atm_st_cmplt_e, lsu_cpx_pkt_atm_st_cmplt,
729
   spu_lsu_ldxa_data_vld_w2, spu_lsu_ldxa_illgl_va_w2,
730
   spu_lsu_ldxa_tid_w2, spu_lsu_stxa_ack_tid, spu_lsu_stxa_ack,
731
   spu_lsu_unc_error_w2, spu_lsu_int_w2, tlu_lsu_stxa_ack,
732
   tlu_lsu_stxa_ack_tid, lsu_tlb_invert_endian_g, lmq0_ncache_ld,
733
   lmq1_ncache_ld, lmq2_ncache_ld, lmq3_ncache_ld, ifu_tlu_mb_inst_e,
734
   ifu_tlu_flsh_inst_e, lsu_stb_empty, tlu_dtlb_tag_rd_g,
735
   tlu_dtlb_data_rd_g, tlu_dtlb_dmp_vld_g, tlu_dtlb_dmp_all_g,
736
   tlu_dtlb_rw_index_vld_g, tlu_dtlb_invalidate_all_g,
737
   lsu_st_wr_dcache, tlu_lsu_asi_update_m, tlu_lsu_tid_m,
738
   lsu_rd_dtag_parity_g, dcache_rparity_err_wb,
739
   lsu_diagnstc_wr_data_b0, lsu_byp_ldd_oddrd_m, tlu_lsu_redmode,
740
   tlu_lsu_redmode_rst_d1, dva_vld_m, lsu_dfill_tid_e,
741
   ifu_lsu_asi_ack, lsu_intrpt_cmplt, lsu_iobrdge_tap_rq_type_b8,
742
   lsu_iobrdge_tap_rq_type_b6_b3, lsu_iobrdge_tap_rq_type_b1_b0,
743
   lsu_iobrdge_fwd_pkt_vld, lsu_cpx_ld_dtag_perror_e,
744
   lsu_cpx_ld_dcache_perror_e, lsu_cpx_pkt_ld_err, ifu_lsu_nceen,
745
   tlu_lsu_ldxa_async_data_vld, tlu_lsu_hpv_priv, tlu_lsu_hpstate_en,
746
   ifu_lsu_memref_d, ifu_lsu_pref_inst_e, lsu_pref_pcx_req,
747
   lsu_cpx_pkt_prefetch2, lsu_ld_pcx_rq_sel_d2,
748
   lsu_pcx_req_squash_d1, lsu_bld_helper_cmplt_m, lsu_bld_cnt_m,
749
   lsu_bld_reset, ffu_lsu_blk_st_e, lsu_stb_rmo_st_issue,
750
   lsu_cpx_rmo_st_ack, lsu_dfq_flsh_cmplt, stb_cam_hit,
751
   ifu_tlu_flush_m, ctu_sscan_tid, tte_data_perror_unc,
752
   asi_tte_data_perror, asi_tte_tag_perror, tlu_dtlb_rw_index_g,
753
   lsu_local_early_flush_g, lsu_dfq_vld, gdbginit_l, dc_direct_map,
754
   asi_d, lsu_dctl_asi_state_m, lsu_ldst_va_g, lsu_ifu_err_addr_b39,
755
   lsu_dp_ctl_reg0, lsu_dp_ctl_reg1, lsu_dp_ctl_reg2,
756
   lsu_dp_ctl_reg3, ldd_in_dfq_out, dcache_iob_addr_e,
757
   mbist_dcache_index, mbist_dcache_word, lsu_diagnstc_wr_addr_e,
758
   st_dcfill_addr, lsu_dfq_ld_vld, lsu_dfq_st_vld, lmq0_ldd_vld,
759
   lmq1_ldd_vld, lmq2_ldd_vld, lmq3_ldd_vld, lsu_dfq_byp_tid,
760
   dfq_byp_ff_en, lsu_dcache_iob_way_e, mbist_dcache_way,
761
   lsu_diagnstc_wr_way_e, lsu_st_way_e, lmq0_pcx_pkt_way,
762
   lmq1_pcx_pkt_way, lmq2_pcx_pkt_way, lmq3_pcx_pkt_way,
763
   lmq0_ld_rq_type, lmq1_ld_rq_type, lmq2_ld_rq_type,
764
   lmq3_ld_rq_type, lmq0_pcx_pkt_addr, lmq1_pcx_pkt_addr,
765
   lmq2_pcx_pkt_addr, lmq3_pcx_pkt_addr, lsu_ttype_vld_m2,
766
   tlu_early_flush_pipe2_w, lsu_st_dcfill_size_e, mbist_dcache_write,
767
   mbist_dcache_read
768
   ) ;
769
 
770
 
771
output                  lsu_tlu_nucleus_ctxt_m ;// access is nucleus context 
772
output                  lsu_quad_word_access_g ; // 128b ld request.
773
 
774
input si;
775
input se;
776
input sehold ;
777
input rst_tri_en ;
778
output so;
779
 
780
input      rclk ;
781
input                   grst_l;
782
input                   arst_l;
783
output     dctl_rst_l;
784
 
785
input  lsu_diag_va_prty_invrt ;
786
 
787
   input         dva_svld_e ;
788
   input [15:0] dva_snp_bit_wr_en_e;
789
   input [4:0]  dva_snp_addr_e;
790
 
791
input         lsu_tte_data_cp_g ; // cp bit from tlb    
792
input         lsu_l2fill_vld ;    // fill from dfq to d$.
793
input         ld_inst_vld_e ;     // load accesses d$.
794
input         st_inst_vld_e ;     // load accesses d$.
795
input         ifu_lsu_ldst_fp_e ; // fp load or store
796
input [1:0]   ldst_sz_e ;         // sz of ld/st xsaction.
797
 
798
 
799
input [12:11]  lsu_ldst_va_b12_b11_m;
800
input [7:0]    lsu_ldst_va_b7_b0_m;
801
 
802
input [4:0]   ifu_lsu_rd_e;           // primary rd of ld
803
input         tlb_cam_hit ;           // xlation hits in tlb.     
804
// Read/Write Privileged State Register Access.
805
input [6:0]   ifu_tlu_sraddr_d ;      // addr of sr(st/pr)
806
 
807
input         ifu_tlu_wsr_inst_d ;    // valid wr sr(st/pr)
808
output        lsu_tlu_wsr_inst_e ;    // valid wr sr(st/pr)
809
 
810
input         ifu_lsu_alt_space_d;        // alternate space ld/st
811
 
812
input         tlu_lsu_int_ldxa_vld_w2 ;  // tlu ldxa data is valid (intrpt/scpd)
813
input         tlu_lsu_int_ld_ill_va_w2 ;  // tlu ldxa'va is invalid (intrpt/scpd)
814
 
815
input [1:0]   tlu_lsu_ldxa_tid_w2 ;       // thread id for tlu ldxa data. 
816
 
817
input         ifu_lsu_ldxa_data_vld_w2 ;  // ifu ldxa data is valid
818
input         ifu_lsu_ldxa_illgl_va_w2 ;  // ifu ldxa with illgl va
819
input [1:0]   ifu_lsu_ldxa_tid_w2   ;     // thread id for ifu ldxa data. 
820
input         ifu_lsu_asi_rd_unc ;        // unc error for tlb rd
821
 
822
input [3:0]   tlu_lsu_tl_zero ;           // trap level is zero.
823
input [1:0]   ifu_lsu_thrid_s ;           // thread id
824
input         ifu_lsu_ldst_dbl_e ;        // ldd, atomic quad.
825
 
826
input         ld_stb_full_raw_w2 ;     // full raw for load-thread0
827
input         ld_sec_active ;          // secondary bypassing
828
input         ifu_tlu_inst_vld_m ;     // inst vld in w stage
829
 
830
input         lsu_l2fill_bendian_m ;
831
 
832
//input         lsu_l2fill_fpld_e ;      // fp load
833
output         lsu_l2fill_fpld_e ;      // fp load
834
input         lmq0_l2fill_fpld ;      // fp load
835
input         lmq1_l2fill_fpld ;      // fp load
836
input         lmq2_l2fill_fpld ;      // fp load
837
input         lmq3_l2fill_fpld ;      // fp load
838
 
839
input [3:0]   cache_way_hit_buf1 ;          // hit in set of cache.
840
   input      cache_hit;
841
 
842
//input [3:0]   lsu_byp_misc_addr_m ;   // lower 3bits of addr for ldxa/raw etc
843
 
844
input [1:0]   lmq0_byp_misc_sz ;     // size for ldxa/raw etc
845
input [1:0]   lmq1_byp_misc_sz ;     // size for ldxa/raw etc
846
input [1:0]   lmq2_byp_misc_sz ;     // size for ldxa/raw etc
847
input [1:0]   lmq3_byp_misc_sz ;     // size for ldxa/raw etc
848
 
849
input         lsu_l2fill_sign_extend_m ; // l2fill requires sign-extension
850
input         lsu_l1hit_sign_extend_e ;  // l1hit requires sign-extension
851
input [3:0]   tlu_lsu_pstate_cle ;       // current little endian
852
input [3:0]   tlu_lsu_pstate_am ;        // address mask
853
input [39:10] tlb_pgnum ;
854
input         tlb_demap_nctxt;         // demap with nctxt
855
input         tlb_demap_pctxt;         // demap with pctxt
856
input         tlb_demap_sctxt;         // demap with sctxt
857
input         tlb_demap_actxt;         // demap w autodemap ctxt
858
input [1:0]   tlb_demap_thrid;         // demap thrid
859
 
860
input         ifu_lsu_casa_e ;         // compare-swap instr
861
input         ifu_lsu_ldstub_e ;       // ldstub
862
input         ifu_lsu_swap_e ;         // swap
863
 
864
 
865
input         lsu_atm_st_cmplt_e ;      // atm st ack will restart thread
866
input         lsu_cpx_pkt_atm_st_cmplt ; // applies to atomic ld also.
867
 
868
input         spu_lsu_ldxa_data_vld_w2 ; // ldxa data from spu is valid
869
input         spu_lsu_ldxa_illgl_va_w2 ; // ldxa data from spu with illgl va
870
input [1:0]   spu_lsu_ldxa_tid_w2 ;      // ldxa data from spu is valid
871
input [1:0]   spu_lsu_stxa_ack_tid ;     // stxa data from spu is valid
872
input         spu_lsu_stxa_ack ;         // write to sdata reg complete
873
input         spu_lsu_unc_error_w2 ;
874
input         spu_lsu_int_w2 ;           // spu disrupting trap.
875
 
876
input         tlu_lsu_stxa_ack ;         // for mmu reads/writes/demaps
877
input [1:0]   tlu_lsu_stxa_ack_tid ;      // for mmu reads/writes/demaps - tid
878
 
879
input         lsu_tlb_invert_endian_g ;
880
//input         lsu_ncache_ld_e ;       // non-cacheable ld from dfq
881
   input      lmq0_ncache_ld;
882
   input      lmq1_ncache_ld;
883
   input      lmq2_ncache_ld;
884
   input      lmq3_ncache_ld;
885
 
886
 
887
input         ifu_tlu_mb_inst_e ;     // membar instruction
888
input         ifu_tlu_flsh_inst_e ;   // flush  instruction
889
 
890
input [3:0]   lsu_stb_empty ;         // thread's stb is empty
891
 
892
//input         tlu_dtlb_wr_vld_g ;
893
input         tlu_dtlb_tag_rd_g ;
894
input         tlu_dtlb_data_rd_g ;
895
input         tlu_dtlb_dmp_vld_g ;
896
input         tlu_dtlb_dmp_all_g ;
897
input         tlu_dtlb_rw_index_vld_g ;
898
input         tlu_dtlb_invalidate_all_g ;
899
 
900
input         lsu_st_wr_dcache ;
901
 
902
input         tlu_lsu_asi_update_m ;  // update asi
903
input  [1:0]  tlu_lsu_tid_m ;         // thread for asi update
904
input [3:0]   lsu_rd_dtag_parity_g;     // calculated tag parity
905
 
906
input         dcache_rparity_err_wb;     // calculated tag parity
907
 
908
input         lsu_diagnstc_wr_data_b0 ;
909
input         lsu_byp_ldd_oddrd_m ;   // rd fill for non-alt ldd
910
 
911
input [3:0]   tlu_lsu_redmode ;       // redmode
912
input [3:0]   tlu_lsu_redmode_rst_d1 ;   // redmode
913
//input [2:0]   const_cpuid ;           // cpu's id
914
input [3:0]   dva_vld_m ;             // valid bits for cache.
915
output [3:0]  dva_vld_m_bf;
916
 
917
input [1:0]   lsu_dfill_tid_e ;       // thread id
918
input         ifu_lsu_asi_ack;        // asi ack from ifu
919
 
920
input [3:0]   lsu_intrpt_cmplt ;          // intrpt can restart thread
921
//input [8:0]   lsu_iobrdge_tap_rq_type ;
922
input  [8:8]  lsu_iobrdge_tap_rq_type_b8 ;
923
input  [6:3]  lsu_iobrdge_tap_rq_type_b6_b3 ;
924
input  [1:0]  lsu_iobrdge_tap_rq_type_b1_b0 ;
925
 
926
input         lsu_iobrdge_fwd_pkt_vld ;
927
 
928
input         lsu_cpx_ld_dtag_perror_e ;  // dtag parity error on issue
929
input         lsu_cpx_ld_dcache_perror_e ;// dcache parity error on issue
930
//input [1:1]   lsu_cpx_atm_st_err ;        // atomic st error field
931
input [1:0]   lsu_cpx_pkt_ld_err ;        // err field - cpx ld pkt
932
input [3:0]   ifu_lsu_nceen ;             // uncorrectible error enable 
933
input         tlu_lsu_ldxa_async_data_vld ;   // tlu_lsu_ldxa_data_vld is for async op.
934
input [3:0]   tlu_lsu_hpv_priv ;   // hypervisor privilege modified
935
input [3:0]   tlu_lsu_hpstate_en ;         // enable bit from hpstate
936
 
937
input         ifu_lsu_memref_d;
938
input         ifu_lsu_pref_inst_e ;       // prefetch inst
939
input         lsu_pref_pcx_req ;          // pref sent to pcx
940
 
941
input         lsu_cpx_pkt_prefetch2 ;     // ld is prefetch
942
 
943
// pref counter   
944
input [3:0]   lsu_ld_pcx_rq_sel_d2 ;
945
input         lsu_pcx_req_squash_d1;
946
 
947
input         lsu_bld_helper_cmplt_m ;    // bld helper completes.
948
input [2:0]   lsu_bld_cnt_m ;
949
input         lsu_bld_reset ;
950
 
951
output [3:0]  lsu_no_spc_pref;
952
 
953
input         ffu_lsu_blk_st_e ;        // blk st helper signalled by ffu
954
input   [3:0]    lsu_stb_rmo_st_issue ;  // thread's stb issues rmo st
955
input   [3:0]    lsu_cpx_rmo_st_ack ;    // rmo ack clears
956
 
957
input   [3:0]    lsu_dfq_flsh_cmplt ;
958
 
959
input           stb_cam_hit ;
960
 
961
input   ifu_tlu_flush_m;
962
 
963
output  ifu_tlu_flush_fd_w;
964
output  ifu_tlu_flush_fd2_w;
965
output  ifu_tlu_flush_fd3_w;
966
output  ifu_lsu_flush_w;
967
 
968
input   [3:0]           ctu_sscan_tid ;
969
 
970
//input         tte_data_perror_corr ;
971
input           tte_data_perror_unc ;
972
input           asi_tte_data_perror ;
973
input           asi_tte_tag_perror ;
974
 
975
input   [5:0]    tlu_dtlb_rw_index_g ;
976
 
977
input           lsu_local_early_flush_g ;
978
 
979
//input         lsu_error_pa_b39_m ;
980
 
981
input         lsu_dfq_vld;
982
 
983
input           gdbginit_l ;
984
input           dc_direct_map ;
985
 
986
output  [1:0]    lsu_tlu_thrid_d ;
987
 
988
output  [3:0] lsu_diagnstc_data_sel ;
989
output  [3:0] lsu_diagnstc_va_sel ;
990
 
991
output  [2:0] lsu_err_addr_sel ;
992
 
993
output [15:0] dva_bit_wr_en_e;
994
output [10:6] dva_wr_adr_e;
995
 
996
output      lsu_exu_ldst_miss_w2 ;  // load misses in d$.
997
//output  [3:0]   lsu_way_hit ;   // ld/st access hits in d$.
998
output      lsu_exu_dfill_vld_w2 ;  // data fill to irf(exu).
999
output      lsu_ffu_ld_vld ;  // fp load writes to frf
1000
output      lsu_ld_miss_wb ;  // load misses in d$.
1001
//output      lsu_ld_hit_wb ;   // load hits in d$.
1002
 
1003
output      lsu_dtlb_bypass_e ; // dtlb is bypassed
1004
 
1005
output [65-1:40] ld_pcx_pkt_g ;    // ld miss pkt for thread.
1006
output      tlb_ldst_cam_vld ;
1007
 
1008
 
1009
//output      stxa_internal ;   // internal stxa, stg g 
1010
output      ldxa_internal ;   // internal ldxa, stg g
1011
 
1012
output      lsu_ifu_ldsta_internal_e ; // any internal asi
1013
output  [3:0]   lsu_ifu_ldst_cmplt ;
1014
output  [3:0]   lsu_ifu_itlb_en ;
1015
output  [3:0]   lsu_ifu_icache_en ;
1016
 
1017
 
1018
output  [3:0]           lmq_byp_data_en_w2 ;
1019
 
1020
output  [3:0]           lmq_byp_data_fmx_sel ;  // final data sel for lmq byp
1021
output  [3:0]           lmq_byp_data_mxsel0 ;     // ldxa vs stb bypass data sel.
1022
output  [3:0]           lmq_byp_data_mxsel1 ;     // ldxa vs stb bypass data sel.
1023
output  [3:0]           lmq_byp_data_mxsel2 ;     // ldxa vs stb bypass data sel.
1024
output  [3:0]           lmq_byp_data_mxsel3 ;     // ldxa vs stb bypass data sel.
1025
output  [2:0]           lmq_byp_ldxa_mxsel0 ;     // ldxa data sel - thread0
1026
output  [2:0]           lmq_byp_ldxa_mxsel1 ;     // ldxa data sel - thread1
1027
output  [2:0]           lmq_byp_ldxa_mxsel2 ;     // ldxa data sel - thread2
1028
output  [2:0]           lmq_byp_ldxa_mxsel3 ;     // ldxa data sel - thread3
1029
output  [2:0]   lsu_ld_thrd_byp_sel_e ;
1030
 
1031
output  [15:0]    dcache_byte_wr_en_e ; // 16-byte write enable mask.
1032
 
1033
output      lsu_dcache_wr_vld_e ; // write to dcache.
1034
 
1035
output      lsu_ldstub_g ;    // ldstub(a) instruction
1036
output      lsu_swap_g ;    // swap(a) instruction
1037
output                  lsu_tlu_dtlb_done;  // dtlb rd/dmp/wr cmplt
1038
output  [1:0]   lsu_exu_thr_m ;
1039
 
1040
output                   merge7_sel_byte0_m;
1041
output                   merge7_sel_byte7_m;
1042
 
1043
output                   merge6_sel_byte1_m;
1044
output                   merge6_sel_byte6_m;
1045
 
1046
output                   merge5_sel_byte2_m;
1047
output                   merge5_sel_byte5_m;
1048
 
1049
output                   merge4_sel_byte3_m;
1050
output                   merge4_sel_byte4_m;
1051
 
1052
output                   merge3_sel_byte0_m;
1053
output                   merge3_sel_byte3_m;
1054
output                   merge3_sel_byte4_m;
1055
output                   merge3_sel_byte7_default_m;
1056
output                   merge3_sel_byte_m ;
1057
 
1058
output                   merge2_sel_byte1_m;
1059
output                   merge2_sel_byte2_m;
1060
output                   merge2_sel_byte5_m;
1061
output                   merge2_sel_byte6_default_m;
1062
output                   merge2_sel_byte_m ;
1063
 
1064
output                   merge0_sel_byte0_m, merge0_sel_byte1_m;
1065
output                   merge0_sel_byte2_m, merge0_sel_byte3_default_m;
1066
 
1067
output                   merge0_sel_byte4_m, merge0_sel_byte5_m;
1068
output                   merge0_sel_byte6_m, merge0_sel_byte7_default_m;
1069
 
1070
output                   merge1_sel_byte0_m, merge1_sel_byte1_m;
1071
output                   merge1_sel_byte2_m, merge1_sel_byte3_default_m;
1072
output                   merge1_sel_byte4_m, merge1_sel_byte5_m;
1073
output                   merge1_sel_byte6_m, merge1_sel_byte7_default_m;
1074
 
1075
output                               merge0_sel_byte_1h_m ;
1076
 
1077
output                               merge1_sel_byte_1h_m, merge1_sel_byte_2h_m ;
1078
 
1079
output          lsu_dtlb_cam_real_e ;
1080
output      lsu_dtagv_wr_vld_e ;
1081
 
1082
output      lsu_dtag_wrreq_x_e ;
1083
output      lsu_dtag_index_sel_x_e ;
1084
 
1085
output      lsu_dtlb_wr_vld_e ;
1086
output      lsu_dtlb_tag_rd_e ;
1087
output      lsu_dtlb_data_rd_e ;
1088
output      lsu_dtlb_dmp_vld_e ;
1089
output      lsu_dtlb_dmp_all_e ;
1090
output      lsu_dtlb_rwindex_vld_e ;
1091
output      lsu_dtlb_invalid_all_l_m ;
1092
output      lsu_tlu_tlb_ld_inst_m ;
1093
output      lsu_tlu_tlb_st_inst_m ;
1094
output  [1:0]   lsu_tlu_tlb_access_tid_m ;
1095
output      lsu_tlb_data_rd_vld_g ;
1096
 
1097
 
1098
output  [3:0]   lsu_tlb_st_sel_m ;
1099
 
1100
output         lsu_va_wtchpt0_wr_en_l;
1101
output         lsu_va_wtchpt1_wr_en_l;
1102
output         lsu_va_wtchpt2_wr_en_l;
1103
output         lsu_va_wtchpt3_wr_en_l;
1104
 
1105
output         thread0_m;
1106
output         thread1_m;
1107
output         thread2_m;
1108
output         thread3_m;
1109
 
1110
output         lsu_dctldp_thread0_m;
1111
output         lsu_dctldp_thread1_m;
1112
output         lsu_dctldp_thread2_m;
1113
output         lsu_dctldp_thread3_m;
1114
 
1115
output         thread0_g;
1116
output         thread1_g;
1117
output         thread2_g;
1118
output         thread3_g;
1119
 
1120
output                  lsu_tlu_nonalt_ldst_m ; // non-alternate load or store
1121
output                  lsu_tlu_xslating_ldst_m ;// xslating ldst,atomic etc
1122
 
1123
output   [2:0]          lsu_tlu_ctxt_sel_m;           // context selected:0-p,1-s,2-n
1124
output                  lsu_tlu_write_op_m;           // fault occurs for data write operation
1125
 
1126
output                  lsu_dtlb_addr_mask_l_e ;  // address mask applies
1127
 
1128
 
1129
output            dva_din_e;
1130
 
1131
output            lsu_diagnstc_dtagv_prty_invrt_e ;
1132
 
1133
output                  lsu_ifu_asi_load;   // asi load to ifu
1134
output [1:0]            lsu_ifu_asi_thrid;    // asi event thrid to ifu
1135
output                  lsu_ifu_asi_vld;    // asi event vld - ld+st
1136
output      lsu_quad_asi_e ;
1137
//output      lsu_tlu_64kpg_hit_g ;   // 64k page page accessed
1138
 
1139
output            lsu_local_ldxa_sel_g;
1140
output  [3:0]     lsu_dtag_rsel_m ;  // dtag way sel
1141
 
1142
output      lsu_tlbop_force_swo ;
1143
output  [2:0]     lsu_atomic_pkt2_bsel_g ;
1144
output      lsu_dcache_tag_perror_g ;       // dcache tag parity error
1145
output      lsu_dcache_data_perror_g ;      // dcache data parity error
1146
 
1147
output      lsu_ifu_l2_unc_error ;    // l2 uncorrectible error
1148
output      lsu_ifu_l2_corr_error ;   // l2 correctible error
1149
output      lsu_ifu_dcache_data_perror ;  // dcache data parity error
1150
output      lsu_ifu_dcache_tag_perror ; // dcache tag parity error
1151
output  [1:0]   lsu_ifu_error_tid ;   // thread id for error
1152
output      lsu_ifu_io_error ;    // error on io ld
1153
//output  [1:0]   lsu_tlu_derr_tid_g ;    // daccess error tid
1154
 
1155
output      lsu_tlu_squash_va_oor_m ;   // squash va_oor for mem-op.
1156
output      lsu_squash_va_oor_m ;   // squash va_oor for mem-op.
1157
 
1158
output          tlb_cam_hit_g ;           // xlation hits in tlb.     
1159
 
1160
   output        lsu_st_hw_le_g;
1161
   output        lsu_st_w_or_dbl_le_g;
1162
   output        lsu_st_x_le_g;
1163
   output        lsu_swap_sel_default_g;
1164
   output        lsu_swap_sel_default_byte_7_2_g;
1165
 
1166
output          lsu_st_rmo_m ;          // rmo store in m stage
1167
output          lsu_bst_in_pipe_m ;     // 1st helper for bst.
1168
output          lsu_snap_blk_st_m ;     // snap blk st state 
1169
output          lsu_blk_st_m ;          // blk st in m
1170
output  [39:10] lsu_blkst_pgnum_m ;
1171
output          lsu_ffu_blk_asi_e ;     // blk
1172
output          lsu_blk_asi_m ;
1173
 
1174
output          lsu_nonalt_nucl_access_m ;
1175
 
1176
//output        [3:0]   lsu_spu_stb_empty ;
1177
 
1178
   output     dcache_alt_mx_sel_e;
1179
   output     dcache_alt_mx_sel_e_bf;
1180
   output     dcache_rvld_e;
1181
 
1182
output          lsu_dc_iob_access_e ;   // dcache iob access
1183
 
1184
output          lsu_ifu_ldst_miss_w ;
1185
 
1186
   output lsu_ifu_dc_parity_error_w2;
1187
 
1188
   output lsu_ldst_inst_vld_e;
1189
 
1190
output          lsu_local_ldxa_tlbrd_sel_g;
1191
output          lsu_local_diagnstc_tagrd_sel_g;
1192
output          lsu_va_wtchpt_sel_g;
1193
 
1194
 
1195
   input [7:0]   asi_d;
1196
   input [7:0]   lsu_dctl_asi_state_m;
1197
 
1198
   output  [3:0] asi_state_wr_thrd;
1199
   output        thread0_d;
1200
   output        thread1_d;
1201
   output        thread2_d;
1202
   output        thread3_d;
1203
   output        tlu_lsu_asi_update_g;
1204
 
1205
output  [3:0] pctxt_state_wr_thrd ;
1206
output  [3:0] sctxt_state_wr_thrd ;
1207
 
1208
   output     thread_pctxt;
1209
   output     thread_sctxt;
1210
 
1211
   output     thread_actxt;
1212
   output     thread_default;
1213
 
1214
   output     thread0_ctxt;
1215
   output     thread1_ctxt;
1216
   output     thread2_ctxt;
1217
   output     thread3_ctxt;
1218
 
1219
   output [3:0] pid_state_wr_en;
1220
   output       thread0_e;
1221
   output       thread1_e;
1222
   output       thread2_e;
1223
   output       thread3_e;
1224
 
1225
   output       dfture_tap_wr_mx_sel;
1226
   output [3:0] lctl_rst;
1227
   output [3:0] lsu_ctl_state_wr_en;
1228
   output [3:0] lsuctl_ctlbits_wr_en;
1229
   output [3:0] dfture_tap_rd_en;
1230
 
1231
   output      bist_tap_wr_en;
1232
   output      bistctl_wr_en;
1233
   output      bist_ctl_reg_wr_en;
1234
   output      mrgn_tap_wr_en;
1235
 
1236
   output      ldiagctl_wr_en;
1237
 
1238
   output [3:0]  misc_ctl_sel_din ;
1239
 
1240
   output [2:0] lsu_asi_sel_fmx1;
1241
   output [2:0] lsu_asi_sel_fmx2;
1242
 
1243
 
1244
   output       tlb_access_en0_g;
1245
   output       tlb_access_en1_g;
1246
   output       tlb_access_en2_g;
1247
   output       tlb_access_en3_g;
1248
 
1249
   output tlb_access_sel_thrd0;
1250
   output tlb_access_sel_thrd1;
1251
   output tlb_access_sel_thrd2;
1252
   output tlb_access_sel_default;
1253
 
1254
   input [7:0] lsu_ldst_va_g;
1255
 
1256
   output mrgnctl_wr_en;
1257
 
1258
   input  lsu_ifu_err_addr_b39;
1259
 
1260
   input [5:0] lsu_dp_ctl_reg0;
1261
   input [5:0] lsu_dp_ctl_reg1;
1262
   input [5:0] lsu_dp_ctl_reg2;
1263
   input [5:0] lsu_dp_ctl_reg3;
1264
 
1265
   input       ldd_in_dfq_out;     //from qctl2 
1266
 
1267
 
1268
   output hpv_priv_m;
1269
   output hpstate_en_m;
1270
 
1271
   output                dcache_arry_data_sel_m;
1272
 
1273
   output                dtlb_bypass_m;
1274
 
1275
   output                lsu_alt_space_m;
1276
   output                atomic_m;
1277
 
1278
   output                ldst_dbl_m;
1279
   output                fp_ldst_m;
1280
 
1281
   output                lda_internal_m;
1282
   output                sta_internal_m;
1283
   output                cam_real_m;
1284
 
1285
   output                data_rd_vld_g;
1286
   output                tag_rd_vld_g;
1287
   output [1:0]          ldst_sz_m;
1288
   output                asi_internal_m;
1289
 
1290
//   output                ld_inst_vld_unflushed;
1291
//   output                st_inst_vld_unflushed;
1292
 
1293
   output                rd_only_ltlb_asi_e;
1294
   output                wr_only_ltlb_asi_e;
1295
   output                dfill_tlb_asi_e;
1296
   output                ifill_tlb_asi_e;
1297
 
1298
   output                nofault_asi_m;
1299
   output                as_if_user_asi_m;
1300
 
1301
   output                atomic_asi_m;
1302
   output                phy_use_ec_asi_m;
1303
   output                phy_byp_ec_asi_m;
1304
 
1305
   output                quad_asi_m;
1306
   output                binit_quad_asi_m;
1307
   output                blk_asi_m;
1308
 
1309
   output                recognized_asi_m;
1310
   output                strm_asi_m;
1311
   output                mmu_rd_only_asi_m;
1312
   output                rd_only_asi_m;
1313
   output                wr_only_asi_m;
1314
   output                unimp_asi_m;
1315
 
1316
   output                va_wtchpt_cmp_en_m;
1317
 
1318
   output               lsu_tlu_async_ttype_vld_w2 ;    // daccess error - asynchronous
1319
   output   [6:0]        lsu_tlu_async_ttype_w2 ;
1320
   output   [1:0]        lsu_tlu_async_tid_w2 ;          // asynchronous trap - thread 
1321
 
1322
   output   [5:0]        async_tlb_index ;
1323
 
1324
//=========================================
1325
//dc_fill CP
1326
//=========================================   
1327
   output                l2fill_vld_m;    //to qdp1
1328
   output  [3:0]   ld_thrd_byp_mxsel_m ;  //to qdp1
1329
   output [7:0]    morphed_addr_m;        //to dcdp
1330
 
1331
 
1332
   output          signed_ldst_byte_m;    //to dcdp
1333
//   output          unsigned_ldst_byte_m;  //to dcdp 
1334
   output          signed_ldst_hw_m;      //to dcdp
1335
//   output          unsigned_ldst_hw_m;    //to dcdp
1336
   output          signed_ldst_w_m;       //to dcdp
1337
//   output          unsigned_ldst_w_m;     //to dcdp
1338
 
1339
   output       lsu_tlb_asi_data_perr_g ;
1340
   output       lsu_tlb_asi_tag_perr_g ;
1341
 
1342
   output  [14:13]   lsu_sscan_data ;
1343
 
1344
   output  [3:0]         lsu_ld_inst_vld_g ;
1345
 
1346
   output  [1:0]     lsu_dcache_rand;
1347
   output  [1:0]     lsu_encd_way_hit;
1348
   output            lsu_way_hit_or;
1349
//   output            lsu_quad_asi_g;
1350
 
1351
   output            lsu_memref_m ;
1352
   output            lsu_flsh_inst_m ;
1353
 
1354
   output               lsu_ifu_asi_data_en_l ;
1355
 
1356
 
1357
//dcfill_addr [10:0]
1358
   input [7:0]  dcache_iob_addr_e;
1359
   input [6:0]  mbist_dcache_index;
1360
   input        mbist_dcache_word;
1361
   input [10:0] lsu_diagnstc_wr_addr_e;
1362
   input [10:0] st_dcfill_addr;
1363
   output [10:3] lsu_dcache_fill_addr_e;
1364
   output [10:4] lsu_dcache_fill_addr_e_err;
1365
 
1366
   input         lsu_dfq_ld_vld;
1367
   input         lsu_dfq_st_vld;
1368
 
1369
   output [3:0]  lsu_thread_g;
1370
 
1371
//=========================================
1372
//LMQ thread sel
1373
//=========================================
1374
   input         lmq0_ldd_vld;      //from qdp1
1375
   input         lmq1_ldd_vld;
1376
   input         lmq2_ldd_vld;
1377
   input         lmq3_ldd_vld;
1378
   output        lmq_ldd_vld;       //to  qctl2 
1379
 
1380
   input [1:0]   lsu_dfq_byp_tid;   //from qdp2
1381
   input         dfq_byp_ff_en;     //from qctl2 
1382
 
1383
   input [1:0]   lsu_dcache_iob_way_e;   //from qdp2
1384
 
1385
   input   [1:0]  mbist_dcache_way;
1386
   output  [3:0]  lsu_bist_rsel_way_e;
1387
 
1388
   input   [1:0]   lsu_diagnstc_wr_way_e ;  //from dctldp
1389
 
1390
   input [1:0]     lsu_st_way_e;    //from qdp2
1391
 
1392
   input [1:0]     lmq0_pcx_pkt_way;  //from qctl1
1393
   input [1:0]     lmq1_pcx_pkt_way;
1394
   input [1:0]     lmq2_pcx_pkt_way;
1395
   input [1:0]     lmq3_pcx_pkt_way;
1396
   output [3:0]    lsu_dcache_fill_way_e;
1397
 
1398
 
1399
input  [2:0]             lmq0_ld_rq_type ;        // for identifying atomic ld.
1400
input  [2:0]             lmq1_ld_rq_type ;        // for identifying atomic ld.
1401
input  [2:0]             lmq2_ld_rq_type ;        // for identifying atomic ld.
1402
input  [2:0]             lmq3_ld_rq_type ;        // for identifying atomic ld.
1403
 
1404
input  [10:0]            lmq0_pcx_pkt_addr;
1405
input  [10:0]            lmq1_pcx_pkt_addr;
1406
input  [10:0]            lmq2_pcx_pkt_addr;
1407
input  [10:0]            lmq3_pcx_pkt_addr;
1408
 
1409
output                   lmq_ld_addr_b3;
1410
 
1411
output [3:0]             lsu_outstanding_rmo_st_max;
1412
 
1413
input                 lsu_ttype_vld_m2;
1414
input                 tlu_early_flush_pipe2_w;
1415
input [1:0]           lsu_st_dcfill_size_e;
1416
 
1417
   input              mbist_dcache_write;
1418
   input              mbist_dcache_read;
1419
 
1420
   output             lsu_dcfill_data_mx_sel_e;
1421
 
1422
wire  [3:0]   ld_thrd_byp_sel_e ;
1423
wire          ifu_asi_vld,ifu_asi_vld_d1 ;
1424
wire  [1:0]   dcache_wr_size_e ;
1425
wire          lsu_ncache_ld_e;
1426
wire          lsu_diagnstc_wr_src_sel_e ; // dcache/dtag/v write - diag
1427
 
1428
wire         dctl_flush_pipe_w ;   // flush pipe due to error
1429
 wire        dctl_early_flush_w;
1430
 
1431
wire  [10:0] lmq_pcx_pkt_addr;
1432
wire  [2:0]  lmq_ld_rq_type_e;
1433
 
1434
wire [10:0]  dcache_fill_addr_e;
1435
wire [2:0]   dcache_wr_addr_e ;
1436
wire    lsuctl_dtlb_byp_e ;
1437
 
1438
wire    cam_perr_unc0,asi_data_perr0,asi_tag_perr0,ifu_unc_err0 ;
1439
wire    cam_perr_unc1,asi_data_perr1,asi_tag_perr1,ifu_unc_err1 ;
1440
wire    cam_perr_unc2,asi_data_perr2,asi_tag_perr2,ifu_unc_err2 ;
1441
wire    cam_perr_unc3,asi_data_perr3,asi_tag_perr3,ifu_unc_err3 ;
1442
wire    cam_perr_unc_e, asi_data_perr_e,asi_tag_perr_e,ifu_unc_err_e ;
1443
wire    cam_perr_unc_m, asi_data_perr_m,asi_tag_perr_m,ifu_unc_err_m ;
1444
wire    cam_perr_unc_g, asi_data_perr_g,asi_tag_perr_g,ifu_unc_err_g ;
1445
//wire  cam_real_err_e, cam_real_err_m ;
1446
wire    [3:0] squash_byp_cmplt,squash_byp_cmplt_m, squash_byp_cmplt_g ;
1447
wire      ld_inst_vld_m,ld_inst_vld_g ;
1448
wire      st_inst_vld_m,st_inst_vld_g ;
1449
wire      fp_ldst_m,fp_ldst_g,fp_ldst_w2 ;
1450
wire      lsu_ld_hit_wb, lsu_ld_miss_wb ;
1451
wire  [3:0]   lsu_way_hit ;
1452
wire  [1:0]   ldst_sz_m,ldst_sz_g ;
1453
wire  [4:0]   ld_rd_m, ld_rd_g ;
1454
wire      lsu_dtlb_bypass_g,dtlb_bypass_e,dtlb_bypass_m ;
1455
wire [6:0]  lsu_sraddr_e ;
1456
//wire    lsu_rsr_inst_e,lsu_rsr_inst_m, lsu_rsr_inst_w ;
1457
wire    lsu_wsr_inst_e;
1458
wire    pctxt_state_en, sctxt_state_en ;
1459
wire    asi_state_wr_en ;
1460
//wire  [3:0] pctxt_state_rd_en, sctxt_state_rd_en ;
1461
wire    lsu_alt_space_m,lsu_alt_space_g ;
1462
wire    ldxa_internal, stxa_internal ;
1463
wire    lsu_ctl_state_en;
1464
//wire  [3:0] lsu_ctl_state_rd_en;
1465
wire  [3:0]   lsu_ctl_state_wr_en ;
1466
//wire  [7:0] imm_asi_e,imm_asi_m,imm_asi_g ;
1467
//wire    imm_asi_vld_e,imm_asi_vld_m,imm_asi_vld_g;
1468
//wire  [7:0]   asi_state0,asi_state1,asi_state2,asi_state3 ;
1469
 
1470
wire    ldsta_internal_e,sta_internal_e,lda_internal_e;
1471
wire    sta_internal_m,lda_internal_m;
1472
wire  [7:0] asi_d ;
1473
wire    [1:0]   thrid_d,thrid_e,thrid_m, thrid_g, thrid_w2, thrid_w3, ldxa_thrid_w2 ;
1474
wire    stxa_internal_d1, stxa_internal_d2 ;
1475
wire    ld_pcx_pkt_vld_e ;
1476
wire    ld_pcx_pkt_vld_m ;
1477
wire    ld_pcx_pkt_vld_g ;
1478
wire    ldst_dbl_m, ldst_dbl_g;
1479
wire    ldd_force_l2access_w2, ldd_force_l2access_w3;
1480
 
1481
//wire    ld_stb_full_raw_w2 ;
1482
wire    ld_stb_full_raw_w3 ;
1483
 
1484
wire    ldbyp0_vld_rst, ldbyp0_vld_en, ldbyp0_fpld ;
1485
wire    ldbyp1_vld_rst, ldbyp1_vld_en, ldbyp1_fpld ;
1486
wire    ldbyp2_vld_rst, ldbyp2_vld_en, ldbyp2_fpld ;
1487
wire    ldbyp3_vld_rst, ldbyp3_vld_en, ldbyp3_fpld ;
1488
//wire    ldbyp0_vld_en_d1,ldbyp1_vld_en_d1,ldbyp2_vld_en_d1,ldbyp3_vld_en_d1 ;
1489
 
1490
wire    thread0_e,thread1_e,thread2_e,thread3_e;
1491
wire    thread0_d,thread1_d,thread2_d,thread3_d;
1492
wire    thread0_m,thread1_m,thread2_m,thread3_m;
1493
wire    thread0_g,thread1_g,thread2_g,thread3_g;
1494
wire    thread0_w2,thread1_w2,thread2_w2,thread3_w2;
1495
wire    thread0_w3,thread1_w3,thread2_w3,thread3_w3;
1496
wire    tlu_stxa_thread0_w2,tlu_stxa_thread1_w2 ;
1497
wire    tlu_stxa_thread2_w2,tlu_stxa_thread3_w2 ;
1498
wire    tlu_ldxa_thread0_w2,tlu_ldxa_thread1_w2 ;
1499
wire    tlu_ldxa_thread2_w2,tlu_ldxa_thread3_w2 ;
1500
wire    spu_ldxa_thread0_w2,spu_ldxa_thread1_w2 ;
1501
wire    spu_ldxa_thread2_w2,spu_ldxa_thread3_w2 ;
1502
wire    spu_stxa_thread0,spu_stxa_thread1 ;
1503
wire    spu_stxa_thread2,spu_stxa_thread3 ;
1504
wire    ifu_ldxa_thread0_w2,ifu_ldxa_thread1_w2 ;
1505
wire    ifu_ldxa_thread2_w2,ifu_ldxa_thread3_w2 ;
1506
wire    ifu_stxa_thread0_w2,ifu_stxa_thread1_w2 ;
1507
wire    ifu_stxa_thread2_w2,ifu_stxa_thread3_w2 ;
1508
wire    ldbyp0_vld, ldbyp1_vld, ldbyp2_vld, ldbyp3_vld ;
1509
//wire    ld_any_byp_data_vld ;              
1510
wire  [3:0] asi_state_wr_thrd;
1511
wire  [3:0] pctxt_state_wr_thrd ;
1512
wire  [3:0] sctxt_state_wr_thrd ;
1513
wire    tlb_cam_hit_g ;
1514
wire    ld_inst_vld_unflushed ;
1515
wire    st_inst_vld_unflushed ;
1516
 
1517
wire  [7:0]  baddr_m ;
1518
wire  [15:0]  byte_wr_enable ;
1519
//wire  [1:0] st_size ;
1520
//wire    l2fill_bendian_g ;
1521
wire    ldst_byte,ldst_hword,ldst_word,ldst_dword;
1522
wire    byte_m,hword_m,word_m,dword_m;
1523
wire    tlb_invert_endian_g ;
1524
//wire  [7:0] l2fill_bytes_msb_m, l2fill_bytes_msb_g ;
1525
//wire    byte_g, hword_g, word_g ;
1526
 
1527
   wire signed_ldst_m ;
1528
//wire  unsigned_ldst_m ;
1529
//wire    sign_bit_g  ;
1530
//wire  [7:0] align_bytes_msb ;
1531
 
1532
wire    l2fill_vld_m, l2fill_vld_g ;
1533
wire    l2fill_fpld_e, l2fill_fpld_m, l2fill_fpld_g ;
1534
wire    pstate_cle_e, pstate_cle_m, pstate_cle_g ;
1535
wire    l1hit_lendian_g ;
1536
wire    l1hit_sign_extend_m, l1hit_sign_extend_g ;
1537
wire    demap_thread0, demap_thread1, demap_thread2, demap_thread3 ;
1538
 
1539
wire    misc_byte_m,misc_hword_m,misc_word_m,misc_dword_m;
1540
wire    byp_word_g;
1541
//wire  [15:0]  byp_baddr_g ;
1542
//wire    ld_stb_hit_g ;
1543
wire    atomic_ld_squash_e ;
1544
wire    atomic_m,atomic_g,atomic_w2, atomic_w3 ;
1545
wire  [2:0] ld_rq_type ;
1546
wire    ncache_pcx_rq_g ;
1547
wire    lmq_pkt_vld_g ;
1548
wire    tlb_lng_ltncy_asi_d,tlb_lng_ltncy_asi_e, tlb_lng_ltncy_asi_m,tlb_lng_ltncy_asi_g ;
1549
wire    recognized_asi_d,recognized_asi_e,recognized_asi_m,recognized_asi_g,recognized_asi_tmp ;
1550
wire    asi_internal_d, asi_internal_e ;
1551
wire    asi_internal_m, asi_internal_g ;
1552
wire    dcache_byp_asi_d, dcache_byp_asi_e ;
1553
wire    dcache_byp_asi_m, dcache_byp_asi_g ;
1554
wire    phy_use_ec_asi_d,phy_use_ec_asi_e,phy_use_ec_asi_m;
1555
wire    phy_byp_ec_asi_d,phy_byp_ec_asi_e,phy_byp_ec_asi_m;
1556
wire    lendian_asi_d, lendian_asi_e;
1557
wire    lendian_asi_m, lendian_asi_g;
1558
wire    intrpt_disp_asi_d,intrpt_disp_asi_e,intrpt_disp_asi_m,intrpt_disp_asi_g ;
1559
wire    nofault_asi_d, nofault_asi_e, nofault_asi_m ;
1560
wire    nucleus_asi_d, nucleus_asi_e ;
1561
wire    primary_asi_d, primary_asi_e ;
1562
wire    quad_asi_d,quad_asi_e,quad_asi_m,quad_asi_g;
1563
wire    binit_quad_asi_d,binit_quad_asi_e,binit_quad_asi_m,binit_quad_asi_g ;
1564
wire    secondary_asi_d, secondary_asi_e ;
1565
wire    tlb_byp_asi_d, tlb_byp_asi_e;
1566
wire    thread0_ctxt, thread1_ctxt ;
1567
wire    thread2_ctxt, thread3_ctxt ;
1568
 
1569
 
1570
wire    altspace_ldst_e, non_altspace_ldst_e ;
1571
wire    altspace_ldst_m, altspace_ldst_g ;
1572
wire    non_altspace_ldst_m, non_altspace_ldst_g ;
1573
wire    thread_pctxt, thread_sctxt, thread_nctxt, thread_actxt ;
1574
wire    ncache_asild_rq_g ;
1575
//SC wire    pstate_priv, pstate_priv_m ;
1576
//SC wire    priv_pg_usr_mode ;
1577
//SC wire    nonwr_pg_st_access ;
1578
//SC wire    nfo_pg_nonnfo_asi ;
1579
//wire    daccess_excptn ;
1580
wire    mbar_inst_m,flsh_inst_m ;
1581
wire    mbar_inst_g,flsh_inst_g ;
1582
wire    bsync0_reset,bsync1_reset;
1583
wire    bsync2_reset,bsync3_reset ;
1584
wire    bsync0_en,bsync1_en ;
1585
wire    bsync2_en,bsync3_en ;
1586
wire    flush_inst0_g,mbar_inst0_g ;
1587
wire    flush_inst1_g,mbar_inst1_g ;
1588
wire    flush_inst2_g,mbar_inst2_g ;
1589
wire    flush_inst3_g,mbar_inst3_g ;
1590
wire    dfill_thread0,dfill_thread1;
1591
wire    dfill_thread2,dfill_thread3;
1592
wire    mbar_vld0, flsh_vld0 ;
1593
wire    mbar_vld1, flsh_vld1 ;
1594
wire    mbar_vld2, flsh_vld2 ;
1595
wire    mbar_vld3, flsh_vld3 ;
1596
   wire [1:0] dfq_tid_m,dfq_tid_g;
1597
 
1598
wire  [1:0]   ldbyp_tid_m ;
1599
wire    stxa_stall_asi_g ;
1600
wire    stxa_stall_wr_cmplt0, stxa_stall_wr_cmplt1 ;
1601
wire    stxa_stall_wr_cmplt2, stxa_stall_wr_cmplt3 ;
1602
wire    stxa_stall_wr_cmplt0_d1, stxa_stall_wr_cmplt1_d1 ;
1603
wire    stxa_stall_wr_cmplt2_d1, stxa_stall_wr_cmplt3_d1 ;
1604
wire    dtlb_done ;
1605
wire    tag_rd_vld_m, tag_rd_vld_g ;
1606
wire    data_rd_vld_m, data_rd_vld_g ;
1607
wire    tlb_demap_vld ;
1608
wire    dtlb_done_d1 ;
1609
wire    dtlb_done_d2 ;
1610
 
1611
 
1612
wire    tlu_lsu_asi_update_g ;
1613
wire  [1:0] tlu_lsu_tid_g ;
1614
wire    tsa_update_asi0,tsa_update_asi1;
1615
wire    tsa_update_asi2,tsa_update_asi3;
1616
wire    tlb_ld_inst0,tlb_ld_inst1,tlb_ld_inst2,tlb_ld_inst3 ;
1617
wire    tlb_st_inst0,tlb_st_inst1,tlb_st_inst2,tlb_st_inst3 ;
1618
wire    tlb_access_en0_e,tlb_access_en1_e,tlb_access_en2_e,tlb_access_en3_e ;
1619
wire    tlb_access_en0_m,tlb_access_en1_m,tlb_access_en2_m,tlb_access_en3_m ;
1620
wire    tlb_access_en0_tmp,tlb_access_en1_tmp,tlb_access_en2_tmp,tlb_access_en3_tmp ;
1621
wire    tlb_access_en0_g,tlb_access_en1_g,tlb_access_en2_g,tlb_access_en3_g ;
1622
wire    tlb_access_en0_unflushed,tlb_access_en1_unflushed,tlb_access_en2_unflushed,tlb_access_en3_unflushed ;
1623
wire    tlb_access_rst0,tlb_access_rst1,tlb_access_rst2,tlb_access_rst3 ;
1624
wire    tlb_access_sel_thrd0,tlb_access_sel_thrd1;
1625
wire    tlb_access_sel_thrd2,tlb_access_sel_thrd3;
1626
wire    tlb_access_blocked ;
1627
wire    tlb_access_pending ;
1628
wire    tlb_access_initiated ;
1629
//wire    tlb_pending_access_rst ;
1630
 
1631
wire    vw_wtchpt_cmp_en_m,vr_wtchpt_cmp_en_m ;
1632
 
1633
 
1634
//wire    va_b12_3_match_m,va_b47_40_match_m ;
1635
//wire    va_b12_3_match_g,va_b47_40_match_g ;
1636
//wire    wtchpt_msk_match_m,wtchpt_msk_match_g ;
1637
 
1638
wire    as_if_user_asi_d,as_if_user_asi_e,as_if_user_asi_m;
1639
//SC wire    as_if_usr_priv_pg ;
1640
//SC wire    priv_action,priv_action_m ;
1641
//SC wire    stdf_maddr_not_align, lddf_maddr_not_align ;
1642
//wire  [8:0] early_ttype_m,early_ttype_g ; 
1643
//wire    early_trap_vld_m, early_trap_vld_g ;  
1644
//SC wire    atm_access_w_nc, atm_access_unsup_asi ;
1645
wire    atomic_asi_d,atomic_asi_e,atomic_asi_m ;
1646
//wire    dflush_asi_d,dflush_asi_e,dflush_asi_m,dflush_asi_g;  
1647
wire    blk_asi_d,blk_asi_e,blk_asi_m, blk_asi_g ;
1648
 
1649
wire    fpld_byp_data_vld ;
1650
//wire  [7:0] dcache_rd_parity ;
1651
wire    dcache_rd_parity_error ;
1652
//SC wire    tte_data_parity_error ;
1653
 
1654
wire  [3:0]   dtag_parity_error;
1655
//wire    dtag_mtag_parity_error ;
1656
//wire    daccess_error ;
1657
//SC wire    dmmu_miss_g ;
1658
wire  [2:0]   ctxt_sel_e ;
1659
wire    dc_diagnstc_asi_d, dc_diagnstc_asi_e ;
1660
wire    dc_diagnstc_asi_m, dc_diagnstc_asi_g ;
1661
wire    dtagv_diagnstc_asi_d, dtagv_diagnstc_asi_e ;
1662
wire    dtagv_diagnstc_asi_m, dtagv_diagnstc_asi_g ;
1663
//wire    dc_diagnstc_wr_e,dtagv_diagnstc_wr_e ;
1664
//wire    dside_diagnstc_wr_e ;
1665
wire    dc_diagnstc_wr_en,dtagv_diagnstc_wr_en ;
1666
 
1667
wire  dtagv_diagnstc_rd_g ;
1668
wire  dc0_diagnstc_asi,dtagv0_diagnstc_asi;
1669
wire  dc1_diagnstc_asi,dtagv1_diagnstc_asi;
1670
wire  dc2_diagnstc_asi,dtagv2_diagnstc_asi;
1671
wire  dc3_diagnstc_asi,dtagv3_diagnstc_asi;
1672
//wire [3:0] lngltncy_st_go ;
1673
wire  [3:0]   tlb_st_data_sel_m ;
1674
wire  dc0_diagnstc_wr_en, dc1_diagnstc_wr_en, dc2_diagnstc_wr_en, dc3_diagnstc_wr_en ;
1675
wire  dtagv0_diagnstc_wr_en, dtagv1_diagnstc_wr_en, dtagv2_diagnstc_wr_en, dtagv3_diagnstc_wr_en ;
1676
//wire  merge2_sel_byte7, merge3_sel_byte7 ; 
1677
//SC wire  hw_align_addr,wd_align_addr,dw_align_addr;
1678
wire   hw_size,wd_size,dw_size;
1679
//SC wire  mem_addr_not_align ;
1680
 
1681
wire  wr_only_asi_d,wr_only_asi_e,wr_only_asi_m ;
1682
wire  rd_only_asi_d,rd_only_asi_e,rd_only_asi_m ;
1683
wire  mmu_rd_only_asi_d,mmu_rd_only_asi_e,mmu_rd_only_asi_m ;
1684
wire  unimp_asi_d,unimp_asi_e,unimp_asi_m;
1685
wire  dmmu_asi58_d,dmmu_asi58_e,dmmu_asi58_m;
1686
wire  immu_asi50_d,immu_asi50_e,immu_asi50_m;
1687
 
1688
wire  ifu_asi_store ;
1689
wire  nontlb_asi0, nontlb_asi1, nontlb_asi2, nontlb_asi3 ;
1690
//wire  stxa_stall_reset ;
1691
wire  ifu_nontlb0_asi,ifu_nontlb1_asi,ifu_nontlb2_asi,ifu_nontlb3_asi;
1692
wire  ifu_nontlb_asi_d, ifu_nontlb_asi_e,ifu_nontlb_asi_m,ifu_nontlb_asi_g ;
1693
wire  [2:0] lsu_asi_sel_fmx1 ;
1694
wire  [2:0] lsu_asi_sel_fmx2;
1695
wire    lsu_asi_rd_en, lsu_asi_rd_en_w2 ;
1696
//wire  [12:0]  pctxt_state ;
1697
//wire  [12:0]  sctxt_state ;
1698
 
1699
//wire  [1:0] dcache_rand,dcache_rand_new ;
1700
wire    dtlb_inv_all_e,dtlb_inv_all_m ;
1701
wire  dtlb_wr_vld_d1,dtlb_tag_rd_d1,dtlb_data_rd_d1,dtlb_dmp_vld_d1,dtlb_inv_all_d1 ;
1702
wire  ldst_in_pipe ;
1703
wire  tlbop_init, tlbop_init_d1, tlbop_init_d2 ;
1704
wire  tlbop_init_d3, tlbop_init_d4, tlbop_init_d5 ;
1705
wire  [3:0] ldxa_illgl_va_cmplt,ldxa_illgl_va_cmplt_d1 ;
1706
 
1707
wire  lsuctl_va_vld ;
1708
wire  lsuctl_illgl_va ;
1709
wire  sctxt_va_vld;
1710
//wire  scxt_ldxa_illgl_va ;
1711
wire  pctxt_va_vld;
1712
 
1713
wire  pscxt_ldxa_illgl_va ;
1714
wire  lsu_asi_illgl_va ;
1715
wire  [3:0] lsu_asi_illgl_va_cmplt,lsu_asi_illgl_va_cmplt_w2 ;
1716
wire  bistctl_va_vld,mrgnctl_va_vld,ldiagctl_va_vld ;
1717
wire  bistctl_state_en,mrgnctl_state_en,ldiagctl_state_en ;
1718
wire  mrgnctl_illgl_va ;
1719
wire  asi42_illgl_va ;
1720
 
1721
wire    [3:0]   tap_thread ;
1722
wire    mrgn_tap_wr_en ;
1723
wire    bist_tap_wr_en ;
1724
 
1725
wire [3:0] dfture_tap_rd_d1;
1726
wire [3:0] dfture_tap_wr_en;
1727
 
1728
//wire  dfture_tap_rd_sel ;
1729
 
1730
wire  misc_asi_rd_en ;
1731
 
1732
wire [3:0]  lsuctl_ctlbits_wr_en ;
1733
wire  bistctl_wr_en;
1734
wire  mrgnctl_wr_en;
1735
//wire  ldiagctl_rd_en,ldiagctl_wr_en;
1736
wire  casa_m, casa_g ;
1737
wire  tte_data_perror_unc ;
1738
wire  asi_tte_data_perror,asi_tte_tag_perror ;
1739
 
1740
wire  [1:0] dfill_tid_m,dfill_tid_g ;
1741
wire  dtag_error_m,dcache_error_m;
1742
wire  dtag_error_g,dcache_error_g;
1743
wire  dtag_error_w2,dcache_error_w2;
1744
wire  l2_unc_error_e,l2_corr_error_e;
1745
wire  l2_unc_error_m,l2_corr_error_m;
1746
wire  l2_unc_error_g,l2_corr_error_g;
1747
wire  l2_unc_error_w2,l2_corr_error_w2;
1748
wire  unc_err_trap_e,unc_err_trap_m,unc_err_trap_g ;
1749
//wire  corr_err_trap_e, corr_err_trap_m, corr_err_trap_g ;
1750
wire  dtag_perror_g ;
1751
 
1752
 
1753
wire  ifill_tlb_asi_d,dfill_tlb_asi_d,rd_only_ltlb_asi_d,wr_only_ltlb_asi_d ;
1754
wire  ifill_tlb_asi_e,dfill_tlb_asi_e,rd_only_ltlb_asi_e,wr_only_ltlb_asi_e ;
1755
//SC wire  tlb_daccess_excptn_e,tlb_daccess_error_e  ;
1756
//SC wire  tlb_daccess_excptn_m,tlb_daccess_error_m  ;
1757
//SC wire  tlb_daccess_excptn_g,tlb_daccess_error_g  ;
1758
wire  thread_tl_zero ;
1759
wire    pid_va_vld, pid_state_en ;
1760
wire    [3:0]    pid_state_wr_en ;
1761
 
1762
//wire  [3:0]   pid_state_rd_en ;
1763
//wire  [2:0]   pid_state ;
1764
wire    [3:0]   intld_byp_cmplt ;
1765
 
1766
//wire  hpv_priv,hpstate_en ;   
1767
wire    hpv_priv_m,hpstate_en_m ;
1768
wire    hpv_priv_e,hpstate_en_e ;
1769
wire    blkst_m, blkst_g ;
1770
//wire  dc_direct_map ;         
1771
wire    spubyp_trap_active_e,spubyp_trap_active_m, spubyp_trap_active_g ;
1772
wire [6:0] spubyp_ttype ;
1773
wire    spu_trap ;
1774
wire    spu_trap0, spu_trap1, spu_trap2, spu_trap3 ;
1775
wire    [6:0]    spu_ttype ;
1776
wire    spubyp0_trap,spubyp1_trap,spubyp2_trap,spubyp3_trap;
1777
wire [6:0]       spubyp0_ttype,spubyp1_ttype,spubyp2_ttype,spubyp3_ttype;
1778
wire    bendian_g ;
1779
//wire va_wtchpt_rd_en, pa_wtchpt_rd_en;   
1780
//wire lsu_bendian_access_g;
1781
wire      lsu_tlb_tag_rd_vld_g ;
1782
wire      lsu_dtlb_invalid_all_m ;
1783
 
1784
wire  [3:0]   dva_vld_g;
1785
wire          lsu_diagnstc_asi_rd_en;
1786
wire  [3:0]   ld_thrd_byp_sel_g ;
1787
wire  [3:0]           lmq_byp_data_sel0 ;     // ldxa vs stb bypass data sel.
1788
wire  [3:0]           lmq_byp_data_sel1 ;     // ldxa vs stb bypass data sel.
1789
wire  [3:0]           lmq_byp_data_sel2 ;     // ldxa vs stb bypass data sel.
1790
wire  [3:0]           lmq_byp_data_sel3 ;     // ldxa vs stb bypass data sel.
1791
wire  [2:0]           lmq_byp_ldxa_sel0 ;     // ldxa data sel - thread0
1792
wire  [2:0]           lmq_byp_ldxa_sel1 ;     // ldxa data sel - thread1
1793
wire  [2:0]           lmq_byp_ldxa_sel2 ;     // ldxa data sel - thread2
1794
wire  [2:0]           lmq_byp_ldxa_sel3 ;     // ldxa data sel - thread3
1795
wire    endian_mispred_g ;
1796
 
1797
   wire       ld_inst_vld_w2, ld_inst_vld_w3;
1798
 
1799
   wire [3:0] lmq_byp_data_raw_sel_d1;
1800
   wire [3:0] lmq_byp_data_raw_sel_d2;
1801
 
1802
wire    asi_st_vld_g ;
1803
wire  ignore_fill;
1804
 
1805
wire  [3:0]  pend_atm_ld_ue ;
1806
 
1807
wire [2:0]   lsu_byp_misc_addr_m ;   // lower 3bits of addr for ldxa/raw etc
1808
wire [1:0]   lsu_byp_misc_sz_m ;     // size for ldxa/raw etc
1809
 
1810
//==========================================================
1811
//RESET, CLK
1812
//==========================================================     
1813
   wire       reset;
1814
 
1815
//   assign     reset = ~rst_l;
1816
   wire       dbb_reset_l;
1817
   wire       clk;
1818
 
1819
    dffrl_async rstff(.din (grst_l),
1820
                        .q   (dbb_reset_l),
1821
                        .clk (clk), .se(se), .si(), .so(),
1822
                        .rst_l (arst_l));
1823
 
1824
   assign  reset  =  ~dbb_reset_l;
1825
   assign dctl_rst_l = dbb_reset_l;
1826
   assign clk = rclk;
1827
 
1828
wire      lsu_bist_wvld_e ;           // bist writes to cache
1829
wire            lsu_bist_rvld_e ;                 // bist reads dcache
1830
 
1831
dff #(2) mbist_stge (
1832
   .din ({mbist_dcache_write, mbist_dcache_read}),
1833
   .q   ({lsu_bist_wvld_e,    lsu_bist_rvld_e  }),
1834
   .clk (clk),
1835
   .se  (se),       .si (),          .so ()
1836
);
1837
 
1838
//===========================================================
1839
//from lsu_excpctl
1840
//wire          lsu_flush_pipe_w ;      // flush - local to lsu
1841
 
1842
//   assign lsu_flush_pipe_w = dctl_flush_pipe_w;
1843
 
1844
//===========================================================
1845
//   
1846
   assign     lsu_ldst_inst_vld_e = ld_inst_vld_e | st_inst_vld_e;
1847
 
1848
//wire    lsu_l2fill_bendian_g;
1849
 
1850
wire memref_e;
1851
 
1852
dff #(1) stge_ad_e (
1853
  .din (ifu_lsu_memref_d),
1854
  .q   (memref_e),
1855
  .clk (clk),
1856
  .se     (se),       .si (),          .so ()
1857
);
1858
 
1859
//=================================================================================================
1860
// SHADOW SCAN
1861
//=================================================================================================
1862
 
1863
wire    sscan_data_13, sscan_data_14 ;
1864
// stb status - this monitors the stb state
1865
assign sscan_data_13 =
1866
  ctu_sscan_tid[0] & lsu_stb_empty[0] |
1867
  ctu_sscan_tid[1] & lsu_stb_empty[1] |
1868
  ctu_sscan_tid[2] & lsu_stb_empty[2] |
1869
  ctu_sscan_tid[3] & lsu_stb_empty[3] ;
1870
 
1871
 
1872
// Monitors outstanding long-latency asi transactions - hangs thread. Doesn't cover all asi.
1873
assign  sscan_data_14 =
1874
                ctu_sscan_tid[0] & (tlb_ld_inst0 | tlb_st_inst0) |
1875
                ctu_sscan_tid[1] & (tlb_ld_inst1 | tlb_st_inst1) |
1876
                        ctu_sscan_tid[2] & (tlb_ld_inst2 | tlb_st_inst2) |
1877
                ctu_sscan_tid[3] & (tlb_ld_inst3 | tlb_st_inst3) ;
1878
 
1879
 
1880
dff #(2) stg_d1 (
1881
  .din ({sscan_data_14,sscan_data_13}),
1882
  .q   (lsu_sscan_data[14:13]),
1883
  .clk (clk),
1884
  .se     (se),       .si (),          .so ()
1885
);
1886
 
1887
//=========================================================================================
1888
//  INST_VLD_W GENERATION
1889
//=========================================================================================
1890
 
1891
wire    flush_w_inst_vld_m ;
1892
wire    lsu_inst_vld_w ;
1893
assign  flush_w_inst_vld_m =
1894
        ifu_tlu_inst_vld_m &
1895
        ~(dctl_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
1896
 
1897
dff  stgw_ivld (
1898
        .din    (flush_w_inst_vld_m),
1899
        .q      (lsu_inst_vld_w),
1900
        .clk    (clk),
1901
        .se     (se),       .si (),          .so ()
1902
        );
1903
 
1904
 
1905
// Specifically for qctl2. Does not include flush-pipe, but does include ifu's flush.
1906
wire    ld_vld ;
1907
 
1908
   wire ifu_lsu_flush_w;
1909
 
1910
   wire ifu_tlu_flush_fd_w_q, ifu_tlu_flush_fd2_w_q, ifu_tlu_flush_fd3_w_q;
1911
 
1912
dff #(4) ifu_tlu_flush_stgw (
1913
        .din    ({ifu_tlu_flush_m,ifu_tlu_flush_m,     ifu_tlu_flush_m,      ifu_tlu_flush_m}     ),
1914
        .q      ({ifu_lsu_flush_w,ifu_tlu_flush_fd_w_q,ifu_tlu_flush_fd2_w_q,ifu_tlu_flush_fd3_w_q}),
1915
        .clk    (clk),
1916
        .se     (se),       .si (),          .so ()
1917
        );
1918
 
1919
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd_w  ( .a(ifu_tlu_flush_fd_w_q),  .z(ifu_tlu_flush_fd_w)  );
1920
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd2_w ( .a(ifu_tlu_flush_fd2_w_q), .z(ifu_tlu_flush_fd2_w) );
1921
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd3_w ( .a(ifu_tlu_flush_fd3_w_q), .z(ifu_tlu_flush_fd3_w) );
1922
 
1923
assign  ld_vld = ld_inst_vld_unflushed & lsu_inst_vld_w & ~ifu_lsu_flush_w ;
1924
wire    ld_vld_w_flush ;
1925
assign  ld_vld_w_flush = ld_vld & ~dctl_flush_pipe_w ;
1926
assign  lsu_ld_inst_vld_g[0] = ld_vld_w_flush & thread0_g ;
1927
assign  lsu_ld_inst_vld_g[1] = ld_vld_w_flush & thread1_g ;
1928
assign  lsu_ld_inst_vld_g[2] = ld_vld_w_flush & thread2_g ;
1929
assign  lsu_ld_inst_vld_g[3] = ld_vld_w_flush & thread3_g ;
1930
 
1931
//=========================================================================================
1932
//  TLB Control 
1933
//=========================================================================================
1934
 
1935
wire    alt_space_e ;
1936
dff #(1) aspace_e (
1937
        .din    (ifu_lsu_alt_space_d),
1938
        .q      (alt_space_e),
1939
        .clk    (clk),
1940
        .se     (se),       .si (),          .so ()
1941
        );
1942
 
1943
//Atomics require translation.
1944
assign tlb_ldst_cam_vld =
1945
  memref_e &
1946
    ~dtlb_bypass_e & ~(asi_internal_e & alt_space_e)  ;
1947
 
1948
// in hyper-lite mode, assumption is that real translation is not supported -
1949
// a miss in tlb with real-translation enabled would result in real-address
1950
// translation miss. This would be purely accidental on software's part.
1951
//wire  dtlb_real_byp_e ;
1952
//assign        dtlb_real_byp_e = hpstate_en_e & ~hpv_priv_e ;
1953
// In hyper-lite mode, no concept of real xslation.
1954
assign  lsu_dtlb_cam_real_e =
1955
        // lsu-ctl based RA->PA 
1956
  ( lsuctl_dtlb_byp_e & ~hpv_priv_e & hpstate_en_e) |
1957
        // means RA->PA if used by hypervisor.
1958
  ( tlb_byp_asi_e & hpstate_en_e & altspace_ldst_e) ;
1959
  //( tlb_byp_asi_e & dtlb_real_byp_e & altspace_ldst_e) ;  
1960
 
1961
assign  demap_thread0 = ~tlb_demap_thrid[1] & ~tlb_demap_thrid[0] ;
1962
assign  demap_thread1 = ~tlb_demap_thrid[1] &  tlb_demap_thrid[0] ;
1963
assign  demap_thread2 =  tlb_demap_thrid[1] & ~tlb_demap_thrid[0] ;
1964
assign  demap_thread3 =  tlb_demap_thrid[1] &  tlb_demap_thrid[0] ;
1965
 
1966
// demap access and regular ldst access to tlb are assumed to
1967
// be mutex.
1968
assign thread0_ctxt =   ( demap_thread0 & tlb_demap_vld) |
1969
      (~tlb_demap_vld & thread0_e) ;
1970
      //(thread0_e & memref_e) ;
1971
assign thread1_ctxt =   ( demap_thread1 & tlb_demap_vld) |
1972
      (~tlb_demap_vld & thread1_e) ;
1973
      //(thread1_e & memref_e) ;
1974
assign thread2_ctxt =   ( demap_thread2 & tlb_demap_vld) |
1975
      (~tlb_demap_vld & thread2_e) ;
1976
      //(thread2_e & memref_e) ;
1977
assign thread3_ctxt =   ( demap_thread3 & tlb_demap_vld) |
1978
      (~tlb_demap_vld & thread3_e) ;
1979
      //(thread3_e & memref_e) ;
1980
 
1981
assign  altspace_ldst_e   = memref_e &  alt_space_e ;
1982
assign  non_altspace_ldst_e = memref_e & ~alt_space_e ;
1983
 
1984
dff #(2) aspace_stgm (
1985
        .din    ({altspace_ldst_e,non_altspace_ldst_e}),
1986
        .q      ({altspace_ldst_m,non_altspace_ldst_m}),
1987
        .clk    (clk),
1988
        .se     (se),       .si (),          .so ()
1989
        );
1990
 
1991
dff #(2) aspace_stgg (
1992
        .din    ({altspace_ldst_m,non_altspace_ldst_m}),
1993
        .q      ({altspace_ldst_g,non_altspace_ldst_g}),
1994
        .clk    (clk),
1995
        .se     (se),       .si (),          .so ()
1996
        );
1997
 
1998
wire    [3:0]    tl_zero_d1 ;
1999
dff #(4) tlz_stgd1 (
2000
        .din    (tlu_lsu_tl_zero[3:0]),
2001
        .q      (tl_zero_d1[3:0]),
2002
        .clk    (clk),
2003
        .se     (se),       .si (),          .so ()
2004
        );
2005
 
2006
mux4ds  #(1) trap_level_zero_mux (
2007
        .in0    (tl_zero_d1[0]),
2008
        .in1    (tl_zero_d1[1]),
2009
        .in2    (tl_zero_d1[2]),
2010
        .in3    (tl_zero_d1[3]),
2011
        .sel0   (thread0_e),
2012
        .sel1   (thread1_e),
2013
        .sel2   (thread2_e),
2014
        .sel3   (thread3_e),
2015
        .dout   (thread_tl_zero)
2016
);
2017
 
2018
wire    thread_tl_zero_m ;
2019
dff #(1) ttlz_stgm (
2020
        .din    (thread_tl_zero),
2021
        .q      (thread_tl_zero_m),
2022
        .clk    (clk),
2023
        .se     (se),       .si (),          .so ()
2024
        );
2025
 
2026
 
2027
assign  lsu_nonalt_nucl_access_m = non_altspace_ldst_m & ~thread_tl_zero_m ;
2028
 
2029
// Note : autodemap will need to be or'ed into tlb_demap_vld !!!
2030
// use of tlu_lsu_tl_zero needs to be threaded.
2031
assign  thread_pctxt =  ( tlb_demap_pctxt     &  tlb_demap_vld)      |  // demap
2032
      ( non_altspace_ldst_e &  thread_tl_zero) |  // ldst. non-alt- space
2033
      ( altspace_ldst_e     &  primary_asi_e)      |  // ldst. alt_space
2034
      (~(memref_e | tlb_demap_vld)) ; // default for pipe
2035
      //(~(ld_inst_vld_e | st_inst_vld_e | tlb_demap_vld)) ; // default for pipe
2036
assign  thread_sctxt =  ( tlb_demap_sctxt     &  tlb_demap_vld)      |  // demap
2037
      ( altspace_ldst_e     &  secondary_asi_e) ; // ldst. alt_space
2038
assign  thread_nctxt =  ( tlb_demap_nctxt     &  tlb_demap_vld)      |  // demap
2039
      ( non_altspace_ldst_e & ~thread_tl_zero) |  // ldst. non-alt- space
2040
      ( altspace_ldst_e     &  nucleus_asi_e) ; // ldst. alt_space
2041
assign  thread_actxt =  tlb_demap_actxt & tlb_demap_vld ;
2042
 
2043
//tmp
2044
   wire thread_default;
2045
   assign thread_default = ~(thread_pctxt | thread_sctxt | thread_actxt);
2046
 
2047
wire    [3:0]    pstate_am ;
2048
dff #(4) psam_stgd1 (
2049
        .din    (tlu_lsu_pstate_am[3:0]),
2050
        .q      (pstate_am[3:0]),
2051
        .clk    (clk),
2052
        .se     (se),       .si (),          .so ()
2053
        );
2054
 
2055
//assign  lsu_dtlb_addr_mask_l_e = 
2056
//  thread0_e ? ~pstate_am[0] :
2057
//    thread1_e ? ~pstate_am[1] :
2058
//      thread2_e ? ~pstate_am[2] :
2059
//          ~pstate_am[3] ;
2060
 
2061
mux4ds  #(1) pstate_am_mux (
2062
        .in0    (~pstate_am[0]),
2063
        .in1    (~pstate_am[1]),
2064
        .in2    (~pstate_am[2]),
2065
        .in3    (~pstate_am[3]),
2066
        .sel0   (thread0_e),
2067
        .sel1   (thread1_e),
2068
        .sel2   (thread2_e),
2069
        .sel3   (thread3_e),
2070
        .dout   (lsu_dtlb_addr_mask_l_e)
2071
);
2072
 
2073
//=========================================================================================
2074
//  TLB RD/WR/DMP HANDLING
2075
//=========================================================================================
2076
 
2077
// To speed up the tlb miss handler, wr_vld will now be generated based on
2078
// admp occurence. lsu_dtlb_wr_vld_g is to be ignored. The following paths
2079
// can be improved
2080
// admp->write initiation (+2)
2081
// write->completion initiation (+3)
2082
 
2083
wire admp_write ;
2084
assign  admp_write = lsu_dtlb_dmp_vld_e & tlb_demap_actxt ;
2085
wire admp_rst ;
2086
assign  admp_rst = reset | lsu_dtlb_wr_vld_e ;
2087
 
2088
wire    local_dtlb_wr_vld_g ;
2089
dffre #(1) twr_stgd1 (
2090
        .din    (admp_write),
2091
        .q      (local_dtlb_wr_vld_g),
2092
        .clk    (clk),
2093
        .en     (admp_write),   .rst    (admp_rst),
2094
        .se     (se),       .si (),          .so ()
2095
        );
2096
 
2097
 
2098
wire    dtlb_wr_init_d1,dtlb_wr_init_d2,dtlb_wr_init_d3 ;
2099
// Handshake between tlu and lsu needs to be fine-tuned !!!
2100
assign  lsu_dtlb_wr_vld_e =  local_dtlb_wr_vld_g & ~(memref_e | dtlb_wr_init_d1 | dtlb_wr_init_d2) ;
2101
//assign  lsu_dtlb_wr_vld_e =  tlu_dtlb_wr_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2102
assign  lsu_dtlb_tag_rd_e =  tlu_dtlb_tag_rd_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2103
assign  lsu_dtlb_data_rd_e =  tlu_dtlb_data_rd_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2104
assign  lsu_dtlb_dmp_vld_e =  tlu_dtlb_dmp_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2105
 
2106
   wire lsu_dtlb_dmp_all_e_tmp;
2107
 
2108
assign  lsu_dtlb_dmp_all_e_tmp =  tlu_dtlb_dmp_all_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2109
 bw_u1_buf_5x UZsize_lsu_dtlb_dmp_all_e (.a(lsu_dtlb_dmp_all_e_tmp), .z(lsu_dtlb_dmp_all_e));
2110
 
2111
assign  lsu_dtlb_rwindex_vld_e =  tlu_dtlb_rw_index_vld_g & ~(memref_e | dtlb_wr_init_d1 | dtlb_wr_init_d2) ;
2112
//assign  lsu_dtlb_rwindex_vld_e =  tlu_dtlb_rw_index_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2113
// Can remove reset once invalidate asi in place !!!
2114
// assign lsu_dtlb_invalid_all_w2 = reset | tlu_dtlb_invalidate_all_g ;
2115
 
2116
assign  tlb_demap_vld = lsu_dtlb_dmp_vld_e ;
2117
 
2118
// Switchout for threads. Force threads to swo if tlb operation does not occur for over 5 cycles.
2119
 
2120
dff #(5) tlbop_stgd1 (
2121
        //.din    ({tlu_dtlb_wr_vld_g,tlu_dtlb_tag_rd_g,tlu_dtlb_data_rd_g,tlu_dtlb_dmp_vld_g,
2122
        .din    ({local_dtlb_wr_vld_g,tlu_dtlb_tag_rd_g,tlu_dtlb_data_rd_g,tlu_dtlb_dmp_vld_g,
2123
    tlu_dtlb_invalidate_all_g}),
2124
        .q      ({dtlb_wr_vld_d1,dtlb_tag_rd_d1,dtlb_data_rd_d1,dtlb_dmp_vld_d1,
2125
    dtlb_inv_all_d1}),
2126
        .clk    (clk),
2127
        .se     (se),       .si (),          .so ()
2128
        );
2129
 
2130
// Detect event.
2131
//bug6193 / ECO bug6511   
2132
assign  ldst_in_pipe = memref_e ;
2133
assign tlbop_init =
2134
  ((~dtlb_wr_vld_d1 & local_dtlb_wr_vld_g)  |
2135
  (~dtlb_tag_rd_d1  & tlu_dtlb_tag_rd_g)   |
2136
  (~dtlb_data_rd_d1 & tlu_dtlb_data_rd_g) |
2137
  (~dtlb_inv_all_d1 & tlu_dtlb_invalidate_all_g) |
2138
  (~dtlb_dmp_vld_d1 & tlu_dtlb_dmp_vld_g)) & ldst_in_pipe ;
2139
 
2140
dff #(1) tlbinit_stgd1 ( .din    (tlbop_init), .q      (tlbop_init_d1),
2141
        .clk    (clk), .se     (se),       .si (),          .so ());
2142
dff #(1) tlbinit_stgd2 ( .din    (tlbop_init_d1 &  ldst_in_pipe), .q      (tlbop_init_d2),
2143
        .clk    (clk), .se     (se),       .si (),          .so ());
2144
dff #(1) tlbinit_stgd3 ( .din    (tlbop_init_d2 &  ldst_in_pipe), .q      (tlbop_init_d3),
2145
        .clk    (clk), .se     (se),       .si (),          .so ());
2146
dff #(1) tlbinit_stgd4 ( .din    (tlbop_init_d3 &  ldst_in_pipe), .q      (tlbop_init_d4),
2147
        .clk    (clk), .se     (se),       .si (),          .so ());
2148
dff #(1) tlbinit_stgd5 ( .din    (tlbop_init_d4 &  ldst_in_pipe), .q      (tlbop_init_d5),
2149
        .clk    (clk), .se     (se),       .si (),          .so ());
2150
 
2151
 
2152
assign  lsu_tlbop_force_swo = tlbop_init_d5 & ldst_in_pipe ;
2153
 
2154
//assign  dtlb_done =   lsu_dtlb_wr_vld_e  | lsu_dtlb_tag_rd_e | 
2155
assign  dtlb_done =     lsu_dtlb_tag_rd_e | lsu_dtlb_data_rd_e |
2156
                        lsu_dtlb_dmp_vld_e | dtlb_inv_all_e ;
2157
 
2158
assign  dtlb_inv_all_e = tlu_dtlb_invalidate_all_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
2159
 
2160
dff #(3) dn_stgd1 (
2161
        .din    ({dtlb_done,lsu_dtlb_tag_rd_e,lsu_dtlb_data_rd_e}),
2162
        .q      ({dtlb_done_d1,tag_rd_vld_m,data_rd_vld_m}),
2163
        .clk    (clk),
2164
        .se     (se),       .si (),          .so ()
2165
        );
2166
 
2167
wire    dtlb_inv_all_din ;
2168
assign  dtlb_inv_all_din = sehold ? dtlb_inv_all_m : dtlb_inv_all_e ;
2169
 
2170
dff #(1) dinv_stgd1 (
2171
        .din    (dtlb_inv_all_din),
2172
        .q      (dtlb_inv_all_m),
2173
        .clk    (clk),
2174
        .se     (se),       .si (),          .so ()
2175
        );
2176
 
2177
assign  lsu_dtlb_invalid_all_m = dtlb_inv_all_m ;
2178
// added by sureshT
2179
assign  lsu_dtlb_invalid_all_l_m = ~lsu_dtlb_invalid_all_m;
2180
 
2181
dff #(3) dn_stgd2 (
2182
        .din    ({dtlb_done_d1,tag_rd_vld_m,data_rd_vld_m}),
2183
        .q      ({dtlb_done_d2,tag_rd_vld_g,data_rd_vld_g}),
2184
        .clk    (clk),
2185
        .se     (se),       .si (),          .so ()
2186
        );
2187
 
2188
assign  lsu_tlb_data_rd_vld_g = data_rd_vld_g ;
2189
assign  lsu_tlb_tag_rd_vld_g  = tag_rd_vld_g ;
2190
//assign  lsu_tlb_st_vld_g = ~lsu_tlb_tag_rd_vld_g & ~lsu_tlb_data_rd_vld_g ;
2191
 
2192
// The handshake will have to change !!!
2193
assign  lsu_tlu_dtlb_done =
2194
        dtlb_done_d2 |          // rest
2195
        dtlb_wr_init_d3 ;       // write
2196
 
2197
// Note : if mx_sel bit is high, then it selects va instead of pa.
2198
 
2199
 
2200
 
2201
//=========================================================================================
2202
//  State/ASI Registers.
2203
//=========================================================================================
2204
 
2205
dff #(8) stctl_stg_e (
2206
        .din    ({ifu_tlu_sraddr_d[6:0],ifu_tlu_wsr_inst_d}),
2207
        .q      ({lsu_sraddr_e[6:0],    lsu_wsr_inst_e}),
2208
        .clk    (clk),
2209
        .se     (se),       .si (),          .so ()
2210
        );
2211
 
2212
assign lsu_tlu_wsr_inst_e = lsu_wsr_inst_e;
2213
 
2214
   wire asi_state_wr_en_e, asi_state_wr_en_m;
2215
 
2216
assign  asi_state_wr_en_e =
2217
              ~lsu_sraddr_e[6] &  // 1=hypervisor
2218
              ~lsu_sraddr_e[5] &  // =0 for state reg. 
2219
        ~lsu_sraddr_e[4] & ~lsu_sraddr_e[3] &
2220
        ~lsu_sraddr_e[2] &  lsu_sraddr_e[1] &
2221
         lsu_sraddr_e[0] &
2222
         lsu_wsr_inst_e ; // write
2223
 
2224
dff #(2) stctl_stg_m (
2225
        .din    ({asi_state_wr_en_e, alt_space_e}),
2226
        .q      ({asi_state_wr_en_m, lsu_alt_space_m}),
2227
        .clk    (clk),
2228
        .se     (se),       .si (),          .so ()
2229
        );
2230
 
2231
dff #(2) stctl_stg_w (
2232
        .din    ({asi_state_wr_en_m, lsu_alt_space_m}),
2233
        .q      ({asi_state_wr_en,   lsu_alt_space_g}),
2234
        .clk    (clk),
2235
        .se     (se),       .si (),          .so ()
2236
        );
2237
 
2238
//assign  asi_state_wr_en =   
2239
//      ~lsu_sraddr_w[6] &  // 1=hypervisor
2240
//      ~lsu_sraddr_w[5] &  // =0 for state reg. 
2241
//        ~lsu_sraddr_w[4] & ~lsu_sraddr_w[3] & 
2242
//        ~lsu_sraddr_w[2] &  lsu_sraddr_w[1] & 
2243
//         lsu_sraddr_w[0] &  
2244
//         lsu_wsr_inst_w ; // write
2245
 
2246
 
2247
dff #(3) asi_stgw (
2248
        .din    ({tlu_lsu_asi_update_m,tlu_lsu_tid_m[1:0]}),
2249
        .q      ({tlu_lsu_asi_update_g,tlu_lsu_tid_g[1:0]}),
2250
        .clk    (clk),
2251
        .se     (se),       .si (),          .so ()
2252
        );
2253
 
2254
 
2255
assign  tsa_update_asi0 =  ~tlu_lsu_tid_g[1] & ~tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
2256
assign  tsa_update_asi1 =  ~tlu_lsu_tid_g[1] &  tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
2257
assign  tsa_update_asi2 =   tlu_lsu_tid_g[1] & ~tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
2258
assign  tsa_update_asi3 =   tlu_lsu_tid_g[1] &  tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
2259
 
2260
assign  asi_state_wr_thrd[0] =
2261
((asi_state_wr_en & thread0_g) | tsa_update_asi0) & lsu_inst_vld_w & ~dctl_early_flush_w ;
2262
//((asi_state_wr_en & thread0_g) | tsa_update_asi0) & lsu_inst_vld_w & ~lsu_flush_pipe_w ;
2263
assign  asi_state_wr_thrd[1] =
2264
((asi_state_wr_en & thread1_g) | tsa_update_asi1) & lsu_inst_vld_w & ~dctl_early_flush_w ;
2265
assign  asi_state_wr_thrd[2] =
2266
((asi_state_wr_en & thread2_g) | tsa_update_asi2) & lsu_inst_vld_w & ~dctl_early_flush_w ;
2267
assign  asi_state_wr_thrd[3] =
2268
((asi_state_wr_en & thread3_g) | tsa_update_asi3) & lsu_inst_vld_w & ~dctl_early_flush_w ;
2269
 
2270
// dc diagnstc will swo on write.                                                       
2271
assign  sta_internal_e = asi_internal_e & st_inst_vld_e & alt_space_e ;
2272
// dc diagnstc will not swo on read.                                                    
2273
assign  lda_internal_e = asi_internal_e & ~dc_diagnstc_asi_e & ld_inst_vld_e & alt_space_e ;
2274
 
2275
assign  ldsta_internal_e = sta_internal_e | lda_internal_e ;
2276
 
2277
// MMU_ASI
2278
// Do no switch out for lds. lds switched out thru ldst_miss.
2279
// qualification must be removed.
2280
assign  lsu_ifu_ldsta_internal_e = asi_internal_e ;
2281
//assign  lsu_ifu_ldsta_internal_e = asi_internal_e & ~ld_inst_vld_e  ;
2282
 
2283
 
2284
dff #(2)  stai_stgm (
2285
        .din    ({sta_internal_e,lda_internal_e}),
2286
        .q      ({sta_internal_m,lda_internal_m}),
2287
        .clk    (clk),
2288
        .se     (se),       .si (),          .so ()
2289
        );
2290
 
2291
   wire stxa_internal_m;
2292
   assign stxa_internal_m = sta_internal_m & ~(dtagv_diagnstc_asi_m | dc_diagnstc_asi_m);
2293
 
2294
dff #(2)  stai_stgg (
2295
        .din    ({stxa_internal_m, lda_internal_m}),
2296
        .q      ({stxa_internal,   ldxa_internal}),
2297
        .clk    (clk),
2298
        .se     (se),       .si (),          .so ()
2299
        );
2300
 
2301
   wire [7:0] ldst_va_g;
2302
 
2303
   assign ldst_va_g[7:0] = lsu_ldst_va_g[7:0];
2304
 
2305
   wire [7:0]    lsu_asi_state ;
2306
dff #(8)  asistate_stgg (
2307
        .din    (lsu_dctl_asi_state_m[7:0]),
2308
        .q      (lsu_asi_state[7:0]),
2309
        .clk    (clk),
2310
        .se     (se),       .si (),          .so ()
2311
        );
2312
 
2313
assign  pctxt_va_vld = (ldst_va_g[7:0] == 8'h08) ;
2314
assign  pctxt_state_en =  (lsu_asi_state[7:0] == 8'h21) & pctxt_va_vld &
2315
        lsu_alt_space_g & lsu_inst_vld_w ;
2316
 
2317
 
2318
//assign  pctxt_state_wr_thrd[0] = pctxt_state_en & st_inst_vld_g & thread0_g ;
2319
assign  pctxt_state_wr_thrd[0] = pctxt_state_en & asi_st_vld_g & thread0_g ;
2320
assign  pctxt_state_wr_thrd[1] = pctxt_state_en & asi_st_vld_g & thread1_g ;
2321
assign  pctxt_state_wr_thrd[2] = pctxt_state_en & asi_st_vld_g & thread2_g ;
2322
assign  pctxt_state_wr_thrd[3] = pctxt_state_en & asi_st_vld_g & thread3_g ;
2323
 
2324
//assign  pctxt_state_rd_en[0] = pctxt_state_en & ld_inst_vld_g & thread0_g ;
2325
 
2326
//assign  pctxt_state_rd_en[0] = pctxt_state_en & asi_ld_vld_g & thread0_g ;
2327
//assign  pctxt_state_rd_en[1] = pctxt_state_en & asi_ld_vld_g & thread1_g ;
2328
//assign  pctxt_state_rd_en[2] = pctxt_state_en & asi_ld_vld_g & thread2_g ;
2329
//assign  pctxt_state_rd_en[3] = pctxt_state_en & asi_ld_vld_g & thread3_g ;
2330
 
2331
 
2332
assign  sctxt_va_vld = (ldst_va_g[7:0] == 8'h10) ;
2333
assign  sctxt_state_en =  (lsu_asi_state[7:0] == 8'h21) & sctxt_va_vld &
2334
        lsu_alt_space_g & lsu_inst_vld_w ;
2335
 
2336
assign  pscxt_ldxa_illgl_va =
2337
        (lsu_asi_state[7:0] == 8'h21) & ~(pctxt_va_vld | sctxt_va_vld) &
2338
        lsu_alt_space_g & lsu_inst_vld_w ;
2339
 
2340
//assign  sctxt_state_wr_thrd[0] = sctxt_state_en & st_inst_vld_g & thread0_g ;
2341
assign  sctxt_state_wr_thrd[0] = sctxt_state_en & asi_st_vld_g & thread0_g ;
2342
assign  sctxt_state_wr_thrd[1] = sctxt_state_en & asi_st_vld_g & thread1_g ;
2343
assign  sctxt_state_wr_thrd[2] = sctxt_state_en & asi_st_vld_g & thread2_g ;
2344
assign  sctxt_state_wr_thrd[3] = sctxt_state_en & asi_st_vld_g & thread3_g ;
2345
 
2346
//assign  sctxt_state_rd_en[0]   = sctxt_state_en & ld_inst_vld_g & thread0_g ;
2347
 
2348
//assign  sctxt_state_rd_en[0]   = sctxt_state_en & asi_ld_vld_g & thread0_g ;
2349
//assign  sctxt_state_rd_en[1]   = sctxt_state_en & asi_ld_vld_g & thread1_g ;
2350
//assign  sctxt_state_rd_en[2]   = sctxt_state_en & asi_ld_vld_g & thread2_g ;
2351
//assign  sctxt_state_rd_en[3]   = sctxt_state_en & asi_ld_vld_g & thread3_g ;
2352
 
2353
 
2354
// LSU CONTROL REGISTER. ASI=0x45,VA=0x00.
2355
// b0 - i$ enable.
2356
// b1 - d$ enable. 
2357
// b2 - immu enable.
2358
// b3 - dmmu enable.
2359
 
2360
assign  lsuctl_va_vld = (ldst_va_g[7:0] == 8'h00);
2361
assign  lsu_ctl_state_en = (lsu_asi_state[7:0] == 8'h45) & lsuctl_va_vld &
2362
        lsu_alt_space_g & lsu_inst_vld_w ;
2363
assign  lsuctl_illgl_va = (lsu_asi_state[7:0] == 8'h45) & ~lsuctl_va_vld &
2364
        lsu_alt_space_g & lsu_inst_vld_w ;
2365
 
2366
wire  [3:0] lctl_rst ;
2367
 
2368
//assign  lsu_ctl_state_wr_en[0] = (lsu_ctl_state_en & st_inst_vld_g & thread0_g) | lctl_rst[0] ;
2369
assign  lsu_ctl_state_wr_en[0] = (lsu_ctl_state_en & asi_st_vld_g & thread0_g) | lctl_rst[0] ;
2370
assign  lsu_ctl_state_wr_en[1] = (lsu_ctl_state_en & asi_st_vld_g & thread1_g) | lctl_rst[1] ;
2371
assign  lsu_ctl_state_wr_en[2] = (lsu_ctl_state_en & asi_st_vld_g & thread2_g) | lctl_rst[2];
2372
assign  lsu_ctl_state_wr_en[3] = (lsu_ctl_state_en & asi_st_vld_g & thread3_g) | lctl_rst[3];
2373
 
2374
//assign  lsu_ctl_state_rd_en[0] = lsu_ctl_state_en & ld_inst_vld_g & thread0_g ;
2375
//assign  lsu_ctl_state_rd_en[0] = lsu_ctl_state_en & asi_ld_vld_g & thread0_g ;
2376
//assign  lsu_ctl_state_rd_en[1] = lsu_ctl_state_en & asi_ld_vld_g & thread1_g ;
2377
//assign  lsu_ctl_state_rd_en[2] = lsu_ctl_state_en & asi_ld_vld_g & thread2_g ;
2378
//assign  lsu_ctl_state_rd_en[3] = lsu_ctl_state_en & asi_ld_vld_g & thread3_g ;
2379
 
2380
 
2381
 
2382
wire    [3:0]    redmode_rst ;
2383
//dff #(4) rdmode_stgd1 (
2384
//        .din    ({tlu_lsu_redmode_rst[3:0]}),
2385
//        .q      ({redmode_rst[3:0]}),
2386
//        .clk    (clk),
2387
//        .se     (se),       .si (),          .so ()
2388
//        );  
2389
 
2390
   assign   redmode_rst[3:0] =  tlu_lsu_redmode_rst_d1[3:0];
2391
 
2392
assign  lctl_rst[0] = redmode_rst[0] | reset ;
2393
assign  lctl_rst[1] = redmode_rst[1] | reset ;
2394
assign  lctl_rst[2] = redmode_rst[2] | reset ;
2395
assign  lctl_rst[3] = redmode_rst[3] | reset ;
2396
 
2397
assign  lsuctl_ctlbits_wr_en[0] = lsu_ctl_state_wr_en[0] | dfture_tap_wr_en[0] | lctl_rst[0];
2398
assign  lsuctl_ctlbits_wr_en[1] = lsu_ctl_state_wr_en[1] | dfture_tap_wr_en[1] | lctl_rst[1];
2399
assign  lsuctl_ctlbits_wr_en[2] = lsu_ctl_state_wr_en[2] | dfture_tap_wr_en[2] | lctl_rst[2];
2400
assign  lsuctl_ctlbits_wr_en[3] = lsu_ctl_state_wr_en[3] | dfture_tap_wr_en[3] | lctl_rst[3];
2401
 
2402
   assign dfture_tap_wr_mx_sel = | dfture_tap_wr_en[3:0];
2403
 
2404
// Could enhance bypass/enable conditions by adding all asi conditions.  
2405
wire   [5:0] lsu_ctl_reg0;
2406
wire   [5:0] lsu_ctl_reg1;
2407
wire   [5:0] lsu_ctl_reg2;
2408
wire   [5:0] lsu_ctl_reg3;
2409
 
2410
   assign lsu_ctl_reg0[5:0] = lsu_dp_ctl_reg0[5:0];
2411
   assign lsu_ctl_reg1[5:0] = lsu_dp_ctl_reg1[5:0];
2412
   assign lsu_ctl_reg2[5:0] = lsu_dp_ctl_reg2[5:0];
2413
   assign lsu_ctl_reg3[5:0] = lsu_dp_ctl_reg3[5:0];
2414
 
2415
wire lsu_dcache_enable;
2416
assign lsu_dcache_enable =
2417
  ((lsu_ctl_reg0[1] & thread0_e) | (lsu_ctl_reg1[1] & thread1_e)  |
2418
   (lsu_ctl_reg2[1] & thread2_e) | (lsu_ctl_reg3[1] & thread3_e)) ;
2419
 
2420
assign  lsuctl_dtlb_byp_e =
2421
  (~lsu_ctl_reg0[3] & thread0_e) | (~lsu_ctl_reg1[3] & thread1_e) |
2422
  (~lsu_ctl_reg2[3] & thread2_e) | (~lsu_ctl_reg3[3] & thread3_e) ;
2423
assign dtlb_bypass_e =
2424
  (lsuctl_dtlb_byp_e & ~hpstate_en_e) | // hpv enabled - byp is RA->PA for supv.
2425
  ( tlb_byp_asi_e & ~hpstate_en_e & altspace_ldst_e) |  // altspace tlb bypass - non-hpv
2426
    ((hpv_priv_e & hpstate_en_e) & ~(alt_space_e & (as_if_user_asi_e | tlb_byp_asi_e)));
2427
        // hpv enabled VA->PA 
2428
 
2429
assign  lsu_dtlb_bypass_e = dtlb_bypass_e ;
2430
wire  dcache_enable_m,dcache_enable_g ;
2431
dff #(2) dbyp_stgm (
2432
        .din    ({dtlb_bypass_e,lsu_dcache_enable}),
2433
        .q      ({dtlb_bypass_m,dcache_enable_m}),
2434
        .clk    (clk),
2435
        .se     (se),       .si (),          .so ()
2436
        );
2437
 
2438
dff #(2) dbyp_stgg (
2439
        .din    ({dtlb_bypass_m,dcache_enable_m}),
2440
        .q      ({lsu_dtlb_bypass_g,dcache_enable_g}),
2441
        .clk    (clk),
2442
        .se     (se),       .si (),          .so ()
2443
        );
2444
 
2445
   wire lsu_ctl_reg0_bf_b0, lsu_ctl_reg1_bf_b0, lsu_ctl_reg2_bf_b0, lsu_ctl_reg3_bf_b0;
2446
   wire lsu_ctl_reg0_bf_b2, lsu_ctl_reg1_bf_b2, lsu_ctl_reg2_bf_b2, lsu_ctl_reg3_bf_b2;
2447
 
2448
bw_u1_buf_1x UZsize_ctl_reg0_b0  ( .a(lsu_ctl_reg0[0]),  .z(lsu_ctl_reg0_bf_b0)  );
2449
bw_u1_buf_1x UZsize_ctl_reg0_b2  ( .a(lsu_ctl_reg0[2]),  .z(lsu_ctl_reg0_bf_b2)  );
2450
bw_u1_buf_1x UZsize_ctl_reg1_b0  ( .a(lsu_ctl_reg1[0]),  .z(lsu_ctl_reg1_bf_b0)  );
2451
bw_u1_buf_1x UZsize_ctl_reg1_b2  ( .a(lsu_ctl_reg1[2]),  .z(lsu_ctl_reg1_bf_b2)  );
2452
bw_u1_buf_1x UZsize_ctl_reg2_b0  ( .a(lsu_ctl_reg2[0]),  .z(lsu_ctl_reg2_bf_b0)  );
2453
bw_u1_buf_1x UZsize_ctl_reg2_b2  ( .a(lsu_ctl_reg2[2]),  .z(lsu_ctl_reg2_bf_b2)  );
2454
bw_u1_buf_1x UZsize_ctl_reg3_b0  ( .a(lsu_ctl_reg3[0]),  .z(lsu_ctl_reg3_bf_b0)  );
2455
bw_u1_buf_1x UZsize_ctl_reg3_b2  ( .a(lsu_ctl_reg3[2]),  .z(lsu_ctl_reg3_bf_b2)  );
2456
 
2457
assign lsu_ifu_icache_en[3:0] =
2458
  {lsu_ctl_reg3_bf_b0,lsu_ctl_reg2_bf_b0,lsu_ctl_reg1_bf_b0,lsu_ctl_reg0_bf_b0} & ~tlu_lsu_redmode[3:0] ;
2459
assign lsu_ifu_itlb_en[3:0] =
2460
  {lsu_ctl_reg3_bf_b2,lsu_ctl_reg2_bf_b2,lsu_ctl_reg1_bf_b2,lsu_ctl_reg0_bf_b2} & ~tlu_lsu_redmode[3:0] ;
2461
 
2462
//=========================================================================================
2463
//  DCACHE Access thru IOBrdge
2464
//=========================================================================================
2465
 
2466
wire    iob_fwdpkt_vld ;
2467
dff  iobvld_stg (
2468
        .din    (lsu_iobrdge_fwd_pkt_vld),
2469
        .q      (iob_fwdpkt_vld),
2470
        .clk    (clk),
2471
        .se     (se),       .si (),          .so ()
2472
        );
2473
 
2474
wire    dcache_iob_wr_e, dcache_iob_rd_e ;
2475
wire    dcache_iob_wr, dcache_iob_rd ;
2476
assign dcache_iob_wr =
2477
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[6] & lsu_iobrdge_fwd_pkt_vld ;
2478
assign dcache_iob_rd =
2479
 lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[6] & lsu_iobrdge_fwd_pkt_vld ;
2480
 
2481
dff #(2) dcrw_stge (
2482
        .din    ({dcache_iob_wr,dcache_iob_rd}),
2483
        .q      ({dcache_iob_wr_e,dcache_iob_rd_e}),
2484
        .clk    (clk),
2485
        .se     (se),       .si (),          .so ()
2486
        );
2487
 
2488
assign  lsu_dc_iob_access_e = dcache_iob_wr_e | dcache_iob_rd_e ;
2489
 
2490
//=========================================================================================
2491
//  Miscellaneous ASI
2492
//=========================================================================================
2493
 
2494
// Defeature effects the asi lsu_ctl_reg.
2495
// Margin ASI
2496
// Diag  ASI - No TAP access
2497
// BIST ASI   
2498
 
2499
assign  tap_thread[0] = ~lsu_iobrdge_tap_rq_type_b1_b0[1] & ~lsu_iobrdge_tap_rq_type_b1_b0[0] ;
2500
assign  tap_thread[1] = ~lsu_iobrdge_tap_rq_type_b1_b0[1] &  lsu_iobrdge_tap_rq_type_b1_b0[0] ;
2501
assign  tap_thread[2] =  lsu_iobrdge_tap_rq_type_b1_b0[1] & ~lsu_iobrdge_tap_rq_type_b1_b0[0] ;
2502
assign  tap_thread[3] =  lsu_iobrdge_tap_rq_type_b1_b0[1] &  lsu_iobrdge_tap_rq_type_b1_b0[0] ;
2503
 
2504
wire bist_tap_rd,bist_tap_wr ;
2505
assign  bist_tap_rd =
2506
 lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[5] & iob_fwdpkt_vld ;
2507
assign  bist_tap_wr =
2508
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[5] & iob_fwdpkt_vld ;
2509
 
2510
/*
2511
dff #(2) bstrw_stge (
2512
        .din    ({bist_tap_rd,bist_tap_wr}),
2513
        .q      ({bist_tap_rd_en,bist_tap_wr_en}),
2514
        .clk    (clk),
2515
        .se     (se),       .si (),          .so ()
2516
        );
2517
*/
2518
dff #(1) bstrw_stge (
2519
        .din    ({bist_tap_wr}),
2520
        .q      ({bist_tap_wr_en}),
2521
        .clk    (clk),
2522
        .se     (se),       .si (),          .so ()
2523
        );
2524
 
2525
wire mrgn_tap_rd,mrgn_tap_wr ;
2526
assign  mrgn_tap_rd =
2527
lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[4] & iob_fwdpkt_vld ;
2528
assign  mrgn_tap_wr =
2529
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[4] & iob_fwdpkt_vld ;
2530
/*
2531
dff #(2) mrgnrw_stge (
2532
        .din    ({mrgn_tap_rd,mrgn_tap_wr}),
2533
        .q      ({mrgn_tap_rd_en,mrgn_tap_wr_en}),
2534
        .clk    (clk),
2535
        .se     (se),       .si (),          .so ()
2536
        );
2537
*/
2538
dff #(1) mrgnrw_stge (
2539
        .din    ({mrgn_tap_wr}),
2540
        .q      ({mrgn_tap_wr_en}),
2541
        .clk    (clk),
2542
        .se     (se),       .si (),          .so ()
2543
        );
2544
 
2545
wire  dfture_access_vld ;
2546
wire    [3:0]    dfture_tap_rd,dfture_tap_wr ;
2547
assign  dfture_access_vld = lsu_iobrdge_tap_rq_type_b6_b3[3] & iob_fwdpkt_vld ;
2548
 
2549
assign  dfture_tap_rd[0] =
2550
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[0] ;
2551
assign  dfture_tap_rd[1] =
2552
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[1] ;
2553
assign  dfture_tap_rd[2] =
2554
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[2] ;
2555
assign  dfture_tap_rd[3] =
2556
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[3] ;
2557
 
2558
   wire dfture_tap_rd_default;
2559
   assign dfture_tap_rd_default = ~| dfture_tap_rd[2:0];
2560
 
2561
assign  dfture_tap_wr[0] =
2562
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[0] ;
2563
assign  dfture_tap_wr[1] =
2564
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[1] ;
2565
assign  dfture_tap_wr[2] =
2566
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[2] ;
2567
assign  dfture_tap_wr[3] =
2568
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[3] ;
2569
 
2570
dff #(8) dftrw_stge (
2571
        .din    ({dfture_tap_rd_default, dfture_tap_rd[2:0],dfture_tap_wr[3:0]}),
2572
        .q      ({dfture_tap_rd_d1[3:0],                    dfture_tap_wr_en[3:0]}),
2573
        .clk    (clk),
2574
        .se     (se),       .si (),          .so ()
2575
        );
2576
 
2577
 
2578
   assign dfture_tap_rd_en [0] = dfture_tap_rd_d1[0] & ~rst_tri_en;
2579
   assign dfture_tap_rd_en [1] = dfture_tap_rd_d1[1] & ~rst_tri_en;
2580
   assign dfture_tap_rd_en [2] = dfture_tap_rd_d1[2] & ~rst_tri_en;
2581
   assign dfture_tap_rd_en [3] = dfture_tap_rd_d1[3] | rst_tri_en;
2582
 
2583
 
2584
// BIST_Controller ASI
2585
 
2586
wire    bistctl_va_vld_m,bistctl_state_en_m;
2587
assign  bistctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h00);
2588
assign  bistctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h42) & bistctl_va_vld_m &
2589
        lsu_alt_space_m ;
2590
dff  #(2) bistdcd_stw (
2591
        .din    ({bistctl_va_vld_m,bistctl_state_en_m}),
2592
        .q      ({bistctl_va_vld,bistctl_state_en}),
2593
        .clk    (clk),
2594
        .se     (se),       .si (),          .so ()
2595
        );
2596
// asi42 dealt with as a whole.
2597
/*assign  bistctl_illgl_va = (lsu_asi_state[7:0] == 8'h42) & ~bistctl_va_vld &
2598
        lsu_alt_space_g ;*/
2599
//assign  bistctl_rd_en = bistctl_state_en & asi_ld_vld_g ;
2600
assign  bistctl_wr_en = (bistctl_state_en & asi_st_vld_g) | bist_tap_wr_en ;
2601
//assign  bistctl_rd_en = bistctl_state_en & ld_inst_vld_g ;
2602
//assign  bistctl_wr_en = (bistctl_state_en & st_inst_vld_g) | bist_tap_wr_en ;
2603
 
2604
//test_stub interface. bist_tap_wr_en should exclude?
2605
assign  bist_ctl_reg_wr_en = bistctl_wr_en;
2606
 
2607
 
2608
// Self-Timed Margin Control ASI
2609
 
2610
wire    mrgnctl_va_vld_m,mrgnctl_state_en_m;
2611
assign  mrgnctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h00);
2612
assign  mrgnctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h44) & mrgnctl_va_vld_m &
2613
        lsu_alt_space_m ;
2614
dff  #(2) mrgndcd_stw (
2615
        .din    ({mrgnctl_va_vld_m,mrgnctl_state_en_m}),
2616
        .q      ({mrgnctl_va_vld,mrgnctl_state_en}),
2617
        .clk    (clk),
2618
        .se     (se),       .si (),          .so ()
2619
        );
2620
 
2621
assign  mrgnctl_illgl_va = (lsu_asi_state[7:0] == 8'h44) & ~mrgnctl_va_vld &
2622
        lsu_alt_space_g ;
2623
 
2624
assign  mrgnctl_wr_en = ((mrgnctl_state_en & asi_st_vld_g) | mrgn_tap_wr_en | ~dctl_rst_l) & ~sehold; //bug 4508
2625
 
2626
// LSU Diag Reg ASI
2627
// No access from tap.
2628
wire    ldiagctl_va_vld_m,ldiagctl_state_en_m;
2629
assign  ldiagctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h10);
2630
assign  ldiagctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h42) & ldiagctl_va_vld_m &
2631
        lsu_alt_space_m ;
2632
dff  #(2) ldiagdcd_stw (
2633
        .din    ({ldiagctl_va_vld_m,ldiagctl_state_en_m}),
2634
        .q      ({ldiagctl_va_vld,ldiagctl_state_en}),
2635
        .clk    (clk),
2636
        .se     (se),       .si (),          .so ()
2637
        );
2638
// asi42 dealt with as a whole.
2639
/*assign  ldiagctl_illgl_va = (lsu_asi_state[7:0] == 8'h42) & ~ldiagctl_va_vld &
2640
        lsu_alt_space_g ;*/
2641
 
2642
wire    asi42_g ;
2643
wire    ifu_asi42_flush_g ;
2644
assign  ifu_asi42_flush_g =
2645
        bistctl_state_en | ldiagctl_state_en | // lsu's asi42 should not set asi queue.
2646
        (asi42_g & asi42_illgl_va) ;            // illgl-va should not set asi queue.
2647
 
2648
//assign  ldiagctl_rd_en = ldiagctl_state_en & asi_ld_vld_g ;
2649
assign  ldiagctl_wr_en = (ldiagctl_state_en & asi_st_vld_g) | reset;
2650
//assign  ldiagctl_rd_en = ldiagctl_state_en & ld_inst_vld_g ;
2651
//assign  ldiagctl_wr_en = (ldiagctl_state_en & st_inst_vld_g) | reset;
2652
 
2653
wire  instmsk_va_vld ;
2654
assign  instmsk_va_vld = (ldst_va_g[7:0] == 8'h08);
2655
assign  asi42_g = (lsu_asi_state[7:0] == 8'h42) ;
2656
assign  asi42_illgl_va =
2657
        asi42_g &
2658
        ~(ldiagctl_va_vld | bistctl_va_vld | instmsk_va_vld) &
2659
        lsu_alt_space_g ;
2660
 
2661
 
2662
 
2663
//=========================================================================================
2664
//  Partition ID Register
2665
//=========================================================================================
2666
 
2667
// ASI=58, VA=0x80, Per thread
2668
// The pid is to be used by tlb-cam, and writes to tlb. It is kept in the lsu
2669
// as it is used by the dtlb, plus changes to mmu_dp are to be kept to a minimum.
2670
 
2671
// Trap if supervisor accesses hyperpriv asi - see supv_use_hyp. Could be incorrect.
2672
// Correct on merge to mainline.
2673
 
2674
// The VA compares can probably be shortened.
2675
assign  pid_va_vld = (ldst_va_g[7:0] == 8'h80);
2676
assign  pid_state_en = (lsu_asi_state[7:0] == 8'h58) & pid_va_vld &
2677
        lsu_alt_space_g & lsu_inst_vld_w ;
2678
//assign  pid_illgl_va = (lsu_asi_state[7:0] == 8'h58) & ~pid_va_vld &
2679
//        lsu_alt_space_g & lsu_inst_vld_w ; 
2680
 
2681
// remove reset ??
2682
//assign  pid_state_wr_en[0] = (pid_state_en & st_inst_vld_g & thread0_g) | reset ;
2683
assign  pid_state_wr_en[0] = (pid_state_en & asi_st_vld_g & thread0_g) | reset ;
2684
assign  pid_state_wr_en[1] = (pid_state_en & asi_st_vld_g & thread1_g) | reset ;
2685
assign  pid_state_wr_en[2] = (pid_state_en & asi_st_vld_g & thread2_g) | reset ;
2686
assign  pid_state_wr_en[3] = (pid_state_en & asi_st_vld_g & thread3_g) | reset ;
2687
 
2688
//assign  pid_state_rd_en[0] = pid_state_en & ld_inst_vld_g & thread0_g ;
2689
 
2690
//assign  pid_state_rd_en[0] = pid_state_en & asi_ld_vld_g & thread0_g ;
2691
//assign  pid_state_rd_en[1] = pid_state_en & asi_ld_vld_g & thread1_g ;
2692
//assign  pid_state_rd_en[2] = pid_state_en & asi_ld_vld_g & thread2_g ;
2693
//assign  pid_state_rd_en[3] = pid_state_en & asi_ld_vld_g & thread3_g ;
2694
 
2695
 
2696
//=========================================================================================
2697
//  Local LDXA Read
2698
//=========================================================================================
2699
 
2700
// Timing : rd_en changed to _en with inst_vld
2701
 
2702
//wire  [3:0] misc_ctl_sel ;
2703
wire    misc_tap_rd_sel ;
2704
/*
2705
assign  misc_tap_rd_sel = mrgn_tap_rd_en | bist_tap_rd_en |  dfture_tap_rd_sel ;
2706
assign  misc_ctl_sel[0] = bist_tap_rd_en | (~misc_tap_rd_sel &  bistctl_state_en & ld_inst_vld_unflushed) ;
2707
assign  misc_ctl_sel[1] = mrgn_tap_rd_en | (~misc_tap_rd_sel &  mrgnctl_state_en & ld_inst_vld_unflushed) ;
2708
assign  misc_ctl_sel[3] = dfture_tap_rd_sel ;
2709
 
2710
//assign  misc_ctl_sel[2] = (~misc_tap_rd_sel & ldiagctl_state_en & ld_inst_vld_unflushed) ;
2711
assign  misc_ctl_sel[2] = ~(misc_ctl_sel[0] | misc_ctl_sel[1] | misc_ctl_sel[3] ); //force default
2712
*/
2713
 
2714
//****push misc_ctl_sel in previosu cycle*****
2715
   wire [3:0] misc_ctl_sel_din;
2716
 
2717
//0-in bug, priority encode tap requests to prevent illegal type through one-hot mux   
2718
   wire       dfture_tap_rd_or ;
2719
   assign     dfture_tap_rd_or = | (dfture_tap_rd [3:0]);
2720
   assign     misc_tap_rd_sel = mrgn_tap_rd | bist_tap_rd |  dfture_tap_rd_or ;
2721
   assign     misc_ctl_sel_din[0] = bist_tap_rd |
2722
                                   (~misc_tap_rd_sel &  bistctl_state_en_m & ld_inst_vld_m) ;
2723
   assign     misc_ctl_sel_din[1] = (~bist_tap_rd & mrgn_tap_rd) |
2724
                                    (~misc_tap_rd_sel &  mrgnctl_state_en_m & ld_inst_vld_m) ;
2725
   assign     misc_ctl_sel_din[3] = ~bist_tap_rd & ~mrgn_tap_rd & dfture_tap_rd_or;
2726
   assign     misc_ctl_sel_din[2] = ~(misc_ctl_sel_din[0] | misc_ctl_sel_din[1] | misc_ctl_sel_din[3] ) ;
2727
 
2728
 
2729
 
2730
// ASI accesses should be mutex except for non-access cases.
2731
assign  lsu_asi_sel_fmx1[0] = pctxt_state_en & ld_inst_vld_unflushed;
2732
assign  lsu_asi_sel_fmx1[1] = sctxt_state_en & ld_inst_vld_unflushed & ~lsu_asi_sel_fmx1[0];
2733
assign  lsu_asi_sel_fmx1[2] = ~(|lsu_asi_sel_fmx1[1:0]);   //force default
2734
 
2735
assign  lsu_asi_sel_fmx2[0] = |lsu_asi_sel_fmx1[1:0] | (pid_state_en & ld_inst_vld_unflushed) ;
2736
assign  lsu_asi_sel_fmx2[1] = lsu_ctl_state_en & ld_inst_vld_unflushed & ~(lsu_asi_sel_fmx2[0]);
2737
assign  lsu_asi_sel_fmx2[2] = ~(|lsu_asi_sel_fmx2[1:0]) ; //force default
2738
 
2739
   wire va_wtchpt_en;
2740
 
2741
wire    lsu_asi_rd_sel ;
2742
//assign  lsu_asi_rd_sel = ((|lsu_asi_sel_fmx1[1:0]) | 
2743
//                         ((pid_state_en | va_wtchpt_en) & ld_inst_vld_unflushed) |
2744
//                                       (|lsu_asi_sel_fmx2[1:0]) | 
2745
//                          misc_asi_rd_en) & 
2746
//                        lsu_inst_vld_w ;   
2747
 
2748
assign  lsu_asi_rd_sel = ((|lsu_asi_sel_fmx1[1:0]) |
2749
                         (pid_state_en  & ld_inst_vld_unflushed) |     //remove va_wtchpt_en
2750
                                         (|lsu_asi_sel_fmx2[1:0]) |
2751
                          misc_asi_rd_en) &
2752
                          lsu_inst_vld_w ;
2753
 
2754
 
2755
assign  lsu_asi_rd_en = (lsu_asi_rd_sel | lsu_va_wtchpt_sel_g) & ~dctl_early_flush_w ; //add va_wtchpt
2756
 
2757
//assign        lsu_asi_rd_en = lsu_asi_rd_sel & ~lsu_flush_pipe_w ;
2758
 
2759
assign  misc_asi_rd_en = (bistctl_state_en | mrgnctl_state_en | ldiagctl_state_en) & ld_inst_vld_unflushed ;
2760
 
2761
assign        lsu_local_ldxa_sel_g =  lsu_asi_rd_sel  & ~rst_tri_en ; // w/o flush
2762
assign        lsu_local_ldxa_tlbrd_sel_g  =  (lsu_tlb_tag_rd_vld_g | lsu_tlb_data_rd_vld_g) & ~rst_tri_en;
2763
assign        lsu_va_wtchpt_sel_g =  (va_wtchpt_en & ld_inst_vld_unflushed) & ~rst_tri_en;
2764
 
2765
assign        lsu_local_diagnstc_tagrd_sel_g  =  (~(lsu_local_ldxa_sel_g | lsu_local_ldxa_tlbrd_sel_g |
2766
                                                   lsu_va_wtchpt_sel_g)) | rst_tri_en; //add va_wtchpt
2767
 
2768
// or diagnostic read w/ asi read enable
2769
assign  lsu_diagnstc_asi_rd_en  =  lsu_asi_rd_en | dtagv_diagnstc_rd_g  ; //Bug 3959
2770
//assign  lsu_diagnstc_asi_rd_en  =  lsu_asi_rd_en | dtagv_diagnstc_rd_g  | lsu_local_ldxa_tlbrd_sel_g;
2771
 
2772
 
2773
dff  #(1) lldxa_stw2 (
2774
        .din    (lsu_diagnstc_asi_rd_en),
2775
        .q      (lsu_asi_rd_en_w2),
2776
        .clk    (clk),
2777
        .se     (se),       .si (),          .so ()
2778
        );
2779
 
2780
wire    ldxa_tlbrd0_w2,ldxa_tlbrd1_w2,ldxa_tlbrd2_w2,ldxa_tlbrd3_w2;
2781
wire    ldxa_tlbrd0_w3,ldxa_tlbrd1_w3,ldxa_tlbrd2_w3,ldxa_tlbrd3_w3;
2782
 
2783
// stg mismatched intentionally. stxa_tid decode can be used by ldxa.
2784
assign  ldxa_tlbrd3_w2 = tlu_stxa_thread3_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2785
assign  ldxa_tlbrd2_w2 = tlu_stxa_thread2_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2786
assign  ldxa_tlbrd1_w2 = tlu_stxa_thread1_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2787
assign  ldxa_tlbrd0_w2 = tlu_stxa_thread0_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2788
 
2789
// Bug 3959
2790
dff  #(4) tlbrd_stw3 (
2791
        .din    ({ldxa_tlbrd3_w2,ldxa_tlbrd2_w2,
2792
                ldxa_tlbrd1_w2,ldxa_tlbrd0_w2}),
2793
        .q      ({ldxa_tlbrd3_w3,ldxa_tlbrd2_w3,
2794
                ldxa_tlbrd1_w3,ldxa_tlbrd0_w3}),
2795
        .clk    (clk),
2796
        .se     (se),       .si (),          .so ()
2797
        );
2798
 
2799
// pid and va-wtchpt va removed.
2800
assign  lsu_asi_illgl_va =
2801
  lsuctl_illgl_va | pscxt_ldxa_illgl_va | mrgnctl_illgl_va | asi42_illgl_va ;
2802
assign  lsu_asi_illgl_va_cmplt[0] = lsu_asi_illgl_va & ld_inst_vld_g & thread0_g ;
2803
assign  lsu_asi_illgl_va_cmplt[1] = lsu_asi_illgl_va & ld_inst_vld_g & thread1_g ;
2804
assign  lsu_asi_illgl_va_cmplt[2] = lsu_asi_illgl_va & ld_inst_vld_g & thread2_g ;
2805
assign  lsu_asi_illgl_va_cmplt[3] = lsu_asi_illgl_va & ld_inst_vld_g & thread3_g ;
2806
 
2807
dff  #(4) lsuillgl_stgw2(
2808
        .din    (lsu_asi_illgl_va_cmplt[3:0]),
2809
        .q      (lsu_asi_illgl_va_cmplt_w2[3:0]),
2810
        .clk    (clk),
2811
        .se     (se),       .si (),          .so ()
2812
        );
2813
 
2814
//=========================================================================================
2815
//  ASI_DCACHE_TAG way decode
2816
//=========================================================================================
2817
 
2818
// Bug 4569. 
2819
// add sehold. adding in dctldp flop will cause critical path.
2820
 
2821
wire    [3:0]    dtag_rsel_dcd,dtag_rsel_hold ;
2822
assign  dtag_rsel_dcd[3:0]  =    {(lsu_ldst_va_b12_b11_m[12:11] == 2'b11),
2823
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b10),
2824
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b01),
2825
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b00)};
2826
//bug5994
2827
dffe #(4) dtag_hold (
2828
        .din    (dtag_rsel_dcd[3:0]),
2829
        .q      (dtag_rsel_hold[3:0]),
2830
        .en     (sehold),
2831
        .clk    (clk),
2832
        .se     (se),       .si (),          .so ()
2833
        );
2834
 
2835
assign  lsu_dtag_rsel_m[3:0] = sehold ? dtag_rsel_hold[3:0] : dtag_rsel_dcd[3:0] ;
2836
 
2837
 
2838
//=========================================================================================
2839
//  Watchpoint Control
2840
//=========================================================================================
2841
   wire va_vld;
2842
 
2843
assign  va_vld = (ldst_va_g[7:0] == 8'h38);
2844
 
2845
assign  va_wtchpt_en = (lsu_asi_state[7:0] == 8'h58)  & va_vld &
2846
      lsu_alt_space_g & lsu_inst_vld_w ;
2847
 
2848
// Illegal va checking for asi 58 done in MMU.
2849
 
2850
// one VA watchptr supported per thread
2851
 
2852
// Need to read register !!!
2853
// Switchout thread on read.
2854
// qualify with inst_vld_w.
2855
//assign  va_wtchpt_rd_en = va_wtchpt_en & ld_inst_vld_g ;
2856
 
2857
   wire va_wtchpt0_wr_en, va_wtchpt1_wr_en, va_wtchpt2_wr_en, va_wtchpt3_wr_en;
2858
 
2859
//assign  va_wtchpt0_wr_en = va_wtchpt_en & st_inst_vld_g & thread0_g;
2860
assign  va_wtchpt0_wr_en = va_wtchpt_en & asi_st_vld_g & thread0_g;
2861
assign  va_wtchpt1_wr_en = va_wtchpt_en & asi_st_vld_g & thread1_g;
2862
assign  va_wtchpt2_wr_en = va_wtchpt_en & asi_st_vld_g & thread2_g;
2863
assign  va_wtchpt3_wr_en = va_wtchpt_en & asi_st_vld_g & thread3_g;
2864
assign  lsu_va_wtchpt0_wr_en_l = ~va_wtchpt0_wr_en ;
2865
assign  lsu_va_wtchpt1_wr_en_l = ~va_wtchpt1_wr_en ;
2866
assign  lsu_va_wtchpt2_wr_en_l = ~va_wtchpt2_wr_en ;
2867
assign  lsu_va_wtchpt3_wr_en_l = ~va_wtchpt3_wr_en ;
2868
 
2869
assign  vw_wtchpt_cmp_en_m =  // VA Write Watchpoint Enable
2870
  (thread0_m & lsu_ctl_reg0[4]) |
2871
  (thread1_m & lsu_ctl_reg1[4]) |
2872
  (thread2_m & lsu_ctl_reg2[4]) |
2873
  (thread3_m & lsu_ctl_reg3[4]) ;
2874
 
2875
assign  vr_wtchpt_cmp_en_m =  // VA Read Watchpoint Enable
2876
  (thread0_m & lsu_ctl_reg0[5]) |
2877
  (thread1_m & lsu_ctl_reg1[5]) |
2878
  (thread2_m & lsu_ctl_reg2[5]) |
2879
  (thread3_m & lsu_ctl_reg3[5]) ;
2880
 
2881
   assign  va_wtchpt_cmp_en_m =
2882
(vw_wtchpt_cmp_en_m & st_inst_vld_m) |
2883
(vr_wtchpt_cmp_en_m & ld_inst_vld_m) ;
2884
 
2885
//=========================================================================================
2886
//  Hit/Miss/Fill Control
2887
//=========================================================================================
2888
dff  #(10) stg_m (
2889
        .din    ({ld_inst_vld_e, st_inst_vld_e,ldst_sz_e[1:0],
2890
    ifu_lsu_rd_e[4:0],ifu_lsu_ldst_fp_e}),
2891
        .q      ({ld_inst_vld_m, st_inst_vld_m,ldst_sz_m[1:0],
2892
    ld_rd_m[4:0],fp_ldst_m}),
2893
        .clk    (clk),
2894
        .se     (se),       .si (),          .so ()
2895
        );
2896
 
2897
wire    dcache_arry_data_sel_e;
2898
 
2899
assign   dcache_arry_data_sel_e = lsu_bist_rvld_e | ld_inst_vld_e | dcache_iob_rd_e ;
2900
dff #(1) dcache_arry_data_sel_stgm (
2901
  .din (dcache_arry_data_sel_e),
2902
  .q   (dcache_arry_data_sel_m),
2903
  .clk    (clk),
2904
  .se     (se),       .si (),          .so ()
2905
);
2906
 
2907
 
2908
dff  #(10) stg_g (
2909
        .din    ({ld_inst_vld_m, st_inst_vld_m,ldst_sz_m[1:0],
2910
    ld_rd_m[4:0],fp_ldst_m}),
2911
        .q      ({ld_inst_vld_unflushed, st_inst_vld_unflushed,ldst_sz_g[1:0],
2912
    ld_rd_g[4:0],fp_ldst_g}),
2913
        .clk    (clk),
2914
        .se     (se),       .si (),          .so ()
2915
        );
2916
 
2917
 
2918
//assign  asi_ld_vld_g = ld_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_early_flush_w ;
2919
assign  asi_st_vld_g = st_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_early_flush_w ;
2920
assign  ld_inst_vld_g = ld_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
2921
assign  st_inst_vld_g = st_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
2922
 
2923
assign  lsu_way_hit[0] = cache_way_hit_buf1[0] & dcache_enable_g ;
2924
assign  lsu_way_hit[1] = cache_way_hit_buf1[1] & dcache_enable_g ;
2925
assign  lsu_way_hit[2] = cache_way_hit_buf1[2] & dcache_enable_g ;
2926
assign  lsu_way_hit[3] = cache_way_hit_buf1[3] & dcache_enable_g ;
2927
 
2928
//assign  st_set_index_g[5:0] = ldst_va_g[9:4] ;
2929
//assign  st_set_way_g[3:1] = lsu_way_hit[3:1] ;
2930
 
2931
// This should contain ld miss, MMU miss, exception. 
2932
// should tlb_cam_miss be factored in or can miss/hit be solely
2933
// based on way_hit.
2934
 
2935
wire  tlb_cam_hit_mod ;
2936
dff  stgcmiss_g (
2937
        .din    (tlb_cam_hit),
2938
        .q      (tlb_cam_hit_mod),
2939
        .clk    (clk),
2940
        .se     (se),       .si (),          .so ()
2941
        );
2942
 
2943
// NOTE !! qualification with tte_data_parity_error removed for timing.
2944
assign tlb_cam_hit_g = tlb_cam_hit_mod ;
2945
//assign tlb_cam_hit_g = tlb_cam_hit_mod & ~tte_data_parity_error ;
2946
 
2947
/*assign  ld_stb_hit_g =
2948
        ld_stb0_full_raw_g | ld_stb1_full_raw_g |
2949
        ld_stb2_full_raw_g | ld_stb3_full_raw_g |
2950
        ld_stb0_partial_raw_g | ld_stb1_partial_raw_g |
2951
        ld_stb2_partial_raw_g | ld_stb3_partial_raw_g ; */
2952
 
2953
wire nceen_pipe_m, nceen_pipe_g ;
2954
 
2955
   wire [3:0] lsu_nceen_d1;
2956
 
2957
dff #(4) nceen_stg (
2958
   .din (ifu_lsu_nceen[3:0]),
2959
   .q   (lsu_nceen_d1[3:0]),
2960
   .clk (clk),
2961
   .se  (se),       .si (),          .so ()
2962
);
2963
 
2964
 
2965
assign  nceen_pipe_m =
2966
(thread0_m & lsu_nceen_d1[0]) | (thread1_m & lsu_nceen_d1[1]) |
2967
(thread2_m & lsu_nceen_d1[2]) | (thread3_m & lsu_nceen_d1[3]) ;
2968
 
2969
dff #(1)  stgg_een (
2970
        .din    (nceen_pipe_m),
2971
        .q      (nceen_pipe_g),
2972
        .clk    (clk),
2973
        .se     (se),       .si (),          .so ()
2974
        );
2975
 
2976
//wire  tte_data_perror_corr_en ;
2977
wire    tte_data_perror_unc_en ;
2978
// separate ld from st for error reporting.
2979
assign  tte_data_perror_unc_en = ld_inst_vld_unflushed & tte_data_perror_unc & nceen_pipe_g ;
2980
//assign        tte_data_perror_unc_en = tte_data_perror_unc & nceen_pipe_g ;
2981
//assign        tte_data_perror_corr_en = tte_data_perror_corr ;
2982
//assign        tte_data_perror_corr_en = tte_data_perror_corr & ceen_pipe_g ;
2983
 
2984
wire    dtlb_perror_en_w,dtlb_perror_en_w2,dtlb_perror_en_w3 ;
2985
assign  dtlb_perror_en_w = tte_data_perror_unc_en ;
2986
//assign        dtlb_perror_en_w = tte_data_perror_unc_en | tte_data_perror_corr_en ;
2987
 
2988
dff #(1)  stgw2_perr (
2989
        .din    (dtlb_perror_en_w),
2990
        .q      (dtlb_perror_en_w2),
2991
        .clk    (clk),
2992
        .se     (se),       .si (),          .so ()
2993
        );
2994
 
2995
dff #(1)  stgw3_perr (
2996
        .din    (dtlb_perror_en_w2),
2997
        .q      (dtlb_perror_en_w3),
2998
        .clk    (clk),
2999
        .se     (se),       .si (),          .so ()
3000
        );
3001
 
3002
// For now, "or" ld_inst_vld_g and ldst_dbl. Ultimately, it ldst_dbl
3003
// needs to cause ld_inst_vld_g to be asserted.
3004
// st and ld ldst_dbl terms are redundant.
3005
// Diagnostic Dcache access will force a hit in cache. Whatever is read
3006
// out will be written back to irf regardless of whether hit or not. The
3007
// expectation is that cache has been set up to hit.
3008
// lsu_dcache_enable is redundant as factored in lsu_way_hit !!!
3009
// squash both ld_miss and ld_hit in cause of dtlb unc data error.
3010
   wire ldd_force_l2access_g;
3011
 
3012
   wire int_ldd_g, fp_ldd_g;
3013
   assign fp_ldd_g = fp_ldst_g & ~(blk_asi_g & lsu_alt_space_g);
3014
 
3015
   //sas code need int_ldd_g
3016
   assign int_ldd_g = ldst_dbl_g  & ~fp_ldd_g;
3017
   assign ldd_force_l2access_g = int_ldd_g;
3018
 
3019
assign  lsu_ld_miss_wb  =
3020
(~(|lsu_way_hit[3:0]) | ~dcache_enable_g | ~(tlb_cam_hit_g | lsu_dtlb_bypass_g) |
3021
  ldxa_internal | ldd_force_l2access_g | atomic_g |  endian_mispred_g | // remove stb_cam_hit
3022
  dcache_rd_parity_error | dtag_perror_g) &
3023
        ~((dc_diagnstc_asi_g & lsu_alt_space_g)) &
3024
        //~(tte_data_perror_unc_en | tte_data_perror_corr_en | (dc_diagnstc_asi_g & lsu_alt_space_g)) & 
3025
  (ld_vld & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
3026
  //(ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
3027
  //(ldst_dbl_g & st_inst_vld_g)  // signal ld-miss for stdbl.
3028
  ncache_asild_rq_g ;   // asi ld requires bypass
3029
 
3030
assign  lsu_ld_hit_wb   =
3031
((|lsu_way_hit[3:0])  & dcache_enable_g & (tlb_cam_hit_g | lsu_dtlb_bypass_g) &  //bug3702
3032
  ~ldxa_internal & ~dcache_rd_parity_error & ~dtag_perror_g & ~endian_mispred_g &
3033
  ~ldd_force_l2access_g & ~atomic_g &  ~ncache_asild_rq_g) &  // remove stb_cam_hit
3034
~((dc_diagnstc_asi_g & lsu_alt_space_g)) &
3035
//~(tte_data_perror_unc_en | tte_data_perror_corr_en | (dc_diagnstc_asi_g & lsu_alt_space_g)) &
3036
  ld_vld & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g)) ;
3037
//ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g)) ;
3038
// force hit for diagnostic write. 
3039
 
3040
// correctible dtlb data parity error on cam will cause dmmu miss.
3041
// prefetch will rely on the ld_inst_vld/st_inst_vld not being asserted
3042
// to prevent mmu_miss from being signalled if prefetch does not translate.
3043
// Timing Change : Remove data perror from dmmu_miss ; to be treated as disrupting trap.
3044
//SC assign dmmu_miss_g = 
3045
//SC   ~tlb_cam_hit_mod & ~lsu_dtlb_bypass_g & 
3046
//SC   //~(tlb_cam_hit_mod & ~tte_data_perror_corr) & ~lsu_dtlb_bypass_g & 
3047
//SC   ((ld_inst_vld_unflushed & lsu_inst_vld_w) | 
3048
//SC    (st_inst_vld_unflushed & lsu_inst_vld_w)) & 
3049
//SC     ~(ldxa_internal | stxa_internal | early_trap_vld_g) ;
3050
 
3051
//SC    wire dmmu_miss_only_g ;
3052
 
3053
//SC assign dmmu_miss_only_g = 
3054
//SC  ~tlb_cam_hit_mod & ~lsu_dtlb_bypass_g & 
3055
//SC   //~(tlb_cam_hit_mod & ~tte_data_perror_corr) & ~lsu_dtlb_bypass_g & 
3056
//SC   ((ld_inst_vld_unflushed & lsu_inst_vld_w) | 
3057
//SC    (st_inst_vld_unflushed & lsu_inst_vld_w)) & 
3058
//SC     ~(ldxa_internal | stxa_internal);
3059
 
3060
// Atomic Handling :
3061
// Bypass to irf will occur. However, the loads will not write to cache/tag etc.
3062
 
3063
// Exceptions, tlb miss will have to be included.  
3064
// diagnostic dcache/dtagv will read respective arrays in pipeline. (changed!)
3065
// They will not switch out thread with this assumption. 
3066
 
3067
//dc_diagnstc will not switch out, dtagv will switch out
3068
 
3069
//wire dc_diagnstc_rd_g;  
3070
//assign  dc_diagnstc_rd_g = dc_diagnstc_asi_g & ld_inst_vld_g & lsu_alt_space_g ; 
3071
 
3072
//wire  dc0_diagnstc_rd_g,dc1_diagnstc_rd_g,dc2_diagnstc_rd_g,dc3_diagnstc_rd_g ;
3073
//wire  dc0_diagnstc_rd_w2,dc1_diagnstc_rd_w2,dc2_diagnstc_rd_w2,dc3_diagnstc_rd_w2 ;
3074
//assign  dc0_diagnstc_rd_g = dc_diagnstc_rd_g & thread0_g ;
3075
//assign  dc1_diagnstc_rd_g = dc_diagnstc_rd_g & thread1_g ;
3076
//assign  dc2_diagnstc_rd_g = dc_diagnstc_rd_g & thread2_g ;
3077
//assign  dc3_diagnstc_rd_g = dc_diagnstc_rd_g & thread3_g ;
3078
 
3079
//dff #(4)  stgw2_dcdiag (
3080
//        .din  ({dc3_diagnstc_rd_g,dc2_diagnstc_rd_g,dc1_diagnstc_rd_g,dc0_diagnstc_rd_g}),
3081
//        .q    ({dc3_diagnstc_rd_w2,dc2_diagnstc_rd_w2,dc1_diagnstc_rd_w2,dc0_diagnstc_rd_w2}),
3082
//        .clk  (clk),
3083
//        .se     (se),       .si (),          .so ()
3084
//        );
3085
 
3086
assign  dtagv_diagnstc_rd_g = dtagv_diagnstc_asi_g & ld_inst_vld_g & lsu_alt_space_g ;
3087
 
3088
// Prefetch will swo thread if it does not miss in tlb.
3089
dff  stgm_prf (
3090
        .din    (ifu_lsu_pref_inst_e),
3091
        .q      (pref_inst_m),
3092
        .clk  (clk),
3093
        .se     (se),       .si (),          .so ()
3094
        );
3095
 
3096
dff  stgg_prf (
3097
        .din    (pref_inst_m),
3098
        .q      (pref_inst_g),
3099
        .clk  (clk),
3100
        .se     (se),       .si (),          .so ()
3101
        );
3102
 
3103
 
3104
 
3105
//assign        lsu_ifu_data_error_w = 1'b0 ;
3106
 
3107
// is this redundant ? isn't lsu_ncache_ld_e sufficient ?
3108
assign  atomic_ld_squash_e =
3109
  ~lmq_ld_rq_type_e[2] & lmq_ld_rq_type_e[1] & lmq_ld_rq_type_e[0] ;
3110
 
3111
// bypass will occur with hit in d$ or data return from L2.
3112
// Fill for dcache diagnostic rd will happen regardless. dfill vld qualified with
3113
// flush_pipe and inst_vld !!!
3114
 
3115
//timing fix. move logic to previous cycle M.   
3116
//assign  lsu_exu_dfill_vld_w2  =   
3117
//  (l2fill_vld_g & ~(unc_err_trap_g | l2fill_fpld_g))                | // fill
3118
//  (~fp_ldst_g & ld_inst_vld_unflushed & lsu_inst_vld_w)       | // in pipe
3119
//  intld_byp_data_vld ;                                                // bypass
3120
 
3121
   wire lsu_exu_dfill_vld_m;
3122
   wire intld_byp_data_vld_e,intld_byp_data_vld_m ;
3123
   wire intld_byp_data_vld ;
3124
   wire ldxa_swo_annul ;
3125
 
3126
assign lsu_exu_dfill_vld_m =
3127
  (l2fill_vld_m & ~(unc_err_trap_m | l2fill_fpld_m))          | // fill
3128
  (~fp_ldst_m & ld_inst_vld_m &
3129
        ~(ldxa_swo_annul & lsu_alt_space_m) & flush_w_inst_vld_m) | // in pipe
3130
  intld_byp_data_vld_m ;                                              // bypass
3131
 
3132
dff #(1) dfill_vld_stgg (
3133
   .din (lsu_exu_dfill_vld_m),
3134
   .q   (lsu_exu_dfill_vld_w2),
3135
   .clk    (clk),
3136
   .se     (se),       .si (),          .so ()
3137
);
3138
 
3139
//------              
3140
// Bld errors : Bug 4315
3141
// Errors need to be accummulated across helpers. Once unc error detected 
3142
// in any helper, then all further writes to frf are squashed.
3143
// daccess_error trap taken at very end if *any* helper had an unc error.
3144
 
3145
wire    bld_cnt_max_m,bld_cnt_max_g ;
3146
assign  bld_cnt_max_m = lsu_bld_cnt_m[2] & lsu_bld_cnt_m[1] & lsu_bld_cnt_m[0] ;
3147
 
3148
wire    [1:0]    cpx_ld_err_m ;
3149
dff #(3) lderr_stgm (
3150
   .din ({lsu_cpx_pkt_ld_err[1:0],bld_cnt_max_m}),
3151
   .q   ({cpx_ld_err_m[1:0],bld_cnt_max_g}),
3152
   .clk    (clk),
3153
   .se     (se),       .si (),          .so ()
3154
);
3155
 
3156
wire [1:0] bld_err ;
3157
wire [1:0] bld_err_din ;
3158
wire       bld_rst ;
3159
// Accummulate errors.
3160
assign  bld_err_din[1:0] = cpx_ld_err_m[1:0] | bld_err[1:0] ;
3161
assign  bld_rst = reset | lsu_bld_reset ;
3162
 
3163
dffre #(2) blderr_ff (
3164
        .din    (bld_err_din[1:0]),
3165
        .q      (bld_err[1:0]),
3166
        .clk    (clk),
3167
        .en     (lsu_bld_helper_cmplt_m), .rst (bld_rst),
3168
        .se     (se),   .si (), .so ()
3169
        );
3170
 
3171
wire    bld_helper_cmplt_g ;
3172
dff  bldh_stgg (
3173
   .din (lsu_bld_helper_cmplt_m),
3174
   .q   (bld_helper_cmplt_g),
3175
   .clk    (clk),
3176
   .se     (se),       .si (),          .so ()
3177
);
3178
 
3179
wire    bld_unc_err_pend_g, bld_unc_err_pend_w2 ;
3180
assign  bld_unc_err_pend_g = bld_err[1] & bld_helper_cmplt_g ;
3181
wire    bld_corr_err_pend_g, bld_corr_err_pend_w2 ;
3182
// pended unc error gets priority.
3183
assign  bld_corr_err_pend_g = bld_err[0] & ~bld_err[1] & bld_helper_cmplt_g ;
3184
 
3185
wire    bld_squash_err_g,bld_squash_err_w2 ;
3186
// bld cnt should be vld till g
3187
assign  bld_squash_err_g = bld_helper_cmplt_g & ~bld_cnt_max_g ;
3188
 
3189
dff #(3)  bldsq_stgw2 (
3190
   .din ({bld_squash_err_g,bld_unc_err_pend_g,bld_corr_err_pend_g}),
3191
   .q   ({bld_squash_err_w2,bld_unc_err_pend_w2,bld_corr_err_pend_w2}),
3192
   .clk    (clk),
3193
   .se     (se),       .si (),          .so ()
3194
);
3195
 
3196
//------              
3197
 
3198
wire    stb_cam_hit_w2 ;
3199
wire    fld_vld_sync_no_camhit,fld_vld_sync_no_camhit_w2 ;
3200
wire    fld_vld_async,fld_vld_async_w2 ;
3201
dff  #(3) stbchit_stg (
3202
        .din    ({stb_cam_hit,fld_vld_sync_no_camhit,fld_vld_async}),
3203
        .q      ({stb_cam_hit_w2,fld_vld_sync_no_camhit_w2,fld_vld_async_w2}),
3204
        .clk    (clk),
3205
        .se     (se),       .si (),          .so ()
3206
        );
3207
 
3208
assign  fld_vld_sync_no_camhit =
3209
        (lsu_ld_hit_wb & ~tte_data_perror_unc_en & fp_ldst_g &
3210
        ~dctl_flush_pipe_w) ; // l1hit 
3211
 
3212
assign  fld_vld_async =
3213
        (l2fill_vld_g & l2fill_fpld_g & ~(unc_err_trap_g | bld_unc_err_pend_g))  |
3214
                                                // fill from l2, // bug 3705, 4315(err_trap)
3215
        fpld_byp_data_vld ;     // bypass data
3216
 
3217
assign  lsu_ffu_ld_vld =
3218
        (fld_vld_sync_no_camhit_w2 & ~stb_cam_hit_w2) |
3219
        fld_vld_async_w2 ;
3220
 
3221
 
3222
/*dff  #(1) fldvld_stgw2 (
3223
        .din    (ffu_ld_vld),
3224
        .q      (lsu_ffu_ld_vld),
3225
        .clk    (clk),
3226
        .se     (1'b0),       .si (),          .so ()
3227
        ); */
3228
 
3229
dff  #(2) dtid_stgm (
3230
        .din    (lsu_dfill_tid_e[1:0]),
3231
        .q      (dfq_tid_m[1:0]),
3232
        .clk    (clk),
3233
        .se     (se),       .si (),          .so ()
3234
        );
3235
 
3236
dff  #(2) dtid_stgg (
3237
        .din    (dfq_tid_m[1:0]),
3238
        .q      (dfq_tid_g[1:0]),
3239
        .clk    (clk),
3240
        .se     (se),       .si (),          .so ()
3241
        );
3242
 
3243
// Timing Change -  shifting dfill-data sel gen. to m-stage
3244
//assign  ldbyp_tid[0] = ld_thrd_byp_sel_g[1] | ld_thrd_byp_sel_g[3] ;
3245
//assign  ldbyp_tid[1] = ld_thrd_byp_sel_g[2] | ld_thrd_byp_sel_g[3] ;
3246
wire    [3:0]    ld_thrd_byp_sel_m ;
3247
assign  ldbyp_tid_m[0] = ld_thrd_byp_sel_m[1] | ld_thrd_byp_sel_m[3] ;
3248
assign  ldbyp_tid_m[1] = ld_thrd_byp_sel_m[2] | ld_thrd_byp_sel_m[3] ;
3249
 
3250
 
3251
/*assign  lsu_exu_thr_g[1:0] = ld_inst_vld_unflushed ? thrid_g[1:0] :
3252
          l2fill_vld_g ? dfq_tid_g[1:0] : ldbyp_tid[1:0] ; */
3253
assign  lsu_exu_thr_m[1:0] = ld_inst_vld_m ? thrid_m[1:0] :
3254
          l2fill_vld_m ? dfq_tid_m[1:0] : ldbyp_tid_m[1:0] ;
3255
 
3256
// What is the policy for load-double/atomics to update cache ?
3257
// cas will not update cache. similary neither will ldstub nor cas.
3258
// BIST will effect dcache only, not tags and vld bits.
3259
// Removed dcache_enable from dc_diagnstc_wr_en !!!
3260
wire    l2fill_vld_e ;
3261
wire    dcache_alt_src_wr_e ;
3262
assign  l2fill_vld_e = lsu_l2fill_vld & ~lsu_cpx_pkt_prefetch2 ;
3263
assign  lsu_dcache_wr_vld_e =
3264
  (l2fill_vld_e & ~ignore_fill & ~atomic_ld_squash_e & ~ld_sec_active & ~lsu_ncache_ld_e) |
3265
  lsu_st_wr_dcache  | // st writes from stb
3266
  dcache_alt_src_wr_e ;
3267
 
3268
assign  dcache_alt_src_wr_e =
3269
  (lsu_diagnstc_wr_src_sel_e & dc_diagnstc_wr_en)
3270
  | lsu_bist_wvld_e     // bist engine writes to cache
3271
  | dcache_iob_wr_e ;  // iobridge request write to dcache
3272
 
3273
//d$ valid bit 
3274
   wire dv_diagnstic_wr;
3275
assign  dv_diagnstic_wr = (lsu_diagnstc_wr_src_sel_e & dtagv_diagnstc_wr_en & lsu_diagnstc_wr_data_b0) ;
3276
 
3277
   wire dva_din_e;
3278
   wire ld_fill_e;
3279
 
3280
   assign ld_fill_e= (l2fill_vld_e & ~atomic_ld_squash_e & ~ld_sec_active & ~lsu_ncache_ld_e) ;   //ld-fill
3281
   //######################################
3282
   //snp      => dva_din = 0
3283
   //ld fill  => dva_din = 1
3284
   //diag wrt => dva_din = wrt_value
3285
   //######################################
3286
   assign dva_din_e =  ld_fill_e  | //ld-fill
3287
                       dv_diagnstic_wr; // diagnostic write valid bit
3288
 
3289
 
3290
// iob rd dominates
3291
   wire lsu_dc_alt_rd_vld_e;
3292
 
3293
assign  lsu_dc_alt_rd_vld_e = dcache_iob_rd_e | lsu_bist_rvld_e ;
3294
 
3295
   //?? default when no ld in pipe
3296
   assign dcache_alt_mx_sel_e =
3297
                //lsu_dcache_wr_vld_e | : Timing
3298
                dcache_alt_src_wr_e | // rm st updates/fill - ~ld_inst_vld_e.
3299
                lsu_dcache_wr_vld_e |
3300
                lsu_dc_alt_rd_vld_e  | ~ld_inst_vld_e;
3301
 
3302
   assign dcache_alt_mx_sel_e_bf = dcache_alt_mx_sel_e;
3303
 
3304
   wire   dcache_rvld_e_tmp, dcache_rvld_e_minbf;
3305
   assign dcache_rvld_e_tmp =  ld_inst_vld_e | lsu_dc_alt_rd_vld_e ;
3306
   bw_u1_minbuf_5x  UZfix_dcache_rvld_e_minbf (.a(dcache_rvld_e_tmp), .z(dcache_rvld_e_minbf));
3307
   assign dcache_rvld_e = dcache_rvld_e_minbf;
3308
 
3309
   wire   lsu_dtag_wr_vld_e_tmp;
3310
 
3311
assign  lsu_dtag_wr_vld_e_tmp =
3312
  ld_fill_e  & ~ignore_fill | //ld fill   //bug3601, 3676
3313
  (lsu_diagnstc_wr_src_sel_e & dtagv_diagnstc_wr_en) ; // dtag/vld diagnostic wr
3314
 
3315
bw_u1_buf_30x UZsize_lsu_dtag_wrreq_x     ( .a(lsu_dtag_wr_vld_e_tmp), .z(lsu_dtag_wrreq_x_e)     );
3316
bw_u1_buf_30x UZsize_lsu_dtag_index_sel_x ( .a(lsu_dtag_wr_vld_e_tmp), .z(lsu_dtag_index_sel_x_e) );
3317
 
3318
assign  lsu_dtagv_wr_vld_e =
3319
  lsu_dtag_wr_vld_e_tmp |       // fill
3320
  dva_svld_e        |   // snp
3321
  lsu_bist_wvld_e ;     // bist clears dva by default
3322
 
3323
// mem cell change for dva
3324
   wire [15:0] dva_fill_bit_wr_en_e;
3325
 
3326
   assign      dva_fill_bit_wr_en_e[15] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
3327
   assign      dva_fill_bit_wr_en_e[14] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
3328
   assign      dva_fill_bit_wr_en_e[13] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
3329
   assign      dva_fill_bit_wr_en_e[12] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
3330
 
3331
   assign      dva_fill_bit_wr_en_e[11] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
3332
   assign      dva_fill_bit_wr_en_e[10] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
3333
   assign      dva_fill_bit_wr_en_e[09] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
3334
   assign      dva_fill_bit_wr_en_e[08] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
3335
 
3336
   assign      dva_fill_bit_wr_en_e[07] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
3337
   assign      dva_fill_bit_wr_en_e[06] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
3338
   assign      dva_fill_bit_wr_en_e[05] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
3339
   assign      dva_fill_bit_wr_en_e[04] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
3340
 
3341
   assign      dva_fill_bit_wr_en_e[03] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
3342
   assign      dva_fill_bit_wr_en_e[02] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
3343
   assign      dva_fill_bit_wr_en_e[01] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
3344
   assign      dva_fill_bit_wr_en_e[00] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
3345
 
3346
   wire [15:0] dva_bit_wr_en_e;
3347
   assign      dva_bit_wr_en_e[15:0] = dva_svld_e ? dva_snp_bit_wr_en_e[15:0] : dva_fill_bit_wr_en_e;
3348
 
3349
   wire [4:0]  dva_snp_addr_e_bf;
3350
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b4 (.a(dva_snp_addr_e[4]), .z(dva_snp_addr_e_bf[4]));
3351
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b3 (.a(dva_snp_addr_e[3]), .z(dva_snp_addr_e_bf[3]));
3352
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b2 (.a(dva_snp_addr_e[2]), .z(dva_snp_addr_e_bf[2]));
3353
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b1 (.a(dva_snp_addr_e[1]), .z(dva_snp_addr_e_bf[1]));
3354
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b0 (.a(dva_snp_addr_e[0]), .z(dva_snp_addr_e_bf[0]));
3355
 
3356
   assign      dva_wr_adr_e[10:6] = dva_svld_e ? dva_snp_addr_e_bf[4:0] : dcache_fill_addr_e[10:6];
3357
 
3358
// should ldxa_data_vld be included ?
3359
 
3360
assign  dfill_thread0 = ~lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0] ;
3361
assign  dfill_thread1 = ~lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0] ;
3362
assign  dfill_thread2 =  lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0] ;
3363
assign  dfill_thread3 =  lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0] ;
3364
 
3365
assign  l2fill_fpld_e = lsu_l2fill_fpld_e ;
3366
 
3367
//=========================================================================================
3368
//  LD/ST COMPLETE SIGNAL
3369
//=========================================================================================
3370
 
3371
// Prefetch
3372
 
3373
wire    pref_tlbmiss_g ;
3374
assign  pref_tlbmiss_g =
3375
pref_inst_g &
3376
(~tlb_cam_hit_g | (tlb_cam_hit_g & tlb_pgnum[39])) // nop on tlbmiss or io access
3377
& lsu_inst_vld_w & ~dctl_flush_pipe_w ; // Bug 4318 bug6406/eco6619
3378
 
3379
//assign        pref_tlbmiss_g = pref_inst_g & lsu_inst_vld_w & ~tlb_cam_hit_g ;
3380
wire    [3:0] pref_tlbmiss_cmplt,pref_tlbmiss_cmplt_d1,pref_tlbmiss_cmplt_d2 ;
3381
assign  pref_tlbmiss_cmplt[0] = pref_tlbmiss_g & thread0_g ;
3382
assign  pref_tlbmiss_cmplt[1] = pref_tlbmiss_g & thread1_g ;
3383
assign  pref_tlbmiss_cmplt[2] = pref_tlbmiss_g & thread2_g ;
3384
assign  pref_tlbmiss_cmplt[3] = pref_tlbmiss_g & thread3_g ;
3385
 
3386
dff  #(4) pfcmpl_stgd1 (
3387
        .din    (pref_tlbmiss_cmplt[3:0]),
3388
        .q      (pref_tlbmiss_cmplt_d1[3:0]),
3389
        .clk    (clk),
3390
        .se     (se),       .si (),          .so ()
3391
        );
3392
 
3393
dff  #(4) pfcmpl_stgd2 (
3394
        .din    (pref_tlbmiss_cmplt_d1[3:0]),
3395
        .q      (pref_tlbmiss_cmplt_d2[3:0]),
3396
        .clk    (clk),
3397
        .se     (se),       .si (),          .so ()
3398
        );
3399
 
3400
// *** add diagnstc rd and prefetch(tlb-miss) signals. ***
3401
// *** add ifu asi ack.
3402
 
3403
// This equation is critical and needs to be optimized.
3404
wire [3:0]       lsu_pcx_pref_issue;
3405
wire    diag_wr_cmplt0,diag_wr_cmplt1,diag_wr_cmplt2,diag_wr_cmplt3;
3406
wire    ldst_cmplt_late_0, ldst_cmplt_late_1 ;
3407
wire    ldst_cmplt_late_2, ldst_cmplt_late_3 ;
3408
wire    ldst_cmplt_late_0_d1, ldst_cmplt_late_1_d1 ;
3409
wire    ldst_cmplt_late_2_d1, ldst_cmplt_late_3_d1 ;
3410
 
3411
   assign ignore_fill = lmq_ldd_vld & ~ldd_in_dfq_out;
3412
 
3413
assign  lsu_ifu_ldst_cmplt[0] =
3414
    // * can be early or
3415
    ((stxa_internal_d2 & thread0_w3) | stxa_stall_wr_cmplt0_d1) |
3416
    // * late signal and critical.
3417
    // Can this be snapped earlier ?
3418
    //(((l2fill_vld_e & ~atomic_ld_squash_e & ~ignore_fill)) //Bug 3624
3419
    (((l2fill_vld_e & ~ignore_fill))  // 1st fill for ldd.
3420
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
3421
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[0]) & dfill_thread0)  |
3422
    intld_byp_cmplt[0] |
3423
    // * early-or signals
3424
    ldst_cmplt_late_0_d1 ;
3425
 
3426
wire    atm_st_cmplt0 ;
3427
assign  atm_st_cmplt0 = lsu_atm_st_cmplt_e & dfill_thread0 ;
3428
assign  ldst_cmplt_late_0 =
3429
    (atm_st_cmplt0 & ~pend_atm_ld_ue[0]) |  // Bug 3624,4048
3430
    bsync0_reset    |
3431
    lsu_intrpt_cmplt[0]   |
3432
    diag_wr_cmplt0 |
3433
//    dc0_diagnstc_rd_w2 |
3434
    ldxa_illgl_va_cmplt_d1[0] |
3435
    pref_tlbmiss_cmplt_d2[0] |
3436
    lsu_pcx_pref_issue[0];
3437
 
3438
 
3439
assign  lsu_ifu_ldst_cmplt[1] =
3440
    ((stxa_internal_d2 & thread1_w3) | stxa_stall_wr_cmplt1_d1) |
3441
    (((l2fill_vld_e & ~ignore_fill)) // // 1st fill for ldd
3442
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
3443
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[1]) & dfill_thread1)  |
3444
    intld_byp_cmplt[1] |
3445
    ldst_cmplt_late_1_d1 ;
3446
 
3447
wire    atm_st_cmplt1 ;
3448
assign  atm_st_cmplt1 = lsu_atm_st_cmplt_e & dfill_thread1 ;
3449
assign  ldst_cmplt_late_1 =
3450
    (atm_st_cmplt1 & ~pend_atm_ld_ue[1]) |  // Bug 3624,4048
3451
    bsync1_reset    |
3452
    lsu_intrpt_cmplt[1]   |
3453
    diag_wr_cmplt1 |
3454
//    dc1_diagnstc_rd_w2 |
3455
    ldxa_illgl_va_cmplt_d1[1] |
3456
    pref_tlbmiss_cmplt_d2[1] |
3457
    lsu_pcx_pref_issue[1];
3458
 
3459
assign  lsu_ifu_ldst_cmplt[2] =
3460
    ((stxa_internal_d2 & thread2_w3) | stxa_stall_wr_cmplt2_d1) |
3461
    (((l2fill_vld_e & ~ignore_fill)) // 1st fill for ldd.
3462
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
3463
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[2]) & dfill_thread2)  |
3464
    intld_byp_cmplt[2] |
3465
    ldst_cmplt_late_2_d1 ;
3466
 
3467
wire    atm_st_cmplt2 ;
3468
assign  atm_st_cmplt2 = lsu_atm_st_cmplt_e & dfill_thread2 ;
3469
assign  ldst_cmplt_late_2 =
3470
    (atm_st_cmplt2 & ~pend_atm_ld_ue[2]) |  // Bug 3624,4048
3471
    bsync2_reset    |
3472
    lsu_intrpt_cmplt[2]   |
3473
    diag_wr_cmplt2 |
3474
//    dc2_diagnstc_rd_w2 |
3475
    ldxa_illgl_va_cmplt_d1[2] |
3476
    pref_tlbmiss_cmplt_d2[2] |
3477
    lsu_pcx_pref_issue[2];
3478
 
3479
assign  lsu_ifu_ldst_cmplt[3] =
3480
    ((stxa_internal_d2 & thread3_w3) | stxa_stall_wr_cmplt3_d1) |
3481
    //(((l2fill_vld_e & atomic_st_cmplt) | 
3482
    (((l2fill_vld_e & ~ignore_fill)) // 1st fill for ldd.
3483
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
3484
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[3]) & dfill_thread3)  |
3485
    intld_byp_cmplt[3] |
3486
    ldst_cmplt_late_3_d1 ;
3487
 
3488
wire    atm_st_cmplt3 ;
3489
assign  atm_st_cmplt3 = lsu_atm_st_cmplt_e & dfill_thread3 ;
3490
assign  ldst_cmplt_late_3 =
3491
    (atm_st_cmplt3 & ~pend_atm_ld_ue[3]) |  // Bug 3624,4048
3492
    bsync3_reset    |
3493
    lsu_intrpt_cmplt[3]   |
3494
    diag_wr_cmplt3 |
3495
//    dc3_diagnstc_rd_w2 |
3496
    ldxa_illgl_va_cmplt_d1[3] |
3497
    pref_tlbmiss_cmplt_d2[3] |
3498
    lsu_pcx_pref_issue[3];
3499
 
3500
dff #(4) ldstcmplt_d1 (
3501
        .din    ({ldst_cmplt_late_3,ldst_cmplt_late_2,ldst_cmplt_late_1,ldst_cmplt_late_0}),
3502
        .q      ({ldst_cmplt_late_3_d1,ldst_cmplt_late_2_d1,
3503
                ldst_cmplt_late_1_d1,ldst_cmplt_late_0_d1}),
3504
        .clk    (clk),
3505
        .se     (se),       .si (),          .so ()
3506
        );
3507
 
3508
//=========================================================================================
3509
//  LD/ST MISS SIGNAL - IFU
3510
//=========================================================================================
3511
 
3512
// Switchout of internal asi ld
3513
// Do not switchout for tag-target,
3514
assign  ldxa_swo_annul =
3515
        (lsu_dctl_asi_state_m[7:4] == 4'h3)   |         // ldxa to 0x3X does not swo
3516
        (((lsu_dctl_asi_state_m[7:0] == 8'h58) &         // tag-target,tag-access,sfsr,sfar
3517
                ~((lsu_ldst_va_b7_b0_m[7:0] == 8'h38) | (lsu_ldst_va_b7_b0_m[7:0] == 8'h80))) | // wtcpt/pid
3518
         (lsu_dctl_asi_state_m[7:0] == 8'h50)) |
3519
        mmu_rd_only_asi_m ;
3520
 
3521
wire    ldxa_internal_swo_m,ldxa_internal_swo_g ;
3522
assign  ldxa_internal_swo_m = lda_internal_m & ~ldxa_swo_annul ;
3523
 
3524
// This represents *all* ld asi.
3525
wire    asi_internal_ld_m,asi_internal_ld_g ;
3526
assign  asi_internal_ld_m =
3527
        asi_internal_m & ld_inst_vld_m & lsu_alt_space_m ;
3528
 
3529
dff #(2) ldaswo_stgg (
3530
        .din    ({ldxa_internal_swo_m,asi_internal_ld_m}),
3531
        .q      ({ldxa_internal_swo_g,asi_internal_ld_g}),
3532
        .clk    (clk),
3533
        .se     (se),       .si (),          .so ()
3534
        );
3535
 
3536
wire    common_ldst_miss_w ;
3537
assign  common_ldst_miss_w =
3538
(~(cache_hit & (tlb_cam_hit_g | lsu_dtlb_bypass_g)) |   // include miss in tlb;bypass
3539
   ~dcache_enable_g     |       // 
3540
    //endian_mispred_g    |     // endian mispredict
3541
    ldd_force_l2access_g                |       // ifu to incorporate directly
3542
    ncache_asild_rq_g   ) &     // bypass asi
3543
        ~asi_internal_ld_g ;
3544
 
3545
assign  lsu_ifu_ldst_miss_w =
3546
  (common_ldst_miss_w  |         // common between ifu and exu.
3547
    // MMU_ASI : ifu must switch out early only for stores.
3548
    ldxa_internal_swo_g)
3549
//  ldxa_internal       |       // ifu incorporates directly
3550
//  atomic_g            |       // ifu incorporates directly
3551
//  ld_stb_hit_g        |       // late 
3552
//    stb_cam_hit)              // ** rm once ifu uses late signal. ** 
3553
//  dcache_rd_parity_error |    // late
3554
//  dtag_perror_g) &    |       // late
3555
    & (lsu_inst_vld_w & ld_inst_vld_unflushed) ;        // flush uptil m accounted for.
3556
//  & ld_inst_vld_g ;           // assume flush=1 clears ldst_miss=1
3557
//  ~tte_data_perror_unc &      // in flush 
3558
//  (ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
3559
//  ncache_asild_rq_g ;   // asi ld requires bypass
3560
 
3561
 
3562
   //timing fix
3563
   wire lsu_ifu_dc_parity_error_w;
3564
   assign lsu_ifu_dc_parity_error_w =
3565
        (
3566
        lsu_dcache_data_perror_g | // bug 4267
3567
        lsu_dcache_tag_perror_g  |
3568
  endian_mispred_g         |    // endian mispredict ; mv'ed from ldst_miss
3569
        tte_data_perror_unc_en) ;
3570
 
3571
/*
3572
   wire   lsu_ld_inst_vld_flush_w, lsu_ld_inst_vld_flush_w2;
3573
   assign lsu_ld_inst_vld_flush_w = lsu_inst_vld_w & ld_inst_vld_unflushed & ~dctl_flush_pipe_w ;
3574
 
3575
 
3576
dff #(1) lsu_ld_inst_vld_flush_stgw2 (
3577
        .din    (lsu_ld_inst_vld_flush_w),
3578
        .q      (lsu_ld_inst_vld_flush_w2),
3579
        .clk    (clk),
3580
        .se     (se),       .si (),          .so ()
3581
        );
3582
*/
3583
 
3584
   wire   lsu_ifu_dc_parity_error_w2_q;
3585
 
3586
dff #(1) lsu_ifu_dc_parity_error_stgw2 (
3587
        .din    (lsu_ifu_dc_parity_error_w),
3588
        .q      (lsu_ifu_dc_parity_error_w2_q),
3589
        .clk    (clk),
3590
        .se     (se),       .si (),          .so ()
3591
        );
3592
 
3593
   assign lsu_ifu_dc_parity_error_w2 = (lsu_ifu_dc_parity_error_w2_q | stb_cam_hit_w2) & ld_inst_vld_w2;
3594
 
3595
//=========================================================================================
3596
//  LD/ST MISS SIGNAL - EXU
3597
//=========================================================================================
3598
 
3599
// for a diagnstc access to the cache, the if it misses in the cache, then 
3600
// ldst_miss is asserted, preventing a write into the cache, but code is
3601
// allowed to continue executing.
3602
wire    exu_ldst_miss_g_no_stb_cam_hit ;
3603
assign  exu_ldst_miss_g_no_stb_cam_hit =
3604
  (common_ldst_miss_w     |
3605
   ldxa_internal_swo_g    |
3606
   endian_mispred_g       |
3607
   atomic_g               |
3608
   lsu_dcache_data_perror_g     |
3609
   lsu_dcache_tag_perror_g      |
3610
   tte_data_perror_unc_en       |
3611
   pref_inst_g) & ld_inst_vld_unflushed & lsu_inst_vld_w ; // flush qual done in exu
3612
 
3613
 
3614
   wire ld_inst_vld_no_flush_w, ld_inst_vld_no_flush_w2;
3615
   assign ld_inst_vld_no_flush_w = ld_inst_vld_unflushed & lsu_inst_vld_w;
3616
 
3617
dff #(1) ld_inst_vld_no_flush_stgw2 (
3618
        .din    (ld_inst_vld_no_flush_w),
3619
        .q      (ld_inst_vld_no_flush_w2),
3620
        .clk    (clk),
3621
        .se     (se),       .si (),          .so ()
3622
        );
3623
 
3624
   wire lsu_exu_ldst_miss_w2_tmp;
3625
 
3626
dff #(1) exuldstmiss_stgw2 (
3627
        .din    (exu_ldst_miss_g_no_stb_cam_hit),
3628
        .q      (lsu_exu_ldst_miss_w2_tmp),
3629
        .clk    (clk),
3630
        .se     (se),       .si (),          .so ()
3631
        );
3632
 
3633
   assign lsu_exu_ldst_miss_w2 =  (lsu_exu_ldst_miss_w2_tmp | stb_cam_hit_w2) & ld_inst_vld_no_flush_w2;
3634
 
3635
 
3636
wire    lsu_ldst_miss_w2;
3637
assign  lsu_ldst_miss_w2 = lsu_exu_ldst_miss_w2 ;
3638
 
3639
//=========================================================================================
3640
//  RMO Store control data
3641
//=========================================================================================
3642
 
3643
assign  lsu_st_rmo_m = (st_inst_vld_m & (binit_quad_asi_m | blk_asi_m) & lsu_alt_space_m) | blkst_m ;
3644
assign  lsu_bst_in_pipe_m = (st_inst_vld_m &  blk_asi_m & lsu_alt_space_m) ;
3645
 
3646
//=========================================================================================
3647
//  ASI BUS 
3648
//=========================================================================================
3649
 
3650
// *** This logic is now used by all long-latency asi operations on chip. ***
3651
 
3652
// Start with SDATA Reg for Streaming
3653
wire    strm_asi, strm_asi_m ;
3654
assign  strm_asi_m = (lsu_dctl_asi_state_m[7:0]==8'h40) ;
3655
 
3656
dff  strm_stgg (
3657
        .din    (strm_asi_m),
3658
        .q      (strm_asi),
3659
        .clk    (clk),
3660
        .se     (se),       .si (),          .so ()
3661
        );
3662
 
3663
assign  stxa_stall_asi_g =
3664
  strm_asi & ((ldst_va_g[7:0] == 8'h80)) ;       // ma ctl
3665
  /*strm_asi & (        (ldst_va_g[7:0] == 8'h18) |     // streaming stxa to sdata
3666
                (ldst_va_g[7:0] == 8'h00) |     // stream ctl
3667
                (ldst_va_g[7:0] == 8'h08) ) ;   // ma ctl */
3668
 
3669
wire    dtlb_wr_cmplt0, dtlb_wr_cmplt1;
3670
wire    dtlb_wr_cmplt2, dtlb_wr_cmplt3;
3671
assign  dtlb_wr_cmplt0 = demap_thread0 & lsu_dtlb_wr_vld_e ;
3672
assign  dtlb_wr_cmplt1 = demap_thread1 & lsu_dtlb_wr_vld_e ;
3673
assign  dtlb_wr_cmplt2 = demap_thread2 & lsu_dtlb_wr_vld_e ;
3674
assign  dtlb_wr_cmplt3 = demap_thread3 & lsu_dtlb_wr_vld_e ;
3675
 
3676
dff  dtlbw_stgd1 (
3677
        .din    (lsu_dtlb_wr_vld_e),
3678
        .q      (dtlb_wr_init_d1),
3679
        .clk    (clk),
3680
        .se     (se),       .si (),          .so ()
3681
        );
3682
 
3683
dff  dtlbw_stgd2 (
3684
        .din    (dtlb_wr_init_d1),
3685
        .q      (dtlb_wr_init_d2),
3686
        .clk    (clk),
3687
        .se     (se),       .si (),          .so ()
3688
        );
3689
 
3690
dff  dtlbw_stgd3 (
3691
        .din    (dtlb_wr_init_d2),
3692
        .q      (dtlb_wr_init_d3),
3693
        .clk    (clk),
3694
        .se     (se),       .si (),          .so ()
3695
        );
3696
 
3697
wire    dtlb_wr_init_d4 ;
3698
dff  dtlbw_stgd4 (
3699
        .din    (dtlb_wr_init_d3),
3700
        .q      (dtlb_wr_init_d4),
3701
        .clk    (clk),
3702
        .se     (se),       .si (),          .so ()
3703
        );
3704
 
3705
 
3706
 
3707
wire    tlb_access_sel_thrd3_d1,tlb_access_sel_thrd2_d1;
3708
wire    tlb_access_sel_thrd1_d1,tlb_access_sel_thrd0_d1 ;
3709
wire    ifu_asi_store_cmplt_en, ifu_asi_store_cmplt_en_d1 ;
3710
assign  stxa_stall_wr_cmplt0 =  (spu_lsu_stxa_ack & spu_stxa_thread0) |
3711
        (tlu_stxa_thread0_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3712
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd0_d1) |
3713
        dtlb_wr_cmplt0 ;
3714
assign  stxa_stall_wr_cmplt1 =  (spu_lsu_stxa_ack & spu_stxa_thread1) |
3715
        (tlu_stxa_thread1_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3716
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd1_d1) |
3717
        dtlb_wr_cmplt1 ;
3718
assign  stxa_stall_wr_cmplt2 =  (spu_lsu_stxa_ack & spu_stxa_thread2) |
3719
        (tlu_stxa_thread2_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3720
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd2_d1) |
3721
        dtlb_wr_cmplt2 ;
3722
assign  stxa_stall_wr_cmplt3 =  (spu_lsu_stxa_ack & spu_stxa_thread3) |
3723
        (tlu_stxa_thread3_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3724
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd3_d1) |
3725
        dtlb_wr_cmplt3 ;
3726
 
3727
dff  #(4) stxastall_stgd1 (
3728
        .din    ({stxa_stall_wr_cmplt3,stxa_stall_wr_cmplt2,
3729
                stxa_stall_wr_cmplt1,stxa_stall_wr_cmplt0}),
3730
        .q      ({stxa_stall_wr_cmplt3_d1,stxa_stall_wr_cmplt2_d1,
3731
                stxa_stall_wr_cmplt1_d1,stxa_stall_wr_cmplt0_d1}),
3732
        .clk    (clk),
3733
        .se     (se),       .si (),          .so ()
3734
        );
3735
 
3736
 
3737
// enable speculates on inst not being flushed
3738
// Only dside diagnostic writes will be logged for long-latency action. dside diagnostic
3739
// reads are aligned to pipe.
3740
wire wr_dc_diag_asi_e, wr_dtagv_diag_asi_e ;
3741
 
3742
assign  wr_dc_diag_asi_e = dc_diagnstc_asi_e & st_inst_vld_e ;
3743
assign  wr_dtagv_diag_asi_e =  dtagv_diagnstc_asi_e & st_inst_vld_e ;
3744
 
3745
assign  tlb_access_en0_e =
3746
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3747
    & thread0_e & alt_space_e ;
3748
assign  tlb_access_en1_e =
3749
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3750
    & thread1_e & alt_space_e ;
3751
assign  tlb_access_en2_e =
3752
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3753
    & thread2_e & alt_space_e ;
3754
assign  tlb_access_en3_e =
3755
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3756
    & thread3_e & alt_space_e ;
3757
 
3758
dff  #(4) tlbac_stgm (
3759
        .din    ({tlb_access_en0_e,tlb_access_en1_e,tlb_access_en2_e,tlb_access_en3_e}),
3760
        .q      ({tlb_access_en0_tmp,tlb_access_en1_tmp,tlb_access_en2_tmp,tlb_access_en3_tmp}),
3761
        .clk    (clk),
3762
        .se     (se),       .si (),          .so ()
3763
        );
3764
 
3765
wire    ldst_vld_m = ld_inst_vld_m | st_inst_vld_m ;
3766
assign  tlb_access_en0_m = tlb_access_en0_tmp & ldst_vld_m ;
3767
assign  tlb_access_en1_m = tlb_access_en1_tmp & ldst_vld_m ;
3768
assign  tlb_access_en2_m = tlb_access_en2_tmp & ldst_vld_m ;
3769
assign  tlb_access_en3_m = tlb_access_en3_tmp & ldst_vld_m ;
3770
 
3771
dff  #(4) tlbac_stgw (
3772
        .din    ({tlb_access_en0_m,tlb_access_en1_m,tlb_access_en2_m,tlb_access_en3_m}),
3773
        .q      ({tlb_access_en0_unflushed,tlb_access_en1_unflushed,tlb_access_en2_unflushed,tlb_access_en3_unflushed}),
3774
        .clk    (clk),
3775
        .se     (se),       .si (),          .so ()
3776
        );
3777
 
3778
// Flush ld/st with as=42 belonging to lsu. bistctl and ldiag
3779
 
3780
assign  tlb_access_en0_g = tlb_access_en0_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3781
//assign  tlb_access_en0_g = tlb_access_en0_unflushed & lsu_inst_vld_w & ~(dctl_flush_pipe_w | ifu_asi42_flush_g) ;
3782
assign  tlb_access_en1_g = tlb_access_en1_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3783
assign  tlb_access_en2_g = tlb_access_en2_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3784
assign  tlb_access_en3_g = tlb_access_en3_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3785
 
3786
assign  diag_wr_cmplt0 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd0_d1 ;
3787
assign  diag_wr_cmplt1 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd1_d1 ;
3788
assign  diag_wr_cmplt2 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd2_d1 ;
3789
assign  diag_wr_cmplt3 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd3_d1 ;
3790
 
3791
wire    ifu_tlb_rd_cmplt0,ifu_tlb_rd_cmplt1,ifu_tlb_rd_cmplt2,ifu_tlb_rd_cmplt3 ;
3792
wire    st_sqsh_m, ifu_asi_ack_d1 ;
3793
assign  ifu_tlb_rd_cmplt0 =  (ifu_ldxa_thread0_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb0_asi) ;
3794
assign  ifu_tlb_rd_cmplt1 =  (ifu_ldxa_thread1_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb1_asi) ;
3795
assign  ifu_tlb_rd_cmplt2 =  (ifu_ldxa_thread2_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb2_asi) ;
3796
assign  ifu_tlb_rd_cmplt3 =  (ifu_ldxa_thread3_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb3_asi) ;
3797
 
3798
// stxa ack will share tid with ldxa
3799
// This should be qualified with inst_vld_w also !!!
3800
// ldxa_data_vld needs to be removed once full interface in !!!
3801
assign  tlb_access_rst0 =  reset |
3802
  (tlu_ldxa_thread0_w2 & tlu_lsu_ldxa_async_data_vld) |
3803
  (tlu_stxa_thread0_w2 & tlu_lsu_stxa_ack) |
3804
  (ifu_tlb_rd_cmplt0) |
3805
  (ifu_stxa_thread0_w2 & ifu_lsu_asi_ack) |
3806
  diag_wr_cmplt0 ;
3807
assign  tlb_access_rst1 =  reset |
3808
  (tlu_ldxa_thread1_w2 & tlu_lsu_ldxa_async_data_vld) |
3809
  (tlu_stxa_thread1_w2 & tlu_lsu_stxa_ack) |
3810
  (ifu_tlb_rd_cmplt1) |
3811
  (ifu_stxa_thread1_w2 & ifu_lsu_asi_ack) |
3812
  diag_wr_cmplt1 ;
3813
assign  tlb_access_rst2 =  reset |
3814
  (tlu_ldxa_thread2_w2 & tlu_lsu_ldxa_async_data_vld) |
3815
  (tlu_stxa_thread2_w2 & tlu_lsu_stxa_ack) |
3816
  (ifu_tlb_rd_cmplt2) |
3817
  (ifu_stxa_thread2_w2 & ifu_lsu_asi_ack) |
3818
  diag_wr_cmplt2 ;
3819
assign  tlb_access_rst3 =  reset |
3820
  (tlu_ldxa_thread3_w2 & tlu_lsu_ldxa_async_data_vld) |
3821
  (tlu_stxa_thread3_w2 & tlu_lsu_stxa_ack) |
3822
  (ifu_tlb_rd_cmplt3) |
3823
  (ifu_stxa_thread3_w2 & ifu_lsu_asi_ack) |
3824
  diag_wr_cmplt3 ;
3825
 
3826
 
3827
// tlb_ld_inst* and tlb_st_inst* are generically used to indicate a read or write. 
3828
// Thread 0
3829
 
3830
dffre #(2)  asiv_thrd0 (
3831
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3832
        .q      ({tlb_ld_inst0,tlb_st_inst0}),
3833
        .rst    (tlb_access_rst0),        .en     (tlb_access_en0_g),
3834
        .clk    (clk),
3835
        .se     (se),       .si (),          .so ()
3836
        );
3837
 
3838
dffe #(3)  asiv_thrd0_sec (
3839
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3840
        .q      ({dc0_diagnstc_asi,dtagv0_diagnstc_asi,ifu_nontlb0_asi}),
3841
        .en     (tlb_access_en0_g),
3842
        .clk    (clk),
3843
        .se     (se),       .si (),          .so ()
3844
        );
3845
 
3846
assign  nontlb_asi0 = dc0_diagnstc_asi | dtagv0_diagnstc_asi | ifu_nontlb0_asi ;
3847
 
3848
// Thread 1
3849
 
3850
dffre #(2)  asiv_thrd1 (
3851
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3852
        .q      ({tlb_ld_inst1,tlb_st_inst1}),
3853
        .rst    (tlb_access_rst1),        .en     (tlb_access_en1_g),
3854
        .clk    (clk),
3855
        .se     (se),       .si (),          .so ()
3856
        );
3857
 
3858
dffe #(3)  asiv_thrd1_sec (
3859
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3860
        .q      ({dc1_diagnstc_asi,dtagv1_diagnstc_asi,ifu_nontlb1_asi}),
3861
        .en     (tlb_access_en1_g),
3862
        .clk    (clk),
3863
        .se     (se),       .si (),          .so ()
3864
        );
3865
 
3866
assign  nontlb_asi1 = dc1_diagnstc_asi | dtagv1_diagnstc_asi | ifu_nontlb1_asi ;
3867
 
3868
// Thread 2
3869
 
3870
dffre #(2)  asiv_thrd2 (
3871
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3872
        .q      ({tlb_ld_inst2,tlb_st_inst2}),
3873
        .rst    (tlb_access_rst2),        .en     (tlb_access_en2_g),
3874
        .clk    (clk),
3875
        .se     (se),       .si (),          .so ()
3876
        );
3877
 
3878
dffe #(3)  asiv_thrd2_sec (
3879
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3880
        .q      ({dc2_diagnstc_asi,dtagv2_diagnstc_asi,ifu_nontlb2_asi}),
3881
        .en     (tlb_access_en2_g),
3882
        .clk    (clk),
3883
        .se     (se),       .si (),          .so ()
3884
        );
3885
 
3886
assign  nontlb_asi2 = dc2_diagnstc_asi | dtagv2_diagnstc_asi | ifu_nontlb2_asi ;
3887
 
3888
// Thread 3
3889
 
3890
dffre #(2)  asiv_thrd3 (
3891
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3892
        .q      ({tlb_ld_inst3,tlb_st_inst3}),
3893
        .rst    (tlb_access_rst3),        .en     (tlb_access_en3_g),
3894
        .clk    (clk),
3895
        .se     (se),       .si (),          .so ()
3896
        );
3897
 
3898
dffe #(3)  asiv_thrd3_sec (
3899
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3900
        .q      ({dc3_diagnstc_asi,dtagv3_diagnstc_asi,ifu_nontlb3_asi}),
3901
        .en     (tlb_access_en3_g),
3902
        .clk    (clk),
3903
        .se     (se),       .si (),          .so ()
3904
        );
3905
 
3906
assign  nontlb_asi3 = dc3_diagnstc_asi | dtagv3_diagnstc_asi | ifu_nontlb3_asi ;
3907
 
3908
//---
3909
//  Prioritization of threaded events from asi queue.
3910
//  - It is not expected that a significant bias will exist in selecting
3911
//  1 of 4 possible events from the asi queue because of the low frequency
3912
//  of such events. However, to bulletproof we will prioritize the events
3913
//  in a fifo manner.
3914
//---
3915
 
3916
// Control :
3917
 
3918
wire    [3:0]    fifo_top ;
3919
wire    asi_fifo0_vld,asi_fifo1_vld,asi_fifo2_vld,asi_fifo3_vld;
3920
 
3921
assign  fifo_top[0] = ~asi_fifo0_vld ;
3922
assign  fifo_top[1] = ~asi_fifo1_vld & asi_fifo0_vld ;
3923
assign  fifo_top[2] = ~asi_fifo2_vld & asi_fifo1_vld & asi_fifo0_vld ;
3924
assign  fifo_top[3] = ~asi_fifo3_vld & asi_fifo2_vld & asi_fifo1_vld & asi_fifo0_vld ;
3925
 
3926
// Check for timing on flush.
3927
// Do not confuse thread# with fifo entry#.
3928
wire    fifo_wr, fifo_shift ;
3929
assign  fifo_wr =
3930
tlb_access_en0_g | tlb_access_en1_g | tlb_access_en2_g | tlb_access_en3_g ;
3931
assign  fifo_shift =
3932
tlb_access_rst0 | tlb_access_rst1 | tlb_access_rst2 | tlb_access_rst3 ;
3933
 
3934
wire    [3:0]    fifo_top_wr ;
3935
assign  fifo_top_wr[0] = fifo_top[0] & fifo_wr ;
3936
assign  fifo_top_wr[1] = fifo_top[1] & fifo_wr ;
3937
assign  fifo_top_wr[2] = fifo_top[2] & fifo_wr ;
3938
assign  fifo_top_wr[3] = fifo_top[3] & fifo_wr ;
3939
 
3940
// Matrix for Data Selection.
3941
// shift | wr | din for entry
3942
// 0       0    na
3943
// 0       1    thrid_g
3944
// 1       0    q
3945
// 1       1    q if top is not 1 above
3946
// 1       1    thrid_g if top is 1 above
3947
 
3948
// shift writeable entry into correct position, if exists.
3949
wire    asi_fifo0_sel,asi_fifo1_sel,asi_fifo2_sel ;
3950
assign  asi_fifo0_sel = fifo_shift ? fifo_top_wr[1] : fifo_top_wr[0] ;
3951
assign  asi_fifo1_sel = fifo_shift ? fifo_top_wr[2] : fifo_top_wr[1] ;
3952
assign  asi_fifo2_sel = fifo_shift ? fifo_top_wr[3] : fifo_top_wr[2] ;
3953
 
3954
wire    [1:0]    asi_fifo3_din,asi_fifo2_din,asi_fifo1_din,asi_fifo0_din ;
3955
wire    [1:0]    asi_fifo3_q,asi_fifo2_q,asi_fifo1_q,asi_fifo0_q ;
3956
assign  asi_fifo0_din[1:0] = asi_fifo0_sel ? thrid_g[1:0] : asi_fifo1_q[1:0] ;
3957
assign  asi_fifo1_din[1:0] = asi_fifo1_sel ? thrid_g[1:0] : asi_fifo2_q[1:0] ;
3958
assign  asi_fifo2_din[1:0] = asi_fifo2_sel ? thrid_g[1:0] : asi_fifo3_q[1:0] ;
3959
assign  asi_fifo3_din[1:0] = thrid_g[1:0] ; // can never shift into.
3960
 
3961
// Matrix for Enable 
3962
// shift | wr | Entry Written ?
3963
// 0       0    0
3964
// 0       1    if top
3965
// 1       0    if entry+1 is vld
3966
// 1       1    if entry itself is vld => as is.
3967
 
3968
wire    wr_not_sh,sh_not_wr,wr_and_sh ;
3969
assign  wr_not_sh =  fifo_wr & ~fifo_shift ; // write not shift
3970
assign  sh_not_wr = ~fifo_wr &  fifo_shift ; // shift not write
3971
assign  wr_and_sh =  fifo_wr &  fifo_shift ; // shift and write
3972
 
3973
wire    asi_fifo0_vin,asi_fifo1_vin,asi_fifo2_vin,asi_fifo3_vin ;
3974
assign  asi_fifo0_vin =
3975
        (wr_not_sh & fifo_top[0]) |
3976
        (sh_not_wr & asi_fifo1_vld) |
3977
        (wr_and_sh & asi_fifo0_vld) ;
3978
assign  asi_fifo1_vin =
3979
        (wr_not_sh & fifo_top[1]) |
3980
        (sh_not_wr & asi_fifo2_vld) |
3981
        (wr_and_sh & asi_fifo1_vld) ;
3982
assign  asi_fifo2_vin =
3983
        (wr_not_sh & fifo_top[2]) |
3984
        (sh_not_wr & asi_fifo3_vld) |
3985
        (wr_and_sh & asi_fifo2_vld) ;
3986
assign  asi_fifo3_vin =
3987
        (wr_not_sh & fifo_top[3]) |
3988
        (wr_and_sh & asi_fifo3_vld) ;
3989
 
3990
wire    asi_fifo0_en,asi_fifo1_en,asi_fifo2_en,asi_fifo3_en ;
3991
assign  asi_fifo0_en = (fifo_wr & fifo_top[0]) | fifo_shift ;
3992
assign  asi_fifo1_en = (fifo_wr & fifo_top[1]) | fifo_shift ;
3993
assign  asi_fifo2_en = (fifo_wr & fifo_top[2]) | fifo_shift ;
3994
assign  asi_fifo3_en = (fifo_wr & fifo_top[3]) | fifo_shift ;
3995
 
3996
wire    asi_fifo3_rst,asi_fifo2_rst,asi_fifo1_rst,asi_fifo0_rst ;
3997
assign  asi_fifo0_rst = reset ;
3998
assign  asi_fifo1_rst = reset ;
3999
assign  asi_fifo2_rst = reset ;
4000
assign  asi_fifo3_rst = reset ;
4001
 
4002
// Datapath :
4003
// fifo entry 0 is earliest. fifo entry 3 is latest.
4004
dffe #(2)  asiq_fifo_0 (
4005
        .din    (asi_fifo0_din[1:0]),
4006
        .q      (asi_fifo0_q[1:0]),
4007
        .en     (asi_fifo0_en),
4008
        .clk    (clk),
4009
        .se     (se),       .si (),          .so ()
4010
        );
4011
 
4012
dffre   asiqv_fifo_0 (
4013
        .din    (asi_fifo0_vin),
4014
        .q      (asi_fifo0_vld),
4015
        .en     (asi_fifo0_en), .rst (asi_fifo0_rst),
4016
        .clk    (clk),
4017
        .se     (se),       .si (),          .so ()
4018
        );
4019
 
4020
wire    asi_sel_thrd3,asi_sel_thrd2,asi_sel_thrd1,asi_sel_thrd0;
4021
assign  asi_sel_thrd0 = ~asi_fifo0_q[1] & ~asi_fifo0_q[0] & (tlb_ld_inst0 | tlb_st_inst0) ;
4022
assign  asi_sel_thrd1 = ~asi_fifo0_q[1] &  asi_fifo0_q[0] & (tlb_ld_inst1 | tlb_st_inst1) ;
4023
assign  asi_sel_thrd2 =  asi_fifo0_q[1] & ~asi_fifo0_q[0] & (tlb_ld_inst2 | tlb_st_inst2) ;
4024
assign  asi_sel_thrd3 =  asi_fifo0_q[1] &  asi_fifo0_q[0] & (tlb_ld_inst3 | tlb_st_inst3) ;
4025
 
4026
dffe #(2)  asiq_fifo_1 (
4027
        .din    (asi_fifo1_din[1:0]),
4028
        .q      (asi_fifo1_q[1:0]),
4029
        .en     (asi_fifo1_en),
4030
        .clk    (clk),
4031
        .se     (se),       .si (),          .so ()
4032
        );
4033
 
4034
dffre  asiqv_fifo_1 (
4035
        .din    (asi_fifo1_vin),
4036
        .q      (asi_fifo1_vld),
4037
        .en     (asi_fifo1_en), .rst    (asi_fifo1_rst),
4038
        .clk    (clk),
4039
        .se     (se),       .si (),          .so ()
4040
        );
4041
 
4042
dffe #(2)  asiq_fifo_2 (
4043
        .din    (asi_fifo2_din[1:0]),
4044
        .q      (asi_fifo2_q[1:0]),
4045
        .en     (asi_fifo2_en),
4046
        .clk    (clk),
4047
        .se     (se),       .si (),          .so ()
4048
        );
4049
 
4050
dffre   asiqv_fifo_2 (
4051
        .din    (asi_fifo2_vin),
4052
        .q      (asi_fifo2_vld),
4053
        .en     (asi_fifo2_en), .rst    (asi_fifo2_rst),
4054
        .clk    (clk),
4055
        .se     (se),       .si (),          .so ()
4056
        );
4057
 
4058
dffe #(2)  asiq_fifo_3 (
4059
        .din    (asi_fifo3_din[1:0]),
4060
        .q      (asi_fifo3_q[1:0]),
4061
        .en     (asi_fifo3_en),
4062
        .clk    (clk),
4063
        .se     (se),       .si (),          .so ()
4064
        );
4065
 
4066
dffre  asiqv_fifo_3 (
4067
        .din    (asi_fifo3_vin),
4068
        .q      (asi_fifo3_vld),
4069
        .en     (asi_fifo3_en), .rst    (asi_fifo3_rst),
4070
        .clk    (clk),
4071
        .se     (se),       .si (),          .so ()
4072
        );
4073
 
4074
//---
4075
 
4076
assign  tlb_access_initiated =
4077
  ((tlb_access_sel_thrd0 & ~tlb_access_rst0) |
4078
   (tlb_access_sel_thrd1 & ~tlb_access_rst1) |
4079
   (tlb_access_sel_thrd2 & ~tlb_access_rst2) |
4080
   (tlb_access_sel_thrd3 & ~tlb_access_rst3)) & ~tlb_access_pending ;
4081
 
4082
 
4083
wire  tlb_blocking_rst ;
4084
assign  tlb_blocking_rst = reset |
4085
  tlu_lsu_stxa_ack | tlu_lsu_ldxa_async_data_vld |
4086
  ifu_tlb_rd_cmplt0 | ifu_tlb_rd_cmplt1 |
4087
  ifu_tlb_rd_cmplt2 | ifu_tlb_rd_cmplt3 |
4088
  ifu_lsu_asi_ack |
4089
  lsu_diagnstc_wr_src_sel_e;
4090
 
4091
 
4092
// MMU/IFU/DIAG Action is pending
4093
dffre #(1)  tlbpnd (
4094
        .din    (tlb_access_initiated),
4095
        .q      (tlb_access_pending),
4096
        .rst    (tlb_blocking_rst),        .en     (tlb_access_initiated),
4097
        .clk    (clk),
4098
        .se     (se),       .si (),          .so ()
4099
        );
4100
 
4101
/*wire  asi_pend0,asi_pend1,asi_pend2,asi_pend3 ;
4102
dffre #(4)  asithrdpnd (
4103
        .din    ({tlb_access_sel_thrd3,tlb_access_sel_thrd2,
4104
                            tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
4105
        .q    ({asi_pend3,asi_pend2,asi_pend1,asi_pend0}),
4106
        .rst    (tlb_blocking_rst),     .en     (tlb_access_initiated),
4107
        .clk  (clk),
4108
        .se   (se),       .si (),          .so ()
4109
        );
4110
 
4111
wire    asi_pend_non_thrd0 ;
4112
assign  asi_pend_non_thrd0 = asi_pend1 | asi_pend2 | asi_pend3 ;
4113
wire    asi_pend_non_thrd1 ;
4114
assign  asi_pend_non_thrd1 = asi_pend0 | asi_pend2 | asi_pend3 ;
4115
wire    asi_pend_non_thrd2 ;
4116
assign  asi_pend_non_thrd2 = asi_pend0 | asi_pend1 | asi_pend3 ;
4117
wire    asi_pend_non_thrd3 ;
4118
assign  asi_pend_non_thrd3 = asi_pend0 | asi_pend1 | asi_pend2 ; */
4119
 
4120
// Would like to remove st_inst_vld_m. This is however required to
4121
// source rs3 data to tlu/mmu. Send rs3_data directly !!!
4122
 
4123
wire    diag_wr_src, diag_wr_src_d1, diag_wr_src_d2 ;
4124
 
4125
assign  tlb_access_blocked =
4126
  (tlb_access_pending & ~ifu_asi_vld_d1 & ~diag_wr_src_d1) |
4127
  (st_sqsh_m & ~(ifu_asi_vld_d1 & ~ifu_asi_ack_d1) & ~diag_wr_src_d1) ; // Bug 4875
4128
  //(st_inst_vld_m & ~lsu_ifu_asi_vld_d1 & ~diag_wr_src_d1) ;
4129
 
4130
// fixed priority. tlb accesses are issued speculatively in the m-stage and are
4131
// Change priority to round-robin !!!
4132
// flushed in the g-stage in the tlu if necessary.
4133
// diagnstc writes will block for cache/tag access.
4134
// This means that access can be blocked if a st is 
4135
// in the m-stage or a memref in the d stage. (!!!)
4136
// In this case, it is better to stage a different
4137
// bus for rs3 data.
4138
 
4139
// Note : Selection Process.
4140
// 1. Priority Encoded selection if no access pending.
4141
// This may have to be changed to prevent bias towards a
4142
// single thread.
4143
// 2. Once thread is selected :
4144
//      a. generate single pulse - mmu. tlb_access_blocked
4145
//      used for this purpose.
4146
//      b. generate window - ifu/diag. To prevent spurious change
4147
//      in selects, asi_pend_non_thrdx and tlb_access_pending
4148
//      qual. is required.
4149
 
4150
 
4151
assign  tlb_access_sel_thrd0 = ~rst_tri_en &
4152
  asi_sel_thrd0 & ~tlb_access_blocked ;
4153
assign  tlb_access_sel_thrd1 = ~rst_tri_en &
4154
  asi_sel_thrd1 & ~tlb_access_blocked ;
4155
assign  tlb_access_sel_thrd2 = ~rst_tri_en &
4156
  asi_sel_thrd2 & ~tlb_access_blocked ;
4157
assign  tlb_access_sel_thrd3 = ~rst_tri_en &
4158
  asi_sel_thrd3 & ~tlb_access_blocked ;
4159
 
4160
//assign  tlb_access_sel_thrd0 = ~rst_tri_en & ( 
4161
//  (tlb_ld_inst0 | tlb_st_inst0) & ~tlb_access_blocked & 
4162
//  ~asi_pend_non_thrd0 );
4163
//assign  tlb_access_sel_thrd1 = ~rst_tri_en & (
4164
//  (tlb_ld_inst1 | tlb_st_inst1) & 
4165
//  ~(((tlb_ld_inst0 | tlb_st_inst0) & ~tlb_access_pending) | tlb_access_blocked) & 
4166
//  ~asi_pend_non_thrd1 );
4167
//assign  tlb_access_sel_thrd2 = ~rst_tri_en & ( 
4168
//  (tlb_ld_inst2 | tlb_st_inst2) & 
4169
//  ~(((tlb_ld_inst0 | tlb_st_inst0 | tlb_ld_inst1 | tlb_st_inst1) & ~tlb_access_pending) 
4170
//              | tlb_access_blocked) &
4171
//  ~asi_pend_non_thrd2 );
4172
//assign  tlb_access_sel_thrd3 = ~rst_tri_en & ( 
4173
//  (tlb_ld_inst3 | tlb_st_inst3) & 
4174
//  ~(((tlb_ld_inst0 | tlb_st_inst0 | tlb_ld_inst1 | tlb_st_inst1 | 
4175
//    tlb_ld_inst2 | tlb_st_inst2) & ~tlb_access_pending) | tlb_access_blocked) &
4176
//  ~asi_pend_non_thrd3 );
4177
 
4178
dff  #(4) selt_stgd1 (
4179
        .din    ({tlb_access_sel_thrd3,tlb_access_sel_thrd2,
4180
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
4181
        .q     ({tlb_access_sel_thrd3_d1,tlb_access_sel_thrd2_d1,
4182
                tlb_access_sel_thrd1_d1,tlb_access_sel_thrd0_d1}),
4183
        .clk    (clk),
4184
        .se     (se),       .si (),          .so ()
4185
        );
4186
 
4187
   wire tlb_access_sel_default;
4188
assign  tlb_access_sel_default = rst_tri_en | (
4189
        ~(tlb_access_sel_thrd2 | tlb_access_sel_thrd1 | tlb_access_sel_thrd0));
4190
 
4191
dff  #(4) lsu_diagnstc_data_sel_ff (
4192
        .din    ({tlb_access_sel_default,tlb_access_sel_thrd2,
4193
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
4194
        .q     ({lsu_diagnstc_data_sel[3:0]}),
4195
        .clk    (clk),
4196
        .se     (se),       .si (),          .so ()
4197
        );
4198
 
4199
dff  #(4) lsu_diagnstc_va_sel_ff (
4200
        .din    ({tlb_access_sel_default,tlb_access_sel_thrd2,
4201
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
4202
        .q     ({lsu_diagnstc_va_sel[3:0]}),
4203
        .clk    (clk),
4204
        .se     (se),       .si (),          .so ()
4205
        );
4206
 
4207
 
4208
// Begin - Bug 3487
4209
assign  st_sqsh_m =
4210
        (st_inst_vld_m & asi_internal_m & lsu_alt_space_m) ; // Squash as bus required for stxa.
4211
assign  tlb_st_data_sel_m[0] = (tlb_access_sel_thrd0 & ~st_sqsh_m) | (st_sqsh_m & thread0_m) ;
4212
assign  tlb_st_data_sel_m[1] = (tlb_access_sel_thrd1 & ~st_sqsh_m) | (st_sqsh_m & thread1_m) ;
4213
assign  tlb_st_data_sel_m[2] = (tlb_access_sel_thrd2 & ~st_sqsh_m) | (st_sqsh_m & thread2_m) ;
4214
assign  tlb_st_data_sel_m[3] = ~|tlb_st_data_sel_m[2:0];
4215
 
4216
assign  lsu_ifu_asi_data_en_l = ~(ifu_asi_vld & tlb_access_initiated) ;
4217
 
4218
// End - Bug 3487
4219
 
4220
/*assign  tlb_st_data_sel_m[0] = tlb_access_sel_thrd0 | ((st_inst_vld_m & thread0_m) & tlb_access_blocked) ;
4221
assign  tlb_st_data_sel_m[1] = tlb_access_sel_thrd1 | ((st_inst_vld_m & thread1_m) & tlb_access_blocked) ;
4222
assign  tlb_st_data_sel_m[2] = tlb_access_sel_thrd2 | ((st_inst_vld_m & thread2_m) & tlb_access_blocked) ;
4223
assign  tlb_st_data_sel_m[3] = ~|tlb_st_data_sel_m[2:0];*/
4224
 
4225
//assign        lsu_tlb_st_sel_m[3:0] = tlb_st_data_sel_m[3:0] ;
4226
assign  lsu_tlb_st_sel_m[0] = tlb_st_data_sel_m[0] & ~rst_tri_en;
4227
assign  lsu_tlb_st_sel_m[1] = tlb_st_data_sel_m[1] & ~rst_tri_en;
4228
assign  lsu_tlb_st_sel_m[2] = tlb_st_data_sel_m[2] & ~rst_tri_en;
4229
assign  lsu_tlb_st_sel_m[3] = tlb_st_data_sel_m[3] |  rst_tri_en;
4230
 
4231
assign  lsu_tlu_tlb_ld_inst_m =
4232
  (tlb_access_sel_thrd0 & tlb_ld_inst0 & ~nontlb_asi0) |
4233
  (tlb_access_sel_thrd1 & tlb_ld_inst1 & ~nontlb_asi1) |
4234
  (tlb_access_sel_thrd2 & tlb_ld_inst2 & ~nontlb_asi2) |
4235
  (tlb_access_sel_thrd3 & tlb_ld_inst3 & ~nontlb_asi3) ;
4236
 
4237
// diagnstic write for dside will not go thru tlu.
4238
assign  lsu_tlu_tlb_st_inst_m =
4239
  (tlb_access_sel_thrd0 & tlb_st_inst0 & ~nontlb_asi0) |
4240
  (tlb_access_sel_thrd1 & tlb_st_inst1 & ~nontlb_asi1) |
4241
  (tlb_access_sel_thrd2 & tlb_st_inst2 & ~nontlb_asi2) |
4242
  (tlb_access_sel_thrd3 & tlb_st_inst3 & ~nontlb_asi3) ;
4243
 
4244
assign  lsu_tlu_tlb_access_tid_m[0] = tlb_access_sel_thrd1 | tlb_access_sel_thrd3 ;
4245
assign  lsu_tlu_tlb_access_tid_m[1] = tlb_access_sel_thrd2 | tlb_access_sel_thrd3 ;
4246
 
4247
// Diagnostic write to dcache
4248
assign  dc0_diagnstc_wr_en = (tlb_access_sel_thrd0 & tlb_st_inst0 & dc0_diagnstc_asi) ;
4249
assign  dc1_diagnstc_wr_en = (tlb_access_sel_thrd1 & tlb_st_inst1 & dc1_diagnstc_asi) ;
4250
assign  dc2_diagnstc_wr_en = (tlb_access_sel_thrd2 & tlb_st_inst2 & dc2_diagnstc_asi) ;
4251
assign  dc3_diagnstc_wr_en = (tlb_access_sel_thrd3 & tlb_st_inst3 & dc3_diagnstc_asi) ;
4252
assign  dc_diagnstc_wr_en =
4253
  dc0_diagnstc_wr_en | dc1_diagnstc_wr_en | dc2_diagnstc_wr_en | dc3_diagnstc_wr_en ;
4254
 
4255
// Diagnostic write to dtag/vld
4256
assign  dtagv0_diagnstc_wr_en = (tlb_access_sel_thrd0 & tlb_st_inst0 & dtagv0_diagnstc_asi) ;
4257
assign  dtagv1_diagnstc_wr_en = (tlb_access_sel_thrd1 & tlb_st_inst1 & dtagv1_diagnstc_asi) ;
4258
assign  dtagv2_diagnstc_wr_en = (tlb_access_sel_thrd2 & tlb_st_inst2 & dtagv2_diagnstc_asi) ;
4259
assign  dtagv3_diagnstc_wr_en = (tlb_access_sel_thrd3 & tlb_st_inst3 & dtagv3_diagnstc_asi) ;
4260
assign  dtagv_diagnstc_wr_en =
4261
  dtagv0_diagnstc_wr_en | dtagv1_diagnstc_wr_en | dtagv2_diagnstc_wr_en | dtagv3_diagnstc_wr_en ;
4262
 
4263
// If a diagnostic access is selected in a cycle, then the earliest the
4264
// e-stage can occur for the write is 2-cycles later.
4265
 
4266
assign  diag_wr_src = dtagv_diagnstc_wr_en | dc_diagnstc_wr_en ;
4267
 
4268
   wire diag_wr_src_with_rst;
4269
   assign diag_wr_src_with_rst = diag_wr_src & ~lsu_diagnstc_wr_src_sel_e;
4270
 
4271
dff  #(1) diagwr_d1 (
4272
        .din    (diag_wr_src_with_rst),
4273
        .q      (diag_wr_src_d1),
4274
        .clk    (clk),
4275
        .se     (se),       .si (),          .so ()
4276
        );
4277
 
4278
   wire diag_wr_src_d1_with_rst;
4279
   assign diag_wr_src_d1_with_rst = diag_wr_src_d1 & ~lsu_diagnstc_wr_src_sel_e;
4280
 
4281
dff  #(1) diagwr_d2 (
4282
        .din    (diag_wr_src_d1_with_rst),
4283
        .q      (diag_wr_src_d2),
4284
        .clk    (clk),
4285
        .se     (se),       .si (),          .so ()
4286
        );
4287
 
4288
// If there is no memory reference, then the diag access is free to go.
4289
// tlb_access_blocked must be set appr. 
4290
wire diag_wr_src_sel_d1, diag_wr_src_sel_din;
4291
 
4292
//bug4057: kill diagnostic write if dfq has valid requests to l1d$
4293
//assign diag_wr_src_sel_din = diag_wr_src_d2 & ~memref_e;
4294
assign diag_wr_src_sel_din = diag_wr_src_d2 & ~(memref_e | lsu_dfq_vld);
4295
 
4296
assign  lsu_diagnstc_wr_src_sel_e =  ~diag_wr_src_sel_d1 & diag_wr_src_sel_din ;
4297
 
4298
dff  #(1) diagwrsel_d1 (
4299
        .din    (diag_wr_src_sel_din),
4300
        .q      (diag_wr_src_sel_d1),
4301
        .clk    (clk),
4302
        .se     (se),       .si (),          .so ()
4303
        );
4304
 
4305
// Decode for diagnostic cache/dtag/vld write 
4306
   //wire [13:11] lngltncy_ldst_va;
4307
 
4308
   //assign lngltncy_ldst_va[13:11]= lsu_lngltncy_ldst_va[13:11];
4309
 
4310
//assign  lsu_diagnstc_wr_way_e[0] = ~lngltncy_ldst_va[12] & ~lngltncy_ldst_va[11] ;
4311
//assign  lsu_diagnstc_wr_way_e[1] = ~lngltncy_ldst_va[12] &  lngltncy_ldst_va[11] ;
4312
//assign  lsu_diagnstc_wr_way_e[2] =  lngltncy_ldst_va[12] & ~lngltncy_ldst_va[11] ;
4313
//assign  lsu_diagnstc_wr_way_e[3] =  lngltncy_ldst_va[12] &  lngltncy_ldst_va[11] ;
4314
 
4315
assign  lsu_diagnstc_dtagv_prty_invrt_e =
4316
        lsu_diag_va_prty_invrt & dtagv_diagnstc_wr_en & lsu_diagnstc_wr_src_sel_e ;
4317
 
4318
// ASI Interface to IFU
4319
 
4320
assign  lsu_ifu_asi_load =
4321
  (tlb_access_sel_thrd0 & tlb_ld_inst0 & ifu_nontlb0_asi) |
4322
  (tlb_access_sel_thrd1 & tlb_ld_inst1 & ifu_nontlb1_asi) |
4323
  (tlb_access_sel_thrd2 & tlb_ld_inst2 & ifu_nontlb2_asi) |
4324
  (tlb_access_sel_thrd3 & tlb_ld_inst3 & ifu_nontlb3_asi) ;
4325
 
4326
assign  ifu_asi_store =
4327
  (tlb_access_sel_thrd0 & tlb_st_inst0 & ifu_nontlb0_asi) |
4328
  (tlb_access_sel_thrd1 & tlb_st_inst1 & ifu_nontlb1_asi) |
4329
  (tlb_access_sel_thrd2 & tlb_st_inst2 & ifu_nontlb2_asi) |
4330
  (tlb_access_sel_thrd3 & tlb_st_inst3 & ifu_nontlb3_asi) ;
4331
 
4332
assign  ifu_asi_vld = lsu_ifu_asi_load | ifu_asi_store ;
4333
 
4334
dff  #(2) iasiv_d1 (
4335
        .din    ({ifu_asi_vld,ifu_lsu_asi_ack}),
4336
        .q      ({ifu_asi_vld_d1,ifu_asi_ack_d1}),
4337
        .clk    (clk),
4338
        .se     (se),       .si (),          .so ()
4339
        );
4340
 
4341
// Bug 3932 - delay asi_vld for ifu.
4342
assign  lsu_ifu_asi_vld = ifu_asi_vld_d1 & ~ifu_asi_ack_d1 ;
4343
 
4344
assign  ifu_asi_store_cmplt_en = ifu_asi_store & ifu_lsu_asi_ack ;
4345
dff  #(1) iasist_d1 (
4346
        .din    (ifu_asi_store_cmplt_en),
4347
        .q      (ifu_asi_store_cmplt_en_d1),
4348
        .clk    (clk),
4349
        .se     (se),       .si (),          .so ()
4350
        );
4351
 
4352
assign  lsu_ifu_asi_thrid[1:0] = lsu_tlu_tlb_access_tid_m[1:0] ;
4353
 
4354
 
4355
//=========================================================================================
4356
//  MEMBAR/FLUSH HANDLING
4357
//=========================================================================================
4358
 
4359
// Check for skids in this area - verification.
4360
 
4361
wire [3:0] no_spc_rmo_st ;
4362
 
4363
// Can membar/flush cause switch out from front end ??? Need to remove from
4364
// ldst_miss if case.
4365
// membar/flush will both swo thread and assert flush.
4366
// membar will signal completion once stb for thread empty
4367
// flush  will signal completion once flush pkt is visible at head of cfq and
4368
// i-side invalidates are complete
4369
// ** flush bit needs to be added to dfq **
4370
 
4371
dff  #(2) bsync_stgm (
4372
        .din    ({ifu_tlu_mb_inst_e,ifu_tlu_flsh_inst_e}),
4373
        .q      ({mbar_inst_m,flsh_inst_m}),
4374
        .clk    (clk),
4375
        .se     (se),       .si (),          .so ()
4376
        );
4377
 
4378
assign  lsu_flsh_inst_m = flsh_inst_m ;
4379
 
4380
wire  mbar_inst_unflushed,flsh_inst_unflushed ;
4381
 
4382
dff  #(2) bsync_stgg (
4383
        .din    ({mbar_inst_m,flsh_inst_m}),
4384
        .q      ({mbar_inst_unflushed,flsh_inst_unflushed}),
4385
        .clk    (clk),
4386
        .se     (se),       .si (),          .so ()
4387
        );
4388
 
4389
wire    [3:0]    flsh_cmplt_d1 ;
4390
/*dff  #(4) flshcmplt (
4391
        .din    (lsu_dfq_flsh_cmplt[3:0]),
4392
        .q      (flsh_cmplt_d1[3:0]),
4393
        .clk    (clk),
4394
        .se     (se),       .si (),          .so ()
4395
        );*/
4396
 
4397
// now flopped in dctl
4398
assign  flsh_cmplt_d1[3:0] = lsu_dfq_flsh_cmplt[3:0] ;
4399
 
4400
assign  mbar_inst_g = mbar_inst_unflushed & lsu_inst_vld_w ;
4401
assign  flsh_inst_g = flsh_inst_unflushed & lsu_inst_vld_w ;
4402
 
4403
// THREAD0 MEMBAR/FLUSH
4404
 
4405
// barrier sync
4406
assign bsync0_reset =
4407
        reset  | (mbar_vld0 & lsu_stb_empty[0] & no_spc_rmo_st[0])
4408
               | (flsh_vld0 & flsh_cmplt_d1[0]) ;
4409
 
4410
assign  bsync0_en = (flush_inst0_g | mbar_inst0_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
4411
 
4412
assign  flush_inst0_g = flsh_inst_g & thread0_g ;
4413
assign  mbar_inst0_g  = mbar_inst_g & thread0_g ;
4414
 
4415
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
4416
// thread's stb
4417
dffre #(2)  bsync_vld0 (
4418
        .din    ({mbar_inst0_g,flush_inst0_g}),
4419
        .q      ({mbar_vld0,flsh_vld0}),
4420
        .rst    (bsync0_reset),        .en     (bsync0_en),
4421
        .clk    (clk),
4422
        .se     (se),       .si (),          .so ()
4423
        );
4424
 
4425
// THREAD1 MEMBAR/FLUSH
4426
 
4427
// barrier sync
4428
assign bsync1_reset =
4429
        reset  | (mbar_vld1 & lsu_stb_empty[1] & no_spc_rmo_st[1])
4430
               | (flsh_vld1 & flsh_cmplt_d1[1]) ;
4431
 
4432
assign  bsync1_en = (flush_inst1_g | mbar_inst1_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
4433
 
4434
assign  flush_inst1_g = flsh_inst_g & thread1_g ;
4435
assign  mbar_inst1_g  = mbar_inst_g & thread1_g ;
4436
 
4437
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
4438
// thread's stb
4439
dffre #(2)  bsync_vld1 (
4440
        .din    ({mbar_inst1_g,flush_inst1_g}),
4441
        .q      ({mbar_vld1,flsh_vld1}),
4442
        .rst    (bsync1_reset),        .en     (bsync1_en),
4443
        .clk    (clk),
4444
        .se     (se),       .si (),          .so ()
4445
        );
4446
 
4447
// THREAD2 MEMBAR/FLUSH
4448
 
4449
// barrier sync
4450
assign bsync2_reset =
4451
        reset  | (mbar_vld2 & lsu_stb_empty[2] & no_spc_rmo_st[2])
4452
               | (flsh_vld2 & flsh_cmplt_d1[2]) ;
4453
 
4454
assign  bsync2_en = (flush_inst2_g | mbar_inst2_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
4455
 
4456
assign  flush_inst2_g = flsh_inst_g & thread2_g ;
4457
assign  mbar_inst2_g  = mbar_inst_g & thread2_g ;
4458
 
4459
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
4460
// thread's stb
4461
dffre #(2)  bsync_vld2 (
4462
        .din    ({mbar_inst2_g,flush_inst2_g}),
4463
        .q      ({mbar_vld2,flsh_vld2}),
4464
        .rst    (bsync2_reset),        .en     (bsync2_en),
4465
        .clk    (clk),
4466
        .se     (se),       .si (),          .so ()
4467
        );
4468
 
4469
// THREAD3 MEMBAR/FLUSH
4470
 
4471
// barrier sync
4472
assign bsync3_reset =
4473
        reset  | (mbar_vld3 & lsu_stb_empty[3] & no_spc_rmo_st[3])
4474
               | (flsh_vld3 & flsh_cmplt_d1[3]) ;
4475
 
4476
assign  bsync3_en = (flush_inst3_g | mbar_inst3_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
4477
 
4478
assign  flush_inst3_g = flsh_inst_g & thread3_g ;
4479
assign  mbar_inst3_g  = mbar_inst_g & thread3_g ;
4480
 
4481
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
4482
// thread's stb
4483
dffre #(2)  bsync_vld3 (
4484
        .din    ({mbar_inst3_g,flush_inst3_g}),
4485
        .q      ({mbar_vld3,flsh_vld3}),
4486
        .rst    (bsync3_reset),        .en     (bsync3_en),
4487
        .clk    (clk),
4488
        .se     (se),       .si (),          .so ()
4489
        );
4490
 
4491
//=========================================================================================
4492
//  RMO Store Ack Count
4493
//=========================================================================================
4494
 
4495
// Each thread maintains an 8b outstanding rmo ack count. To avoid overflow,
4496
// it is the responsiblity of software to insert a membar after at most 256 rmo stores.
4497
// 03/08/2003 now change from 256 to 16
4498
// 8 outstanding instead of 16   
4499
 
4500
wire    [3:0]    ackcnt0,ackcnt1,ackcnt2,ackcnt3 ;
4501
wire    [3:0]    ackcnt0_din,ackcnt1_din,ackcnt2_din,ackcnt3_din ;
4502
 
4503
// st_rmo_issue/st_rmo_ack vectors are one hot.
4504
// Adders(2). Need two as two separate threads can be incremented and decremented
4505
// in a cycle.
4506
wire    [3:0]    ackcnt_incr, ackcnt_decr ;
4507
wire    [3:0]    ackcnt_mx_incr, ackcnt_mx_decr ;
4508
 
4509
   wire [3:0] acknt_mx_incr_sel;
4510
   assign     acknt_mx_incr_sel[3:0] = lsu_stb_rmo_st_issue[3:0];
4511
 
4512
assign ackcnt_mx_incr[3:0] =
4513
  (acknt_mx_incr_sel[0] ? ackcnt0[3:0] :  4'b0) |
4514
  (acknt_mx_incr_sel[1] ? ackcnt1[3:0] :  4'b0) |
4515
  (acknt_mx_incr_sel[2] ? ackcnt2[3:0] :  4'b0) |
4516
  (acknt_mx_incr_sel[3] ? ackcnt3[3:0] :  4'b0) ;
4517
 
4518
 
4519
   wire [3:0] acknt_mx_decr_sel;
4520
   assign     acknt_mx_decr_sel[3:0] = lsu_cpx_rmo_st_ack[3:0];
4521
 
4522
assign ackcnt_mx_decr[3:0] =
4523
  (acknt_mx_decr_sel[0] ? ackcnt0[3:0] : 4'b0 ) |
4524
  (acknt_mx_decr_sel[1] ? ackcnt1[3:0] : 4'b0 ) |
4525
  (acknt_mx_decr_sel[2] ? ackcnt2[3:0] : 4'b0 ) |
4526
  (acknt_mx_decr_sel[3] ? ackcnt3[3:0] : 4'b0 ) ;
4527
 
4528
 
4529
assign  ackcnt_incr[3:0] = ackcnt_mx_incr[3:0] + 4'b0001 ;
4530
assign  ackcnt_decr[3:0] = ackcnt_mx_decr[3:0] - 4'b0001 ;
4531
 
4532
assign  ackcnt0_din[3:0] = lsu_cpx_rmo_st_ack[0] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
4533
assign  ackcnt1_din[3:0] = lsu_cpx_rmo_st_ack[1] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
4534
assign  ackcnt2_din[3:0] = lsu_cpx_rmo_st_ack[2] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
4535
assign  ackcnt3_din[3:0] = lsu_cpx_rmo_st_ack[3] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
4536
 
4537
wire    [3:0]    ackcnt_en ;
4538
// if both occur in the same cycle then they cancel out.
4539
assign  ackcnt_en[0] = lsu_stb_rmo_st_issue[0] ^ lsu_cpx_rmo_st_ack[0] ;
4540
assign  ackcnt_en[1] = lsu_stb_rmo_st_issue[1] ^ lsu_cpx_rmo_st_ack[1] ;
4541
assign  ackcnt_en[2] = lsu_stb_rmo_st_issue[2] ^ lsu_cpx_rmo_st_ack[2] ;
4542
assign  ackcnt_en[3] = lsu_stb_rmo_st_issue[3] ^ lsu_cpx_rmo_st_ack[3] ;
4543
 
4544
// Thread0
4545
dffre #(4)  ackcnt0_ff (
4546
        .din    (ackcnt0_din[3:0]),
4547
        .q      (ackcnt0[3:0]),
4548
        .rst    (reset),        .en     (ackcnt_en[0]),
4549
        .clk    (clk),
4550
        .se     (se),       .si (),          .so ()
4551
        );
4552
 
4553
// Thread1
4554
dffre #(4)  ackcnt1_ff (
4555
        .din    (ackcnt1_din[3:0]),
4556
        .q      (ackcnt1[3:0]),
4557
        .rst    (reset),        .en     (ackcnt_en[1]),
4558
        .clk    (clk),
4559
        .se     (se),       .si (),          .so ()
4560
        );
4561
 
4562
// Thread2
4563
dffre #(4)  ackcnt2_ff (
4564
        .din    (ackcnt2_din[3:0]),
4565
        .q      (ackcnt2[3:0]),
4566
        .rst    (reset),        .en     (ackcnt_en[2]),
4567
        .clk    (clk),
4568
        .se     (se),       .si (),          .so ()
4569
        );
4570
 
4571
// Thread3
4572
dffre #(4)  ackcnt3_ff (
4573
        .din    (ackcnt3_din[3:0]),
4574
        .q      (ackcnt3[3:0]),
4575
        .rst    (reset),        .en     (ackcnt_en[3]),
4576
        .clk    (clk),
4577
        .se     (se),       .si (),          .so ()
4578
        );
4579
 
4580
assign  no_spc_rmo_st[0] = ~(|ackcnt0[3:0]) ;
4581
assign  no_spc_rmo_st[1] = ~(|ackcnt1[3:0]) ;
4582
assign  no_spc_rmo_st[2] = ~(|ackcnt2[3:0]) ;
4583
assign  no_spc_rmo_st[3] = ~(|ackcnt3[3:0]) ;
4584
 
4585
//8 outstanding rmo st will throttle the PCX issue st   
4586
assign lsu_outstanding_rmo_st_max [0] = ackcnt0[3];
4587
assign lsu_outstanding_rmo_st_max [1] = ackcnt1[3];
4588
assign lsu_outstanding_rmo_st_max [2] = ackcnt2[3];
4589
assign lsu_outstanding_rmo_st_max [3] = ackcnt3[3];
4590
 
4591
// streaming unit does not have to care about outstanding rmo sparc-stores.
4592
// membar will take care of that. spu must insert appr. delay in sampling signal.
4593
 
4594
/*dff #(4)  spustb_d1 ( // moved to stb_rwctl
4595
        .din    (lsu_stb_empty[3:0]),
4596
        .q      (lsu_spu_stb_empty[3:0]),
4597
        .clk    (clk),
4598
        .se     (se),       .si (),          .so ()
4599
        ); */
4600
 
4601
//assign                lsu_spu_stb_empty[3:0] = lsu_stb_empty[3:0] ;
4602
 
4603
//=========================================================================================
4604
//  Thread Staging
4605
//=========================================================================================
4606
 
4607
// Thread staging can be optimized. 
4608
 
4609
dff  #(2) thrid_stgd (
4610
        .din    (ifu_lsu_thrid_s[1:0]),
4611
        .q      (thrid_d[1:0]),
4612
        .clk    (clk),
4613
        .se     (se),       .si (),          .so ()
4614
        );
4615
 
4616
dff  #(2) lsu_tlu_thrid_stgd (
4617
        .din    (ifu_lsu_thrid_s[1:0]),
4618
        .q      (lsu_tlu_thrid_d[1:0]),
4619
        .clk    (clk),
4620
        .se     (se),       .si (),          .so ()
4621
        );
4622
 
4623
//assign        lsu_tlu_thrid_d[1:0] = thrid_d[1:0] ;
4624
 
4625
assign  thread0_d = ~thrid_d[1] & ~thrid_d[0] ;
4626
assign  thread1_d = ~thrid_d[1] &  thrid_d[0] ;
4627
assign  thread2_d =  thrid_d[1] & ~thrid_d[0] ;
4628
assign  thread3_d =  thrid_d[1] &  thrid_d[0] ;
4629
 
4630
dff  #(2) thrid_stge (
4631
        .din    (thrid_d[1:0]),
4632
        .q      (thrid_e[1:0]),
4633
        .clk    (clk),
4634
        .se     (se),       .si (),          .so ()
4635
        );
4636
 
4637
assign  thread0_e = ~thrid_e[1] & ~thrid_e[0] ;
4638
assign  thread1_e = ~thrid_e[1] &  thrid_e[0] ;
4639
assign  thread2_e =  thrid_e[1] & ~thrid_e[0] ;
4640
assign  thread3_e =  thrid_e[1] &  thrid_e[0] ;
4641
 
4642
dff  #(2) thrid_stgm (
4643
        .din    (thrid_e[1:0]),
4644
        .q      (thrid_m[1:0]),
4645
        .clk    (clk),
4646
        .se     (se),       .si (),          .so ()
4647
        );
4648
 
4649
assign  thread0_m = ~thrid_m[1] & ~thrid_m[0] ;
4650
assign  thread1_m = ~thrid_m[1] &  thrid_m[0] ;
4651
assign  thread2_m =  thrid_m[1] & ~thrid_m[0] ;
4652
assign  thread3_m =  thrid_m[1] &  thrid_m[0] ;
4653
 
4654
bw_u1_buf_30x UZfix_thread0_m  ( .a(thread0_m),  .z(lsu_dctldp_thread0_m)  );
4655
bw_u1_buf_30x UZfix_thread1_m  ( .a(thread1_m),  .z(lsu_dctldp_thread1_m)  );
4656
bw_u1_buf_30x UZfix_thread2_m  ( .a(thread2_m),  .z(lsu_dctldp_thread2_m)  );
4657
bw_u1_buf_30x UZfix_thread3_m  ( .a(thread3_m),  .z(lsu_dctldp_thread3_m)  );
4658
 
4659
dff  #(2) thrid_stgg (
4660
        .din    (thrid_m[1:0]),
4661
        .q      (thrid_g[1:0]),
4662
        .clk    (clk),
4663
        .se     (se),       .si (),          .so ()
4664
        );
4665
 
4666
assign  thread0_g = ~thrid_g[1] & ~thrid_g[0] ;
4667
assign  thread1_g = ~thrid_g[1] &  thrid_g[0] ;
4668
assign  thread2_g =  thrid_g[1] & ~thrid_g[0] ;
4669
assign  thread3_g =  thrid_g[1] &  thrid_g[0] ;
4670
 
4671
dff  #(2) thrid_stgw2 (
4672
        .din    (thrid_g[1:0]),
4673
        .q      (thrid_w2[1:0]),
4674
        .clk    (clk),
4675
        .se     (se),       .si (),          .so ()
4676
        );
4677
 
4678
assign  thread0_w2 = ~thrid_w2[1] & ~thrid_w2[0] ;
4679
assign  thread1_w2 = ~thrid_w2[1] &  thrid_w2[0] ;
4680
assign  thread2_w2 =  thrid_w2[1] & ~thrid_w2[0] ;
4681
assign  thread3_w2 =  thrid_w2[1] &  thrid_w2[0] ;
4682
 
4683
dff  #(2) thrid_stgw3 (
4684
        .din    (thrid_w2[1:0]),
4685
        .q      (thrid_w3[1:0]),
4686
        .clk    (clk),
4687
        .se     (se),       .si (),          .so ()
4688
        );
4689
 
4690
assign  thread0_w3 = ~thrid_w3[1] & ~thrid_w3[0] ;
4691
assign  thread1_w3 = ~thrid_w3[1] &  thrid_w3[0] ;
4692
assign  thread2_w3 =  thrid_w3[1] & ~thrid_w3[0] ;
4693
assign  thread3_w3 =  thrid_w3[1] &  thrid_w3[0] ;
4694
 
4695
//dff  #(4) thrid_stgw3 (
4696
//        .din    ({thread0_w2,thread1_w2,thread2_w2,thread3_w2}),
4697
//        .q      ({thread0_w3,thread1_w3,thread2_w3,thread3_w3}),
4698
//        .clk    (clk),
4699
//        .se     (se),       .si (),          .so ()
4700
//        );
4701
 
4702
// ldxa thread id
4703
 
4704
assign  ldxa_thrid_w2[1:0] = tlu_lsu_ldxa_tid_w2[1:0] ;
4705
 
4706
assign  tlu_ldxa_thread0_w2 = ~ldxa_thrid_w2[1] & ~ldxa_thrid_w2[0] ;
4707
assign  tlu_ldxa_thread1_w2 = ~ldxa_thrid_w2[1] &  ldxa_thrid_w2[0] ;
4708
assign  tlu_ldxa_thread2_w2 =  ldxa_thrid_w2[1] & ~ldxa_thrid_w2[0] ;
4709
assign  tlu_ldxa_thread3_w2 =  ldxa_thrid_w2[1] &  ldxa_thrid_w2[0] ;
4710
 
4711
assign  spu_stxa_thread0 = ~spu_lsu_stxa_ack_tid[1] & ~spu_lsu_stxa_ack_tid[0] ;
4712
assign  spu_stxa_thread1 = ~spu_lsu_stxa_ack_tid[1] &  spu_lsu_stxa_ack_tid[0] ;
4713
assign  spu_stxa_thread2 =  spu_lsu_stxa_ack_tid[1] & ~spu_lsu_stxa_ack_tid[0] ;
4714
assign  spu_stxa_thread3 =  spu_lsu_stxa_ack_tid[1] &  spu_lsu_stxa_ack_tid[0] ;
4715
 
4716
assign  spu_ldxa_thread0_w2 = ~spu_lsu_ldxa_tid_w2[1] & ~spu_lsu_ldxa_tid_w2[0] ;
4717
assign  spu_ldxa_thread1_w2 = ~spu_lsu_ldxa_tid_w2[1] &  spu_lsu_ldxa_tid_w2[0] ;
4718
assign  spu_ldxa_thread2_w2 =  spu_lsu_ldxa_tid_w2[1] & ~spu_lsu_ldxa_tid_w2[0] ;
4719
assign  spu_ldxa_thread3_w2 =  spu_lsu_ldxa_tid_w2[1] &  spu_lsu_ldxa_tid_w2[0] ;
4720
 
4721
assign  ifu_ldxa_thread0_w2 = ~ifu_lsu_ldxa_tid_w2[1] & ~ifu_lsu_ldxa_tid_w2[0] ;
4722
assign  ifu_ldxa_thread1_w2 = ~ifu_lsu_ldxa_tid_w2[1] &  ifu_lsu_ldxa_tid_w2[0] ;
4723
assign  ifu_ldxa_thread2_w2 =  ifu_lsu_ldxa_tid_w2[1] & ~ifu_lsu_ldxa_tid_w2[0] ;
4724
assign  ifu_ldxa_thread3_w2 =  ifu_lsu_ldxa_tid_w2[1] &  ifu_lsu_ldxa_tid_w2[0] ;
4725
 
4726
wire    [1:0]    ifu_nontlb_asi_tid ;
4727
dff  #(2) iasi_tid (
4728
        .din    (lsu_ifu_asi_thrid[1:0]),
4729
        .q      (ifu_nontlb_asi_tid[1:0]),
4730
        .clk    (clk),
4731
        .se     (se),       .si (),          .so ()
4732
        );
4733
 
4734
assign  ifu_stxa_thread0_w2 = ~ifu_nontlb_asi_tid[1] & ~ifu_nontlb_asi_tid[0] ;
4735
assign  ifu_stxa_thread1_w2 = ~ifu_nontlb_asi_tid[1] &  ifu_nontlb_asi_tid[0] ;
4736
assign  ifu_stxa_thread2_w2 =  ifu_nontlb_asi_tid[1] & ~ifu_nontlb_asi_tid[0] ;
4737
assign  ifu_stxa_thread3_w2 =  ifu_nontlb_asi_tid[1] &  ifu_nontlb_asi_tid[0] ;
4738
 
4739
assign  tlu_stxa_thread0_w2 = ~tlu_lsu_stxa_ack_tid[1] & ~tlu_lsu_stxa_ack_tid[0] ;
4740
assign  tlu_stxa_thread1_w2 = ~tlu_lsu_stxa_ack_tid[1] &  tlu_lsu_stxa_ack_tid[0] ;
4741
assign  tlu_stxa_thread2_w2 =  tlu_lsu_stxa_ack_tid[1] & ~tlu_lsu_stxa_ack_tid[0] ;
4742
assign  tlu_stxa_thread3_w2 =  tlu_lsu_stxa_ack_tid[1] &  tlu_lsu_stxa_ack_tid[0] ;
4743
 
4744
//=========================================================================================
4745
//  Exception Handling
4746
//=========================================================================================
4747
 
4748
 
4749
// tlb related exceptions/errors
4750
//SC assign  tlb_daccess_excptn_e  =
4751
//SC  ((rd_only_ltlb_asi_e &  st_inst_vld_e)  |
4752
//SC   (wr_only_ltlb_asi_e &  ld_inst_vld_e)) & alt_space_e   ;
4753
 
4754
//SC assign  tlb_daccess_error_e =
4755
//SC   ((dfill_tlb_asi_e & ~lsu_tlb_writeable)     | 
4756
//SC   (ifill_tlb_asi_e & ~ifu_lsu_tlb_writeable)) & st_inst_vld_e & alt_space_e ; 
4757
 
4758
//SC dff  #(2) tlbex_stgm (
4759
//SC         .din    ({tlb_daccess_excptn_e,tlb_daccess_error_e}),
4760
//SC         .q      ({tlb_daccess_excptn_m,tlb_daccess_error_m}),
4761
//SC         .clk    (clk),
4762
//SC         .se     (se),       .si (),          .so ()
4763
//SC         );
4764
 
4765
//SC dff  #(2) tlbex_stgg (
4766
//SC         .din    ({tlb_daccess_excptn_m,tlb_daccess_error_m}),
4767
//SC         .q      ({tlb_daccess_excptn_g,tlb_daccess_error_g}),
4768
//SC         .clk    (clk),
4769
//SC         .se     (se),       .si (),          .so ()
4770
//SC         );
4771
 
4772
//assign  pstate_priv_m = 
4773
//  thread0_m ? tlu_lsu_pstate_priv[0] :
4774
//    thread1_m ? tlu_lsu_pstate_priv[1] :
4775
//      thread2_m ? tlu_lsu_pstate_priv[2] :
4776
//          tlu_lsu_pstate_priv[3] ;
4777
 
4778
//SC mux4ds  #(1) pstate_priv_m_mux (
4779
//SC         .in0    (tlu_lsu_pstate_priv[0]),
4780
//SC         .in1    (tlu_lsu_pstate_priv[1]),
4781
//SC         .in2    (tlu_lsu_pstate_priv[2]),
4782
//SC         .in3    (tlu_lsu_pstate_priv[3]),
4783
//SC         .sel0   (thread0_m),  
4784
//SC         .sel1   (thread1_m),
4785
//SC         .sel2   (thread2_m),  
4786
//SC         .sel3   (thread3_m),
4787
//SC         .dout   (pstate_priv_m)
4788
//SC );
4789
 
4790
//SC dff  priv_stgg (
4791
//SC         .din    (pstate_priv_m),
4792
//SC         .q      (pstate_priv),
4793
//SC         .clk    (clk),
4794
//SC         .se     (se),       .si (),          .so ()
4795
//SC         );
4796
 
4797
// privilege violation - priv page accessed in user mode
4798
//SC assign  priv_pg_usr_mode =  // data access exception; TT=h30
4799
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~(pstate_priv | hpv_priv) & tlb_rd_tte_data[`STLB_DATA_P] ;
4800
 
4801
// protection violation - store to a page that does not have write permission
4802
//SC assign  nonwr_pg_st_access =  // data access protection; TT=h33
4803
//SC   st_inst_vld_unflushed   & 
4804
//SC   ~tlb_rd_tte_data[`STLB_DATA_W] & ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
4805
   //lsu_dtlb_bypass_g) ; // W=1 in bypass mode - In bypass mode this trap will never happen !!!
4806
 
4807
//SC wire  daccess_prot ;
4808
//SC assign  daccess_prot = nonwr_pg_st_access  ;
4809
    //((~lsu_dtlb_bypass_g & tlb_cam_hit_g) | (tlb_byp_asi_g & lsu_alt_space_g)) ;
4810
 
4811
// access to a page marked with the nfo with an asi other than nfo asi.
4812
//SC assign  nfo_pg_nonnfo_asi  =  // data access exception; TT=h30
4813
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) &   // any access
4814
//SC   ((~nofault_asi_g & lsu_alt_space_g) | ~lsu_alt_space_g) // in alternate space or not
4815
//SC   & tlb_rd_tte_data[`STLB_DATA_NFO] ;
4816
 
4817
// as_if_usr asi accesses priv page.
4818
//SC assign  as_if_usr_priv_pg  =  // data access exception; TT=h30
4819
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & as_if_user_asi_g & lsu_alt_space_g & 
4820
//SC       tlb_rd_tte_data[`STLB_DATA_P] ;
4821
 
4822
 
4823
// non-cacheable address - iospace or cp=0 (???)
4824
// atomic access to non-cacheable space.
4825
//SC assign  atm_access_w_nc = atomic_g & tlb_pgnum[39] ; // io space 
4826
 
4827
// atomic inst with unsupported asi.
4828
//SC assign  atm_access_unsup_asi = atomic_g & ~atomic_asi_g & lsu_alt_space_g ;
4829
 
4830
//SC wire  tlb_tte_vld_g ;
4831
//SC assign  tlb_tte_vld_g = ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
4832
 
4833
//SC wire  pg_with_ebit ;
4834
//SC assign     pg_with_ebit = 
4835
//SC    (tlb_rd_tte_data[`STLB_DATA_E] & tlb_tte_vld_g)  | // tte
4836
//SC         (lsu_dtlb_bypass_g & ~(phy_use_ec_asi_g & lsu_alt_space_g)) | // regular bypass 
4837
//SC         (tlb_byp_asi_g & ~phy_use_ec_asi_g & lsu_alt_space_g) ; // phy_byp
4838
 
4839
//SC wire  spec_access_epage ;
4840
//SC assign  spec_access_epage = 
4841
//SC   ((ld_inst_vld_unflushed & nofault_asi_g & lsu_alt_space_g) |  // spec load
4842
//SC   flsh_inst_g) & // flush inst
4843
//SC   pg_with_ebit ; // page with side effects
4844
//  tlb_rd_tte_data[`STLB_DATA_E] ; // page with side effects
4845
 
4846
//SC wire  quad_asi_non_ldstda ;
4847
// quad-asi used with non ldda/stda
4848
// remove st_inst_vld - stquad unused
4849
// the equation may be incorrect - needs to be for a non-ldda
4850
//SC assign  quad_asi_non_ldstda = quad_asi_g & lsu_alt_space_g & ~ldst_dbl_g & 
4851
//SC      (ld_inst_vld_unflushed | st_inst_vld_unflushed) ;
4852
// need to put in similar exception for binit st
4853
//SC wire  binit_asi_non_ldda ;
4854
//SC assign  binit_asi_non_ldda = binit_quad_asi_g & lsu_alt_space_g & ~ldst_dbl_g & 
4855
//SC      (ld_inst_vld_unflushed) ;
4856
//SC wire  blk_asi_non_ldstdfa ;
4857
//SC assign  blk_asi_non_ldstdfa = blk_asi_g & lsu_alt_space_g & 
4858
//SC      ~(ldst_dbl_g & fp_ldst_g) & (ld_inst_vld_unflushed | st_inst_vld_unflushed) ;
4859
 
4860
// trap on illegal asi
4861
//SC wire  illegal_asi_trap_g ;
4862
//SC assign  illegal_asi_trap_g = 
4863
//SC (ld_inst_vld_unflushed | st_inst_vld_unflushed) &
4864
//SC lsu_alt_space_g & ~recognized_asi_g & lsu_inst_vld_w ;
4865
 
4866
// This can be pushed back into previous cycle.
4867
//SC wire wr_to_strm_sync ;
4868
//SC assign     wr_to_strm_sync =       
4869
//SC   strm_asi & ((ldst_va_g[7:0] == 8'hA0) | (ldst_va_g[7:0] == 8'h68)) &
4870
//SC   st_inst_vld_unflushed & lsu_alt_space_g ;
4871
 
4872
// This should not be double-anded with tlb_tte_vld_g. Check !!!
4873
//SC assign  daccess_excptn =  
4874
//SC     ((priv_pg_usr_mode | as_if_usr_priv_pg | nfo_pg_nonnfo_asi | 
4875
//SC     atm_access_w_nc | atm_access_unsup_asi)) 
4876
//SC       & tlb_tte_vld_g | 
4877
//SC     spec_access_epage |
4878
//SC     asi_related_trap_g | quad_asi_non_ldstda | tlb_daccess_excptn_g |
4879
//SC     illegal_asi_trap_g | spv_use_hpv | binit_asi_non_ldda | wr_to_strm_sync | 
4880
//SC    blk_asi_non_ldstdfa ;
4881
 
4882
// HPV Changes 
4883
// Push back into previous stage.
4884
// qualification with hpv_priv and hpstate_en required to ensure hypervisor
4885
// is not trying to access.
4886
 
4887
//assign  hpv_priv_e = 
4888
//  thread0_e ? tlu_lsu_hpv_priv[0] :
4889
//    thread1_e ? tlu_lsu_hpv_priv[1] :
4890
//      thread2_e ? tlu_lsu_hpv_priv[2] :
4891
//                      tlu_lsu_hpv_priv[3] ;
4892
 
4893
// Timing change :
4894
 
4895
wire [3:0] hpv_priv_d1 ;
4896
wire [3:0] hpstate_en_d1 ;
4897
 
4898
dff #(8) hpv_stgd1 (
4899
        .din    ({tlu_lsu_hpv_priv[3:0],tlu_lsu_hpstate_en[3:0]}),
4900
        .q      ({hpv_priv_d1[3:0],hpstate_en_d1[3:0]}),
4901
        .clk    (clk),
4902
        .se     (se),       .si (),          .so ()
4903
        );
4904
 
4905
mux4ds  #(1) hpv_priv_e_mux (
4906
        .in0    (hpv_priv_d1[0]),
4907
        .in1    (hpv_priv_d1[1]),
4908
        .in2    (hpv_priv_d1[2]),
4909
        .in3    (hpv_priv_d1[3]),
4910
        .sel0   (thread0_e),
4911
        .sel1   (thread1_e),
4912
        .sel2   (thread2_e),
4913
        .sel3   (thread3_e),
4914
        .dout   (hpv_priv_e)
4915
);
4916
 
4917
//assign  hpstate_en_e = 
4918
//  thread0_e ? tlu_lsu_hpstate_en[0] :
4919
//    thread1_e ? tlu_lsu_hpstate_en[1] :
4920
//      thread2_e ? tlu_lsu_hpstate_en[2] :
4921
//                      tlu_lsu_hpstate_en[3] ;
4922
 
4923
mux4ds  #(1) hpstate_en_e_mux (
4924
        .in0    (hpstate_en_d1[0]),
4925
        .in1    (hpstate_en_d1[1]),
4926
        .in2    (hpstate_en_d1[2]),
4927
        .in3    (hpstate_en_d1[3]),
4928
        .sel0   (thread0_e),
4929
        .sel1   (thread1_e),
4930
        .sel2   (thread2_e),
4931
        .sel3   (thread3_e),
4932
        .dout   (hpstate_en_e)
4933
);
4934
 
4935
dff #(2) hpv_stgm (
4936
        .din    ({hpv_priv_e, hpstate_en_e}),
4937
        .q      ({hpv_priv_m, hpstate_en_m}),
4938
        .clk    (clk),
4939
        .se     (se),       .si (),          .so ()
4940
        );
4941
 
4942
//dff #(2) hpv_stgg (
4943
//        .din    ({hpv_priv_m, hpstate_en_m}),
4944
//        .q            ({hpv_priv,   hpstate_en}),
4945
//        .clk    (clk),
4946
//        .se     (se),       .si (),          .so ()
4947
//        );
4948
 
4949
/*assign  priv_action = (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~lsu_asi_state[7] &
4950
      ~pstate_priv & ~(hpv_priv & hpstate_en) & lsu_alt_space_g ;*/
4951
// Generate a stage earlier
4952
//SC assign  priv_action_m = (ld_inst_vld_m | st_inst_vld_m) & ~lsu_dctl_asi_state_m[7] & 
4953
//SC       ~pstate_priv_m & ~(hpv_priv_m & hpstate_en_m) & lsu_alt_space_m ;
4954
 
4955
//SC dff  pact_stgg (
4956
//SC         .din    (priv_action_m),
4957
//SC         .q         (priv_action),
4958
//SC         .clk    (clk),
4959
//SC         .se     (se),       .si (),          .so ()
4960
//SC         );
4961
 
4962
// Take data_access exception if supervisor uses hypervisor asi
4963
//SC wire    hpv_asi_range ;
4964
//SC assign  hpv_asi_range =
4965
//SC                     ~lsu_asi_state[7] & (
4966
//SC                          (~lsu_asi_state[6] & lsu_asi_state[5] & lsu_asi_state[4]) | // 0x3?
4967
//SC                          ( lsu_asi_state[6]));                                   // 0x4?,5?,6?,7?
4968
 
4969
// Take data_access exception if supervisor uses hypervisor asi
4970
//SC `ifdef  SPARC_HPV_EN
4971
//SC assign  spv_use_hpv = (ld_inst_vld_unflushed | st_inst_vld_unflushed) &
4972
//SC                          hpv_asi_range &
4973
//SC                          //~lsu_asi_state[7] & lsu_asi_state[6] & lsu_asi_state[5] & // 0x30-0x7f
4974
//SC                          pstate_priv & ~hpv_priv & lsu_alt_space_g ;
4975
//SC `else
4976
//SC assign  spv_use_hpv = 1'b0 ;
4977
//SC `endif
4978
 
4979
 
4980
// EARLY TRAPS
4981
 
4982
// memory address not aligned
4983
//SC wire  qw_align_addr,blk_align_addr ;
4984
//SC assign  hw_align_addr = ~ldst_va_m[0] ;         // half-word addr
4985
//SC assign  wd_align_addr = ~ldst_va_m[1] & ~ldst_va_m[0] ;     // word addr
4986
//SC assign  dw_align_addr = ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // dw addr
4987
//SC assign  qw_align_addr = ~ldst_va_m[3] & ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // qw addr
4988
//SC assign  blk_align_addr = 
4989
//SC ~ldst_va_m[5] & ~ldst_va_m[4] & ~ldst_va_m[3] & 
4990
//SC ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // 64B aligned addr for block ld/st
4991
 
4992
//assign  byte_size = ~ldst_sz_m[1] &  ~ldst_sz_m[0] ; // byte size    
4993
//assign  hw_size = ~ldst_sz_m[1] &  ldst_sz_m[0] ; // half-word size 
4994
//assign  wd_size =  ldst_sz_m[1] & ~ldst_sz_m[0] ; // word size
4995
//assign  dw_size =  ldst_sz_m[1] &  ldst_sz_m[0] ; // double-word size
4996
 
4997
//assign  byte_size = byte_m;
4998
assign  hw_size = hword_m;
4999
assign  wd_size = word_m;
5000
assign  dw_size = dword_m;
5001
 
5002
//SC assign  mem_addr_not_align
5003
//SC   = ((hw_size & ~hw_align_addr) | // half-word check
5004
//SC     (wd_size & ~wd_align_addr)  | // word check
5005
//SC     (dw_size & ~dw_align_addr)  | // double word check
5006
//SC    ((quad_asi_m | binit_quad_asi_m) & lsu_alt_space_m & ldst_dbl_m & ~qw_align_addr) | // quad word check
5007
//SC     (blk_asi_m & lsu_alt_space_m & fp_ldst_m & ldst_dbl_m & ~blk_align_addr)) & // 64B blk ld/st check
5008
//SC     //(blk_asi_m & lsu_alt_space_m & blk_asi_m & ~blk_align_addr)) & // 64B blk ld/st check
5009
//SC     (ld_inst_vld_m | st_inst_vld_m) ;
5010
 
5011
//SC assign  stdf_maddr_not_align
5012
//SC     = st_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr ;
5013
 
5014
//SC assign  lddf_maddr_not_align
5015
//SC     = ld_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr ;
5016
 
5017
// internal asi access by ld/st other than ldxa/stxa/lddfa/stdfa.
5018
// qual with ldst_dbl_m needed. lda and stda should take trap if accessing internal asi.
5019
//SC assign  asi_internal_non_xdw 
5020
//SC     = (st_inst_vld_m | ld_inst_vld_m) & lsu_alt_space_m & asi_internal_m  & ~(dw_size & ~ldst_dbl_m) ;
5021
 
5022
 
5023
// asi related
5024
// rd-only mmu asi requiring va decode.
5025
//SC wire       mmu_rd_only_asi_wva_m ;
5026
//SC assign     mmu_rd_only_asi_wva_m =
5027
//SC    ((lsu_dctl_asi_state_m[7:0]==8'h58) & (
5028
//SC            (ldst_va_m[8:0] == 9'h000) |    // dtag_target
5029
//SC            (ldst_va_m[8:0] == 9'h020))) |  // dsync_far
5030
//SC    ((lsu_dctl_asi_state_m[7:0]==8'h50) & 
5031
//SC            (ldst_va_m[8:0] == 9'h000)) ;   // itag_target
5032
 
5033
//SC assign  wr_to_rd_only_asi = 
5034
//SC    (mmu_rd_only_asi_wva_m |// mmu with non-unique asi
5035
//SC    mmu_rd_only_asi_m |     // mmu with unique asi
5036
//SC    rd_only_asi_m)          // non mmu
5037
//SC     &  st_inst_vld_m & lsu_alt_space_m ;
5038
 
5039
//SC assign  rd_of_wr_only_asi = wr_only_asi_m &  ld_inst_vld_m & lsu_alt_space_m ;
5040
//SC assign  unimp_asi_used = unimp_asi_m &  (ld_inst_vld_m | st_inst_vld_m) & lsu_alt_space_m ;
5041
//assign  asi_related_trap_m = wr_to_rd_only_asi | rd_of_wr_only_asi | unimp_asi_used | asi_internal_non_xdw ;
5042
 
5043
//SC assign  early_trap_vld_m =  stdf_maddr_not_align | lddf_maddr_not_align | mem_addr_not_align ;
5044
 
5045
//SC assign  lsu_tlu_misalign_addr_ldst_atm_m = early_trap_vld_m ;
5046
 
5047
// mux select order must be maintained
5048
//SC assign  early_ttype_m[8:0] = 
5049
//SC       stdf_maddr_not_align ? 9'h036 :
5050
//SC         lddf_maddr_not_align ? 9'h035 : 
5051
//SC           mem_addr_not_align ? 9'h034 : 9'hxxx ;
5052
 
5053
//SC dff #(11)   etrp_stgg (
5054
//SC         .din    ({early_ttype_m[8:0],early_trap_vld_m,asi_related_trap_m}),
5055
//SC         .q      ({early_ttype_g[8:0],early_trap_vld_g,asi_related_trap_g}),
5056
//SC         .clk    (clk),
5057
//SC         .se     (se),       .si (),          .so ()
5058
//SC         );
5059
 
5060
//SC wire nceen_pipe_g ;
5061
//SC assign  nceen_pipe_g = 
5062
//SC   (thread0_g & ifu_lsu_nceen[0]) | (thread1_g & ifu_lsu_nceen[1]) |
5063
//SC   (thread2_g & ifu_lsu_nceen[2]) | (thread3_g & ifu_lsu_nceen[3]) ;
5064
//SC wire nceen_fill_e,nceen_fill_m,nceen_fill_g ;
5065
//SC assign  nceen_fill_e = 
5066
//SC   (dfill_thread0 & ifu_lsu_nceen[0]) | (dfill_thread1 & ifu_lsu_nceen[1]) |
5067
//SC   (dfill_thread2 & ifu_lsu_nceen[2]) | (dfill_thread3 & ifu_lsu_nceen[3]) ;
5068
 
5069
//SC dff  #(1) nce_stgm (
5070
//SC         .din    (nceen_fill_e),
5071
//SC         .q      (nceen_fill_m),
5072
//SC         .clk    (clk),
5073
//SC         .se     (se),       .si (),          .so ()
5074
//SC         );
5075
 
5076
//SC dff  #(1) nce_stgg (
5077
//SC         .din    (nceen_fill_m),
5078
//SC         .q      (nceen_fill_g),
5079
//SC         .clk    (clk),
5080
//SC         .se     (se),       .si (),          .so ()
5081
//SC         );
5082
 
5083
//SC assign  daccess_error = 1'b0 ;
5084
  // Commented out currently for timing reasons. This needs to be
5085
  // rolled into the ttype_vld sent to the tlu, but can be left out
5086
  // of the flush sent to the remaining units.
5087
  /*((tte_data_perror_unc) & nceen_pipe_g & // on xslate
5088
  ~(early_trap_vld_g | priv_action | va_wtchpt_match | dmmu_miss_g)) |
5089
  tlb_asi_unc_err_g |     // asi read
5090
  (unc_err_trap_g & nceen_fill_g) | // cache data
5091
  tlb_daccess_error_g ;     // tlb not writeable */
5092
 
5093
//SC assign  lsu_tlu_async_dacc_err_g = unc_err_trap_g | tlb_asi_unc_err_g ;
5094
 
5095
//SC assign  lsu_tlu_dmmu_miss_g = dmmu_miss_g ;
5096
 
5097
 wire  cam_real_m ;
5098
 dff   real_stgm (
5099
         .din    (lsu_dtlb_cam_real_e),
5100
         .q      (cam_real_m),
5101
         .clk    (clk),
5102
         .se     (se),       .si (),          .so ()
5103
         );
5104
 
5105
// dff   real_stgg (
5106
//         .din    (cam_real_m),
5107
//         .q      (cam_real_g),
5108
//         .clk    (clk),
5109
//         .se     (se),       .si (),          .so ()
5110
//         );
5111
 
5112
assign  lsu_tlu_nonalt_ldst_m =  (st_inst_vld_m | ld_inst_vld_m) & ~lsu_alt_space_m  ;
5113
assign  lsu_tlu_xslating_ldst_m = (st_inst_vld_m | ld_inst_vld_m) &
5114
        (((~asi_internal_m  & recognized_asi_m) & lsu_alt_space_m)  | // Bug 4327
5115
        ~lsu_alt_space_m) ;
5116
 
5117
assign  ctxt_sel_e[0] = thread_pctxt ;
5118
assign  ctxt_sel_e[1] = thread_sctxt ;
5119
assign  ctxt_sel_e[2] =
5120
        thread_nctxt |
5121
        (~(thread_pctxt | thread_sctxt) &  // default to nucleus - translating asi
5122
        ~(alt_space_e & (asi_internal_e | ~recognized_asi_e ))) ; //bug3660
5123
                                           // nontranslating asi to select 11 in CT
5124
                                           // field of dsfsr.
5125
 
5126
dff  #(3) ctxsel (
5127
        .din    (ctxt_sel_e[2:0]),
5128
        .q      (lsu_tlu_ctxt_sel_m[2:0]),
5129
        .clk    (clk),
5130
        .se     (se),       .si (),          .so ()
5131
        );
5132
 
5133
assign  lsu_tlu_nucleus_ctxt_m = lsu_tlu_ctxt_sel_m[2] ;
5134
 
5135
assign  lsu_tlu_write_op_m = st_inst_vld_m | atomic_m ;
5136
 
5137
// va_oor_m check needs to be in case of bypass, pstate.am=1, internal and illegal asi. 
5138
// pstate.am squashing is done locally in tlu.
5139
 
5140
assign  lsu_tlu_squash_va_oor_m =
5141
  dtlb_bypass_m   |     // bypass
5142
  //sta_internal_m  | lda_internal_m |  // internal asi
5143
  (asi_internal_m & lsu_alt_space_m) |  // Bug 5156
5144
  (~recognized_asi_tmp & lsu_alt_space_m) ; // illegal asi // Timing change.
5145
 
5146
   assign lsu_squash_va_oor_m =  lsu_tlu_squash_va_oor_m;
5147
 
5148
//=========================================================================================
5149
//  Generate Flush Pipe
5150
//=========================================================================================
5151
 
5152
//SC wire       other_flush_pipe_w ;
5153
// lsu_tlu_ttype_vld needs to be optimized in terms of timing.
5154
//SC assign     other_flush_pipe_w = tlu_early_flush_pipe_w | (lsu_tlu_ttype_vld_m2 & lsu_inst_vld_w);
5155
//SC assign     lsu_ifu_flush_pipe_w = other_flush_pipe_w ;
5156
//SC assign     lsu_exu_flush_pipe_w = other_flush_pipe_w ;
5157
//SC assign     lsu_ffu_flush_pipe_w = other_flush_pipe_w ;
5158
 
5159
//SC //assign   lsu_flush_pipe_w = other_flush_pipe_w | ifu_tlu_flush_w ;
5160
 
5161
//=========================================================================================
5162
//  Early Traps to SPU
5163
//=========================================================================================
5164
 
5165
// detect st to ma/strm sync - data-access exception.
5166
//SC wire       st_to_sync_dexcp_m ;
5167
// qual with alt_space not required - spu will do it.
5168
//SC assign     st_to_sync_dexcp_m = 
5169
//SC   strm_asi_m & ((ldst_va_m[7:0] == 8'ha0) | (ldst_va_m[7:0] == 8'h68)) & st_inst_vld_m ;  
5170
 
5171
//SC wire       spu_early_flush_m ;
5172
 
5173
//SC assign     spu_early_flush_m =
5174
//SC    priv_action_m           |
5175
//SC    mem_addr_not_align      |
5176
//SC    st_to_sync_dexcp_m      ; 
5177
 
5178
//SC dff  eflushspu_g (
5179
//SC         .din    (spu_early_flush_m),
5180
//SC         .q      (lsu_spu_early_flush_g),
5181
//SC         .clk    (clk),
5182
//SC         .se     (se),       .si (),          .so ()
5183
//SC         );
5184
 
5185
//SC dff  eflushtlu_g (
5186
//SC         .din    (spu_early_flush_m),
5187
//SC         .q      (lsu_tlu_early_flush_w),
5188
//SC        .clk    (clk),
5189
//SC         .se     (se),       .si (),          .so ()
5190
 //SC        );
5191
 
5192
//=========================================================================================
5193
//  Parity Error Checking
5194
//=========================================================================================
5195
 
5196
// DCache Parity Error
5197
// - Parity Check is done for entire 64b. No attempt is made to match on size. A
5198
// parity error will force a miss and refetch a line to the same way of the cache.
5199
// - Logging of error is done in g-stage of issue.
5200
// - Trap taken on data return
5201
 
5202
wire    dcache_perr_en ;
5203
assign  dcache_perr_en  =
5204
  dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) &
5205
  ~atomic_g  &
5206
  // dcache_rd_parity_err qualified with cache_way_hit - could be x.
5207
  (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g)) ;
5208
assign dcache_rd_parity_error = dcache_rparity_err_wb & dcache_perr_en ;
5209
 
5210
// dtag parity error gets priority over dcache priority.
5211
assign  lsu_dcache_data_perror_g =
5212
  dcache_rd_parity_error & ld_inst_vld_unflushed & lsu_inst_vld_w & ~dtag_perror_g &
5213
  dcache_perr_en ;
5214
//  dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) & 
5215
//  ~atomic_g ; 
5216
 
5217
// DTLB Parity Errors. 
5218
// ASI read of Tag/Data :
5219
//  - uncorrectible error
5220
//  - logging occurs on read.
5221
//  - precise trap is taken when ldxa completes if nceen set.
5222
//  - if not set then ldxa is allowed to complete.
5223
// CAM Read of Tag/Data :
5224
//  - correctible if locked bit not set.
5225
//    - takes disrupting trap later.
5226
//  - uncorrectible if locked bit set.
5227
//  - both are treated as precise traps.
5228
//  - if errors not enabled, then load completes as if hit in L1.
5229
// ** TLB error will cause a trap which will preclude concurrent dcache,dtag  **
5230
// ** parity errors.                **
5231
 
5232
//SC assign  tte_data_parity_error = 
5233
//SC   tlb_rd_tte_data_parity ^ lsu_rd_tte_data_parity ;
5234
//SC assign  tte_tag_parity_error  = 
5235
//SC   tlb_rd_tte_tag_parity ^ lsu_rd_tte_tag_parity ;
5236
 
5237
// cam related tte data parity error - error assumed correctible if locked
5238
// bit is not set. Will cause a dmmu_miss for correction.
5239
// qualify with cam_hit ??
5240
//SC assign  tte_data_perror_corr = 
5241
//SC   tte_data_parity_error & ~tlb_rd_tte_data_locked & tlb_tte_vld_g & 
5242
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w ;
5243
// same as above except error is treated as uncorrectible. This is to be posted to 
5244
// error status register which will cause a disrupting trap later.
5245
//SC assign  tte_data_perror_unc  = 
5246
//SC   tte_data_parity_error &  tlb_rd_tte_data_locked & tlb_tte_vld_g & 
5247
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w ;
5248
// Asi rd parity error detection
5249
//SC assign  asi_tte_data_perror =
5250
//SC   tte_data_parity_error & data_rd_vld_g ;
5251
// For data tte read, both tag and data arrays are read.
5252
// Parity error on asi read of tag should not be reported.
5253
//SC assign  asi_tte_tag_perror =
5254
//SC   tte_tag_parity_error & tag_rd_vld_g & ~data_rd_vld_g ;
5255
//SC assign  lsu_tlu_asi_rd_unc = asi_tte_data_perror | asi_tte_tag_perror ;
5256
 
5257
// asi rd parity errors need to be reported thru asi bus
5258
/*assign  lsu_ifu_tlb_data_ce = tte_data_perror_corr ;
5259
assign  lsu_ifu_tlb_data_ue = tte_data_perror_unc | asi_tte_data_perror ;
5260
assign  lsu_ifu_tlb_tag_ue  = asi_tte_tag_perror ; */
5261
 
5262
 
5263
//SC wire  tlb_data_ue_g ;
5264
//SC assign  tlb_data_ue_g = tte_data_perror_unc | asi_tte_data_perror ;
5265
 
5266
//SC dff  #(3) terr_stgd1 (
5267
//SC         .din    ({tte_data_perror_corr,tlb_data_ue_g,asi_tte_tag_perror}),
5268
//SC         .q      ({lsu_ifu_tlb_data_ce,lsu_ifu_tlb_data_ue,lsu_ifu_tlb_tag_ue}),
5269
//SC         .clk    (clk),
5270
//SC         .se     (se),       .si (),          .so ()
5271
//SC         );
5272
 
5273
// Dtag Parity Error
5274
// - corrected thru special mechanism
5275
// - correctible error
5276
// - Trap taken on data return
5277
 
5278
// move parity error calculation to g stage
5279
 
5280
dff  #(4) dva_vld_g_ff (
5281
         .din    (dva_vld_m[3:0]),
5282
         .q      (dva_vld_g[3:0]),
5283
        .clk    (clk),
5284
        .se     (se),       .si (),          .so ()
5285
        );
5286
 
5287
   assign dva_vld_m_bf[3:0] = dva_vld_m[3:0];
5288
 
5289
wire    dtag_perr_en ;
5290
assign  dtag_perr_en =
5291
dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) & // Bug 3541
5292
  ~(lsu_alt_space_g & blk_asi_g) &  // Bug 3926. 
5293
  ~atomic_g & // Bug 4274,4297 
5294
  ~pref_inst_g ; // Bug 5046
5295
assign  dtag_parity_error[0] =
5296
      lsu_rd_dtag_parity_g[0] & dva_vld_g[0] & dtag_perr_en;
5297
assign  dtag_parity_error[1] =
5298
      lsu_rd_dtag_parity_g[1] & dva_vld_g[1] & dtag_perr_en ;
5299
assign  dtag_parity_error[2] =
5300
      lsu_rd_dtag_parity_g[2] & dva_vld_g[2] & dtag_perr_en ;
5301
assign  dtag_parity_error[3] =
5302
      lsu_rd_dtag_parity_g[3] & dva_vld_g[3] & dtag_perr_en ;
5303
 
5304
assign  dtag_perror_g = |dtag_parity_error[3:0] ;
5305
assign  lsu_dcache_tag_perror_g =
5306
  (|dtag_parity_error[3:0]) & ld_inst_vld_unflushed & lsu_inst_vld_w &
5307
  // Correction pkt should not be generated to io.
5308
  ~(tlb_pgnum[39] & (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g))) ;
5309
//  (|dtag_parity_error[3:0]) & ld_inst_vld_unflushed & lsu_inst_vld_w &
5310
//  ~(lsu_alt_space_g & blk_asi_g) &  // Bug 3926. 
5311
//  // Correction pkt should not be generated to io.
5312
//  ~(tlb_pgnum[39] & (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g))) &
5313
//  ~atomic_g ; // Bug 4274,4297 
5314
//=========================================================================================
5315
//  Error Related Traps 
5316
//=========================================================================================
5317
 
5318
//bug6382/eco6621   
5319
dff #(2)  derrtrp_stgm (
5320
        .din    ({lsu_cpx_ld_dtag_perror_e & ~ignore_fill, lsu_cpx_ld_dcache_perror_e & ~ignore_fill}),
5321
        .q      ({dtag_error_m,dcache_error_m}),
5322
        .clk    (clk),
5323
        .se     (se),       .si (),          .so ()
5324
        );
5325
 
5326
dff #(2)  derrtrp_stgg (
5327
        .din    ({dtag_error_m,dcache_error_m}),
5328
        .q      ({dtag_error_g,dcache_error_g}),
5329
        .clk    (clk),
5330
        .se     (se),       .si (),          .so ()
5331
        );
5332
 
5333
dff #(2)  derrtrp_stgw2 (
5334
        .din    ({dtag_error_g,dcache_error_g}),
5335
        .q      ({dtag_error_w2,dcache_error_w2}),
5336
        .clk    (clk),
5337
        .se     (se),       .si (),          .so ()
5338
        );
5339
 
5340
assign  lsu_ifu_dcache_data_perror = dcache_error_w2 & ~bld_squash_err_w2;  //bug6382/eco6621
5341
assign  lsu_ifu_dcache_tag_perror  = dtag_error_w2  ;
5342
 
5343
assign  l2_unc_error_e  = lsu_cpx_pkt_ld_err[1] & l2fill_vld_e & ~ignore_fill  ; // Bug 4998
5344
assign  l2_corr_error_e = lsu_cpx_pkt_ld_err[0] & l2fill_vld_e & ~ignore_fill  ;
5345
 
5346
dff #(2)  lerrtrp_stgm (
5347
        .din    ({l2_unc_error_e,l2_corr_error_e}),
5348
        .q      ({l2_unc_error_m,l2_corr_error_m}),
5349
        .clk    (clk),
5350
        .se     (se),       .si (),          .so ()
5351
        );
5352
 
5353
dff #(2)  lerrtrp_stgg (
5354
        .din    ({l2_unc_error_m,l2_corr_error_m}),
5355
        .q      ({l2_unc_error_g,l2_corr_error_g}),
5356
        .clk    (clk),
5357
        .se     (se),       .si (),          .so ()
5358
        );
5359
 
5360
dff #(2)  lerrtrp_stgw2 (
5361
        .din    ({l2_unc_error_g,l2_corr_error_g}),
5362
        .q      ({l2_unc_error_w2,l2_corr_error_w2}),
5363
        .clk    (clk),
5364
        .se     (se),       .si (),          .so ()
5365
        );
5366
 
5367
assign  lsu_ifu_l2_unc_error  = // Bug 4315
5368
(l2_unc_error_w2 | bld_unc_err_pend_w2) & ~lsu_ifu_err_addr_b39 & ~bld_squash_err_w2 ;
5369
assign  lsu_ifu_l2_corr_error =
5370
(l2_corr_error_w2 | bld_corr_err_pend_w2) & ~bld_squash_err_w2 ;
5371
 
5372
wire    fill_err_trap_e ;
5373
 
5374
//assign  unc_err_trap_e = 
5375
assign  fill_err_trap_e =
5376
  (lsu_cpx_pkt_ld_err[1] & l2fill_vld_e) ;
5377
   /*(lsu_cpx_atm_st_err[1] & lsu_atm_st_cmplt_e)) &
5378
      ((dfill_thread0 & ifu_lsu_nceen[0]) |
5379
       (dfill_thread1 & ifu_lsu_nceen[1]) |
5380
       (dfill_thread2 & ifu_lsu_nceen[2]) |
5381
       (dfill_thread3 & ifu_lsu_nceen[3])) ; */ // Bug 3624
5382
 
5383
assign  unc_err_trap_e = fill_err_trap_e ;
5384
 
5385
/*assign  corr_err_trap_e =
5386
  ((lsu_cpx_pkt_ld_err[0] | lsu_cpx_ld_dtag_perror_e | lsu_cpx_ld_dcache_perror_e) &
5387
   l2fill_vld_e) |
5388
   (lsu_cpx_atm_st_err[0] & lsu_atm_st_cmplt_e)) &
5389
   & ~unc_err_trap_e &
5390
      ((dfill_thread0 & ifu_lsu_ceen[0]) |
5391
       (dfill_thread1 & ifu_lsu_ceen[1]) |
5392
       (dfill_thread2 & ifu_lsu_ceen[2]) |
5393
       (dfill_thread3 & ifu_lsu_ceen[3])) ; */
5394
 
5395
 
5396
dff #(1)  errtrp_stgm (
5397
        .din    ({unc_err_trap_e}),
5398
        .q      ({unc_err_trap_m}),
5399
        .clk    (clk),
5400
        .se     (se),       .si (),          .so ()
5401
        );
5402
 
5403
dff #(1)  errtrp_stgg (
5404
        .din    ({unc_err_trap_m}),
5405
        .q      ({unc_err_trap_g}),
5406
        .clk    (clk),
5407
        .se     (se),       .si (),          .so ()
5408
        );
5409
 
5410
// The tlu should source demap_thrid for all tlb operations !!!
5411
dff #(2)  filla_stgm (
5412
        .din    ({lsu_dfill_tid_e[1:0]}),
5413
        .q      ({dfill_tid_m[1:0]}),
5414
        .clk    (clk),
5415
        .se     (se),       .si (),          .so ()
5416
        );
5417
 
5418
dff #(2)  filla_stgg (
5419
        .din    ({dfill_tid_m[1:0]}),
5420
        .q      ({dfill_tid_g[1:0]}),
5421
        .clk    (clk),
5422
        .se     (se),       .si (),          .so ()
5423
        );
5424
 
5425
 
5426
 
5427
//=========================================================================================
5428
//  LSU to IRF Data Bypass Control
5429
//=========================================================================================
5430
 
5431
assign  spu_trap =  spu_lsu_unc_error_w2 ;
5432
assign  spu_trap0 = spu_trap & spu_ldxa_thread0_w2 ;
5433
assign  spu_trap1 = spu_trap & spu_ldxa_thread1_w2 ;
5434
assign  spu_trap2 = spu_trap & spu_ldxa_thread2_w2 ;
5435
assign  spu_trap3 = spu_trap & spu_ldxa_thread3_w2 ;
5436
 
5437
assign  spu_ttype[6:0]   = spu_lsu_int_w2 ? 7'h70 : 7'h32 ;
5438
 
5439
dff #(2)   lfraw_stgw2 (
5440
        .din    ({ld_inst_vld_g,fp_ldst_g}),
5441
        .q      ({ld_inst_vld_w2,fp_ldst_w2}),
5442
        .clk    (clk),
5443
        .se     (se),       .si (),          .so ()
5444
        );
5445
 
5446
dff #(2)   lfraw_stgw3 (
5447
        .din    ({ld_stb_full_raw_w2, ld_inst_vld_w2}),
5448
        .q      ({ld_stb_full_raw_w3, ld_inst_vld_w3}),
5449
        .clk    (clk),
5450
        .se     (se),       .si (),          .so ()
5451
        );
5452
 
5453
// Delay all ldbyp*vld_en by a cycle for write of unc error
5454
//dff #(4)  lbypen_stgd1 (
5455
//        .din    ({ldbyp0_vld_en,ldbyp1_vld_en,ldbyp2_vld_en,ldbyp3_vld_en}),
5456
//        .q      ({ldbyp0_vld_en_d1,ldbyp1_vld_en_d1,ldbyp2_vld_en_d1,ldbyp3_vld_en_d1}),
5457
//        .clk    (clk),
5458
//        .se     (se),       .si (),          .so ()
5459
//        ); 
5460
 
5461
 
5462
wire   fp_ldst_thrd0_w2,fp_ldst_thrd1_w2,fp_ldst_thrd2_w2,fp_ldst_thrd3_w2 ;
5463
wire   fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3 ;
5464
wire   fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4 ;
5465
wire   fp_ldst_thrd0_w5,fp_ldst_thrd1_w5,fp_ldst_thrd2_w5,fp_ldst_thrd3_w5 ;
5466
 
5467
//RAW read STB at W3 (changed from W2)
5468
 
5469
dff #(4) fp_ldst_stg_w3 (
5470
  .din ({fp_ldst_thrd0_w2,fp_ldst_thrd1_w2,fp_ldst_thrd2_w2,fp_ldst_thrd3_w2}),
5471
  .q   ({fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3}),
5472
  .clk    (clk),
5473
  .se     (se),       .si (),          .so ()
5474
  );
5475
 
5476
dff #(4) fp_ldst_stg_w4 (
5477
  .din ({fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3}),
5478
  .q   ({fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4}),
5479
  .clk    (clk),
5480
  .se     (se),       .si (),          .so ()
5481
  );
5482
 
5483
dff #(4) fp_ldst_stg_w5 (
5484
  .din ({fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4}),
5485
  .q   ({fp_ldst_thrd0_w5,fp_ldst_thrd1_w5,fp_ldst_thrd2_w5,fp_ldst_thrd3_w5}),
5486
  .clk    (clk),
5487
  .se     (se),       .si (),          .so ()
5488
  );
5489
 
5490
// THREAD 0
5491
 
5492
wire    tte_data_perror_unc_w2,asi_tte_data_perror_w2,asi_tte_tag_perror_w2 ;
5493
// if nceen/ceen=0, then tte_data_perror* are not logged for trap generation. Earlier error-reporting
5494
// is however never screened off.
5495
// asi_tte* however has to be logged in order to report errors thru the asiQ. Traps must be squashed. 
5496
dff #(3) ltlbrd_w2 (
5497
  .din ({tte_data_perror_unc_en,asi_tte_data_perror,asi_tte_tag_perror}),
5498
  .q   ({tte_data_perror_unc_w2,asi_tte_data_perror_w2,asi_tte_tag_perror_w2}),
5499
  .clk    (clk),
5500
  .se     (se),       .si (),          .so ()
5501
  );
5502
 
5503
 
5504
// Error Table for Queue
5505
// ** In all cases; squash writes to irf.
5506
//                              | Error Reporting       | Trap ?        | 
5507
// ifu_lsu_asi_rd_unc           | NA;done by ifu        | daccess-error |
5508
// tte_data_perror_unc_w2       | sync;in pipe          | daccess-error |
5509
// tte_data_perror_corr_w2      | sync;in pipe          | dmmu-miss     | --> NA !! all unc.
5510
// asi_tte_data_perror_w2       | async;out of Q        | daccess-error |
5511
// asi_tte_tag_perror_w2        | async;out of Q        | daccess-error |
5512
 
5513
wire [3:0] tlb_err_en_w2 ;
5514
// used for xslate errors - enable queues
5515
//assign        tlb_err_en_w2[0] = (tte_data_perror_unc_w2 | tte_data_perror_corr_w2) & thread0_w2 ;    
5516
assign  tlb_err_en_w2[0] = tte_data_perror_unc_w2 & thread0_w2 ;
5517
assign  tlb_err_en_w2[1] = tte_data_perror_unc_w2 & thread1_w2 ;
5518
assign  tlb_err_en_w2[2] = tte_data_perror_unc_w2 & thread2_w2 ;
5519
assign  tlb_err_en_w2[3] = tte_data_perror_unc_w2 & thread3_w2 ;
5520
 
5521
assign ldbyp0_vld_rst =
5522
        (reset | (ld_thrd_byp_sel_e[0])) |
5523
        atm_st_cmplt0 ; // Bug 4048
5524
 
5525
// thread qualification required.
5526
//assign ldbyp0_vld_en = (lmq_byp_data_en_w2[0] & 
5527
//        ~(|lmq_byp_data_sel0[2:1]))  // do not set vld for cas/stdbl
5528
//      | spu_trap0 ;
5529
 
5530
wire            atm_ld_w_uerr ;
5531
assign          atm_ld_w_uerr = l2fill_vld_e & lsu_cpx_pkt_atm_st_cmplt & lsu_cpx_pkt_ld_err[1] ;
5532
 
5533
//bug6525 notes
5534
// spu ldxa and spu trap can async with the main pipe, and cause more than one ldbyp*_vld_en asserted 
5535
// at the same cycle   
5536
assign ldbyp0_vld_en = lmq_byp_data_raw_sel_d2[0] |                  //ld hit stb RAW bypass
5537
                       lmq_byp_data_sel0[3]       |                  //ldxa (ifu, spu*, lsu)
5538
                       (atm_ld_w_uerr & lsu_nceen_d1[0] & dfill_thread0) |       //atomic
5539
                       lmq_byp_data_fmx_sel[0]    |                  //tlu ldxa
5540
                       tlb_err_en_w2[0]    |                                      //tlb parity err
5541
                       spu_trap0 ;                                   //spu trap*
5542
 
5543
assign   fp_ldst_thrd0_w2 = fp_ldst_w2 & thread0_w2 & ld_inst_vld_w2 ;
5544
 
5545
// ld valid
5546
wire    ldbyp0_vld_tmp ;
5547
dffre #(1)  ldbyp0_vld_ff (
5548
        .din    (ldbyp0_vld_en),
5549
        .q      (ldbyp0_vld_tmp),
5550
        .rst    (ldbyp0_vld_rst),        .en     (ldbyp0_vld_en),
5551
        .clk    (clk),
5552
        .se     (se),       .si (),          .so ()
5553
        );
5554
// Bug 5379 - make ld ue invisible in q until atm st ack resets.
5555
 
5556
assign  ldbyp0_vld = ldbyp0_vld_tmp & ~pend_atm_ld_ue[0] ;
5557
 
5558
 
5559
// assumes that rw_index is not reset at mmu.
5560
wire [6:0]       misc_data_in ;
5561
wire [6:0]       misc_data0,misc_data1,misc_data2,misc_data3 ;
5562
wire            misc_sel ;
5563
wire [5:0]       rw_index_d1 ;
5564
dff #(6)  rwind_d1 (
5565
        .din    (tlu_dtlb_rw_index_g[5:0]),
5566
        .q      (rw_index_d1[5:0]),
5567
        .clk    (clk),
5568
        .se     (se),       .si (),          .so ()
5569
        );
5570
assign  misc_sel = asi_tte_data_perror_w2 | asi_tte_tag_perror_w2 ;
5571
assign  misc_data_in[6:0] = misc_sel ? {1'b0,rw_index_d1[5:0]} : spu_ttype[6:0] ;
5572
 
5573
dffe #(9)  ldbyp0_other_ff (
5574
        .din    ({fp_ldst_thrd0_w5,spu_trap0,misc_data_in[6:0]}),  //bug6525 fix2
5575
        .q      ({ldbyp0_fpld,spubyp0_trap,misc_data0[6:0]}),
5576
        .en     (ldbyp0_vld_en),
5577
        .clk    (clk),
5578
        .se     (se),       .si (),          .so ()
5579
        );
5580
 
5581
 
5582
dffre #(5)  ldbyp0_err_ff (
5583
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5584
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5585
        .q      ({cam_perr_unc0,pend_atm_ld_ue[0],asi_data_perr0,asi_tag_perr0,
5586
                ifu_unc_err0}),
5587
        .rst    (ldbyp0_vld_rst), .en     (ldbyp0_vld_en & ~spu_trap0 & ~lmq_byp_ldxa_sel0[1]), //bug6525 fix2
5588
        .clk    (clk),
5589
        .se     (se),       .si (),          .so ()
5590
        );
5591
 
5592
 
5593
//assign  ldbyp0_unc_err = ldbyp0_unc_err_q & ifu_lsu_nceen[0] ;
5594
 
5595
// THREAD 1
5596
 
5597
assign ldbyp1_vld_rst =
5598
        (reset | (ld_thrd_byp_sel_e[1])) |
5599
        atm_st_cmplt1 ; // Bug 4048
5600
 
5601
assign   fp_ldst_thrd1_w2 = fp_ldst_w2 & thread1_w2 & ld_inst_vld_w2 ;
5602
 
5603
// thread qualification required.
5604
//assign ldbyp1_vld_en = (lmq_byp_data_en_w2[1] &
5605
//        ~(|lmq_byp_data_sel1[2:1])) | // do not set vld for cas/stdbl
5606
//      | spu_trap1 ;
5607
 
5608
assign ldbyp1_vld_en = lmq_byp_data_raw_sel_d2[1] |
5609
                       lmq_byp_data_sel1[3]       |
5610
                       (atm_ld_w_uerr & lsu_nceen_d1[1] & dfill_thread1) |
5611
                       lmq_byp_data_fmx_sel[1]    |
5612
                       tlb_err_en_w2[1]   |
5613
                       spu_trap1 ;
5614
 
5615
// ld valid
5616
wire    ldbyp1_vld_tmp ;
5617
dffre #(1)  ldbyp1_vld_ff (
5618
        .din    (ldbyp1_vld_en),
5619
        .q      (ldbyp1_vld_tmp),
5620
        .rst    (ldbyp1_vld_rst),        .en     (ldbyp1_vld_en),
5621
        .clk    (clk),
5622
        .se     (se),       .si (),          .so ()
5623
        );
5624
assign  ldbyp1_vld = ldbyp1_vld_tmp & ~pend_atm_ld_ue[1] ;
5625
 
5626
 
5627
dffe #(9)  ldbyp1_other_ff (
5628
        .din    ({fp_ldst_thrd1_w5,spu_trap1,misc_data_in[6:0]}),  //bug6525 fix2
5629
        .q      ({ldbyp1_fpld,spubyp1_trap,misc_data1[6:0]}),
5630
        .en     (ldbyp1_vld_en),
5631
        .clk    (clk),
5632
        .se     (se),       .si (),          .so ()
5633
        );
5634
 
5635
// The tlb rd unc errors are delayed a cycle wrt to ldxa_data
5636
// No reset required
5637
dffre #(5)  ldbyp1_err_ff (
5638
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5639
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5640
        .q      ({cam_perr_unc1,pend_atm_ld_ue[1],asi_data_perr1,asi_tag_perr1,
5641
                ifu_unc_err1}),
5642
        .rst    (ldbyp1_vld_rst), .en     (ldbyp1_vld_en & ~spu_trap1 & ~lmq_byp_ldxa_sel1[1]), //bug6525 fix2
5643
        .clk    (clk),
5644
        .se     (se),       .si (),          .so ()
5645
        );
5646
 
5647
//assign  ldbyp1_unc_err = ldbyp1_unc_err_q & ifu_lsu_nceen[1] ;
5648
 
5649
// THREAD 2
5650
 
5651
assign ldbyp2_vld_rst =
5652
        (reset | (ld_thrd_byp_sel_e[2])) |
5653
        atm_st_cmplt2 ; // Bug 4048
5654
 
5655
// thread qualification required.
5656
//assign ldbyp2_vld_en = (lmq_byp_data_en_w2[2] &
5657
//        ~(|lmq_byp_data_sel2[2:1])) | // do not set vld for cas/stdbl
5658
//      spu_trap2 ;
5659
 
5660
assign ldbyp2_vld_en = lmq_byp_data_raw_sel_d2[2] |
5661
                       lmq_byp_data_sel2[3]       |
5662
                       (atm_ld_w_uerr & lsu_nceen_d1[2] & dfill_thread2) |
5663
                       lmq_byp_data_fmx_sel[2]    |
5664
                       tlb_err_en_w2[2]   |
5665
                       spu_trap2 ;
5666
 
5667
assign   fp_ldst_thrd2_w2 = fp_ldst_w2 & thread2_w2 & ld_inst_vld_w2 ;
5668
 
5669
// ld valid
5670
wire    ldbyp2_vld_tmp ;
5671
dffre #(1)  ldbyp2_vld_ff (
5672
        .din    (ldbyp2_vld_en),
5673
        .q      (ldbyp2_vld_tmp),
5674
        .rst    (ldbyp2_vld_rst),        .en     (ldbyp2_vld_en),
5675
        .clk    (clk),
5676
        .se     (se),       .si (),          .so ()
5677
        );
5678
assign  ldbyp2_vld = ldbyp2_vld_tmp & ~pend_atm_ld_ue[2] ;
5679
 
5680
dffe #(9)  ldbyp2_other_ff (
5681
        .din    ({fp_ldst_thrd2_w5,spu_trap2,misc_data_in[6:0]}),  //bug6525 fix2
5682
        .q      ({ldbyp2_fpld,spubyp2_trap,misc_data2[6:0]}),
5683
        .en     (ldbyp2_vld_en),
5684
        .clk    (clk),
5685
        .se     (se),       .si (),          .so ()
5686
        );
5687
 
5688
dffre #(5)  ldbyp2_err_ff (
5689
        .din    ({tte_data_perror_unc_w2, atm_ld_w_uerr,
5690
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5691
        .q      ({cam_perr_unc2,pend_atm_ld_ue[2],asi_data_perr2,asi_tag_perr2,
5692
                ifu_unc_err2}),
5693
        .rst    (ldbyp2_vld_rst), .en     (ldbyp2_vld_en & ~spu_trap2 & ~lmq_byp_ldxa_sel2[1]), //bug6525 fix2
5694
        .clk    (clk),
5695
        .se     (se),       .si (),          .so ()
5696
        );
5697
 
5698
//assign  ldbyp2_unc_err = ldbyp2_unc_err_q & ifu_lsu_nceen[2] ;
5699
 
5700
// THREAD 3
5701
 
5702
assign ldbyp3_vld_rst =
5703
        (reset | (ld_thrd_byp_sel_e[3])) |
5704
        atm_st_cmplt3 ; // Bug 4048
5705
 
5706
// thread qualification required.
5707
//assign ldbyp3_vld_en = (lmq_byp_data_en_w2[3] &
5708
//        ~(|lmq_byp_data_sel3[2:1])) | // do not set vld for cas/stdbl
5709
//      | spu_trap3 ;
5710
 
5711
assign ldbyp3_vld_en = lmq_byp_data_raw_sel_d2[3] |
5712
                       lmq_byp_data_sel3[3]       |
5713
                       (atm_ld_w_uerr & lsu_nceen_d1[3] & dfill_thread3) |
5714
                       lmq_byp_data_fmx_sel[3]    |
5715
                       tlb_err_en_w2[3]   |
5716
                       spu_trap3 ;
5717
 
5718
assign   fp_ldst_thrd3_w2 = fp_ldst_w2 & thread3_w2 & ld_inst_vld_w2 ;
5719
 
5720
// ld valid
5721
wire    ldbyp3_vld_tmp ;
5722
dffre #(1)  ldbyp3_vld_ff (
5723
        .din    (ldbyp3_vld_en),
5724
        .q      (ldbyp3_vld_tmp),
5725
        .rst    (ldbyp3_vld_rst),        .en     (ldbyp3_vld_en),
5726
        .clk    (clk),
5727
        .se     (se),       .si (),          .so ()
5728
        );
5729
assign  ldbyp3_vld = ldbyp3_vld_tmp & ~pend_atm_ld_ue[3] ;
5730
 
5731
 
5732
dffe #(9)  ldbyp3_other_ff (
5733
        .din    ({fp_ldst_thrd3_w5,spu_trap3,misc_data_in[6:0]}),  //bug6525 fix2
5734
        .q      ({ldbyp3_fpld,spubyp3_trap,misc_data3[6:0]}),
5735
        .en     (ldbyp3_vld_en),
5736
        .clk    (clk),
5737
        .se     (se),       .si (),          .so ()
5738
        );
5739
 
5740
dffre #(5)  ldbyp3_err_ff (
5741
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5742
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5743
        .q      ({cam_perr_unc3,pend_atm_ld_ue[3],asi_data_perr3,asi_tag_perr3,
5744
                ifu_unc_err3}),
5745
        .rst    (ldbyp3_vld_rst), .en     (ldbyp3_vld_en & ~spu_trap3 & ~lmq_byp_ldxa_sel3[1]), //bug6525 fix2
5746
        .clk    (clk),
5747
        .se     (se),       .si (),          .so ()
5748
        );
5749
 
5750
//assign  ldbyp3_unc_err = ldbyp3_unc_err_q & ifu_lsu_nceen[3] ;
5751
 
5752
//assign  ld_any_byp_data_vld = 
5753
//  ldbyp0_vld | ldbyp1_vld | ldbyp2_vld | ldbyp3_vld ;
5754
 
5755
dff #(4)   stgm_sqshcmplt (
5756
        .din    (squash_byp_cmplt[3:0]),
5757
        .q      (squash_byp_cmplt_m[3:0]),
5758
        .clk    (clk),
5759
        .se     (se),       .si (),          .so ()
5760
        );
5761
 
5762
dff #(4)  stgg_sqshcmplt (
5763
        .din    (squash_byp_cmplt_m[3:0]),
5764
        .q      (squash_byp_cmplt_g[3:0]),
5765
        .clk    (clk),
5766
        .se     (se),       .si (),          .so ()
5767
        );
5768
 
5769
assign  fpld_byp_data_vld =
5770
  (ld_thrd_byp_sel_g[0] & ldbyp0_fpld & ~squash_byp_cmplt_g[0]) | // Bug 4998
5771
  (ld_thrd_byp_sel_g[1] & ldbyp1_fpld & ~squash_byp_cmplt_g[1]) |
5772
  (ld_thrd_byp_sel_g[2] & ldbyp2_fpld & ~squash_byp_cmplt_g[2]) |
5773
  (ld_thrd_byp_sel_g[3] & ldbyp3_fpld & ~squash_byp_cmplt_g[3]) ;
5774
 
5775
//assign  intld_byp_data_vld = |intld_byp_cmplt[3:0] ;
5776
// squash for spu-trap situation.
5777
assign  intld_byp_data_vld_e =
5778
        //(intld_byp_cmplt[0] & ~spubyp0_trap) |
5779
        (intld_byp_cmplt[0]) | // squash now thru squash_byp_cmplt
5780
        (intld_byp_cmplt[1]) |
5781
        (intld_byp_cmplt[2]) |
5782
        (intld_byp_cmplt[3]) ;
5783
 
5784
dff   stgm_ibvld (
5785
        .din    (intld_byp_data_vld_e),
5786
        .q      (intld_byp_data_vld_m),
5787
        .clk    (clk),
5788
        .se     (se),       .si (),          .so ()
5789
        );
5790
 
5791
// to be removed - intld_byp_data_vld in lsu_mon.v
5792
/*
5793
dff   stgg_ibvld (
5794
        .din    (intld_byp_data_vld_m),
5795
        .q      (intld_byp_data_vld),
5796
        .clk    (clk),
5797
        .se     (se),       .si (),          .so ()
5798
        );
5799
*/
5800
assign  spubyp_trap_active_e =
5801
        //(intld_byp_cmplt[0] & spubyp0_trap) | // Bug 4040
5802
        (ld_thrd_byp_sel_e[0] & spubyp0_trap) |
5803
        (ld_thrd_byp_sel_e[1] & spubyp1_trap) |
5804
        (ld_thrd_byp_sel_e[2] & spubyp2_trap) |
5805
        (ld_thrd_byp_sel_e[3] & spubyp3_trap) ;
5806
 
5807
dff   stgm_strmtrp (
5808
        .din    (spubyp_trap_active_e),
5809
        .q      (spubyp_trap_active_m),
5810
        .clk    (clk),
5811
        .se     (se),       .si (),          .so ()
5812
        );
5813
 
5814
dff   stgg_strmtrp (
5815
        .din    (spubyp_trap_active_m),
5816
        .q      (spubyp_trap_active_g),
5817
        .clk    (clk),
5818
        .se     (se),       .si (),          .so ()
5819
        );
5820
 
5821
assign  spubyp0_ttype[6:0] = misc_data0[6:0] ;
5822
assign  spubyp1_ttype[6:0] = misc_data1[6:0] ;
5823
assign  spubyp2_ttype[6:0] = misc_data2[6:0] ;
5824
assign  spubyp3_ttype[6:0] = misc_data3[6:0] ;
5825
 
5826
mux4ds #(7) mux_spubyp_ttype (
5827
        .in0(spubyp0_ttype[6:0]),
5828
        .in1(spubyp1_ttype[6:0]),
5829
        .in2(spubyp2_ttype[6:0]),
5830
        .in3(spubyp3_ttype[6:0]),
5831
        .sel0(ld_thrd_byp_mxsel_m[0]),
5832
        .sel1(ld_thrd_byp_mxsel_m[1]),
5833
        .sel2(ld_thrd_byp_mxsel_m[2]),
5834
        .sel3(ld_thrd_byp_mxsel_m[3]),
5835
        .dout(spubyp_ttype[6:0])
5836
);
5837
 
5838
assign  intld_byp_cmplt[0] = (ld_thrd_byp_sel_e[0] & ~(ldbyp0_fpld | squash_byp_cmplt[0])) ;
5839
assign  intld_byp_cmplt[1] = (ld_thrd_byp_sel_e[1] & ~(ldbyp1_fpld | squash_byp_cmplt[1])) ;
5840
assign  intld_byp_cmplt[2] = (ld_thrd_byp_sel_e[2] & ~(ldbyp2_fpld | squash_byp_cmplt[2])) ;
5841
assign  intld_byp_cmplt[3] = (ld_thrd_byp_sel_e[3] & ~(ldbyp3_fpld | squash_byp_cmplt[3])) ;
5842
 
5843
dff #(2)  stgm_l2fv (
5844
        .din    ({l2fill_vld_e,lsu_l2fill_fpld_e}),
5845
        .q      ({l2fill_vld_m,l2fill_fpld_m}),
5846
        .clk    (clk),
5847
        .se     (se),       .si (),          .so ()
5848
        );
5849
 
5850
dff #(2) stgg_l2fv (
5851
        .din    ({l2fill_vld_m,l2fill_fpld_m}),
5852
        .q      ({l2fill_vld_g,l2fill_fpld_g}),
5853
        .clk    (clk),
5854
        .se     (se),       .si (),          .so ()
5855
        );
5856
 
5857
// write to irf will need to be postphoned by a few cycles. 
5858
// may wish to find more bubbles by counting misses !!!
5859
//assign  lsu_irf_byp_data_src[0]  =      ld_inst_vld_unflushed ;
5860
//assign  lsu_irf_byp_data_src[1]  =    l2fill_vld_g ;
5861
//assign  lsu_irf_byp_data_src[2]  =    
5862
//  ~l2fill_vld_g    &      // no dfq fill
5863
//  ~ld_inst_vld_unflushed ;  // no ld/st in pipe.
5864
 
5865
  //~(ld_inst_vld_unflushed | st_inst_vld_unflushed) ;  // no ld/st in pipe.
5866
   // Timing Change.
5867
   //ld_any_byp_data_vld ;      // full raw bypasses data
5868
 
5869
 
5870
// Store to load full raw bypassing. Plus ldxa data bypassing.
5871
// ldxa-data may be bypassed asap if port available.
5872
// ldxa/stb raw and atomics assumed to be mutually exclusive.
5873
 
5874
wire int_ldxa_vld ;
5875
assign int_ldxa_vld = tlu_lsu_int_ldxa_vld_w2 & ~tlu_lsu_int_ld_ill_va_w2 ;
5876
assign  lmq_byp_data_fmx_sel[0] = int_ldxa_vld & thread0_w2 ;
5877
assign  lmq_byp_data_fmx_sel[1] = int_ldxa_vld & thread1_w2 ;
5878
assign  lmq_byp_data_fmx_sel[2] = int_ldxa_vld & thread2_w2 ;
5879
assign  lmq_byp_data_fmx_sel[3] = int_ldxa_vld & thread3_w2 ;
5880
 
5881
assign lmq_byp_data_en_w2[0] =  (|lmq_byp_data_sel0[3:0]) | lmq_byp_data_fmx_sel[0] ;
5882
assign lmq_byp_data_en_w2[1] =  (|lmq_byp_data_sel1[3:0]) | lmq_byp_data_fmx_sel[1] ;
5883
assign lmq_byp_data_en_w2[2] =  (|lmq_byp_data_sel2[3:0]) | lmq_byp_data_fmx_sel[2] ;
5884
assign lmq_byp_data_en_w2[3] =  (|lmq_byp_data_sel3[3:0]) | lmq_byp_data_fmx_sel[3] ;
5885
 
5886
/*
5887
assign  stq_pkt2_data_en[0] =
5888
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread0_g ;
5889
assign  stq_pkt2_data_en[1] =
5890
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread1_g ;
5891
assign  stq_pkt2_data_en[2] =
5892
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread2_g ;
5893
assign  stq_pkt2_data_en[3] =
5894
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread3_g ;
5895
*/
5896
 
5897
// casxa to be decoded as doubleword.
5898
// casa to be decoded as word.
5899
// ldstuba to be decoded as byte.
5900
// casa, casxa and ldstuba needed to be decoded as alternate space insts with optional
5901
// imm_asi use.
5902
// An atomic will switch out a thread.
5903
 
5904
 
5905
wire  ifu_ldxa_vld,  spu_ldxa_vld ;
5906
assign  ifu_ldxa_vld = ifu_lsu_ldxa_data_vld_w2 & ~ifu_lsu_ldxa_illgl_va_w2 ;
5907
//assign  tlu_ldxa_vld = tlu_lsu_ldxa_data_vld_w2 & ~tlu_lsu_ldxa_illgl_va_w2 ;
5908
assign  spu_ldxa_vld = spu_lsu_ldxa_data_vld_w2 & ~spu_lsu_ldxa_illgl_va_w2 ;
5909
 
5910
wire int_ldxa_ivld ;
5911
assign int_ldxa_ivld = tlu_lsu_int_ldxa_vld_w2 & tlu_lsu_int_ld_ill_va_w2 ;
5912
// ldxa data returns need to cmplt thread without writing to register file
5913
assign  ldxa_illgl_va_cmplt[0] =
5914
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread0_w2) |
5915
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread0_w2) |
5916
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread0_w2) |
5917
  (int_ldxa_ivld & thread0_w2) |
5918
  lsu_asi_illgl_va_cmplt_w2[0] ;
5919
assign  ldxa_illgl_va_cmplt[1] =
5920
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread1_w2) |
5921
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread1_w2) |
5922
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread1_w2) |
5923
  (int_ldxa_ivld & thread1_w2) |
5924
  lsu_asi_illgl_va_cmplt_w2[1] ;
5925
assign  ldxa_illgl_va_cmplt[2] =
5926
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread2_w2) |
5927
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread2_w2) |
5928
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread2_w2) |
5929
  (int_ldxa_ivld & thread2_w2) |
5930
  lsu_asi_illgl_va_cmplt_w2[2] ;
5931
assign  ldxa_illgl_va_cmplt[3] =
5932
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread3_w2) |
5933
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread3_w2) |
5934
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread3_w2) |
5935
  (int_ldxa_ivld & thread3_w2) |
5936
  lsu_asi_illgl_va_cmplt_w2[3] ;
5937
 
5938
dff #(4)  illglva_cmplt_d1 (
5939
        .din    (ldxa_illgl_va_cmplt[3:0]),
5940
        .q      (ldxa_illgl_va_cmplt_d1[3:0]),
5941
        .clk    (clk),
5942
        .se     (se),       .si (),          .so ()
5943
        );
5944
 
5945
// Thread0
5946
// Should be able to remove thread qualification for full-raw.
5947
// Could have and e stage store and w2 stage stb rd in same cycle !!! Qualify select3
5948
// with select0 to give the earlier event priority. 
5949
assign  lmq_byp_ldxa_sel0[0] = ifu_ldxa_vld & ifu_ldxa_thread0_w2 ;
5950
//assign  lmq_byp_ldxa_sel0[1] = tlu_ldxa_vld & tlu_ldxa_thread0_w2 ; 
5951
assign  lmq_byp_ldxa_sel0[1] = spu_ldxa_vld & spu_ldxa_thread0_w2 ;
5952
assign  lmq_byp_ldxa_sel0[2] = (lsu_asi_rd_en_w2 & thread0_w2) | ldxa_tlbrd0_w3 ;
5953
 
5954
wire    fraw_annul0,fraw_annul1,fraw_annul2,fraw_annul3 ;
5955
wire    ldst_miss0,ldst_miss1,ldst_miss2,ldst_miss3 ;
5956
 
5957
//RAW read STB at W3 (not W2)
5958
//   E M W        W2 W3                      w4
5959
//LD     cam_hit     RD STB, flop in byp FFs
5960
//inst+1 D        E  
5961
//inst+2          D  E                            <= squash (stxa) rs3_e to write into byp FFs
5962
//  
5963
assign  fraw_annul0 = ld_stb_full_raw_w3 & thread0_w3 & ld_inst_vld_w3;
5964
assign  fraw_annul1 = ld_stb_full_raw_w3 & thread1_w3 & ld_inst_vld_w3;
5965
assign  fraw_annul2 = ld_stb_full_raw_w3 & thread2_w3 & ld_inst_vld_w3;
5966
assign  fraw_annul3 = ld_stb_full_raw_w3 & thread3_w3 & ld_inst_vld_w3;
5967
 
5968
assign  ldst_miss0 = lsu_ldst_miss_w2 & thread0_w2 ;
5969
assign  ldst_miss1 = lsu_ldst_miss_w2 & thread1_w2 ;
5970
assign  ldst_miss2 = lsu_ldst_miss_w2 & thread2_w2 ;
5971
assign  ldst_miss3 = lsu_ldst_miss_w2 & thread3_w2 ;
5972
 
5973
wire    fraw_annul0_d1,fraw_annul1_d1,fraw_annul2_d1,fraw_annul3_d1 ;
5974
wire    ldst_miss0_d1,ldst_miss1_d1,ldst_miss2_d1,ldst_miss3_d1 ;
5975
 
5976
dff #(4)  fraw_d1 (
5977
        .din    ({fraw_annul3,fraw_annul2,fraw_annul1,fraw_annul0}),
5978
        .q      ({fraw_annul3_d1,fraw_annul2_d1,fraw_annul1_d1,fraw_annul0_d1}),
5979
        .clk    (clk),
5980
        .se     (se),       .si (),          .so ()
5981
        );
5982
 
5983
dff #(4)  ldstm_d1 (
5984
        .din    ({ldst_miss3,ldst_miss2,ldst_miss1,ldst_miss0}),
5985
        .q      ({ldst_miss3_d1,ldst_miss2_d1,ldst_miss1_d1,ldst_miss0_d1}),
5986
        .clk    (clk),
5987
        .se     (se),       .si (),          .so ()
5988
        );
5989
 
5990
//wire  memref_d ;
5991
//assign        memref_d = ifu_lsu_memref_d ;
5992
/*wire  mref_vld0,mref_vld1,mref_vld2,mref_vld3;
5993
wire    mref_vld0_d1,mref_vld1_d1,mref_vld2_d1,mref_vld3_d1;
5994
 
5995
// Bug 3053 - prevent overwrite of ldxa data with subsequent st-data
5996
assign  mref_vld0 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread0_w2) ;
5997
assign  mref_vld1 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread1_w2) ;
5998
assign  mref_vld2 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread2_w2) ;
5999
assign  mref_vld3 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread3_w2) ;
6000
 
6001
dff #(4)  mrefv_d1 (
6002
        .din    ({mref_vld3,mref_vld2,mref_vld1,mref_vld0}),
6003
        .q      ({mref_vld3_d1,mref_vld2_d1,mref_vld1_d1,mref_vld0_d1}),
6004
        .clk    (clk),
6005
        .se     (se),       .si (),          .so ()
6006
        );  */
6007
 
6008
//RAW timing change   
6009
assign  lmq_byp_data_sel0[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3)  & thread0_w3 & ld_inst_vld_w3 ;
6010
//assign  lmq_byp_data_sel0[1] = st_inst_vld_e & thread0_e & ~ifu_lsu_casa_e & ~fraw_annul0 ;
6011
// Timing fix - at most ld will also update the bypass buffer also.
6012
//assign  lmq_byp_data_sel0[1] = memref_e & thread0_e & ~ifu_lsu_casa_e & ~fraw_annul0 ; //bug3009
6013
assign  lmq_byp_data_sel0[1] =  ~lmq_byp_data_sel0[0] & memref_e & thread0_e & ~ifu_lsu_casa_e &
6014
                        ~(fraw_annul0 | fraw_annul0_d1 | ldst_miss0 | ldst_miss0_d1); // Bug 3053,3180
6015
//assign  lmq_byp_data_sel0[1] = mref_vld0_d1 & thread0_e & ~ifu_lsu_casa_e & ~(fraw_annul0 | fraw_annul0_d1); // Bug 3053
6016
//assign  lmq_byp_data_sel0[1] = memref_e & thread0_e & ~ifu_lsu_casa_e & ~(fraw_annul0 | fraw_annul0_d1);
6017
assign  lmq_byp_data_sel0[2] = ~(|lmq_byp_data_sel0[1:0]) & casa_g & thread0_g & lsu_inst_vld_w & ~fraw_annul0_d1 ;
6018
assign  lmq_byp_data_sel0[3] = |lmq_byp_ldxa_sel0[2:0];
6019
//assign  lmq_byp_data_sel0[3] = |lmq_byp_ldxa_sel0[3:0];
6020
 
6021
// Thread1
6022
assign  lmq_byp_ldxa_sel1[0] = ifu_ldxa_vld & ifu_ldxa_thread1_w2 ;
6023
//assign  lmq_byp_ldxa_sel1[1] = tlu_ldxa_vld & tlu_ldxa_thread1_w2 ; 
6024
assign  lmq_byp_ldxa_sel1[1] = spu_ldxa_vld & spu_ldxa_thread1_w2 ;
6025
assign  lmq_byp_ldxa_sel1[2] = (lsu_asi_rd_en_w2 & thread1_w2) | ldxa_tlbrd1_w3 ;
6026
 
6027
assign  lmq_byp_data_sel1[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread1_w3 ;
6028
assign  lmq_byp_data_sel1[1] = ~lmq_byp_data_sel1[0] & memref_e & thread1_e & ~ifu_lsu_casa_e &
6029
                        ~(fraw_annul1 | fraw_annul1_d1 | ldst_miss1 | ldst_miss1_d1); // Bug 3053,3180
6030
//assign  lmq_byp_data_sel1[1] = memref_e & thread1_e & ~ifu_lsu_casa_e & ~fraw_annul1; // bug3009
6031
//assign  lmq_byp_data_sel1[1] = mref_vld1_d1 & thread1_e & ~ifu_lsu_casa_e & ~(fraw_annul1 | fraw_annul1_d1);
6032
//assign  lmq_byp_data_sel1[1] = memref_e & thread1_e & ~ifu_lsu_casa_e & ~(fraw_annul1 | fraw_annul1_d1); // Bug 3053
6033
assign  lmq_byp_data_sel1[2] =  ~(|lmq_byp_data_sel1[1:0]) & casa_g & thread1_g & lsu_inst_vld_w & ~fraw_annul1_d1 ;
6034
assign  lmq_byp_data_sel1[3] = |lmq_byp_ldxa_sel1[2:0];
6035
 
6036
// Thread2
6037
assign  lmq_byp_ldxa_sel2[0] = ifu_ldxa_vld & ifu_ldxa_thread2_w2 ;
6038
//assign  lmq_byp_ldxa_sel2[1] = tlu_ldxa_vld & tlu_ldxa_thread2_w2 ; 
6039
assign  lmq_byp_ldxa_sel2[1] = spu_ldxa_vld & spu_ldxa_thread2_w2 ;
6040
assign  lmq_byp_ldxa_sel2[2] = (lsu_asi_rd_en_w2 & thread2_w2) | ldxa_tlbrd2_w3 ;
6041
 
6042
assign  lmq_byp_data_sel2[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread2_w3 ;
6043
//assign  lmq_byp_data_sel2[1] = memref_e & thread2_e & ~ifu_lsu_casa_e & ~fraw_annul2; // bug3009
6044
assign  lmq_byp_data_sel2[1] = ~lmq_byp_data_sel2[0] & memref_e & thread2_e & ~ifu_lsu_casa_e &
6045
                        ~(fraw_annul2 | fraw_annul2_d1 | ldst_miss2 | ldst_miss2_d1); // Bug 3053,3180
6046
//assign  lmq_byp_data_sel2[1] = memref_e & thread2_e & ~ifu_lsu_casa_e & ~(fraw_annul2 | fraw_annul2_d1); // Bug 3053
6047
assign  lmq_byp_data_sel2[2] =  ~(|lmq_byp_data_sel2[1:0]) & casa_g & thread2_g & lsu_inst_vld_w & ~fraw_annul2_d1 ;
6048
assign  lmq_byp_data_sel2[3] = |lmq_byp_ldxa_sel2[2:0];
6049
 
6050
// Thread3
6051
assign  lmq_byp_ldxa_sel3[0] = ifu_ldxa_vld & ifu_ldxa_thread3_w2 ;
6052
//assign  lmq_byp_ldxa_sel3[1] = tlu_ldxa_vld & tlu_ldxa_thread3_w2 ; 
6053
assign  lmq_byp_ldxa_sel3[1] = spu_ldxa_vld & spu_ldxa_thread3_w2 ;
6054
assign  lmq_byp_ldxa_sel3[2] =  (lsu_asi_rd_en_w2 & thread3_w2) | ldxa_tlbrd3_w3 ;
6055
 
6056
assign  lmq_byp_data_sel3[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread3_w3 ;
6057
assign  lmq_byp_data_sel3[1] = ~lmq_byp_data_sel3[0] & memref_e & thread3_e & ~ifu_lsu_casa_e &
6058
                        ~(fraw_annul3 | fraw_annul3_d1 | ldst_miss3 | ldst_miss3_d1); // Bug 3053,3180
6059
//assign  lmq_byp_data_sel3[1] = memref_e & thread3_e & ~ifu_lsu_casa_e & ~(fraw_annul3 | fraw_annul3_d1); // Bug 3053
6060
assign  lmq_byp_data_sel3[2] = ~(|lmq_byp_data_sel3[1:0]) & casa_g & thread3_g & lsu_inst_vld_w & ~fraw_annul3_d1 ;
6061
assign  lmq_byp_data_sel3[3] = |lmq_byp_ldxa_sel3[2:0];
6062
 
6063
 
6064
dff #(4)  ff_lmq_byp_data_raw_sel_d1 (
6065
        .din    ({lmq_byp_data_sel3[0], lmq_byp_data_sel2[0],
6066
                  lmq_byp_data_sel1[0], lmq_byp_data_sel0[0]}),
6067
        .q      (lmq_byp_data_raw_sel_d1[3:0]),
6068
        .clk    (clk),
6069
        .se     (se),       .si (),          .so ()
6070
        );
6071
 
6072
dff #(4)  ff_lmq_byp_data_raw_sel_d2 (
6073
        .din    (lmq_byp_data_raw_sel_d1[3:0]),
6074
        .q      (lmq_byp_data_raw_sel_d2[3:0]),
6075
        .clk    (clk),
6076
        .se     (se),       .si (),          .so ()
6077
        );
6078
 
6079
wire            lsu_irf_raw_byp_e;
6080
// Includes both ldxa and raw bypass. 
6081
assign  lsu_irf_raw_byp_e  =
6082
  ~l2fill_vld_e    &      // no dfq fill
6083
  ~(memref_e) ; // no ld/st in pipe. 
6084
  //~(ld_inst_vld_e | st_inst_vld_e) ; // no ld/st in pipe. 
6085
 
6086
// bug 5379 plus misc (randomize selection to prevent deadlock.
6087
wire [3:0] bypass_sel ;
6088
assign  bypass_sel[0] = lsu_dcache_rand[0] ?
6089
        ldbyp0_vld : (ldbyp0_vld & ~(ldbyp3_vld | ldbyp2_vld | ldbyp1_vld)) ;
6090
assign  bypass_sel[1] = lsu_dcache_rand[0] ?
6091
        (ldbyp1_vld & ~ldbyp0_vld) : (ldbyp1_vld & ~(ldbyp3_vld | ldbyp2_vld)) ;
6092
assign  bypass_sel[2] = lsu_dcache_rand[0] ?
6093
        (ldbyp2_vld & ~(ldbyp0_vld | ldbyp1_vld)) : (ldbyp2_vld & ~ldbyp3_vld) ;
6094
assign  bypass_sel[3] = lsu_dcache_rand[0] ?
6095
        (ldbyp3_vld & ~(ldbyp0_vld | ldbyp1_vld | ldbyp2_vld)) : ldbyp3_vld ;
6096
 
6097
assign ld_thrd_byp_sel_e[0] = bypass_sel[0] & lsu_irf_raw_byp_e ;
6098
assign ld_thrd_byp_sel_e[1] = bypass_sel[1] & lsu_irf_raw_byp_e ;
6099
assign ld_thrd_byp_sel_e[2] = bypass_sel[2] & lsu_irf_raw_byp_e ;
6100
assign ld_thrd_byp_sel_e[3] = bypass_sel[3] & lsu_irf_raw_byp_e ;
6101
 
6102
/*assign ld_thrd_byp_sel_e[0] = ldbyp0_vld & lsu_irf_raw_byp_e ;
6103
assign ld_thrd_byp_sel_e[1] = ldbyp1_vld & lsu_irf_raw_byp_e &
6104
      ~ldbyp0_vld ;
6105
assign ld_thrd_byp_sel_e[2] = ldbyp2_vld & lsu_irf_raw_byp_e &
6106
      ~(ldbyp0_vld | ldbyp1_vld);
6107
assign ld_thrd_byp_sel_e[3] = ldbyp3_vld & lsu_irf_raw_byp_e &
6108
      ~(ldbyp0_vld | ldbyp1_vld | ldbyp2_vld) ; */
6109
 
6110
 
6111
   //assign lsu_ld_thrd_byp_sel_e[2:0] = ld_thrd_byp_sel_e[2:0];
6112
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b2 (.a(ld_thrd_byp_sel_e[2]), .z(lsu_ld_thrd_byp_sel_e[2]));
6113
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b1 (.a(ld_thrd_byp_sel_e[1]), .z(lsu_ld_thrd_byp_sel_e[1]));
6114
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b0 (.a(ld_thrd_byp_sel_e[0]), .z(lsu_ld_thrd_byp_sel_e[0]));
6115
 
6116
dff #(4)  tbyp_stgd1 (
6117
        .din    (ld_thrd_byp_sel_e[3:0]),
6118
        .q      (ld_thrd_byp_sel_m[3:0]),
6119
        .clk    (clk),
6120
        .se     (se),       .si (),          .so ()
6121
        );
6122
 
6123
//assign ld_thrd_byp_mxsel_m[2:0]  =    ld_thrd_byp_sel_m[2:0];
6124
//assign ld_thrd_byp_mxsel_m[3]    =  ~|ld_thrd_byp_sel_m[2:0];
6125
 
6126
assign ld_thrd_byp_mxsel_m[0]  =    ld_thrd_byp_sel_m[0] & ~rst_tri_en;
6127
assign ld_thrd_byp_mxsel_m[1]  =    ld_thrd_byp_sel_m[1] & ~rst_tri_en;
6128
assign ld_thrd_byp_mxsel_m[2]  =    ld_thrd_byp_sel_m[2] & ~rst_tri_en;
6129
assign ld_thrd_byp_mxsel_m[3]  =    (~|ld_thrd_byp_sel_m[2:0]) |  rst_tri_en;
6130
 
6131
dff #(4)  tbyp_stgd2 (
6132
        .din    (ld_thrd_byp_sel_m[3:0]),
6133
        .q      (ld_thrd_byp_sel_g[3:0]),
6134
        .clk    (clk),
6135
        .se     (se),       .si (),          .so ()
6136
        );
6137
 
6138
  //should move to M stage 
6139
 
6140
//assign ld_thrd_byp_mxsel_g[2:0]  =    ld_thrd_byp_sel_g[2:0];
6141
//assign ld_thrd_byp_mxsel_g[3]    =  ~|ld_thrd_byp_sel_g[2:0];
6142
 
6143
assign  lmq_byp_ldxa_mxsel0[1:0] =   lmq_byp_ldxa_sel0[1:0];
6144
assign  lmq_byp_ldxa_mxsel0[2]   = ~|lmq_byp_ldxa_sel0[1:0];
6145
assign  lmq_byp_ldxa_mxsel1[1:0] =   lmq_byp_ldxa_sel1[1:0];
6146
assign  lmq_byp_ldxa_mxsel1[2]   = ~|lmq_byp_ldxa_sel1[1:0];
6147
assign  lmq_byp_ldxa_mxsel2[1:0] =   lmq_byp_ldxa_sel2[1:0];
6148
assign  lmq_byp_ldxa_mxsel2[2]   = ~|lmq_byp_ldxa_sel2[1:0];
6149
assign  lmq_byp_ldxa_mxsel3[1:0] =   lmq_byp_ldxa_sel3[1:0];
6150
assign  lmq_byp_ldxa_mxsel3[2]   = ~|lmq_byp_ldxa_sel3[1:0];
6151
 
6152
assign  lmq_byp_data_mxsel0[0] =   lmq_byp_data_sel0[0] & ~rst_tri_en |  sehold;
6153
assign  lmq_byp_data_mxsel0[1] =   lmq_byp_data_sel0[1] & ~rst_tri_en & ~sehold;
6154
assign  lmq_byp_data_mxsel0[2] =   lmq_byp_data_sel0[2] & ~rst_tri_en & ~sehold;
6155
assign  lmq_byp_data_mxsel0[3]   = (~|lmq_byp_data_sel0[2:0] | rst_tri_en) & ~sehold;
6156
 
6157
assign  lmq_byp_data_mxsel1[0] =   lmq_byp_data_sel1[0] & ~rst_tri_en |  sehold;
6158
assign  lmq_byp_data_mxsel1[1] =   lmq_byp_data_sel1[1] & ~rst_tri_en & ~sehold;
6159
assign  lmq_byp_data_mxsel1[2] =   lmq_byp_data_sel1[2] & ~rst_tri_en & ~sehold;
6160
assign  lmq_byp_data_mxsel1[3]   = (~|lmq_byp_data_sel1[2:0] | rst_tri_en) & ~sehold;
6161
 
6162
assign  lmq_byp_data_mxsel2[0] =   lmq_byp_data_sel2[0] & ~rst_tri_en |  sehold;
6163
assign  lmq_byp_data_mxsel2[1] =   lmq_byp_data_sel2[1] & ~rst_tri_en & ~sehold;
6164
assign  lmq_byp_data_mxsel2[2] =   lmq_byp_data_sel2[2] & ~rst_tri_en & ~sehold;
6165
assign  lmq_byp_data_mxsel2[3]   = (~|lmq_byp_data_sel2[2:0] | rst_tri_en) & ~sehold;
6166
 
6167
assign  lmq_byp_data_mxsel3[0] =   lmq_byp_data_sel3[0] & ~rst_tri_en |  sehold;
6168
assign  lmq_byp_data_mxsel3[1] =   lmq_byp_data_sel3[1] & ~rst_tri_en & ~sehold;
6169
assign  lmq_byp_data_mxsel3[2] =   lmq_byp_data_sel3[2] & ~rst_tri_en & ~sehold;
6170
assign  lmq_byp_data_mxsel3[3]   = (~|lmq_byp_data_sel3[2:0] | rst_tri_en) & ~sehold;
6171
 
6172
//=========================================================================================
6173
//      Error Based Traps/Reporting
6174
//
6175
//=========================================================================================
6176
 
6177
// !!! ORIGINAL ABOVE !!!
6178
// Error Table for Queue
6179
// ** In all cases; squash writes to irf.
6180
//                              | Error Reporting       | Trap ?        | 
6181
// ifu_lsu_asi_rd_unc           | NA;done by ifu        | daccess-error |
6182
// tte_data_perror_unc_w2       | sync;in pipe          | daccess-error |
6183
// tte_data_perror_corr_w2      | sync;in pipe          | dmmu-miss     |
6184
// asi_tte_data_perror_w2       | async;out of Q        | daccess-error |
6185
// asi_tte_tag_perror_w2        | async;out of Q        | daccess-error |
6186
 
6187
assign  squash_byp_cmplt[0] =
6188
        ((cam_perr_unc0  |
6189
        asi_data_perr0 |
6190
        asi_tag_perr0  |
6191
        ifu_unc_err0   ) & lsu_nceen_d1[0]) |
6192
        pend_atm_ld_ue[0] |
6193
        spubyp0_trap ; // Bug 3873. add spu trap squash. (change reverted).
6194
assign  squash_byp_cmplt[1] =
6195
        ((cam_perr_unc1 | asi_data_perr1 | asi_tag_perr1 | ifu_unc_err1) & lsu_nceen_d1[1]) |
6196
        pend_atm_ld_ue[1] | spubyp1_trap ;
6197
assign  squash_byp_cmplt[2] =
6198
        ((cam_perr_unc2 | asi_data_perr2 | asi_tag_perr2 | ifu_unc_err2) & lsu_nceen_d1[2]) |
6199
        pend_atm_ld_ue[2] | spubyp2_trap ;
6200
assign  squash_byp_cmplt[3] =
6201
        ((cam_perr_unc3 | asi_data_perr3 | asi_tag_perr3 | ifu_unc_err3) & lsu_nceen_d1[3]) |
6202
        pend_atm_ld_ue[3] | spubyp3_trap ;
6203
 
6204
assign  cam_perr_unc_e =
6205
  (ld_thrd_byp_sel_e[0] & cam_perr_unc0) |
6206
  (ld_thrd_byp_sel_e[1] & cam_perr_unc1) |
6207
  (ld_thrd_byp_sel_e[2] & cam_perr_unc2) |
6208
  (ld_thrd_byp_sel_e[3] & cam_perr_unc3) ;
6209
assign  asi_data_perr_e =
6210
  (ld_thrd_byp_sel_e[0] & asi_data_perr0) |
6211
  (ld_thrd_byp_sel_e[1] & asi_data_perr1) |
6212
  (ld_thrd_byp_sel_e[2] & asi_data_perr2) |
6213
  (ld_thrd_byp_sel_e[3] & asi_data_perr3) ;
6214
assign  asi_tag_perr_e =
6215
  (ld_thrd_byp_sel_e[0] & asi_tag_perr0) |
6216
  (ld_thrd_byp_sel_e[1] & asi_tag_perr1) |
6217
  (ld_thrd_byp_sel_e[2] & asi_tag_perr2) |
6218
  (ld_thrd_byp_sel_e[3] & asi_tag_perr3) ;
6219
assign  ifu_unc_err_e =
6220
  (ld_thrd_byp_sel_e[0] & ifu_unc_err0) |
6221
  (ld_thrd_byp_sel_e[1] & ifu_unc_err1) |
6222
  (ld_thrd_byp_sel_e[2] & ifu_unc_err2) |
6223
  (ld_thrd_byp_sel_e[3] & ifu_unc_err3) ;
6224
wire atm_st_unc_err_e,atm_st_unc_err_m,atm_st_unc_err_g ;
6225
assign  atm_st_unc_err_e =
6226
(atm_st_cmplt0 & pend_atm_ld_ue[0]) |
6227
(atm_st_cmplt1 & pend_atm_ld_ue[1]) |
6228
(atm_st_cmplt2 & pend_atm_ld_ue[2]) |
6229
(atm_st_cmplt3 & pend_atm_ld_ue[3]) ;
6230
 
6231
dff #(5)  stgm_tlberr (
6232
        .din    ({cam_perr_unc_e,asi_data_perr_e,
6233
                asi_tag_perr_e,ifu_unc_err_e,atm_st_unc_err_e}),
6234
        .q      ({cam_perr_unc_m,asi_data_perr_m,
6235
                asi_tag_perr_m,ifu_unc_err_m,atm_st_unc_err_m}),
6236
        .clk    (clk),
6237
        .se     (se),       .si (),          .so ()
6238
        );
6239
 
6240
 
6241
dff #(5)  stgg_tlberr (
6242
        .din    ({cam_perr_unc_m,asi_data_perr_m,
6243
                asi_tag_perr_m,ifu_unc_err_m,atm_st_unc_err_m}),
6244
        .q      ({cam_perr_unc_g,asi_data_perr_g,
6245
                asi_tag_perr_g,ifu_unc_err_g,atm_st_unc_err_g}),
6246
        .clk    (clk),
6247
        .se     (se),       .si (),          .so ()
6248
        );
6249
 
6250
assign  lsu_tlb_asi_data_perr_g = asi_data_perr_g ;
6251
assign  lsu_tlb_asi_tag_perr_g = asi_tag_perr_g ;
6252
 
6253
// Asynchronous Trap Reporting to TLU (Traps are still precise).
6254
// This version of nceen is meant specifically for trap reporting
6255
// out of the asi queue.
6256
wire nceen_m, nceen_g ;
6257
assign nceen_m =
6258
        (ld_thrd_byp_sel_m[0] & lsu_nceen_d1[0]) |
6259
        (ld_thrd_byp_sel_m[1] & lsu_nceen_d1[1]) |
6260
        (ld_thrd_byp_sel_m[2] & lsu_nceen_d1[2]) |
6261
        (ld_thrd_byp_sel_m[3] & lsu_nceen_d1[3]) ;
6262
 
6263
wire nceen_dfq_m,nceen_dfq_g ;
6264
 
6265
// This version is meant specifically for lds reporting traps
6266
// from the dfq.
6267
assign  nceen_dfq_m =
6268
        ((~dfq_tid_m[1] & ~dfq_tid_m[0]) & lsu_nceen_d1[0]) |
6269
        ((~dfq_tid_m[1] &  dfq_tid_m[0]) & lsu_nceen_d1[1]) |
6270
        (( dfq_tid_m[1] & ~dfq_tid_m[0]) & lsu_nceen_d1[2]) |
6271
        (( dfq_tid_m[1] &  dfq_tid_m[0]) & lsu_nceen_d1[3]) ;
6272
 
6273
dff #(2)  trpen_stg (
6274
        .din    ({nceen_m,nceen_dfq_m}),
6275
        .q      ({nceen_g,nceen_dfq_g}),
6276
        .clk    (clk),
6277
        .se     (se),       .si (),          .so ()
6278
        );
6279
 
6280
 
6281
// l2c/dram
6282
wire    atm_ld_w_uerr_m ;
6283
dff #(1)  atmldu_stm (
6284
        .din    (atm_ld_w_uerr),
6285
        .q      (atm_ld_w_uerr_m),
6286
        .clk    (clk),
6287
        .se     (se),       .si (),          .so ()
6288
        );
6289
 
6290
wire    pmem_unc_error_m,pmem_unc_error_g ;
6291
assign  pmem_unc_error_m =
6292
        l2_unc_error_m &  // bug3666
6293
        ~atm_ld_w_uerr_m ; //bug4048 - squash for atm ld with error.
6294
 
6295
wire    pmem_unc_error_tmp ;
6296
dff #(1)  pmem_stg (
6297
        .din    (pmem_unc_error_m),
6298
        .q      (pmem_unc_error_tmp),
6299
        .clk    (clk),
6300
        .se     (se),       .si (),          .so ()
6301
        );
6302
 
6303
assign  pmem_unc_error_g =
6304
        (pmem_unc_error_tmp | bld_unc_err_pend_g) & ~bld_squash_err_g ;
6305
 
6306
wire    async_ttype_vld_g ;
6307
wire [6:0] async_ttype_g ;
6308
wire [1:0] async_tid_g ;
6309
 
6310
//wire  st_dtlb_perr_en ;
6311
//assign        st_dtlb_perr_en = st_inst_vld_unflushed & tte_data_perror_unc & nceen_pipe_g ;
6312
 
6313
// traps are not to be taken if enables are not set. The asi rds of the tlb must
6314
// thus complete as usual.
6315
assign  async_ttype_vld_g =
6316
        (((cam_perr_unc_g | asi_data_perr_g | asi_tag_perr_g | ifu_unc_err_g) & nceen_g) |
6317
                (pmem_unc_error_g & nceen_dfq_g)) | // Bug 3335,3518
6318
        atm_st_unc_err_g |      // Bug 4048
6319
        //lsu_defr_trp_taken_g |
6320
        //st_dtlb_perr_en |
6321
        //cam_perr_corr_g |
6322
        spubyp_trap_active_g ;
6323
 
6324
wire [6:0]       async_ttype_m ;
6325
assign  async_ttype_m[6:0] =
6326
        spubyp_trap_active_m ? spubyp_ttype[6:0] : 7'h32 ;
6327
 
6328
dff #(7)  attype_stg (
6329
        .din    (async_ttype_m[6:0]),
6330
        .q      (async_ttype_g[6:0]),
6331
        .clk    (clk),
6332
        .se     (se),       .si (),          .so ()
6333
        );
6334
 
6335
wire [1:0]       async_err_tid_e,async_err_tid_m,async_err_tid_g ;
6336
assign  async_err_tid_e[0] = ld_thrd_byp_sel_e[1] | ld_thrd_byp_sel_e[3] ;
6337
assign  async_err_tid_e[1] = ld_thrd_byp_sel_e[3] | ld_thrd_byp_sel_e[2] ;
6338
 
6339
dff #(2)  ldbyperr_stgm (
6340
        .din    (async_err_tid_e[1:0]),
6341
        .q      (async_err_tid_m[1:0]),
6342
        .clk    (clk),
6343
        .se     (se),       .si (),          .so ()
6344
        );
6345
 
6346
dff #(2)  ldbyperr_stgg (
6347
        .din    (async_err_tid_m[1:0]),
6348
        .q      (async_err_tid_g[1:0]),
6349
        .clk    (clk),
6350
        .se     (se),       .si (),          .so ()
6351
        );
6352
 
6353
wire    sel_dfq_tid ;
6354
assign  sel_dfq_tid = pmem_unc_error_g | atm_st_unc_err_g ;
6355
assign  async_tid_g[1:0] =
6356
        //lsu_defr_trp_taken_g ? thrid_g[1:0] : // Bug 4660 - remove.
6357
        sel_dfq_tid ? // Bug 3335,4048
6358
        dfq_tid_g[1:0] : async_err_tid_g[1:0] ;
6359
 
6360
// Delay async_trp interface to TLU by a cycle.
6361
 
6362
dff #(10)  asynctrp_stgw2 (
6363
        .din    ({async_ttype_vld_g,async_tid_g[1:0],async_ttype_g[6:0]}),
6364
        .q      ({lsu_tlu_async_ttype_vld_w2,lsu_tlu_async_tid_w2[1:0],
6365
                lsu_tlu_async_ttype_w2[6:0]}),
6366
        .clk    (clk),
6367
        .se     (se),       .si (),          .so ()
6368
        );
6369
 
6370
// Asynchronous Error Reporting to IFU 
6371
// Partial.
6372
 
6373
wire  sync_error_sel ;
6374
wire    memref_m ,memref_g;
6375
 
6376
dff #(1) memref_stgg (
6377
        .din    (memref_m),
6378
        .q      (memref_g),
6379
        .clk    (clk),
6380
        .se     (se),       .si (),          .so ()
6381
        );
6382
 
6383
//assign  sync_error_sel = tte_data_perror_unc | tte_data_perror_corr ;
6384
 
6385
//for in1 or in2 to be selected, memref_g must be 0.
6386
//in1 is reported thru the bypass/asi queues, in2 thru the dfq.
6387
//So err_addr_sel[0] can be memref_g.
6388
   assign sync_error_sel = memref_g;
6389
 
6390
wire    async_error_sel ;
6391
assign  async_error_sel = asi_data_perr_g | asi_tag_perr_g ;
6392
 
6393
assign  lsu_err_addr_sel[0] =  sync_error_sel & ~rst_tri_en;
6394
assign  lsu_err_addr_sel[1] =  async_error_sel & ~rst_tri_en;
6395
assign  lsu_err_addr_sel[2] = ~(sync_error_sel | async_error_sel) | rst_tri_en;
6396
 
6397
//mux4ds  #(6) async_tlb_index_mx(
6398
//  .in0  (misc_data0[5:0]),
6399
//  .in1  (misc_data1[5:0]),
6400
//  .in2  (misc_data2[5:0]),
6401
//  .in3  (misc_data3[5:0]),
6402
//  .sel0 (ld_thrd_byp_sel_g[0]),
6403
//  .sel1 (ld_thrd_byp_sel_g[1]),
6404
//  .sel2 (ld_thrd_byp_sel_g[2]),
6405
//  .sel3 (ld_thrd_byp_sel_g[3]),
6406
//  .dout (async_tlb_index[5:0])
6407
//   );
6408
 
6409
assign async_tlb_index[5:0] =
6410
  (ld_thrd_byp_sel_g[0] ? misc_data0[5:0] : 6'b0) |
6411
  (ld_thrd_byp_sel_g[1] ? misc_data1[5:0] : 6'b0) |
6412
  (ld_thrd_byp_sel_g[2] ? misc_data2[5:0] : 6'b0) |
6413
  (ld_thrd_byp_sel_g[3] ? misc_data3[5:0] : 6'b0) ;
6414
 
6415
wire    [1:0] err_tid_g ;
6416
//assign  err_tid_g[1:0] =
6417
//  sync_error_sel ? thrid_g[1:0] :
6418
//      async_error_sel ? async_err_tid_g[1:0] : dfill_tid_g[1:0] ;
6419
 
6420
mux3ds #(2) err_tid_mx (
6421
  .in0 (thrid_g[1:0]),
6422
  .in1 (async_err_tid_g[1:0]),
6423
  .in2 (dfill_tid_g[1:0]),
6424
  .sel0(lsu_err_addr_sel[0]),
6425
  .sel1(lsu_err_addr_sel[1]),
6426
  .sel2(lsu_err_addr_sel[2]),
6427
  .dout(err_tid_g[1:0])
6428
                   );
6429
 
6430
// Can shift to m.
6431
//assign  lsu_tlu_derr_tid_g[1:0] = err_tid_g[1:0] ;
6432
 
6433
dff #(2)  errad_stgg (
6434
        .din    (err_tid_g[1:0]),
6435
        .q      (lsu_ifu_error_tid[1:0]),
6436
        .clk    (clk),
6437
        .se     (se),       .si (),          .so ()
6438
        );
6439
 
6440
assign  lsu_ifu_io_error = //l2_unc_error_w2 & lsu_ifu_err_addr_b39 ;
6441
// extend for bld to io space.
6442
(l2_unc_error_w2 | bld_unc_err_pend_w2) & lsu_ifu_err_addr_b39 & ~bld_squash_err_w2 ;
6443
 
6444
 
6445
//=========================================================================================
6446
 
6447
 
6448
wire stxa_internal_cmplt ;
6449
assign  stxa_internal_cmplt =
6450
stxa_internal &
6451
~(intrpt_disp_asi_g | stxa_stall_asi_g | (ifu_nontlb_asi_g & ~ifu_asi42_flush_g) | tlb_lng_ltncy_asi_g) &
6452
                                        lsu_inst_vld_w & ~dctl_early_flush_w ;
6453
                                        //lsu_inst_vld_w & ~dctl_flush_pipe_w ;
6454
 
6455
// Need to add stxa's related to ifu non-tlb asi.
6456
dff  stxa_int_d1 (
6457
        .din    (stxa_internal_cmplt),
6458
        //.din    (stxa_internal & ~(stxa_stall_asi_g | tlb_lng_ltncy_asi_g) & lsu_inst_vld_w),
6459
        .q      (stxa_internal_d1),
6460
        .clk    (clk),
6461
        .se     (se),       .si (),          .so ()
6462
        );
6463
 
6464
dff  stxa_int_d2 (
6465
        .din    (stxa_internal_d1),
6466
        .q      (stxa_internal_d2),
6467
        .clk    (clk),
6468
        .se     (se),       .si (),          .so ()
6469
        );
6470
 
6471
 
6472
//=========================================================================================
6473
//  Replacement Algorithm for Cache
6474
//=========================================================================================
6475
 
6476
 
6477
 
6478
// Increment Condition.
6479
wire    lfsr_incr, lfsr_incr_d1 ;
6480
assign  lfsr_incr =
6481
        ld_inst_vld_g & ~lsu_way_hit_or & ~ldxa_internal &
6482
        ~ncache_pcx_rq_g ; // must be cacheable
6483
 
6484
dff  lfsrd1_ff (
6485
        .din    (lfsr_incr),
6486
        .q      (lfsr_incr_d1),
6487
        .clk    (clk),
6488
        .se     (se),       .si (),          .so ()
6489
        );
6490
 
6491
wire    lfsr_rst ;
6492
assign  lfsr_rst =
6493
                reset           |
6494
                ~gdbginit_l     | // debug init.
6495
                dc_direct_map   ; // direct map mode will reset.
6496
 
6497
// Bug 4027
6498
lsu_dcache_lfsr lfsr(.out (lsu_dcache_rand[1:0]),
6499
                                           .clk  (clk),
6500
                                           .advance (lfsr_incr_d1),
6501
                                           .reset (lfsr_rst),
6502
                                           .se (se),
6503
                                           .si (),
6504
                                           .so ());
6505
 
6506
//assign  lsu_dcache_rand[1:0]  =  dcache_rand[1:0]; 
6507
 
6508
 
6509
/*assign  dcache_rand_new[1:0] = dcache_rand[1:0] + {1'b0, lsu_ld_miss_wb} ;
6510
dffre #(2) drand (
6511
        .din    (dcache_rand_new[1:0]),
6512
        .q      (dcache_rand[1:0]),
6513
        .rst  (reset), .en    (lsu_ld_miss_wb),
6514
        .clk    (clk),
6515
        .se     (se),       .si (),          .so ()
6516
        );
6517
 
6518
assign  lsu_dcache_rand[1:0]  =  dcache_rand[1:0]; */
6519
 
6520
//=========================================================================================
6521
//  Packet Assembly
6522
//=========================================================================================
6523
 
6524
assign lsu_encd_way_hit[0] = cache_way_hit_buf1[1] | cache_way_hit_buf1[3] ;
6525
assign lsu_encd_way_hit[1] = cache_way_hit_buf1[2] | cache_way_hit_buf1[3] ;
6526
 
6527
//assign lsu_way_hit_or  =  |lsu_way_hit[3:0];
6528
assign lsu_way_hit_or  =  |cache_way_hit_buf1[3:0]; // Bug 3940
6529
 
6530
//assign  stb_byp_pkt_vld_e = st_inst_vld_e & ~(ldsta_internal_e & alt_space_e);
6531
assign  ld_pcx_pkt_vld_e = ld_inst_vld_e & ~(ldsta_internal_e & alt_space_e);
6532
 
6533
 
6534
dff #(5)  pktctl_stgm (
6535
        .din    ({ifu_lsu_ldst_dbl_e, ld_pcx_pkt_vld_e,
6536
    ifu_lsu_casa_e,ifu_lsu_ldstub_e,ifu_lsu_swap_e}),
6537
        .q      ({ldst_dbl_m, ld_pcx_pkt_vld_m,
6538
    casa_m,ldstub_m,swap_m}),
6539
        .clk    (clk),
6540
        .se     (se),       .si (),          .so ()
6541
        );
6542
 
6543
assign  atomic_m = casa_m | ldstub_m | swap_m ;
6544
 
6545
dff #(6) pktctl_stgg (
6546
        .din    ({ldst_dbl_m, ld_pcx_pkt_vld_m,
6547
    casa_m,ldstub_m,swap_m,atomic_m}),
6548
        .q      ({ldst_dbl_g, ld_pcx_pkt_vld_g,
6549
    casa_g,ldstub_g,swap_g,atomic_g}),
6550
        .clk    (clk),
6551
        .se     (se),       .si (),          .so ()
6552
        );
6553
 
6554
dff #(2) pktctl_stgw2 (
6555
        .din    ({ldd_force_l2access_g, atomic_g}),
6556
        .q      ({ldd_force_l2access_w2,atomic_w2}),
6557
        .clk    (clk),
6558
        .se     (se),       .si (),          .so ()
6559
        );
6560
 
6561
dff #(2) pktctl_stgw3 (
6562
        .din    ({ldd_force_l2access_w2, atomic_w2}),
6563
        .q      ({ldd_force_l2access_w3, atomic_w3}),
6564
        .clk    (clk),
6565
        .se     (se),       .si (),          .so ()
6566
        );
6567
 
6568
assign  lsu_ldstub_g = ldstub_g ;
6569
assign  lsu_swap_g = swap_g ;
6570
 
6571
// Choose way for load. If load hits in dcache but sent out to xbar because
6572
// of partial raw then need to use hit way else use random. Similarly, dcache
6573
// parity error will force a miss and fill to same way.
6574
 
6575
// Moved to qctl1
6576
// For direct-map mode, assume that addition set-index bits 12:11 are
6577
// used to file line in set.
6578
//assign  ld_way[1:0] = 
6579
//    (|lsu_way_hit[3:0]) ? 
6580
//        {lsu_encd_way_hit[1],lsu_encd_way_hit[0]} : 
6581
//              lsu_ld_sec_hit_l2access_g ? lsu_ld_sec_hit_wy_g[1:0] :
6582
//                      (dc_direct_map ? ldst_va_g[12:11] : dcache_rand[1:0]) ;
6583
 
6584
// set to 011 for atomic - only cas encoding used for pcx pkt.
6585
assign  ld_rq_type[2:0] =
6586
    atomic_g ? 3'b011 :       // cas pkt 2/ldstub/swap 
6587
//        (ldst_dbl_g & st_inst_vld_g & quad_asi_g) ? 3'b001 : // stquad - label as store.
6588
    3'b000 ;      // normal load
6589
 
6590
 
6591
//assign  lmq_pkt_vld_g = ld_pcx_pkt_vld_g | (ldst_dbl_g & st_inst_vld_unflushed) | pref_inst_g ; 
6592
assign  lmq_pkt_vld_g = ld_pcx_pkt_vld_g | pref_inst_g ;
6593
 
6594
// Moved to qctl1
6595
// 2'b01 encodes ld as st-quad pkt2. 2'b00 needed for cas-pkt2
6596
//assign  lmq_pkt_way_g[1:0] = 
6597
//(ldst_dbl_g & st_inst_vld_unflushed & quad_asi_g) ? 2'b01 :
6598
//        casa_g ? 2'b00 : ld_way[1:0] ;
6599
 
6600
// ld is 128b request.
6601
wire    qword_access_g;
6602
assign  qword_access_g =
6603
(quad_asi_g | blk_asi_g ) & lsu_alt_space_g & ld_inst_vld_unflushed ;
6604
 
6605
assign  lsu_quad_word_access_g = qword_access_g ;
6606
 
6607
wire  fp_ld_inst_g ;
6608
assign  fp_ld_inst_g  = fp_ldst_g & ld_inst_vld_g ;
6609
 
6610
wire  ldst_sz_b0_g ;
6611
assign  ldst_sz_b0_g =
6612
  ldst_sz_g[0] &
6613
  ~(ldst_dbl_g & ~fp_ldst_g &
6614
    (~lsu_alt_space_g | (lsu_alt_space_g & ~quad_asi_g))) ;
6615
                // word for ld-dbl
6616
 
6617
wire    asi_real_iomem_m,asi_real_iomem_g ;
6618
assign  asi_real_iomem_m =
6619
(dtlb_bypass_m & (phy_use_ec_asi_m | phy_byp_ec_asi_m) & lsu_alt_space_m) ;
6620
 
6621
dff #(1) stgg_asir (
6622
        .din    (asi_real_iomem_m),
6623
        .q      (asi_real_iomem_g),
6624
        .clk    (clk),
6625
        .se     (se),       .si (),          .so ()
6626
        );
6627
 
6628
assign  ncache_pcx_rq_g   =
6629
  atomic_g    |   // cas,ldstub,swap  
6630
  asi_real_iomem_g | // real_mem, real_io
6631
  ~dcache_enable_g | // dcache disabled : Bug 5174 (accidental removal)
6632
  ((tlb_pgnum[39] & ~lsu_dtlb_bypass_g & tlb_cam_hit_g) | // IO - tlb not in bypass
6633
   (tlb_pgnum[39] &  lsu_dtlb_bypass_g)) |    // IO - tlb bypass
6634
  (~lsu_tte_data_cp_g & tlb_cam_hit_g) |      // cp bit is clear
6635
  ((quad_asi_g | binit_quad_asi_g | blk_asi_g)  & lsu_alt_space_g & ldst_dbl_g & ld_inst_vld_unflushed) |  // quad-ld
6636
  pref_inst_g ; // pref will not alloc. in L2 dir
6637
 
6638
//wire  dflush_ld_g ;
6639
//assign  dflush_ld_g = dflush_asi_g & lsu_alt_space_g ;
6640
 
6641
// st-quad pkt1 and pkt2 need different addresses !!
6642
// ** should be able to reduce the width, rd2,stquad,lmq_pkt_way ** 
6643
//assign  ld_pcx_pkt_g[`LMQ_WIDTH-1:0] =
6644
 
6645
//bug3601
6646
//dbl_data_return will become lmq_ldd
6647
//it includes quad ld, int ldd, block ld, all these cases need return data twice.    
6648
   wire dbl_data_return;
6649
   assign dbl_data_return = ldst_dbl_g & ~ (fp_ldst_g & ~ (blk_asi_g & lsu_alt_space_g));
6650
 
6651
assign  ld_pcx_pkt_g[65-1:40] =
6652
  {lmq_pkt_vld_g,
6653
  1'b0,                  //dflush_ld_g, bug 4580 
6654
  pref_inst_g,
6655
  fp_ld_inst_g,
6656
  l1hit_sign_extend_g,
6657
  //lsu_bendian_access_g,
6658
  bendian_g,    // l2fill_bendian removed.
6659
  ld_rd_g[4:0], // use rd1 only for now.
6660
  dbl_data_return,  //bug 3601
6661
  //ldst_dbl_g & ~fp_ldst_g,  // rd2 used by ld double.
6662
  {ld_rd_g[4:1],~ld_rd_g[0]}, // rd2 to be used with atomics.
6663
  ld_rq_type[2:0],
6664
  ncache_pcx_rq_g,  // NC.
6665
  //lmq_pkt_way_g[1:0], // replacement way
6666
  2'b00,
6667
  ldst_sz_g[1],ldst_sz_b0_g};
6668
  //{tlb_pgnum[39:10], ldst_va_g[9:0]}};
6669
 
6670
//=========================================================================================
6671
//  Byte Masking for writes
6672
//=========================================================================================
6673
 
6674
// Byte-enables will be generated in cycle prior to fill (E-stage)
6675
// Reads and writes are mutex as array is single-ported.
6676
// byte-enables are handled thru read-modify-writes.
6677
 
6678
// Create 16b Write Mask based on size and va ;
6679
// This is to be put in the DFQ once the DFQ is on-line.
6680
 
6681
 
6682
wire [2:0] dc_waddr_m ;
6683
dff #(4) stgm_addr (
6684
        .din    ({memref_e, dcache_wr_addr_e[2:0]}),
6685
        .q      ({memref_m, dc_waddr_m[2:0]}),
6686
        .clk    (clk),
6687
        .se     (se),       .si (),          .so ()
6688
        );
6689
 
6690
assign  lsu_memref_m = memref_m ;
6691
 
6692
//wire [3:0] rwaddr_enc ;
6693
//assign  rwaddr_enc[3:0] = memref_m ? 
6694
//        lsu_ldst_va_b7_b0_m[3:0] : dc_waddr_m[3:0];
6695
 
6696
wire [2:0] rwaddr_enc ;
6697
assign  rwaddr_enc[2:0] = memref_m ?
6698
        lsu_ldst_va_b7_b0_m[2:0] : dc_waddr_m[2:0];
6699
 
6700
 
6701
   wire [1:0] wr_size;
6702
 
6703
   assign wr_size[1:0] = dcache_wr_size_e[1:0];
6704
 
6705
   wire   wr_hword, wr_word, wr_dword;
6706
 
6707
//assign  wr_byte    = ~wr_size[1] & ~wr_size[0] ; // 01
6708
assign  wr_hword   = ~wr_size[1] &  wr_size[0] ; // 01
6709
assign  wr_word    =  wr_size[1] & ~wr_size[0] ; // 10
6710
assign  wr_dword   =  wr_size[1] &  wr_size[0] ; // 11
6711
 
6712
assign  ldst_byte    = ~ldst_sz_e[1] & ~ldst_sz_e[0] ; // 01
6713
assign  ldst_hword   = ~ldst_sz_e[1] &  ldst_sz_e[0] ; // 01
6714
assign  ldst_word    =  ldst_sz_e[1] & ~ldst_sz_e[0] ; // 10
6715
assign  ldst_dword   =  ldst_sz_e[1] &  ldst_sz_e[0] ; // 11
6716
 
6717
// In Bypass mode, endianness is determined by asi.
6718
// Need to complete this equation.
6719
 
6720
// Note : add MMU disable bypass conditions !!!
6721
assign  tlb_invert_endian_g = lsu_tlb_invert_endian_g & ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
6722
 
6723
// Is qualification with reset needed ?
6724
//assign  l2fill_bendian_g = lsu_l2fill_bendian_g & ~reset;
6725
 
6726
//assign  pstate_cle_m = 
6727
//  thread0_m ? tlu_lsu_pstate_cle[0] :
6728
//    thread1_m ? tlu_lsu_pstate_cle[1] :
6729
//      thread2_m ? tlu_lsu_pstate_cle[2] :
6730
//          tlu_lsu_pstate_cle[3] ;
6731
 
6732
mux4ds  #(1) pstate_cle_e_mux (
6733
        .in0    (tlu_lsu_pstate_cle[0]),
6734
        .in1    (tlu_lsu_pstate_cle[1]),
6735
        .in2    (tlu_lsu_pstate_cle[2]),
6736
        .in3    (tlu_lsu_pstate_cle[3]),
6737
        .sel0   (thread0_e),
6738
        .sel1   (thread1_e),
6739
        .sel2   (thread2_e),
6740
        .sel3   (thread3_e),
6741
        .dout   (pstate_cle_e)
6742
);
6743
 
6744
dff #(1) stgm_pstatecle (
6745
        .din    (pstate_cle_e),
6746
        .q      (pstate_cle_m),
6747
        .clk    (clk),
6748
        .se     (se),       .si (),          .so ()
6749
        );
6750
 
6751
dff #(1) stgg_pstatecle (
6752
        .din    (pstate_cle_m),
6753
        .q      (pstate_cle_g),
6754
        .clk    (clk),
6755
        .se     (se),       .si (),          .so ()
6756
        );
6757
 
6758
//SPARC V9 page 52. pstate.cle should only affect implicit ASI   
6759
assign  l1hit_lendian_g =
6760
    ((non_altspace_ldst_g & (pstate_cle_g ^ tlb_invert_endian_g)) |       // non altspace ldst
6761
     (altspace_ldst_g     & (lendian_asi_g ^ tlb_invert_endian_g)))       // altspace ldst
6762
    & ~(asi_internal_g & lsu_alt_space_g);                                // internal asi is big-endian
6763
 
6764
wire    l1hit_lendian_predict_m ;
6765
// Predict endian-ness in m-stage. Assume tte.IE=0
6766
assign  l1hit_lendian_predict_m =
6767
    ((non_altspace_ldst_m & pstate_cle_m) |        // non altspace ldst
6768
     (altspace_ldst_m     & lendian_asi_m))        // altspace ldst
6769
    & ~asi_internal_m ;                            // internal asi is big-endian
6770
 
6771
// Further, decode of ASI is not factored into endian calculation. 
6772
//assign  lsu_bendian_access_g = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ?
6773
//    ~l1hit_lendian_g : l2fill_bendian_g ;
6774
 
6775
// m stage endian signal is predicted for in-pipe lds only.
6776
wire    bendian_pred_m, bendian_pred_g ;
6777
assign  bendian_pred_m = (ld_inst_vld_m | st_inst_vld_m) ?
6778
    ~l1hit_lendian_predict_m : lsu_l2fill_bendian_m ;
6779
 
6780
dff #(1) stgg_bendpr(
6781
        .din    (bendian_pred_m),
6782
        .q      (bendian_pred_g),
6783
        .clk    (clk),
6784
        .se     (se),       .si (),          .so ()
6785
        );
6786
 
6787
// mispredict applies to only in-pipe lds.
6788
assign  endian_mispred_g =  bendian_pred_g ^ ~l1hit_lendian_g ;
6789
 
6790
// Staging for alignment on read from l1 or fill to l2.
6791
dff #(4) stgm_sz (
6792
        .din    ({ldst_byte,  ldst_hword,  ldst_word,  ldst_dword}),
6793
        .q      ({byte_m,hword_m,word_m,dword_m}),
6794
        .clk    (clk),
6795
        .se     (se),       .si (),          .so ()
6796
        );
6797
 
6798
wire    [7:0]    rwaddr_dcd_part ;
6799
 
6800
assign  rwaddr_dcd_part[0]  = ~rwaddr_enc[2] & ~rwaddr_enc[1] & ~rwaddr_enc[0] ;
6801
assign  rwaddr_dcd_part[1]  = ~rwaddr_enc[2] & ~rwaddr_enc[1] &  rwaddr_enc[0] ;
6802
assign  rwaddr_dcd_part[2]  = ~rwaddr_enc[2] &  rwaddr_enc[1] & ~rwaddr_enc[0] ;
6803
assign  rwaddr_dcd_part[3]  = ~rwaddr_enc[2] &  rwaddr_enc[1] &  rwaddr_enc[0] ;
6804
assign  rwaddr_dcd_part[4]  =  rwaddr_enc[2] & ~rwaddr_enc[1] & ~rwaddr_enc[0] ;
6805
assign  rwaddr_dcd_part[5]  =  rwaddr_enc[2] & ~rwaddr_enc[1] &  rwaddr_enc[0] ;
6806
assign  rwaddr_dcd_part[6]  =  rwaddr_enc[2] &  rwaddr_enc[1] & ~rwaddr_enc[0] ;
6807
assign  rwaddr_dcd_part[7]  =  rwaddr_enc[2] &  rwaddr_enc[1] &  rwaddr_enc[0] ;
6808
 
6809
   assign baddr_m[7:0] = rwaddr_dcd_part[7:0];
6810
/*
6811
assign baddr_m[0]  = ~rwaddr_enc[3] & rwaddr_dcd_part[0] ;
6812
assign baddr_m[1]  = ~rwaddr_enc[3] & rwaddr_dcd_part[1] ;
6813
assign baddr_m[2]  = ~rwaddr_enc[3] & rwaddr_dcd_part[2] ;
6814
assign baddr_m[3]  = ~rwaddr_enc[3] & rwaddr_dcd_part[3] ;
6815
assign baddr_m[4]  = ~rwaddr_enc[3] & rwaddr_dcd_part[4] ;
6816
assign baddr_m[5]  = ~rwaddr_enc[3] & rwaddr_dcd_part[5] ;
6817
assign baddr_m[6]  = ~rwaddr_enc[3] & rwaddr_dcd_part[6] ;
6818
assign baddr_m[7]  = ~rwaddr_enc[3] & rwaddr_dcd_part[7] ;
6819
assign baddr_m[8]  =  rwaddr_enc[3] & rwaddr_dcd_part[0] ;
6820
assign baddr_m[9]  =  rwaddr_enc[3] & rwaddr_dcd_part[1] ;
6821
assign baddr_m[10] =  rwaddr_enc[3] & rwaddr_dcd_part[2] ;
6822
assign baddr_m[11] =  rwaddr_enc[3] & rwaddr_dcd_part[3] ;
6823
assign baddr_m[12] =  rwaddr_enc[3] & rwaddr_dcd_part[4] ;
6824
assign baddr_m[13] =  rwaddr_enc[3] & rwaddr_dcd_part[5] ;
6825
assign baddr_m[14] =  rwaddr_enc[3] & rwaddr_dcd_part[6] ;
6826
assign baddr_m[15] =  rwaddr_enc[3] & rwaddr_dcd_part[7] ;
6827
*/
6828
// Byte Address to start write from. Quantity can be byte/hword/word/dword.
6829
// E-stage decoding for write to cache.
6830
 
6831
wire    [3:0]    waddr_enc ;
6832
wire    [7:0]    waddr_dcd_part ;
6833
wire    [15:0]   waddr_dcd ;
6834
 
6835
assign  waddr_dcd_part[0]  = ~waddr_enc[2] & ~waddr_enc[1] & ~waddr_enc[0] ;
6836
assign  waddr_dcd_part[1]  = ~waddr_enc[2] & ~waddr_enc[1] &  waddr_enc[0] ;
6837
assign  waddr_dcd_part[2]  = ~waddr_enc[2] &  waddr_enc[1] & ~waddr_enc[0] ;
6838
assign  waddr_dcd_part[3]  = ~waddr_enc[2] &  waddr_enc[1] &  waddr_enc[0] ;
6839
assign  waddr_dcd_part[4]  =  waddr_enc[2] & ~waddr_enc[1] & ~waddr_enc[0] ;
6840
assign  waddr_dcd_part[5]  =  waddr_enc[2] & ~waddr_enc[1] &  waddr_enc[0] ;
6841
assign  waddr_dcd_part[6]  =  waddr_enc[2] &  waddr_enc[1] & ~waddr_enc[0] ;
6842
assign  waddr_dcd_part[7]  =  waddr_enc[2] &  waddr_enc[1] &  waddr_enc[0] ;
6843
 
6844
assign  waddr_dcd[0]  = ~waddr_enc[3] & waddr_dcd_part[0] ;
6845
assign  waddr_dcd[1]  = ~waddr_enc[3] & waddr_dcd_part[1] ;
6846
assign  waddr_dcd[2]  = ~waddr_enc[3] & waddr_dcd_part[2] ;
6847
assign  waddr_dcd[3]  = ~waddr_enc[3] & waddr_dcd_part[3] ;
6848
assign  waddr_dcd[4]  = ~waddr_enc[3] & waddr_dcd_part[4] ;
6849
assign  waddr_dcd[5]  = ~waddr_enc[3] & waddr_dcd_part[5] ;
6850
assign  waddr_dcd[6]  = ~waddr_enc[3] & waddr_dcd_part[6] ;
6851
assign  waddr_dcd[7]  = ~waddr_enc[3] & waddr_dcd_part[7] ;
6852
assign  waddr_dcd[8]  =  waddr_enc[3] & waddr_dcd_part[0] ;
6853
assign  waddr_dcd[9]  =  waddr_enc[3] & waddr_dcd_part[1] ;
6854
assign  waddr_dcd[10] =  waddr_enc[3] & waddr_dcd_part[2] ;
6855
assign  waddr_dcd[11] =  waddr_enc[3] & waddr_dcd_part[3] ;
6856
assign  waddr_dcd[12] =  waddr_enc[3] & waddr_dcd_part[4] ;
6857
assign  waddr_dcd[13] =  waddr_enc[3] & waddr_dcd_part[5] ;
6858
assign  waddr_dcd[14] =  waddr_enc[3] & waddr_dcd_part[6] ;
6859
assign  waddr_dcd[15] =  waddr_enc[3] & waddr_dcd_part[7] ;
6860
 
6861
// Byte enables for 16 bytes.
6862
   //bug6216/eco6624
6863
   wire write_16byte_e;
6864
   assign write_16byte_e = l2fill_vld_e | lsu_bist_wvld_e;
6865
 
6866
assign byte_wr_enable[15] =
6867
    write_16byte_e  |   waddr_dcd[0] ;
6868
assign byte_wr_enable[14] =
6869
    write_16byte_e  |   waddr_dcd[1]    |
6870
    (wr_hword & waddr_dcd[0])  |   (wr_word & waddr_dcd[0]) |
6871
    (wr_dword & waddr_dcd[0])  ;
6872
assign byte_wr_enable[13] =
6873
    write_16byte_e  |   waddr_dcd[2]    |
6874
    (wr_word & waddr_dcd[0]) |     (wr_dword & waddr_dcd[0])  ;
6875
assign byte_wr_enable[12] =
6876
    write_16byte_e  |   waddr_dcd[3]    |
6877
    (wr_hword & waddr_dcd[2])  |   (wr_word & waddr_dcd[0]) |
6878
    (wr_dword & waddr_dcd[0])  ;
6879
assign byte_wr_enable[11] =
6880
    write_16byte_e  |   waddr_dcd[4]    |
6881
    (wr_dword & waddr_dcd[0])  ;
6882
assign byte_wr_enable[10] =
6883
    write_16byte_e  |   waddr_dcd[5]    |
6884
    (wr_hword & waddr_dcd[4])  |   (wr_word & waddr_dcd[4]) |
6885
    (wr_dword & waddr_dcd[0])  ;
6886
assign byte_wr_enable[9] =
6887
    write_16byte_e  |   waddr_dcd[6]    |
6888
    (wr_word & waddr_dcd[4]) |     (wr_dword & waddr_dcd[0])  ;
6889
assign byte_wr_enable[8] =
6890
    write_16byte_e  |   waddr_dcd[7]    |
6891
    (wr_hword & waddr_dcd[6])  |   (wr_word & waddr_dcd[4]) |
6892
    (wr_dword & waddr_dcd[0])  ;
6893
assign byte_wr_enable[7] =
6894
    write_16byte_e  |   waddr_dcd[8] ;
6895
assign byte_wr_enable[6] =
6896
    write_16byte_e  |   waddr_dcd[9]    |
6897
    (wr_hword & waddr_dcd[8])  |   (wr_word & waddr_dcd[8]) |
6898
    (wr_dword & waddr_dcd[8])  ;
6899
assign byte_wr_enable[5] =
6900
    write_16byte_e  |   waddr_dcd[10]   |
6901
    (wr_word & waddr_dcd[8]) |     (wr_dword & waddr_dcd[8])  ;
6902
assign byte_wr_enable[4] =
6903
    write_16byte_e  |   waddr_dcd[11]   |
6904
    (wr_hword & waddr_dcd[10]) |   (wr_word & waddr_dcd[8]) |
6905
    (wr_dword & waddr_dcd[8])  ;
6906
assign byte_wr_enable[3] =
6907
    write_16byte_e  |   waddr_dcd[12]   |
6908
    (wr_dword & waddr_dcd[8])  ;
6909
assign byte_wr_enable[2] =
6910
    write_16byte_e  |   waddr_dcd[13]   |
6911
    (wr_hword & waddr_dcd[12]) |   (wr_word & waddr_dcd[12])  |
6912
    (wr_dword & waddr_dcd[8])  ;
6913
assign byte_wr_enable[1] =
6914
    write_16byte_e  |   waddr_dcd[14]   |
6915
    (wr_word & waddr_dcd[12])  |   (wr_dword & waddr_dcd[8])  ;
6916
assign byte_wr_enable[0] =
6917
    write_16byte_e  |   waddr_dcd[15]   |
6918
    (wr_hword & waddr_dcd[14]) |   (wr_word & waddr_dcd[12])  |
6919
    (wr_dword & waddr_dcd[8])  ;
6920
 
6921
assign  dcache_byte_wr_en_e[15:0] = byte_wr_enable[15:0] ;
6922
//assign  lsu_st_byte_addr_g[15:0]  = byp_baddr_g[15:0] ;
6923
 
6924
//=========================================================================================
6925
//  Sign/Zero-Extension
6926
//=========================================================================================
6927
 
6928
dff #(1) stgm_msb (
6929
       .din    ({lsu_l1hit_sign_extend_e}),
6930
       .q      ({l1hit_sign_extend_m}),
6931
       .clk    (clk),
6932
       .se     (se),       .si (),          .so ()
6933
       );
6934
 
6935
dff #(1) stgg_msb (
6936
       .din    ({l1hit_sign_extend_m}),
6937
       .q      ({l1hit_sign_extend_g}),
6938
       .clk    (clk),
6939
       .se     (se),       .si (),          .so ()
6940
       );
6941
 
6942
 
6943
//wire [1:0] lsu_byp_misc_sz_g ;   
6944
 
6945
/*dff #(2) ff_lsu_byp_misc_sz_g (
6946
        .din   (lsu_byp_misc_sz_m[1:0]),
6947
        .q     (lsu_byp_misc_sz_g[1:0]),
6948
        .clk    (clk),
6949
        .se     (se),       .si (),          .so ()
6950
        );  */
6951
 
6952
assign  misc_byte_m   = ~lsu_byp_misc_sz_m[1] & ~lsu_byp_misc_sz_m[0] ; // 00
6953
assign  misc_hword_m  = ~lsu_byp_misc_sz_m[1] &  lsu_byp_misc_sz_m[0] ; // 01
6954
assign  misc_word_m   =  lsu_byp_misc_sz_m[1] & ~lsu_byp_misc_sz_m[0] ; // 10
6955
assign  misc_dword_m  =  lsu_byp_misc_sz_m[1] &  lsu_byp_misc_sz_m[0] ; // 11
6956
 
6957
wire    byp_byte_m,byp_hword_m,byp_word_m,byp_dword_m;
6958
assign  byp_byte_m =  (ld_inst_vld_m) ?  byte_m :  misc_byte_m ;
6959
assign  byp_hword_m = (ld_inst_vld_m) ? hword_m :  misc_hword_m ;
6960
assign  byp_word_m =  (ld_inst_vld_m) ?  word_m :  misc_word_m ;
6961
assign  byp_dword_m = (ld_inst_vld_m) ? dword_m :  misc_dword_m ;
6962
 
6963
/*assign  byp_byte_g =  (|lsu_irf_byp_data_src[2:1]) ? misc_byte_g : byte_g ;
6964
assign  byp_hword_g = (|lsu_irf_byp_data_src[2:1]) ? misc_hword_g : hword_g ;
6965
assign  byp_word_g =  (|lsu_irf_byp_data_src[2:1]) ? misc_word_g : word_g ;*/
6966
 
6967
dff #(1) bypsz_stgg(
6968
        .din   ({byp_word_m}),
6969
        .q     ({byp_word_g}),
6970
        .clk    (clk),
6971
        .se     (se),       .si (),          .so ()
6972
        );
6973
 
6974
//wire [3:0]    misc_waddr_m ; 
6975
//assign  misc_waddr_m[3:0] = {lsu_byp_misc_addr_m[3],lsu_byp_misc_addr_m[2]^lsu_byp_ldd_oddrd_m,lsu_byp_misc_addr_m[1:0]} ;
6976
 
6977
wire [2:0]       misc_waddr_m ;
6978
assign  misc_waddr_m[2:0] = {lsu_byp_misc_addr_m[2]^lsu_byp_ldd_oddrd_m,lsu_byp_misc_addr_m[1:0]} ;
6979
 
6980
//wire    [15:0] misc_baddr_m ;
6981
wire    [7:0] misc_baddr_m ;
6982
 
6983
// m-stage decoding
6984
// Might be better to stage encoded waddr, mux and then decode.
6985
/*
6986
assign  misc_baddr_m[0] = ~misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6987
assign  misc_baddr_m[1] = ~misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6988
assign  misc_baddr_m[2] = ~misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6989
assign  misc_baddr_m[3] = ~misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6990
assign  misc_baddr_m[4] = ~misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6991
assign  misc_baddr_m[5] = ~misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6992
assign  misc_baddr_m[6] = ~misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6993
assign  misc_baddr_m[7] = ~misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6994
assign  misc_baddr_m[8] =  misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6995
assign  misc_baddr_m[9] =  misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6996
assign  misc_baddr_m[10] =  misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6997
assign  misc_baddr_m[11] =  misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6998
assign  misc_baddr_m[12] =  misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6999
assign  misc_baddr_m[13] =  misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
7000
assign  misc_baddr_m[14] =  misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
7001
assign  misc_baddr_m[15] =  misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
7002
*/
7003
assign  misc_baddr_m[0] = ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
7004
assign  misc_baddr_m[1] = ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
7005
assign  misc_baddr_m[2] = ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
7006
assign  misc_baddr_m[3] = ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
7007
assign  misc_baddr_m[4] =  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
7008
assign  misc_baddr_m[5] =  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
7009
assign  misc_baddr_m[6] =  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
7010
assign  misc_baddr_m[7] =  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
7011
 
7012
//wire [15:0] byp_baddr_m ;
7013
//assign  byp_baddr_m[15:0] = (~(ld_inst_vld_m | st_inst_vld_m)) ? misc_baddr_m[15:0] : baddr_m[15:0] ;
7014
wire [7:0] byp_baddr_m ;
7015
assign  byp_baddr_m[7:0] = (~(ld_inst_vld_m | st_inst_vld_m)) ? misc_baddr_m[7:0] : baddr_m[7:0] ;
7016
 
7017
   wire l2fill_sign_extend_m;
7018
 
7019
assign  l2fill_sign_extend_m = lsu_l2fill_sign_extend_m ;
7020
//?? why need st ??
7021
assign  signed_ldst_m = (ld_inst_vld_m | st_inst_vld_m) ?
7022
                         l1hit_sign_extend_m : l2fill_sign_extend_m ;
7023
 
7024
//assign  unsigned_ldst_m = ~signed_ldst_m ;
7025
 
7026
   assign signed_ldst_byte_m = signed_ldst_m & byp_byte_m;
7027
//   assign unsigned_ldst_byte_m = unsigned_ldst_m & byp_byte_m;
7028
 
7029
   assign signed_ldst_hw_m = signed_ldst_m & ( byp_byte_m | byp_hword_m );
7030
//   assign unsigned_ldst_hw_m = unsigned_ldst_m & ( byp_byte_m | byp_hword_m );
7031
 
7032
   assign signed_ldst_w_m = signed_ldst_m & ( byp_byte_m | byp_hword_m | byp_word_m );
7033
//   assign unsigned_ldst_w_m = unsigned_ldst_m & ( byp_byte_m | byp_hword_m | byp_word_m );
7034
 
7035
//C assign  align_bytes_msb[7:0] = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ? lsu_l1hit_bytes_msb_g[7:0] :
7036
//C     (l2fill_vld_g ? l2fill_bytes_msb_g[7:0] : lsu_misc_bytes_msb_g[7:0])  ;
7037
 
7038
//assign  align_bytes_msb[7:0] = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ? lsu_l1hit_bytes_msb_g[7:0] :
7039
//    (lsu_irf_byp_data_src[2] ? lsu_misc_bytes_msb_g[7:0] : l2fill_bytes_msb_g[7:0])  ;
7040
 
7041
 
7042
// For little-endian accesses, the following morphing must occur to the byte addr.
7043
//
7044
// Byte Addr(lower 3b)  
7045
//  000(0)  ->  001(1) (hw)
7046
//    ->  011(3) (w)
7047
//    ->  111(7) (dw)
7048
//  001(1)  ->  not morphed
7049
//  010(2)  ->  011(3) (hw)
7050
//  011(3)  ->  not morphed
7051
//  100(4)  ->  101(5) (hw)
7052
//    ->  111(7) (w)
7053
//  101(5)  ->  not morphed
7054
//  110(6)  ->  111(7) (hw)
7055
//  111(7)  ->  not morphed
7056
 
7057
wire  [7:0] merged_addr_m ;
7058
wire  [7:0] morphed_addr_m ;
7059
 
7060
//wire  bendian ;
7061
 
7062
//assign  merged_addr_m[7:0] = byp_baddr_m[15:8] | byp_baddr_m[7:0] ;
7063
assign  merged_addr_m[7:0] = byp_baddr_m[7:0] ;
7064
 
7065
assign  morphed_addr_m[0]
7066
  =  merged_addr_m[0] & ~(~bendian_pred_m & ~byp_byte_m) ;
7067
assign  morphed_addr_m[1]
7068
  =  merged_addr_m[1] | (merged_addr_m[0] & ~bendian_pred_m & byp_hword_m) ;
7069
assign  morphed_addr_m[2]
7070
  =  merged_addr_m[2] & ~(~bendian_pred_m & byp_hword_m) ;
7071
assign  morphed_addr_m[3]
7072
  =  merged_addr_m[3] | (merged_addr_m[0] & ~bendian_pred_m & byp_word_m) |
7073
  (merged_addr_m[2] & ~bendian_pred_m & byp_hword_m) ;
7074
assign  morphed_addr_m[4]
7075
  =  merged_addr_m[4] & ~(~bendian_pred_m & (byp_hword_m | byp_word_m)) ;
7076
assign  morphed_addr_m[5]
7077
  =  merged_addr_m[5] | (merged_addr_m[4] & ~bendian_pred_m & byp_hword_m) ;
7078
assign  morphed_addr_m[6]
7079
  =  merged_addr_m[6] & ~(~bendian_pred_m & byp_hword_m) ;
7080
assign  morphed_addr_m[7]
7081
  =  merged_addr_m[7] | (merged_addr_m[0] & ~bendian_pred_m & ~(byp_byte_m | byp_hword_m | byp_word_m))  |
7082
  (merged_addr_m[4] & ~bendian_pred_m & byp_word_m) | (merged_addr_m[6] & ~bendian_pred_m & byp_hword_m) ;
7083
 
7084
 
7085
 
7086
 
7087
//=========================================================================================
7088
//  ALIGNMENT CONTROL FOR DCDP 
7089
//=========================================================================================
7090
 
7091
// First generate control for swapping related to endianness.
7092
// byte7-byte0 is source data from cache etc.
7093
// swap7-swap0 is result of endianness swapping.
7094
 
7095
// First logical level - Swapping of bytes. 
7096
// Swap byte 0 
7097
 
7098
wire  swap0_sel_byte0, swap0_sel_byte1, swap0_sel_byte3  ;
7099
wire  swap1_sel_byte0, swap1_sel_byte1, swap1_sel_byte2, swap1_sel_byte6 ;
7100
wire  swap2_sel_byte1, swap2_sel_byte2, swap2_sel_byte3, swap2_sel_byte5 ;
7101
wire  swap3_sel_byte0, swap3_sel_byte2, swap3_sel_byte3, swap3_sel_byte4 ;
7102
wire  swap4_sel_byte3, swap4_sel_byte4, swap4_sel_byte5 ;
7103
wire  swap5_sel_byte2, swap5_sel_byte4, swap5_sel_byte5, swap5_sel_byte6 ;
7104
wire  swap6_sel_byte1, swap6_sel_byte5, swap6_sel_byte6 ;
7105
wire  swap7_sel_byte0, swap7_sel_byte4, swap7_sel_byte6, swap7_sel_byte7 ;
7106
 
7107
//assign  bendian = bendian_pred_m ;
7108
//assign  bendian = lsu_bendian_access_g ;
7109
 
7110
assign  swap0_sel_byte0   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7111
assign  swap0_sel_byte1   = ~bendian_pred_m & byp_hword_m ;
7112
assign  swap0_sel_byte3   = ~bendian_pred_m & byp_word_m ;
7113
// could be substituted with dword encoding.
7114
//assign  swap0_sel_byte7   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7115
 
7116
// Swap byp_byte_m 1 
7117
assign  swap1_sel_byte0   = ~bendian_pred_m & byp_hword_m ;
7118
assign  swap1_sel_byte1   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7119
assign  swap1_sel_byte2   = ~bendian_pred_m & byp_word_m ;
7120
assign  swap1_sel_byte6   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7121
 
7122
// Swap byp_byte_m 2 
7123
assign  swap2_sel_byte1   = ~bendian_pred_m & byp_word_m ;
7124
assign  swap2_sel_byte2   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7125
assign  swap2_sel_byte3   = ~bendian_pred_m & byp_hword_m ;
7126
assign  swap2_sel_byte5   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7127
 
7128
// Swap byp_byte_m 3 
7129
assign  swap3_sel_byte0   = ~bendian_pred_m & byp_word_m ;
7130
assign  swap3_sel_byte2   = ~bendian_pred_m & byp_hword_m ;
7131
assign  swap3_sel_byte3   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7132
assign  swap3_sel_byte4   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7133
 
7134
// Swap byp_byte_m 4 
7135
assign  swap4_sel_byte3   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7136
assign  swap4_sel_byte4   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7137
assign  swap4_sel_byte5   = ~bendian_pred_m & byp_hword_m ;
7138
//assign  swap4_sel_byte7   = ~bendian_pred_m & byp_word_m ;
7139
 
7140
// Swap byp_byte_m 5 
7141
assign  swap5_sel_byte2   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7142
assign  swap5_sel_byte4   = ~bendian_pred_m & byp_hword_m ;
7143
assign  swap5_sel_byte5   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7144
assign  swap5_sel_byte6   = ~bendian_pred_m & byp_word_m ;
7145
 
7146
// Swap byp_byte_m 6 
7147
assign  swap6_sel_byte1   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7148
assign  swap6_sel_byte5   = ~bendian_pred_m & byp_word_m ;
7149
assign  swap6_sel_byte6   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7150
//assign  swap6_sel_byte7   = ~bendian_pred_m & byp_hword_m ;
7151
 
7152
// Swap byp_byte_m 7 
7153
assign  swap7_sel_byte0   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
7154
assign  swap7_sel_byte4   = ~bendian_pred_m & byp_word_m ;
7155
assign  swap7_sel_byte6   = ~bendian_pred_m & byp_hword_m ;
7156
assign  swap7_sel_byte7   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
7157
 
7158
// 2nd logical level - Alignment. 
7159
// rjust7-rjust0 is result of alignment operation.
7160
// sbyte7-sbyte0 is the result of the endian swapping from the 1st logic level.
7161
 
7162
wire  rjust0_sel_sbyte0, rjust0_sel_sbyte1, rjust0_sel_sbyte2, rjust0_sel_sbyte3 ;
7163
wire  rjust0_sel_sbyte4, rjust0_sel_sbyte5, rjust0_sel_sbyte6, rjust0_sel_sbyte7 ;
7164
wire  rjust1_sel_sbyte1, rjust1_sel_sbyte3, rjust1_sel_sbyte5, rjust1_sel_sbyte7 ;
7165
wire  rjust2_sel_sbyte2, rjust2_sel_sbyte6 ;
7166
wire  rjust3_sel_sbyte3, rjust3_sel_sbyte7 ;
7167
 
7168
// Aligned Byte 0
7169
assign  rjust0_sel_sbyte0   =
7170
  ~(rjust0_sel_sbyte1 | rjust0_sel_sbyte2 | rjust0_sel_sbyte3 |
7171
    rjust0_sel_sbyte4 | rjust0_sel_sbyte5 | rjust0_sel_sbyte6 |
7172
    rjust0_sel_sbyte7) ;
7173
assign  rjust0_sel_sbyte1   =
7174
//  ((byp_baddr_m[14] | byp_baddr_m[6]) & byp_byte_m) ;
7175
  ((byp_baddr_m[6]) & byp_byte_m) ;
7176
 
7177
assign  rjust0_sel_sbyte2   =
7178
//  ((byp_baddr_m[12] | byp_baddr_m[4]) & byp_hword_m) | 
7179
  ((byp_baddr_m[4]) & byp_hword_m) |
7180
//  ((byp_baddr_m[13] | byp_baddr_m[5]) & byp_byte_m) ;
7181
  ((byp_baddr_m[5]) & byp_byte_m) ;
7182
assign  rjust0_sel_sbyte3 =
7183
//  (byp_baddr_m[12] | byp_baddr_m[4]) & byp_byte_m ; 
7184
  (byp_baddr_m[4]) & byp_byte_m ;
7185
assign  rjust0_sel_sbyte4 =
7186
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_hword_m) | 
7187
//  ((byp_baddr_m[11] | byp_baddr_m[3]) & byp_byte_m) |
7188
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m) ;
7189
  ((byp_baddr_m[2]) & byp_hword_m) |
7190
  ((byp_baddr_m[3]) & byp_byte_m) |
7191
  ((byp_baddr_m[0]) & byp_word_m) ;
7192
assign  rjust0_sel_sbyte5 =
7193
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_byte_m) ; 
7194
  ((byp_baddr_m[2]) & byp_byte_m) ;
7195
assign  rjust0_sel_sbyte6 =
7196
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_hword_m) | 
7197
//  ((byp_baddr_m[9] | byp_baddr_m[1]) & byp_byte_m) ;
7198
  ((byp_baddr_m[0]) & byp_hword_m) |
7199
  ((byp_baddr_m[1]) & byp_byte_m) ;
7200
assign  rjust0_sel_sbyte7 =
7201
//  (byp_baddr_m[8] | byp_baddr_m[0]) & byp_byte_m ;
7202
  (byp_baddr_m[0]) & byp_byte_m ;
7203
 
7204
// Aligned Byte 1
7205
assign  rjust1_sel_sbyte1   =
7206
  ~(rjust1_sel_sbyte3 | rjust1_sel_sbyte5 | rjust1_sel_sbyte7) ;
7207
assign  rjust1_sel_sbyte3   =
7208
//  (byp_baddr_m[12] | byp_baddr_m[4]) & byp_hword_m ;
7209
  (byp_baddr_m[4]) & byp_hword_m ;
7210
assign  rjust1_sel_sbyte5   =
7211
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_hword_m) | 
7212
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m) ;
7213
  ((byp_baddr_m[2]) & byp_hword_m) |
7214
  ((byp_baddr_m[0]) & byp_word_m) ;
7215
assign  rjust1_sel_sbyte7   =
7216
//  (byp_baddr_m[8] | byp_baddr_m[0]) & byp_hword_m ;
7217
  (byp_baddr_m[0]) & byp_hword_m ;
7218
 
7219
// Aligned Byte 2
7220
assign  rjust2_sel_sbyte2   = ~rjust2_sel_sbyte6 ;
7221
//assign  rjust2_sel_sbyte6   = (byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m ;
7222
assign  rjust2_sel_sbyte6   = (byp_baddr_m[0]) & byp_word_m ;
7223
 
7224
// Aligned Byte 3
7225
assign  rjust3_sel_sbyte3   = ~rjust3_sel_sbyte7 ;
7226
//assign  rjust3_sel_sbyte7   = (byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m ;
7227
assign  rjust3_sel_sbyte7   = (byp_baddr_m[0]) & byp_word_m ;
7228
 
7229
// 3rd logical level - Complete alignment. Sign-Extension/Zero-Extension.
7230
// merge7-merge0 corresponds to cumulative swapping and alignment result.
7231
// byte[7]-byte[0] refers to the original pre-swap/alignment data.
7232
 
7233
wire merge7_sel_byte0_m, merge7_sel_byte7_m;
7234
wire merge6_sel_byte1_m, merge6_sel_byte6_m;
7235
wire merge5_sel_byte2_m, merge5_sel_byte5_m;
7236
wire merge4_sel_byte3_m, merge4_sel_byte4_m;
7237
wire merge3_sel_byte0_m, merge3_sel_byte3_m;
7238
wire merge3_sel_byte4_m, merge3_sel_byte7_m,merge3_sel_byte_m;
7239
wire merge2_sel_byte1_m, merge2_sel_byte2_m, merge2_sel_byte5_m;
7240
wire merge2_sel_byte6_m, merge2_sel_byte_m;
7241
wire merge0_sel_byte0_m, merge0_sel_byte1_m;
7242
wire merge0_sel_byte2_m, merge0_sel_byte3_m;
7243
wire merge0_sel_byte4_m, merge0_sel_byte5_m;
7244
wire merge0_sel_byte6_m;
7245
wire merge1_sel_byte0_m, merge1_sel_byte1_m;
7246
wire merge1_sel_byte2_m, merge1_sel_byte3_m;
7247
wire merge1_sel_byte4_m, merge1_sel_byte5_m;
7248
wire merge1_sel_byte6_m, merge1_sel_byte7_m;
7249
wire merge0_sel_byte_1h_m,merge1_sel_byte_1h_m, merge1_sel_byte_2h_m;
7250
 
7251
// Final Merged Byte 0
7252
assign  merge0_sel_byte0_m  =
7253
  (rjust0_sel_sbyte0 & swap0_sel_byte0) |
7254
  (rjust0_sel_sbyte1 & swap1_sel_byte0) |
7255
  (rjust0_sel_sbyte3 & swap3_sel_byte0) |
7256
  (rjust0_sel_sbyte7 & swap7_sel_byte0) ;
7257
 
7258
assign  merge0_sel_byte1_m  =
7259
  (rjust0_sel_sbyte0 & swap0_sel_byte1) |
7260
  (rjust0_sel_sbyte1 & swap1_sel_byte1) |
7261
  (rjust0_sel_sbyte2 & swap2_sel_byte1) |
7262
  (rjust0_sel_sbyte6 & swap6_sel_byte1) ;
7263
 
7264
assign  merge0_sel_byte2_m  =
7265
  (rjust0_sel_sbyte1 & swap1_sel_byte2) |
7266
  (rjust0_sel_sbyte2 & swap2_sel_byte2) |
7267
  (rjust0_sel_sbyte3 & swap3_sel_byte2) |
7268
  (rjust0_sel_sbyte5 & swap5_sel_byte2) ;
7269
 
7270
 
7271
assign  merge0_sel_byte3_m  =
7272
  (rjust0_sel_sbyte0 & swap0_sel_byte3) |
7273
  (rjust0_sel_sbyte2 & swap2_sel_byte3) |
7274
  (rjust0_sel_sbyte3 & swap3_sel_byte3) |
7275
  (rjust0_sel_sbyte4 & swap4_sel_byte3) ;
7276
 
7277
assign merge0_sel_byte3_default_m = ~ (merge0_sel_byte0_m | merge0_sel_byte1_m | merge0_sel_byte2_m);
7278
 
7279
assign  merge0_sel_byte4_m  =
7280
  (rjust0_sel_sbyte3 & swap3_sel_byte4) |
7281
  (rjust0_sel_sbyte4 & swap4_sel_byte4) |
7282
  (rjust0_sel_sbyte5 & swap5_sel_byte4) |
7283
  (rjust0_sel_sbyte7 & swap7_sel_byte4) ;
7284
 
7285
assign  merge0_sel_byte5_m  =
7286
  (rjust0_sel_sbyte2 & swap2_sel_byte5) |
7287
  (rjust0_sel_sbyte4 & swap4_sel_byte5) |
7288
  (rjust0_sel_sbyte5 & swap5_sel_byte5) |
7289
  (rjust0_sel_sbyte6 & swap6_sel_byte5) ;
7290
 
7291
assign  merge0_sel_byte6_m  =
7292
  (rjust0_sel_sbyte1 & swap1_sel_byte6) |
7293
  (rjust0_sel_sbyte5 & swap5_sel_byte6) |
7294
  (rjust0_sel_sbyte6 & swap6_sel_byte6) |
7295
  (rjust0_sel_sbyte7 & swap7_sel_byte6) ;
7296
 
7297
//assign  merge0_sel_byte7_m  = 
7298
//  (rjust0_sel_sbyte0 & swap0_sel_byte7) |
7299
//  (rjust0_sel_sbyte4 & swap4_sel_byte7) |
7300
//  (rjust0_sel_sbyte6 & swap6_sel_byte7) |
7301
//  (rjust0_sel_sbyte7 & swap7_sel_byte7) ;
7302
 
7303
   assign merge0_sel_byte7_default_m = ~(merge0_sel_byte4_m | merge0_sel_byte5_m |  merge0_sel_byte6_m);
7304
 
7305
assign  merge0_sel_byte_1h_m =
7306
  merge0_sel_byte0_m |  merge0_sel_byte1_m | merge0_sel_byte2_m | merge0_sel_byte3_m ;
7307
 
7308
// Final Merged Byte 1
7309
assign  merge1_sel_byte0_m  =
7310
  (rjust1_sel_sbyte1 & swap1_sel_byte0) |
7311
  (rjust1_sel_sbyte3 & swap3_sel_byte0) |
7312
  (rjust1_sel_sbyte7 & swap7_sel_byte0) ;
7313
 
7314
assign  merge1_sel_byte1_m  =
7315
  (rjust1_sel_sbyte1 & swap1_sel_byte1) ;
7316
 
7317
assign  merge1_sel_byte2_m  =
7318
  (rjust1_sel_sbyte1 & swap1_sel_byte2) |
7319
  (rjust1_sel_sbyte3 & swap3_sel_byte2) |
7320
  (rjust1_sel_sbyte5 & swap5_sel_byte2) ;
7321
 
7322
assign  merge1_sel_byte3_m  =
7323
  (rjust1_sel_sbyte3 & swap3_sel_byte3) ;
7324
 
7325
   assign merge1_sel_byte3_default_m = ~( merge1_sel_byte0_m | merge1_sel_byte1_m | merge1_sel_byte2_m);
7326
 
7327
assign  merge1_sel_byte4_m  =
7328
  (rjust1_sel_sbyte3 & swap3_sel_byte4) |
7329
  (rjust1_sel_sbyte5 & swap5_sel_byte4) |
7330
  (rjust1_sel_sbyte7 & swap7_sel_byte4) ;
7331
 
7332
assign  merge1_sel_byte5_m  =
7333
  (rjust1_sel_sbyte5 & swap5_sel_byte5) ;
7334
 
7335
assign  merge1_sel_byte6_m  =
7336
  (rjust1_sel_sbyte1 & swap1_sel_byte6) |
7337
  (rjust1_sel_sbyte5 & swap5_sel_byte6) |
7338
  (rjust1_sel_sbyte7 & swap7_sel_byte6) ;
7339
 
7340
assign  merge1_sel_byte7_m  =
7341
  (rjust1_sel_sbyte7 & swap7_sel_byte7) ;
7342
 
7343
   assign merge1_sel_byte7_default_m = ~( merge1_sel_byte4_m | merge1_sel_byte5_m | merge1_sel_byte6_m);
7344
 
7345
assign  merge1_sel_byte_1h_m = ~byp_byte_m &
7346
  (merge1_sel_byte0_m |  merge1_sel_byte1_m | merge1_sel_byte2_m | merge1_sel_byte3_m) ;
7347
 
7348
assign  merge1_sel_byte_2h_m = ~byp_byte_m &
7349
  (merge1_sel_byte4_m |  merge1_sel_byte5_m | merge1_sel_byte6_m | merge1_sel_byte7_m) ;
7350
 
7351
 
7352
// Final Merged Byte 2
7353
 
7354
assign  merge2_sel_byte1_m  =
7355
  (rjust2_sel_sbyte2 & swap2_sel_byte1) |
7356
  (rjust2_sel_sbyte6 & swap6_sel_byte1) ;
7357
 
7358
assign  merge2_sel_byte2_m  =
7359
  (rjust2_sel_sbyte2 & swap2_sel_byte2) ;
7360
 
7361
assign  merge2_sel_byte5_m  =
7362
  (rjust2_sel_sbyte2 & swap2_sel_byte5) |
7363
  (rjust2_sel_sbyte6 & swap6_sel_byte5) ;
7364
 
7365
assign  merge2_sel_byte6_m  =
7366
  (rjust2_sel_sbyte6 & swap6_sel_byte6) ;
7367
 
7368
   assign merge2_sel_byte6_default_m  = ~(merge2_sel_byte1_m | merge2_sel_byte2_m | merge2_sel_byte5_m);
7369
 
7370
assign merge2_sel_byte_m = ~byp_byte_m & ~byp_hword_m &
7371
(merge2_sel_byte1_m | merge2_sel_byte2_m | merge2_sel_byte5_m | merge2_sel_byte6_m);
7372
 
7373
// Final Merged Byte 3
7374
assign  merge3_sel_byte0_m  =
7375
  (rjust3_sel_sbyte3 & swap3_sel_byte0) |
7376
  (rjust3_sel_sbyte7 & swap7_sel_byte0) ;
7377
 
7378
assign  merge3_sel_byte3_m  =
7379
  (rjust3_sel_sbyte3 & swap3_sel_byte3) ;
7380
 
7381
assign  merge3_sel_byte4_m  =
7382
  (rjust3_sel_sbyte3 & swap3_sel_byte4) |
7383
  (rjust3_sel_sbyte7 & swap7_sel_byte4) ;
7384
 
7385
assign  merge3_sel_byte7_m  =
7386
  (rjust3_sel_sbyte7 & swap7_sel_byte7) ;
7387
 
7388
assign merge3_sel_byte7_default_m  =  ~(merge3_sel_byte0_m | merge3_sel_byte3_m | merge3_sel_byte4_m);
7389
 
7390
assign merge3_sel_byte_m = ~byp_byte_m & ~byp_hword_m &
7391
(merge3_sel_byte0_m | merge3_sel_byte3_m | merge3_sel_byte4_m | merge3_sel_byte7_m);
7392
 
7393
// Final Merged Byte 4
7394
assign  merge4_sel_byte3_m = byp_dword_m & swap4_sel_byte3 ;
7395
assign  merge4_sel_byte4_m = byp_dword_m & swap4_sel_byte4 ;
7396
 
7397
 
7398
// Final Merged Byte 5
7399
assign  merge5_sel_byte2_m = byp_dword_m & swap5_sel_byte2 ;
7400
assign  merge5_sel_byte5_m = byp_dword_m & swap5_sel_byte5 ;
7401
 
7402
// Final Merged Byte 6
7403
assign  merge6_sel_byte1_m = byp_dword_m & swap6_sel_byte1 ;
7404
assign  merge6_sel_byte6_m = byp_dword_m & swap6_sel_byte6 ;
7405
 
7406
// Final Merged Byte 7
7407
assign  merge7_sel_byte0_m = byp_dword_m & swap7_sel_byte0 ;
7408
assign  merge7_sel_byte7_m = byp_dword_m & swap7_sel_byte7 ;
7409
 
7410
 
7411
 
7412
//=========================================================================================
7413
//  STQ/CAS 2ND PKT FORMATTING 
7414
//=========================================================================================
7415
 
7416
// stq and cas write to an extra buffer. stq always uses a full 64bits.
7417
// cas may use either 64b or 32b. stq requires at most endian alignment.
7418
// cas may require both address and endian alignment.
7419
 
7420
// Byte Alignment. Assume 8 bytes, 7-0
7421
//  Case 1 : 7,6,5,4,3,2,1,0 
7422
//  Case 2 : 3,2,1,0,0,1,2,3 
7423
//  Case 3 : 0,1,2,3,4,5,6,7  
7424
 
7425
wire casa_wd_g ;
7426
assign  casa_wd_g = casa_g & byp_word_g ;
7427
wire casa_dwd_g ;
7428
assign  casa_dwd_g = casa_g & ~byp_word_g ;
7429
 
7430
// Change bendian to bendian_g - should not be dependent on fill. 
7431
 
7432
//assign  lsu_atomic_pkt2_bsel_g[2] =   // Case 1
7433
//  (casa_dwd_g &  bendian_g)   |  // bendian stq and dw cas
7434
//  (casa_wd_g &  bendian_g &  ldst_va_g[2]) ;  // bendian_g wd casa addr to uhalf
7435
 
7436
assign lsu_atomic_pkt2_bsel_g[2] = ~| (lsu_atomic_pkt2_bsel_g[1:0]) | rst_tri_en ; //one-hot default
7437
 
7438
assign  lsu_atomic_pkt2_bsel_g[1] =   // Case 2
7439
  ((casa_wd_g &  bendian_g & ~ldst_va_g[2]) |  // bendian_g wd casa addr to lhalf
7440
  (casa_wd_g & ~bendian_g &  ldst_va_g[2])) &  ~rst_tri_en ;  // lendian wd casa addr to uhalf
7441
assign  lsu_atomic_pkt2_bsel_g[0] =   // Case 3 
7442
  ((casa_dwd_g & ~bendian_g) |    // lendian stq and dw cas
7443
  (casa_wd_g & ~bendian_g & ~ldst_va_g[2])) &  ~rst_tri_en ;  // lendian wd cas addr to lhalf
7444
 
7445
// Alignment done in qdp1
7446
 
7447
//=========================================================================================
7448
//  ASI DECODE
7449
//=========================================================================================
7450
 
7451
// Note : tlb_byp_asi same as phy_use/phy_byp asi.
7452
 
7453
 
7454
lsu_asi_decode asi_decode (/*AUTOINST*/
7455
                           // Outputs
7456
                           .asi_internal_d(asi_internal_d),
7457
                           .nucleus_asi_d(nucleus_asi_d),
7458
                           .primary_asi_d(primary_asi_d),
7459
                           .secondary_asi_d(secondary_asi_d),
7460
                           .lendian_asi_d(lendian_asi_d),
7461
                           .nofault_asi_d(nofault_asi_d),
7462
                           .quad_asi_d  (quad_asi_d),
7463
                           .binit_quad_asi_d(binit_quad_asi_d),
7464
                           .dcache_byp_asi_d(dcache_byp_asi_d),
7465
                           .tlb_lng_ltncy_asi_d(tlb_lng_ltncy_asi_d),
7466
                           .tlb_byp_asi_d(tlb_byp_asi_d),
7467
                           .as_if_user_asi_d(as_if_user_asi_d),
7468
                           .atomic_asi_d(atomic_asi_d),
7469
                           .blk_asi_d   (blk_asi_d),
7470
                           .dc_diagnstc_asi_d(dc_diagnstc_asi_d),
7471
                           .dtagv_diagnstc_asi_d(dtagv_diagnstc_asi_d),
7472
                           .wr_only_asi_d(wr_only_asi_d),
7473
                           .rd_only_asi_d(rd_only_asi_d),
7474
                           .unimp_asi_d (unimp_asi_d),
7475
                           .ifu_nontlb_asi_d(ifu_nontlb_asi_d),
7476
                           .recognized_asi_d(recognized_asi_d),
7477
                           .ifill_tlb_asi_d(ifill_tlb_asi_d),
7478
                           .dfill_tlb_asi_d(dfill_tlb_asi_d),
7479
                           .rd_only_ltlb_asi_d(rd_only_ltlb_asi_d),
7480
                           .wr_only_ltlb_asi_d(wr_only_ltlb_asi_d),
7481
                           .phy_use_ec_asi_d(phy_use_ec_asi_d),
7482
                           .phy_byp_ec_asi_d(phy_byp_ec_asi_d),
7483
                           .mmu_rd_only_asi_d(mmu_rd_only_asi_d),
7484
                           .intrpt_disp_asi_d(intrpt_disp_asi_d),
7485
                           .dmmu_asi58_d(dmmu_asi58_d),
7486
                           .immu_asi50_d(immu_asi50_d),
7487
                           // Inputs
7488
                           .asi_d       (asi_d[7:0]));
7489
 
7490
dff #(31)  asidcd_stge (
7491
        .din    ({asi_internal_d,primary_asi_d,secondary_asi_d,nucleus_asi_d,
7492
    lendian_asi_d, tlb_byp_asi_d, dcache_byp_asi_d,nofault_asi_d,
7493
    tlb_lng_ltncy_asi_d,as_if_user_asi_d,atomic_asi_d, blk_asi_d,
7494
    dc_diagnstc_asi_d,dtagv_diagnstc_asi_d,
7495
    wr_only_asi_d, rd_only_asi_d,mmu_rd_only_asi_d,unimp_asi_d,dmmu_asi58_d, immu_asi50_d, quad_asi_d, binit_quad_asi_d,
7496
    ifu_nontlb_asi_d,recognized_asi_d, ifill_tlb_asi_d,
7497
    dfill_tlb_asi_d, rd_only_ltlb_asi_d,wr_only_ltlb_asi_d,phy_use_ec_asi_d, phy_byp_ec_asi_d, intrpt_disp_asi_d}),
7498
        .q      ({asi_internal_e,primary_asi_e,secondary_asi_e,nucleus_asi_e,
7499
    lendian_asi_e, tlb_byp_asi_e, dcache_byp_asi_e,nofault_asi_e,
7500
    tlb_lng_ltncy_asi_e,as_if_user_asi_e,atomic_asi_e, blk_asi_e,
7501
    dc_diagnstc_asi_e,dtagv_diagnstc_asi_e,
7502
    wr_only_asi_e, rd_only_asi_e,mmu_rd_only_asi_e,unimp_asi_e,dmmu_asi58_e, immu_asi50_e, quad_asi_e, binit_quad_asi_e,
7503
    ifu_nontlb_asi_e,recognized_asi_e,ifill_tlb_asi_e,
7504
    dfill_tlb_asi_e,rd_only_ltlb_asi_e,wr_only_ltlb_asi_e,phy_use_ec_asi_e, phy_byp_ec_asi_e, intrpt_disp_asi_e}),
7505
        .clk    (clk),
7506
        .se     (se),       .si (),          .so ()
7507
        );
7508
 
7509
assign  lsu_ffu_blk_asi_e = blk_asi_e & alt_space_e;
7510
assign  lsu_quad_asi_e = quad_asi_e ;
7511
 
7512
wire    unimp_asi_tmp ;
7513
dff #(23)  asidcd_stgm (
7514
        .din    ({asi_internal_e,dcache_byp_asi_e,nofault_asi_e,lendian_asi_e,tlb_lng_ltncy_asi_e,
7515
    as_if_user_asi_e,atomic_asi_e, blk_asi_e,dc_diagnstc_asi_e,dtagv_diagnstc_asi_e,
7516
    wr_only_asi_e, rd_only_asi_e,mmu_rd_only_asi_e,unimp_asi_e,dmmu_asi58_e, immu_asi50_e, quad_asi_e,binit_quad_asi_e,recognized_asi_e,
7517
    ifu_nontlb_asi_e,phy_use_ec_asi_e, phy_byp_ec_asi_e, intrpt_disp_asi_e}),
7518
        .q      ({asi_internal_m,dcache_byp_asi_m,nofault_asi_m,lendian_asi_m,tlb_lng_ltncy_asi_m,
7519
    as_if_user_asi_m,atomic_asi_m, blk_asi_m,dc_diagnstc_asi_m,dtagv_diagnstc_asi_m,
7520
    wr_only_asi_m, rd_only_asi_m,mmu_rd_only_asi_m,unimp_asi_tmp,dmmu_asi58_m, immu_asi50_m, quad_asi_m,binit_quad_asi_m,recognized_asi_tmp,
7521
    ifu_nontlb_asi_m,phy_use_ec_asi_m, phy_byp_ec_asi_m, intrpt_disp_asi_m}),
7522
        .clk    (clk),
7523
        .se     (se),       .si (),          .so ()
7524
        );
7525
 
7526
assign  lsu_blk_asi_m = blk_asi_m ;
7527
 
7528
   wire pa_wtchpt_unimp_m ; // Bug 3408
7529
   wire d_tsb_unimp_m, i_tsb_unimp_m, pctxt_unimp_m, sctxt_unimp_m;
7530
   wire unimp_m;
7531
 
7532
assign  pa_wtchpt_unimp_m  = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h40);
7533
assign  d_tsb_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h28);
7534
assign  pctxt_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h8);
7535
assign  sctxt_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h10);
7536
assign  i_tsb_unimp_m = immu_asi50_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h28);
7537
assign  unimp_m =  pa_wtchpt_unimp_m |
7538
                   d_tsb_unimp_m | i_tsb_unimp_m |
7539
                   pctxt_unimp_m | sctxt_unimp_m;
7540
 
7541
assign  unimp_asi_m = unimp_asi_tmp | unimp_m ;
7542
assign  recognized_asi_m = recognized_asi_tmp | unimp_m ;
7543
 
7544
dff #(12)  asidcd_stgg (
7545
        .din    ({asi_internal_m,dcache_byp_asi_m, lendian_asi_m,tlb_lng_ltncy_asi_m,
7546
  blk_asi_m,dc_diagnstc_asi_m,dtagv_diagnstc_asi_m,quad_asi_m,
7547
  binit_quad_asi_m,recognized_asi_m,ifu_nontlb_asi_m,  intrpt_disp_asi_m}),
7548
        .q      ({asi_internal_g,dcache_byp_asi_g, lendian_asi_g,tlb_lng_ltncy_asi_g,
7549
  blk_asi_g,dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,quad_asi_g,
7550
  binit_quad_asi_g,recognized_asi_g,ifu_nontlb_asi_g,  intrpt_disp_asi_g}),
7551
        .clk    (clk),
7552
        .se     (se),       .si (),          .so ()
7553
        );
7554
 
7555
//assign lsu_quad_asi_g = quad_asi_g;
7556
assign  ncache_asild_rq_g   = dcache_byp_asi_g & altspace_ldst_g ;
7557
 
7558
//st data alignment control signals
7559
wire st_sz_hw_g, st_sz_w_g, st_sz_dw_g, stdbl_g;
7560
wire stdbl_m;
7561
 
7562
//assign stdbl_m =  ldst_dbl_m & (~lsu_alt_space_m | (lsu_alt_space_m & ~blk_asi_m)) ;
7563
assign stdbl_m =  ldst_dbl_m ;
7564
 
7565
dff #(4) ff_st_sz_m (
7566
  .din ({hw_size, wd_size, dw_size, stdbl_m }),
7567
  .q   ({st_sz_hw_g, st_sz_w_g, st_sz_dw_g, stdbl_g}),
7568
  .clk (clk),
7569
  .se  (se), .si (), .so ()
7570
);
7571
 
7572
 
7573
//assign        bendian = lsu_bendian_access_g ;        // bendian store
7574
 
7575
wire    swap_sel_default_g, swap_sel_default_byte_7_2_g, st_hw_le_g,st_w_or_dbl_le_g,st_x_le_g;
7576
assign  bendian_g = ~l1hit_lendian_g ;
7577
//assign        swap_sel_default_g = (bendian_g | (~bendian_g & st_sz_b_g)) ;
7578
 
7579
assign swap_sel_default_g = ~ (st_hw_le_g | st_w_or_dbl_le_g | st_x_le_g);
7580
assign swap_sel_default_byte_7_2_g = ~ (st_w_or_dbl_le_g | st_x_le_g);
7581
 
7582
assign  st_hw_le_g = (st_sz_hw_g & ~bendian_g) & (~stdbl_g | fp_ldst_g) & st_inst_vld_unflushed ;  //0-in bug
7583
//bug 3169 
7584
// std(a) on floating point is the same as stx(a)
7585
assign  st_w_or_dbl_le_g = ((st_sz_w_g | (stdbl_g & ~fp_ldst_g)) & ~bendian_g) &  st_inst_vld_unflushed ;
7586
assign  st_x_le_g = (st_sz_dw_g & (~stdbl_g | fp_ldst_g)  & ~bendian_g) &  st_inst_vld_unflushed;
7587
 
7588
wire blkst_m_tmp ;
7589
dff  stgm_bst (
7590
  .din (ffu_lsu_blk_st_e),
7591
  .q   (blkst_m_tmp),
7592
  .clk (clk),
7593
  .se     (se),       .si (),          .so ()
7594
);
7595
 
7596
assign  blkst_m = blkst_m_tmp & ~(st_inst_vld_m  | flsh_inst_m
7597
                | ld_inst_vld_m) ; // Bug 3444
7598
 
7599
assign  lsu_blk_st_m = blkst_m ;
7600
 
7601
dff  stgg_bst (
7602
  .din (blkst_m),
7603
  .q   (blkst_g),
7604
  .clk (clk),
7605
  .se     (se),       .si (),          .so ()
7606
);
7607
 
7608
wire    bst_swap_sel_default_g, bst_swap_sel_default_byte_7_2_g,bst_st_hw_le_g,bst_st_w_or_dbl_le_g,bst_st_x_le_g;
7609
assign  lsu_swap_sel_default_g = (blkst_g ? bst_swap_sel_default_g : swap_sel_default_g) | rst_tri_en ;
7610
assign  lsu_swap_sel_default_byte_7_2_g = (blkst_g ? bst_swap_sel_default_byte_7_2_g : swap_sel_default_byte_7_2_g)
7611
                                         | rst_tri_en ;
7612
 
7613
assign  lsu_st_hw_le_g  = (blkst_g ? bst_st_hw_le_g : st_hw_le_g) & ~rst_tri_en ;
7614
assign  lsu_st_w_or_dbl_le_g = (blkst_g ? bst_st_w_or_dbl_le_g : st_w_or_dbl_le_g) & ~rst_tri_en ;
7615
assign  lsu_st_x_le_g = (blkst_g ? bst_st_x_le_g : st_x_le_g) & ~rst_tri_en ;
7616
 
7617
 
7618
//=========================================================================================
7619
//      BLK STORE
7620
//=========================================================================================
7621
 
7622
// Blk-St Handling : Snap state in g-stage of issue from IFU.
7623
 
7624
wire snap_blk_st_m,snap_blk_st_g ;
7625
assign snap_blk_st_m = st_inst_vld_m & blk_asi_m & lsu_alt_space_m & fp_ldst_m;
7626
 
7627
assign lsu_snap_blk_st_m = snap_blk_st_m ;
7628
 
7629
wire    snap_blk_st_local_m;
7630
assign  snap_blk_st_local_m = snap_blk_st_m & ifu_tlu_inst_vld_m ;
7631
 
7632
dff  stgg_snap (
7633
  .din (snap_blk_st_local_m),
7634
  .q   (snap_blk_st_g),
7635
  .clk (clk),
7636
  .se     (se),       .si (),          .so ()
7637
);
7638
 
7639
// output to be used in g-stage.
7640
dffe #(5) bst_state_g (
7641
        .din    ({lsu_swap_sel_default_g, lsu_swap_sel_default_byte_7_2_g, lsu_st_hw_le_g,
7642
                lsu_st_w_or_dbl_le_g,lsu_st_x_le_g}),
7643
        .q      ({bst_swap_sel_default_g, bst_swap_sel_default_byte_7_2_g,  bst_st_hw_le_g,
7644
                bst_st_w_or_dbl_le_g,bst_st_x_le_g}),
7645
        .en     (snap_blk_st_g),
7646
        .clk    (clk),
7647
        .se     (se),       .si (),          .so ()
7648
        );
7649
 
7650
 
7651
// snapped in g, used in m
7652
 
7653
   wire [39:10] blkst_pgnum_m;
7654
 
7655
dffe #(30) bst_pg_g (
7656
        .din    (tlb_pgnum[39:10]),
7657
        .q      (blkst_pgnum_m[39:10]),
7658
        .en     (snap_blk_st_g),
7659
        .clk    (clk),
7660
        .se     (se),       .si (),          .so ()
7661
        );
7662
 
7663
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b10 (.a(blkst_pgnum_m[10]), .z(lsu_blkst_pgnum_m[10]));
7664
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b11 (.a(blkst_pgnum_m[11]), .z(lsu_blkst_pgnum_m[11]));
7665
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b12 (.a(blkst_pgnum_m[12]), .z(lsu_blkst_pgnum_m[12]));
7666
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b13 (.a(blkst_pgnum_m[13]), .z(lsu_blkst_pgnum_m[13]));
7667
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b14 (.a(blkst_pgnum_m[14]), .z(lsu_blkst_pgnum_m[14]));
7668
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b15 (.a(blkst_pgnum_m[15]), .z(lsu_blkst_pgnum_m[15]));
7669
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b16 (.a(blkst_pgnum_m[16]), .z(lsu_blkst_pgnum_m[16]));
7670
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b17 (.a(blkst_pgnum_m[17]), .z(lsu_blkst_pgnum_m[17]));
7671
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b18 (.a(blkst_pgnum_m[18]), .z(lsu_blkst_pgnum_m[18]));
7672
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b19 (.a(blkst_pgnum_m[19]), .z(lsu_blkst_pgnum_m[19]));
7673
 
7674
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b20 (.a(blkst_pgnum_m[20]), .z(lsu_blkst_pgnum_m[20]));
7675
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b21 (.a(blkst_pgnum_m[21]), .z(lsu_blkst_pgnum_m[21]));
7676
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b22 (.a(blkst_pgnum_m[22]), .z(lsu_blkst_pgnum_m[22]));
7677
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b23 (.a(blkst_pgnum_m[23]), .z(lsu_blkst_pgnum_m[23]));
7678
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b24 (.a(blkst_pgnum_m[24]), .z(lsu_blkst_pgnum_m[24]));
7679
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b25 (.a(blkst_pgnum_m[25]), .z(lsu_blkst_pgnum_m[25]));
7680
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b26 (.a(blkst_pgnum_m[26]), .z(lsu_blkst_pgnum_m[26]));
7681
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b27 (.a(blkst_pgnum_m[27]), .z(lsu_blkst_pgnum_m[27]));
7682
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b28 (.a(blkst_pgnum_m[28]), .z(lsu_blkst_pgnum_m[28]));
7683
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b29 (.a(blkst_pgnum_m[29]), .z(lsu_blkst_pgnum_m[29]));
7684
 
7685
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b30 (.a(blkst_pgnum_m[30]), .z(lsu_blkst_pgnum_m[30]));
7686
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b31 (.a(blkst_pgnum_m[31]), .z(lsu_blkst_pgnum_m[31]));
7687
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b32 (.a(blkst_pgnum_m[32]), .z(lsu_blkst_pgnum_m[32]));
7688
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b33 (.a(blkst_pgnum_m[33]), .z(lsu_blkst_pgnum_m[33]));
7689
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b34 (.a(blkst_pgnum_m[34]), .z(lsu_blkst_pgnum_m[34]));
7690
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b35 (.a(blkst_pgnum_m[35]), .z(lsu_blkst_pgnum_m[35]));
7691
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b36 (.a(blkst_pgnum_m[36]), .z(lsu_blkst_pgnum_m[36]));
7692
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b37 (.a(blkst_pgnum_m[37]), .z(lsu_blkst_pgnum_m[37]));
7693
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b38 (.a(blkst_pgnum_m[38]), .z(lsu_blkst_pgnum_m[38]));
7694
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b39 (.a(blkst_pgnum_m[39]), .z(lsu_blkst_pgnum_m[39]));
7695
 
7696
//=========================================================================================
7697
//  Prefetch Count
7698
//=========================================================================================
7699
 
7700
wire [3:0] lsu_cpx_pref_ack;
7701
wire [3:0] no_spc_pref;
7702
 
7703
wire    [3:0]    pref_ackcnt0,pref_ackcnt1,pref_ackcnt2,pref_ackcnt3 ;
7704
wire    [3:0]    pref_ackcnt0_din,pref_ackcnt1_din,pref_ackcnt2_din,pref_ackcnt3_din ;
7705
 
7706
wire    [3:0]    pref_ackcnt_incr, pref_ackcnt_decr ;
7707
wire    [3:0]    pref_ackcnt_mx_incr, pref_ackcnt_mx_decr ;
7708
 
7709
   wire     lsu_pref_pcx_req_d1;
7710
 
7711
dff #(1) pref_pcx_req_stg (
7712
         .din (lsu_pref_pcx_req),
7713
         .q   (lsu_pref_pcx_req_d1),
7714
         .clk (clk),
7715
         .se  (se),       .si (),          .so ()
7716
);
7717
 
7718
assign   lsu_pcx_pref_issue[0] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[0] & ~lsu_pcx_req_squash_d1;
7719
assign   lsu_pcx_pref_issue[1] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[1] & ~lsu_pcx_req_squash_d1;
7720
assign   lsu_pcx_pref_issue[2] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[2] & ~lsu_pcx_req_squash_d1;
7721
assign   lsu_pcx_pref_issue[3] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[3] & ~lsu_pcx_req_squash_d1;
7722
 
7723
 
7724
   wire [3:0] pref_acknt_mx_incr_sel;
7725
   assign     pref_acknt_mx_incr_sel[3:0] = lsu_pcx_pref_issue[3:0];
7726
 
7727
assign  pref_ackcnt_mx_incr[3:0] =
7728
  (pref_acknt_mx_incr_sel[0] ? pref_ackcnt0[3:0] : 4'b0) |
7729
  (pref_acknt_mx_incr_sel[1] ? pref_ackcnt1[3:0] : 4'b0) |
7730
  (pref_acknt_mx_incr_sel[2] ? pref_ackcnt2[3:0] : 4'b0) |
7731
  (pref_acknt_mx_incr_sel[3] ? pref_ackcnt3[3:0] : 4'b0) ;
7732
 
7733
 
7734
//====================================================================================
7735
// prefetch ack back from CPX
7736
   wire       dcfill_active_e;
7737
   assign dcfill_active_e = lsu_dfq_ld_vld & ~memref_e ;
7738
 
7739
   wire   dfq_thread0, dfq_thread1, dfq_thread2, dfq_thread3;
7740
 
7741
   assign dfq_thread0 = dfill_thread0;
7742
   assign dfq_thread1 = dfill_thread1;
7743
   assign dfq_thread2 = dfill_thread2;
7744
   assign dfq_thread3 = dfill_thread3;
7745
 
7746
   assign lsu_cpx_pref_ack[0]  = dfq_thread0  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7747
   assign lsu_cpx_pref_ack[1]  = dfq_thread1  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7748
   assign lsu_cpx_pref_ack[2]  = dfq_thread2  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7749
   assign lsu_cpx_pref_ack[3]  = dfq_thread3  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7750
 
7751
   wire [3:0] pref_acknt_mx_decr_sel;
7752
   assign     pref_acknt_mx_decr_sel[3:0] = lsu_cpx_pref_ack[3:0];
7753
 
7754
assign    pref_ackcnt_mx_decr[3:0] =
7755
  (pref_acknt_mx_decr_sel[0] ? pref_ackcnt0[3:0] : 4'b0) |
7756
  (pref_acknt_mx_decr_sel[1] ? pref_ackcnt1[3:0] : 4'b0) |
7757
  (pref_acknt_mx_decr_sel[2] ? pref_ackcnt2[3:0] : 4'b0) |
7758
  (pref_acknt_mx_decr_sel[3] ? pref_ackcnt3[3:0] : 4'b0) ;
7759
 
7760
 
7761
assign  pref_ackcnt_incr[3:0] = pref_ackcnt_mx_incr[3:0] + 4'b0001 ;
7762
assign  pref_ackcnt_decr[3:0] = pref_ackcnt_mx_decr[3:0] - 4'b0001 ;
7763
 
7764
assign  pref_ackcnt0_din[3:0] = lsu_cpx_pref_ack[0] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7765
assign  pref_ackcnt1_din[3:0] = lsu_cpx_pref_ack[1] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7766
assign  pref_ackcnt2_din[3:0] = lsu_cpx_pref_ack[2] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7767
assign  pref_ackcnt3_din[3:0] = lsu_cpx_pref_ack[3] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7768
 
7769
wire    [3:0]    pref_ackcnt_en ;
7770
// if both occur in the same cycle then they cancel out.
7771
assign  pref_ackcnt_en[0] = lsu_pcx_pref_issue[0] ^ lsu_cpx_pref_ack[0] ;
7772
assign  pref_ackcnt_en[1] = lsu_pcx_pref_issue[1] ^ lsu_cpx_pref_ack[1] ;
7773
assign  pref_ackcnt_en[2] = lsu_pcx_pref_issue[2] ^ lsu_cpx_pref_ack[2] ;
7774
assign  pref_ackcnt_en[3] = lsu_pcx_pref_issue[3] ^ lsu_cpx_pref_ack[3] ;
7775
 
7776
// Thread0
7777
dffre #(4)  pref_ackcnt0_ff (
7778
        .din    (pref_ackcnt0_din[3:0]),
7779
        .q      (pref_ackcnt0[3:0]),
7780
        .rst    (reset),        .en     (pref_ackcnt_en[0]),
7781
        .clk    (clk),
7782
        .se     (se),       .si (),          .so ()
7783
        );
7784
 
7785
// Thread1
7786
dffre #(4)  pref_ackcnt1_ff (
7787
        .din    (pref_ackcnt1_din[3:0]),
7788
        .q      (pref_ackcnt1[3:0]),
7789
        .rst    (reset),        .en     (pref_ackcnt_en[1]),
7790
        .clk    (clk),
7791
        .se     (se),       .si (),          .so ()
7792
        );
7793
 
7794
// Thread2
7795
dffre #(4)  pref_ackcnt2_ff (
7796
        .din    (pref_ackcnt2_din[3:0]),
7797
        .q      (pref_ackcnt2[3:0]),
7798
        .rst    (reset),        .en     (pref_ackcnt_en[2]),
7799
        .clk    (clk),
7800
        .se     (se),       .si (),          .so ()
7801
        );
7802
 
7803
// Thread3
7804
dffre #(4)  pref_ackcnt3_ff (
7805
        .din    (pref_ackcnt3_din[3:0]),
7806
        .q      (pref_ackcnt3[3:0]),
7807
        .rst    (reset),        .en     (pref_ackcnt_en[3]),
7808
        .clk    (clk),
7809
        .se     (se),       .si (),          .so ()
7810
        );
7811
 
7812
assign  no_spc_pref[0] = pref_ackcnt0[3] ;
7813
assign  no_spc_pref[1] = pref_ackcnt1[3] ;
7814
assign  no_spc_pref[2] = pref_ackcnt2[3] ;
7815
assign  no_spc_pref[3] = pref_ackcnt3[3] ;
7816
 
7817
assign  lsu_no_spc_pref[3:0] = no_spc_pref[3:0];
7818
 
7819
//====================================================================
7820
   wire lsu_bist_e;
7821
 
7822
   assign lsu_bist_e = lsu_bist_wvld_e | lsu_bist_rvld_e;
7823
 
7824
   wire [10:0]      lmq_pcx_pkt_addr_din;
7825
 
7826
   wire [3:0] dfq_byp_thrd_sel;
7827
 
7828
mux4ds #(11) lmq_pcx_pkt_addr_mux (
7829
       .in0 ({lmq0_pcx_pkt_addr[10:0]}),
7830
       .in1 ({lmq1_pcx_pkt_addr[10:0]}),
7831
       .in2 ({lmq2_pcx_pkt_addr[10:0]}),
7832
       .in3 ({lmq3_pcx_pkt_addr[10:0]}),
7833
       .sel0(dfq_byp_thrd_sel[0]),
7834
       .sel1(dfq_byp_thrd_sel[1]),
7835
       .sel2(dfq_byp_thrd_sel[2]),
7836
       .sel3(dfq_byp_thrd_sel[3]),
7837
       .dout({lmq_pcx_pkt_addr_din[10:0]})
7838
);
7839
 
7840
dffe #(11)  lmq_pcx_pkt_addr_ff (
7841
           .din    ({lmq_pcx_pkt_addr_din[10:0]}),
7842
           .q      ({lmq_pcx_pkt_addr[10:0]}),
7843
           .en     (dfq_byp_ff_en),
7844
           .clk    (clk),
7845
           .se     (se),       .si (),          .so ()
7846
           );
7847
 
7848
 
7849
   wire [10:4] lmq_pcx_pkt_addr_minbf;
7850
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b10 (.a(lmq_pcx_pkt_addr[10]), .z(lmq_pcx_pkt_addr_minbf[10]));
7851
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b9 (.a(lmq_pcx_pkt_addr[9]), .z(lmq_pcx_pkt_addr_minbf[9]));
7852
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b8 (.a(lmq_pcx_pkt_addr[8]), .z(lmq_pcx_pkt_addr_minbf[8]));
7853
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b7 (.a(lmq_pcx_pkt_addr[7]), .z(lmq_pcx_pkt_addr_minbf[7]));
7854
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b6 (.a(lmq_pcx_pkt_addr[6]), .z(lmq_pcx_pkt_addr_minbf[6]));
7855
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b5 (.a(lmq_pcx_pkt_addr[5]), .z(lmq_pcx_pkt_addr_minbf[5]));
7856
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b4 (.a(lmq_pcx_pkt_addr[4]), .z(lmq_pcx_pkt_addr_minbf[4]));
7857
 
7858
 
7859
assign           lmq_ld_addr_b3 = lmq_pcx_pkt_addr[3];
7860
 
7861
 
7862
assign  dcache_fill_addr_e[10:0] =
7863
{11{lsu_dc_iob_access_e}}               & {dcache_iob_addr_e[7:0],3'b000} |
7864
{11{lsu_bist_wvld_e | lsu_bist_rvld_e}} & {mbist_dcache_index[6:0], mbist_dcache_word, 3'b000} |
7865
{11{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_addr_e[10:0] |
7866
{11{lsu_dfq_st_vld}}                    & st_dcfill_addr[10:0] |
7867
{11{lsu_dfq_ld_vld}}                    & {lmq_pcx_pkt_addr_minbf[10:4], lmq_pcx_pkt_addr[3:0]};
7868
 
7869
assign lsu_dcache_fill_addr_e[10:3] = dcache_fill_addr_e[10:3];
7870
 
7871
   wire [10:4] dcache_fill_addr_e_tmp;
7872
assign dcache_fill_addr_e_tmp[10:4]    = dcache_fill_addr_e[10:4];
7873
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b10 ( .a(dcache_fill_addr_e_tmp[10]),  .z(lsu_dcache_fill_addr_e_err[10]));
7874
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b9  ( .a(dcache_fill_addr_e_tmp[9]),  .z(lsu_dcache_fill_addr_e_err[9] ));
7875
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b8  ( .a(dcache_fill_addr_e_tmp[8]),  .z(lsu_dcache_fill_addr_e_err[8]));
7876
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b7  ( .a(dcache_fill_addr_e_tmp[7]),  .z(lsu_dcache_fill_addr_e_err[7]));
7877
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b6  ( .a(dcache_fill_addr_e_tmp[6]),  .z(lsu_dcache_fill_addr_e_err[6]));
7878
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b5  ( .a(dcache_fill_addr_e_tmp[5]),  .z(lsu_dcache_fill_addr_e_err[5]));
7879
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b4  ( .a(dcache_fill_addr_e_tmp[4]),  .z(lsu_dcache_fill_addr_e_err[4]));
7880
 
7881
// used as ld bypass 
7882
assign dcache_wr_addr_e[2:0] = dcache_fill_addr_e[2:0];
7883
 
7884
//ldfill doesn't need to create wrt byte msk, always fill one line
7885
assign waddr_enc[3:0] =
7886
{4{lsu_dc_iob_access_e}}               & {dcache_iob_addr_e[0],3'b000} |
7887
{4{lsu_bist_e}}                        & {mbist_dcache_word, 3'b000} |
7888
{4{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_addr_e[3:0] |
7889
{4{lsu_dfq_st_vld}}                    & st_dcfill_addr[3:0] ;
7890
 
7891
//==============================================================
7892
/*
7893
dff  #(4) lsu_thread_stgg (
7894
        .din    ({thread3_m, thread2_m, thread1_m,thread0_m}),
7895
        .q      (lsu_thread_g[3:0]),
7896
        .clk    (clk),
7897
        .se     (se),       .si (),          .so ()
7898
        );
7899
*/
7900
   assign lsu_thread_g[3] = thread3_g;
7901
   assign lsu_thread_g[2] = thread2_g;
7902
   assign lsu_thread_g[1] = thread1_g;
7903
   assign lsu_thread_g[0] = thread0_g;
7904
 
7905
//===============================================================
7906
//LMQ thread sel
7907
//===============================================================
7908
//lmq_ldd_vld
7909
   assign     dfq_byp_thrd_sel[0] = ~lsu_dfq_byp_tid[1] & ~lsu_dfq_byp_tid[0];
7910
   assign     dfq_byp_thrd_sel[1] = ~lsu_dfq_byp_tid[1] &  lsu_dfq_byp_tid[0];
7911
   assign     dfq_byp_thrd_sel[2] =  lsu_dfq_byp_tid[1] & ~lsu_dfq_byp_tid[0];
7912
   assign     dfq_byp_thrd_sel[3] =  lsu_dfq_byp_tid[1] &  lsu_dfq_byp_tid[0];
7913
 
7914
   wire       lmq_ldd_vld_din;
7915
 
7916
mux4ds #(1) lmq_ldd_vld_mux (
7917
       .in0 ({lmq0_ldd_vld}),
7918
       .in1 ({lmq1_ldd_vld}),
7919
       .in2 ({lmq2_ldd_vld}),
7920
       .in3 ({lmq3_ldd_vld}),
7921
       .sel0(dfq_byp_thrd_sel[0]),
7922
       .sel1(dfq_byp_thrd_sel[1]),
7923
       .sel2(dfq_byp_thrd_sel[2]),
7924
       .sel3(dfq_byp_thrd_sel[3]),
7925
       .dout({lmq_ldd_vld_din})
7926
);
7927
 
7928
dffe #(1)  lmq_ldd_vld_ff (
7929
           .din    ({lmq_ldd_vld_din}),
7930
           .q      ({lmq_ldd_vld}),
7931
           .en     (dfq_byp_ff_en),
7932
           .clk    (clk),
7933
           .se     (se),       .si (),          .so ()
7934
           );
7935
 
7936
//bist
7937
wire [1:0] bist_way_enc_e;
7938
wire [3:0] bist_way_e;
7939
 
7940
 
7941
assign bist_way_enc_e[1:0] =  lsu_dc_iob_access_e ?
7942
       lsu_dcache_iob_way_e[1:0] : mbist_dcache_way[1:0] ;
7943
 
7944
assign  bist_way_e[0] = ~bist_way_enc_e[1] & ~bist_way_enc_e[0] ;
7945
assign  bist_way_e[1] = ~bist_way_enc_e[1] &  bist_way_enc_e[0] ;
7946
assign  bist_way_e[2] =  bist_way_enc_e[1] & ~bist_way_enc_e[0] ;
7947
assign  bist_way_e[3] =  bist_way_enc_e[1] &  bist_way_enc_e[0] ;
7948
 
7949
assign lsu_bist_rsel_way_e[3:0] = bist_way_e[3:0];
7950
 
7951
   wire lmq_l2fill_fp_din;
7952
assign    lmq_l2fill_fp_din =
7953
       dfq_byp_thrd_sel[0] & lmq0_l2fill_fpld |
7954
       dfq_byp_thrd_sel[1] & lmq1_l2fill_fpld |
7955
       dfq_byp_thrd_sel[2] & lmq2_l2fill_fpld |
7956
       dfq_byp_thrd_sel[3] & lmq3_l2fill_fpld ;
7957
 
7958
dffe #(1) lmq_l2fill_fp_ff (
7959
           .din (lmq_l2fill_fp_din),
7960
           .q   (lsu_l2fill_fpld_e),
7961
           .en  (dfq_byp_ff_en),
7962
           .clk (clk),
7963
           .se  (se),       .si (),          .so ()
7964
           );
7965
 
7966
   wire lmq_ncache_ld_din;
7967
assign    lmq_ncache_ld_din =
7968
       dfq_byp_thrd_sel[0] & lmq0_ncache_ld |
7969
       dfq_byp_thrd_sel[1] & lmq1_ncache_ld |
7970
       dfq_byp_thrd_sel[2] & lmq2_ncache_ld |
7971
       dfq_byp_thrd_sel[3] & lmq3_ncache_ld ;
7972
 
7973
dffe #(1) lmq_ncache_ld_ff (
7974
           .din (lmq_ncache_ld_din),
7975
           .q   (lsu_ncache_ld_e),
7976
           .en  (dfq_byp_ff_en),
7977
           .clk (clk),
7978
           .se  (se),       .si (),          .so ()
7979
           );
7980
 
7981
//lmq
7982
   wire [1:0]      lmq_ldfill_way_din;
7983
 
7984
mux4ds #(2) lmq_ldfill_way_mux (
7985
       .in0 ({lmq0_pcx_pkt_way[1:0]}),
7986
       .in1 ({lmq1_pcx_pkt_way[1:0]}),
7987
       .in2 ({lmq2_pcx_pkt_way[1:0]}),
7988
       .in3 ({lmq3_pcx_pkt_way[1:0]}),
7989
       .sel0(dfq_byp_thrd_sel[0]),
7990
       .sel1(dfq_byp_thrd_sel[1]),
7991
       .sel2(dfq_byp_thrd_sel[2]),
7992
       .sel3(dfq_byp_thrd_sel[3]),
7993
       .dout({lmq_ldfill_way_din[1:0]})
7994
);
7995
   wire [1:0]      lmq_ldfill_way;
7996
 
7997
dffe #(2)  lmq_ldfill_way_ff (
7998
           .din    ({lmq_ldfill_way_din[1:0]}),
7999
           .q      ({lmq_ldfill_way[1:0]}),
8000
           .en     (dfq_byp_ff_en),
8001
           .clk    (clk),
8002
           .se     (se),       .si (),          .so ()
8003
           );
8004
 
8005
wire [1:0] dcache_fill_way_enc_e;
8006
 
8007
assign dcache_fill_way_enc_e[1:0] =
8008
{2{lsu_dc_iob_access_e}}               & lsu_dcache_iob_way_e[1:0] |
8009
{2{lsu_bist_e}}                        & bist_way_enc_e[1:0]       |
8010
{2{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_way_e[1:0]|
8011
{2{lsu_dfq_st_vld}}                    & lsu_st_way_e[1:0]         |
8012
{2{lsu_dfq_ld_vld}}                    & lmq_ldfill_way[1:0];
8013
 
8014
   assign lsu_dcache_fill_way_e[0] =   ~dcache_fill_way_enc_e[1] & ~dcache_fill_way_enc_e[0];
8015
   assign lsu_dcache_fill_way_e[1] =   ~dcache_fill_way_enc_e[1] &  dcache_fill_way_enc_e[0];
8016
   assign lsu_dcache_fill_way_e[2] =    dcache_fill_way_enc_e[1] & ~dcache_fill_way_enc_e[0];
8017
   assign lsu_dcache_fill_way_e[3] =    dcache_fill_way_enc_e[1] &  dcache_fill_way_enc_e[0];
8018
 
8019
//ld_rq_type
8020
 
8021
   wire [2:0]      lmq_ld_rq_type_din;
8022
 
8023
mux4ds #(3) lmq_ld_rq_type_mux (
8024
       .in0 ({lmq0_ld_rq_type[2:0]}),
8025
       .in1 ({lmq1_ld_rq_type[2:0]}),
8026
       .in2 ({lmq2_ld_rq_type[2:0]}),
8027
       .in3 ({lmq3_ld_rq_type[2:0]}),
8028
       .sel0(dfq_byp_thrd_sel[0]),
8029
       .sel1(dfq_byp_thrd_sel[1]),
8030
       .sel2(dfq_byp_thrd_sel[2]),
8031
       .sel3(dfq_byp_thrd_sel[3]),
8032
       .dout({lmq_ld_rq_type_din[2:0]})
8033
);
8034
 
8035
dffe #(3)  lmq_ld_rq_type_e_ff (
8036
           .din    ({lmq_ld_rq_type_din[2:0]}),
8037
           .q      ({lmq_ld_rq_type_e[2:0]}),
8038
           .en     (dfq_byp_ff_en),
8039
           .clk    (clk),
8040
           .se     (se),       .si (),          .so ()
8041
           );
8042
 
8043
//================================================================
8044
wire    other_flush_pipe_w ;
8045
 
8046
assign  other_flush_pipe_w = tlu_early_flush_pipe2_w | (lsu_ttype_vld_m2 & lsu_inst_vld_w);
8047
assign  dctl_flush_pipe_w = other_flush_pipe_w | ifu_lsu_flush_w ;
8048
// Staged ifu_tlu_flush_m should be used !!
8049
assign  dctl_early_flush_w = (lsu_local_early_flush_g | tlu_early_flush_pipe2_w | ifu_lsu_flush_w) ;
8050
 
8051
//================================================================
8052
// dcfill size
8053
   wire dcfill_size_mx_sel_e;
8054
//bug6216/eco6624 
8055
assign  dcfill_size_mx_sel_e  =  lsu_dc_iob_access_e | lsu_diagnstc_wr_src_sel_e;
8056
 
8057
mux2ds  #(2)  dcache_wr_size_e_mux (
8058
              .in0(2'b11),
8059
              .in1(lsu_st_dcfill_size_e[1:0]),
8060
              .sel0(dcfill_size_mx_sel_e),
8061
              .sel1(~dcfill_size_mx_sel_e),
8062
              .dout(dcache_wr_size_e[1:0])
8063
);
8064
 
8065
 
8066
//assign  lsu_dcfill_data_mx_sel_e  =   (dcache_iob_wr_e | dcache_iob_rd_e | lsu_bist_wvld_e);   
8067
   wire dcfill_data_mx_sel_e_l;
8068
 
8069
bw_u1_nor3_8x  UZsize_dcfill_data_mx_sel_e_l (.a (dcache_iob_wr_e),
8070
                                              .b (dcache_iob_rd_e),
8071
                                              .c (lsu_bist_wvld_e),
8072
                                              .z (dcfill_data_mx_sel_e_l));
8073
 
8074
bw_u1_inv_30x  UZsize_dcfill_data_mx_sel_e   ( .a(dcfill_data_mx_sel_e_l), .z (lsu_dcfill_data_mx_sel_e));
8075
 
8076
//================================================================
8077
   wire [3:0] dfq_thread_e;
8078
   assign     dfq_thread_e[0] = ~lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0];
8079
   assign     dfq_thread_e[1] = ~lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0];
8080
   assign     dfq_thread_e[2] =  lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0];
8081
   assign     dfq_thread_e[3] =  lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0];
8082
 
8083
   wire [3:0] dfq_byp_sel_e;
8084
   assign     dfq_byp_sel_e[0] = dfq_thread_e[0] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
8085
   assign     dfq_byp_sel_e[1] = dfq_thread_e[1] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
8086
   assign     dfq_byp_sel_e[2] = dfq_thread_e[2] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
8087
   assign     dfq_byp_sel_e[3] = dfq_thread_e[3] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
8088
 
8089
wire    [3:0] lmq_byp_misc_sel_e ;
8090
 
8091
assign  lmq_byp_misc_sel_e[0] = ld_thrd_byp_sel_e[0]  |        // select for ldxa/raw.
8092
                                dfq_byp_sel_e[0]  ;              // select for dfq.
8093
assign  lmq_byp_misc_sel_e[1] = ld_thrd_byp_sel_e[1]  |        // select for ldxa/raw.
8094
                                dfq_byp_sel_e[1] ;               // select for dfq.
8095
assign  lmq_byp_misc_sel_e[2] = ld_thrd_byp_sel_e[2]  |        // select for ldxa/raw.
8096
                                dfq_byp_sel_e[2] ;               // select for dfq.
8097
assign  lmq_byp_misc_sel_e[3] = ld_thrd_byp_sel_e[3]  |
8098
                                dfq_byp_sel_e[3] ;
8099
 
8100
   wire [2:0] byp_misc_addr_e;
8101
assign byp_misc_addr_e[2:0] = (lmq_byp_misc_sel_e[0] ? lmq0_pcx_pkt_addr[2:0] : 3'b0) |
8102
                              (lmq_byp_misc_sel_e[1] ? lmq1_pcx_pkt_addr[2:0] : 3'b0) |
8103
                              (lmq_byp_misc_sel_e[2] ? lmq2_pcx_pkt_addr[2:0] : 3'b0) |
8104
                              (lmq_byp_misc_sel_e[3] ? lmq3_pcx_pkt_addr[2:0] : 3'b0) ;
8105
 
8106
   wire [1:0] byp_misc_sz_e;
8107
assign byp_misc_sz_e[1:0] = (lmq_byp_misc_sel_e[0] ? lmq0_byp_misc_sz[1:0] : 2'b0) |
8108
                            (lmq_byp_misc_sel_e[1] ? lmq1_byp_misc_sz[1:0] : 2'b0) |
8109
                            (lmq_byp_misc_sel_e[2] ? lmq2_byp_misc_sz[1:0] : 2'b0) |
8110
                            (lmq_byp_misc_sel_e[3] ? lmq3_byp_misc_sz[1:0] : 2'b0) ;
8111
 
8112
 
8113
dff #(5)  lmq_byp_misc_stgm (
8114
           .din    ({byp_misc_addr_e[2:0], byp_misc_sz_e[1:0]}),
8115
           .q      ({lsu_byp_misc_addr_m[2:0], lsu_byp_misc_sz_m[1:0]}),
8116
           .clk    (clk),
8117
           .se     (se),       .si (),          .so ()
8118
           );
8119
 
8120
endmodule
8121
 
8122
 

powered by: WebSVN 2.1.0

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