Question: Consider the data hazard in the following program. Assume that there is no structure hazard, and assume that the memory access time is very short
Consider the data hazard in the following program. Assume that there is no structure hazard, and assume that the memory access time is very short (<1 cycle).
instruction 1: addi r2, r0, 0x100 instruction 2: ldw r3, 4(r2) instruction 3: addi r4, r3, 4 instruction 4: ldw r5, 8(r2) instruction 5: addi r6, r5, 4
Please find out how long it takes to run the program if we just use pipeline stalling.
Stage 5 of instruction 1 is executed in cycle 5
Stage 5 of instruction 2 is executed in cycle( )
Stage 5 of instruction 3 is executed in cycle ( )
Stage 5 of instruction 4 is executed in cycle ( )
Stage 5 of instruction 5 is executed in cycle ( )
Please find out how long it takes to run the same program if we just use operand forwarding.
Stage 5 of instruction 1 is executed in cycle 5
Stage 5 of instruction 2 is executed in cycle ( )
Stage 5 of instruction 3 is executed in cycle ( )
Stage 5 of instruction 4 is executed in cycle ( )
Stage 5 of instruction 5 is executed in cycle ( )
Finally, we can reduce the total running time of the above program if we use both operand forwarding and instruction reordering.
Instruction ( ) and instruction( ) should be swapped.
With operand forwarding and instruction reordering, stage 5 of instruction 5 is executed in cycle ( )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
