Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could anyone help with probelm 4.13.2 in Computer Organization and Design(5th)?

ID: 3769985 • Letter: C

Question

Could anyone help with probelm 4.13.2 in Computer Organization and Design(5th)?

Probelm 4.13.2 is below :

Problems in this exercise refer to the following sequence of instructions, and assume that it is executed on 5-stage pipelined datapath:

add r5,r2,r1
lw r3,4(r5)
lw r2,0(r2)
or r3,r5,r3
sw r3,0(r5)

If there is no forwarding or hazard detection, insert nops to ensure correct execution.
Use nops only when a hazard cannot be avoided by changing or rearranging these instructions.
You can assume register R7 can be used to hold temporary values in your modified code.

Explanation / Answer

Every arthimetic operation, two NOP operations required.
After list of LOAD operations, one NOP operation required.

ADD $r5, $r2, $r1
NOP
NOP
LW $r3, 4($r5)
LW $r2, 0($r2)
NOP
OR $r3, $r5, $r3
NOP
NOP
SW $r3, 0($r5)