Controlling A Pipelined Datapath
Controlling A Pipelined Datapath
Add
Add
Add result
PC
Address
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Read data
1 M u x 0
16
Sign extend
32
Pipeline registers: Intermediate storage Question: how do we determine the width of the registers?
Step-by-step Execution of lw
Instruction Fetch
Step-by-step Execution of lw
Instruction Decode
Instruction Decode
Step-by-step Execution of lw
lw Execution
0 M u x 1
IF/ID
Add
ID/EX
EX/MEM
MEM/WB
4 Shift left 2
Add
Add result
Instruction
PC
Read data 1 Read register 2 Registers Read Write data 2 register Write data
Read register 1
0 M u x 1
Read data
1 M u x 0
16
Sign extend
32
Instruction Execution
Step-by-step Execution of lw
Memory Access
Step-by-step Execution of lw
IM
Reg
ALU
DM
Reg
IM
Reg
ALU
DM
Reg
IF/ID
ID/EX
EX/MEM
MEM/WB
Add 4
RegWrite Shift left 2 Add Add result
Branch
Instruction
PC
Read register 1
MemWrite
ALUSrc Zero Zero ALU ALU result
0 M u x 1
Instruction 16 [150]
Sign extend
32
ALU control
MemRead
0 M u x 1
RegDst
ALUOp
10
11
Control
IF/ID
ID/EX
EX/MEM
MEM/WB
All control decisions are made during the instruction decoding and are carried forward across stages in the pipeline.
12
PCSrc
0 M u x 1 Control
ID/EX
WB M EX
EX/MEM
WB M
MEM/WB
WB
IF/ID Add
4
RegWrite
ALUSrc
Instruction
PC
Address
Instruction memory
Read data 1 Read register 2 Registers Read Write data 2 register Write data
0 M u x 1
Read data
Instruction16
Sign extend
32
ALU control
MemRead
Instruction
Instruction
0 M u x 1 RegDst
ALUOp
MemtoReg
1 M u x 0
Read register 1
MemWrite
Shift left 2
Branch
13
Work through the example of the execution of five instructions starting in page 471!
14
15
Time (in clock cycles) CC 1 Value of register $2: 10 Program execution order (in instructions) sub $2, $1, $3 IM Reg DM CC 2 10 CC 3 10 CC 4 10 CC 5 CC 6 CC 7 CC 8 CC 9
Reg
IM
Reg
DM
Reg
or $13, $6, $2
IM
Reg
DM
Reg
IM
Reg
DM
Reg
sw $15, 100($2)
IM
Reg
DM
Reg
16
$2,
$1,
$3
nop
bubble
nop
bubble
and or add sw
17