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

Subversion Repositories s1_core

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

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

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: sparc_ifu_ifqctl.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
//  Module Name: sparc_ifu_ifqctl
24
//  Description:
25
//  Contains the control logic for the ifq and mil.
26
*/
27
////////////////////////////////////////////////////////////////////////
28
// Global header file includes
29
////////////////////////////////////////////////////////////////////////
30
 
31
/*
32
/* ========== Copyright Header Begin ==========================================
33
*
34
* OpenSPARC T1 Processor File: iop.h
35
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
36
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
37
*
38
* The above named program is free software; you can redistribute it and/or
39
* modify it under the terms of the GNU General Public
40
* License version 2 as published by the Free Software Foundation.
41
*
42
* The above named program is distributed in the hope that it will be
43
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
44
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
45
* General Public License for more details.
46
*
47
* You should have received a copy of the GNU General Public
48
* License along with this work; if not, write to the Free Software
49
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
50
*
51
* ========== Copyright Header End ============================================
52
*/
53
//-*- verilog -*-
54
////////////////////////////////////////////////////////////////////////
55
/*
56
//
57
//  Description:        Global header file that contain definitions that
58
//                      are common/shared at the IOP chip level
59
*/
60
////////////////////////////////////////////////////////////////////////
61
 
62
 
63
// Address Map Defines
64
// ===================
65
 
66
 
67
 
68
 
69
// CMP space
70
 
71
 
72
 
73
// IOP space
74
 
75
 
76
 
77
 
78
                               //`define ENET_ING_CSR     8'h84
79
                               //`define ENET_EGR_CMD_CSR 8'h85
80
 
81
 
82
 
83
 
84
 
85
 
86
 
87
 
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
// L2 space
96
 
97
 
98
 
99
// More IOP space
100
 
101
 
102
 
103
 
104
 
105
//Cache Crossbar Width and Field Defines
106
//======================================
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
 
117
 
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
 
134
 
135
 
136
 
137
 
138
 
139
 
140
 
141
 
142
 
143
 
144
 
145
 
146
 
147
 
148
 
149
 
150
 
151
 
152
//bits 133:128 are shared by different fields
153
//for different packet types.
154
 
155
 
156
 
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
 
175
 
176
 
177
 
178
 
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
 
209
 
210
 
211
 
212
 
213
 
214
 
215
 
216
//End cache crossbar defines
217
 
218
 
219
// Number of COS supported by EECU 
220
 
221
 
222
 
223
// 
224
// BSC bus sizes
225
// =============
226
//
227
 
228
// General
229
 
230
 
231
 
232
 
233
// CTags
234
 
235
 
236
 
237
 
238
 
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
 
247
// reinstated temporarily
248
 
249
 
250
 
251
 
252
// CoS
253
 
254
 
255
 
256
 
257
 
258
 
259
// L2$ Bank
260
 
261
 
262
 
263
// L2$ Req
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
// L2$ Ack
278
 
279
 
280
 
281
 
282
 
283
 
284
 
285
 
286
// Enet Egress Command Unit
287
 
288
 
289
 
290
 
291
 
292
 
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
// Enet Egress Packet Unit
302
 
303
 
304
 
305
 
306
 
307
 
308
 
309
 
310
 
311
 
312
 
313
 
314
 
315
// This is cleaved in between Egress Datapath Ack's
316
 
317
 
318
 
319
 
320
 
321
 
322
 
323
 
324
// Enet Egress Datapath
325
 
326
 
327
 
328
 
329
 
330
 
331
 
332
 
333
 
334
 
335
 
336
 
337
 
338
 
339
 
340
 
341
// In-Order / Ordered Queue: EEPU
342
// Tag is: TLEN, SOF, EOF, QID = 15
343
 
344
 
345
 
346
 
347
 
348
 
349
// Nack + Tag Info + CTag
350
 
351
 
352
 
353
 
354
// ENET Ingress Queue Management Req
355
 
356
 
357
 
358
 
359
 
360
 
361
 
362
 
363
 
364
 
365
 
366
 
367
// ENET Ingress Queue Management Ack
368
 
369
 
370
 
371
 
372
 
373
 
374
 
375
 
376
// Enet Ingress Packet Unit
377
 
378
 
379
 
380
 
381
 
382
 
383
 
384
 
385
 
386
 
387
 
388
 
389
// ENET Ingress Packet Unit Ack
390
 
391
 
392
 
393
 
394
 
395
 
396
 
397
// In-Order / Ordered Queue: PCI
398
// Tag is: CTAG
399
 
400
 
401
 
402
 
403
 
404
// PCI-X Request
405
 
406
 
407
 
408
 
409
 
410
 
411
 
412
 
413
 
414
 
415
 
416
// PCI_X Acknowledge
417
 
418
 
419
 
420
 
421
 
422
 
423
 
424
 
425
 
426
 
427
 
428
//
429
// BSC array sizes
430
//================
431
//
432
 
433
 
434
 
435
 
436
 
437
 
438
 
439
 
440
 
441
 
442
 
443
 
444
// ECC syndrome bits per memory element
445
 
446
 
447
 
448
 
449
//
450
// BSC Port Definitions
451
// ====================
452
//
453
// Bits 7 to 4 of curr_port_id
454
 
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462
// Number of ports of each type
463
 
464
 
465
// Bits needed to represent above
466
 
467
 
468
// How wide the linked list pointers are
469
// 60b for no payload (2CoS)
470
// 80b for payload (2CoS)
471
 
472
//`define BSC_OBJ_PTR   80
473
//`define BSC_HD1_HI    69
474
//`define BSC_HD1_LO    60
475
//`define BSC_TL1_HI    59
476
//`define BSC_TL1_LO    50
477
//`define BSC_CT1_HI    49
478
//`define BSC_CT1_LO    40
479
//`define BSC_HD0_HI    29
480
//`define BSC_HD0_LO    20
481
//`define BSC_TL0_HI    19
482
//`define BSC_TL0_LO    10
483
//`define BSC_CT0_HI     9
484
//`define BSC_CT0_LO     0
485
 
486
 
487
 
488
 
489
 
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
 
515
 
516
 
517
 
518
 
519
// I2C STATES in DRAMctl
520
 
521
 
522
 
523
 
524
 
525
 
526
 
527
//
528
// IOB defines
529
// ===========
530
//
531
 
532
 
533
 
534
 
535
 
536
 
537
 
538
 
539
 
540
 
541
 
542
 
543
 
544
 
545
 
546
 
547
 
548
 
549
 
550
//`define IOB_INT_STAT_WIDTH   32
551
//`define IOB_INT_STAT_HI      31
552
//`define IOB_INT_STAT_LO       0
553
 
554
 
555
 
556
 
557
 
558
 
559
 
560
 
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
 
575
 
576
 
577
 
578
 
579
 
580
 
581
 
582
 
583
 
584
 
585
 
586
 
587
 
588
 
589
 
590
 
591
 
592
 
593
 
594
 
595
 
596
 
597
 
598
 
599
 
600
 
601
 
602
// fixme - double check address mapping
603
// CREG in `IOB_INT_CSR space
604
 
605
 
606
 
607
 
608
 
609
 
610
 
611
 
612
 
613
 
614
// CREG in `IOB_MAN_CSR space
615
 
616
 
617
 
618
 
619
 
620
 
621
 
622
 
623
 
624
 
625
 
626
 
627
 
628
 
629
 
630
 
631
 
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
 
640
 
641
 
642
 
643
 
644
 
645
 
646
 
647
 
648
 
649
 
650
 
651
 
652
// Address map for TAP access of SPARC ASI
653
 
654
 
655
 
656
 
657
 
658
 
659
 
660
 
661
 
662
 
663
 
664
 
665
 
666
//
667
// CIOP UCB Bus Width
668
// ==================
669
//
670
//`define IOB_EECU_WIDTH       16  // ethernet egress command
671
//`define EECU_IOB_WIDTH       16
672
 
673
//`define IOB_NRAM_WIDTH       16  // NRAM (RLDRAM previously)
674
//`define NRAM_IOB_WIDTH        4
675
 
676
 
677
 
678
 
679
//`define IOB_ENET_ING_WIDTH   32  // ethernet ingress
680
//`define ENET_ING_IOB_WIDTH    8
681
 
682
//`define IOB_ENET_EGR_WIDTH    4  // ethernet egress
683
//`define ENET_EGR_IOB_WIDTH    4
684
 
685
//`define IOB_ENET_MAC_WIDTH    4  // ethernet MAC
686
//`define ENET_MAC_IOB_WIDTH    4
687
 
688
 
689
 
690
 
691
//`define IOB_BSC_WIDTH         4  // BSC
692
//`define BSC_IOB_WIDTH         4
693
 
694
 
695
 
696
 
697
 
698
 
699
 
700
//`define IOB_CLSP_WIDTH        4  // clk spine unit
701
//`define CLSP_IOB_WIDTH        4
702
 
703
 
704
 
705
 
706
 
707
//
708
// CIOP UCB Buf ID Type
709
// ====================
710
//
711
 
712
 
713
 
714
//
715
// Interrupt Device ID
716
// ===================
717
//
718
// Caution: DUMMY_DEV_ID has to be 9 bit wide
719
//          for fields to line up properly in the IOB.
720
 
721
 
722
 
723
//
724
// Soft Error related definitions 
725
// ==============================
726
//
727
 
728
 
729
 
730
//
731
// CMP clock
732
// =========
733
//
734
 
735
 
736
 
737
 
738
//
739
// NRAM/IO Interface
740
// =================
741
//
742
 
743
 
744
 
745
 
746
 
747
 
748
 
749
 
750
 
751
 
752
//
753
// NRAM/ENET Interface
754
// ===================
755
//
756
 
757
 
758
 
759
 
760
 
761
 
762
 
763
//
764
// IO/FCRAM Interface
765
// ==================
766
//
767
 
768
 
769
 
770
 
771
 
772
 
773
//
774
// PCI Interface
775
// ==================
776
// Load/store size encodings
777
// -------------------------
778
// Size encoding
779
// 000 - byte
780
// 001 - half-word
781
// 010 - word
782
// 011 - double-word
783
// 100 - quad
784
 
785
 
786
 
787
 
788
 
789
 
790
//
791
// JBI<->SCTAG Interface
792
// =======================
793
// Outbound Header Format
794
 
795
 
796
 
797
 
798
 
799
 
800
 
801
 
802
 
803
 
804
 
805
 
806
 
807
 
808
 
809
 
810
 
811
 
812
 
813
 
814
 
815
 
816
 
817
 
818
 
819
 
820
 
821
// Inbound Header Format
822
 
823
 
824
 
825
 
826
 
827
 
828
 
829
 
830
 
831
 
832
 
833
 
834
 
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
//
843
// JBI->IOB Mondo Header Format
844
// ============================
845
//
846
 
847
 
848
 
849
 
850
 
851
 
852
 
853
 
854
 
855
 
856
 
857
 
858
 
859
 
860
// JBI->IOB Mondo Bus Width/Cycle
861
// ==============================
862
// Cycle  1 Header[15:8]
863
// Cycle  2 Header[ 7:0]
864
// Cycle  3 J_AD[127:120]
865
// Cycle  4 J_AD[119:112]
866
// .....
867
// Cycle 18 J_AD[  7:  0]
868
 
869
 
870
/*
871
/* ========== Copyright Header Begin ==========================================
872
*
873
* OpenSPARC T1 Processor File: ifu.h
874
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
875
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
876
*
877
* The above named program is free software; you can redistribute it and/or
878
* modify it under the terms of the GNU General Public
879
* License version 2 as published by the Free Software Foundation.
880
*
881
* The above named program is distributed in the hope that it will be
882
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
883
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
884
* General Public License for more details.
885
*
886
* You should have received a copy of the GNU General Public
887
* License along with this work; if not, write to the Free Software
888
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
889
*
890
* ========== Copyright Header End ============================================
891
*/
892
////////////////////////////////////////////////////////////////////////
893
/*
894
//
895
//  Module Name: ifu.h
896
//  Description:
897
//  All ifu defines
898
*/
899
 
900
//--------------------------------------------
901
// Icache Values in IFU::ICD/ICV/ICT/FDP/IFQDP
902
//--------------------------------------------
903
// Set Values
904
 
905
// IC_IDX_HI = log(icache_size/4ways) - 1
906
 
907
 
908
// !!IMPORTANT!! a change to IC_LINE_SZ will mean a change to the code as
909
//   well.  Unfortunately this has not been properly parametrized.
910
//   Changing the IC_LINE_SZ param alone is *not* enough.
911
 
912
 
913
// !!IMPORTANT!! a change to IC_TAG_HI will mean a change to the code as
914
//   well.  Changing the IC_TAG_HI param alone is *not* enough to
915
//   change the PA range. 
916
// highest bit of PA
917
 
918
 
919
 
920
// Derived Values
921
// 4095
922
 
923
 
924
// number of entries - 1 = 511
925
 
926
 
927
// 12
928
 
929
 
930
// 28
931
 
932
 
933
// 7
934
 
935
 
936
// tags for all 4 ways + parity
937
// 116
938
 
939
 
940
// 115
941
 
942
 
943
 
944
//----------------------------------------------------------------------
945
// For thread scheduler in IFU::DTU::SWL
946
//----------------------------------------------------------------------
947
// thread states:  (thr_state[4:0])
948
 
949
 
950
 
951
 
952
 
953
 
954
 
955
 
956
 
957
// thread configuration register bit fields
958
 
959
 
960
 
961
 
962
 
963
 
964
 
965
//----------------------------------------------------------------------
966
// For MIL fsm in IFU::IFQ
967
//----------------------------------------------------------------------
968
 
969
 
970
 
971
 
972
 
973
 
974
 
975
 
976
 
977
 
978
 
979
//---------------------------------------------------
980
// Interrupt Block
981
//---------------------------------------------------
982
 
983
 
984
 
985
 
986
 
987
 
988
 
989
//-------------------------------------
990
// IFQ
991
//-------------------------------------
992
// valid bit plus ifill
993
 
994
 
995
 
996
 
997
 
998
 
999
 
1000
 
1001
 
1002
 
1003
 
1004
 
1005
 
1006
//`ifdef SPARC_L2_64B
1007
 
1008
 
1009
//`else
1010
//`define BANK_ID_HI 8
1011
//`define BANK_ID_LO 7
1012
//`endif
1013
 
1014
//`define CPX_INV_PA_HI  116
1015
//`define CPX_INV_PA_LO  112
1016
 
1017
 
1018
 
1019
 
1020
 
1021
 
1022
 
1023
//----------------------------------------
1024
// IFU Traps
1025
//----------------------------------------
1026
// precise
1027
 
1028
 
1029
 
1030
 
1031
 
1032
 
1033
 
1034
 
1035
 
1036
 
1037
 
1038
 
1039
 
1040
 
1041
 
1042
// disrupting
1043
 
1044
 
1045
 
1046
 
1047
 
1048
 
1049
 
1050
 
1051
 
1052
module sparc_ifu_ifqctl(/*AUTOARG*/
1053
   // Outputs
1054
   ifu_lsu_inv_clear, ifu_lsu_ibuf_busy, ifu_lsu_asi_ack,
1055
   ifu_lsu_ldxa_illgl_va_w2, ifu_lsu_fwd_wr_ack, ifu_lsu_pcxreq_d,
1056
   ifu_lsu_destid_s, ifu_tlu_l2imiss, ifq_fcl_stallreq,
1057
   ifq_swl_stallreq, ifq_fcl_flush_sonly_e, ifq_fcl_wrreq_bf,
1058
   ifq_fcl_rdreq_bf, ifq_fcl_icd_wrreq_bf, ifq_fcl_ictv_wrreq_bf,
1059
   ifq_erb_fwdrd_bf, ifq_erb_rdtag_f, ifq_erb_rdinst_f,
1060
   ifq_erb_asi_erren_i2, ifq_erb_asi_errstat_i2,
1061
   ifq_erb_asi_errinj_i2, ifq_erb_asi_erraddr_i2,
1062
   ifq_erb_asi_imask_i2, ifq_erb_asiwr_i2, ifq_fcl_asird_bf,
1063
   ifq_fcl_asi_tid_bf, ifq_erb_ue_rep, ifq_erb_ce_rep, ifq_erb_l2_ue,
1064
   ifq_erb_io_ue, ifq_erb_ifet_ce, ifq_erb_l2err_tid,
1065
   ifq_icv_wrdata_bf, ifq_icd_worden_bf, ifq_fcl_fill_thr,
1066
   ifq_dtu_thrrdy, ifq_dtu_pred_rdy, ifc_ifd_filladdr4_i2,
1067
   ifc_ifd_reqvalid_e, ifc_ifd_idx_sel_fwd_i2, ifc_ifd_errinv_e,
1068
   ifc_ifd_uncached_e, ifc_ifd_thrid_e, ifc_ifd_pcxline_adj_d,
1069
   ifc_inv_asireq_i2, ifc_ifd_repway_s, ifq_sscan_data,
1070
   ifc_ifd_milfill_sel_i2_l, ifc_ifd_finst_sel_l,
1071
   ifc_ifd_milreq_sel_d_l, ifc_ifd_ifqbyp_sel_fwd_l,
1072
   ifc_ifd_ifqbyp_sel_inq_l, ifc_ifd_ifqbyp_sel_asi_l,
1073
   ifc_ifd_ifqbyp_sel_lsu_l, ifc_ifd_ifqbyp_en_l,
1074
   ifc_ifd_addr_sel_bist_i2_l, ifc_ifd_addr_sel_asi_i2_l,
1075
   ifc_ifd_addr_sel_old_i2_l, ifc_ifd_addr_sel_fill_i2_l,
1076
   ifq_icd_data_sel_bist_i2, ifq_icd_data_sel_fill_i2,
1077
   ifq_icd_data_sel_old_i2, ifc_ifd_ldmil_sel_new, ifc_ifd_ld_inq_i1,
1078
   ifc_inv_ifqadv_i2, so,
1079
   // Inputs
1080
   lsu_ifu_cpxpkt_wayvld_i1, ifd_ifc_milhit_s, ifd_ifc_instoffset0, ifd_ifc_instoffset1,
1081
   ifd_ifc_instoffset2, ifd_ifc_instoffset3, ifd_ifc_cpxvalid_i1,
1082
   ifd_ifc_cpxreq_i1, ifd_ifc_cpxreq_nxt, ifd_ifc_cpxthr_nxt,
1083
   ifd_ifc_cpxvld_i2, ifd_ifc_iobpkt_i2, ifd_ifc_4bpkt_i2,
1084
   ifd_ifc_cpxnc_i2, ifd_ifc_fwd2ic_i2, ifd_ifc_cpxce_i2,
1085
   ifd_ifc_cpxue_i2, ifd_ifc_cpxms_i2, ifd_ifc_miladdr4_i2,
1086
   ifd_ifc_asiaddr_i2, ifd_ifc_asi_vachklo_i2, ifd_ifc_destid0,
1087
   ifd_ifc_destid1, ifd_ifc_destid2, ifd_ifc_destid3,
1088
   ifd_ifc_newdestid_s, ifd_ifc_pcxline_d, inv_ifc_inv_pending,
1089
   fcl_ifq_icmiss_s1, fcl_ifq_rdreq_s1, fcl_ifq_thr_s1,
1090
   fcl_ifq_canthr, fcl_ifq_grant_bf, dtu_ifq_kill_latest_d,
1091
   erb_ifq_ifeterr_d1, erb_ifq_itlberr_s1, lsu_ifu_pcxpkt_ack_d,
1092
   lsu_ifu_direct_map_l1, lsu_ifu_asi_vld, lsu_ifu_asi_state,
1093
   lsu_ifu_asi_load, lsu_ifu_asi_thrid, fcl_ifq_icache_en_s_l,
1094
   mbist_ifq_run_bist, mbist_icache_write, mbist_icache_read,
1095
   ctu_sscan_tid, rclk, se, si, gdbginit_l, arst_l, grst_l,
1096
   rst_tri_en, sehold
1097
   );
1098
 
1099
   input          lsu_ifu_cpxpkt_wayvld_i1;
1100
   input [3:0]     ifd_ifc_milhit_s;      // if an Imiss hits in MIL
1101
   input [1:0]    ifd_ifc_instoffset0; // to select inst to TIR
1102
   input [1:0]    ifd_ifc_instoffset1; // to select inst to TIR
1103
   input [1:0]    ifd_ifc_instoffset2; // to select inst to TIR
1104
   input [1:0]    ifd_ifc_instoffset3; // to select inst to TIR
1105
 
1106
   input         ifd_ifc_cpxvalid_i1;
1107
   input [(143 - 140 + 1):0] ifd_ifc_cpxreq_i1;
1108
 
1109
   input [3:0]   ifd_ifc_cpxreq_nxt;
1110
   input [1:0]   ifd_ifc_cpxthr_nxt;
1111
   input         ifd_ifc_cpxvld_i2;
1112
 
1113
   input         ifd_ifc_iobpkt_i2;
1114
   input         ifd_ifc_4bpkt_i2;
1115
   input         ifd_ifc_cpxnc_i2;
1116
   input         ifd_ifc_fwd2ic_i2;
1117
   input         ifd_ifc_cpxce_i2,
1118
                             ifd_ifc_cpxue_i2,
1119
                 ifd_ifc_cpxms_i2;
1120
 
1121
   input [3:0]   ifd_ifc_miladdr4_i2;
1122
 
1123
   input [3:2]   ifd_ifc_asiaddr_i2;
1124
   input         ifd_ifc_asi_vachklo_i2;
1125
 
1126
   input [2:0]   ifd_ifc_destid0,
1127
                             ifd_ifc_destid1,
1128
                             ifd_ifc_destid2,
1129
                             ifd_ifc_destid3,
1130
                             ifd_ifc_newdestid_s;
1131
   input [4:2]   ifd_ifc_pcxline_d;
1132
//   input [7:0]   ifd_ifc_mil_repway_s;   
1133
 
1134
   input         inv_ifc_inv_pending;
1135
 
1136
   input         fcl_ifq_icmiss_s1;   // icache miss
1137
   input         fcl_ifq_rdreq_s1;
1138
 
1139
   input [1:0]   fcl_ifq_thr_s1;
1140
 
1141
   input [3:0]   fcl_ifq_canthr;        // cancel the imiss reqs to
1142
                                        // these threads
1143
   input         fcl_ifq_grant_bf;
1144
 
1145
   input         dtu_ifq_kill_latest_d;
1146
   input         erb_ifq_ifeterr_d1;
1147
   input         erb_ifq_itlberr_s1;
1148
 
1149
   input         lsu_ifu_pcxpkt_ack_d;
1150
   input         lsu_ifu_direct_map_l1;
1151
 
1152
   input         lsu_ifu_asi_vld;
1153
   input [7:0]   lsu_ifu_asi_state;
1154
   input         lsu_ifu_asi_load;
1155
   input [1:0]   lsu_ifu_asi_thrid;
1156
 
1157
   input         fcl_ifq_icache_en_s_l;
1158
 
1159
   input         mbist_ifq_run_bist,
1160
                 mbist_icache_write,
1161
                             mbist_icache_read;
1162
 
1163
   input [3:0]   ctu_sscan_tid;
1164
 
1165
   input         rclk,
1166
                 se,
1167
                 si,
1168
                 gdbginit_l,
1169
                 arst_l,
1170
                 grst_l;
1171
 
1172
   input         rst_tri_en;
1173
   input         sehold;
1174
 
1175
   // outputs
1176
   output        ifu_lsu_inv_clear;
1177
   output        ifu_lsu_ibuf_busy;
1178
   output        ifu_lsu_asi_ack;
1179
   output        ifu_lsu_ldxa_illgl_va_w2;
1180
 
1181
   output        ifu_lsu_fwd_wr_ack;
1182
 
1183
   output        ifu_lsu_pcxreq_d;
1184
   output [2:0]  ifu_lsu_destid_s;
1185
 
1186
   output [3:0]  ifu_tlu_l2imiss;
1187
 
1188
   output        ifq_fcl_stallreq;
1189
   output        ifq_swl_stallreq;
1190
   output        ifq_fcl_flush_sonly_e;
1191
 
1192
   output        ifq_fcl_wrreq_bf;
1193
   output        ifq_fcl_rdreq_bf;
1194
 
1195
   output        ifq_fcl_icd_wrreq_bf,
1196
                             ifq_fcl_ictv_wrreq_bf;
1197
   output        ifq_erb_fwdrd_bf;
1198
   output        ifq_erb_rdtag_f;
1199
   output        ifq_erb_rdinst_f;
1200
   output        ifq_erb_asi_erren_i2;
1201
   output        ifq_erb_asi_errstat_i2;
1202
   output        ifq_erb_asi_errinj_i2;
1203
   output        ifq_erb_asi_erraddr_i2;
1204
   output        ifq_erb_asi_imask_i2;
1205
   output        ifq_erb_asiwr_i2;
1206
 
1207
   output        ifq_fcl_asird_bf;
1208
   output [1:0]  ifq_fcl_asi_tid_bf;
1209
 
1210
   output        ifq_erb_ue_rep;
1211
   output        ifq_erb_ce_rep;
1212
   output        ifq_erb_l2_ue;
1213
   output        ifq_erb_io_ue;
1214
   output        ifq_erb_ifet_ce;
1215
   output [1:0]  ifq_erb_l2err_tid;
1216
 
1217
   output        ifq_icv_wrdata_bf;
1218
   output [3:0]  ifq_icd_worden_bf;
1219
 
1220
   output [3:0]  ifq_fcl_fill_thr;     // should be same stage as 
1221
   // fill_inst
1222
   output [3:0]  ifq_dtu_thrrdy;
1223
   output [3:0]  ifq_dtu_pred_rdy;
1224
 
1225
   output        ifc_ifd_filladdr4_i2;
1226
   output        ifc_ifd_reqvalid_e;
1227
   output        ifc_ifd_idx_sel_fwd_i2;
1228
 
1229
   output        ifc_ifd_errinv_e;
1230
   output        ifc_ifd_uncached_e;
1231
   output [1:0]  ifc_ifd_thrid_e;
1232
   output [4:2]  ifc_ifd_pcxline_adj_d;
1233
 
1234
   output        ifc_inv_asireq_i2;
1235
 
1236
   output [1:0]  ifc_ifd_repway_s;
1237
 
1238
   output [3:0]  ifq_sscan_data;
1239
 
1240
   // mux selects
1241
   output [3:0]  ifc_ifd_milfill_sel_i2_l;
1242
   output [3:0]  ifc_ifd_finst_sel_l;
1243
   output [3:0]  ifc_ifd_milreq_sel_d_l;
1244
   output        ifc_ifd_ifqbyp_sel_fwd_l, // select next input to ifq pipe
1245
                             ifc_ifd_ifqbyp_sel_inq_l,
1246
                             ifc_ifd_ifqbyp_sel_asi_l,
1247
                             ifc_ifd_ifqbyp_sel_lsu_l;
1248
         output        ifc_ifd_ifqbyp_en_l;
1249
 
1250
   output        ifc_ifd_addr_sel_bist_i2_l,
1251
                             ifc_ifd_addr_sel_asi_i2_l,
1252
                 ifc_ifd_addr_sel_old_i2_l,
1253
                             ifc_ifd_addr_sel_fill_i2_l;
1254
 
1255
   output        ifq_icd_data_sel_bist_i2,
1256
                             ifq_icd_data_sel_fill_i2,
1257
                             ifq_icd_data_sel_old_i2;
1258
 
1259
   // 2:1 mux selects
1260
   output [3:0]  ifc_ifd_ldmil_sel_new;     // mil load enable
1261
 
1262
 
1263
   output        ifc_ifd_ld_inq_i1;
1264
 
1265
   output        ifc_inv_ifqadv_i2;         // move a new op from ifq
1266
         // pipe to icache
1267
 
1268
   output        so;
1269
 
1270
   //----------------------------------------------------------------------
1271
   // Declarations
1272
   //----------------------------------------------------------------------   
1273
   // local signals
1274
   wire [3:0]    thr_s1,      // s1 thread which missed in I$
1275
                             thr_d1,
1276
                 thr_e1,
1277
                             dfthr_f,     // thread currently being filled in I$
1278
                 dfthr_next_i2,
1279
                             dfthr_i2,    // next thread to be filled from CPX
1280
                 milfthr_i2,
1281
                             dpcxthr_s,
1282
                             dpcxthr_d;   // thread being transmitted to lsu
1283
 
1284
   wire [1:0]    thrid_d,
1285
                 thrid_e;
1286
 
1287
   wire [3:0]    pcx_accept_d;
1288
 
1289
   wire          req_pending_d,
1290
//                           req_pending_e,
1291
                             req_accept_d,
1292
//                 can_pcx_d,
1293
                 pcxreq_vbit_d;
1294
 
1295
   wire [3:0]    comp_valid_s,
