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

Subversion Repositories s1_core

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

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

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: lsu_stb_rwctl.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21
///////////////////////////////////////////////////////////////////
22
/*
23
//  Description:  Control for Unified STB CAM/DATA of LSU
24
*/
25
////////////////////////////////////////////////////////////////////////
26
// Global header file includes
27
////////////////////////////////////////////////////////////////////////
28
// system level definition file which contains the /*
29
/* ========== Copyright Header Begin ==========================================
30
*
31
* OpenSPARC T1 Processor File: sys.h
32
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
34
*
35
* The above named program is free software; you can redistribute it and/or
36
* modify it under the terms of the GNU General Public
37
* License version 2 as published by the Free Software Foundation.
38
*
39
* The above named program is distributed in the hope that it will be
40
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
41
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42
* General Public License for more details.
43
*
44
* You should have received a copy of the GNU General Public
45
* License along with this work; if not, write to the Free Software
46
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
47
*
48
* ========== Copyright Header End ============================================
49
*/
50
// -*- verilog -*-
51
////////////////////////////////////////////////////////////////////////
52
/*
53
//
54
// Description:         Global header file that contain definitions that
55
//                      are common/shared at the systme level
56
*/
57
////////////////////////////////////////////////////////////////////////
58
//
59
// Setting the time scale
60
// If the timescale changes, JP_TIMESCALE may also have to change.
61
`timescale      1ps/1ps
62
 
63
//
64
// JBUS clock
65
// =========
66
//
67
 
68
 
69
 
70
// Afara Link Defines
71
// ==================
72
 
73
// Reliable Link
74
 
75
 
76
 
77
 
78
// Afara Link Objects
79
 
80
 
81
// Afara Link Object Format - Reliable Link
82
 
83
 
84
 
85
 
86
 
87
 
88
 
89
 
90
 
91
 
92
// Afara Link Object Format - Congestion
93
 
94
 
95
 
96
 
97
 
98
 
99
 
100
 
101
 
102
 
103
 
104
// Afara Link Object Format - Acknowledge
105
 
106
 
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
// Afara Link Object Format - Request
117
 
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
 
134
// Afara Link Object Format - Message
135
 
136
 
137
 
138
// Acknowledge Types
139
 
140
 
141
 
142
 
143
// Request Types
144
 
145
 
146
 
147
 
148
 
149
// Afara Link Frame
150
 
151
 
152
 
153
//
154
// UCB Packet Type
155
// ===============
156
//
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
//
175
// UCB Data Packet Format
176
// ======================
177
//
178
 
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
// Size encoding for the UCB_SIZE_HI/LO field
209
// 000 - byte
210
// 001 - half-word
211
// 010 - word
212
// 011 - double-word
213
// 111 - quad-word
214
 
215
 
216
 
217
 
218
 
219
 
220
 
221
//
222
// UCB Interrupt Packet Format
223
// ===========================
224
//
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232
 
233
 
234
 
235
//`define UCB_THR_HI             9      // (6) cpu/thread ID shared with
236
//`define UCB_THR_LO             4             data packet format
237
//`define UCB_PKT_HI             3      // (4) packet type shared with
238
//`define UCB_PKT_LO             0      //     data packet format
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
//
247
// FCRAM Bus Widths
248
// ================
249
//
250
 
251
 
252
 
253
 
254
 
255
 
256
//
257
// ENET clock periods
258
// ==================
259
//
260
 
261
 
262
 
263
 
264
//
265
// JBus Bridge defines
266
// =================
267
//
268
 
269
 
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
 
279
//
280
// PCI Device Address Configuration
281
// ================================
282
//
283
 
284
 
285
 
286
 
287
 
288
 
289
 
290
 
291
 
292
 
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
 
305
 
306
          // time scale definition
307
 
308
/*
309
/* ========== Copyright Header Begin ==========================================
310
*
311
* OpenSPARC T1 Processor File: iop.h
312
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
313
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
314
*
315
* The above named program is free software; you can redistribute it and/or
316
* modify it under the terms of the GNU General Public
317
* License version 2 as published by the Free Software Foundation.
318
*
319
* The above named program is distributed in the hope that it will be
320
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
321
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
322
* General Public License for more details.
323
*
324
* You should have received a copy of the GNU General Public
325
* License along with this work; if not, write to the Free Software
326
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
327
*
328
* ========== Copyright Header End ============================================
329
*/
330
//-*- verilog -*-
331
////////////////////////////////////////////////////////////////////////
332
/*
333
//
334
//  Description:        Global header file that contain definitions that
335
//                      are common/shared at the IOP chip level
336
*/
337
////////////////////////////////////////////////////////////////////////
338
 
339
 
340
// Address Map Defines
341
// ===================
342
 
343
 
344
 
345
 
346
// CMP space
347
 
348
 
349
 
350
// IOP space
351
 
352
 
353
 
354
 
355
                               //`define ENET_ING_CSR     8'h84
356
                               //`define ENET_EGR_CMD_CSR 8'h85
357
 
358
 
359
 
360
 
361
 
362
 
363
 
364
 
365
 
366
 
367
 
368
 
369
 
370
 
371
 
372
// L2 space
373
 
374
 
375
 
376
// More IOP space
377
 
378
 
379
 
380
 
381
 
382
//Cache Crossbar Width and Field Defines
383
//======================================
384
 
385
 
386
 
387
 
388
 
389
 
390
 
391
 
392
 
393
 
394
 
395
 
396
 
397
 
398
 
399
 
400
 
401
 
402
 
403
 
404
 
405
 
406
 
407
 
408
 
409
 
410
 
411
 
412
 
413
 
414
 
415
 
416
 
417
 
418
 
419
 
420
 
421
 
422
 
423
 
424
 
425
 
426
 
427
 
428
 
429
//bits 133:128 are shared by different fields
430
//for different packet types.
431
 
432
 
433
 
434
 
435
 
436
 
437
 
438
 
439
 
440
 
441
 
442
 
443
 
444
 
445
 
446
 
447
 
448
 
449
 
450
 
451
 
452
 
453
 
454
 
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462
 
463
 
464
 
465
 
466
 
467
 
468
 
469
 
470
 
471
 
472
 
473
 
474
 
475
 
476
 
477
 
478
 
479
 
480
 
481
 
482
 
483
 
484
 
485
 
486
 
487
 
488
 
489
 
490
 
491
 
492
 
493
//End cache crossbar defines
494
 
495
 
496
// Number of COS supported by EECU 
497
 
498
 
499
 
500
// 
501
// BSC bus sizes
502
// =============
503
//
504
 
505
// General
506
 
507
 
508
 
509
 
510
// CTags
511
 
512
 
513
 
514
 
515
 
516
 
517
 
518
 
519
 
520
 
521
 
522
 
523
 
524
// reinstated temporarily
525
 
526
 
527
 
528
 
529
// CoS
530
 
531
 
532
 
533
 
534
 
535
 
536
// L2$ Bank
537
 
538
 
539
 
540
// L2$ Req
541
 
542
 
543
 
544
 
545
 
546
 
547
 
548
 
549
 
550
 
551
 
552
 
553
 
554
// L2$ Ack
555
 
556
 
557
 
558
 
559
 
560
 
561
 
562
 
563
// Enet Egress Command Unit
564
 
565
 
566
 
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
 
575
 
576
 
577
 
578
// Enet Egress Packet Unit
579
 
580
 
581
 
582
 
583
 
584
 
585
 
586
 
587
 
588
 
589
 
590
 
591
 
592
// This is cleaved in between Egress Datapath Ack's
593
 
594
 
595
 
596
 
597
 
598
 
599
 
600
 
601
// Enet Egress Datapath
602
 
603
 
604
 
605
 
606
 
607
 
608
 
609
 
610
 
611
 
612
 
613
 
614
 
615
 
616
 
617
 
618
// In-Order / Ordered Queue: EEPU
619
// Tag is: TLEN, SOF, EOF, QID = 15
620
 
621
 
622
 
623
 
624
 
625
 
626
// Nack + Tag Info + CTag
627
 
628
 
629
 
630
 
631
// ENET Ingress Queue Management Req
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
 
640
 
641
 
642
 
643
 
644
// ENET Ingress Queue Management Ack
645
 
646
 
647
 
648
 
649
 
650
 
651
 
652
 
653
// Enet Ingress Packet Unit
654
 
655
 
656
 
657
 
658
 
659
 
660
 
661
 
662
 
663
 
664
 
665
 
666
// ENET Ingress Packet Unit Ack
667
 
668
 
669
 
670
 
671
 
672
 
673
 
674
// In-Order / Ordered Queue: PCI
675
// Tag is: CTAG
676
 
677
 
678
 
679
 
680
 
681
// PCI-X Request
682
 
683
 
684
 
685
 
686
 
687
 
688
 
689
 
690
 
691
 
692
 
693
// PCI_X Acknowledge
694
 
695
 
696
 
697
 
698
 
699
 
700
 
701
 
702
 
703
 
704
 
705
//
706
// BSC array sizes
707
//================
708
//
709
 
710
 
711
 
712
 
713
 
714
 
715
 
716
 
717
 
718
 
719
 
720
 
721
// ECC syndrome bits per memory element
722
 
723
 
724
 
725
 
726
//
727
// BSC Port Definitions
728
// ====================
729
//
730
// Bits 7 to 4 of curr_port_id
731
 
732
 
733
 
734
 
735
 
736
 
737
 
738
 
739
// Number of ports of each type
740
 
741
 
742
// Bits needed to represent above
743
 
744
 
745
// How wide the linked list pointers are
746
// 60b for no payload (2CoS)
747
// 80b for payload (2CoS)
748
 
749
//`define BSC_OBJ_PTR   80
750
//`define BSC_HD1_HI    69
751
//`define BSC_HD1_LO    60
752
//`define BSC_TL1_HI    59
753
//`define BSC_TL1_LO    50
754
//`define BSC_CT1_HI    49
755
//`define BSC_CT1_LO    40
756
//`define BSC_HD0_HI    29
757
//`define BSC_HD0_LO    20
758
//`define BSC_TL0_HI    19
759
//`define BSC_TL0_LO    10
760
//`define BSC_CT0_HI     9
761
//`define BSC_CT0_LO     0
762
 
763
 
764
 
765
 
766
 
767
 
768
 
769
 
770
 
771
 
772
 
773
 
774
 
775
 
776
 
777
 
778
 
779
 
780
 
781
 
782
 
783
 
784
 
785
 
786
 
787
 
788
 
789
 
790
 
791
 
792
 
793
 
794
 
795
 
796
// I2C STATES in DRAMctl
797
 
798
 
799
 
800
 
801
 
802
 
803
 
804
//
805
// IOB defines
806
// ===========
807
//
808
 
809
 
810
 
811
 
812
 
813
 
814
 
815
 
816
 
817
 
818
 
819
 
820
 
821
 
822
 
823
 
824
 
825
 
826
 
827
//`define IOB_INT_STAT_WIDTH   32
828
//`define IOB_INT_STAT_HI      31
829
//`define IOB_INT_STAT_LO       0
830
 
831
 
832
 
833
 
834
 
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
 
843
 
844
 
845
 
846
 
847
 
848
 
849
 
850
 
851
 
852
 
853
 
854
 
855
 
856
 
857
 
858
 
859
 
860
 
861
 
862
 
863
 
864
 
865
 
866
 
867
 
868
 
869
 
870
 
871
 
872
 
873
 
874
 
875
 
876
 
877
 
878
 
879
// fixme - double check address mapping
880
// CREG in `IOB_INT_CSR space
881
 
882
 
883
 
884
 
885
 
886
 
887
 
888
 
889
 
890
 
891
// CREG in `IOB_MAN_CSR space
892
 
893
 
894
 
895
 
896
 
897
 
898
 
899
 
900
 
901
 
902
 
903
 
904
 
905
 
906
 
907
 
908
 
909
 
910
 
911
 
912
 
913
 
914
 
915
 
916
 
917
 
918
 
919
 
920
 
921
 
922
 
923
 
924
 
925
 
926
 
927
 
928
 
929
// Address map for TAP access of SPARC ASI
930
 
931
 
932
 
933
 
934
 
935
 
936
 
937
 
938
 
939
 
940
 
941
 
942
 
943
//
944
// CIOP UCB Bus Width
945
// ==================
946
//
947
//`define IOB_EECU_WIDTH       16  // ethernet egress command
948
//`define EECU_IOB_WIDTH       16
949
 
950
//`define IOB_NRAM_WIDTH       16  // NRAM (RLDRAM previously)
951
//`define NRAM_IOB_WIDTH        4
952
 
953
 
954
 
955
 
956
//`define IOB_ENET_ING_WIDTH   32  // ethernet ingress
957
//`define ENET_ING_IOB_WIDTH    8
958
 
959
//`define IOB_ENET_EGR_WIDTH    4  // ethernet egress
960
//`define ENET_EGR_IOB_WIDTH    4
961
 
962
//`define IOB_ENET_MAC_WIDTH    4  // ethernet MAC
963
//`define ENET_MAC_IOB_WIDTH    4
964
 
965
 
966
 
967
 
968
//`define IOB_BSC_WIDTH         4  // BSC
969
//`define BSC_IOB_WIDTH         4
970
 
971
 
972
 
973
 
974
 
975
 
976
 
977
//`define IOB_CLSP_WIDTH        4  // clk spine unit
978
//`define CLSP_IOB_WIDTH        4
979
 
980
 
981
 
982
 
983
 
984
//
985
// CIOP UCB Buf ID Type
986
// ====================
987
//
988
 
989
 
990
 
991
//
992
// Interrupt Device ID
993
// ===================
994
//
995
// Caution: DUMMY_DEV_ID has to be 9 bit wide
996
//          for fields to line up properly in the IOB.
997
 
998
 
999
 
1000
//
1001
// Soft Error related definitions 
1002
// ==============================
1003
//
1004
 
1005
 
1006
 
1007
//
1008
// CMP clock
1009
// =========
1010
//
1011
 
1012
 
1013
 
1014
 
1015
//
1016
// NRAM/IO Interface
1017
// =================
1018
//
1019
 
1020
 
1021
 
1022
 
1023
 
1024
 
1025
 
1026
 
1027
 
1028
 
1029
//
1030
// NRAM/ENET Interface
1031
// ===================
1032
//
1033
 
1034
 
1035
 
1036
 
1037
 
1038
 
1039
 
1040
//
1041
// IO/FCRAM Interface
1042
// ==================
1043
//
1044
 
1045
 
1046
 
1047
 
1048
 
1049
 
1050
//
1051
// PCI Interface
1052
// ==================
1053
// Load/store size encodings
1054
// -------------------------
1055
// Size encoding
1056
// 000 - byte
1057
// 001 - half-word
1058
// 010 - word
1059
// 011 - double-word
1060
// 100 - quad
1061
 
1062
 
1063
 
1064
 
1065
 
1066
 
1067
//
1068
// JBI<->SCTAG Interface
1069
// =======================
1070
// Outbound Header Format
1071
 
1072
 
1073
 
1074
 
1075
 
1076
 
1077
 
1078
 
1079
 
1080
 
1081
 
1082
 
1083
 
1084
 
1085
 
1086
 
1087
 
1088
 
1089
 
1090
 
1091
 
1092
 
1093
 
1094
 
1095
 
1096
 
1097
 
1098
// Inbound Header Format
1099
 
1100
 
1101
 
1102
 
1103
 
1104
 
1105
 
1106
 
1107
 
1108
 
1109
 
1110
 
1111
 
1112
 
1113
 
1114
 
1115
 
1116
 
1117
 
1118
 
1119
//
1120
// JBI->IOB Mondo Header Format
1121
// ============================
1122
//
1123
 
1124
 
1125
 
1126
 
1127
 
1128
 
1129
 
1130
 
1131
 
1132
 
1133
 
1134
 
1135
 
1136
 
1137
// JBI->IOB Mondo Bus Width/Cycle
1138
// ==============================
1139
// Cycle  1 Header[15:8]
1140
// Cycle  2 Header[ 7:0]
1141
// Cycle  3 J_AD[127:120]
1142
// Cycle  4 J_AD[119:112]
1143
// .....
1144
// Cycle 18 J_AD[  7:  0]
1145
 
1146
 
1147
 
1148
////////////////////////////////////////////////////////////////////////
1149
// Local header file includes / local defines
1150
////////////////////////////////////////////////////////////////////////
1151
 
1152
module lsu_stb_rwctl (/*AUTOARG*/
1153
   // Outputs
1154
   so, lsu_stbctl_flush_pipe_w, stb_cam_wr_no_ivld_m,
1155
   ld_rawp_st_ced_w2, stb_data_wr_ptr, stb_data_wptr_vld,
1156
   stb_data_rd_ptr, stb_data_rptr_vld, stb_wdata_ramd_b75_b64,
1157
   stb_cam_cm_tid, stb_ldst_byte_msk, stb_ldst_byte_msk_min,
1158
   stb_cam_rw_ptr, stb_cam_wptr_vld, stb_cam_rptr_vld,
1159
   lsu_st_sz_bhww_m, lsu_st_sz_dw_m, lsu_st_sz_bhw_m,
1160
   lsu_st_sz_wdw_m, lsu_st_sz_b_m, lsu_st_sz_w_m, lsu_st_sz_hw_m,
1161
   lsu_st_sz_hww_m, ld_rawp_st_ackid_w2, stb_flush_st_g,
1162
   stb_cam_wvld_m, lsu_st_rq_type_m, lsu_stb_data_early_sel_e,
1163
   lsu_stb_data_final_sel_m, lsu_ldquad_inst_m, stb_thrd_en_g,
1164
   flsh_inst_m, lsu_stb_va_m, lsu_stb_empty_buf, lsu_spu_stb_empty,
1165
   ifu_tlu_inst_vld_m_bf1, ifu_tlu_inst_vld_m_bf2, lsu_ifu_stbcnt0,
1166
   lsu_ifu_stbcnt1, lsu_ifu_stbcnt2, lsu_ifu_stbcnt3,
1167
   lsu_ffu_stb_full0, lsu_ffu_stb_full1, lsu_ffu_stb_full2,
1168
   lsu_ffu_stb_full3,
1169
   // Inputs
1170
   rclk, rst_tri_en, si, se, ld_inst_vld_e, ldst_sz_e, st_inst_vld_e,
1171
   stb_pcx_rptr0, stb_wrptr0, stb_pcx_rptr1, stb_wrptr1,
1172
   stb_pcx_rptr2, stb_wrptr2, stb_pcx_rptr3, stb_wrptr3,
1173
   stb_cam_hit_ptr, stb_cam_hit, lsu_ldst_va_m, sta_internal_m,
1174
   ifu_tlu_thrid_e, tlu_exu_early_flush_pipe_w, lsu_ttype_vld_m2,
1175
   ifu_lsu_flush_w, lsu_defr_trp_taken_g, ifu_lsu_casa_e,
1176
   ifu_lsu_ldstub_e, ifu_lsu_swap_e, ifu_lsu_ldst_dbl_e,
1177
   stb_state_ced0, stb_state_ced1, stb_state_ced2, stb_state_ced3,
1178
   stb_ld_full_raw, stb_ld_partial_raw, stb_wrptr0_prev,
1179
   stb_wrptr1_prev, stb_wrptr2_prev, stb_wrptr3_prev,
1180
   ifu_lsu_alt_space_e, ifu_lsu_ldst_fp_e, lsu_quad_asi_e,
1181
   lsu_st_rmo_m, lsu_bst_in_pipe_m, ffu_lsu_kill_fst_w,
1182
   ffu_lsu_blk_st_e, ffu_lsu_blk_st_tid_m, ffu_lsu_blk_st_va_e,
1183
   lsu_snap_blk_st_m, tlb_pgnum_b39_g, lsu_stb_empty,
1184
   ifu_tlu_flsh_inst_e, stb_cam_mhit, ifu_tlu_inst_vld_m,
1185
   lsu_st_pcx_rq_pick, lsu_st_pcx_rq_vld, stb_rdata_ramc_b8t0,
1186
   lsu_stbcnt0, lsu_stbcnt1, lsu_stbcnt2, lsu_stbcnt3
1187
   ) ;
1188
 
1189
input     rclk ;
1190
//input     grst_l ;   
1191
//input     arst_l ;   
1192
   input  rst_tri_en;
1193
 
1194
   input  si;
1195
   input  se;
1196
   output so;
1197
 
1198
 
1199
input     ld_inst_vld_e ;   // load in pipe.
1200
input [1:0]   ldst_sz_e ;   // size of load.
1201
input     st_inst_vld_e ;   // store in pipe.
1202
// Currently bypass flop make request 
1203
//input [3:0]   pcx_rq_for_stb ;  // pcx request rd of dfq - threaded
1204
//input [2:0]   stb_dfq_rptr0 ;   // dfq rptr for stb0
1205
input [2:0]   stb_pcx_rptr0 ;   // pcx rptr for stb0
1206
input [2:0]   stb_wrptr0 ;    // wrt ptr - stb0
1207
//input [2:0]   stb_dfq_rptr1 ;   // dfq rptr for stb1
1208
input [2:0]   stb_pcx_rptr1 ;   // pcx rptr for stb1
1209
input [2:0]   stb_wrptr1 ;    // wrt ptr - stb1
1210
//input [2:0]   stb_dfq_rptr2 ;   // dfq rptr for stb2
1211
input [2:0]   stb_pcx_rptr2 ;   // pcx rptr for stb2
1212
input [2:0]   stb_wrptr2 ;    // wrt ptr - stb2
1213
//input [2:0]   stb_dfq_rptr3 ;   // dfq rptr for stb3
1214
input [2:0]   stb_pcx_rptr3 ;   // pcx rptr for stb3
1215
input [2:0]   stb_wrptr3 ;    // wrt ptr - stb3
1216
input [2:0]     stb_cam_hit_ptr ; // entry which hit
1217
input     stb_cam_hit ;   // hit has occurred
1218
//input [7:0]     stb_state_vld0 ;  // valid bits - stb0
1219
//input [7:0]     stb_state_vld1 ;  // valid bits - stb1
1220
//input [7:0]     stb_state_vld2 ;  // valid bits - stb2
1221
//input [7:0]     stb_state_vld3 ;  // valid bits - stb3
1222
input [9:0]    lsu_ldst_va_m ;
1223
input     sta_internal_m ;   // internal stxa
1224
input [1:0]   ifu_tlu_thrid_e ; // thread-id.
1225
 
