-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmips_cpu.v
1192 lines (1017 loc) · 49.2 KB
/
mips_cpu.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
153
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
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
603
604
605
606
607
608
609
610
611
612
613
614
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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
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
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
822
823
824
825
826
827
828
829
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
880
881
882
883
884
885
886
887
888
889
890
891
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
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* mips_cpu.v
* Author: Pravin P. Prabhu and Dean Tullsen
* Last Revision: 1/5/11
* Abstract:
* The top level module for the MIPS32 processor. This is a classic 5-stage
* MIPS pipeline architecture which is intended to follow heavily from the model
* presented in Hennessy and Patterson's Computer Organization and Design.
*/
module mips_cpu(// General
input CLOCK_50, //These inputs are all pre-defined input/output pin names
//input Global_Reset_n, // TEMP - Remove this after testing
input [3:0] KEY, // which correspond to the DE2_pin_assignments,csv file. This
input [17:0] SW, // way, the mapping is automatically taken care of if we get the
output [6:0] HEX7, HEX6, HEX5, HEX4, HEX3, HEX2, HEX1, HEX0, // name right.
output [7:0] LEDG,
output [17:0] LEDR,
//SDRAM interface
output [11:0] DRAM_ADDR,
output DRAM_BA_0,
output DRAM_BA_1,
output DRAM_CAS_N,
output DRAM_CKE,
output DRAM_CLK,
output DRAM_CS_N,
inout [15:0] DRAM_DQ,
output DRAM_LDQM,
output DRAM_UDQM,
output DRAM_RAS_N,
output DRAM_WE_N,
//Flash RAM interface
output [21:0] FL_ADDR,
inout [7:0] FL_DQ,
output FL_CE_N,
output FL_OE_N,
output FL_RST_N,
output FL_WE_N,
//SRAM interface
output [17:0] SRAM_ADDR,
inout [15:0] SRAM_DQ,
output SRAM_UB_N,
output SRAM_LB_N,
output SRAM_WE_N,
output SRAM_OE_N,
output SRAM_CE_N
);
//===================================================================
// Internal Wiring
//===================================================================
//===================================================================
// General Signals
localparam FALSE = 1'b0;
localparam TRUE = 1'b1;
localparam ADDRESS_WIDTH = 22;
localparam DATA_WIDTH = 32;
localparam HISTORY_SIZE = 10; //NEW for history table
localparam COUNT_SIZE = 4; //NEW for branch prediction
localparam CHECKPOINT_WIDTH = 2; //NEW for register renaming
//wire Global_Reset_n; // Global reset
wire Global_Reset_n = KEY[0];
// MTC0 codes - Did we pass/fail a test or reach the done state?
localparam MTC0_NOOP = 0; // No significance
localparam MTC0_PASS = 1; // Passed a test
localparam MTC0_FAIL = 2; // Failed a test
localparam MTC0_DONE = 3; // Have completed execution
assign LEDG[7:1] = 0;
assign LEDR[17:1] = 0;
assign SRAM_ADDR = 0;
assign SRAM_UB_N = 0;
assign SRAM_LB_N = 0;
assign SRAM_WE_N = 0;
assign SRAM_OE_N = 0;
assign SRAM_CE_N = 0;
//===================================================================
// New signals
wire [DATA_WIDTH-1:0] EX_i_Instruction;
wire EX_i_Is_Load = (EX_i_Instruction[(DATA_WIDTH-1):(DATA_WIDTH-6)] == 6'd32
|| EX_i_Instruction[DATA_WIDTH-1:DATA_WIDTH-6] == 6'd15
|| EX_i_Instruction[DATA_WIDTH-1:DATA_WIDTH-6] == 6'd35);
wire i_Taken;
wire i_Was_Taken;
wire [DATA_WIDTH-1:0] DMEM_i_Instruction;
// Value History Table Signals
wire [DATA_WIDTH-1:0] Predict_Data;
wire Revert_Predict;
wire Predicted;
wire Value_Predicted;
// Branch History Table Signals
wire [1:0] DEC_o_Branch_Predictor;
wire [COUNT_SIZE-1:0] DEC_o_Branch_Pattern;
wire [1:0] EX_i_Branch_Predictor;
wire [COUNT_SIZE-1:0] EX_i_Branch_Pattern;
wire Smash_Transient_i;
//RR Signals
localparam FREE_LIST_WIDTH = 5;
wire Hazard_Create_Map_Checkpoint;
wire Hazard_Create_List_Checkpoint;
wire [ADDRESS_WIDTH-1:0] Revert_PC;
wire [CHECKPOINT_WIDTH-1:0] Revert_Checkpoint;
wire Regfile_Stall;
//===================================================================
// IFetch Signals
wire IFetch_i_Flush; // Flush for IFetch
wire Hazard_Stall_IF; // Stall for IFetch
wire IFetch_i_Load; // Load signal - if high, load pc with vector
wire [ADDRESS_WIDTH-1:0] IFetch_i_PCSrc; // Vector to branch to
wire [ADDRESS_WIDTH-1:0] IMEM_i_Address; // Current PC
wire IMEM_o_Ready;
wire IMEM_o_Valid;
wire [DATA_WIDTH-1:0] IMEM_o_Instruction;
//==============
// Pipe signals: IF->ID
wire Hazard_Flush_IF; // 1st pipe flush
wire Hazard_Stall_DEC; // 1st pipe stall
wire imembubble_DEC; // set if instruction coming out of icache
// was not real instruction
//===================================================================
// Decoder Signals
localparam ALU_CTLCODE_WIDTH = 8;
localparam REG_ADDR_WIDTH = 5;
localparam MEM_MASK_WIDTH = 3;
wire [ADDRESS_WIDTH-1:0] DEC_i_PC; // PC of inst
wire [DATA_WIDTH-1:0] DEC_i_Instruction; // Inst into decode
wire DEC_Noop = (DEC_i_Instruction == 32'd0);
wire DEC_o_Uses_ALU;
wire [ALU_CTLCODE_WIDTH-1:0] DEC_o_ALUCTL; // ALU control code
wire DEC_o_Is_Branch; // If it's a branch
wire [ADDRESS_WIDTH-1:0] DEC_o_Branch_Target; // Where we will branch to
wire DEC_o_Jump_Reg; // If this is a special case where we jump TO a register value
wire DEC_o_Mem_Valid;
wire DEC_o_Mem_Read_Write_n;
wire [MEM_MASK_WIDTH-1:0] DEC_o_Mem_Mask; // Used for masking individual memory ops - such as byte and halfword transactions
wire DEC_o_Writes_Back;
wire [REG_ADDR_WIDTH-1:0] DEC_o_VWrite_Addr;
wire [REG_ADDR_WIDTH:0] DEC_o_PWrite_Addr;
wire [FREE_LIST_WIDTH-1:0] DEC_o_Phys_Active_List_Index;
wire DEC_o_Uses_RS;
wire [REG_ADDR_WIDTH-1:0] DEC_o_Read_VRegister_1;
wire DEC_o_Uses_RT;
wire [REG_ADDR_WIDTH-1:0] DEC_o_Read_VRegister_2;
wire [CHECKPOINT_WIDTH-1:0] DEC_o_Checkpoint;
wire [REG_ADDR_WIDTH:0] DEC_o_Read_PRegister_1;
wire [REG_ADDR_WIDTH:0] DEC_o_Read_PRegister_2;
wire [DATA_WIDTH-1:0] DEC_o_Read_Data_1;
wire [DATA_WIDTH-1:0] DEC_o_Read_Data_2;
wire DEC_o_Uses_Immediate;
wire [DATA_WIDTH-1:0] DEC_o_Immediate;
wire [DATA_WIDTH-1:0] FORWARD_o_Forwarded_Data_1,FORWARD_o_Forwarded_Data_2; // Looked up regs
//==============
// Pipe signals: ID->EX
wire Hazard_Flush_DEC; // 2nd pipe flush
wire Hazard_Stall_EX; // 2nd pipe stall
wire [ADDRESS_WIDTH-1:0] DEC_o_PC;
assign DEC_o_PC = DEC_i_PC;
//===================================================================
// Execute Signals
wire [ADDRESS_WIDTH-1:0] ALU_i_PC;
wire EX_i_Is_Branch;
wire EX_i_Mem_Valid;
wire [MEM_MASK_WIDTH-1:0] EX_i_Mem_Mask;
wire EX_i_Mem_Read_Write_n;
wire [DATA_WIDTH-1:0] EX_i_Mem_Write_Data;
wire EX_i_Writes_Back;
wire [REG_ADDR_WIDTH-1:0] EX_i_VWrite_Addr;
wire [REG_ADDR_WIDTH:0] EX_i_PWrite_Addr;
wire [FREE_LIST_WIDTH-1:0] EX_i_Phys_Active_List_Index;
wire ALU_i_Valid; // Whether input to ALU is valid or not
wire ALU_o_Valid;
wire [ALU_CTLCODE_WIDTH-1:0] ALU_i_ALUOp; // Control bus to ALU
wire [DATA_WIDTH-1:0] ALU_i_Operand1,ALU_i_Operand2; // Ops for ALU
wire [ADDRESS_WIDTH-1:0] EX_i_Branch_Target;
wire [DATA_WIDTH-1:0] ALU_o_Result; // Computation of ALU
wire ALU_o_Branch_Valid; // Whether branch is valid or not
wire ALU_o_Branch_Outcome; // Whether branch is taken or not
wire [15:0] ALU_o_Pass_Done_Value; // reports the value of a PASS/FAIL/DONE instruction
wire [1:0] ALU_o_Pass_Done_Change; // indicates the above signal is meaningful
// 1 = pass, 2 = fail, 3 = done
wire [CHECKPOINT_WIDTH-1:0] EX_i_Checkpoint;
// Cumulative signals
wire EX_Take_Branch = ALU_o_Valid && ALU_o_Branch_Valid && ALU_o_Branch_Outcome; // Whether we should branch or not.
//==============
// Pipe signals: EX->MEM
wire Hazard_Flush_EX; // 3rd pipe flush
wire Hazard_Stall_MEM; // 3rd pipe stall
//===================================================================
// Memory Signals
wire [ADDRESS_WIDTH-1:0] DMEM_i_PC;
wire [DATA_WIDTH-1:0] DMEM_i_Result; // Result from the ALU
wire [DATA_WIDTH-1:0] DMEM_i_Mem_Write_Data; // What we will write back to mem (if applicable)
wire DMEM_i_Mem_Valid; // If the memory operation is valid
wire [MEM_MASK_WIDTH-1:0] DMEM_i_Mem_Mask; // Mem mask for sub-word operations
wire DMEM_i_Mem_Read_Write_n; // Type of memop
wire DMEM_i_Writes_Back; // If the result should be written back to regfile
wire [REG_ADDR_WIDTH-1:0] DMEM_i_VWrite_Addr; // Which vreg in the regfile to write to
wire [REG_ADDR_WIDTH:0] DMEM_i_PWrite_Addr; // Which preg in the regfile to write to
wire [FREE_LIST_WIDTH-1:0] DMEM_i_Phys_Active_List_Index;
wire [DATA_WIDTH-1:0] DMEM_o_Read_Data; // The data READ from DMEM
wire DMEM_o_Mem_Ready; // If the DMEM is ready to service another request
wire DMEM_o_Mem_Valid; // If the value read from DMEM is valid
reg DMEM_o_Done; // If MEM's work is finalized
reg [DATA_WIDTH-1:0] DMEM_o_Write_Data; // Data we should write back to regfile
wire MemToReg = DMEM_i_Mem_Valid; // Selects what we will write back -- mem or ALU result
wire [CHECKPOINT_WIDTH-1:0] MEM_i_Checkpoint;
//==============
// Mem_Prediction Signals
wire [DATA_WIDTH-1:0] r_DMEM_o_Write_Data;
wire r_DMEM_i_Writes_Back;
wire [REG_ADDR_WIDTH-1:0] r_DMEM_i_VWrite_Addr;
wire [REG_ADDR_WIDTH:0] r_DMEM_i_PWrite_Addr;
wire [FREE_LIST_WIDTH-1:0] r_DMEM_i_Phys_Active_List_Index;
//==============
// Pipe signals: MEM->WB
wire Hazard_Flush_MEM; // 4th pipe flush
wire Hazard_Stall_WB; // 4th pipe stall
//===================================================================
// Write-Back Signals
wire r_WB_i_Writes_Back; // If we will write back
wire [REG_ADDR_WIDTH-1:0] r_DEC_i_VWrite_Register;
wire [REG_ADDR_WIDTH:0] r_DEC_i_PWrite_Register;// Where we will write back to
wire [FREE_LIST_WIDTH-1:0] r_DEC_i_Phys_Active_List_Index;
wire [DATA_WIDTH-1:0] r_WB_i_Write_Data; // What we will write back
wire r_Hazard_Flush_WB; // Request to squash WB contents
wire WB_i_Writes_Back; // If we will write back
wire [REG_ADDR_WIDTH-1:0] DEC_i_VWrite_Register;
wire [REG_ADDR_WIDTH:0] DEC_i_PWrite_Register;// Where we will write back to
wire [FREE_LIST_WIDTH-1:0] DEC_i_Phys_Active_List_Index;
wire [DATA_WIDTH-1:0] WB_i_Write_Data; // What we will write back
wire Hazard_Flush_WB; // Request to squash WB contents
wire DEC_i_RegWrite = WB_i_Writes_Back && !Hazard_Flush_WB;
//===================================================================
// Flash Signals
wire o_FlashLoader_Done; // Raised when the loader finishes
wire o_FlashLoader_SDRAM_Read_Write_n; // FlashLoader's actual request to dmem
wire o_FlashLoader_SDRAM_Req_Valid; // FlashLoader's verification of request to dmem
wire [ADDRESS_WIDTH-1:0] o_FlashLoader_SDRAM_Addr; // FlashLoader's request addrto dmem
wire [DATA_WIDTH-1:0] o_FlashLoader_SDRAM_Data; // FlashLoader's output data
wire i_FlashLoader_SDRAM_Data_Read; // FlashLoader's input callback from dmem
wire i_FlashLoader_SDRAM_Last; // ""
wire [21:0] o_FlashLoader_FL_Addr; // FlashLoader's addr request to flash
wire [7:0] i_FlashLoader_FL_Data; // FlashLoader's data coming back from flash
wire o_FlashLoader_FL_Chip_En_n; // FlashLoader's chip enable to flash
wire o_FlashLoader_FL_Output_En_n; // "" (output enable)
wire o_FlashLoader_FL_Reset_n; // "" (flash reset)
wire o_FlashLoader_FL_Write_En_n; // Write enable going out to flash
// Top level connections
assign FL_ADDR = o_FlashLoader_FL_Addr; // Addr we're requesting to deal with
assign i_FlashLoader_FL_Data = FL_DQ; // Incoming data from flash (for reads)
assign FL_CE_N = o_FlashLoader_FL_Chip_En_n; // Flash chip enable
assign FL_OE_N = o_FlashLoader_FL_Output_En_n; // Flash output enable
assign FL_WE_N = o_FlashLoader_FL_Write_En_n; // Flash write enable
assign FL_RST_N = o_FlashLoader_FL_Reset_n; // Flash reset
//===================================================================
// Arbiter Signals
wire Arbiter_i_IMEM_Valid;
wire [ADDRESS_WIDTH-1:0] Arbiter_i_IMEM_Address;
wire Arbiter_o_IMEM_Valid;
wire Arbiter_o_IMEM_Last;
wire [DATA_WIDTH-1:0] Arbiter_o_IMEM_Data;
wire Arbiter_i_DMEM_Valid;
wire Arbiter_i_DMEM_Read_Write_n;
wire [ADDRESS_WIDTH-1:0] Arbiter_i_DMEM_Address;
wire [DATA_WIDTH-1:0] Arbiter_i_DMEM_Data;
wire [DATA_WIDTH-1:0] Arbiter_o_DMEM_Data;
wire Arbiter_o_DMEM_Data_Read;
wire Arbiter_o_DMEM_Valid;
wire Arbiter_o_DMEM_Last;
wire Arbiter_i_Flash_Valid;
wire [DATA_WIDTH-1:0] Arbiter_i_Flash_Data;
wire [ADDRESS_WIDTH-1:0] Arbiter_i_Flash_Address;
wire Arbiter_o_Flash_Data_Read;
//wire [DATA_WIDTH-1:0] Arbiter_o_Flash_Data_Read;
wire Arbiter_o_Flash_Last;
assign Arbiter_i_Flash_Valid = o_FlashLoader_SDRAM_Req_Valid;
assign Arbiter_i_Flash_Data = o_FlashLoader_SDRAM_Data;
assign Arbiter_i_Flash_Address = o_FlashLoader_SDRAM_Addr;
assign i_FlashLoader_SDRAM_Data_Read = Arbiter_o_Flash_Data_Read;
assign i_FlashLoader_SDRAM_Last = Arbiter_o_Flash_Last;
//====================================================================
// Controller Signals
wire [ADDRESS_WIDTH-1:0] SDRAM_i_Address; // Transact address
wire SDRAM_i_Valid; // If request is valid
wire SDRAM_i_Read_Write_n; // Request type
wire [DATA_WIDTH-1:0] SDRAM_i_Data; // What to write
wire SDRAM_o_Data_Read; // If data was read or not
wire [DATA_WIDTH-1:0] SDRAM_o_Data; // Read in data from SDRAM
wire SDRAM_o_Data_Valid; // If read in data is valid
wire SDRAM_o_Last; // If we're on the last part of the burst
wire i_Clk;
//===================================================================
// Top-level Connections
// Clock handling for mem & processor
wire Done = (ALU_o_Pass_Done_Change == MTC0_DONE);
wire Local_Clock;
wire Internal_Reset_n;
//integer file;
//initial
// begin
// file = $fopen("dumppcs");
// end
`ifdef MODEL_TECH
assign Internal_Reset_n = Global_Reset_n;
assign Local_Clock = CLOCK_50;
`else
wire PLL_Locked;
pll my_pll(
.areset(!Global_Reset_n),
.inclk0(CLOCK_50),
.c0(Local_Clock),
.locked(PLL_Locked)
);
assign Internal_Reset_n = PLL_Locked && Global_Reset_n;
`endif
assign i_Clk = Local_Clock;
// Performance metrics
reg [31:0] CycleCount; // # of cycles that have passed since reset
reg [31:0] InstructionsExecuted; // # of insts that have went through WB stage since reset
reg displaystop;
always @(posedge i_Clk or negedge Internal_Reset_n)
begin
if( !Internal_Reset_n )
begin
// Asynch. reset on counters
CycleCount <= 32'b0;
InstructionsExecuted <= 32'b0;
displaystop <= 0;
end
else
begin
// If we're currently executing instructions...
if( o_FlashLoader_Done && !Done )
begin
// If we have a valid instruction that is finishing up execution in Decode, then count it
if( !Hazard_Stall_DEC && !Hazard_Flush_DEC && !DEC_Noop )
begin
if (!displaystop)
begin
//$fwrite(file, "%h\n", (DEC_o_PC<<2) + 'h20240);
if (InstructionsExecuted > 1000000000)
begin
displaystop <= 1;
// $fflush(file);
// $fclose(file);
end
end
InstructionsExecuted <= InstructionsExecuted + 32'b1;
end
CycleCount <= CycleCount + 32'b1; // Always count another cycle
end
end
end
// Visual output
assign LEDG[0] = (Done);
assign LEDR[0] = (!Done);
reg[3:0] HEX_Buf [7:0]; // Buffers for visualization of data
always @(posedge i_Clk)
begin
HEX_Buf[0] <= 4'd0;
HEX_Buf[1] <= 4'd0;
HEX_Buf[2] <= 4'd0;
HEX_Buf[3] <= 4'd0;
HEX_Buf[4] <= 4'd0;
HEX_Buf[5] <= 4'd0;
HEX_Buf[6] <= 4'd0;
HEX_Buf[7] <= 4'd0;
case(SW[1:0])
2'd0: // Default: Display Pass/Done/Fail, PC, and PDF Value information
begin
HEX_Buf[0] <= ALU_o_Pass_Done_Value[3:0];
HEX_Buf[1] <= ALU_o_Pass_Done_Value[7:4];
HEX_Buf[6] <= IMEM_i_Address[3:0];
HEX_Buf[7] <= IMEM_i_Address[7:4];
end
2'd1: // Cycle Count
begin
HEX_Buf[0] <= CycleCount[3:0];
HEX_Buf[1] <= CycleCount[7:4];
HEX_Buf[2] <= CycleCount[11:8];
HEX_Buf[3] <= CycleCount[15:12];
HEX_Buf[4] <= CycleCount[19:16];
HEX_Buf[5] <= CycleCount[23:20];
HEX_Buf[6] <= CycleCount[27:24];
HEX_Buf[7] <= CycleCount[31:28];
end
2'd2: // Instructions Executed
begin
HEX_Buf[0] <= InstructionsExecuted[3:0];
HEX_Buf[1] <= InstructionsExecuted[7:4];
HEX_Buf[2] <= InstructionsExecuted[11:8];
HEX_Buf[3] <= InstructionsExecuted[15:12];
HEX_Buf[4] <= InstructionsExecuted[19:16];
HEX_Buf[5] <= InstructionsExecuted[23:20];
HEX_Buf[6] <= InstructionsExecuted[27:24];
HEX_Buf[7] <= InstructionsExecuted[31:28];
end
2'd3: // (free for any other metric)
begin
end
endcase
end
wire [6:0] HEX2_SSD, HEX2_PFD;
SevenSegmentDisplayDecoder SSD0 (i_Clk, HEX0, HEX_Buf[0]);
SevenSegmentDisplayDecoder SSD1 (i_Clk, HEX1, HEX_Buf[1]);
SevenSegmentDisplayDecoder SSD2 (i_Clk, HEX2_SSD, HEX_Buf[2]);
SevenSegmentDisplayDecoder SSD3 (i_Clk, HEX3, HEX_Buf[3]);
SevenSegmentDisplayDecoder SSD4 (i_Clk, HEX4, HEX_Buf[4]);
SevenSegmentDisplayDecoder SSD5 (i_Clk, HEX5, HEX_Buf[5]);
SevenSegmentDisplayDecoder SSD6 (i_Clk, HEX6, HEX_Buf[6]);
SevenSegmentDisplayDecoder SSD7 (i_Clk, HEX7, HEX_Buf[7]);
SevenSegmentPFD PFD2 (i_Clk, HEX2_PFD, ALU_o_Pass_Done_Change); // display pass/done/fail status
// Special case: If SW is 0, then HEX2 output comes from PFD. Else, comes from SSD.
assign HEX2 = (SW[1:0]==2'd0 ? HEX2_PFD : HEX2_SSD);
/*
SevenSegmentPFD SSD3 (i_Clk, HEX2, ALU_o_Pass_Done_Change); // display pass/done/fail status
SevenSegmentDisplayDecoder SSD0 (i_Clk, HEX0, ALU_o_Pass_Done_Value[3:0]);
SevenSegmentDisplayDecoder SSD1 (i_Clk, HEX1, ALU_o_Pass_Done_Value[7:4]);
SevenSegmentDisplayDecoder SSD7 (i_Clk, HEX7, IMEM_i_Address[7:4]);
SevenSegmentDisplayDecoder SSD6 (i_Clk, HEX6, IMEM_i_Address[3:0]);
*/
//===================================================================
// Structural Description - Overhead
//===================================================================
//===================================================================
// Structural Description - Pipeline stages
//===================================================================
//===================================================================
// Instruction Fetch
fetch_unit #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH)
)
IFETCH
( // Inputs
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
.i_Stall(Hazard_Stall_IF),
.i_Load(IFetch_i_Load),
.i_Load_Address(IFetch_i_PCSrc),
// Outputs
.o_PC(IMEM_i_Address)
);
i_cache #( .DATA_WIDTH(DATA_WIDTH)
)
I_CACHE
(
// General
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
// Requests
.i_Valid(o_FlashLoader_Done),
.i_Address(IMEM_i_Address),
// Mem Transaction
.o_MEM_Valid(Arbiter_i_IMEM_Valid),
.o_MEM_Address(Arbiter_i_IMEM_Address),
.i_MEM_Valid(Arbiter_o_IMEM_Valid), // If data from main mem is valid
.i_MEM_Last(Arbiter_o_IMEM_Last), // If main mem is sending the last piece of data
.i_MEM_Data(Arbiter_o_IMEM_Data), // Data from main mem
// Outputs
.o_Ready(IMEM_o_Ready),
.o_Valid(IMEM_o_Valid), // If the output is correct.
.o_Data(IMEM_o_Instruction) // The data requested.
);
//===================================================================
// Decode
pipe_if_dec #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH)
)
PIPE_IF_DEC
(
// Inputs
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
.i_Flush(Hazard_Flush_IF),
.i_Stall(Hazard_Stall_DEC),
.i_imembubble(IMEM_o_Valid),
// Pipe signals
.i_PC(IMEM_i_Address),
.o_PC(DEC_i_PC),
.i_Instruction(IMEM_o_Instruction),
.o_Instruction(DEC_i_Instruction),
.o_imembubble(imembubble_DEC)
);
decoder #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH),
.REG_ADDRESS_WIDTH(REG_ADDR_WIDTH),
.ALUCTL_WIDTH(ALU_CTLCODE_WIDTH),
.MEM_MASK_WIDTH(MEM_MASK_WIDTH)
)
DECODE
( // Inputs
.i_PC(DEC_i_PC),
.i_Instruction(DEC_i_Instruction),
.i_Stall(Hazard_Stall_DEC),
// Outputs
.o_Uses_ALU(DEC_o_Uses_ALU),
.o_ALUCTL(DEC_o_ALUCTL),
.o_Is_Branch(DEC_o_Is_Branch),
.o_Jump_Reg(DEC_o_Jump_Reg),
.o_Mem_Valid(DEC_o_Mem_Valid),
.o_Mem_Read_Write_n(DEC_o_Mem_Read_Write_n),
.o_Mem_Mask(DEC_o_Mem_Mask),
.o_Writes_Back(DEC_o_Writes_Back),
.o_Write_Addr(DEC_o_VWrite_Addr),
.o_Uses_RS(DEC_o_Uses_RS),
.o_RS_Addr(DEC_o_Read_VRegister_1),
.o_Uses_RT(DEC_o_Uses_RT),
.o_RT_Addr(DEC_o_Read_VRegister_2),
.o_Uses_Immediate(DEC_o_Uses_Immediate),
.o_Immediate(DEC_o_Immediate),
.o_Branch_Target(DEC_o_Branch_Target)
);
regfile_RR #( .DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH),
.FREE_LIST_WIDTH(FREE_LIST_WIDTH),
.CHECKPOINT_WIDTH(CHECKPOINT_WIDTH)
)
REGFILE
( // Inputs
.i_Clk(i_Clk),
.i_Stall(Hazard_Stall_DEC),
.i_VRS_Addr(DEC_o_Read_VRegister_1),
.i_VRT_Addr(DEC_o_Read_VRegister_2),
.i_DEC_Write_Enable(DEC_o_Writes_Back),
.i_VRD_Addr(DEC_o_VWrite_Addr),
.i_MEM_Write_Enable(DEC_i_RegWrite), // Account for squashing WB stage
.i_PWrite_Data(WB_i_Write_Data),
.i_PWrite_Addr(DEC_i_PWrite_Register),
.i_Phys_Active_List_Index(DEC_i_Phys_Active_List_Index),
.i_VWrite_Addr(DEC_i_VWrite_Register),
.i_DEC_Is_Branch(DEC_o_Is_Branch),
.i_EX_Is_Branch(EX_i_Is_Branch), // to create a checkpoint
.i_WB_Is_Branch(WB_i_Is_Branch),
.i_Mem_Valid(DEC_o_Mem_Valid),
.i_Mem_Read(DEC_o_Mem_Read_Write_n),
.i_Create_Map_Checkpoint(Hazard_Create_Map_Checkpoint),
.i_Create_List_Checkpoint(Hazard_Create_List_Checkpoint),
.i_Revert(Revert_Predict),
.i_Revert_Checkpoint(Revert_Checkpoint),
// Outputs
.o_PRS_Addr(DEC_o_Read_PRegister_1),
.o_PRT_Addr(DEC_o_Read_PRegister_2),
.o_VRS_Data(DEC_o_Read_Data_1),
.o_VRT_Data(DEC_o_Read_Data_2),
.o_PRD_Addr(DEC_o_PWrite_Addr),
.o_Phys_Active_List_Index(DEC_o_Phys_Active_List_Index),
.o_Stall(Regfile_Stall),
.o_Checkpoint(DEC_o_Checkpoint)
);
//===================================================================
// Execute
pipe_dec_ex #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH),
.ALU_CTLCODE_WIDTH(ALU_CTLCODE_WIDTH),
.MEM_MASK_WIDTH(MEM_MASK_WIDTH),
.COUNT_SIZE(COUNT_SIZE),
.FREE_LIST_WIDTH(FREE_LIST_WIDTH),
.CHECKPOINT_WIDTH(CHECKPOINT_WIDTH)
)
PIPE_DEC_EX
( // Inputs
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
.i_Flush(Hazard_Flush_DEC),
.i_Stall(Hazard_Stall_EX),
// Pipeline
.i_PC(DEC_o_PC),
.o_PC(ALU_i_PC),
.i_Instruction(DEC_i_Instruction),//[ADDRESS_WIDTH-1:0]),
.o_Instruction(EX_i_Instruction),
.i_Uses_ALU(DEC_o_Uses_ALU),
.o_Uses_ALU(ALU_i_Valid),
.i_ALUCTL(DEC_o_ALUCTL),
.o_ALUCTL(ALU_i_ALUOp),
.i_Is_Branch(DEC_o_Is_Branch),
.o_Is_Branch(EX_i_Is_Branch),
.i_Mem_Valid(DEC_o_Mem_Valid),
.o_Mem_Valid(EX_i_Mem_Valid),
.i_Mem_Mask(DEC_o_Mem_Mask),
.o_Mem_Mask(EX_i_Mem_Mask),
.i_Mem_Read_Write_n(DEC_o_Mem_Read_Write_n),
.o_Mem_Read_Write_n(EX_i_Mem_Read_Write_n),
.i_Mem_Write_Data(FORWARD_o_Forwarded_Data_2),
.o_Mem_Write_Data(EX_i_Mem_Write_Data),
.i_Writes_Back(DEC_o_Writes_Back),
.o_Writes_Back(EX_i_Writes_Back),
.i_VWrite_Addr(DEC_o_VWrite_Addr),
.o_VWrite_Addr(EX_i_VWrite_Addr),
.i_PWrite_Addr(DEC_o_PWrite_Addr),
.o_PWrite_Addr(EX_i_PWrite_Addr),
.i_Phys_Active_List_Index(DEC_o_Phys_Active_List_Index),
.o_Phys_Active_List_Index(EX_i_Phys_Active_List_Index),
.i_Operand1(FORWARD_o_Forwarded_Data_1),
.o_Operand1(ALU_i_Operand1),
.i_Operand2(DEC_o_Uses_Immediate?DEC_o_Immediate:FORWARD_o_Forwarded_Data_2), // Convention - Operand2 mapped to immediates
.o_Operand2(ALU_i_Operand2),
.i_Branch_Target(DEC_o_Jump_Reg?FORWARD_o_Forwarded_Data_1[ADDRESS_WIDTH-1:0]:DEC_o_Branch_Target),
.o_Branch_Target(EX_i_Branch_Target),
.i_Predictor(DEC_o_Branch_Predictor),
.o_Predictor(EX_i_Branch_Predictor),
.i_Pattern(DEC_o_Branch_Pattern),
.o_Pattern(EX_i_Branch_Pattern),
.i_Checkpoint(DEC_o_Checkpoint),
.o_Checkpoint(EX_i_Checkpoint)
);
alu #( .DATA_WIDTH(DATA_WIDTH),
.CTLCODE_WIDTH(ALU_CTLCODE_WIDTH)
)
ALU
( // Inputs
.i_Valid(ALU_i_Valid),
.i_ALUCTL(ALU_i_ALUOp),
.i_Operand1(ALU_i_Operand1),
.i_Operand2(ALU_i_Operand2),
// Outputs
.o_Valid(ALU_o_Valid),
.o_Result(ALU_o_Result),
.o_Branch_Valid(ALU_o_Branch_Valid),
.o_Branch_Outcome(ALU_o_Branch_Outcome),
.o_Pass_Done_Value(ALU_o_Pass_Done_Value),
.o_Pass_Done_Change(ALU_o_Pass_Done_Change)
);
//===================================================================
// Mem
pipe_ex_mem #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH),
.ALU_CTLCODE_WIDTH(ALU_CTLCODE_WIDTH),
.FREE_LIST_WIDTH(FREE_LIST_WIDTH),
.CHECKPOINT_WIDTH(CHECKPOINT_WIDTH)
)
PIPE_EX_MEM
( // Inputs
.i_Clk(i_Clk),
.i_PC(ALU_i_PC),
.i_Reset_n(Internal_Reset_n),
.i_Flush(Hazard_Flush_EX),
.i_Stall(Hazard_Stall_MEM),
.i_Value_Predicted(Predicted),
// Pipe in/out
.o_PC(DMEM_i_PC),
.o_Value_Predicted(DMEM_i_Predicted),
.i_Instruction(EX_i_Instruction),
.o_Instruction(DMEM_i_Instruction),
.i_ALU_Result(ALU_o_Result),
.o_ALU_Result(DMEM_i_Result),
.i_Mem_Valid(EX_i_Mem_Valid),
.o_Mem_Valid(DMEM_i_Mem_Valid),
.i_Mem_Mask(EX_i_Mem_Mask),
.o_Mem_Mask(DMEM_i_Mem_Mask),
.i_Mem_Read_Write_n(EX_i_Mem_Read_Write_n),
.o_Mem_Read_Write_n(DMEM_i_Mem_Read_Write_n),
.i_Mem_Write_Data(EX_i_Mem_Write_Data),
.o_Mem_Write_Data(DMEM_i_Mem_Write_Data),
.i_Writes_Back(EX_i_Writes_Back),
.o_Writes_Back(DMEM_i_Writes_Back),
.i_VWrite_Addr(EX_i_VWrite_Addr),
.o_VWrite_Addr(DMEM_i_VWrite_Addr),
.i_PWrite_Addr(EX_i_PWrite_Addr),
.o_PWrite_Addr(DMEM_i_PWrite_Addr),
.i_Phys_Active_List_Index(EX_i_Phys_Active_List_Index),
.o_Phys_Active_List_Index(DMEM_i_Phys_Active_List_Index),
.i_Checkpoint(EX_i_Checkpoint),
.o_Checkpoint(MEM_i_Checkpoint),
.i_Is_Branch(EX_i_Is_Branch),
.o_Is_Branch(MEM_i_Is_Branch)
);
d_cache #(
.DATA_WIDTH(32),
.ADDRESS_WIDTH(ADDRESS_WIDTH),
.MEM_MASK_WIDTH(3)
)
D_CACHE
( // Inputs
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
.i_Valid(DMEM_i_Mem_Valid),
.i_Mem_Mask(DMEM_i_Mem_Mask),
.i_Address(DMEM_i_Result[ADDRESS_WIDTH:2]),
.i_Read_Write_n(DMEM_i_Mem_Read_Write_n), //1=MemRead, 0=MemWrite
.i_Write_Data(DMEM_i_Mem_Write_Data),
// Outputs
.o_Ready(DMEM_o_Mem_Ready),
.o_Valid(DMEM_o_Mem_Valid),
.o_Data(DMEM_o_Read_Data),
// Mem Transaction
.o_MEM_Valid(Arbiter_i_DMEM_Valid),
.o_MEM_Read_Write_n(Arbiter_i_DMEM_Read_Write_n),
.o_MEM_Address(Arbiter_i_DMEM_Address),
.o_MEM_Data(Arbiter_i_DMEM_Data),
.i_MEM_Valid(Arbiter_o_DMEM_Valid),
.i_MEM_Data_Read(Arbiter_o_DMEM_Data_Read),
.i_MEM_Last(Arbiter_o_DMEM_Last),
.i_MEM_Data(Arbiter_o_DMEM_Data)
);
mem_prediction #(
.ADDRESS_WIDTH(ADDRESS_WIDTH),
.CHECKPOINT_WIDTH(CHECKPOINT_WIDTH),
.DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH),
.FREE_LIST_WIDTH(FREE_LIST_WIDTH))
MEM_PREDICTION
(
.i_Clk(i_Clk),
.i_PC(DMEM_i_PC),
.i_Mem_Ready(DMEM_o_Mem_Ready),
.i_Mem_Done(DMEM_o_Mem_Valid),
.i_Checkpoint(MEM_i_Checkpoint),
.i_Value_Predicted(DMEM_i_Predicted),
.o_PC(Revert_PC),
.o_Checkpoint(Revert_Checkpoint),
.o_Value_Predicted(Value_Predicted),
.i_WriteBack_Data(DMEM_o_Write_Data),
.o_WriteBack_Data(r_DMEM_o_Write_Data),
.i_Writes_Back(DMEM_i_Writes_Back),
.o_Writes_Back(r_DMEM_i_Writes_Back),
.i_VWrite_Addr(DMEM_i_VWrite_Addr),
.o_VWrite_Addr(r_DMEM_i_VWrite_Addr),
.i_PWrite_Addr(DMEM_i_PWrite_Addr),
.o_PWrite_Addr(r_DMEM_i_PWrite_Addr),
.i_Phys_Active_List_Index(DMEM_i_Phys_Active_List_Index),
.o_Phys_Active_List_Index(r_DMEM_i_Phys_Active_List_Index),
.i_Is_Branch(MEM_i_Is_Branch),
.o_Is_Branch(r_MEM_i_Is_Branch)
);
// Multiplexor - Select what we will write back
always @(*)
begin
if( MemToReg ) // If it was a memory operation
begin
DMEM_o_Write_Data <= DMEM_o_Read_Data; // We will write back value from memory
DMEM_o_Done <= DMEM_o_Mem_Valid; // Write back only if value is valid
end
else
begin
DMEM_o_Write_Data <= DMEM_i_Result; // Else we will write back value from ALU
DMEM_o_Done <= TRUE;
end
end
//===================================================================
// Write-Back
pipe_mem_wb #( .ADDRESS_WIDTH(ADDRESS_WIDTH),
.DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH),
.FREE_LIST_WIDTH(FREE_LIST_WIDTH)
)
PIPE_MEM_WB
( // Inputs
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
.i_Flush(Hazard_Flush_MEM),
.i_Stall(Hazard_Stall_WB),
// Pipe in/out
.i_WriteBack_Data(DMEM_o_Write_Data),
.o_WriteBack_Data(WB_i_Write_Data),
.i_Writes_Back(DMEM_i_Writes_Back),
.o_Writes_Back(WB_i_Writes_Back),
.i_VWrite_Addr(DMEM_i_VWrite_Addr),
.o_VWrite_Addr(DEC_i_VWrite_Register),
.i_PWrite_Addr(DMEM_i_PWrite_Addr),
.o_PWrite_Addr(DEC_i_PWrite_Register),
.i_Phys_Active_List_Index(DMEM_i_Phys_Active_List_Index),
.o_Phys_Active_List_Index(DEC_i_Phys_Active_List_Index),
.i_Is_Branch(MEM_i_Is_Branch),
.o_Is_Branch(WB_i_Is_Branch)
);
// Write-Back is simply wires feeding back into regfile to perform writes
// (SEE REGFILE)
//===================================================================
// Arbitration Logic
// Memory arbiter
memory_arbiter #( .DATA_WIDTH(DATA_WIDTH),
.ADDRESS_WIDTH(ADDRESS_WIDTH)
)
ARBITER
(
// General
.i_Clk(i_Clk),
.i_Reset_n(Internal_Reset_n),
// Requests to/from IMEM - Assume we always read
.i_IMEM_Valid(Arbiter_i_IMEM_Valid), // If IMEM request is valid
.i_IMEM_Address(Arbiter_i_IMEM_Address), // IMEM request addr.
.o_IMEM_Valid(Arbiter_o_IMEM_Valid),
.o_IMEM_Last(Arbiter_o_IMEM_Last),
.o_IMEM_Data(Arbiter_o_IMEM_Data),
// Requests to/from DMEM
.i_DMEM_Valid(Arbiter_i_DMEM_Valid),
.i_DMEM_Read_Write_n(Arbiter_i_DMEM_Read_Write_n),
.i_DMEM_Address(Arbiter_i_DMEM_Address),
.i_DMEM_Data(Arbiter_i_DMEM_Data),
.o_DMEM_Valid(Arbiter_o_DMEM_Valid),
.o_DMEM_Data_Read(Arbiter_o_DMEM_Data_Read),
.o_DMEM_Last(Arbiter_o_DMEM_Last),
.o_DMEM_Data(Arbiter_o_DMEM_Data),
// Requests to/from FLASH - Assume we always write
.i_Flash_Valid(Arbiter_i_Flash_Valid),
.i_Flash_Data(Arbiter_i_Flash_Data),
.i_Flash_Address(Arbiter_i_Flash_Address),
.o_Flash_Data_Read(Arbiter_o_Flash_Data_Read),
.o_Flash_Last(Arbiter_o_Flash_Last),
// Interface with SDRAM Controller
.o_MEM_Valid(SDRAM_i_Valid),
.o_MEM_Address(SDRAM_i_Address),
.o_MEM_Read_Write_n(SDRAM_i_Read_Write_n),
// Write data interface
.o_MEM_Data(SDRAM_i_Data),
.i_MEM_Data_Read(SDRAM_o_Data_Read),
// Read data interface
.i_MEM_Data(SDRAM_o_Data),
.i_MEM_Data_Valid(SDRAM_o_Data_Valid),
.i_MEM_Last(SDRAM_o_Last)
);
sdram_controller memory_controller(
.i_Clk(i_Clk),
.i_Reset(!Internal_Reset_n),
// Request interface
.i_Addr(SDRAM_i_Address),
.i_Req_Valid(SDRAM_i_Valid),
.i_Read_Write_n(SDRAM_i_Read_Write_n),
// Write .data interface
.i_Data(SDRAM_i_Data),
.o_Data_Read(SDRAM_o_Data_Read),
// Read data .interface
.o_Data(SDRAM_o_Data),
.o_Data_Valid(SDRAM_o_Data_Valid),
// output
.o_Last(SDRAM_o_Last),
// SDRAM interface
.b_Dq(DRAM_DQ),
.o_Addr(DRAM_ADDR),
.o_Ba({DRAM_BA_0,DRAM_BA_1}),
.o_Clk(DRAM_CLK),
.o_Cke(DRAM_CKE),
.o_Cs_n(DRAM_CS_N),
.o_Ras_n(DRAM_RAS_N),
.o_Cas_n(DRAM_CAS_N),
.o_We_n(DRAM_WE_N),
.o_Dqm({DRAM_UDQM,DRAM_LDQM})
);
// Forwarding logic
forwarding_unit #( .DATA_WIDTH(DATA_WIDTH),
.REG_ADDR_WIDTH(REG_ADDR_WIDTH)
)
FORWARDING_UNIT
(
// Feedback from DEC
.i_DEC_Uses_RS(DEC_o_Uses_RS),
.i_DEC_RS_Addr(DEC_o_Read_PRegister_1),
.i_DEC_Uses_RT(DEC_o_Uses_RT), // DEC wants to use RT
.i_DEC_RT_Addr(DEC_o_Read_PRegister_2), // RT request addr.
.i_DEC_RS_Data(DEC_o_Read_Data_1),
.i_DEC_RT_Data(DEC_o_Read_Data_2),
// Feedback from EX
.i_EX_Writes_Back(EX_i_Writes_Back), // EX is valid for analysis
.i_EX_Valid(ALU_i_Valid), // If it's a valid ALU op or not
.i_EX_Write_Addr(EX_i_PWrite_Addr), // What EX will write to
.i_EX_Write_Data(ALU_o_Result),