1296
                             mil_valid_s,
1297
                 mil_cancel;
1298
 
1299
   wire [3:0]    finst_i2,
1300
                 finst0,
1301
                 finst1,
1302
                 finst2,
1303
                 finst3;
1304
 
1305
   wire [2:0]    milchld0,
1306
                             milchld1,
1307
                             milchld2,
1308
                             milchld3,
1309
                             next_milchld,
1310
                             milchld_d1;
1311
   wire          milchld_vld_f,
1312
                             next_milchld_i2,
1313
                             milchld_vld_i2;
1314
 
1315
   wire [3:0]    mil0_state,
1316
                 mil1_state,
1317
                 mil2_state,
1318
                 mil3_state;
1319
 
1320
   wire [2:0]    i2out;         // state machine output in i2 stage
1321
 
1322
   wire          any_milhit_qual_s,     // hit in MIL
1323
                 any_qualhit_or_io_s,
1324
                             icmiss_qual_s,
1325
//                           reqq_empty,    // no pending requests in MIL
1326
                             oldreq_valid,
1327
                             next_wrreq_i2,
1328
                             wrreq_f;
1329
   wire          block_fetch_s1,
1330
                 block_fetch_d1;
1331
 
1332
   wire [3:0]    mil_thr_ready,
1333
                 all_retry_rdy_e1,
1334
                 all_retry_rdy_m1;
1335
   wire          retry_rdy_final_d1,
1336
                 retry_rdy_e1;
1337
 
1338
   wire          rst_starv_ctr_l;
1339
   wire          starv_alert;
1340
 
1341
   wire [3:0]    milhit_vec_s;
1342
   wire          any_milhit_s;
1343
 
1344
   wire [1:0]    rand_repway_s;
1345
//   wire [1:0]    mil_repway_s;
1346
 
1347
   wire [3:0]    errthr_d1,
1348
                             err_vec_d1,
1349
                             err_req;
1350
   wire          errinv_d1;
1351
 
1352
   wire          ifeterr_qual_d1,
1353
                 ifeterr_e1;
1354
   wire          thr_match_d1e1;
1355
   wire          ifqadv_i1;
1356
 
1357
   wire          ifqadvi2_nxt,
1358
                 ifqadv_i2_ff;
1359
   wire          access_grant_l;
1360
 
1361
   wire          addrbit4_i2;
1362
   wire          addrbit4_nxt_i2;
1363
 
1364
   wire [3:0]    cpxreq_i2;
1365
   wire [1:0]    cpxthr_i2;
1366
 
1367
 
1368
   wire          uncached_i2,
1369
                 uncached_s,
1370
                 mil_vld_i2,
1371
                 mil_uncan_i2,
1372
                 mil_nc_i2,
1373
                 mil_nc_e,
1374
                 mil_nc_d,
1375
                             uncached_fill_i2,
1376
                             uncached_f;
1377
 
1378
   wire [3:0]    mil_nc_vec,
1379
                 mil_nc_vec_nxt;
1380
 
1381
 
1382
   wire [3:0]    pcxreq_s,          // req bit from MIL
1383
                 pcxreq_qual_s,
1384
//                           newpcxreq_s,       // valid new request from latest miss
1385
//                           oldpcxreq_s,
1386
                             rr_gnt,          // round robin grant signal
1387
                             fill_addr4_i2;    // fill address bit 4 - determines
1388
         // which 16B of the 32B line gets
1389
         // written. Assume 0 first then 1
1390
 
1391
   wire          newreq_valid,    // latest S stage miss creates request.
1392
                             nextreq_valid_s, // if either a new req from i$ or old
1393
                                         // req from MIL is made in this cycle.
1394
                             req_valid_d;     // req to LSU is valid
1395
 
1396
   wire          inq_vld,
1397
                             inq_vld_nxt;
1398
 
1399
   wire          ic_pkt_i1;
1400
 
1401
//   wire          fill_this16b;
1402
 
1403
   wire [1:0]    filltid_i2,
1404
                             next_filltid_i2,
1405
                             filltid_f;
1406
 
1407
   wire          imissrtn_i2,   // input cpx is ifill return
1408
                 imissrtn_next_i2,
1409
                 imissrtn_f,
1410
                             imissrtn_i1;   // pkt in inq is ifill ret
1411
 
1412
   wire          invalidate_i1;
1413
 
1414
   wire [3:0]    icmiss_thr_s,
1415
                             icmiss_thr_d;
1416
   wire          icmiss_d1,
1417
                 icmiss_qual_d1;
1418
   wire          canthr_s1,
1419
                 canthr_d1,
1420
                 canthr_s1_del1;
1421
   wire          itlberr_d1;
1422
 
1423
   wire [2:0]    old_destid_s;
1424
 
1425
   wire          destid_iob_s,
1426
                 destid_iob_d;
1427
 
1428
   wire          iosp_d1_l,
1429
                 n763;
1430
 
1431
   wire [3:0]    wrt_tir;
1432
 
1433
   wire [3:0]    wr_complete_f;
1434
   wire [3:0]    pred_rdy_i2;
1435
   wire [3:0]    fill_retn_thr_i2;
1436
 
1437
   wire          filladdr4_f;
1438
 
1439
   wire [3:0]    milhit_to_thr_s,
1440
                             icmiss_for_milchk,
1441
                 qualhit_pe_s,
1442
                 qualhit_or_io_s;
1443
//                           milhit_qual_s;
1444
 
1445
   wire          l2_ue_i2,
1446
                             l2_ce_i2,
1447
                             io_ue_i2;
1448
   wire          l2_miss_i2,
1449
                 l2_miss_f;
1450
//   wire [3:0]    l2ms_thr;
1451
 
1452
   wire          ce_rep_i2,
1453
                             ue_rep_i2;
1454
 
1455
   wire          fwdreq_i2,
1456
                 fwdreq_i3,
1457
                 fwd_stall,
1458
                 fwdwr_i3,
1459
                 fwdrd_i3;
1460
 
1461
   wire          cpxnc_i3;
1462
 
1463
   wire          stallreq_d0,
1464
                 stallreq_d1;
1465
 
1466
   wire          ifu_asireq_i1,
1467
                 ifu_asireq_i0,
1468
                 byp_sel_asi_l,
1469
                 asird_i1,
1470
                             asireq_i2,
1471
                 asireq_i2_l,
1472
                             asi_load_i1,
1473
                             asi_load_i2,
1474
                             asi_vld_next,
1475
                 asi_vld_i0,
1476
                 asi_vld_qual_i0;
1477
 
1478
   wire [7:0]    asi_state_i1;
1479
   wire          asi_ic_data_i1,
1480
                             asi_ic_data_i2,
1481
                             asi_ic_tag_i1,
1482
                             asi_ic_tag_i2;
1483
 
1484
   wire          asi_erren_i1,
1485
                             asi_errstat_i1,
1486
                             asi_errinj_i1,
1487
                             asi_erraddr_i1,
1488
                             asi_imask_i1;
1489
 
1490
   wire          asi_ic_data_unchk_i1,
1491
                             asi_ic_tag_unchk_i1;
1492
 
1493
   wire          asi_erren_unchk_i1,
1494
                             asi_errstat_unchk_i1,
1495
                             asi_errinj_unchk_i1,
1496
                             asi_erraddr_unchk_i1,
1497
                             asi_imask_unchk_i1;
1498
 
1499
   wire          illva_i0,
1500
                 illva_i1,
1501
                 illva_i2,
1502
                 illva_f,
1503
                 illva_s,
1504
                 illva_w2;
1505
 
1506
   wire [3:0]    word_sel_i2;
1507
   wire          bist_op;
1508
 
1509
   wire          rdinst_bf,
1510
                             rd_tag_bf;
1511
 
1512
   wire          errpkt_i1;
1513
 
1514
   wire          stpkt_i1,
1515
                 strmack_i1,
1516
                             ldpkt_i1,
1517
                             evpkt_i1,
1518
                             errpkt_i2;
1519
 
1520
   wire          icv_wrdata_i2,
1521
                             icv_wbit_i2,
1522
                             icv_wrdata_f;
1523
 
1524
   wire          rst_way_lfsr;
1525
 
1526
   wire          inq_wayvld_i1;
1527
   wire          inq_wayvld_i1_nxt;
1528
   wire          ldinv_i1;
1529
   wire          ldinv_i2_nxt;
1530
   wire          ldinv_i2;
1531
 
1532
   wire          ifq_reset,
1533
                 rnd_reset,
1534
                 ifq_reset_l;
1535
 
1536
 
1537
   wire          clk;
1538
 
1539
 
1540
//----------------------------------------------------------------------
1541
// Code start here 
1542
//----------------------------------------------------------------------
1543
 
1544
   assign        clk = rclk;
1545
 
1546
 
1547
   // reset buffer
1548
   dffrl_async rstff(.din (grst_l),
1549
                     .q   (ifq_reset_l),
1550
                     .clk (clk), .se(se), .si(), .so(),
1551
                     .rst_l (arst_l));
1552
 
1553
   assign       ifq_reset = ~ifq_reset_l;
1554
 
1555
 
1556
//---------
1557
// MIL fsm
1558
//---------   
1559
   sparc_ifu_milfsm mil0(
1560
                               .ifc_fsm_can_thisthr      (fcl_ifq_canthr[0]),
1561
                         //     .ifc_fsm_orphan_thisthr (orphan_thr_d1[0]),
1562
 
1563
 
1564
                               .ifc_fsm_fill_thisthr_i2  (fill_retn_thr_i2[0]),
1565
                               .ifc_fsm_wr_complete_f    (wr_complete_f[0]),
1566
 
1567
                         .ifqadv_i2  (ifc_inv_ifqadv_i2),
1568
 
1569
                         .ifd_ifc_4bpkt_i2         (ifd_ifc_4bpkt_i2),
1570
                               .fcl_ifq_thr_s1           (fcl_ifq_thr_s1),
1571
                               .ifc_fsm_imiss_thisthr_s  (icmiss_thr_s[0]),
1572
                               .ifc_fsm_milhit_s         (any_milhit_qual_s),
1573
 
1574
                               .ifc_fsm_hiton_thismil_s  (milhit_to_thr_s[0]),
1575
 
1576
                               .ifc_fsm_pcxaccept_thisthr(pcx_accept_d[0]),
1577
                         .ifc_fsm_miladdr4         (ifd_ifc_miladdr4_i2[0]),
1578
 
1579
                               .clk                      (clk),
1580
                         .se                       (se),
1581
                         .si                       (si),
1582
                               .reset                    (ifq_reset),
1583
 
1584
                         .so                       (),
1585
 
1586
                               .ifc_fsm_err_thisthr      (errthr_d1[0]),
1587
 
1588
                               // outputs        
1589
                         .fsm_ifc_errreq           (err_req[0]),
1590
 
1591
                               .fsm_ifc_wrt_tir          (wrt_tir[0]),
1592
                               .fsm_ifc_comp_valid       (comp_valid_s[0]),
1593
                               .fsm_ifc_mil_valid        (mil_valid_s[0]),
1594
                               .fsm_ifc_mil_cancel       (mil_cancel[0]),
1595
                         .fsm_ifc_milstate         (mil0_state[3:0]),
1596
 
1597
                               .fsm_ifc_thr_ready        (mil_thr_ready[0]),
1598
                               .fsm_ifc_pred_rdy         (pred_rdy_i2[0]),
1599
                               .fsm_ifc_pcxreq           (pcxreq_s[0]),
1600
                               .fsm_ifc_addrbit4_i2      (fill_addr4_i2[0]),
1601
                               .fsm_ifc_milchld          (milchld0[2:0]));
1602
 
1603
 
1604
   sparc_ifu_milfsm mil1(
1605
                         .ifc_fsm_can_thisthr      (fcl_ifq_canthr[1]),
1606
                         //        .ifc_fsm_orphan_thisthr   (orphan_thr_d1[1]),     
1607
 
1608
                               .ifc_fsm_fill_thisthr_i2  (fill_retn_thr_i2[1]),
1609
                               .ifc_fsm_wr_complete_f    (wr_complete_f[1]),
1610
 
1611
                         .ifqadv_i2  (ifc_inv_ifqadv_i2),
1612
 
1613
                         .ifd_ifc_4bpkt_i2         (ifd_ifc_4bpkt_i2),
1614
                               .fcl_ifq_thr_s1           (fcl_ifq_thr_s1),
1615
                               .ifc_fsm_milhit_s         (any_milhit_qual_s),
1616
                               .ifc_fsm_hiton_thismil_s (milhit_to_thr_s[1]),
1617
                               .ifc_fsm_imiss_thisthr_s   (icmiss_thr_s[1]),
1618
 
1619
                               .ifc_fsm_pcxaccept_thisthr   (pcx_accept_d[1]),
1620
                         //        .ifc_fsm_reqq_empty       (reqq_empty),         
1621
                         .ifc_fsm_miladdr4         (ifd_ifc_miladdr4_i2[1]),
1622
 
1623
                               .clk                      (clk),
1624
                         .se                       (se),
1625
                         .si                       (si),
1626
                               .reset                    (ifq_reset),
1627
 
1628
                               .ifc_fsm_err_thisthr      (errthr_d1[1]),
1629
 
1630
                               // outputs        
1631
                         .fsm_ifc_errreq           (err_req[1]),
1632
 
1633
                               .fsm_ifc_wrt_tir          (wrt_tir[1]),
1634
                         .so                       (),
1635
                         //        .fsm_ifc_cm_pending       (can_miss_pending[1]),
1636
                         //        .fsm_ifc_delay_mil        (delay_mil[1]),
1637
                               .fsm_ifc_comp_valid       (comp_valid_s[1]),
1638
                               .fsm_ifc_mil_valid        (mil_valid_s[1]),
1639
                               .fsm_ifc_mil_cancel       (mil_cancel[1]),
1640
                         .fsm_ifc_milstate         (mil1_state[3:0]),
1641
 
1642
                               .fsm_ifc_pcxreq           (pcxreq_s[1]),
1643
                               .fsm_ifc_thr_ready        (mil_thr_ready[1]),
1644
                               .fsm_ifc_pred_rdy         (pred_rdy_i2[1]),
1645
                               .fsm_ifc_addrbit4_i2      (fill_addr4_i2[1]),
1646
                               .fsm_ifc_milchld          (milchld1[2:0]));
1647
 
