Title: Multicycle Datapath
1 2Single Cycle Review
3Instruction Flow
- What are some of the main steps in the
instruction execution? (refer to previous slide) - Is this an efficient use of hardware? Why or why
not? - Do we really need 2 adders?
4Multicycle Implementation
- Key elements (How many cycles is this? What are
they?)
5Examples
- add 1,2,3
- lw 2,10(3)
- sw 2,10(3)
- beq 7,8,40
- j 0x2ABCDEF
We will be ignoring the control signals for now!
6add 1,2,3
1.
2.
3.
4.
IR MemPC PC PC 4
A 1st Reg Src B 2nd Reg Src
ALUout A B
Rdest ALUOut
4 clock cycles for an ADD
7lw 2,10(3)
1.
2.
3.
4.
5.
IR MemPC PC PC 4
A Addr Reg Src
ALUout A Imm.
MDR MemALUOut
Rdest MDR
5 clock cycles for a Load Word
8sw 2,10(3)
1.
2.
3.
4.
IR MemPC PC PC 4
A Addr Reg Src B Store Reg Src
ALUout A Imm.
MemALUOut B
4 clock cycles for a Load Word
9beq 7,8,40
1.
2.
3.
4.
IR MemPC PC PC 4
A 1st Reg Src B 2nd Reg Src
if (AB) ? PC ALUOut
3 clock cycles for a Branch Equal
10j 0x2ABCDEF
1.
2.
3.
4.
IR MemPC PC PC 4
Decode Jump 1
PC PC31-28 (IR25-0ltlt2
3 clock cycles for a Jump
11CPI Revisited
- Now you see why we have such a thing as effective
CPI. - Different instruction types have different time
requirements. - And we havent even talked about floating-point
instructions yet!
12Multicycle in MIPS (basic, w/o JUMP)
13Instruction Steps
- Instruction fetch (IF)
- Instruction decode and register fetch (ID/RF)
- Execution, EA Comp., or Branch Completion (EX)
- Memory access or R-type completion (MEM/WB)
- Memory read completion (WB)
141. IF
- Hardware
- Instruction Memory
- PC Adder
- Instruction Register
- Operation
- IR MemoryPC
- PC PC 4
15Complete Multicycle Datapath (IF)
162. ID/RF
- Operation
- A RegIR25-21
- B RegIR20-16
- ALUOut PC (sign-extend (IR15-0 ltlt 2
- Hardware
- Instruction Register
- Register File
- Registers A B
- Sign Extension
- Shift by 2
- ALU ALUOut
17Complete Multicycle Datapath (ID/RF)
183. EX
- Operation
- Memory reference
- ALUOut A sign-extend (IR15-0)
- Arithmetic/Logic
- ALUOut A op B
- Branch
- if (AB) then PC ALUOut
- Jump
- PC PC31-28 (IR25-0ltlt2)
- Hardware
- ALU
- ALUOut
- PC
- PC Shift
19Complete Multicycle Datapath (EX)
204. MEM ( also R-type WB)
- Operation
- Memory reference
- MDR MemoryALUOut
- or
- MemoryALUOut B
- Arithmetic/Logical
- RegIR15-11 ALUOut
- Hardware
- MDR
- Data memory
- B
- Register File
- ALUOut
R-type WB
21Complete Multicycle Datapath (MEM)
225. WB (memory type)
- Operation
- Load
- RegIR20-16 MDR
- Hardware
- Register file
- MDR
23Complete Multicycle Datapath (WB)
24A Word About Pipelining
- Note the overlap of stages in different types of
instructions - Can we exploit this?
IF ID/RF EX MEM WB
25MC Datapath with Control
26Complete MC Datapath
27Defining the Control
- MC is more complex cuz instruction is executed
in a series of steps - MC datapath must specify both control signals and
next step in sequence. - 2 different techniques for specifying control
- finite state machine
- microprogramming
- Both allow detailed implementation to be
synthesized by a CAD system
28Defining the State Machine
- Consists of a set of states and directions on how
to change states - Each state also specifies a set of output that
are asserted when the machine is in that state. - Each state takes 1 cc
- Initial two states will be common for all
instructions (why?) - Steps 3-5 will differ, depending on instruction
class - FSM will return to initial state to begin next
fetch
29Finite State Machine Control
S
t
a
r
t
I
n
s
t
r
u
c
t
i
o
n
f
e
t
c
h
/
d
e
c
o
d
e
a
n
d
r
e
g
i
s
t
e
r
f
e
t
c
h
(
F
i
g
u
r
e
5
.
3
2
)
M
e
m
o
r
y
a
c
c
e
s
s
R
-
t
y
p
e
i
n
s
t
r
u
c
t
i
o
n
s
B
r
a
n
c
h
i
n
s
t
r
u
c
t
i
o
n
J
u
m
p
i
n
s
t
r
u
c
t
i
o
n
i
n
s
t
r
u
c
t
i
o
n
s
(
F
i
g
u
r
e
5
.
3
4
)
(
F
i
g
u
r
e
5
.
3
5
)
(
F
i
g
u
r
e
5
.
3
6
)
(
F
i
g
u
r
e
5
.
3
3
)
30FSM Diagram for IF ID/RF
31Multicycle Datapath
32(No Transcript)
33(No Transcript)
34(No Transcript)
35S
t
a
r
t
I
n
s
t
r
u
c
t
i
o
n
f
e
t
c
h
/
d
e
c
o
d
e
a
n
d
r
e
g
i
s
t
e
r
f
e
t
c
h
(
F
i
g
u
r
e
5
.
3
7
)
M
e
m
o
r
y
a
c
c
e
s
s
R
-
t
y
p
e
i
n
s
t
r
u
c
t
i
o
n
s
B
r
a
n
c
h
i
n
s
t
r
u
c
t
i
o
n
J
u
m
p
i
n
s
t
r
u
c
t
i
o
n
i
n
s
t
r
u
c
t
i
o
n
s
(
F
i
g
u
r
e
5
.
3
9
)
(
F
i
g
u
r
e
5
.
4
0
)
(
F
i
g
u
r
e
5
.
4
1
)
(
F
i
g
u
r
e
5
.
3
8
)
36(No Transcript)
37(No Transcript)
38(No Transcript)
39Control Block Diagram
Combinational Control logic
outputs inputs
Data path control outputs
Next state
State register
Inputs from instruction register opcode field
40New MC Datapath with Exception Handling
41New States for Exception Handling
IntCause 1 CauseWrite ALUSrcA 0 ALUSrcB
01 ALUOp 01 EPCWrite PCWrite PCSource 11
11
IntCause 0 CauseWrite ALUSrcA 0 ALUSrcB
01 ALUOp 01 EPCWrite PCWrite PC Source 11
10
To state 0 to begin next instruction
42Complete FSM with Exception Handling