CS473 Homework 4 Solution


Paper Part

Consider the following sequence of MIPS code:

addi  $1, $0, 100
add $2, $0, $1
lw $3, 100($2)
lw $5, 200($3)
sw $5, 100($3)

Draw a Gantt (timing) chart showing how these four instructions are executed. Where a stall is necessary, show it by "stretching" the instruction decode stage. Where forwarding is necessary, show it by drawing an arrow from the stage where the data is produced to the stage where it is consumed.

execution chart
Note:For the last instruction, we need to stretch IF, because we'll run into structural hazard otherwise.


Program Part

            Solution

           
Test Data