1648
   sparc_ifu_milfsm mil2(
1649
                         .ifc_fsm_can_thisthr      (fcl_ifq_canthr[2]),
1650
                         //        .ifc_fsm_orphan_thisthr   (orphan_thr_d1[2]),     
1651
 
1652
                               .ifc_fsm_fill_thisthr_i2  (fill_retn_thr_i2[2]),
1653
                               .ifc_fsm_wr_complete_f    (wr_complete_f[2]),
1654
 
1655
                         .ifqadv_i2  (ifc_inv_ifqadv_i2),
1656
 
1657
                         .ifd_ifc_4bpkt_i2         (ifd_ifc_4bpkt_i2),
1658
                               .fcl_ifq_thr_s1           (fcl_ifq_thr_s1),
1659
                               .ifc_fsm_milhit_s         (any_milhit_qual_s),
1660
                               .ifc_fsm_hiton_thismil_s (milhit_to_thr_s[2]),
1661
                               .ifc_fsm_imiss_thisthr_s  (icmiss_thr_s[2]),
1662
 
1663
                               .ifc_fsm_pcxaccept_thisthr(pcx_accept_d[2]),
1664
                         //        .ifc_fsm_reqq_empty       (reqq_empty),         
1665
 
1666
                         .ifc_fsm_miladdr4         (ifd_ifc_miladdr4_i2[2]),
1667
 
1668
                               .clk                      (clk),
1669
                         .se                       (se),
1670
                         .si                       (si),
1671
                               .reset                    (ifq_reset),
1672
 
1673
                               .ifc_fsm_err_thisthr      (errthr_d1[2]),
1674
 
1675
                               // outputs        
1676
                         .fsm_ifc_errreq           (err_req[2]),
1677
 
1678
                         .so                       (),
1679
                         //        .fsm_ifc_cm_pending       (can_miss_pending[2]),
1680
                         //        .fsm_ifc_delay_mil        (delay_mil[2]),
1681
                               .fsm_ifc_wrt_tir          (wrt_tir[2]),
1682
                               .fsm_ifc_comp_valid       (comp_valid_s[2]),
1683
                               .fsm_ifc_mil_valid        (mil_valid_s[2]),
1684
                               .fsm_ifc_mil_cancel       (mil_cancel[2]),
1685
                         .fsm_ifc_milstate         (mil2_state[3:0]),
1686
 
1687
                               .fsm_ifc_pcxreq           (pcxreq_s[2]),
1688
                               .fsm_ifc_thr_ready        (mil_thr_ready[2]),
1689
                               .fsm_ifc_pred_rdy         (pred_rdy_i2[2]),
1690
                               .fsm_ifc_addrbit4_i2      (fill_addr4_i2[2]),
1691
                               .fsm_ifc_milchld          (milchld2[2:0]));
1692
 
1693
 
1694
   sparc_ifu_milfsm mil3(
1695
                         .ifc_fsm_can_thisthr      (fcl_ifq_canthr[3]),
1696
                         //        .ifc_fsm_orphan_thisthr   (orphan_thr_d1[3]),     
1697
 
1698
                               .ifc_fsm_fill_thisthr_i2  (fill_retn_thr_i2[3]),
1699
                               .ifc_fsm_wr_complete_f    (wr_complete_f[3]),
1700
 
1701
                         .ifqadv_i2  (ifc_inv_ifqadv_i2),
1702
 
1703
                         .ifd_ifc_4bpkt_i2         (ifd_ifc_4bpkt_i2),
1704
                               .fcl_ifq_thr_s1           (fcl_ifq_thr_s1),
1705
                               .ifc_fsm_milhit_s         (any_milhit_qual_s),
1706
                               .ifc_fsm_hiton_thismil_s (milhit_to_thr_s[3]),
1707
                               .ifc_fsm_imiss_thisthr_s   (icmiss_thr_s[3]),
1708
 
1709
                               .ifc_fsm_pcxaccept_thisthr(pcx_accept_d[3]),
1710
                         //        .ifc_fsm_reqq_empty       (reqq_empty),         
1711
 
1712
                         .ifc_fsm_miladdr4         (ifd_ifc_miladdr4_i2[3]),
1713
 
1714
                               .clk                      (clk),
1715
                         .se                       (se),
1716
                         .si                       (si),
1717
                               .reset                    (ifq_reset),
1718
 
1719
                               .ifc_fsm_err_thisthr      (errthr_d1[3]),
1720
 
1721
                               // outputs        
1722
                         .fsm_ifc_errreq           (err_req[3]),
1723
 
1724
                         .so                       (),
1725
                         //        .fsm_ifc_cm_pending       (can_miss_pending[3]),
1726
                         //        .fsm_ifc_delay_mil        (delay_mil[3]),
1727
                               .fsm_ifc_wrt_tir          (wrt_tir[3]),
1728
                               .fsm_ifc_comp_valid       (comp_valid_s[3]),
1729
                               .fsm_ifc_mil_valid        (mil_valid_s[3]),
1730
                               .fsm_ifc_mil_cancel       (mil_cancel[3]),
1731
                         .fsm_ifc_milstate         (mil3_state[3:0]),
1732
 
1733
                               .fsm_ifc_pcxreq           (pcxreq_s[3]),
1734
                               .fsm_ifc_thr_ready        (mil_thr_ready[3]),
1735
                               .fsm_ifc_pred_rdy         (pred_rdy_i2[3]),
1736
                               .fsm_ifc_addrbit4_i2      (fill_addr4_i2[3]),
1737
                               .fsm_ifc_milchld          (milchld3[2:0]));
1738
 
1739
 
1740
 
1741
//-------------------------------------------
1742
// Fill Return Control (IFU interfac to CPX)
1743
//-------------------------------------------
1744
 
1745
   // use soffm2 for lower setup
1746
   dffe #(4) cpxreq_reg(.din (ifd_ifc_cpxreq_nxt),
1747
                        .q   (cpxreq_i2),
1748
                        .en  (ifqadv_i1),
1749
                        .clk (clk), .se(se), .si(), .so());
1750
   dffe #(2) cpxthr_reg(.din (ifd_ifc_cpxthr_nxt),
1751
                        .q   (cpxthr_i2),
1752
                        .en  (ifqadv_i1),
1753
                        .clk (clk), .se(se), .si(), .so());
1754
 
1755
 
1756
   // Decode CPX request
1757
   assign imissrtn_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b0001}) ? 1'b1 : 1'b0;
1758
   assign imissrtn_i2 = (cpxreq_i2 == 4'b0001) ? ifd_ifc_cpxvld_i2 : 1'b0;
1759
 
1760
   assign imissrtn_next_i2 = ifc_inv_ifqadv_i2 ? imissrtn_i2 : imissrtn_f;
1761
 
1762
   dff #(1) imsf_ff(.din (imissrtn_next_i2),
1763
                    .q   (imissrtn_f),
1764
                    .clk (clk), .se (se), .si(), .so());
1765
 
1766
   // Determine if this is an IFILL RET to one of the threads
1767
   assign fill_retn_thr_i2 = dfthr_i2 & {4{imissrtn_i2}};
1768
 
1769
   // decode current icache fill thread
1770
   assign dfthr_f[0] = ~filltid_f[1] & ~filltid_f[0];
1771
   assign dfthr_f[1] = ~filltid_f[1] &  filltid_f[0];
1772
   assign dfthr_f[2] =  filltid_f[1] & ~filltid_f[0];
1773
   assign dfthr_f[3] =  filltid_f[1] &  filltid_f[0];
1774
 
1775
//`ifdef IFU_SAT
1776
//   assign ifc_ifd_uncached_s = fcl_ifq_icache_en_s_l;   
1777
//`else   
1778
//`endif
1779
 
1780
   assign uncached_s = ifd_ifc_newdestid_s[2] | fcl_ifq_icache_en_s_l;
1781
 
1782
   // timing fix: keep nc bit locally instead of in DP
1783
   assign mil_nc_vec_nxt = ({4{uncached_s & fcl_ifq_rdreq_s1}} &
1784
                              thr_s1 & ~errthr_d1 |
1785
                              mil_nc_vec & (mil_valid_s |
1786
                                            errthr_d1));
1787
 
1788
   dff #(4) nc_reg(.din (mil_nc_vec_nxt),
1789
                   .q   (mil_nc_vec),
1790
                   .clk (clk), .se(se), .si(), .so());
1791
 
1792
   assign mil_nc_i2 = (dfthr_i2[0] & mil_nc_vec[0] |
1793
                       dfthr_i2[1] & mil_nc_vec[1] |
1794
                       dfthr_i2[2] & mil_nc_vec[2] |
1795
                       dfthr_i2[3] & mil_nc_vec[3]);
1796
 
1797
   assign mil_nc_d = (dpcxthr_d[0] & mil_nc_vec[0] |
1798
                      dpcxthr_d[1] & mil_nc_vec[1] |
1799
                      dpcxthr_d[2] & mil_nc_vec[2] |
1800
                      dpcxthr_d[3] & mil_nc_vec[3]);
1801
 
1802
   dff #(1) nce_ff(.din (mil_nc_d),
1803
                   .q   (mil_nc_e),
1804
                   .clk (clk), .se(se), .si(), .so());
1805
   assign ifc_ifd_uncached_e = mil_nc_e;
1806
 
1807
//   assign uncached_fill_i2 = ifd_ifc_uncached_i2 | ifd_ifc_cpxnc_i2;
1808
   assign uncached_fill_i2 = mil_nc_i2 | ifd_ifc_cpxnc_i2;
1809
 
1810
   // uncached fill -- do not write to icache
1811
   assign uncached_i2 = ifc_inv_ifqadv_i2 ?
1812
                                  uncached_fill_i2 : uncached_f;
1813
 
1814
   dff unc_ff(.din (uncached_i2),
1815
                    .q   (uncached_f),
1816
                    .clk (clk),
1817
                    .se  (se), .si(), .so());
1818
 
1819
   // Determine if Icache write is done or 
1820
   // if none is necessary (i.e. if this is a child process or NC)
1821
   assign wr_complete_f = dfthr_f & {4{(wrreq_f & ifc_inv_ifqadv_i2 |
1822
                                        milchld_vld_f |
1823
                                                                uncached_f) & imissrtn_f}};
1824
 
1825
   // State Machine Outputs
1826
   // One of these has to be chosen for I2 stage operation
1827
   mux4ds #(3)  i2out_mux(.dout  (i2out),
1828
                       .in0   (milchld0),
1829
                       .in1   (milchld1),
1830
                       .in2   (milchld2),
1831
                       .in3   (milchld3),
1832
                       .sel0  (dfthr_i2[0]),
1833
                       .sel1  (dfthr_i2[1]),
1834
                       .sel2  (dfthr_i2[2]),
1835
                       .sel3  (dfthr_i2[3]));
1836
 
1837
   assign mil_vld_i2 = (mil_valid_s[0] & dfthr_i2[0] |
1838
                        mil_valid_s[1] & dfthr_i2[1] |
1839
                        mil_valid_s[2] & dfthr_i2[2] |
1840
                        mil_valid_s[3] & dfthr_i2[3]);
1841
 
1842
   assign mil_uncan_i2 = (mil_valid_s[0] & ~mil_cancel[0] & dfthr_i2[0] |
1843
                          mil_valid_s[1] & ~mil_cancel[1] & dfthr_i2[1] |
1844
                          mil_valid_s[2] & ~mil_cancel[2] & dfthr_i2[2] |
1845
                          mil_valid_s[3] & ~mil_cancel[3] & dfthr_i2[3]);
1846
 
1847
   // Don't make a wrreq if this is a child entry.  However, if this is
1848
   // a child and the parent was cancelled, then go ahead and
1849
   // write... is this really necessary?  Not for functionality.
1850
   // 3/19: parent will write even if cancelled.  So never write child
1851
   assign next_wrreq_i2 = imissrtn_i2 & mil_vld_i2 & ~uncached_fill_i2 &
1852
                          ~milchld_vld_i2 & ~ifd_ifc_4bpkt_i2; // was: iobpkt_i2
1853
 
1854
   assign addrbit4_i2 = (milfthr_i2[0] & fill_addr4_i2[0] |
1855
                         milfthr_i2[1] & fill_addr4_i2[1] |
1856
                         milfthr_i2[2] & fill_addr4_i2[2] |
1857
                         milfthr_i2[3] & fill_addr4_i2[3]);
1858
 
1859
   assign addrbit4_nxt_i2= ifc_inv_ifqadv_i2 ? addrbit4_i2 : filladdr4_f;
1860
   dff #(1) ab4_ff(.din (addrbit4_nxt_i2),
1861
                   .q   (filladdr4_f),
1862
                   .clk (clk),
1863
                   .se  (se), .si(), .so());
1864
 
1865
   assign ifc_ifd_filladdr4_i2 = addrbit4_nxt_i2;
1866
 
1867
   assign next_milchld = ifc_inv_ifqadv_i2 ?
1868
                                  {(i2out[2] & imissrtn_i2), i2out[1:0]} :
1869
                                  milchld_d1;
1870
 
1871
   // After the packet is processed, the child entry in the MIL,
1872
   // pointed to by the reg below is processed next (if valid)
1873
   dffr #(3)  milchldd_reg(.din  (next_milchld),
1874
                                             .clk  (clk),
1875
                                             .rst  (ifq_reset),
1876
                                             .q    (milchld_d1),
1877
                                             .se   (se), .si(), .so());
1878
 
1879
   assign milchld_vld_i2 = milchld_d1[2];
1880
   assign next_milchld_i2 = ifc_inv_ifqadv_i2 ? milchld_d1[2] :
1881
                                                      milchld_vld_f;
1882
 
1883
   dffr #(1) milchldf_ff(.din  (next_milchld_i2),
1884
                       .q    (milchld_vld_f),
1885
                       .clk  (clk),
1886
                       .rst  (ifq_reset),
1887
                       .se   (se), .si(), .so());
1888
 
1889
   // need this to avoid x's in the simulation
1890
//   assign cpxthrid_adj_i2 = ifd_ifc_cpxthr_i2 &
1891
//                                {2{ifd_ifc_cpxreq_i2[`CPX_RQ_SIZE]}};
1892
 
1893
   // Determine if we should process the child or a new entry
1894
//   assign next_thr_sel_milchld_i2 = ifc_inv_ifqadv_i2 & milchld_vld_i2 & 
1895
//                                  ~errpkt_i2;
1896
//   assign next_thr_sel_milchld_i2 = milchld_vld_i2 & ~errpkt_i2;
1897
 
1898
 
1899
   // if previous mil entry had a child, process that next