1226
//   output     lsu_stbrwctl_flush_pipe_w ;  // tmp for tso_mon
1227
   input      tlu_exu_early_flush_pipe_w;
1228
   input      lsu_ttype_vld_m2;
1229
 
1230
   input      ifu_lsu_flush_w;
1231
   input      lsu_defr_trp_taken_g;
1232
   output     lsu_stbctl_flush_pipe_w;
1233
 
1234
 
1235
input                   ifu_lsu_casa_e ;        // compare-swap instr
1236
input                   ifu_lsu_ldstub_e ;      // ldstub
1237
input                   ifu_lsu_swap_e ;        // swap
1238
input     ifu_lsu_ldst_dbl_e; // ldst dbl, specifically for stquad.
1239
//input   [63:0]          lsu_stb_st_data_g ;     // data to be written to stb
1240
input [7:0]   stb_state_ced0 ;
1241
input [7:0]   stb_state_ced1 ;
1242
input [7:0]   stb_state_ced2 ;
1243
input [7:0]   stb_state_ced3 ;
1244
input [7:0]   stb_ld_full_raw ;
1245
input [7:0]   stb_ld_partial_raw ;
1246
input   [2:0]   stb_wrptr0_prev ;
1247
input   [2:0]   stb_wrptr1_prev ;
1248
input   [2:0]     stb_wrptr2_prev ;
1249
input   [2:0]   stb_wrptr3_prev ;
1250
input     ifu_lsu_alt_space_e ; // alt_space inst
1251
input     ifu_lsu_ldst_fp_e ;
1252
//input     tlb_cam_hit ;   // tlb cam hit - mstage
1253
input     lsu_quad_asi_e ;  // quad ldst asi
1254
//input  [3:0]      lsu_st_ack_rq_stb ;
1255
//input     lsu_dtlb_bypass_e ;
1256
input   lsu_st_rmo_m ;  // rmo st in m cycle.
1257
input   lsu_bst_in_pipe_m ;     // 1st helper for bst.
1258
input           ffu_lsu_kill_fst_w ;    // ecc error on st.
1259
input           ffu_lsu_blk_st_e ;      // blk st helper signalled by ffu
1260
input   [1:0]    ffu_lsu_blk_st_tid_m ;  // blk st tid - from ffu_lsu_data
1261
input   [5:3]   ffu_lsu_blk_st_va_e ;   // bits 5:3 of va from increment
1262
input           lsu_snap_blk_st_m ;             // snap blk st state
1263
input           tlb_pgnum_b39_g ;
1264
 
1265
input   [3:0]   lsu_stb_empty ;         // thread's stb is empty
1266
input           ifu_tlu_flsh_inst_e;
1267
input           stb_cam_mhit ;
1268
input           ifu_tlu_inst_vld_m ;
1269
//input   [3:0]   lsu_st_pcx_rq_kill_w2 ;
1270
 
1271
input [3:0]   lsu_st_pcx_rq_pick ;
1272
 
1273
input         lsu_st_pcx_rq_vld ;
1274
 
1275
input   [8:0]    stb_rdata_ramc_b8t0 ;   // scan-only
1276
 
1277
output          stb_cam_wr_no_ivld_m ;
1278
 
1279
//output      ld_rawp_st_ced_g ;
1280
output      ld_rawp_st_ced_w2 ;
1281
output  [4:0]   stb_data_wr_ptr ; // write ptr - stb data
1282
output      stb_data_wptr_vld ; // wr vld for stb data
1283
output  [4:0]   stb_data_rd_ptr ; // rd ptr for stb data
1284
output      stb_data_rptr_vld ; // rptr vld for stb data
1285
output  [75:64]    stb_wdata_ramd_b75_b64 ;  // write data for DATA RAM. 
1286
 
1287
// partial or full raw required
1288
output  [1:0]   stb_cam_cm_tid ;  // cam tid - stb cam
1289
//output  [7:0]   stb_cam_sqsh_msk ;  // squash spurious hits
1290
//output      stb_cam_vld ;
1291
output  [7:0]   stb_ldst_byte_msk ; // byte mask for write/cam
1292
output  [7:0]   stb_ldst_byte_msk_min ; // byte mask for write/cam for min path
1293
 
1294
//output  [3:0]   stb_rd_for_pcx_sel ;    // stb's st selected for read for pcx
1295
output  [4:0]   stb_cam_rw_ptr ;        // rw ptr for shared stb cam port
1296
output          stb_cam_wptr_vld ;      // wr vld for stb write   
1297
output          stb_cam_rptr_vld ;      // rd vld for stb write   
1298
 
1299
 
1300
//output      lsu_stb_pcx_rvld_d1 ; // stb has been read-delayby1cycle
1301
//output      lsu_stb_dfq_rvld ;  // wr to dfq stb bypass ff
1302
 
1303
output                  lsu_st_sz_bhww_m ;      // byte or hword or word
1304
output                  lsu_st_sz_dw_m ;        // double word
1305
output                  lsu_st_sz_bhw_m ;       // byte or hword
1306
output                  lsu_st_sz_wdw_m ;       // word or dword
1307
output                  lsu_st_sz_b_m ;         // byte
1308
output                  lsu_st_sz_w_m ;         // word
1309
output                  lsu_st_sz_hw_m ;        // hword
1310
output                  lsu_st_sz_hww_m ;       // hword or word
1311
 
1312
//output     ld_stb_full_raw_g ;
1313
//output     ld_stb_partial_raw_g ;
1314
//output  [3:0]   ld_stb_full_raw_g ;
1315
//output  [3:0]   ld_stb_partial_raw_g ;
1316
 
1317
output  [2:0]   ld_rawp_st_ackid_w2 ;
1318
 
1319
//output  [2:0]   stb_dfq_rd_id ;   // stb entry being read for current thread for current thread
1320
 
1321
output  [3:0]     stb_flush_st_g ;  // st is flushed in cycle g
1322
output  [3:0]     stb_cam_wvld_m ;
1323
 
1324
output  [2:1]   lsu_st_rq_type_m ;
1325
 
1326
output  [3:0]   lsu_stb_data_early_sel_e ;// select source of stb data.
1327
output      lsu_stb_data_final_sel_m ;// select source of stb data.
1328
 
1329
output      lsu_ldquad_inst_m ; // stquad inst
1330
//output      lsu_stdbl_inst_m ;  // stdbl inst
1331
 
1332
//output  [1:0]   lsu_stb_rd_tid ;  // thread for which stb read occurs
1333
 
1334
output  [3:0]    stb_thrd_en_g ; // thread id for current stb access
1335
 
1336
   output     flsh_inst_m;
1337
 
1338
   output [9:3] lsu_stb_va_m;
1339
 
1340
output  [3:0]    lsu_stb_empty_buf ;
1341
output  [3:0]    lsu_spu_stb_empty ;
1342
 
1343
   output     ifu_tlu_inst_vld_m_bf1;
1344
   output     ifu_tlu_inst_vld_m_bf2;
1345
 
1346
   input [3:0] lsu_stbcnt0;
1347
   input [3:0] lsu_stbcnt1;
1348
   input [3:0] lsu_stbcnt2;
1349
   input [3:0] lsu_stbcnt3;
1350
 
1351
   output [3:0] lsu_ifu_stbcnt0;
1352
   output [3:0] lsu_ifu_stbcnt1;
1353
   output [3:0] lsu_ifu_stbcnt2;
1354
   output [3:0] lsu_ifu_stbcnt3;
1355
 
1356
   output       lsu_ffu_stb_full0;
1357
   output       lsu_ffu_stb_full1;
1358
   output       lsu_ffu_stb_full2;
1359
   output       lsu_ffu_stb_full3;
1360
 
1361
/*AUTOWIRE*/
1362
// Beginning of automatic wires (for undeclared instantiated-module outputs)
1363
// End of automatics
1364
// Beginning of automatic wires (for undeclared instantiated-module outputs)
1365
// End of automatics
1366
//wire  [4:0] stb_dequeue_ptr ;
1367
wire  [2:0] stb_wptr_prev ;
1368
wire  [1:0] st_thrid_m,st_thrid_g ;
1369
wire  [7:0] ld_any_raw_vld ;
1370
wire  [7:0] ld_any_raw_vld_d1 ;
1371
//wire    ld_raw_mhit ;
1372
wire  [2:0] st_rq_type_m,st_rq_type_g ;
1373
 
1374
wire  [1:0] ldst_sz_m,ldst_sz_g, pipe_ldst_sz_m ;
1375
wire    ldst_byte, ldst_hwrd, ldst_word, ldst_dwrd ;
1376
wire  [7:0] ldst_byte_mask ;
1377
wire  [2:0] stb_wptr ;
1378
wire  [1:0] thrid_m,thrid_g ;
1379
wire    ld_inst_vld_m, st_inst_vld_m ;
1380
 
1381
wire    ldst_dbl_m;
1382
wire    atomic_m ;
1383
wire    ldstub_m ;
1384
wire    casa_m, casa_g ;
1385
wire    swap_m;
1386
wire    flush_st_g ;
1387
wire    cam_wptr_vld_g ;
1388
wire  [2:0] cam_wptr_d1 ;
1389
 
1390
wire  [2:0] stb_rdptr0,stb_rdptr1 ;
1391
wire  [2:0] stb_rdptr2,stb_rdptr3 ;
1392
 
1393
//wire  [3:0] stb_rd_mask ;
1394
wire  [3:0] stb_select_rptr ;
1395
wire  [1:0] stb_rd_thrid ;
1396
//wire    cam_vld_g ;
1397
wire  [9:0]  ldst_va_m, pipe_ldst_va_m ;
1398
wire  [3:0]  ldst_va_g ;
1399
wire  [2:0] cam_wr_ptr ;
1400
wire  thread0_m, thread1_m, thread2_m, thread3_m ;
1401
wire  thread0_g, thread1_g, thread2_g, thread3_g ;
1402
wire  [2:0]   ld_rawp_stb_id ;
1403
 
