-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlUnit.v
74 lines (63 loc) · 1.64 KB
/
ControlUnit.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
73
74
module control_unit (
output reg RegRead,
RegWrite,
MemRead,
MemWrite,
Branch,
input [5:0] opcode,
input [8:0] xoxo,
input [9:0] xox,
input [1:0] xods
);
always @(opcode, xoxo, xox, xods)
begin
//RESET TO 0
MemRead = 1'b0;
MemWrite = 1'b0;
RegWrite = 1'b0;
RegRead = 1'b0;
Branch = 1'b0;
//XO
if(opcode == 6'd31 & xoxo != 0)
begin
RegRead = 1'b1;
RegWrite = 1'b1;
end
//X
else if(opcode == 6'd31 & xox != 0) //X
begin
RegRead = 1'b1;
RegWrite = 1'b1;
end
//D-ALU Instructions
else if(opcode == 6'd14 | opcode == 6'd15 | opcode == 6'd28 |opcode == 6'd24 |opcode == 6'd26) //D-ALU instructions
begin
RegRead = 1'b1;
RegWrite = 1'b1;
end
//D-Load Instructions
else if(opcode == 6'd32 |opcode == 6'd40 | opcode == 6'd42 |opcode == 6'd34 | opcode == 6'd58)
begin
RegRead = 1'b1;
RegWrite = 1'b1;
MemRead = 1'b1;
end
//D-Store Instructions
else if(opcode == 6'd36 | opcode == 6'd37 | opcode == 6'd44 | opcode == 6'd38 | opcode == 6'd62)
begin
RegRead = 1'b1;
MemWrite = 1'b1;
end
//Unconditional Branch
else if(opcode == 6'd18)
begin
Branch = 1'b1;
end
//Conditional Branch
else if(opcode == 6'd19)
begin
RegRead = 1'b1;
Branch = 1'b1;
end
end
endmodule