1900
//   mux2ds  #(2) filltid_mux(.dout  (filltid_i2),
1901
//                                      .in0   (cpxthrid_adj_i2),
1902
//                                      .in1   (milchld_d1[1:0]),
1903
//                                      .sel0  (~milchld_vld_i2),
1904
//                                      .sel1  (milchld_vld_i2));
1905
   assign filltid_i2 = milchld_vld_i2 ? milchld_d1[1:0] :
1906
                                        cpxthr_i2[1:0];
1907
 
1908
   // decode fill thread  (either cpx thread or MIL child thread from above)
1909
   // need to qual with valid bit to avoid X's in simulation
1910
//   assign cpxvld_or_milc_i2 = ifd_ifc_cpxreq_i2[`CPX_RQ_SIZE] | milchld_vld_i2;
1911
   assign dfthr_i2[0] = ~filltid_i2[1] & ~filltid_i2[0];
1912
   assign dfthr_i2[1] = ~filltid_i2[1] &  filltid_i2[0];
1913
   assign dfthr_i2[2] =  filltid_i2[1] & ~filltid_i2[0];
1914
   assign dfthr_i2[3] =  filltid_i2[1] &  filltid_i2[0];
1915
 
1916
   dp_mux2es  #(2)  thren_mux(.dout (next_filltid_i2),
1917
                                                .in0  (filltid_f),
1918
                                                .in1  (filltid_i2),
1919
                                                .sel  (ifc_inv_ifqadv_i2));
1920
 
1921
   dff #(2) wrthr_reg(.din  (next_filltid_i2),
1922
                                  .clk  (clk),
1923
                                  .q    (filltid_f),
1924
                                  .se   (se), .si(), .so());
1925
 
1926
 
1927
   dp_mux2es  #(4)  dthren_mux(.dout (dfthr_next_i2),
1928
                                                 .in0  (dfthr_f),
1929
                                                 .in1  (dfthr_i2),
1930
                                                 .sel  (ifc_inv_ifqadv_i2));
1931
 
1932
 
1933
   // Early start of threads
1934
   // Do we need a control bit to turn this off?
1935
   // -- do it in SWL
1936
   assign ifq_dtu_pred_rdy =  pred_rdy_i2 & {dfthr_next_i2[3:0]} &
1937
                              {4{imissrtn_next_i2}};
1938
 
1939
// If timing is a problem resort to:
1940
//   assign ifq_dtu_pred_rdy =  pred_rdy_i2 & {4{ifc_inv_ifqadv_i2}} &
1941
//                              dfthr_i2 & {4{imissrtn_i2}};
1942
 
1943
 
1944
 
1945
   // pick 16B half cache line which contains the instruction we want
1946
//   assign fill_this16b = ~(ifc_ifd_filladdr4_i2 ^ ifd_ifc_missaddr4_i2);
1947
                         // | ifd_ifc_4bpkt_i2;
1948
 
1949
   // write to thread instruction register
1950
//   assign ifq_fcl_fill_thr = wrt_tir & {4{fill_this16b | ifd_ifc_4bpkt_i2}};
1951
//   assign ifq_fcl_fill_thr = wrt_tir & {4{fill_this16b}};
1952
   assign ifq_fcl_fill_thr = wrt_tir | thr_d1 & {4{itlberr_d1 &
1953
                                                   ~canthr_d1 &
1954
                                                   icmiss_d1 &
1955
                                                   ~canthr_s1_del1}};
1956
 
1957
   // Select instruction to send to TIR
1958
   // TBD: Need to find out how the inst from boot PROM is aligned -- Done
1959
   // From kinkee 02/21/03: It is aligned to the correct 4B of the 16B 
1960
   // packet.  The other locations are X.
1961
   assign finst0[0] = ~ifd_ifc_instoffset0[1] & ~ifd_ifc_instoffset0[0];
1962
   assign finst0[1] = ~ifd_ifc_instoffset0[1] &  ifd_ifc_instoffset0[0];
1963
   assign finst0[2] =  ifd_ifc_instoffset0[1] & ~ifd_ifc_instoffset0[0];
1964
   assign finst0[3] =  ifd_ifc_instoffset0[1] &  ifd_ifc_instoffset0[0];
1965
 
1966
   assign finst1[0] = ~ifd_ifc_instoffset1[1] & ~ifd_ifc_instoffset1[0];
1967
   assign finst1[1] = ~ifd_ifc_instoffset1[1] &  ifd_ifc_instoffset1[0];
1968
   assign finst1[2] =  ifd_ifc_instoffset1[1] & ~ifd_ifc_instoffset1[0];
1969
   assign finst1[3] =  ifd_ifc_instoffset1[1] &  ifd_ifc_instoffset1[0];
1970
 
1971
   assign finst2[0] = ~ifd_ifc_instoffset2[1] & ~ifd_ifc_instoffset2[0];
1972
   assign finst2[1] = ~ifd_ifc_instoffset2[1] &  ifd_ifc_instoffset2[0];
1973
   assign finst2[2] =  ifd_ifc_instoffset2[1] & ~ifd_ifc_instoffset2[0];
1974
   assign finst2[3] =  ifd_ifc_instoffset2[1] &  ifd_ifc_instoffset2[0];
1975
 
1976
   assign finst3[0] = ~ifd_ifc_instoffset3[1] & ~ifd_ifc_instoffset3[0];
1977
   assign finst3[1] = ~ifd_ifc_instoffset3[1] &  ifd_ifc_instoffset3[0];
1978
   assign finst3[2] =  ifd_ifc_instoffset3[1] & ~ifd_ifc_instoffset3[0];
1979
   assign finst3[3] =  ifd_ifc_instoffset3[1] &  ifd_ifc_instoffset3[0];
1980
 
1981
//   mux4ds #(4) finst_mx(.dout (finst_i2),
1982
//                        .in0  (finst0),
1983
//                        .in1  (finst1),
1984
//                        .in2  (finst2),
1985
//                        .in3  (finst3),
1986
//                        .sel0 (dfthr_i2[0]),
1987
//                        .sel1 (dfthr_i2[1]),
1988
//                        .sel2 (dfthr_i2[2]),
1989
//                        .sel3 (dfthr_i2[3]));
1990
 
1991
   wire [3:0] finst_ev,
1992
              finst_od,
1993
              finst_i2_l;
1994
   wire [1:0] filltid_i2_l;
1995
   bw_u1_inv_10x UZsize_ftid_bf0(.z (filltid_i2_l[0]),
1996
                                 .a (filltid_i2[0]));
1997
   bw_u1_inv_20x UZsize_ftid_bf1(.z (filltid_i2_l[1]),
1998
                                 .a (filltid_i2[1]));
1999
   // use bw_u1_muxi21_4x
2000
   assign finst_ev = filltid_i2_l[1] ? finst0 : finst2;
2001
   assign finst_od = filltid_i2_l[1] ? finst1 : finst3;
2002
   assign finst_i2_l = filltid_i2_l[0] ? (~finst_ev) : (~finst_od);
2003
   assign finst_i2 = ~finst_i2_l;
2004
 
2005
   assign ifc_ifd_finst_sel_l = ~finst_i2;
2006
 
2007
   // pick MIL entry corresponding to current thread
2008
   assign milfthr_i2[0] = ~cpxthr_i2[1] & ~cpxthr_i2[0];
2009
   assign milfthr_i2[1] = ~cpxthr_i2[1] &  cpxthr_i2[0];
2010
   assign milfthr_i2[2] =  cpxthr_i2[1] & ~cpxthr_i2[0];
2011
   assign milfthr_i2[3] =  cpxthr_i2[1] &  cpxthr_i2[0];
2012
   assign ifc_ifd_milfill_sel_i2_l = ~milfthr_i2;
2013
 
2014
   // write request
2015
   // assign ifq_fcl_wrreq_bf = ifc_inv_ifqadv_i2 ? next_wrreq_i2 : wrreq_f;
2016
   // assign ifq_fcl_wrreq_bf = ~ifc_inv_ifqadv_i2 | next_wrreq_i2;
2017
   assign ifq_fcl_wrreq_bf = wrreq_f & ~ifc_inv_ifqadv_i2 | next_wrreq_i2;
2018
 
2019
   dffr #(1) wrreq_ff(.din (ifq_fcl_wrreq_bf),
2020
                                  .clk (clk),
2021
                                  .q   (wrreq_f),
2022
                                  .rst (ifq_reset),
2023
                                  .se  (se), .si(), .so());
2024
 
2025
   // starvation check
2026
   // if a write is not granted for 24 cycles, sound the alarm
2027
   sparc_ifu_ctr5 starv_ctr(
2028
                                              // Outputs
2029
                                              .limit    (starv_alert),
2030
                                              .so       (so),
2031
                                              // Inputs
2032
                                              .clk      (clk),
2033
                                              .se       (se),
2034
                                              .si       (si),
2035
                                              .rst_ctr_l (rst_starv_ctr_l));
2036
   assign rst_starv_ctr_l = ~ifq_reset & wrreq_f;
2037
 
2038
   // advance in i2 when a write ack is received or if not a fill
2039
   // Can help timing of this signal by doing
2040
   //  ifqadv_nxt = ~ifq_fcl_wrreq_bf | fcl_icd_index_sel_ifq_bf
2041
   assign access_grant_l = ~fcl_ifq_grant_bf;
2042
   bw_u1_nand2_2x UZsize_acc_n2(.z (ifqadvi2_nxt),
2043
                                .a (ifq_fcl_wrreq_bf),
2044
                                .b (access_grant_l));
2045
   dff #(1) qadv_ff(.din (ifqadvi2_nxt),
2046
                    .q   (ifqadv_i2_ff),
2047
                    .clk (clk), .se(se), .si(), .so());
2048
   assign ifc_inv_ifqadv_i2 = ifqadv_i2_ff;
2049
 
2050
 
2051
 
2052
   // advance in i1 when a write ack is received AND there are no
2053
   // child threads to be taken care of
2054
   assign ifqadv_i1 = (ifc_inv_ifqadv_i2 & ~next_milchld[2] & ~fwd_stall) |
2055
                        ifq_reset;
2056
 
2057
//-----------------------------------
2058
// Errors and Error Packet
2059
//-----------------------------------   
2060
 
2061
   assign errpkt_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b1100}) ? 1'b1 : 1'b0;
2062
   assign errpkt_i2 = (cpxreq_i2 == 4'b1100) ? ifd_ifc_cpxvld_i2 : 1'b0;
2063
 
2064
   // Reported Errors are not logged in ERB
2065
   assign ce_rep_i2 = ifd_ifc_cpxce_i2 & ~ifd_ifc_cpxue_i2 & errpkt_i2 &
2066
                            ifc_inv_ifqadv_i2;
2067
   assign ue_rep_i2 = ifd_ifc_cpxue_i2 & errpkt_i2 & ifc_inv_ifqadv_i2;
2068
 
2069
   dff #(1) cerep_ff(.din (ce_rep_i2),
2070
                                 .q   (ifq_erb_ce_rep),
2071
                                 .clk (clk), .se(se), .si(), .so());
2072
   dff #(1) uerep_ff(.din (ue_rep_i2),
2073
                                 .q   (ifq_erb_ue_rep),
2074
                                 .clk (clk), .se(se), .si(), .so());
2075
 
2076
//   dff #(2) ertid_reg(.din (filltid_i2),
2077
//                                .q   (ifq_erb_l2err_tid),
2078
//                                .clk (clk), .se(se), .si(), .so());
2079
   // send thread id one cycle earlier to help crit path
2080
   assign ifq_erb_l2err_tid = filltid_i2;
2081
 
2082
   // Ifetch Errors are logged in ERB
2083
   assign l2_ce_i2 = ifd_ifc_cpxce_i2 & ~ifd_ifc_cpxue_i2 & imissrtn_i2 &
2084
                           ifc_inv_ifqadv_i2 & mil_uncan_i2;
2085
   assign l2_ue_i2 = ifd_ifc_cpxue_i2 & imissrtn_i2 & ~ifd_ifc_iobpkt_i2 &
2086
                           ifc_inv_ifqadv_i2 & mil_uncan_i2;
2087
   assign io_ue_i2 = ifd_ifc_cpxue_i2 & imissrtn_i2 & ifd_ifc_iobpkt_i2 &
2088
                           ifc_inv_ifqadv_i2 & mil_uncan_i2;
2089
 
2090
   dff #(1) l2ce_ff(.din (l2_ce_i2),
2091
                                .q   (ifq_erb_ifet_ce),
2092
                                .clk (clk), .se(se), .si(), .so());
2093
   dff #(1) l2ue_ff(.din (l2_ue_i2),
2094
                                .q   (ifq_erb_l2_ue),
2095
                                .clk (clk), .se(se), .si(), .so());
2096
   dff #(1) ioue_ff(.din (io_ue_i2),
2097
                                .q   (ifq_erb_io_ue),
2098
                                .clk (clk), .se(se), .si(), .so());
2099
 
2100
   assign l2_miss_i2 = ifd_ifc_cpxms_i2 & imissrtn_i2 & ifc_inv_ifqadv_i2;
2101
   dff #(1) l2ms_ff(.din (l2_miss_i2),
2102
                                .q   (l2_miss_f),
2103
                                .clk (clk), .se(se), .si(), .so());
2104
 
2105
   assign ifu_tlu_l2imiss = dfthr_f & {4{l2_miss_f}};
2106
 
2107
//--------------------------------------------
2108
// Miss Request Control (IFU interface to PCX)
2109
//--------------------------------------------
2110
 
2111
   // decode imiss thread
2112
   assign thr_s1[0] = ~fcl_ifq_thr_s1[0] & ~fcl_ifq_thr_s1[1];
2113
   assign thr_s1[1] =  fcl_ifq_thr_s1[0] & ~fcl_ifq_thr_s1[1];
2114
   assign thr_s1[2] = ~fcl_ifq_thr_s1[0] & fcl_ifq_thr_s1[1];
2115
   assign thr_s1[3] =  fcl_ifq_thr_s1[0] & fcl_ifq_thr_s1[1];
2116
 
2117
   // signal ic miss to thread MIL state machines
2118
   assign icmiss_thr_s = {4{fcl_ifq_icmiss_s1 & ~block_fetch_s1}} & thr_s1 &
2119
                               ~icmiss_thr_d;
2120
 
2121
//   dff #(4) icmsreg(.din  (icmiss_thr_s),
2122
//                              .clk  (clk),
2123
//                              .q    (icmiss_thr_d),
2124
//                              .se   (se), .si(), .so());
2125
 
2126
   dff #(1) icmsd_ff(.din  (fcl_ifq_icmiss_s1),
2127
                                 .clk  (clk),
2128
                                 .q    (icmiss_d1),
2129
                                 .se   (se), .si(), .so());
2130
 
2131
   assign icmiss_qual_d1 = icmiss_d1 & ~(thr_match_d1e1 & ifeterr_e1);
2132
 
2133
   // bug 5926
2134
   assign n763 = ~ifd_ifc_newdestid_s[2];
2135
   dff #(1) iosp_ff(.din (n763),
2136
                                .q   (iosp_d1_l),
2137
                                .clk (clk), .se(se), .si(), .so());
2138
 
2139
   assign icmiss_thr_d = {4{icmiss_d1 | erb_ifq_ifeterr_d1 & iosp_d1_l}} & thr_d1 |
2140
                         {4{ifeterr_e1}} & thr_e1;
2141
 
2142
   dff #(4) thrdreg(.din  (thr_s1),
2143
                                .clk  (clk),
2144
                                .q    (thr_d1),
2145
                                .se   (se), .si(), .so());
2146
 
2147
   dff #(4) threreg(.din  (thr_d1),
2148
                                .clk  (clk),
2149
                                .q    (thr_e1),
2150
                                .se   (se), .si(), .so());
2151
 
2152
   dff #(1) erre_ff(.din (ifeterr_qual_d1),
2153
                    .q   (ifeterr_e1),
2154
                    .clk (clk), .se(se), .si(), .so());
2155
   assign thr_match_d1e1 =  (thr_d1[0] & thr_e1[0] |
2156
                             thr_d1[1] & thr_e1[1] |
2157
                             thr_d1[2] & thr_e1[2] |
2158
                             thr_d1[3] & thr_e1[3]);
2159
 
2160
//   assign ifeterr_qual_d1 = ~(thr_match_d1e1 & ifeterr_e1) & ~canthr_d1 & 
2161
//                               erb_ifq_ifeterr_d1;
2162
   assign ifeterr_qual_d1 = ~(thr_match_d1e1 & ifeterr_e1) &
2163
                               erb_ifq_ifeterr_d1 & iosp_d1_l;
2164
 
2165
   assign errthr_d1 = (thr_d1 & {4{ifeterr_qual_d1 & ~block_fetch_d1}});
2166
 
2167
   // If misses to same thread, (in successive cycles), ignore
2168
   assign ifc_ifd_ldmil_sel_new = (thr_s1 & {4{fcl_ifq_rdreq_s1}} &
2169
                                                           ~errthr_d1 & ~mil_valid_s);
2170
 
2171
   // Check hit in MIL -- a thread cannot hit 
2172
   //   1. its own MIL
2173
   //   2. an MIL that is being filled
2174
   //   3. if it is to an IOB line
2175
   assign qualhit_or_io_s = ifd_ifc_milhit_s & comp_valid_s &
2176
                                  ~thr_s1 &
2177
                            ~fill_retn_thr_i2 &
2178
                            {4{~ifd_ifc_newdestid_s[2]}};
2179
 
2180
   assign any_qualhit_or_io_s = (qualhit_or_io_s[0] |
2181
                                             qualhit_or_io_s[1] |
2182
                                             qualhit_or_io_s[2] |
2183
                                             qualhit_or_io_s[3]);
2184
 
2185
//   assign milhit_qual_s = ifd_ifc_milhit_s & comp_valid_s & 
2186
//                              ~thr_s1 & 
2187
//                          ~fill_retn_thr_i2 & 
2188
//                          {4{~ifd_ifc_newdestid_s[2]}};
2189
 
2190
//   assign any_milhit_qual_s = any_qualhit_or_io_s & ~ifd_ifc_newdestid_s[2];
2191
   assign any_milhit_qual_s = any_qualhit_or_io_s;
2192
 
2193
   // Generate Replacement Way
2194
   // Make sure a req doesn't go out to a different way than 
2195
   // what is pending
2196
   assign milhit_vec_s = ifd_ifc_milhit_s & (mil_valid_s | errthr_d1);
2197
   assign any_milhit_s = (|milhit_vec_s[3:0]);
2198
 
2199
//   assign mil_repway_s = (ifd_ifc_mil_repway_s[7:6] & {2{milhit_vec_s[3]}} | 
2200
//                          ifd_ifc_mil_repway_s[5:4] & {2{milhit_vec_s[2]}} | 
2201
//                          ifd_ifc_mil_repway_s[3:2] & {2{milhit_vec_s[1]}} | 
2202
//                          ifd_ifc_mil_repway_s[1:0] & {2{milhit_vec_s[0]}});
2203
 
2204
//   assign ifc_ifd_repway_s = any_milhit_s ? mil_repway_s : rand_repway_s;
2205
   assign ifc_ifd_repway_s = rand_repway_s;
2206
 
2207
   // pick any way at random
2208
   // reset with dbg_init as well
2209
   sparc_ifu_lfsr5  lfsr(.out (rand_repway_s),
2210
                                           .clk  (clk),
2211
                                           .advance (fcl_ifq_icmiss_s1),
2212
                                           .reset (rst_way_lfsr),
2213
                                           .se (se),
2214
                                           .si (si),
2215
                                           .so (so));
2216
 
2217
   assign rst_way_lfsr = ifq_reset | lsu_ifu_direct_map_l1 | ~gdbginit_l;
2218
 
2219
   // check if miss req is valid in a given pipe stage
2220
   assign canthr_s1 = (fcl_ifq_canthr[0] & thr_s1[0] |
2221
                       fcl_ifq_canthr[1] & thr_s1[1] |
2222
                       fcl_ifq_canthr[2] & thr_s1[2] |
2223
                       fcl_ifq_canthr[3] & thr_s1[3]);
2224
   assign canthr_d1 = (fcl_ifq_canthr[0] & thr_d1[0] |
2225
                       fcl_ifq_canthr[1] & thr_d1[1] |
2226
                       fcl_ifq_canthr[2] & thr_d1[2] |
2227
                       fcl_ifq_canthr[3] & thr_d1[3]);
2228
 
2229
   // retry a fetch if the imiss occurs while it is being filled
2230
//   assign block_fetch_s1 = any_milhit_s & 
2231
//                           ~(any_qualhit_or_io_s | ifd_ifc_newdestid_s[2]) |
2232
//                           dtu_ifq_kill_latest_d;
2233
   assign block_fetch_s1 = any_milhit_s & ~ifd_ifc_newdestid_s[2] &
2234
                           ~any_qualhit_or_io_s |
2235
                           dtu_ifq_kill_latest_d |
2236
                           erb_ifq_itlberr_s1;
2237
 
2238
   dff #(1) bfd_ff(.din (block_fetch_s1),
2239
                   .q   (block_fetch_d1),
2240
                   .clk (clk), .se(se), .si(), .so());
2241
 
2242
   dff #(1) tlbe_ff(.din (erb_ifq_itlberr_s1),
2243
                    .q   (itlberr_d1),
2244
                    .clk (clk), .se(se), .si(), .so());
2245
 
2246
//   assign retry_rdy_s1 = block_fetch_s1 & fcl_ifq_icmiss_s1;
2247
//   dff #(1) retrd_ff(.din (retry_rdy_s1),
2248
//                     .q   (retry_rdy_d1),
2249
//                     .clk (clk), .se(se), .si(), .so());
2250
 
2251
   assign retry_rdy_final_d1 = block_fetch_d1 & (icmiss_qual_d1 |
2252
                                                 ifeterr_qual_d1);
2253
   dff #(1) retre_ff(.din (retry_rdy_final_d1),
2254
                     .q   (retry_rdy_e1),
2255
                     .clk (clk), .se(se), .si(), .so());
2256
 
2257
   assign all_retry_rdy_e1 = {4{retry_rdy_e1}} & thr_e1;
2258
   dff #(4) retrm_reg(.din (all_retry_rdy_e1),
2259
                      .q   (all_retry_rdy_m1),
2260
                     .clk (clk), .se(se), .si(), .so());
2261
 
2262
   assign ifq_dtu_thrrdy = mil_thr_ready | all_retry_rdy_m1;
2263
 
2264
//   assign retry_fetch_s1 = block_fetch_s1 & fcl_ifq_icmiss_s1 & 
2265
//                           ~canthr_s1;
2266
   dff #(1) cans_ff(.din (canthr_s1),
2267
                    .q   (canthr_s1_del1),
2268
                    .clk (clk), .se(se), .si(), .so());
2269
 
2270
   assign ifq_fcl_flush_sonly_e = (block_fetch_d1 &
2271
                                   (icmiss_qual_d1 & ~canthr_s1_del1 |
2272
                                    ifeterr_qual_d1) &
2273
                                   ~canthr_d1 & ~itlberr_d1);
2274
 
2275
   // Determine which thread's MIL was hit, if at all
2276
   // first check if this really was an imiss
2277
   assign icmiss_for_milchk = thr_s1 & ~icmiss_thr_d & ~errthr_d1;
2278
   assign icmiss_qual_s = (|icmiss_for_milchk[3:0]) & fcl_ifq_icmiss_s1 &
2279
                          ~dtu_ifq_kill_latest_d & ~erb_ifq_itlberr_s1;
2280
 
2281
   // since multiple requests can be outstanding when an error is
2282
   // encountered, need to prioritise the mil hits.
2283
   // TBD: there must be a cleaner way to do this!
2284
   assign qualhit_pe_s[0] = qualhit_or_io_s[0];
2285
   assign qualhit_pe_s[1] = ~qualhit_or_io_s[0] & qualhit_or_io_s[1];
2286
   assign qualhit_pe_s[2] = ~qualhit_or_io_s[0] & ~qualhit_or_io_s[1] &
2287
                             qualhit_or_io_s[2];
2288
   assign qualhit_pe_s[3] = ~qualhit_or_io_s[0] & ~qualhit_or_io_s[1] &
2289
                            ~qualhit_or_io_s[2] & qualhit_or_io_s[3];
2290
 
2291
   // A thread cannot hit on an MIL to the IOB
2292
   assign milhit_to_thr_s = qualhit_pe_s & {4{icmiss_qual_s &
2293
                                                 ~ifd_ifc_newdestid_s[2]}};
2294
 
2295
   // Make Request to PCX if miss in Icache and MIL
2296
   // determine if we need to send req to L2
2297
//   assign newpcxreq_s = icmiss_for_milchk & ~fcl_ifq_canthr;
2298
//   assign newreq_valid = fcl_ifq_icmiss_s1 & ~dtu_ifq_kill_latest_d & 
2299
//                             (newpcxreq_s[0] | 
2300
//                                          newpcxreq_s[1] | 
2301
//                                          newpcxreq_s[2] | 
2302
//                                          newpcxreq_s[3]) & 
2303
//                           (~any_milhit_s | ifd_ifc_newdestid_s[2]);
2304
 
2305
   assign newreq_valid = icmiss_qual_s &
2306
                          (~any_milhit_s | ifd_ifc_newdestid_s[2]);
2307
 
2308
   // check if there are any old requests outstanding, that are not
2309
   // current in  the D stage. 
2310
   assign pcxreq_qual_s = pcxreq_s & ~(dpcxthr_d & {4{req_valid_d}});
2311
 
2312
//   assign reqq_empty = ~(|pcxreq_qual_s[3:0]);
2313
//   assign oldpcxreq_s = pcxreq_qual_s & rr_gnt & ~fcl_ifq_canthr;
2314
//   assign oldreq_valid = (|oldpcxreq_s);
2315
//   assign oldpcxreq_s = pcxreq_qual_s & rr_gnt;   
2316
   assign oldreq_valid = (|pcxreq_qual_s);
2317
 
2318
   // Send out PCX request in round robin order if there are other
2319
   // reqests pending.  If the request queue is empty send this req
2320
//   assign nextreq_valid_s = ~reqq_empty | newreq_valid;
2321
 
2322
   assign nextreq_valid_s = oldreq_valid | newreq_valid | req_pending_d;
2323
 
2324
   assign rnd_reset = ifq_reset | ~gdbginit_l;
2325
 
2326
   // round robin assignment to pcx
2327
   sparc_ifu_rndrob  pcxrndrob(.req_vec   (pcxreq_qual_s),
2328
                                                 .grant_vec (rr_gnt),
2329
                                                 .advance   (req_accept_d),
2330
                                                 .rst_tri_enable (rst_tri_en),
2331
                                                 .clk       (clk),
2332
                                                 .reset     (rnd_reset),
2333
                                                 .se  (se),
2334
                                                 .si (si),
2335
                                                 .so ());
2336
 
2337
   // if req queue is empty forward the new request to pcx
2338
   // if not store it in the MIL
2339
   assign dpcxthr_s  = req_pending_d ? dpcxthr_d :
2340
                             ~oldreq_valid ? thr_s1    :
2341
                                             rr_gnt;
2342
   dff #(4) pcxthr_ff(.din (dpcxthr_s),
2343
                                  .clk (clk),
2344
                                  .q   (dpcxthr_d),
2345
                                  .se  (se), .si(), .so());
2346
 
2347
   assign thrid_d[0] = dpcxthr_d[3] | dpcxthr_d[1];
2348
   assign thrid_d[1] = dpcxthr_d[3] | dpcxthr_d[2];
2349
   dff #(2) tide_reg(.din (thrid_d),
2350
                     .q   (thrid_e),
2351
                     .clk (clk), .se(se), .si(), .so());
2352
   assign ifc_ifd_thrid_e = thrid_e;
2353
 
2354
   // Determine the destination to which the request is made:
2355
   mux4ds #(3) dest_mux(.dout (old_destid_s),
2356
                                    .in0  (ifd_ifc_destid0[2:0]),
2357
                                    .in1  (ifd_ifc_destid1[2:0]),
2358
                                    .in2  (ifd_ifc_destid2[2:0]),
2359
                                    .in3  (ifd_ifc_destid3[2:0]),
2360
                                    .sel0 (rr_gnt[0]),
2361
                                    .sel1 (rr_gnt[1]),
2362
                                    .sel2 (rr_gnt[2]),
2363
                                    .sel3 (rr_gnt[3]));
2364
 
2365
//   mux2ds #(3) fdest_mux(.dout (destid_s),
2366
//                                   .in0  (ifd_ifc_newdestid_s),
2367
//                                   .in1  (old_destid_s),
2368
//                                   .sel0 (~oldreq_valid),
2369
//                                   .sel1 (oldreq_valid));
2370
 
2371
//   assign destid_s  = req_pending_d ? ifu_lsu_destid_d    :
2372
//                          ~oldreq_valid ? ifd_ifc_newdestid_s : 
2373
//                                          old_destid_s;
2374
   assign ifu_lsu_destid_s = oldreq_valid ? old_destid_s :
