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

The pieces of code below run on a 5-stage pipelined datapath. The datapath has a

ID: 3552996 • Letter: T

Question

The pieces of code below run on a 5-stage pipelined datapath. The datapath has a forwarding unit that can
forward from MEM?EX and from WB?EX. For each piece of code, mention if forwarding is needed
and insert the necessary nops. For each forwarding, mention the register being forwarded and the fromand
to- stages.


Example:
lw t0, 0(s0)
add t1, t0, s2
sub t2, t3, t1
Answer:
lw t0, 0(s0)
nop
add t1, t0, s2 # t0 is forwarded from WB to EX
sub t2, t3, t1 # t1 is forwarded from MEM to EX


Code 1:
sub t2, s0, s1
or t7, t2, t1


Code 2:
and t1, t2, t3
sub s1, s2, s3
or t7, t1, s1


Code 3:
lw t0, 44(s0)
nor t5, t6, t0


Code 4:
add t1, t2, t3
sub t1, a0, a1
or t7, t1, t6


Code 5:
lw t2, 12(s1)
sub t6, a0, a1
xor t1, t5, t2
lw t3, 12(t1)

Explanation / Answer

Code 1:
sub t2, s0, s1
or t7, t2, t1 # t2 is forwarded from MEM to EX


Code 2:
and t1, t2, t3
sub s1, s2, s3
or t7, t1, s1 # s1 is forwarded from MEM to EX, t1 is forwarded from WB to EX


Code 3:
lw t0, 44(s0)

nop
nor t5, t6, t0 # t0 is forwarded from WB to EX


Code 4:
add t1, t2, t3
sub t1, a0, a1
or t7, t1, t6 # t1 is forwarded from MEM to EX


Code 5:
lw t2, 12(s1)
sub t6, a0, a1
xor t1, t5, t2 # t2 is forwarded from WB to EX
lw t3, 12(t1) # t1 is forwarded from MEM to EX

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote