1) If a data hazard is NOT prevented by data forwarding, then
the pipeline stalls. Assume data forwarding is working, does the
following code stall? "stall" means it needs an extra nop instruction
inserted, If the code stalls then list the labels of the
instruction(s) that cause a stall.
L1: lw $3, 50($3)
L2: add $2, $3, $4
L3: sw $2, 20($2)
L4: lw $5, 30($2)
L5: lw $6, 40($5)
L6: or $5, $6, $5
This question is asking if stall signal is set to '1', four cases.
See the following link for four cases:
2) Draw the pipeline diagram, you may use the style
similar to Lecture 19 and 20 (Lecture 20 is in the link above. Follow it
and press previous to find Lecture 19), or similar to the attached
diagram, simplified to use one clock at one ns for every stage.
There are no nop instructions to be fetched, yet show the effect of
hazard prevention by repeating the stage name when an
instruction is stalled.
We have full data forwarding and hazard prevention that
automatically inserts nop as needed into the pipeline.
add $5, $6, $7
lw $6, 60($5)
sub $7, $6, $5
or $8, $4, $6
3) How many total clock cycles, start to completion, are
required by your expanded code in part 2)
4) Assuming all instructions are in the cache:
If the nop instruction was actually in the code,
rather than being inserted into the pipeline, would
the total clock cycles be the same as in part 3)Attachments