2375
                                            ifd_ifc_newdestid_s;
2376
 
2377
   // remove this
2378
   assign destid_iob_s  = req_pending_d ? destid_iob_d :
2379
                                          ifu_lsu_destid_s[2];
2380
   dff #(1) destd_reg(.din (destid_iob_s),
2381
                                  .q   (destid_iob_d),
2382
                                  .clk (clk), .se(se), .si(), .so());
2383
 
2384
   // If this is going to any L2 bank, zero out the line address 
2385
   // for Rams 
2386
   assign ifc_ifd_pcxline_adj_d[4:2] = ifd_ifc_pcxline_d[4:2] &
2387
                                       {3{destid_iob_d}};
2388
 
2389
   // advace req 
2390
   dffr #(1) pcxreqvd_ff(.din  (nextreq_valid_s),
2391
                                     .clk  (clk),
2392
                                     .rst  (ifq_reset),
2393
                                     .q    (req_valid_d),
2394
                                     .se   (se), .si(), .so());
2395
 
2396
   assign ifu_lsu_pcxreq_d = req_valid_d;
2397
 
2398
//   assign req_pending_d = req_valid_d & ~can_pcx_d & ~lsu_ifu_pcxpkt_ack_d;
2399
   assign req_pending_d = req_valid_d & ~(lsu_ifu_pcxpkt_ack_d & ~errinv_d1);
2400
   assign req_accept_d = req_valid_d & lsu_ifu_pcxpkt_ack_d;
2401
//   assign rr_advance_d = req_accept_d & ~errinv_d1
2402
 
2403
   // Signal to FSM if pcx request has been accepted by LSU
2404
   assign pcx_accept_d = dpcxthr_d & {4{req_accept_d}};
2405
   // Alternate implementation with canthr delayed by a cycle
2406
//   assign pcxreq_vbit_d = req_valid_d & ~can_pcx_d;
2407
//   assign pcx_accept_d = dpcxthr_d & {4{req_accept_d}} & ~fcl_ifq_canthr;
2408
 
2409
   // check if there was an error to this thread
2410
   assign err_vec_d1 = dpcxthr_d & (errthr_d1 | err_req);
2411
   assign errinv_d1 = (|err_vec_d1[3:0]);
2412
 
2413
   dff #(1) errinv_ff(.din (errinv_d1),
2414
                                  .q   (ifc_ifd_errinv_e),
2415
                                  .clk (clk), .se(se), .si(), .so());
2416
 
2417
   assign pcxreq_vbit_d = req_valid_d;
2418
   dff #(1) pcxreqve_ff(.din  (pcxreq_vbit_d),  // same as ifu_lsu_pcxreq_d
2419
                                    .clk  (clk),
2420
                                    .q    (ifc_ifd_reqvalid_e),
2421
                                    .se   (se), .si(), .so());
2422
 
2423
//   dff #(1) pcxreqpe_ff(.din  (req_pending_d),
2424
//                                  .clk  (clk),
2425
//                                  .q    (req_pending_e),
2426
//                                  .se   (se), .si(), .so());
2427
 
2428
   // advance pcx request if there is no prev request pending
2429
   // the data is deliberately held valid for one extra cycle.  this
2430
   // is legacy stuff.  LSU guarantees that the data is picked up
2431
   // minimum 1 cycle after request is made. 
2432
//   assign ifc_ifd_nxtpcx_sel_new_d = ~req_pending_e;
2433
//   assign ifc_ifd_nxtpcx_sel_new_d = 1'b1;   
2434
 
2435
   // Select which MIL request to send out to PCX
2436
   assign ifc_ifd_milreq_sel_d_l[0] = ~dpcxthr_d[0] & ~rst_tri_en;
2437
   assign ifc_ifd_milreq_sel_d_l[1] = ~dpcxthr_d[1] | rst_tri_en;
2438
   assign ifc_ifd_milreq_sel_d_l[2] = ~dpcxthr_d[2] | rst_tri_en;
2439
   assign ifc_ifd_milreq_sel_d_l[3] = ~dpcxthr_d[3] | rst_tri_en;
2440
 
2441
 
2442
//-----------------------------
2443
// Invalidate Controls
2444
//----------------------------
2445
   assign stpkt_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b0100}) ? 1'b1 : 1'b0;
2446
   assign strmack_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b0110}) ? 1'b1 : 1'b0;
2447
   assign evpkt_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b0011}) ? 1'b1 : 1'b0;
2448
   assign ldpkt_i1 = (ifd_ifc_cpxreq_i1 == {1'b1, 4'b0000}) ? 1'b1 : 1'b0;
2449
 
2450
   assign invalidate_i1 = (stpkt_i1 | strmack_i1 | evpkt_i1 | ldpkt_i1);
2451
   assign ifu_lsu_inv_clear = ~(invalidate_i1 | inv_ifc_inv_pending);
2452
//       assign ifc_inv_wrreq_i2 = (imissrtn_i2 |
2453
//                              asireq_i2 & asi_ic_tag_i2 & ~asi_load_i2 |
2454
//                                              mbist_icache_write);
2455
 
2456
//   assign wrt_en_wd0_i2 = inv_ifc_word0_inv_i2 & (stpkt_i2 | evpkt_i2) |
2457
//                          ldinv_i2 & ~ifd_ifc_ldaddr5_i2 |
2458
//                                    (imissrtn_i2 |
2459
//                           asireq_i2 & asi_ic_tag_i2 & ~asi_load_i2 |
2460
//                                           mbist_icache_write) & 
2461
//                             ~ifd_ifc_missaddr5_i2;
2462
//
2463
//   assign wrt_en_wd1_i2 = inv_ifc_word1_inv_i2 & (stpkt_i2 | evpkt_i2) |
2464
//                                            ldinv_i2 & ifd_ifc_ldaddr5_i2 |
2465
//                                      (imissrtn_i2 |
2466
//                                             asireq_i2 & asi_ic_tag_i2 & ~asi_load_i2 |
2467
//                                             mbist_icache_write) & 
2468
//                              ifd_ifc_missaddr5_i2;
2469
 
2470
   // calculate the ICV write data
2471
   assign icv_wbit_i2 = imissrtn_i2 & ifc_ifd_filladdr4_i2 |
2472
                           asireq_i2 & asi_ic_tag_i2 & ~asi_load_i2 &
2473
                           cpxreq_i2[2];
2474
 
2475
   assign icv_wrdata_i2 = ifc_inv_ifqadv_i2 ? icv_wbit_i2 : icv_wrdata_f;
2476
 
2477
//   mux2ds #(2) icv_damux(.dout (icv_wrdata_i2),
2478
//                                   .in0  (icv_wrdata_f),
2479
//                                   .in1  (icv_wbit_i2),
2480
//                                   .sel0 (~ifc_inv_ifqadv_i2),
2481
//                                   .sel1 (ifc_inv_ifqadv_i2));
2482
 
2483
   dff #(1) icv_daff(.din  (icv_wrdata_i2),
2484
                                 .q    (icv_wrdata_f),
2485
                                 .clk  (clk),
2486
                                 .se   (se), .si(), .so());
2487
   assign ifq_icv_wrdata_bf = icv_wrdata_i2;
2488
 
2489
 
2490
// Begin ECO7010
2491
   dp_mux2es #(1) wayvld_mux (.dout (inq_wayvld_i1_nxt),        //done
2492
                              .in0 (lsu_ifu_cpxpkt_wayvld_i1),
2493
                              .in1 (inq_wayvld_i1),
2494
                              .sel(inq_vld));
2495
 
2496
   dff #(1) wayvld_ff (.din (inq_wayvld_i1_nxt),             //done
2497
                       .q   (inq_wayvld_i1),
2498
                       .clk (clk), .se(se), .si(), .so());
2499
 
2500
   assign ldinv_i1 = ldpkt_i1 & inq_wayvld_i1;  //done
2501
 
2502
   dp_mux2es #(1) ldinv_i2_mux (.dout (ldinv_i2_nxt),  //done
2503
                              .in0 (ldinv_i1),
2504
                              .in1 (ldinv_i2),
2505
                              .sel(ifc_ifd_ifqbyp_en_l));
2506
 
2507
   dff #(1) ldinv_i2_ff (.din (ldinv_i2_nxt),   //done
2508
                         .q   (ldinv_i2),
2509
                         .clk (clk), .se(se), .si(), .so());
2510
 
2511
//End ECO7010
2512
 
2513
//------------------------------------------------
2514
// Fwd Request to read/write Icache
2515
//------------------------------------------------
2516
   // is this a fwd req to the L1I?
2517
   assign fwdreq_i2 = (cpxreq_i2 == 4'b1010) ?
2518
                        (ifd_ifc_fwd2ic_i2 & ifd_ifc_4bpkt_i2 &
2519
                         ifd_ifc_cpxvld_i2) : 1'b0;
2520
 
2521
   // detect first cycle of fwdpkt and stall
2522
   assign fwd_stall = fwdreq_i2 & ~fwdreq_i3;
2523
 
2524
   dff #(1) freq_ff(.din (fwd_stall),
2525
                    .q   (fwdreq_i3),
2526
                    .clk (clk), .se(se), .si(), .so());
2527
 
2528
   dff #(1) cpx3_ff(.din (ifd_ifc_cpxnc_i2),
2529
                    .q   (cpxnc_i3),
2530
                    .clk (clk), .se(se), .si(), .so());
2531
 
2532
   // NC bit is also R/W_bar bit
2533
   assign fwdrd_i3 = fwdreq_i3 & cpxnc_i3;
2534
   assign fwdwr_i3 = fwdreq_i3 & ~cpxnc_i3;
2535
 
2536
   // ack back to the LSU to send fwd reply
2537
   assign ifu_lsu_fwd_wr_ack = fwdwr_i3;
2538
   assign ifc_ifd_idx_sel_fwd_i2 = fwdreq_i2;
2539
 
2540
   // let errctl know a fwd packet is coming
2541
   assign ifq_erb_fwdrd_bf = fwdrd_i3;
2542
 
2543
//----------------------------------
2544
// INQ controls -- now ibuf controls
2545
//----------------------------------
2546
 
2547
// INQ removed 2/13/02   
2548
 
2549
   // Is the pkt in the inq a pkt that affects the icache?
2550
   assign ic_pkt_i1 = invalidate_i1 | imissrtn_i1 | errpkt_i1;
2551
 
2552
//   assign inq_vld_nxt = ~inq_vld & ifd_ifc_cpxvalid_i1 & 
2553
//                            (~ifqadv_i1 | asireq_i1) | 
2554
//                            inq_vld & ((~ifqadv_i1 | asireq_i1) & ic_pkt_i1 |
2555
//                                                           ifd_ifc_cpxvalid_i1);
2556
 
2557
   // cut this down to 1 aoi gate
2558
   assign inq_vld_nxt = (ifd_ifc_cpxvalid_i1 |
2559
                         inq_vld & ic_pkt_i1) & (~ifqadv_i1 | ifu_asireq_i1);
2560
 
2561
   dffr #(1) inqv_ff(.din (inq_vld_nxt),
2562
                                 .q   (inq_vld),
2563
                                 .rst (ifq_reset),
2564
                                 .clk (clk), .se(se), .si(), .so());
2565
 
2566
   assign ifc_ifd_ifqbyp_en_l = ~(ifqadv_i1 | fwd_stall);
2567
 
2568
   assign ifc_ifd_ifqbyp_sel_fwd_l = ~(fwd_stall & ~ifq_reset);
2569
   assign ifc_ifd_ifqbyp_sel_asi_l = ~(~fwd_stall & ~ifq_reset &
2570
                                       ifu_asireq_i1);
2571
   assign ifc_ifd_ifqbyp_sel_inq_l = ~(~fwd_stall & ~ifq_reset &
2572
                                       ~ifu_asireq_i1 & inq_vld);
2573
   assign ifc_ifd_ifqbyp_sel_lsu_l = ~(~fwd_stall & ~ifu_asireq_i1 &
2574
                                       ~inq_vld | ifq_reset);
2575
 
2576
   assign byp_sel_asi_l = ~(ifqadv_i1 & ifu_asireq_i1);
2577
 
2578
//   assign ifu_lsu_ibuf_busy = inq_vld & (~ifqadv_i1 | asireq_i1);
2579
//   assign ifc_ifd_ld_inq_i1 = ~inq_vld | ifqadv_i1 & ~asireq_i1;
2580
 
2581
   assign ifu_lsu_ibuf_busy = inq_vld;
2582
   assign ifc_ifd_ld_inq_i1 = ~inq_vld;
2583
 
2584
//-----------------------------------------
2585
// ASI access controls
2586
//-----------------------------------------
2587
 
2588
   // need this to help with timing
2589
   // - asi_vld is asserted only if the asi transaction is to an IFU asi
2590
   //   register AND that register is not in the IMMU.
2591
   // - it is held valid until an ack is signalled .
2592
   // - the ack is not signalled for atleast 2 cycles
2593
   assign asi_vld_next = lsu_ifu_asi_vld & byp_sel_asi_l &
2594
                               ~asireq_i2 & ~illva_i2;  // not when ack is sent
2595
 
2596
   dff #(1) asiv0_ff(.din (asi_vld_next),
2597
                                .q   (asi_vld_i0),
2598
                                .clk (clk), .se(se), .si(), .so());
2599
   assign asi_vld_qual_i0 = asi_vld_i0 & ~asireq_i2 & ~illva_i2 &
2600
                            byp_sel_asi_l & ~illva_i1 &
2601
                            lsu_ifu_asi_vld;
2602
 
2603
   dff #(8) asi_reg(.din (lsu_ifu_asi_state[7:0]),
2604
                                .q   (asi_state_i1),
2605
                                .clk (clk), .se(se), .si(), .so());
2606
 
2607
   dff #(2) asi_tid_reg(.din (lsu_ifu_asi_thrid[1:0]),
2608
                                    .q   (ifq_fcl_asi_tid_bf[1:0]),
2609
                                    .clk (clk), .se(se), .si(), .so());
2610
 
2611
//   assign ifu_lsu_asi_ack = ~byp_sel_asi_l;
2612
   // Decided to wait one more cycle before sending the ack.
2613
   assign ifu_lsu_asi_ack = asireq_i2 | illva_i2;
2614
 
2615
   // ifu ASIs
2616
   // icache data = 0x66
2617
   assign asi_ic_data_unchk_i1 = ~asi_state_i1[7] &
2618
                asi_state_i1[6] &
