Title: The Multicycle Processor CPSC 321
1The Multicycle ProcessorCPSC 321
2Administrative Issues
- Midterm is on October 12
- Allen Parishs help session Friday 1015-1215
- Project 1 has been release work in a team
3Questions? Problems?
4Todays Menu
5Recall Marrying two Datapaths
What kind of instructions can be realized by
these datapaths?
6Datapaths for Instruction Fetch, Memory and
R-type Instructions
A
L
U
o
p
e
r
a
t
i
o
n
A
L
U
o
p
e
r
a
t
i
o
n
3
3
M
e
m
W
r
i
t
e
M
e
m
W
r
i
t
e
M
e
m
t
o
R
e
g
M
e
m
t
o
R
e
g
A
L
U
S
r
c
A
L
U
S
r
c
Z
e
r
o
Z
e
r
o
A
L
U
o
p
e
r
a
t
i
o
n
3
A
L
U
A
L
U
A
L
U
A
L
U
r
e
s
u
l
t
A
d
d
r
e
s
s
r
e
s
u
l
t
A
d
d
r
e
s
s
M
e
m
W
r
i
t
e
M
e
m
t
o
R
e
g
A
L
U
S
r
c
Z
e
r
o
A
L
U
A
L
U
r
e
s
u
l
t
A
d
d
r
e
s
s
R
e
g
W
r
i
t
e
R
e
g
W
r
i
t
e
M
e
m
R
e
a
d
M
e
m
R
e
a
d
x
t
e
n
d
x
t
e
n
d
R
e
g
W
r
i
t
e
M
e
m
R
e
a
d
x
t
e
n
d
Note the added multiplexor switching between
register 2 and sign-extended immediate value
7Datapath for MIPS instructions
8Control
We get the control signals from bits 31-26 and 5-0
9Multicycle Approach
- Single memory unit for instructions and data
- Single arithmetic-logical unit
- Registers after every major unit
- (some visible to the programmer, some not)
- hold output of that unit until value is used in
next clock cycle - data used in subsequent instructions must be
stored in programmer visible registers
10Multicycle Datapath
11Additional Internal Registers
- Instruction and memory data register
- both memory and instruction registers are used
because both values are needed - A and B registers
- hold register operands
- ALUout register
- holds output of ALU
12Five Execution Steps
- Instruction Fetch
- Instruction Decode and Register Fetch
- Execution, Memory Address Computation, or Branch
Completion - Memory Access or R-type instruction completion
- Write-back stepINSTRUCTIONS TAKE FROM 3 - 5
CYCLES!
13Step 1 Instruction Fetch
- Use PC to get instruction and put it in the
Instruction Register. - PC PC 4
- RTL "Register-Transfer Language" IR
MemoryPC PC PC 4What is the advantage
of updating the PC now?
14Step 2 Instruction Decode and Register Fetch
- Read registers rs and rt in case we need them
- Compute the branch address in case the
instruction is a branch - RTL
- A RegIR25-21B RegIR20-16ALUOut
PC(sign-extended(IR15-0)ltlt2) - No control lines based on the instruction type
are set b/c control logic busy "decoding".
15Step 3 (Instruction Dependent)
- ALU performs one of three functions, based on
instruction type - Memory Reference
- ALUOutAsign-extend(IR15-0)
- R-type ALUOut A op B
- Branch if (AB) PC ALUOut
16Step 4 (R-type or memory-access)
- Loads and stores access memory
- MDR MemoryALUOut
- or MemoryALUOut B
- R-type instructions finish RegIR15-11
ALUOutThe write actually takes place at the
end of the cycle on the edge
17Step 5 Write-back step
- Load operations
- RegIR20-16 MDR
- What about all the other instructions?
18Summary
19Clock Cycles per Instruction
- R-type
- 4 clock cycles
- Memory reference instructions
- 5 clock cycles
- Branches
- 3 clock cycles
- Jumps
- 3 clock cycles
20Questions
- How many cycles will it take to execute this
code? lw t2, 0(t3) lw t3, 4(t3) beq
t2, t3, Label assume not add t5, t2,
t3 sw t5, 8(t3)Label ... - What is going on during the 8th cycle of
execution? - In what cycle does the actual addition of t2 and
t3 takes place? -
21MIPS Multicycle Datapath
- Incomplete (branch and jumps)
22Control
- What are the control signals?
- Finite state machine control
- Instruction fetch
- instruction decode
- memory reference
- R-type
- branch
- jump
23Multicycle Datapath and Control Lines
24(No Transcript)
25Outlook
- What happens precisely during each step of
fetch/decode/execute cycles - Construct the finite state control machine
- High-level view
26Instruction Fetch/Decode/Execute
27(No Transcript)
28(No Transcript)
29(No Transcript)
30(No Transcript)
31(No Transcript)
32Finite State Machines
33Instruction Fetch Decode FSM
34Memory-Reference FSM
- Address calculation
- Load sequence
- read from memory
- store to register
- Access memory
- Store sequence write
35R-type Instruction
- Execution of instruction
- Completion of instruction
36Branch Instruction
37Implementation of FSM
- A FSM can be implemented by a register holding
the state and a block of combinatorial logic - Task of the combinatorial logic
- Assert appropriate signals
- Generate the new state to be stored in the
register