1404
//wire  rd_for_dfq_granted ;
1405
wire  [7:0] stb_state_ced,stb_state_ced_d1 ;
1406
//wire    stq_wr_en ;
1407
//wire  [3:0] stq_wr_en_g ;
1408
//wire  [3:0] stquad_vld ;
1409
//wire  [2:0] stquad_ptr0,stquad_ptr1,stquad_ptr2,stquad_ptr3 ;
1410
//wire  [3:0] ld_stq_hit_g ;
1411
//wire  ldq_hit_g ;
1412
//wire  [3:0] ldq_hit_g ;
1413
wire  ldst_fp_m;
1414
wire  ldstub_e,casa_e,ldst_dbl_e;
1415
//wire  stb_data_final_sel_e ;
1416
wire  alt_space_e,alt_space_m ;
1417
wire  quad_asi_m ;
1418
//wire  stquad_e, stquad_m ;
1419
wire  stdbl_e ;
1420
//wire  dfq_any_rq_for_stb ;
1421
//wire  [3:0]   stb_rd_for_dfq ;  // read rq for dfq - threaded
1422
wire    blkst_m,blkst_g ;
1423
wire    stb_not_empty ;
1424
 
1425
   wire       clk;
1426
   assign     clk = rclk;
1427
 
1428
//   wire       rst_l;
1429
//   wire       stb_rwctl_rst_l;
1430
 
1431
//   dffrl_async rstff(.din (grst_l),
1432
//                     .q   (stb_rwctl_rst_l),
1433
//                     .clk (clk), .se(se), .si(), .so(),
1434
//                     .rst_l (arst_l));
1435
 
1436
//=========================================================================================
1437
//  MISC
1438
//=========================================================================================
1439
 
1440
// Scan-only flops.
1441
 
1442
wire    [8:0]    stb_rdata_ramc_b8t0_so ;
1443
dff #(9)  scmscan_ff (
1444
        .din    (stb_rdata_ramc_b8t0[8:0]),
1445
        .q      (stb_rdata_ramc_b8t0_so[8:0]),
1446
        .clk    (clk),
1447
        .se   (se),       .si (),          .so ()
1448
        );
1449
 
1450
//=========================================================================================
1451
//  INST_VLD_W GENERATION
1452
//=========================================================================================
1453
 
1454
wire    flush_w_inst_vld_m ;
1455
wire    lsu_inst_vld_w ;
1456
wire    lsu_stbrwctl_flush_pipe_w;
1457
 
1458
//=======================================
1459
//instaniate buffers
1460
//======================================
1461
 
1462
   wire   ifu_tlu_inst_vld_m_bf0;
1463
 
1464
bw_u1_buf_10x UZfix_ifu_tlu_inst_vld_m_bf0 ( .a(ifu_tlu_inst_vld_m), .z(ifu_tlu_inst_vld_m_bf0) );
1465
bw_u1_buf_30x UZfix_ifu_tlu_inst_vld_m_bf1 ( .a(ifu_tlu_inst_vld_m_bf0), .z(ifu_tlu_inst_vld_m_bf1) );
1466
bw_u1_buf_20x UZfix_ifu_tlu_inst_vld_m_bf2 ( .a(ifu_tlu_inst_vld_m_bf0), .z(ifu_tlu_inst_vld_m_bf2) );
1467
 
1468
assign  flush_w_inst_vld_m =
1469
        ifu_tlu_inst_vld_m_bf0 &
1470
        ~(lsu_stbrwctl_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
1471
 
1472
dff  stgw_ivld (
1473
        .din    (flush_w_inst_vld_m),
1474
        .q      (lsu_inst_vld_w),
1475
        .clk    (clk),
1476
        .se   (se),       .si (),          .so ()
1477
        );
1478
 
1479
   wire other_flush_pipe_w;
1480
   wire tlu_early_flush_pipe_w;
1481
   assign tlu_early_flush_pipe_w = tlu_exu_early_flush_pipe_w;
1482
 
1483
assign  other_flush_pipe_w =
1484
tlu_early_flush_pipe_w | (lsu_ttype_vld_m2 & lsu_inst_vld_w) |
1485
lsu_defr_trp_taken_g ;
1486
 
1487
   wire lsu_flush_pipe_w;
1488
 
1489
assign  lsu_flush_pipe_w = other_flush_pipe_w | ifu_lsu_flush_w ;
1490
assign  lsu_stbctl_flush_pipe_w = lsu_flush_pipe_w ;
1491
assign  lsu_stbrwctl_flush_pipe_w = lsu_flush_pipe_w ;
1492
 
1493
//=========================================================================================
1494
//  STB Array Addr/Ctl Generation
1495
//=========================================================================================
1496
 
1497
assign  ldstub_e = ifu_lsu_ldstub_e ;
1498
assign  casa_e   = ifu_lsu_casa_e ;
1499
assign  ldst_dbl_e = ifu_lsu_ldst_dbl_e ;
1500
 
1501
assign  alt_space_e = ifu_lsu_alt_space_e ;
1502
 
1503
//assign  stdbl_e =  ldst_dbl_e & (~alt_space_e | (alt_space_e & ~lsu_quad_asi_e)) ;
1504
assign  stdbl_e =  ldst_dbl_e ;
1505
 
1506
//   wire lsu_stdbl_inst_m;
1507
 
1508
//dff  stq_stgm (
1509
//  .din  (stdbl_e), 
1510
//  .q          (lsu_stdbl_inst_m),  
1511
//  .clk  (clk), 
1512
//  .se (se), .si (), .so ()
1513
//  );
1514
 
1515
// This path can probably be eased.
1516
assign  lsu_stb_data_early_sel_e[0] = ldstub_e  & ~rst_tri_en;
1517
assign  lsu_stb_data_early_sel_e[1] = casa_e & ~rst_tri_en;
1518
assign  lsu_stb_data_early_sel_e[2] = ~(ldstub_e | casa_e |  stdbl_e) | rst_tri_en;
1519
assign  lsu_stb_data_early_sel_e[3] = stdbl_e & ~rst_tri_en ;
1520
 
1521
// modify for accepting bst data out of pipe.
1522
//assign  stb_data_final_sel_e = ~(ldst_fp_e | ffu_lsu_blk_st_e) ;
1523
 
1524
/*dff  lsel_g (
1525
  .din  (stb_data_final_sel_e),
1526
  .q  (lsu_stb_data_final_sel_m),
1527
  .clk  (clk),
1528
  .se (se), .si (), .so ()
1529
  );*/
1530
 
1531
assign  lsu_stb_data_final_sel_m = ~(ldst_fp_m | blkst_m) ;
1532
 
1533
wire    real_st_m ;
1534
wire    flsh_inst_m, flsh_inst_g ;
1535
// !!! could qualify st_inst_vld_e with stxa_internal !!!
1536
dff #(13) stgm_vld  (
1537
  .din  ({ld_inst_vld_e,st_inst_vld_e,ldst_sz_e[1:0],
1538
    ifu_lsu_swap_e, ifu_lsu_ldstub_e, ifu_lsu_casa_e,ifu_lsu_ldst_dbl_e,
1539
    ifu_tlu_thrid_e[1:0],ifu_lsu_ldst_fp_e,lsu_quad_asi_e,ifu_tlu_flsh_inst_e}),
1540
  .q  ({ld_inst_vld_m,real_st_m,pipe_ldst_sz_m[1:0],
1541
    swap_m,ldstub_m,casa_m,ldst_dbl_m,thrid_m[1:0],ldst_fp_m,quad_asi_m,flsh_inst_m}),
1542
  .clk  (clk),
1543
  .se   (se), .si (), .so ()
1544
  );
1545
 
1546
assign  st_inst_vld_m = real_st_m | flsh_inst_m ;
1547
 
1548
// do we need ld/st unflushed ?
1549
   wire sta_internal_g;
1550
 
1551
dff #(7) stgw_vld  (
1552
  .din  ({sta_internal_m,
1553
    casa_m, thrid_m[1:0],ldst_sz_m[1:0], flsh_inst_m}),
1554
  .q    ({sta_internal_g,
1555
    casa_g, thrid_g[1:0],ldst_sz_g[1:0], flsh_inst_g}),
1556
  .clk  (clk),
1557
  .se   (se), .si (), .so ()
1558
  );
1559
 
1560
 
1561
// stb-cam will be written by st at rising edge of g-stage.
1562
// However, st can be flushed after write. To keep, the stb state consistent,
1563
// The valid and write ptr will not be updated until the rising edge of w2.
1564
 
1565
wire    early_flush_cond_g,partial_flush_st_g ;
1566
assign early_flush_cond_g =
1567
(sta_internal_g | ~(lsu_inst_vld_w | blkst_g) | ffu_lsu_kill_fst_w) ;
1568
assign  flush_st_g = (early_flush_cond_g | lsu_stbrwctl_flush_pipe_w) & cam_wptr_vld_g ;
1569
 
1570
//timing, send to stb_ctl and qualified by stb_cam_wvld_g (thread version of cam_wptr_vld_g)   
1571
//assign        partial_flush_st_g = early_flush_cond_g & cam_wptr_vld_g ;
1572
assign  partial_flush_st_g = early_flush_cond_g ;
1573
 
1574
assign  atomic_m = (casa_m | ldstub_m | swap_m) & st_inst_vld_m ;
1575
 
1576
// WRITE PTR VALID GENERATION.
1577
 
1578
// meant specifically to squash pcx_rq_for_stb.
1579
assign  stb_cam_wr_no_ivld_m
1580
  = (st_inst_vld_m | casa_m | ldstub_m | swap_m | blkst_m) ;
1581
 
1582
//bug3610 - kill cam write vld(==stb data write vld next cycle) to avoid datat read and write same cycle
1583
//          to the same entry
1584
wire  b2b_st_detect ;
1585
 
1586
assign  stb_cam_wptr_vld
1587
  = (((st_inst_vld_m | atomic_m) & ifu_tlu_inst_vld_m_bf0) | blkst_m) & ~(flush_st_g & b2b_st_detect) ;
1588
  //= ((st_inst_vld_m | atomic_m) & ifu_tlu_inst_vld_m_bf0) | blkst_m ;  // bug3610
1589
  //= (st_inst_vld_m | atomic_m | (ldst_dbl_m & st_inst_vld_m) | blkst_m) ;
1590
 
1591
dff  wptr_g (
1592
  .din  (stb_cam_wptr_vld), .q  (cam_wptr_vld_g),
1593
  .clk  (clk),
1594
  .se   (se), .si (), .so ()
1595
  );
1596
 
1597
//flop move into mem cell (roll back)  
1598
assign  stb_data_wptr_vld = cam_wptr_vld_g ;
1599
 
1600
// WRITE PTR GENERATION
1601
 
1602
// It is assumed that if there is a store in the pipe, there is a 
1603
// free entry in the corresponding stb. Otherwise, the pipe would've
1604
// stalled for the thread.      
1605
 
1606
// If a store-like inst has been flushed, then the old ptr has to be restored
1607
// and used.  This is done within thread specific stb control
1608
 
