-
Notifications
You must be signed in to change notification settings - Fork 0
/
CONTROL_UNIT.v
72 lines (53 loc) · 1.74 KB
/
CONTROL_UNIT.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
module CONTROL_UNIT
(
input [3:0] opcode ,
output reg reg_sel ,
output reg alu_src ,
output reg reg_w_enbl ,
output reg br ,
output reg jump ,
output reg m_r_enbl ,
output reg m_w_enbl ,
output reg mem_mux ,
output reg [3:0] to_alu_ctrl
);
always @(opcode)
begin
to_alu_ctrl <= opcode;
if(opcode == 4'b0000)
begin
reg_sel <= 1'b1; alu_src <= 1'b0; reg_w_enbl<= 1'b1; br <= 1'b0;
jump <= 1'b0; m_r_enbl <= 1'b0; m_w_enbl <= 1'b0; mem_mux <= 1'b0;
end
else if(opcode == 4'b0100)
begin
reg_sel <= 1'b1; alu_src <= 1'b1; reg_w_enbl<= 1'b1; br <= 1'b0;
jump <= 1'b0; m_r_enbl <= 1'b0; m_w_enbl <= 1'b0; mem_mux <= 1'b0;
end
else if(opcode == 4'b1011)
begin
reg_sel <= 1'b1; alu_src <= 1'b1; reg_w_enbl<= 1'b1; br <= 1'b0;
jump <= 1'b0; m_r_enbl <= 1'b1; m_w_enbl <= 1'b0; mem_mux <= 1'b1;
end
else if(opcode == 4'b1111)
begin
reg_sel <= 1'b0; alu_src <= 1'b1; reg_w_enbl<= 1'b0; br <= 1'b0;
jump <= 1'b0; m_r_enbl <= 1'b0; m_w_enbl <= 1'b1; mem_mux <= 1'b0;
end
else if(opcode == 4'b1000)
begin
reg_sel <= 1'b0; alu_src <= 1'b0; reg_w_enbl<= 1'b0; br <= 1'b1;
jump <= 1'b0; m_r_enbl <= 1'b0; m_w_enbl <= 1'b0; mem_mux <= 1'b0;
end
else if(opcode == 4'b0010)
begin
reg_sel <= 1'b1; alu_src <= 1'b0; reg_w_enbl<= 1'b0; br <= 1'b0;
jump <= 1'b1; m_r_enbl <= 1'b0; m_w_enbl <= 1'b0; mem_mux <= 1'b0;
end
else
begin
reg_sel <= 1'b0; alu_src <= 1'b0; reg_w_enbl<= 1'b0; br <= 1'b0;
jump <= 1'b0; m_r_enbl <= 1'b0; m_w_enbl <= 1'b0; mem_mux <= 1'b0;
end
end
endmodule