-
Notifications
You must be signed in to change notification settings - Fork 0
/
Control.java
89 lines (72 loc) · 1.38 KB
/
Control.java
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
public class Control {
/*
* Each control line, including
* RegDist,
* Branch,
* MemRead,
* MemtoReg,
* ALUOp,
* MemWrite,
* ALUSrc, and
* RegWrite
* must be implemented as a distinct Boolean variable.
*/
private boolean RegDist;
private boolean Branch;
private boolean MemRead;
private boolean MemtoReg;
private boolean ALUOp1;
private boolean ALUOp0;
private boolean MemWrite;
private boolean ALUsrc;
private boolean RegWrite;
public Control(InstructionDecode decode) {
String opcode = decode.getOpcode();
if(opcode.compareTo("000000")==0) {
RegDist = true;
RegWrite = true;
ALUOp1 = true;
}
else if(opcode.compareTo("100011")==0) {
MemRead = true;
MemtoReg = true;
RegWrite = true;
ALUsrc = true;
}
else if(opcode.compareTo("101011")==0) {
MemWrite = true;
ALUsrc = true;
}
else if(opcode.compareTo("000111")==0) {
Branch = true;
ALUOp0 = true;
}
}
public boolean isRegDist() {
return RegDist;
}
public boolean isBranch() {
return Branch;
}
public boolean isMemRead() {
return MemRead;
}
public boolean isMemtoReg() {
return MemtoReg;
}
public boolean isALUOp1() {
return ALUOp1;
}
public boolean isALUOp0() {
return ALUOp0;
}
public boolean isMemWrite() {
return MemWrite;
}
public boolean isALUsrc() {
return ALUsrc;
}
public boolean isRegWrite() {
return RegWrite;
}
}