1609
assign  thread0_m = ~st_thrid_m[1] & ~st_thrid_m[0] ;
1610
assign  thread1_m = ~st_thrid_m[1] &  st_thrid_m[0] ;
1611
assign  thread2_m =  st_thrid_m[1] & ~st_thrid_m[0] ;
1612
assign  thread3_m =  st_thrid_m[1] &  st_thrid_m[0] ;
1613
 
1614
dff #(4) stgg_thrd (
1615
  .din  ({thread0_m,thread1_m,thread2_m,thread3_m}),
1616
  .q  ({thread0_g,thread1_g,thread2_g,thread3_g}),
1617
  .clk  (clk),
1618
  .se (se), .si (), .so ()
1619
  );
1620
 
1621
assign  stb_thrd_en_g[0] = thread0_g ;
1622
assign  stb_thrd_en_g[1] = thread1_g ;
1623
assign  stb_thrd_en_g[2] = thread2_g ;
1624
assign  stb_thrd_en_g[3] = thread3_g ;
1625
 
1626
//assign  stb_wptr[2:0] = 
1627
//  thread0_m ? stb_wrptr0[2:0] :
1628
//    thread1_m ? stb_wrptr1[2:0] :
1629
//      thread2_m ? stb_wrptr2[2:0] :
1630
//        thread3_m ? stb_wrptr3[2:0] : 3'bxxx ;
1631
 
