Title: (1) FETCH = ??? ????? ???????? ?"? ?????? ????? ?-PC.
1???? ????? ????? ?????
- (1) FETCH ??? ????? ???????? ?"? ?????? ?????
?-PC. - (2) DECODE ???? ?? ?????? ???? ?? ???????
??????? (??? ?? ?????). - (3) EXECUTE ????? ?-ALU ??? ?? ??????, ?? ?????
?????. - (4) MEMORY ????? ?????? ???? ????? ????? ??
????? ??????? (Store) ?? ????? ???????? (Load). - (5) WRITE BACK ??? ????? ????? ????? ?????.
2 ???? ?? ????? ????? ?????? ???? ????? ??????
???? ????? - ??????? ?? ?? ?????, ?? ????? ????
???? ???????? ?? ???? ????? (?? ????)
3MIPS ????? ????? ?? ????
???????? ???????? ?????? ??? ???? ?????? R-type
?- I-type ??? ????? ??????? add, sub, or, xor,
and, slt, lw, sw, beq, j ????? ?????? ???? ????
??????? ?????? ?????? ??? ???? bne, addi, jal,
jr
4??? ????? ??????
5 ????? ?????? ?? ????? ??????? ???? ?-fetch
Instruction
Address
Instruction
Instruction
Memory
Sum
Add
????? ????? ?????? ?????? , ?????? ??????
?????? ??? adder ????? ?????? ????
6FETCH -??? ?
Add
4
4
PC
Read
address
Instruction
Instruction
memory
7A CPU capable of R-type instructions only
4
Adder
6
3126
Instruction Memory
PC
6
50funct
8????? ?????????. ????? ?? ????? ????
?-decode(????? ?-write back)
Read
register
1
Read
data
1
Read
2
????? ???????
register
Registers
Write
Read
register
data
2
Write
Data
Data
9Arithmetic Logic operation
ALU operation
Read
ALU operation
register
1
Read
data
1
Zero
Read
register
2
Instruction
Registers
ALU
Write
ALU
register
Read
result
data
2
ALU
Write
Data
?????? ??????? ?????? ??? ????? R-type
10A CPU capable of R-type instructions only
4
Adder
6
3126
Reg File
Instruction Memory
PC
ALU
6
50funct
11A CPU capable of R-type instructions only
4
Adder
6
3126
Reg File
Instruction Memory
PC
ALU
6
50funct
12The internal structure of the Register File
Rd reg 1 ( Rs)
32
5
32
32
32
32
Read data 1
write data
32
32
32
Rd reg 2 ( Rt)
5
32
32
32
Read data 2
32
32
Wr reg ( Rd)
5
E
RegWrite
?????? ???? ??????? ??????? ????? ?? ??? ????????
????? ?????? ???? ????????? ?????? (?????? ?????
????)
13A CPU capable of R-type instructions only
4
Adder
6
3126
RegWrite
Reg File
Instruction Memory
PC
ALU
14A CPU capable of R-type instructions only
Instruction Memory
Reg File
PC
ALU
15A CPU capable of R-type instructions only
4
Instruction Memory
Reg File
ALU
PC
16A CPU capable of R-type instructions only
4
Adder
6
3126
RegWrite
6
50funct
ALU control
Reg File
Instruction Memory
PC
ALU
17Load,Store ????? ??????
Write
Read
address
Read
data
Write
address
Data
Write
memory
data
Read
??? ???? ?????? ?- data ???? ???? ????? ????? ???
?? ?? ???? sign extension ?? ?- imm ???? ?? 16bit
18A CPU capable of lw instructions only
4
Adder
6
3126
add
RegWrite1
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
D. Out
5
16
150
Sext 16-gt32
19A CPU capable of lw instructions only
4
Adder
6
3126
add
RegWrite1
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
D. Out
5
16
150
Sext 16-gt32
20A CPU capable of lw instructions only
4
Adder
6
3126
add
RegWrite1
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
D. Out
5
16
150
Sext 16-gt32
21A CPU capable of lw sw instructions only
4
MeWrite1
Adder
6
3126
add
RegWrite0
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
5
D.In
16
150
Sext 16-gt32
22A CPU capable of R-type lw instructions
(principle)
4
Adder
6
3126
add
RegWrite
6
50funct
ALU control
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
5
16
150
Sext 16-gt32
23A CPU capable of R-type lw instructions
4
Adder
6
3126
add
RegWrite
6
50funct
ALU control
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
D. Out
5
Rd
16
150
Sext 16-gt32
24A CPU capable of R-type lw/sw instructions
4
MemWrite
Adder
6
3126
add
RegWrite
6
50funct
ALU control
Reg File
Data Memory
Instruction Memory
PC
ALU
Address
D. Out
5
Rd
D.In
16
150
Sext 16-gt32
25Branch ??????? ?????? ??????
PC4 ???? ?- Fetch
Adder
In addresses, we always shift left by two bits
Sum
Shift
Branch
Read
left
2
Target
register
1
Read
Read
data
1
register
2
Registers
Write
Instruction
Zero
register
?????
ALU
Read
Write
data
2
??????
Data
?????
??????
16
32
Sigh
??????
Extend
??
???????
26????? ?? ???????
M
u
x
Add
4
ADD
Write
PC
Read
Zero
data
1
Instruction
Read
ALU
data
2
Data
memory
Read
16
32
27???? ?- CPU?
Instruction Memory
CPU
PC
Data Memory
28???? ????
P
C
S
r
c
M
u
Add
A
d
d
x
ALU result
4
Shift left 2
R
e
g
i
s
t
e
r
s
A
L
U
o
p
e
r
a
t
i
o
n
R
e
a
d
3
M
e
m
W
r
i
t
e
R
e
a
d
r
e
g
i
s
t
e
r
1
A
L
U
S
r
c
P
C
R
e
a
d
a
d
d
r
e
s
s
R
e
a
d
d
a
t
a
1
M
e
m
t
o
R
e
g
r
e
g
i
s
t
e
r
2
Z
e
r
o
I
n
s
t
r
u
c
t
i
o
n
A
L
U
A
L
U
W
r
i
t
e
R
e
a
d
R
e
a
d
A
d
d
r
e
s
s
r
e
g
i
s
t
e
r
r
e
s
u
l
t
d
a
t
a
2
M
d
a
t
a
I
n
s
t
r
u
c
t
i
o
n
M
u
W
r
i
t
e
u
m
e
m
o
r
y
x
D
a
t
a
x
d
a
t
a
m
e
m
o
r
y
W
r
i
t
e
R
e
g
W
r
i
t
e
d
a
t
a
1
6
3
2
S
i
g
n
M
e
m
R
e
a
d
e
x
t
e
n
d
29Control
A
d
d
S
h
i
f
t
l
e
f
t
2
R
B
r
a
n
c
h
M
e
m
R
e
a
d
M
e
m
t
o
R
e
g
A
L
U
O
p
M
e
m
W
r
i
t
e
R
e
g
W
r
i
t
e
I
n
s
t
r
u
c
t
i
o
n
2
5
2
1
R
e
a
d
P
C
a
d
d
r
e
s
s
I
n
s
t
r
u
c
t
i
o
n
2
0
1
6
Z
e
r
o
r
e
g
i
s
t
e
r
2
I
n
s
t
r
u
c
t
i
o
n
A
L
U
A
L
U
3
1
0
R
e
a
d
r
e
s
u
l
t
1
A
d
d
r
e
s
s
d
a
t
a
I
n
s
t
r
u
c
t
i
o
n
M
M
u
m
e
m
o
r
y
u
I
n
s
t
r
u
c
t
i
o
n
1
5
1
1
x
D
a
t
a
x
1
m
e
m
o
r
y
W
r
i
t
e
d
a
t
a
S
i
g
n
e
x
t
e
n
d
A
L
U
c
o
n
t
r
o
l
I
n
s
t
r
u
c
t
i
o
n
5
0
30Control
31ALU control
ALU control output000 AND001 OR010 add110 s
ubtract111 set-on-less-than (sign of rs-rt
-gt rd)
00 lw, sw01 beq, 10 arithmetic
ALUop
32????? ?- jump
????? ?????? J 101101111011
?????? ???? ????? ?????? 1111110111001
4 bits 26 bits 2 bits
????? ????? ??????
101 101111011
????? ????? ?????
00
101 101111011
0110
101 101111011
????? 4 ????? ???????
00
101 101111011
0110
?????? ??????
33Jump
S
h
i
f
t
l
e
f
t
2
2
6
2
8
0
M
u
x
1
0
s
u
l
t
A
d
d
S
h
i
f
t
R
e
g
D
s
t
l
e
f
t
2
J
u
m
p
B
r
a
n
c
h
M
e
m
R
e
a
d
I
M
e
m
t
o
R
e
g
A
L
U
O
p
M
e
m
W
r
i
t
e
A
L
U
S
r
c
R
e
g
W
r
i
t
e
I
n
s
t
r
u
c
t
i
o
n
2
5
2
1
R
e
a
d
R
e
a
d
r
e
g
i
s
t
e
r
1
P
C
R
e
a
d
a
d
d
r
e
s
s
d
a
t
a
1
I
n
s
t
r
u
c
t
i
o
n
2
0
1
6
R
e
a
d
Z
e
r
o
r
e
g
i
s
t
e
r
2
I
n
s
t
r
u
c
t
i
o
n
R
e
g
i
s
t
e
r
s
A
L
U
R
e
a
d
A
L
U
3
1
0
R
e
a
d
W
r
i
t
e
d
a
t
a
2
r
e
s
u
l
t
A
d
d
r
e
s
s
d
a
t
a
I
n
s
t
r
u
c
t
i
o
n
r
e
g
i
s
t
e
r
m
e
m
o
r
y
I
n
s
t
r
u
c
t
i
o
n
1
5
1
1
W
r
i
t
e
D
a
t
a
d
a
t
a
m
e
m
o
r
y
W
r
i
t
e
d
a
t
a
I
n
s
t
r
u
c
t
i
o
n
5
0