-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtop_datapath.vhd
1594 lines (1090 loc) · 55.9 KB
/
top_datapath.vhd
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
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package pkg is
type slv8_array_t is array (natural range <>) of std_logic_vector(7 downto 0);
type slv4_array_t is array (natural range <>) of std_logic_vector(3 downto 0);
type slv6_array_t is array (natural range <>) of std_logic_vector(5 downto 0);
type slv16_array_t is array (natural range <>) of std_logic_vector(15 downto 0);
type slv_array_t is array (natural range <>) of std_logic;
type slv3_array_t is array (natural range <>) of std_logic_vector(2 downto 0);
type slv2_array_t is array (natural range <>) of std_logic_vector(1 downto 0);
type slv6_int_array_t is array (natural range <>) of integer range 0 to 9;
end package;
package body pkg is
end package body;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.pkg.all;
entity top_level is
port (
top_clock:in std_logic;
system_reset:in std_logic;-----------------------------------active high system reset
r0_out: out std_logic_vector(15 downto 0);
r1_out: out std_logic_vector(15 downto 0);
r2_out: out std_logic_vector(15 downto 0);
r3_out: out std_logic_vector(15 downto 0);
r4_out: out std_logic_vector(15 downto 0);
r5_out: out std_logic_vector(15 downto 0);
r6_out: out std_logic_vector(15 downto 0);
r7_out: out std_logic_vector(15 downto 0);
curr_pc: out std_logic_vector(15 downto 0)
);
end entity;
architecture struct of top_level is
component memory_code is
port (clk : in std_logic;
we : in std_logic;
a : in std_logic_vector(15 downto 0);
di : in std_logic_vector(15 downto 0);
do : out std_logic_vector(31 downto 0));
end component memory_code;
component fetch is
port (
clk: in std_logic;
Mem_in: in std_logic_vector(31 downto 0);
PC_in: in std_logic_vector(15 downto 0);
stall_in: in std_logic;
instr_invalidate_in: in std_logic;
------------------------------------------------------------
inst_1_valid: out std_logic;
inst_2_valid: out std_logic;
Instr1: out std_logic_vector(15 downto 0);
Instr2: out std_logic_vector(15 downto 0);
PC: out std_logic_vector(15 downto 0)
) ;
end component fetch;
component add_pc is
port (
PC_in:in std_logic_vector(15 downto 0);
PC_out:out std_logic_vector(15 downto 0)
);
end component add_pc;
component decode is
port (
clk: in std_logic;
reset:in std_logic;
inst_1_valid_in: in std_logic;
inst_2_valid_in: in std_logic;
Instr1_in: in std_logic_vector(15 downto 0);
Instr2_in: in std_logic_vector(15 downto 0);
PC_in: in std_logic_vector(15 downto 0);
Nxt_PC_in: in std_logic_vector(15 downto 0);
br_inst_valid_in: in std_logic;
br_btag_in: in std_logic_vector(2 downto 0);
br_self_tag_in: in std_logic_vector(2 downto 0);
stall_in: in std_logic;
instr_invalidate_in: in std_logic;
------------------------------------------------------------
--Instruction 1
I1_valid: out std_logic;
I1_op_code: out std_logic_vector(3 downto 0);
I1_op_cz: out std_logic_vector(1 downto 0);
I1_dest_code: out std_logic_vector(2 downto 0);
I1_operand_1_code: out std_logic_vector(2 downto 0);
I1_operand_2_code: out std_logic_vector(2 downto 0);
I1_Imm: out std_logic_vector(15 downto 0);
I1_PC: out std_logic_vector(15 downto 0);
I1_Nxt_PC: out std_logic_vector(15 downto 0);
I1_BTAG: out std_logic_vector(2 downto 0);
I1_self_tag: out std_logic_vector(2 downto 0);
--Instruction 2
I2_valid: out std_logic;
I2_op_code: out std_logic_vector(3 downto 0);
I2_op_cz: out std_logic_vector(1 downto 0);
I2_dest_code: out std_logic_vector(2 downto 0);
I2_operand_1_code: out std_logic_vector(2 downto 0);
I2_operand_2_code: out std_logic_vector(2 downto 0);
I2_Imm: out std_logic_vector(15 downto 0);
I2_PC: out std_logic_vector(15 downto 0);
I2_Nxt_PC: out std_logic_vector(15 downto 0);
I2_BTAG: out std_logic_vector(2 downto 0);
I2_self_tag: out std_logic_vector(2 downto 0);
-----------------------------------
stall_out: out std_logic
);
end component decode;
component bit16_2x1 is
port ( c_0 : in STD_LOGIC;
d_0 : in std_logic_vector(15 downto 0);
d_1 : in std_logic_vector(15 downto 0);
o : out std_logic_vector(15 downto 0));
end component bit16_2x1;
component bit1_2x1 is
port ( c_0 : in STD_LOGIC;
d_0 : in std_logic;
d_1 : in std_logic;
o : out std_logic);
end component bit1_2x1;
component reservation_state is
port (instr1_valid_in:in std_logic;
op_code1_in:in std_logic_vector(3 downto 0);
op_cz1_in: in std_logic_vector(1 downto 0);
destn_code1_in:in std_logic_vector(2 downto 0);
opr1_code1_in:in std_logic_vector(2 downto 0);
opr2_code1_in:in std_logic_vector(2 downto 0);
opr3_code1_in:in std_logic_vector(2 downto 0);
curr_pc1_in: in std_logic_vector(15 downto 0);
next_pc1_in:in std_logic_vector(15 downto 0);
imm1_in:in std_logic_vector(15 downto 0);
btag1_in:in std_logic_vector(2 downto 0);
self1_tag_in:in std_logic_vector(2 downto 0);
instr2_valid_in:in std_logic;
op_code2_in:in std_logic_vector(3 downto 0);
op_cz2_in: in std_logic_vector(1 downto 0);
destn_code2_in:in std_logic_vector(2 downto 0);
opr1_code2_in:in std_logic_vector(2 downto 0);
opr2_code2_in:in std_logic_vector(2 downto 0);
opr3_code2_in:in std_logic_vector(2 downto 0);
curr_pc2_in: in std_logic_vector(15 downto 0);
next_pc2_in:in std_logic_vector(15 downto 0);
imm2_in:in std_logic_vector(15 downto 0);
btag2_in:in std_logic_vector(2 downto 0);
self2_tag_in:in std_logic_vector(2 downto 0);
alu_valid_done1_in:in std_logic;
alu_done_number1:in std_logic_vector(3 downto 0);
alu_valid_done2_in:in std_logic;
alu_done_number2:in std_logic_vector(3 downto 0);
ls_valid_done_in:in std_logic;
ls_done_number:in std_logic_vector(3 downto 0);
jmp_valid_done_in:in std_logic;
jmp_done_number:in std_logic_vector(3 downto 0);
reset_system:in std_logic;--to be done at start of cycle general reset which assigns all registers its original values
--reset_system_mapping:in std_logic;--to be used to clear all assigned ARF and RRF's
clk_input:in std_logic;
stall_reservation_update:in std_logic;--no data comes to reservation station if becomes 1
broadcast1_rename_in:in std_logic_vector(5 downto 0);--refers to rename register broadcasted
broadcast1_orig_destn_in:in std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
broadcast1_data_in:in std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
broadcast1_valid_in: in std_logic;--refers whether broadcasted data is valid or not
broadcast1_c_flag_in:in std_logic;
broadcast1_c_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast1_c_flag_valid_in:in std_logic;
broadcast1_z_flag_in:in std_logic;
broadcast1_z_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast1_z_flag_valid_in:in std_logic;
broadcast1_btag_in: in std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
broadcast2_rename_in:in std_logic_vector(5 downto 0);--refers to rename register broadcasted
broadcast2_orig_destn_in:in std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
broadcast2_data_in:in std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
broadcast2_valid_in: in std_logic;--refers whether broadcasted data is valid or not
broadcast2_c_flag_in:in std_logic;
broadcast2_c_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast2_c_flag_valid_in:in std_logic;
broadcast2_z_flag_in:in std_logic;
broadcast2_z_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast2_z_flag_valid_in:in std_logic;
broadcast2_btag_in:in std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
broadcast3_rename_in:in std_logic_vector(5 downto 0);--refers to rename register broadcasted
broadcast3_orig_destn_in:in std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
broadcast3_data_in:in std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
broadcast3_valid_in: in std_logic;--refers whether broadcasted data is valid or not
--
broadcast3_btag_in:in std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
broadcast4_rename_in:in std_logic_vector(5 downto 0);--refers to rename register broadcasted
broadcast4_orig_destn_in:in std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
broadcast4_data_in:in std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
broadcast4_valid_in: in std_logic;--refers whether broadcasted data is valid or not
broadcast4_c_flag_in:in std_logic;
broadcast4_c_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast4_c_flag_valid_in:in std_logic;
broadcast4_z_flag_in:in std_logic;
broadcast4_z_flag_rename_in:in std_logic_vector(2 downto 0);
broadcast4_z_flag_valid_in:in std_logic;
broadcast4_btag_in:in std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
branch_mispredict_broadcast_in:in std_logic_vector(1 downto 0); --00 implies no misprediction 01 implies first branch mispredicted 10 implies second branch mispredicted
broadcast5_rename_in:in std_logic_vector(5 downto 0);
broadcast5_orig_destn_in:in std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
broadcast5_data_in:in std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
broadcast5_valid_in: in std_logic;--refers whether broadcasted data is valid or not \
broadcast5_btag_in:in std_logic_vector(2 downto 0);
--entry in ROB output
curr_pc1_rob_out:out std_logic_vector(15 downto 0);
destn_code1_rob_out:out std_logic_vector(2 downto 0);
op_code1_rob_out:out std_logic_vector(3 downto 0);
destn_rename1_rob_out:out std_logic_vector(5 downto 0);
destn_rename_c1_rob_out:out std_logic_vector(2 downto 0);
destn_rename_z1_rob_out:out std_logic_vector(2 downto 0);
curr_pc2_rob_out:out std_logic_vector(15 downto 0);
destn_code2_rob_out:out std_logic_vector(2 downto 0);
op_code2_rob_out:out std_logic_vector(3 downto 0);
destn_rename2_rob_out:out std_logic_vector(5 downto 0);
destn_rename_c2_rob_out:out std_logic_vector(2 downto 0);
destn_rename_z2_rob_out:out std_logic_vector(2 downto 0);
alu_instr_valid_out:out slv_array_t(0 to 9);
alu_op_code_out:out slv4_array_t(0 to 9);
alu_op_code_cz_out:out slv2_array_t(0 to 9);
alu_destn_rename_code_out:out slv6_array_t(0 to 9);
alu_operand1_out:out slv16_array_t(0 to 9);
alu_valid1_out:out slv_array_t(0 to 9);
alu_operand2_out:out slv16_array_t(0 to 9);
alu_valid2_out:out slv_array_t(0 to 9);
alu_operand3_out:out slv16_array_t(0 to 9);
alu_valid3_out:out slv_array_t(0 to 9);
alu_c_flag_out:out slv_array_t(0 to 9);
alu_c_flag_rename_out:out slv3_array_t(0 to 9);
alu_c_flag_valid_out:out slv_array_t(0 to 9);
alu_z_flag_out:out slv_array_t(0 to 9);
alu_z_flag_rename_out:out slv3_array_t(0 to 9);
alu_z_flag_valid_out:out slv_array_t(0 to 9);
alu_btag_out:out slv3_array_t(0 to 9);
alu_orign_destn_out:out slv3_array_t(0 to 9);
alu_curr_pc_out:out slv16_array_t(0 to 9);
alu_scheduler_valid_out:out slv_array_t(0 to 9);
ls_instr_valid_out:out slv_array_t(0 to 9);
ls_op_code_out:out slv4_array_t(0 to 9);
--_op_code_cz_out:out slv2_array_t(0 to 9);
ls_destn_rename_code_out:out slv6_array_t(0 to 9);
ls_operand1_out:out slv16_array_t(0 to 9);
ls_valid1_out:out slv_array_t(0 to 9);
ls_operand2_out:out slv16_array_t(0 to 9);
ls_valid2_out:out slv_array_t(0 to 9);
ls_operand3_out:out slv16_array_t(0 to 9);--denotes which register to load onto or store from
ls_valid3_out:out slv_array_t(0 to 9);
ls_btag_out:out slv3_array_t(0 to 9);
ls_orign_destn_out:out slv3_array_t(0 to 9);
ls_curr_pc_out:out slv16_array_t(0 to 9);
--ls_imm_out:out slv16_array_t(0 to 9);
ls_scheduler_valid_out:out slv_array_t(0 to 9);
jmp_instr_valid_out:out slv_array_t(0 to 9);
jmp_op_code_out:out slv4_array_t(0 to 9);
--_op_code_cz_out:out slv2_array_t(0 to 9);
jmp_destn_rename_code_out:out slv6_array_t(0 to 9);
jmp_operand1_out:out slv16_array_t(0 to 9);
jmp_valid1_out:out slv_array_t(0 to 9);
jmp_operand2_out:out slv16_array_t(0 to 9);
jmp_valid2_out:out slv_array_t(0 to 9);
jmp_operand3_out:out slv16_array_t(0 to 9);--denotes which register to load onto or store from
jmp_valid3_out:out slv_array_t(0 to 9);
jmp_btag_out:out slv3_array_t(0 to 9);
jmp_orign_destn_out:out slv3_array_t(0 to 9);
jmp_curr_pc_out:out slv16_array_t(0 to 9);
--ls_imm_out:out slv16_array_t(0 to 9);
jmp_scheduler_valid_out:out slv_array_t(0 to 9);
jmp_next_pc_out:out slv16_array_t(0 to 9);
jmp_self_tag_out:out slv3_array_t(0 to 9);
halt_out:out std_logic--instr could not be written onto RS
--
);
end component;
-------------------------------------------------------------------------------------------------------------------------------------------------
component lw_sw_sch is
port ( clk: in std_logic;
reset: in std_logic;
ls_instr_valid_in: in slv_array_t(0 to 9);
ls_op_code_in: in slv4_array_t(0 to 9);
ls_original_dest_in: in slv3_array_t(0 to 9);
ls_rename_dest_in: in slv6_array_t(0 to 9);
ls_operand_1_in: in slv16_array_t(0 to 9);
ls_operand_1_valid_in: in slv_array_t(0 to 9);
ls_operand_2_in: in slv16_array_t(0 to 9);
ls_operand_2_valid_in: in slv_array_t(0 to 9);
ls_operand_3_in: in slv16_array_t(0 to 9);
ls_operand_3_valid_in: in slv_array_t(0 to 9);
ls_pc_in: in slv16_array_t(0 to 9);
ls_sch_valid_in: in slv_array_t(0 to 9);
ls_btag_in: in slv3_array_t(0 to 9);
ls_stall_in: in std_logic;
--------------------------------------------------------------------------------
-- Execute Pipepline output
ls_instr_valid_out: out std_logic;
ls_op_code_out: out std_logic_vector(3 downto 0);
ls_original_dest_out: out std_logic_vector(2 downto 0);
ls_rename_dest_out: out std_logic_vector(5 downto 0);
ls_operand_1_out: out std_logic_vector(15 downto 0);
ls_operand_2_out: out std_logic_vector(15 downto 0);
ls_operand_3_out: out std_logic_vector(15 downto 0);
ls_pc_out: out std_logic_vector(15 downto 0);
ls_btag_out: out std_logic_vector(2 downto 0);
--------------------------------------------------------------------------------
-- Data going back to RS
rs_ls_index_out: out std_logic_vector(3 downto 0);
rs_ls_valid_out: out std_logic
);
end component ; -- lw_sw_sch
-------------------------------------------------------------------------------------------------------------------------------------------------
component branch_sch is
port (
clk: in std_logic;
reset: in std_logic;
br_instr_valid_in: in slv_array_t(0 to 9);
br_op_code_in: in slv4_array_t(0 to 9);
br_original_dest_in: in slv3_array_t(0 to 9);
br_rename_dest_in: in slv6_array_t(0 to 9);
br_operand_1_in: in slv16_array_t(0 to 9);
br_operand_1_valid_in: in slv_array_t(0 to 9);
br_operand_2_in: in slv16_array_t(0 to 9);
br_operand_2_valid_in: in slv_array_t(0 to 9);
br_operand_3_in: in slv16_array_t(0 to 9);
br_operand_3_valid_in: in slv_array_t(0 to 9);
br_pc_in: in slv16_array_t(0 to 9);
br_nxt_pc_in: in slv16_array_t(0 to 9);
br_sch_valid_in: in slv_array_t(0 to 9);
br_btag_in: in slv3_array_t(0 to 9);
br_self_tag_in: in slv3_array_t(0 to 9);
br_stall_in: in std_logic;
-----------------------------------------------------------------------------------
--Execute pipeline branch input
br_instr_valid_out: out std_logic;
br_op_code_out: out std_logic_vector(3 downto 0);
br_original_dest_out: out std_logic_vector(2 downto 0);
br_rename_dest_out: out std_logic_vector(5 downto 0);
br_operand_1_out: out std_logic_vector(15 downto 0);--refers to Ra
br_operand_2_out: out std_logic_vector(15 downto 0);--refers to Rb
br_operand_3_out: out std_logic_vector(15 downto 0);--refers to immediate
br_pc_out: out std_logic_vector(15 downto 0);
br_nxt_pc_out: out std_logic_vector(15 downto 0);
br_btag_out: out std_logic_vector(2 downto 0);
br_self_tag_out: out std_logic_vector(2 downto 0);
--------------------------------------------------------------------------------
-- Data going back to RS
rs_br_index_out: out std_logic_vector(3 downto 0);
rs_br_valid_out: out std_logic
);
end component ; -- branch_sch
-------------------------------------------------------------------------------------------------------------------------------------------------
component alu_sch is
port (
clk: in std_logic;
reset: in std_logic;
alu_instr_valid_in: in slv_array_t(0 to 9);
alu_op_code_in: in slv4_array_t(0 to 9);
alu_op_code_cz_in: in slv2_array_t(0 to 9);
alu_original_dest_in: in slv3_array_t(0 to 9);
alu_rename_dest_in: in slv6_array_t(0 to 9);
alu_operand_1_in: in slv16_array_t(0 to 9);
alu_operand_1_valid_in: in slv_array_t(0 to 9);
alu_operand_2_in: in slv16_array_t(0 to 9);
alu_operand_2_valid_in: in slv_array_t(0 to 9);
alu_operand_3_in: in slv16_array_t(0 to 9);
alu_operand_3_valid_in: in slv_array_t(0 to 9);
alu_c_flag_in: in slv_array_t(0 to 9);
alu_c_flag_rename_in: in slv3_array_t(0 to 9);
alu_z_flag_in: in slv_array_t(0 to 9);
alu_z_flag_rename_in: in slv3_array_t(0 to 9);
alu_pc_in: in slv16_array_t(0 to 9);
alu_sch_valid_in: in slv_array_t(0 to 9);
alu_btag_in: in slv3_array_t(0 to 9);
alu_stall_in: in std_logic;
--------------------------------------------------------------------------------
-- Execute Pipepline output
alu_instr_valid_out_1: out std_logic;
alu_op_code_out_1: out std_logic_vector(3 downto 0);
alu_op_code_cz_out_1: out std_logic_vector(1 downto 0);
alu_original_dest_out_1: out std_logic_vector(2 downto 0);
alu_rename_dest_out_1: out std_logic_vector(5 downto 0);
alu_operand_1_out_1: out std_logic_vector(15 downto 0);
alu_operand_2_out_1: out std_logic_vector(15 downto 0);
alu_operand_3_out_1: out std_logic_vector(15 downto 0);
alu_c_flag_out_1: out std_logic;
alu_c_flag_rename_out_1: out std_logic_vector(2 downto 0);
alu_z_flag_out_1: out std_logic;
alu_z_flag_rename_out_1: out std_logic_vector(2 downto 0);
alu_pc_out_1: out std_logic_vector(15 downto 0);
alu_btag_out_1: out std_logic_vector(2 downto 0);
-------------------------------------------------------------------------------------------
--2 copies as 2 pipelines
alu_instr_valid_out_2: out std_logic;
alu_op_code_out_2: out std_logic_vector(3 downto 0);
alu_op_code_cz_out_2: out std_logic_vector(1 downto 0);
alu_original_dest_out_2: out std_logic_vector(2 downto 0);
alu_rename_dest_out_2: out std_logic_vector(5 downto 0);
alu_operand_1_out_2: out std_logic_vector(15 downto 0);
alu_operand_2_out_2: out std_logic_vector(15 downto 0);
alu_operand_3_out_2: out std_logic_vector(15 downto 0);
alu_c_flag_out_2: out std_logic;
alu_c_flag_rename_out_2: out std_logic_vector(2 downto 0);
alu_z_flag_out_2: out std_logic;
alu_z_flag_rename_out_2: out std_logic_vector(2 downto 0);
alu_pc_out_2: out std_logic_vector(15 downto 0);
alu_btag_out_2: out std_logic_vector(2 downto 0);
--------------------------------------------------------------------------------
-- Data going back to RS
rs_alu_index_1_out: out std_logic_vector(3 downto 0);
rs_alu_valid_1_out: out std_logic;
rs_alu_index_2_out: out std_logic_vector(3 downto 0);
rs_alu_valid_2_out: out std_logic
);
end component ; -- alu_sch
-------------------------------------------------------------------------------------------------------------------------------------------------
signal addr_to_mem:std_logic_vector(15 downto 0);
signal code_mem:std_logic_vector(31 downto 0);
--signal curr_pc_mem:std_logic_vector(15 downto 0);
signal fetch_PC_plus_two:std_logic_vector(15 downto 0);--refers to fetch_pc_mem +2
signal control_to_jmp:std_logic; --tells whether instr is jmp or not
signal branch_predicted:std_logic_vector(15 downto 0);--tells us predicted branch from fetch
signal next_pc_fetch_in:std_logic_vector(15 downto 0);--tells us whether to use pc+2 or predicted branch--to be written onto fetch register
signal next_branch_fetch:std_logic_vector(15 downto 0);--tells us whether to use predicted or pc +2
--signal next_pc_mem:std_logic_vector(15 downto 0);--instr feteched next
signal branch_mis_predicted:std_logic;--tells us to fetch branch instr from exec pipeline
signal addr_exec:std_logic_vector(15 downto 0); --tells us the addr from exec pipeline
signal stall_fetch_in:std_logic;--controlling the stopping of writing onto fetch state
signal invalidate_fetch_in:std_logic;--invalidating the fetch register data
signal instr1_fetch_valid:std_logic;--output of fetch state 1
signal instr2_fetch_valid:std_logic;--output of fetch state 2
signal instr1_fetch_out:std_logic_vector(15 downto 0);--output instr2 from fetch
signal instr2_fetch_out:std_logic_vector(15 downto 0);--output instr2 from fetch
signal fetch_pc_out: std_logic_vector(15 downto 0);--output pc from fetch
signal stall_decode_in: std_logic; --stalls the deode stage fetch
--signal
signal decode_invalidate_in:std_logic;--invalidating all instr in decode state
signal instr1_decode_valid:std_logic;
signal instr1_decode_op_code:std_logic_vector(3 downto 0);
signal instr1_decode_op_cz:std_logic_vector(1 downto 0);
signal instr1_decode_destn_code:std_logic_vector(2 downto 0);
signal instr1_decode_op1_code:std_logic_vector(2 downto 0);
signal instr1_decode_op2_code:std_logic_vector(2 downto 0);
signal instr1_decode_imm:std_logic_vector(15 downto 0);
signal instr1_decode_PC:std_logic_vector(15 downto 0);
signal instr1_decode_next_PC:std_logic_vector(15 downto 0);
signal instr1_decode_btag:std_logic_vector(2 downto 0);
signal instr1_decode_self_tag:std_logic_vector(2 downto 0);
signal instr1_RS_valid_in:std_logic;
signal instr2_decode_valid:std_logic;
signal instr2_decode_op_code:std_logic_vector(3 downto 0);
signal instr2_decode_op_cz:std_logic_vector(1 downto 0);
signal instr2_decode_destn_code:std_logic_vector(2 downto 0);
signal instr2_decode_op1_code:std_logic_vector(2 downto 0);
signal instr2_decode_op2_code:std_logic_vector(2 downto 0);
signal instr2_decode_imm:std_logic_vector(15 downto 0);
signal instr2_decode_PC:std_logic_vector(15 downto 0);
signal instr2_decode_next_PC:std_logic_vector(15 downto 0);
signal instr2_decode_btag:std_logic_vector(2 downto 0);
signal instr2_decode_self_tag:std_logic_vector(2 downto 0);
signal instr2_RS_valid_in:std_logic;
signal decode_stall_out:std_logic;
signal broadcast_branch_decode_valid: std_logic; -----------------------------
signal broadcast_branch_btag_in: std_logic_vector(2 downto 0);
signal broadcast_branch_self_tag_in:std_logic_vector(2 downto 0);
--output signals from scheduler
signal alu_valid_done1_RS:std_logic;
signal alu_done_number1_RS:std_logic_vector(3 downto 0);
signal alu_valid_done2_RS:std_logic;
signal alu_done_number2_RS:std_logic_vector(3 downto 0);
signal ls_valid_done_RS:std_logic;
signal ls_done_number_RS:std_logic_vector(3 downto 0);
signal jmp_valid_done_RS:std_logic;
signal jmp_done_number_RS:std_logic_vector(3 downto 0);
signal stall_reservation_center:std_logic; --signal used to control reservation center update
--input signals from execution pipeline and after mem state
signal broadcast1_rename: std_logic_vector(5 downto 0);--refers to rename register broadcasted
signal broadcast1_orig_destn: std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
signal broadcast1_data: std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
signal broadcast1_valid: std_logic;--refers whether broadcasted data is valid or not
signal broadcast1_c_flag: std_logic;
signal broadcast1_c_flag_rename:std_logic_vector(2 downto 0);
signal broadcast1_c_flag_valid: std_logic;
signal broadcast1_z_flag: std_logic;
signal broadcast1_z_flag_rename:std_logic_vector(2 downto 0);
signal broadcast1_z_flag_valid: std_logic;
signal broadcast1_btag: std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
signal broadcast2_rename: std_logic_vector(5 downto 0);--refers to rename register broadcasted
signal broadcast2_orig_destn: std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
signal broadcast2_data: std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
signal broadcast2_valid: std_logic;--refers whether broadcasted data is valid or not
signal broadcast2_c_flag:std_logic;
signal broadcast2_c_flag_rename:std_logic_vector(2 downto 0);
signal broadcast2_c_flag_valid: std_logic;
signal broadcast2_z_flag: std_logic;
signal broadcast2_z_flag_rename: std_logic_vector(2 downto 0);
signal broadcast2_z_flag_valid: std_logic;
signal broadcast2_btag: std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
signal broadcast3_rename: std_logic_vector(5 downto 0);--refers to rename register broadcasted
signal broadcast3_orig_destn: std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
signal broadcast3_data: std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
signal broadcast3_valid: std_logic;--refers whether broadcasted data is valid or not
--
signal broadcast3_btag: std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
signal broadcast4_rename: std_logic_vector(5 downto 0);--refers to rename register broadcasted
signal broadcast4_orig_destn: std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
signal broadcast4_data: std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
signal broadcast4_valid: std_logic;--refers whether broadcasted data is valid or not
signal broadcast4_c_flag: std_logic;
signal broadcast4_c_flag_rename: std_logic_vector(2 downto 0);
signal broadcast4_c_flag_valid: std_logic;
signal broadcast4_z_flag: std_logic;
signal broadcast4_z_flag_rename: std_logic_vector(2 downto 0);
signal broadcast4_z_flag_valid: std_logic;
signal broadcast4_btag:std_logic_vector(2 downto 0);--refers to btag of branch signal useful for updating branch copies
signal branch_mispredict_broadcast: std_logic_vector(1 downto 0); --00 implies no misprediction 01 implies first branch mispredicted 10 implies second branch mispredicted
--if
signal broadcast5_rename: std_logic_vector(5 downto 0);
signal broadcast5_orig_destn: std_logic_vector(2 downto 0);--used if a broadcast signal matches with arrival of other instr with same src register
signal broadcast5_data: std_logic_vector(15 downto 0); --refers to data of rename register broadcasted
signal broadcast5_valid: std_logic;--refers whether broadcasted data is valid or not \
signal broadcast5_btag :std_logic_vector(2 downto 0);
--output signals from Reservation center to ROB
signal curr_pc1_rob: std_logic_vector(15 downto 0);
signal destn_code1_rob: std_logic_vector(2 downto 0);
signal op_code1_rob: std_logic_vector(3 downto 0);
signal destn_rename1_rob: std_logic_vector(5 downto 0);
signal destn_rename_c1_rob: std_logic_vector(2 downto 0);
signal destn_rename_z1_rob: std_logic_vector(2 downto 0);
signal curr_pc2_rob: std_logic_vector(15 downto 0);
signal destn_code2_rob: std_logic_vector(2 downto 0);
signal op_code2_rob: std_logic_vector(3 downto 0);
signal destn_rename2_rob: std_logic_vector(5 downto 0);
signal destn_rename_c2_rob: std_logic_vector(2 downto 0);
signal destn_rename_z2_rob: std_logic_vector(2 downto 0);
---output signals to scheduler
signal alu_instr_valid: slv_array_t(0 to 9);
signal alu_op_code: slv4_array_t(0 to 9);
signal alu_op_code_cz: slv2_array_t(0 to 9);
signal alu_destn_rename_code: slv6_array_t(0 to 9);
signal alu_operand1: slv16_array_t(0 to 9);
signal alu_valid1: slv_array_t(0 to 9);
signal alu_operand2: slv16_array_t(0 to 9);
signal alu_valid2: slv_array_t(0 to 9);
signal alu_operand3: slv16_array_t(0 to 9);
signal alu_valid3: slv_array_t(0 to 9);
signal alu_c_flag: slv_array_t(0 to 9);
signal alu_c_flag_rename: slv3_array_t(0 to 9);
signal alu_c_flag_valid: slv_array_t(0 to 9);
signal alu_z_flag: slv_array_t(0 to 9);
signal alu_z_flag_rename: slv3_array_t(0 to 9);
signal alu_z_flag_valid: slv_array_t(0 to 9);
signal alu_btag: slv3_array_t(0 to 9);
signal alu_orign_destn: slv3_array_t(0 to 9);
signal alu_curr_pc: slv16_array_t(0 to 9);
signal alu_scheduler_valid: slv_array_t(0 to 9);
signal ls_instr_valid: slv_array_t(0 to 9);
signal ls_op_code: slv4_array_t(0 to 9);
--_op_code_cz_out:out slv2_array_t(0 to 9);
signal ls_destn_rename_code: slv6_array_t(0 to 9);
signal ls_operand1: slv16_array_t(0 to 9);
signal ls_valid1: slv_array_t(0 to 9);
signal ls_operand2: slv16_array_t(0 to 9);
signal ls_valid2: slv_array_t(0 to 9);
signal ls_operand3: slv16_array_t(0 to 9);--denotes which register to load onto or store from
signal ls_valid3: slv_array_t(0 to 9);
signal ls_btag: slv3_array_t(0 to 9);
signal ls_orign_destn: slv3_array_t(0 to 9);
signal ls_curr_pc: slv16_array_t(0 to 9);
--ls_imm_out:out slv16_array_t(0 to 9);
signal ls_scheduler_valid: slv_array_t(0 to 9);
--instr of jump to jump scheduler
signal jmp_instr_valid: slv_array_t(0 to 9);
signal jmp_op_code: slv4_array_t(0 to 9);
--_op_code_cz_out:out slv2_array_t(0 to 9);
signal jmp_destn_rename_code: slv6_array_t(0 to 9);
signal jmp_operand1: slv16_array_t(0 to 9);
signal jmp_valid1: slv_array_t(0 to 9);
signal jmp_operand2: slv16_array_t(0 to 9);
signal jmp_valid2: slv_array_t(0 to 9);
signal jmp_operand3:slv16_array_t(0 to 9);--denotes which register to load onto or store from
signal jmp_valid3: slv_array_t(0 to 9);
signal jmp_btag: slv3_array_t(0 to 9);
signal jmp_orign_destn:slv3_array_t(0 to 9);
signal jmp_curr_pc: slv16_array_t(0 to 9);
--ls_imm_out:out slv16_array_t(0 to 9);
signal jmp_scheduler_valid: slv_array_t(0 to 9);
signal jmp_next_pc: slv16_array_t(0 to 9);
signal jmp_self_tag: slv3_array_t(0 to 9);
signal halt_out_RS: std_logic;--instr could not be written onto RS
----added a reset stage after addr to memory
--------------------------------------------------------------------------------------------------------------------------------------------
--Scheduler left output signals(RS valid and number is already an=bove not repeated)
signal alu_sch_stall_in: std_logic;
signal alu_sch_instr_valid_out_1: std_logic;
signal alu_sch_op_code_out_1: std_logic_vector(3 downto 0);
signal alu_sch_op_code_cz_out_1: std_logic_vector(1 downto 0);
signal alu_sch_original_dest_out_1: std_logic_vector(2 downto 0);
signal alu_sch_rename_dest_out_1: std_logic_vector(5 downto 0);
signal alu_sch_operand_1_out_1: std_logic_vector(15 downto 0);
signal alu_sch_operand_2_out_1: std_logic_vector(15 downto 0);
signal alu_sch_operand_3_out_1: std_logic_vector(15 downto 0);
signal alu_sch_c_flag_out_1: std_logic;
signal alu_sch_c_flag_rename_out_1: std_logic_vector(2 downto 0);
signal alu_sch_z_flag_out_1: std_logic;
signal alu_sch_z_flag_rename_out_1: std_logic_vector(2 downto 0);
signal alu_sch_pc_out_1: std_logic_vector(15 downto 0);
signal alu_sch_btag_out_1: std_logic_vector(2 downto 0);
-------------------------------------------------------------------------------------------
--2 copies as 2 pipelines
signal alu_sch_instr_valid_out_2: std_logic;
signal alu_sch_op_code_out_2: std_logic_vector(3 downto 0);
signal alu_sch_op_code_cz_out_2: std_logic_vector(1 downto 0);
signal alu_sch_original_dest_out_2: std_logic_vector(2 downto 0);
signal alu_sch_rename_dest_out_2: std_logic_vector(5 downto 0);
signal alu_sch_operand_1_out_2: std_logic_vector(15 downto 0);
signal alu_sch_operand_2_out_2: std_logic_vector(15 downto 0);
signal alu_sch_operand_3_out_2: std_logic_vector(15 downto 0);
signal alu_sch_c_flag_out_2: std_logic;
signal alu_sch_c_flag_rename_out_2: std_logic_vector(2 downto 0);
signal alu_sch_z_flag_out_2: std_logic;
signal alu_sch_z_flag_rename_out_2: std_logic_vector(2 downto 0);
signal alu_sch_pc_out_2: std_logic_vector(15 downto 0);
signal alu_sch_btag_out_2: std_logic_vector(2 downto 0);
----------------------------------------------------------------------------------
signal ls_sch_stall_in: std_logic;
-- Execute Pipepline output
signal ls_sch_instr_valid_out: std_logic;
signal ls_sch_op_code_out: std_logic_vector(3 downto 0);
signal ls_sch_original_dest_out: std_logic_vector(2 downto 0);
signal ls_sch_rename_dest_out: std_logic_vector(5 downto 0);
signal ls_sch_operand_1_out: std_logic_vector(15 downto 0);
signal ls_sch_operand_2_out: std_logic_vector(15 downto 0);
signal ls_sch_operand_3_out: std_logic_vector(15 downto 0);
signal ls_sch_pc_out: std_logic_vector(15 downto 0);
signal ls_sch_btag_out: std_logic_vector(2 downto 0);
----------------------------------------------------------------------------------
signal br_sch_stall_in: std_logic;
--Execute pipeline branch input
signal br_sch_instr_valid_out: std_logic;
signal br_sch_op_code_out: std_logic_vector(3 downto 0);
signal br_sch_original_dest_out: std_logic_vector(2 downto 0);
signal br_sch_rename_dest_out: std_logic_vector(5 downto 0);
signal br_sch_operand_1_out: std_logic_vector(15 downto 0);
signal br_sch_operand_2_out: std_logic_vector(15 downto 0);
signal br_sch_operand_3_out: std_logic_vector(15 downto 0);
signal br_sch_pc_out: std_logic_vector(15 downto 0);
signal br_sch_nxt_pc_out: std_logic_vector(15 downto 0);
signal br_sch_btag_out: std_logic_vector(2 downto 0);
signal br_sch_self_tag_out: std_logic_vector(2 downto 0);
begin
memory_instance: memory_code port map
(
clk=>top_clock,
we=>'0',
a=>addr_to_mem,
do=>code_mem,
di=>(others=>'0'));
mux_instance3: bit16_2x1 port map( --used for reset
c_0=>system_reset,
d_0=>next_pc_fetch_in,
d_1=>(others=>'0'),
o=>addr_to_mem
);
mux_instance4: bit1_2x1 port map( --used for invalidating decode
c_0=>decode_invalidate_in,
d_0=>instr1_decode_valid,
d_1=>'0',
o=>instr1_RS_valid_in
);
mux_instance5: bit1_2x1 port map( --used for invalidating decode
c_0=>decode_invalidate_in,
d_0=>instr2_decode_valid,
d_1=>'0',
o=>instr2_RS_valid_in
);
add_instance1:add_pc port map(
PC_in=>fetch_pc_out,
PC_out=>fetch_PC_plus_two
);
mux_instance1: bit16_2x1 port map( --used to choose between predicted reisters and branch address
c_0=>control_to_jmp,
d_0=>fetch_PC_plus_two,
d_1=>branch_predicted,
o=>next_branch_fetch
);
mux_instance2: bit16_2x1 port map( --used for misprediction correction
c_0=>branch_mis_predicted,
d_0=>next_branch_fetch,
d_1=>addr_exec,
o=>next_pc_fetch_in
);
fetch_instance:fetch port map(
clk=>top_clock,