1632
assign  stb_wptr[2:0] =
1633
  (thread0_m ? stb_wrptr0[2:0] :  3'b000) |
1634
  (thread1_m ? stb_wrptr1[2:0] :  3'b000) |
1635
  (thread2_m ? stb_wrptr2[2:0] :  3'b000) |
1636
  (thread3_m ? stb_wrptr3[2:0] :  3'b000) ;
1637
 
1638
assign  b2b_st_detect =   // detect back-to-back store
1639
  (thread0_m & thread0_g) |
1640
  (thread1_m & thread1_g) |
1641
  (thread2_m & thread2_g) |
1642
  (thread3_m & thread3_g) ;
1643
 
1644
assign  cam_wr_ptr[2:0] = (flush_st_g & b2b_st_detect) ? cam_wptr_d1[2:0] : stb_wptr[2:0] ;
1645
 
1646
dff #(3)  wptr_d1 (
1647
  .din  (cam_wr_ptr[2:0]),  .q  (cam_wptr_d1[2:0]),
1648
  .clk  (clk),
1649
  .se (se), .si (), .so ()
1650
  );
1651
 
1652
assign  stb_cam_wvld_m[0] = stb_cam_wptr_vld & thread0_m ;
1653
assign  stb_cam_wvld_m[1] = stb_cam_wptr_vld & thread1_m ;
1654
assign  stb_cam_wvld_m[2] = stb_cam_wptr_vld & thread2_m ;
1655
assign  stb_cam_wvld_m[3] = stb_cam_wptr_vld & thread3_m ;
1656
 
1657
// contains potential flush conditions.
1658
assign  stb_flush_st_g[0] = partial_flush_st_g ;
1659
assign  stb_flush_st_g[1] = partial_flush_st_g ;
1660
assign  stb_flush_st_g[2] = partial_flush_st_g ;
1661
assign  stb_flush_st_g[3] = partial_flush_st_g ;
1662
 
1663
// stb-data has a delayed write in w2. Alignment of stb data will be done on write
1664
// of 64b into stb. This allows write of stb cam and data to be done in the
1665
// same cycle, and thus read can occur simultaneously for pcx. 
1666
 
1667
//mem cell change to bw_r_rf32x80, flop move into mem cell (roll back)
1668
//flop outside mem cell
1669
assign  stb_data_wr_ptr[4:0] =  {st_thrid_g[1:0],cam_wptr_d1[2:0]};
1670
 
1671
// RD PTR/VLD GENERATION
1672
 
1673
// stb read for dfq dumps data into a bypass flop. Thus a read for the dfq can occur
1674
// if a thread's stb has an acked entry and the bypass flop is empty.
1675
// stb read for pcx occurs on availability of queue entry. 
1676
 
1677
// Both dfq and pcx require a read of the cam and data. The reads
1678
// can thus not happen when load that hits in the stb is in the w2 (change to W3)
1679
// stage and a store is in the g-stage of the pipe. Both
1680
// probabilities are low.
1681
 
1682
// ??Read for pcx takes priority over dfq. No deadlock can occur
1683
// ??as at some point the pcx reads will be exhausted and the stb
1684
// ??will have to drain itself. The stb is self-regulating in this regard.
1685
 
1686
// priority of stb read: ld_cam_hit (full raw bypass) > dfq > pcx 
1687
 
1688
//====================================================================================
1689
//raw bypass timing 
1690
//G/WB                          W2     W3                      W4
1691
//cam_hit(from stb_cam output)  flop   stb_data rd_ptr/rd_vld  read STB_DATA/BYP
1692
//====================================================================================
1693
 
1694
   wire [1:0] thrid_w2;
1695
   wire [2:0] stb_cam_hit_ptr_w2;
1696
   wire       stb_cam_hit_w2;
1697
   wire       stb_cam_hit_w;
1698
 
1699
   //bug3503
1700
   assign stb_cam_hit_w  =  stb_cam_hit & lsu_inst_vld_w & ~lsu_stbrwctl_flush_pipe_w;
1701
 
1702
dff #(6) stb_cam_hit_stg_w2 (
1703
  .din  ({thrid_g[1:0],  stb_cam_hit_ptr[2:0],    stb_cam_hit_w   }),
1704
  .q    ({thrid_w2[1:0], stb_cam_hit_ptr_w2[2:0], stb_cam_hit_w2}),
1705
  .clk  (clk),
1706
  .se   (se), .si (), .so ()
1707
  );
1708
 
1709
// logic moved to qctl1
1710
// pcx is making request for data in current cycle. Can be multi-hot.
1711
//assign  pcx_any_rq_for_stb = |pcx_rq_for_stb[3:0] ;
1712
//assign  pcx_any_rq_for_stb = 
1713
//      (pcx_rq_for_stb[0] & ~lsu_st_pcx_rq_kill_w2[0]) | 
1714
//      (pcx_rq_for_stb[1] & ~lsu_st_pcx_rq_kill_w2[1]) | 
1715
//      (pcx_rq_for_stb[2] & ~lsu_st_pcx_rq_kill_w2[2]) | 
1716
//      (pcx_rq_for_stb[3] & ~lsu_st_pcx_rq_kill_w2[3]) ; 
1717
 
1718
// ??ld-cam hit based read takes precedence
1719
// ??Timing : This could be made pessimistic by using ld_inst_vld_g
1720
 
1721
//assign  stb_select_rptr[3:0] =  pcx_rq_for_stb[3:0] ;  // timing fix
1722
assign  stb_select_rptr[3:0] =  lsu_st_pcx_rq_pick[3:0] ;
1723
 
1724
// This could be a critical path. Be careful !
1725
//assign  stb_rdptr0[2:0] = ~dfq_any_rq_for_stb ? stb_pcx_rptr0[2:0] : stb_dfq_rptr0[2:0] ; 
1726
assign  stb_rdptr0[2:0] = stb_pcx_rptr0[2:0] ;
1727
assign  stb_rdptr1[2:0] = stb_pcx_rptr1[2:0] ;
1728
assign  stb_rdptr2[2:0] = stb_pcx_rptr2[2:0] ;
1729
assign  stb_rdptr3[2:0] = stb_pcx_rptr3[2:0] ;
1730
 
1731
// logic moved to qctl1
1732
//wire  [1:0] stb_rd_tid ;
1733
//
1734
//assign  stb_rd_tid[0] = pcx_rq_for_stb[1] | pcx_rq_for_stb[3] ;
1735
//assign  stb_rd_tid[1] = pcx_rq_for_stb[2] | pcx_rq_for_stb[3] ;
1736
//   
1737
//dff #(2) stbtid_stgd1 (
1738
//  .din    (stb_rd_tid[1:0]),  .q  (lsu_stb_rd_tid[1:0]),
1739
//  .clk    (clk), 
1740
//  .se   (se), .si (), .so ()
1741
//  );
1742
 
1743
//assign  stb_dfq_rd_id[2:0] = stb_data_rd_ptr[2:0] ; // or cam rd ptr
1744
 
1745
//timing fix:5/6/03
1746
//bug4988 - change the prirority from 0->3 to 3->0; the reason is when select_rptr=0, the
1747
//          default thread id(rptr[4:3])=thread0 but the default rptr[2:0]=thread3. If
1748
//          thread0 and thread3 rptr are the same and the thread0 write is occuring, the
1749
//          rptr[4:0] is same as wptr[4:0]
1750
wire  [2:0]  stb_rdptr ;
1751
//assign  stb_rdptr[2:0] = 
1752
//  stb_select_rptr[0] ? stb_rdptr0[2:0] :
1753
//    stb_select_rptr[1] ? stb_rdptr1[2:0] :
1754
//      stb_select_rptr[2] ? stb_rdptr2[2:0] :
1755
//                             stb_rdptr3[2:0] ;
1756
 
1757
//assign  stb_rdptr[2:0] = 
1758
//  stb_select_rptr[3] ? stb_rdptr3[2:0] :
1759
//    stb_select_rptr[2] ? stb_rdptr2[2:0] :
1760
//      stb_select_rptr[1] ? stb_rdptr1[2:0] :
1761
//                             stb_rdptr0[2:0] ;
1762
 
1763
assign  stb_rdptr[2:0] =
1764
  (stb_select_rptr[3] ? stb_rdptr3[2:0] : 3'b0) |
1765
  (stb_select_rptr[2] ? stb_rdptr2[2:0] : 3'b0) |
1766
  (stb_select_rptr[1] ? stb_rdptr1[2:0] : 3'b0) |
1767
  (stb_select_rptr[0] ? stb_rdptr0[2:0] : 3'b0) ;
1768
 
1769
//timing fix: 8/29/03 - remove the default select logic for stb_select_rptr since synthesis is forced to replace 
1770
//            4to1 mux w/ and-or mux or 2to1 mux
1771
//wire   stb_select_rptr_b3;
1772
//assign stb_select_rptr_b3 =  ~|stb_select_rptr[2:0];
1773
 
1774
wire  [2:0]  stb_rdptr_l;
1775
 
1776
assign stb_rdptr_l[2:0] =  ~stb_rdptr[2:0] ;
1777
//bw_u1_muxi41d_2x  UZsize_stb_rdptr_b0_mux(
1778
//                  .z(stb_rdptr_l[0]), 
1779
//                  .d0(stb_rdptr0[0]), 
1780
//                  .d1(stb_rdptr1[0]), 
1781
//                  .d2(stb_rdptr2[0]), 
1782
//                  .d3(stb_rdptr3[0]), 
1783
//                  .s0(stb_select_rptr[0]), 
1784
//                  .s1(stb_select_rptr[1]), 
1785
//                  .s2(stb_select_rptr[2]), 
1786
//                  .s3(stb_select_rptr[3]));
1787
//   
1788
//bw_u1_muxi41d_2x  UZsize_stb_rdptr_b1_mux(
1789
//                  .z(stb_rdptr_l[1]), 
1790
//                  .d0(stb_rdptr0[1]), 
1791
//                  .d1(stb_rdptr1[1]), 
1792
//                  .d2(stb_rdptr2[1]), 
1793
//                  .d3(stb_rdptr3[1]), 
1794
//                  .s0(stb_select_rptr[0]), 
1795
//                  .s1(stb_select_rptr[1]), 
1796
//                  .s2(stb_select_rptr[2]), 
1797
//                  .s3(stb_select_rptr[3]));
1798
//   
1799
//bw_u1_muxi41d_2x  UZsize_stb_rdptr_b2_mux(
1800
//                  .z(stb_rdptr_l[2]), 
1801
//                  .d0(stb_rdptr0[2]), 
1802
//                  .d1(stb_rdptr1[2]), 
1803
//                  .d2(stb_rdptr2[2]), 
1804
//                  .d3(stb_rdptr3[2]), 
1805
//                  .s0(stb_select_rptr[0]), 
1806
//                  .s1(stb_select_rptr[1]), 
1807
//                  .s2(stb_select_rptr[2]), 
1808
//                  .s3(stb_select_rptr[3]));
1809
//   
1810
 
1811
assign  stb_rd_thrid[0] = stb_select_rptr[1] | stb_select_rptr[3] ;
1812
assign  stb_rd_thrid[1] = stb_select_rptr[2] | stb_select_rptr[3] ;
1813
 
1814
// read
1815
// this mux will have to be accommodated in path !!! Talk to Satya. 
1816
// Timing : This could be made pessimistic by using ld_inst_vld_g
1817
 
1818
// raw read STB at W3 (changed from W2)        
1819
assign  stb_data_rd_ptr[4:0] = stb_cam_hit_w2 ?
1820
        {thrid_w2[1:0],stb_cam_hit_ptr_w2[2:0]} :  // rd based on ld hit
1821
        {stb_rd_thrid[1:0],~stb_rdptr_l[2:0]} ;       // rd for pcx or dfq
1822
 
1823
// Blk-st modification for thread.
1824
assign  st_thrid_m[1:0] = blkst_m ? ffu_lsu_blk_st_tid_m[1:0] : thrid_m[1:0] ;
1825
dff #(2)  stid_stgg (
1826
  .din  (st_thrid_m[1:0]),
1827
  .q    (st_thrid_g[1:0]),
1828
  .clk  (clk),
1829
  .se (se), .si (), .so ()
1830
  );
1831
 
1832
//timing fix: 5/6/03
1833
//assign  stb_cam_rw_ptr[4:0]  = stb_cam_wptr_vld ? 
1834
//        {st_thrid_m[1:0],cam_wr_ptr[2:0]} :  // write
1835
//        {stb_rd_thrid[1:0],stb_rdptr[2:0]} ;  // read
1836
 
1837
wire [2:0] cam_wr_ptr_l;
1838
wire [1:0] stb_rd_thrid_l;
1839
wire [1:0] st_thrid_m_l;
1840
 
1841
assign cam_wr_ptr_l[2:0]  =  ~cam_wr_ptr[2:0];
1842
assign stb_rd_thrid_l[1:0]  =  ~stb_rd_thrid[1:0];
1843
assign st_thrid_m_l[1:0]  =  ~st_thrid_m[1:0];
1844
 
1845
bw_u1_muxi21_2x  UZsize_stb_cam_rw_ptr_b0_mux(
1846
                  .z(stb_cam_rw_ptr[0]),
1847
                  .d0(stb_rdptr_l[0]),
1848
                  .d1(cam_wr_ptr_l[0]),
1849
                  .s(stb_cam_wptr_vld));
1850
 
1851
bw_u1_muxi21_2x  UZsize_stb_cam_rw_ptr_b1_mux(
1852
                  .z(stb_cam_rw_ptr[1]),
1853
                  .d0(stb_rdptr_l[1]),
1854
                  .d1(cam_wr_ptr_l[1]),
1855
                  .s(stb_cam_wptr_vld));
1856
 
1857
bw_u1_muxi21_2x  UZsize_stb_cam_rw_ptr_b2_mux(
1858
                  .z(stb_cam_rw_ptr[2]),
1859
                  .d0(stb_rdptr_l[2]),
1860
                  .d1(cam_wr_ptr_l[2]),
1861
                  .s(stb_cam_wptr_vld));
1862
 
1863
bw_u1_muxi21_2x  UZsize_stb_cam_rw_ptr_b3_mux(
1864
                  .z(stb_cam_rw_ptr[3]),
1865
                  .d0(stb_rd_thrid_l[0]),
1866
                  .d1(st_thrid_m_l[0]),
1867
                  .s(stb_cam_wptr_vld));
1868
 
1869
bw_u1_muxi21_2x  UZsize_stb_cam_rw_ptr_b4_mux(
1870
                  .z(stb_cam_rw_ptr[4]),
1871
                  .d0(stb_rd_thrid_l[1]),
1872
                  .d1(st_thrid_m_l[1]),
1873
                  .s(stb_cam_wptr_vld));
1874
 
1875
 
1876
 
1877
//raw read STB at W3 (not W2)
1878
//timing fix: 9/2/03 - reduce fanout in stb_rwctl for lsu_st_pcx_rq_pick - gen separate signal for
1879
//                     stb_cam_rptr_vld and stb_data_rptr_vld
1880
 
1881
//bug4988 - qual lsu_st_pcx_rq_vld w/ no write vld to stb_data. use stb_cam_wr_no_ivld_m instead of write vld.
1882
//          this is the same signal used to kill pcx_rq_for_stb
1883
//          stb_cam_rptr_vld is not set if stb_cam_wptr_vld=1
1884
 
1885
assign  stb_data_rptr_vld =
1886
  //(|stb_select_rptr[3:0]) |  // pcx/dfq rd - timing fix
1887
  //lsu_st_pcx_rq_vld |  // pcx/dfq rd  // bug4988
1888
   (lsu_st_pcx_rq_vld & ~stb_cam_wr_no_ivld_m) |  // pcx/dfq rd
1889
    stb_cam_hit_w2 ;         // cam hit requires read whether single or multiple
1890
 
1891
//raw read STB at W3 (not W2)      
1892
//timing fix: 9/2/03 - reduce fanout in stb_rwctl for lsu_st_pcx_rq_pick - gen separate signal for
1893
//                     stb_cam_rptr_vld and stb_data_rptr_vld
1894
assign  stb_cam_rptr_vld =
1895
  //((|stb_select_rptr[3:0]) & ~(stb_cam_hit_w2)) & // only pcx read  - timing fix
1896
  (lsu_st_pcx_rq_vld & ~(stb_cam_hit_w2)) & // only pcx read 
1897
      ~stb_cam_wptr_vld ;   // st,st-like write does not block
1898
 
1899
// lsu_stb_rd_vld_d1 - not used
1900
//dff  stbrd_stgd1  (
1901
//  .din    (stb_cam_rptr_vld), .q  (lsu_stb_rd_vld_d1),
1902
//  .clk    (clk), 
1903
//  .se   (se), .si (), .so ()
1904
//  );
1905
 
1906
// logic moved to qctl1
1907
//dff #(1)  prvld_stgd1 (
1908
//  .din  (pcx_any_rq_for_stb), 
1909
//  .q  (lsu_stb_pcx_rvld_d1),
1910
//  .clk  (clk), 
1911
//  .se (se), .si (), .so ()
1912
//  );
1913
 
1914
assign  stb_cam_cm_tid[1:0] = thrid_m[1:0] ;
1915
 
1916
 
1917
//=========================================================================================
1918
//  BYTE MASK FORMATTING
1919
//=========================================================================================
1920
 
1921
 
1922
// Write/CAM Data for CAM RAM.
1923
// Physical dword aligned addr - PA[39:3] (37b)
1924
// Byte Mask - (8b)
1925
// Total - 45b
1926
 
1927
//  | b7  |  b6 | b5  | b4  | b3  | b2  | b1  | b0  |
1928
//  |   hw3 |   hw2 |   hw1 |   hw0 |
1929
//  |     w1    |   w0    |
1930
//  |       dw        | 
1931
 
1932
 
1933
 
1934
//dff  #(11) va_m (
1935
//  .din    (exu_lsu_ldst_va_e[10:0]),  .q  (pipe_ldst_va_m[10:0]),
1936
//  .clk    (clk), 
1937
//  .se   (se), .si (), .so ()
1938
//  );
1939
 
1940
assign pipe_ldst_va_m[9:0] = lsu_ldst_va_m[9:0];
1941
 
1942
// ldst_byte may not be needed
1943
assign ldst_byte = ~ldst_sz_m[1] & ~ldst_sz_m[0] ;  // 00
1944
assign ldst_hwrd = ~ldst_sz_m[1] &  ldst_sz_m[0] ;  // 01
1945
assign ldst_word =  ldst_sz_m[1] & ~ldst_sz_m[0] ;  // 10
1946
assign ldst_dwrd =  ldst_sz_m[1] &  ldst_sz_m[0] ;  // 11
1947
 
1948
// Note : dword term is common. 
1949
assign ldst_byte_mask[0]  =
1950
  ( ldst_va_m[2] &  ldst_va_m[1] &  ldst_va_m[0] )       |
1951
  ( ldst_va_m[2] &  ldst_va_m[1] & ~ldst_va_m[0] & (ldst_hwrd)) |
1952
  ( ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_word))  |
1953
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd))  ;
1954
assign ldst_byte_mask[1]  =
1955
  ( ldst_va_m[2] &  ldst_va_m[1] & ~ldst_va_m[0])        |
1956
  ( ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_word))  |
1957
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd))  ;
1958
assign ldst_byte_mask[2]  =
1959
  ( ldst_va_m[2] & ~ldst_va_m[1] &  ldst_va_m[0])         |
1960
  ( ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_hwrd | ldst_word))  |
1961
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd))  ;
1962
assign ldst_byte_mask[3]  =
1963
  ( ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0])       |
1964
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd))  ;
1965
assign ldst_byte_mask[4]  =
1966
  (~ldst_va_m[2] &  ldst_va_m[1] &  ldst_va_m[0])        |
1967
  (~ldst_va_m[2] &  ldst_va_m[1] & ~ldst_va_m[0] & (ldst_hwrd)) |
1968
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd | ldst_word)) ;
1969
assign ldst_byte_mask[5]  =
1970
  (~ldst_va_m[2] &  ldst_va_m[1] & ~ldst_va_m[0])         |
1971
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] &  (ldst_dwrd | ldst_word))  ;
1972
assign ldst_byte_mask[6]  =
1973
  (~ldst_va_m[2] & ~ldst_va_m[1] &  ldst_va_m[0])     |
1974
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] & (ldst_dwrd | ldst_word | ldst_hwrd)) ;
1975
assign ldst_byte_mask[7]  =
1976
  (~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0])   ;
