lw 1 402 add 2 3 3 add 1 1 2 sw 1 202 a Find all data depenc
lw $1, 40($2)
add $2, $3, $3
add $1, $1, $2
sw $1, 20($2)
a) Find all data depencies in this instruction sequence.
b) Find all hazards in this instruction sequence for a five-stage pipeline with and then without forwarding.
c) To reduce clock cycle time, we are considering a split of the MEM stage into two stages. Repeat (b) for this six-stage pipeline.
Solution
A)
Instruction sequence RAW WAR WAW
L1: lw $1, 40($2) ($1) L1 to L3 ($2) L1 to L2 ($1)L1 to L3
L2: add $2, $3, $3 ($2) L2 to L3, L4
L3: add $1, $1, $2 ($1) L3 to L4
L4: sw $1, 20($2)
B)
Instruction sequence without forwarding
L1: lw $1, 40($2) ($1) L1 to L3
L2: add $2, $3, $3 ($2) L2 to L3, L4
L3: add $1, $1, $2 ($1) L3 to L4
L4: sw $1, 20($2)
Without forwarding
Instructions Pipeline stage
lw $1, 40($6) IF ID EX MEM WB
add $2, $3, $3 IF ID EX MEM WB
nop IF ID EX MEM WB
nop IF ID EX MEM WB
add $1, $1, $2 IF ID EX MEM WB
nop IF ID EX MEM WB
nop IF ID EX MEM WB
sw $1, 20($2 IF ID EX MEM WB
With forwarding
Instructions Pipeline stage
lw $1, 40($6) IF ID EX MEM WB
add $2, $3, $3 IF ID EX MEM WB
add $1, $1, $2 IF ID EX MEM WB
sw $1, 20($2) IF ID EX MEM WB
C)
Instruction sequence without forwarding with forwarding
L1: lw $1, 40($2) ($1) L1 to L3 ($1) L1 to L3
L2: add $2, $3, $3 ($2) L2 to L3, L4
L3: add $1, $1, $2 ($1) L3 to L4
L4: sw $1, 20($2)

