Tom Kelliher, CS 240
Apr. 12, 2004
Read 6.8--9.
Pipeline control exercise.
Superscalar execution.
Consider the code segment:
sub $2, $1, $3
and $12, $2, $5
or $13, $6, $2
add $14, $2, $2
sw $15, 100($2)
What are the dependencies?
What will happen during execution?
Dependencies must be resolved for correct execution.

What can we do to fix this? What are our options? (Stall, forwarding hardware, compiler) Cost, benefits?

Dependency detection:
add $0, $1, $2
or $10, $0, $0
add $1, $1, $2
add $1, $1, $3
add $1, $1, $4

How expensive is this solution?
Is this the optimal position for the forwarding unit? What about the CPU's critical path?
Consider this example:
add $7, $20, $21
add $8, $22, $23
add $6, $7, $8
add $6, $6, $6
Show the forwarding.
Consider the following code segment:
lw $2, 20($1)
and $4, $2, $5
or $8, $2, $5
add $9, $4, $2
slt $1, $6, $7
What are the dependencies?
What will happen during execution?
Why can't we forward? So, what do we do?
What about this situation:
lw $2, 0($10) sw $2, 0($11) add $10, $10, $3 # $3 = 4 add $11, $11, $3Do we need to stall the sw?
What can the compiler do to help out?

Set all control bits in ID stage to 0. Hold the PC and IF/ID reg.
Why do we hold the IF/ID reg? (PC has already advanced.)