1977
 
1978
assign  stb_ldst_byte_msk[7:0]  = ldst_byte_mask[7:0];
1979
 
1980
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b0 (.a(ldst_byte_mask[0]), .z(stb_ldst_byte_msk_min[0]));
1981
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b1 (.a(ldst_byte_mask[1]), .z(stb_ldst_byte_msk_min[1]));
1982
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b2 (.a(ldst_byte_mask[2]), .z(stb_ldst_byte_msk_min[2]));
1983
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b3 (.a(ldst_byte_mask[3]), .z(stb_ldst_byte_msk_min[3]));
1984
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b4 (.a(ldst_byte_mask[4]), .z(stb_ldst_byte_msk_min[4]));
1985
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b5 (.a(ldst_byte_mask[5]), .z(stb_ldst_byte_msk_min[5]));
1986
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b6 (.a(ldst_byte_mask[6]), .z(stb_ldst_byte_msk_min[6]));
1987
   bw_u1_minbuf_5x UZfix_stb_ldst_byte_msk_min_b7 (.a(ldst_byte_mask[7]), .z(stb_ldst_byte_msk_min[7]));
1988
 
1989
 
1990
// Generate selects to format st data
1991
assign  lsu_st_sz_bhww_m = ldst_byte | ldst_hwrd | ldst_word ;      // byte or hword or word
1992
assign  lsu_st_sz_dw_m   = ldst_dwrd ;            // double word
1993
assign  lsu_st_sz_bhw_m  = ldst_byte | ldst_hwrd ;      // byte or hword
1994
assign  lsu_st_sz_wdw_m  = ldst_word | ldst_dwrd ;      // word or dword
1995
assign  lsu_st_sz_b_m    = ldst_byte ;            // byte
1996
assign  lsu_st_sz_w_m    = ldst_word ;            // word
1997
assign  lsu_st_sz_hw_m   = ldst_hwrd ;            // hword
1998
assign  lsu_st_sz_hww_m  = ldst_hwrd | ldst_word ;      // hword or word
1999
 
2000
//=========================================================================================
2001
//  BLK-ST HANDLING
2002
//=========================================================================================
2003
 
2004
wire    blkst_m_tmp ;
2005
dff  stgm_bst (
2006
  .din (ffu_lsu_blk_st_e),
2007
  .q   (blkst_m_tmp),
2008
  .clk (clk),
2009
  .se   (se),       .si (),          .so ()
2010
);
2011
 
2012
assign  blkst_m = blkst_m_tmp & ~(real_st_m  | flsh_inst_m |
2013
                ld_inst_vld_m) ; // Bug 3444
2014
 
2015
dff  stgg_bst (
2016
  .din (blkst_m),
2017
  .q   (blkst_g),
2018
  .clk (clk),
2019
  .se   (se),       .si (),          .so ()
2020
);
2021
 
2022
wire    snap_blk_st_local_m ;
2023
assign  snap_blk_st_local_m = lsu_snap_blk_st_m & ifu_tlu_inst_vld_m_bf0 ;
2024
 
2025
wire    [1:0]    bst_sz_m ;
2026
wire    [9:0]    bst_va_m ;
2027
// output to be used in m-stage.
2028
dffe #(9) bst_state_m (
2029
        .din    ({ldst_sz_m[1:0],ldst_va_m[9:6],ldst_va_m[2:0]}),
2030
        .q      ({bst_sz_m[1:0],bst_va_m[9:6],bst_va_m[2:0]}),
2031
        .en     (snap_blk_st_local_m),
2032
        .clk    (clk),
2033
        .se   (se),       .si (),          .so ()
2034
        );
2035
 
2036
dff #(3)  bsva_stgm (
2037
  .din    (ffu_lsu_blk_st_va_e[5:3]), .q (bst_va_m[5:3]),
2038
  .clk    (clk),
2039
  .se   (se), .si (), .so ()
2040
  );
2041
 
2042
//assign        bst_va_m[5:3]   = ffu_lsu_blk_st_va_e[5:3] ;
2043
 
2044
//assign  ldst_va_m[10] =  pipe_ldst_va_m[10] ;
2045
assign  ldst_va_m[9:0] = blkst_m ?  bst_va_m[9:0] : pipe_ldst_va_m[9:0] ;
2046
 
2047
assign  lsu_stb_va_m[9:3] = ldst_va_m[9:3] ;
2048
 
2049
assign  ldst_sz_m[1:0]   =  blkst_m ? bst_sz_m[1:0] : pipe_ldst_sz_m[1:0] ;
2050
 
2051
//=========================================================================================
2052
//  WRITE DATA FOR DATA RAM
2053
//=========================================================================================
2054
 
2055
// Write Data for DATA RAM.
2056
// Data - (64b)
2057
// (8b parity is generated on read)
2058
// Rqtype - (3b)
2059
// Size - (3b). 
2060
// Addr - (3b). Lower 3b of 40b addr.
2061
// (set index and way available from ctl state.
2062
// Total - 73b.
2063
 
2064
// st-quad requires own encoding.
2065
// assume does not have to be changed for blk-st
2066
assign  st_rq_type_m[2:0] =
2067
                casa_m ? 3'b010 :                       // cas pkt 1
2068
                        (ldstub_m | swap_m) ? 3'b110 :  // ldstub/swap
2069
                          //(stquad_m)  ? 3'b111 :  // stquad-pkt1
2070
                                  3'b001 ;        // normal store or partial interrupt rq type
2071
 
2072
//assign  lsu_st_rq_type_m[2:0] = st_rq_type_m[2:0] ;
2073
assign  lsu_st_rq_type_m[2:1] = st_rq_type_m[2:1] ;
2074
 
2075
// Need ASI decode
2076
/*wire  lsu_stquad_inst_m ;
2077
assign  lsu_stquad_inst_m = ldst_dbl_m & st_inst_vld_m & quad_asi_m ;
2078
*/
2079
 
2080
wire    st_rmo_m,st_rmo_g ;
2081
assign  st_rmo_m = lsu_st_rmo_m | blkst_m ; // binit and blk rmo stores.
2082
dff #(9)  stgg_etc  (
2083
  .din    ({ldst_va_m[3:0],st_rq_type_m[2:0],st_rmo_m,lsu_bst_in_pipe_m}),
2084
  .q      ({ldst_va_g[3:0],st_rq_type_g[2:0],st_rmo_g,bst_in_pipe_g}),
2085
  .clk    (clk),
2086
  .se   (se), .si (), .so ()
2087
  );
2088
 
2089
wire    bst_any_helper ;
2090
assign  bst_any_helper = blkst_g | bst_in_pipe_g ; // Bug 3934
2091
 
2092
// Size will have to be changed to 2bits.
2093
// 7 more bits could be added to data ram to save read of cam in providing dfq pkt !!! 
2094
assign stb_wdata_ramd_b75_b64[75:64]   =
2095
  {st_rmo_g,st_rq_type_g[2:0],flsh_inst_g,bst_any_helper,ldst_sz_g[1:0],ldst_va_g[3:0]};
2096
        // Bug3395, 3934
2097
 
2098
//=========================================================================================
2099
//  FULL/PARTIAL RAW CALCULATION
2100
//=========================================================================================
2101
 
2102
// io load cannot bypass from stb. A stb hit results in an io-ld being treated
2103
// as a partial-raw. (OR should it be serialized behind any io store ??)
2104
wire    io_ld,io_ld_w2 ;
2105
assign  io_ld = tlb_pgnum_b39_g ; // Bug 4362
2106
 
2107
// full-raw is squashed on multiple hits in stb. Treated like partial raw.
2108
// Ensure that all ld and ld-like instructions signal ld_inst_vld. We can then
2109
// remove qualification with ld_inst_vld_g.
2110
/*assign  ld_stb_full_raw_g =
2111
        (|stb_ld_full_raw[7:0]) & ~(stb_cam_mhit | ldq_hit_g | io_ld) ;
2112
assign  ld_stb_full_raw_g[0] = (|stb_ld_full_raw[7:0]) & ld_inst_vld_g &
2113
          ~(stb_cam_mhit | ldq_hit_g[0] | io_ld) & thread0_g ;
2114
          //~(ld_raw_mhit | ld_stq_hit_g[0] | io_ld) & thread0_g ;
2115
assign  ld_stb_full_raw_g[1] = (|stb_ld_full_raw[7:0]) & ld_inst_vld_g &
2116
          ~(stb_cam_mhit | ldq_hit_g[1] | io_ld) & thread1_g ;
2117
assign  ld_stb_full_raw_g[2] = (|stb_ld_full_raw[7:0]) & ld_inst_vld_g &
2118
          ~(stb_cam_mhit | ldq_hit_g[2] | io_ld) & thread2_g ;
2119
assign  ld_stb_full_raw_g[3] = (|stb_ld_full_raw[7:0]) & ld_inst_vld_g &
2120
          ~(stb_cam_mhit | ldq_hit_g[3] | io_ld) & thread3_g ; */
2121
// Multiple full raws are also treated like a partial.
2122
/*assign  ld_stb_partial_raw_g =
2123
        ((|stb_ld_partial_raw[7:0]) | stb_cam_mhit | ldq_hit_g | (io_ld & stb_not_empty)) ;
2124
assign  ld_stb_partial_raw_g[0] =
2125
        ((|stb_ld_partial_raw[7:0]) | stb_cam_mhit | ldq_hit_g[0] | (io_ld & stb_not_empty))
2126
          & ld_inst_vld_g & thread0_g ;
2127
assign  ld_stb_partial_raw_g[1] =
2128
        ((|stb_ld_partial_raw[7:0]) | stb_cam_mhit | ldq_hit_g[1] | (io_ld & stb_not_empty))
2129
          & ld_inst_vld_g & thread1_g ;
2130
assign  ld_stb_partial_raw_g[2] =
2131
        ((|stb_ld_partial_raw[7:0]) | stb_cam_mhit | ldq_hit_g[2] | (io_ld & stb_not_empty))
2132
          & ld_inst_vld_g & thread2_g ;
2133
assign  ld_stb_partial_raw_g[3] =
2134
        ((|stb_ld_partial_raw[7:0]) | stb_cam_mhit | ldq_hit_g[3] | (io_ld & stb_not_empty))
2135
          & ld_inst_vld_g & thread3_g; */
2136
 
2137
//=========================================================================================
2138
//  STQ HANDLING
2139
//=========================================================================================
2140
 
2141
/*      REMOVE STQUAD */
2142
 
2143
//=========================================================================================
2144
//      LD QUAD HANDLING
2145
//=========================================================================================
2146
 
2147
dff  altsp_stgm (
2148
  .din    (alt_space_e), .q (alt_space_m),
2149
  .clk    (clk),
2150
  .se   (se), .si (), .so ()
2151
  );
2152
 
2153
assign  lsu_ldquad_inst_m = ldst_dbl_m & ld_inst_vld_m & quad_asi_m & alt_space_m ;
2154
 
