-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathControlUnit.v
More file actions
80 lines (76 loc) · 1.51 KB
/
ControlUnit.v
File metadata and controls
80 lines (76 loc) · 1.51 KB
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
module ControlUnit(
input [10:0] controlInstruction_in,
output reg reg2Loc,
output reg ALUsrc,
output reg memtoReg,
output reg regWrite,
output reg memRead,
output reg memWrite,
output reg branch,
output reg [1:0] ALUop
);
always @(*) begin
if (controlInstruction_in[10:5] == 6'b000101) begin // Control bits for B
reg2Loc = 0;
ALUsrc = 0;
memtoReg = 0;
regWrite = 0;
memRead = 0;
memWrite = 0;
branch = 0;
ALUop = 01;
end else if (controlInstruction_in[10:3] == 8'b10110100) begin // Control bits for CBZ
reg2Loc = 1;
ALUsrc = 0;
memtoReg = 0;
regWrite = 0;
memRead = 0;
memWrite = 0;
branch = 1;
ALUop = 01;
end else case(controlInstruction_in)
'b11111000010: begin //Load
reg2Loc = 1;
ALUsrc = 1;
memtoReg = 1;
regWrite = 1;
memRead = 1;
memWrite = 0;
branch = 0;
ALUop = 00;
end
'b11111000000: begin //Store
reg2Loc = 1;
ALUsrc = 1;
regWrite = 0;
memRead = 0;
memWrite = 1;
branch = 0;
ALUop = 00;
end
'b10001011000,
'b11001011000,
'b10001010000,
'b10101010000: begin //R-Type (ADD, SUB, AND, ORR)
reg2Loc = 0;
ALUsrc = 0;
memtoReg = 0;
regWrite = 1;
memRead = 0;
memWrite = 0;
branch = 0;
ALUop = 10;
end
default: begin
reg2Loc = 1'h0;
ALUsrc = 1'h0;
memtoReg = 1'h0;
regWrite = 1'h0;
memRead = 1'h0;
memWrite = 1'h0;
branch = 1'h0;
ALUop = 2'h0;
end
endcase
end
endmodule