I am fairly new to computer architecture and having a tough time solving problems based on pipelining. I was trying to solve a problem from this pdf I found on Google
I have a doubt in part b
of problem 2
where we are asked How many cycles will it take to execute on the fully bypassed MIPS processor?
I have two questions: Why is there a need for a stall between lw
and sw
instruction and secondly, how is the final answer being calculated anyway? I don't understand the part 1 + 63 · (6 + 3) + 1 · (6 + 2) = 576
at all. Also,even if I assume the stall between lw
and sw
, then if next iteration of loop starts at cycles 9,18 .. and so on. This should happen 64 times and the initial one cycle from li
instruction and the 3 remaining cycles for the last execution of bnez
means that total cycles = 1 + 64*9 + 3 = 580, right? I got 9 cycles as shown in the timing diagram , at 9th cycle ID of bnez
is going on. for the last iteration, we won't execute the branch , but we need 3 more cycles to complete the bnez
instruction.
EDIT: After checking out solution to the next part of same problem, it seems that the number of cycles are actually approximated for some reason. I thought that should be done only for large number of instructions (million or above). But I am not sure if I am correct :(