2155
/*wire  ldquad_inst_g ;
2156
dff  ldq_stgg (
2157
  .din    (lsu_ldquad_inst_m), .q (ldquad_inst_g),
2158
  .clk    (clk),
2159
  .se   (se), .si (), .so ()
2160
  );
2161
 
2162
wire    ldq_stb_cam_hit ;
2163
assign  ldq_stb_cam_hit = stb_cam_hit & ldquad_inst_g ;
2164
// Terms can be made common.
2165
assign  ldq_hit_g = ldq_stb_cam_hit ; */
2166
/*assign  ldq_hit_g[0] = thread0_g & ldq_stb_cam_hit ;
2167
assign  ldq_hit_g[1] = thread1_g & ldq_stb_cam_hit ;
2168
assign  ldq_hit_g[2] = thread2_g & ldq_stb_cam_hit ;
2169
assign  ldq_hit_g[3] = thread3_g & ldq_stb_cam_hit ; */
2170
 
2171
//=========================================================================================
2172
//  STB MULTIPLE HIT GENERATION
2173
//=========================================================================================
2174
 
2175
// Multiple hits in stb is to be treated as a partial raw case. The ld however must wait
2176
// until the youngest store which hit exits the stb. A ptr needs to be calculated for this case.
2177
// A version of stb_wptr is used instead because it is easily available. (Would this have
2178
// any significant performance impact ? - No)
2179
 
2180
assign  ld_any_raw_vld[7:0] = stb_ld_full_raw[7:0] | stb_ld_partial_raw[7:0] ;
2181
 
2182
dff #(16)  stgw2_rvld (
2183
        .din    ({ld_any_raw_vld[7:0],stb_state_ced[7:0]}),
2184
        .q      ({ld_any_raw_vld_d1[7:0],stb_state_ced_d1[7:0]}),
2185
        .clk    (clk),
2186
        .se     (se),       .si (),          .so ()
2187
        );
2188
 
2189
 
2190
// This equation can be optimized for the grape flow.
2191
// This can be obtained from stb.
2192
/*assign  ld_raw_mhit =
2193
  (ld_any_raw_vld[7] & |(ld_any_raw_vld[6:0])) |
2194
  (ld_any_raw_vld[6] & |(ld_any_raw_vld[5:0])) |
2195
  (ld_any_raw_vld[5] & |(ld_any_raw_vld[4:0])) |
2196
  (ld_any_raw_vld[4] & |(ld_any_raw_vld[3:0])) |
2197
  (ld_any_raw_vld[3] & |(ld_any_raw_vld[2:0])) |
2198
  (ld_any_raw_vld[2] & |(ld_any_raw_vld[1:0])) |
2199
  (ld_any_raw_vld[1] &   ld_any_raw_vld[0]) ; */
2200
 
2201
//=========================================================================================
2202
//  STB Partial Raw ptr generation
2203
//=========================================================================================
2204
 
2205
// The loading on the raw output of the stb cam will be significant if the signal 
2206
// has to fan out to all 4 ctl blocks. That's why the control has to be localized.
2207
 
2208
// Using the ack bit may result in pessimistic issue of partial raw loads.
2209
// For a single partial raw or multiple hit case, detecting whether there is any
2210
// unacked store is sufficient. Calculation is for no unacked store.
2211
// Can we use cam_hit ptr instead !!!
2212
 
2213
//assign  ld_rawp_st_ced_w2 = (~(|(ld_any_raw_vld_d1[7:0] & ~stb_state_ced_d1[7:0]))) ;
2214
wire [2:0] wptr_prev ;
2215
assign  wptr_prev[2:0] = stb_wptr_prev[2:0] ;
2216
wire [7:0] wptr_dcd ; // Bug 4294
2217
assign  wptr_dcd[0] = ~wptr_prev[2] & ~wptr_prev[1] & ~wptr_prev[0] ;
2218
assign  wptr_dcd[1] = ~wptr_prev[2] & ~wptr_prev[1] &  wptr_prev[0] ;
2219
assign  wptr_dcd[2] = ~wptr_prev[2] &  wptr_prev[1] & ~wptr_prev[0] ;
2220
assign  wptr_dcd[3] = ~wptr_prev[2] &  wptr_prev[1] &  wptr_prev[0] ;
2221
assign  wptr_dcd[4] =  wptr_prev[2] & ~wptr_prev[1] & ~wptr_prev[0] ;
2222
assign  wptr_dcd[5] =  wptr_prev[2] & ~wptr_prev[1] &  wptr_prev[0] ;
2223
assign  wptr_dcd[6] =  wptr_prev[2] &  wptr_prev[1] & ~wptr_prev[0] ;
2224
assign  wptr_dcd[7] =  wptr_prev[2] &  wptr_prev[1] &  wptr_prev[0] ;
2225
 
2226
wire iold_st_ced_g,iold_st_ced_w2 ;
2227
assign  iold_st_ced_g = |(wptr_dcd[7:0] & stb_state_ced[7:0]) ;
2228
 
2229
dff #(2)   ioldced_stgw2  (
2230
  .din  ({iold_st_ced_g,io_ld}),
2231
  .q    ({iold_st_ced_w2,io_ld_w2}),
2232
  .clk  (clk),
2233
  .se   (se), .si (), .so ()
2234
  );
2235
 
2236
assign  ld_rawp_st_ced_w2 =
2237
        io_ld_w2 ? iold_st_ced_w2 :
2238
        (~(|(ld_any_raw_vld_d1[7:0] & ~stb_state_ced_d1[7:0]))) ;
2239
 
2240
// For the case of a single partial raw.
2241
assign  ld_rawp_stb_id[0] = stb_cam_hit_ptr[0] ;
2242
assign  ld_rawp_stb_id[1] = stb_cam_hit_ptr[1] ;
2243
assign  ld_rawp_stb_id[2] = stb_cam_hit_ptr[2] ;
2244
/*assign  ld_rawp_stb_id[0] = stb_ld_partial_raw[1] | stb_ld_partial_raw[3] |
2245
        stb_ld_partial_raw[5] | stb_ld_partial_raw[7] ;
2246
assign  ld_rawp_stb_id[1] = stb_ld_partial_raw[2] | stb_ld_partial_raw[3] |
2247
        stb_ld_partial_raw[6] | stb_ld_partial_raw[7] ;
2248
assign  ld_rawp_stb_id[2] = stb_ld_partial_raw[4] | stb_ld_partial_raw[5] |
2249
        stb_ld_partial_raw[6] | stb_ld_partial_raw[7] ; */
2250
 
2251
   wire [3:0] pipe_thread_g;
2252
   assign     pipe_thread_g[0] = ~thrid_g[1] & ~thrid_g[0];
2253
   assign     pipe_thread_g[1] = ~thrid_g[1] &  thrid_g[0];
2254
   assign     pipe_thread_g[2] =  thrid_g[1] & ~thrid_g[0];
2255
   assign     pipe_thread_g[3] =  thrid_g[1] &  thrid_g[0];
2256
 
2257
assign  stb_state_ced[7:0] =
2258
( pipe_thread_g[0] ? stb_state_ced0[7:0] : 8'b0 ) |
2259
( pipe_thread_g[1] ? stb_state_ced1[7:0] : 8'b0 ) |
2260
( pipe_thread_g[2] ? stb_state_ced2[7:0] : 8'b0 ) |
2261
( pipe_thread_g[3] ? stb_state_ced3[7:0] : 8'b0 );
2262
 
2263
assign  stb_wptr_prev[2:0] =
2264
  (pipe_thread_g[0] ? stb_wrptr0_prev[2:0] : 3'b0) |
2265
  (pipe_thread_g[1] ? stb_wrptr1_prev[2:0] : 3'b0) |
2266
  (pipe_thread_g[2] ? stb_wrptr2_prev[2:0] : 3'b0) |
2267
  (pipe_thread_g[3] ? stb_wrptr3_prev[2:0] : 3'b0);
2268
 
2269
assign  stb_not_empty  =
2270
  (pipe_thread_g[0]  & ~lsu_stb_empty[0] ) |
2271
  (pipe_thread_g[1]  & ~lsu_stb_empty[1] ) |
2272
  (pipe_thread_g[2]  & ~lsu_stb_empty[2] ) |
2273
  (pipe_thread_g[3]  & ~lsu_stb_empty[3] ) ;
2274
 
2275
assign  lsu_stb_empty_buf[3:0] = lsu_stb_empty[3:0] ;
2276
assign  lsu_spu_stb_empty[3:0] = lsu_stb_empty[3:0] ;
2277
 
2278
//wire ldstdbl_g ;
2279
// stdbl should be qualified with quad_asi_g !!!
2280
//assign  ldstdbl_g = ldst_dbl_g & (ld_inst_vld_g | st_inst_vld_g) & ~ldst_fp_g ;
2281
 
2282
// casa_g and stdbl_g may not be required.
2283
//assign  ld_rawp_st_ackid_g[2:0] = 
2284
//  (casa_g | ldstdbl_g | stb_cam_mhit | (io_ld & stb_not_empty))
2285
//  ? stb_wptr_prev[2:0] : ld_rawp_stb_id[2:0] ;
2286
 
2287
//===================================================
2288
//casa: need st-st order
2289
//st cam mhit: cannot figure out the youngest
2290
//io: side effect
2291
//remove int ldd and quad ldd, why need ldstdbl?
2292
//===================================================
2293
wire    [2:0]    ld_rawp_st_ackid_g ;
2294
 
2295
assign  ld_rawp_st_ackid_g[2:0] =
2296
  (casa_g | stb_cam_mhit | (io_ld & stb_not_empty))?
2297
   stb_wptr_prev[2:0] : ld_rawp_stb_id[2:0] ;
2298
 
2299
dff #(3)  rawpackid_w2 (
2300
  .din  (ld_rawp_st_ackid_g[2:0]),
2301
  .q    (ld_rawp_st_ackid_w2[2:0]),
2302
  .clk  (clk),
2303
  .se   (se), .si (), .so ()
2304
  );
2305
 
2306
 
2307
   assign lsu_ifu_stbcnt0[3:0] = lsu_stbcnt0[3:0] ;
2308
   assign lsu_ifu_stbcnt1[3:0] = lsu_stbcnt1[3:0] ;
2309
   assign lsu_ifu_stbcnt2[3:0] = lsu_stbcnt2[3:0] ;
2310
   assign lsu_ifu_stbcnt3[3:0] = lsu_stbcnt3[3:0] ;
2311
 
2312
   assign lsu_ffu_stb_full0 =    lsu_stbcnt0[3];
2313
   assign lsu_ffu_stb_full1 =    lsu_stbcnt1[3];
2314
   assign lsu_ffu_stb_full2 =    lsu_stbcnt2[3];
2315
   assign lsu_ffu_stb_full3 =    lsu_stbcnt3[3];
2316
 
2317
endmodule
2318
 

powered by: WebSVN 2.1.0

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