-
Notifications
You must be signed in to change notification settings - Fork 0
/
control_unit.v
72 lines (67 loc) · 942 Bytes
/
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
`timescale 1ns / 1ps
module control_unit(
input [1:0] if_opcode,
input [1:0] id_opcode,
input [1:0] ex_opcode,
output reg writeReg,
output reg exe_ctrl,
output reg pc_jump_sel
);
always @ (*)
begin
case(id_opcode)
2'b00:
begin
exe_ctrl = 0;
end
2'b01:
begin
exe_ctrl = 1;
end
2'b11:
begin
exe_ctrl = 0;
end
default:
begin
exe_ctrl = 0;
end
endcase
case(ex_opcode)
2'b00:
begin
writeReg = 1;
end
2'b01:
begin
writeReg = 1;
end
2'b11:
begin
writeReg = 0;
end
default:
begin
writeReg = 1;
end
endcase
case(if_opcode)
2'b00:
begin
pc_jump_sel = 0;
end
2'b01:
begin
pc_jump_sel = 0;
end
2'b11:
begin
pc_jump_sel = 1;
end
default:
begin
pc_jump_sel = 0;
end
endcase
end
endmodule