-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCU.vhd
175 lines (169 loc) · 4.07 KB
/
CU.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
-- Praktikum EL3111 Arsitektur Sistem Komputer
-- Modul : 5
-- Percobaan : 1 dan 2
-- Tanggal : 25 November 2021
-- Rombongan : C (tuker dari A)
-- Nama (NIM) : Christian Reivan (13219005)
-- Nama File : CU.vhd
-- Deskripsi : Implementasi blok Control Unit
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
ENTITY cu IS
PORT (
--INPUT
OP_In : IN STD_LOGIC_VECTOR (5 DOWNTO 0);
FUNCT_In : IN STD_LOGIC_VECTOR (5 DOWNTO 0);
--OUTPUT
Sig_Jmp : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
Sig_Bne : OUT STD_LOGIC;
Sig_Branch : OUT STD_LOGIC;
Sig_MemtoReg : OUT STD_LOGIC;
Sig_MemRead : OUT STD_LOGIC;
Sig_MemWrite : OUT STD_LOGIC;
Sig_RegDest : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
Sig_RegWrite : OUT STD_LOGIC;
Sig_ALUSrc : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
Sig_ALUCtrl : OUT STD_LOGIC
);
END cu;
ARCHITECTURE BEHAVIOURAL of cu IS
SIGNAL JUMP: STD_LOGIC_VECTOR (1 DOWNTO 0);
SIGNAL BNE: STD_LOGIC;
SIGNAL BRANCH: STD_LOGIC;
SIGNAL MEMTOREG: STD_LOGIC;
SIGNAL MEMREAD: STD_LOGIC;
SIGNAL MEMWRITE: STD_LOGIC;
SIGNAL REGDEST: STD_LOGIC_VECTOR(1 DOWNTO 0);
SIGNAL REGWRITE: STD_LOGIC;
SIGNAL ALUSRC: STD_LOGIC_VECTOR (1 DOWNTO 0);
SIGNAL ALUCTRL: STD_LOGIC;
BEGIN
--Kombinasional Output
Sig_Jmp <= JUMP;
Sig_Bne <= BNE;
Sig_Branch <= BRANCH;
Sig_MemtoReg <= MEMTOREG;
Sig_MemRead <= MEMREAD;
Sig_MemWrite <= MEMWRITE;
Sig_RegDest <= REGDEST;
Sig_RegWrite <= REGWRITE;
Sig_ALUSrc <= ALUSRC;
Sig_ALUCtrl <= ALUCTRL;
--Generate Sinyal Kontrol
CONTROL:
PROCESS(OP_In, FUNCT_In)
BEGIN
IF ((OP_In = "000000") AND (FUNCT_In = "100000")) THEN --add
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "01";
REGWRITE <= '1';
ALUSRC <= "00";
ALUCTRL <= '0';
ELSIF ((OP_In = "000000") AND (FUNCT_In = "100010")) THEN --sub
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "01";
REGWRITE <= '1';
ALUSRC <= "00";
ALUCTRL <= '1';
ELSIF ((OP_In = "000100")) THEN --beq
JUMP <= "00";
BNE <= '0';
BRANCH <= '1';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "--";
REGWRITE <= '0';
ALUSRC <= "--";
ALUCTRL <= '-';
ELSIF ((OP_In = "000101")) THEN --bne
JUMP <= "00";
BNE <= '1';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "--";
REGWRITE <= '0';
ALUSRC <= "--";
ALUCTRL <= '-';
ELSIF ((OP_In = "001000")) THEN --addi
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "00";
REGWRITE <= '1';
ALUSRC <= "01";
ALUCTRL <= '0';
ELSIF ((OP_In = "100011")) THEN --lw
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '1';
MEMREAD <= '1';
MEMWRITE <= '0';
REGDEST <= "00";
REGWRITE <= '1';
ALUSRC <= "01";
ALUCTRL <= '0';
ELSIF ((OP_In = "101011")) THEN --sw
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '1';
REGDEST <= "00";
REGWRITE <= '0';
ALUSRC <= "01";
ALUCTRL <= '0';
ELSIF ((OP_In = "000010")) THEN --jmp
JUMP <= "01";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "--";
REGWRITE <= '0';
ALUSRC <= "--";
ALUCTRL <= '-';
ELSIF ((OP_In = "000000")) THEN --nop
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "00";
REGWRITE <= '0';
ALUSRC <= "00";
ALUCTRL <= '0';
ELSE --SUPAYA TIDAK ADA LATCH
JUMP <= "00";
BNE <= '0';
BRANCH <= '0';
MEMTOREG <= '0';
MEMREAD <= '0';
MEMWRITE <= '0';
REGDEST <= "00";
REGWRITE <= '0';
ALUSRC <= "00";
ALUCTRL <= '0';
END IF;
END PROCESS CONTROL;
END BEHAVIOURAL;