FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CA-Cache-processor/src/hardware/ControlUnit.java at master · Th3Hunger/CA-Cache-processor · GitHub
Th3Hunger
CA-Cache-processor
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CA-Cache-processor
/
src
/
hardware
/
ControlUnit.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
133 lines (127 loc) · 2.98 KB
Breadcrumbs
CA-Cache-processor
/
src
/
hardware
/
ControlUnit.java
Copy path
File metadata and controls
133 lines (127 loc) · 2.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package
hardware
;
/**
* RegDst,Branch,MemRead,MemtoReg,ALUOP,MemWrite,ALUSrc,RegWrite // 8
*
*
*/
public
class
ControlUnit
{
public
static
String
Branch
=
""
;
public
static
String
MemRead
=
""
;
public
static
String
MemtoReg
=
""
;
public
static
String
MemWrite
=
""
;
public
static
String
ALUOP
=
""
;
public
static
String
ALUSrc
=
""
;
public
static
String
RegWrite
=
""
;
public
static
String
Jump
=
"0"
;
public
static
String
ALUCONT_OP
=
""
;
// control to be passed to ALU;
public
static
void
MainControl
(
String
flag
,
String
opcode
) {
// Op or funct
if
(
flag
.
equalsIgnoreCase
(
"0"
)) {
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"0"
;
MemtoReg
=
"0"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000000"
)) {
// ADD
ALUOP
=
"000"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000001"
)) {
ALUOP
=
"001"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000010"
)) {
ALUOP
=
"010"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000011"
)) {
ALUOP
=
"011"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000100"
)) {
ALUOP
=
"100"
;
}
}
else
if
(
flag
.
equalsIgnoreCase
(
"1"
)) {
// funct
if
(
opcode
.
equalsIgnoreCase
(
"00000"
)) {
// lw
ALUOP
=
"000"
;
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"1"
;
MemtoReg
=
"1"
;
MemWrite
=
"0"
;
MemRead
=
"1"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00001"
)) {
// sw
ALUOP
=
"000"
;
RegWrite
=
"0"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"1"
;
MemtoReg
=
"X"
;
MemWrite
=
"1"
;
// changed
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00010"
)) {
ALUOP
=
"000"
;
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"1"
;
MemtoReg
=
"0"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00011"
)) {
ALUOP
=
"101"
;
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"1"
;
MemtoReg
=
"0"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00100"
)) {
ALUOP
=
"001"
;
RegWrite
=
"0"
;
Jump
=
"0"
;
Branch
=
"1"
;
ALUSrc
=
"0"
;
MemtoReg
=
"X"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00101"
)) {
ALUOP
=
"100"
;
RegWrite
=
"0"
;
Jump
=
"0"
;
Branch
=
"1"
;
ALUSrc
=
"0"
;
MemtoReg
=
"X"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"00110"
)) {
ALUOP
=
"XXX"
;
RegWrite
=
"0"
;
Jump
=
"1"
;
Branch
=
"0"
;
ALUSrc
=
"X"
;
MemtoReg
=
"X"
;
MemWrite
=
"X"
;
MemRead
=
"X"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000000111"
)) {
ALUOP
=
"110"
;
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"0"
;
MemtoReg
=
"0"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
else
if
(
opcode
.
equalsIgnoreCase
(
"0000000000001000"
)) {
ALUOP
=
"111"
;
RegWrite
=
"1"
;
Jump
=
"0"
;
Branch
=
"0"
;
ALUSrc
=
"0"
;
MemtoReg
=
"0"
;
MemWrite
=
"0"
;
MemRead
=
"0"
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL