Lecture 6
Lecture 6
Lecture 6
1
RISC/CISC Loads/Stores
RR ALU DM RW
3
Problem 4
• For the following code sequence, show how the instrs
flow through the pipeline:
ADD R3 R1, R2
LD R7 8[R6]
ST R9 4[R8]
BEZ R4, [R5]
4
Problem 4
• For the following code sequence, show how the instrs
flow through the pipeline:
ADD R3 R1, R2
LD R7 8[R6]
ST R9 4[R8]
BEZ R4, [R5]
ST ST ST ST
BEZ BEZ
5
Hazards
6
Structural Hazards
7
Problem 5
• Show the instruction occupying each stage in each cycle (no bypassing)
if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R7+R8R9
CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8
IF IF IF IF IF IF IF IF
DM DM DM DM DM DM DM DM
RW RW RW RW RW RW RW RW 8
Problem 5
• Show the instruction occupying each stage in each cycle (no bypassing)
if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R7+R8R9
CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8
IF IF IF IF IF IF IF IF
I1 I2 I3 I3 I3 I4 I5
D/R D/R D/R D/R D/R D/R D/R D/R
I1 I2 I2 I2 I3 I4
ALU ALU ALU ALU ALU ALU ALU ALU
I1 I2 I3
DM DM DM DM DM DM DM DM
I1 I2 I3
RW RW RW RW RW RW RW RW 9
I1 I2
Bypassing: 5-Stage Pipeline
PC/L1 L2 L3 L4 L5
10
Source: H&P textbook
Problem 6
• Show the instruction occupying each stage in each cycle (with bypassing)
if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R3+R8R9.
Identify the input latch for each input operand.
CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8
IF IF IF IF IF IF IF IF
DM DM DM DM DM DM DM DM
RW RW RW RW RW RW RW RW 11
Problem 6
• Show the instruction occupying each stage in each cycle (with bypassing)
if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R3+R8R9.
Identify the input latch for each input operand.
CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8
IF IF IF IF IF IF IF IF
I1 I2 I3 I4 I5
D/R D/R D/R D/R D/R D/R D/R D/R
I1 I2 I3 I4
L3 L3 L4 L3 L5 L3
ALU ALU ALU ALU ALU ALU ALU ALU
I1 I2 I3
DM DM DM DM DM DM DM DM
I1 I2 I3
RW RW RW RW RW RW RW RW
I1 I2 I3
Pipeline Implementation
• Signals for the muxes have to be generated – some of this can happen during ID
• Need look-up tables in decode stage to identify situations that merit bypassing/stalling
– the number of inputs to the muxes goes up
13
Problem 7
ADD R3 R1+R2
ADD R5 R3+R4
LD R2 [R1]
ADD R4 R2+R3
LD R2 [R1]
SD R3 [R2]
LD R2 [R1]
SD R2 [R3]
14
Problem 7
ADD R3 R1+R2
ADD R5 R3+R4 without: 2 with: 0
LD R2 [R1]
ADD R4 R2+R3 without: 2 with: 1
LD R2 [R1]
SD R3 [R2] without: 2 with: 1
LD R2 [R1]
SD R2 [R3] without: 2 with: 0
15
Summary
lw R1, 8(R2)
sw R1, 4(R3)