2619
                asi_state_i1[5] &
2620
                ~asi_state_i1[4] &
2621
                ~asi_state_i1[3] &
2622
                      asi_state_i1[2] &
2623
                      asi_state_i1[1] &
2624
                      ~asi_state_i1[0];
2625
   assign asi_ic_data_i1 = asi_ic_data_unchk_i1;
2626
 
2627
   // icache tags = 0x67
2628
   // writing to tag also writes to vbits
2629
   assign asi_ic_tag_unchk_i1 = ~asi_state_i1[7] &
2630
                      asi_state_i1[6] &
2631
                      asi_state_i1[5] &
2632
                      ~asi_state_i1[4] &
2633
                      ~asi_state_i1[3] &
2634
                      asi_state_i1[2] &
2635
                      asi_state_i1[1] &
2636
                      asi_state_i1[0];
2637
   assign asi_ic_tag_i1 = asi_ic_tag_unchk_i1;
2638
 
2639
   // error enable 0x4B
2640
   assign asi_erren_unchk_i1 = ~asi_state_i1[7] &
2641
                      asi_state_i1[6] &
2642
                      ~asi_state_i1[5] &
2643
                      ~asi_state_i1[4] &
2644
                      asi_state_i1[3] &
2645
                      ~asi_state_i1[2] &
2646
                      asi_state_i1[1] &
2647
                      asi_state_i1[0];
2648
   assign asi_erren_i1 =  asi_erren_unchk_i1 &
2649
          ~ifd_ifc_asi_vachklo_i2 &
2650
          ~ifd_ifc_asiaddr_i2[2];
2651
 
2652
   // error status 0x4C
2653
   assign asi_errstat_unchk_i1 = ~asi_state_i1[7] &
2654
                      asi_state_i1[6] &
2655
                      ~asi_state_i1[5] &
2656
                      ~asi_state_i1[4] &
2657
                      asi_state_i1[3] &
2658
                      asi_state_i1[2] &
2659
                      ~asi_state_i1[1] &
2660
                      ~asi_state_i1[0];
2661
   assign asi_errstat_i1 = asi_errstat_unchk_i1 &
2662
          ~ifd_ifc_asi_vachklo_i2 &
2663
          ~ifd_ifc_asiaddr_i2[2];
2664
 
2665
   // error addr 0x4D
2666
   assign asi_erraddr_unchk_i1 = ~asi_state_i1[7] &
2667
                      asi_state_i1[6] &
2668
                      ~asi_state_i1[5] &
2669
                      ~asi_state_i1[4] &
2670
                      asi_state_i1[3] &
2671
                      asi_state_i1[2] &
2672
                      ~asi_state_i1[1] &
2673
                      asi_state_i1[0];
2674
   assign asi_erraddr_i1 =  asi_erraddr_unchk_i1 &
2675
          ~ifd_ifc_asi_vachklo_i2 &
2676
          ~ifd_ifc_asiaddr_i2[2];
2677
 
2678
   // error inject 0x43
2679
   assign asi_errinj_unchk_i1 = ~asi_state_i1[7] &
2680
                      asi_state_i1[6] &
2681
                      ~asi_state_i1[5] &
2682
                      ~asi_state_i1[4] &
2683
                      ~asi_state_i1[3] &
2684
                      ~asi_state_i1[2] &
2685
                      asi_state_i1[1] &
2686
                      asi_state_i1[0];
2687
   assign asi_errinj_i1 =  asi_errinj_unchk_i1 &
2688
          ~ifd_ifc_asi_vachklo_i2 &
2689
          ~ifd_ifc_asiaddr_i2[2];
2690
 
2691
   // imask 0x42, va=0x8
2692
   assign asi_imask_unchk_i1 = ~asi_state_i1[7] &
2693
                      asi_state_i1[6] &
2694
                      ~asi_state_i1[5] &
2695
                      ~asi_state_i1[4] &
2696
                      ~asi_state_i1[3] &
2697
                      ~asi_state_i1[2] &
2698
                      asi_state_i1[1] &
2699
                      ~asi_state_i1[0];
2700
   assign asi_imask_i1 = asi_imask_unchk_i1  &
2701
          ~ifd_ifc_asi_vachklo_i2 &
2702
          ifd_ifc_asiaddr_i2[2];  // this is actually va[3]
2703
 
2704
   // illegal va check
2705
   assign illva_i0 = ((asi_erren_unchk_i1 |
2706
                       asi_errstat_unchk_i1 |
2707
                       asi_errinj_unchk_i1 |
2708
                       asi_erraddr_unchk_i1) & (ifd_ifc_asi_vachklo_i2 |
2709
                                                ifd_ifc_asiaddr_i2[2])) &
2710
                       asi_vld_qual_i0;
2711
 
2712
   dff #(1) illvai1_ff(.din (illva_i0),
2713
                       .q   (illva_i1),
2714
                       .clk (clk), .se(se), .si(), .so());
2715
   dff #(1) illvabf_ff(.din (illva_i1),
2716
                     .q   (illva_i2),
2717
                     .clk (clk), .se(se), .si(), .so());
2718
   dff #(1) illvaf_ff(.din (illva_i2),
2719
                     .q   (illva_f),
2720
                     .clk (clk), .se(se), .si(), .so());
2721
   dff #(1) illvas_ff(.din (illva_f),
2722
                      .q   (illva_s),
2723
                      .clk (clk), .se(se), .si(), .so());
2724
   dff #(1) illvaw2_ff(.din (illva_s),
2725
                       .q   (illva_w2),
2726
                       .clk (clk), .se(se), .si(), .so());
2727
   assign ifu_lsu_ldxa_illgl_va_w2 = illva_w2;
2728
 
2729
   dff #(1) tagasi_ff(.din (asi_ic_tag_i1),
2730
                                  .q   (asi_ic_tag_i2),
2731
                                  .clk (clk), .se(se), .si(), .so());
2732
   dff #(1) datasi_ff(.din (asi_ic_data_i1),
2733
                                  .q   (asi_ic_data_i2),
2734
                                  .clk (clk), .se(se), .si(), .so());
2735
 
2736
   dff #(1) asieeni2_ff(.din (asi_erren_i1),
2737
                                    .q   (ifq_erb_asi_erren_i2),
2738
                                    .clk (clk), .se(se), .si(), .so());
2739
   dff #(1) asieini2_ff(.din (asi_errinj_i1),
2740
                                    .q   (ifq_erb_asi_errinj_i2),
2741
                                    .clk (clk), .se(se), .si(), .so());
2742
   dff #(1) asiesti2_ff(.din (asi_errstat_i1),
2743
                                    .q   (ifq_erb_asi_errstat_i2),
2744
                                    .clk (clk), .se(se), .si(), .so());
2745
   dff #(1) asieadi2_ff(.din (asi_erraddr_i1),
2746
                                    .q   (ifq_erb_asi_erraddr_i2),
2747
                                    .clk (clk), .se(se), .si(), .so());
2748
   dff #(1) imaski2_ff(.din (asi_imask_i1),
2749
                                   .q   (ifq_erb_asi_imask_i2),
2750
                                   .clk (clk), .se(se), .si(), .so());
2751
 
2752
   // All IFU asi requests
2753
   assign ifu_asireq_i0 = (asi_ic_tag_i1 | asi_ic_data_i1 | asi_erren_i1 |
2754
                                       asi_errinj_i1 | asi_errstat_i1 | asi_erraddr_i1 |
2755
                                       asi_imask_i1) & asi_vld_qual_i0;
2756
 
2757
   dff #(1) asireq1_ff(.din  (ifu_asireq_i0),
2758
                                   .q    (ifu_asireq_i1),
2759
                                   .clk  (clk), .se(se), .si(), .so());
2760
 
2761
   dff #(1) asivld_ff(.din  (byp_sel_asi_l),
2762
                                  .q    (asireq_i2_l),
2763
                                  .clk  (clk), .se(se), .si(), .so());
2764
   assign asireq_i2 = ~asireq_i2_l;
2765
   assign ifc_inv_asireq_i2 = asireq_i2;
2766
 
2767
   // Stall if we are doing an asi op or fwdreq
2768
  assign stallreq_d0 = (ifu_asireq_i0 |
2769
                         ~byp_sel_asi_l |
2770
                         fwdreq_i2) |
2771
                          starv_alert |
2772
                          mbist_ifq_run_bist |
2773
                          ldinv_i1 & ~ifqadv_i1 |        //ECO 7010
2774
                          ldinv_i2 & ~ifc_inv_ifqadv_i2; //ECO 7010
2775
 
2776
   dff #(1) stal_ff(.din (stallreq_d0),
2777
                    .q   (stallreq_d1),
2778
                    .clk (clk), .se(se), .si(), .so());
2779
 
2780
   // split into two to save repeater
2781
   assign ifq_fcl_stallreq = stallreq_d1;
2782
   assign ifq_swl_stallreq = stallreq_d1;
2783
 
2784
   dff #(1) asil1_ff(.din (lsu_ifu_asi_load),
2785
                                 .q   (asi_load_i1),
2786
                                 .clk (clk), .se(se), .si(), .so());
2787
 
2788
   dff #(1) asil2_ff(.din (asi_load_i1),
2789
                                 .q   (asi_load_i2),
2790
                                 .clk (clk), .se(se), .si(), .so());
2791
 
2792
   // insert parity error in data and/or tag
2793
   // Don't need to qualify with asireq and imissrtn...
2794
   //   -- moved this to the DP since the qual is not necessary
2795
//   assign ifc_ifd_insert_pe = (asireq_i2 | imissrtn_i2) & 
2796
//                              ifd_ifc_cpxue_i2;
2797
 
2798
   // decode asi
2799
   // generate word selects
2800
   // can use finst instead of word_sel_i2, but it screws up timing
2801
 
2802
   assign word_sel_i2[0] = ~ifd_ifc_asiaddr_i2[3] & ~ifd_ifc_asiaddr_i2[2];
2803
   assign word_sel_i2[1] = ~ifd_ifc_asiaddr_i2[3] &  ifd_ifc_asiaddr_i2[2];
2804
   assign word_sel_i2[2] =  ifd_ifc_asiaddr_i2[3] & ~ifd_ifc_asiaddr_i2[2];
2805
   assign word_sel_i2[3] =  ifd_ifc_asiaddr_i2[3] &  ifd_ifc_asiaddr_i2[2];
2806
 
2807
   // this assumes asi requests are never stalled
2808
   assign ifq_icd_worden_bf = (word_sel_i2 | {4{~asireq_i2 & ~fwdwr_i3  |
2809
//                                                ~ifc_inv_ifqadv_i2 | 
2810
                                                mbist_icache_write}});
2811
// & (mbist_icache_worden | {4{~bist_op}});
2812
 
2813
   // choose where the ic address should come from
2814
//   assign bist_op = (mbist_icache_read | mbist_icache_write);
2815
   dff #(1) bist_run_ff(.din (mbist_ifq_run_bist),
2816
                        .q   (bist_op),
2817
                        .clk (clk), .se(se), .si(), .so());
2818
 
2819
   assign ifc_ifd_addr_sel_bist_i2_l = ~bist_op | sehold;
2820
   assign ifc_ifd_addr_sel_old_i2_l = (bist_op | ifc_inv_ifqadv_i2) & ~sehold;
2821
   assign ifc_ifd_addr_sel_asi_i2_l = bist_op | ~ifc_inv_ifqadv_i2 |
2822
                                      sehold | ~(asireq_i2 | fwdreq_i3);
2823
   assign ifc_ifd_addr_sel_fill_i2_l = bist_op | ~ifc_inv_ifqadv_i2 |
2824
                                       sehold | asireq_i2 | fwdreq_i3;
2825
 
2826
   // choose where the data should come from
2827
   assign ifq_icd_data_sel_bist_i2 = mbist_icache_write & ~sehold;
2828
   assign ifq_icd_data_sel_fill_i2 = ~mbist_icache_write & ifc_inv_ifqadv_i2 &
2829
                                     ~sehold;
2830
   assign ifq_icd_data_sel_old_i2 = ~mbist_icache_write & ~ifc_inv_ifqadv_i2 |
2831
                                     sehold;
2832
 
2833
   // generate icache controls
2834
   assign ifq_fcl_rdreq_bf = asireq_i2 & asi_load_i2 &
2835
                                   (asi_ic_data_i2 | asi_ic_tag_i2) |
2836
                                   mbist_icache_read |
2837
                             fwdrd_i3;
2838
 
2839
   assign ifq_fcl_icd_wrreq_bf = asi_ic_data_i2 & asireq_i2 & ~asi_load_i2 |
2840
                                       mbist_icache_write |
2841
                                 fwdwr_i3;
2842
 
2843
   assign ifq_fcl_ictv_wrreq_bf = asi_ic_tag_i2 & asireq_i2 & ~asi_load_i2;
2844
 
2845
   assign rd_tag_bf = asi_ic_tag_i2 & asi_load_i2;
2846
   dff #(1) asi_srcf_ff(.din (rd_tag_bf),
2847
                               .q   (ifq_erb_rdtag_f),
2848
                               .clk (clk), .se(se), .si(), .so());
2849
 
2850
   assign rdinst_bf = asi_ic_data_i2 & asi_load_i2;
2851
   dff #(1) asi_inst_ff(.din (rdinst_bf),
2852
                               .q   (ifq_erb_rdinst_f),
2853
                               .clk (clk), .se(se), .si(), .so());
2854
 
2855
   assign asird_i1 = asi_load_i1 & (~byp_sel_asi_l | illva_i1);
2856
   dff #(1) asirdq_ff(.din (asird_i1),
2857
                      .q   (ifq_fcl_asird_bf),
2858
                      .clk (clk), .se(se), .si(), .so());
2859
 
2860
   assign ifq_erb_asiwr_i2 = ~asi_load_i2 & asireq_i2;
2861
 
2862
 
2863
 
2864
   // Shadow scan mux
2865
   mux4ds #(4) milss_mux(.dout (ifq_sscan_data[3:0]),
2866
                         .in0  (mil0_state),
2867
                         .in1  (mil1_state),
2868
                         .in2  (mil2_state),
2869
                         .in3  (mil3_state),
2870
                         .sel0 (ctu_sscan_tid[0]),
2871
                         .sel1 (ctu_sscan_tid[1]),
2872
                         .sel2 (ctu_sscan_tid[2]),
2873
                         .sel3 (ctu_sscan_tid[3]));
2874
 
2875
 
2876
 
2877
endmodule // sparc_ifu_ifqctl
2878
 

powered by: WebSVN 2.1.0

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