RegMux refers to the mux that chooses between the ALU output and data memory output
and then feeds the data input port on the registers.
ALUMux refers to the mux between second read port of registers
and goes into the second input of the ALU. For both multiplexors assume
that the 0 output is at the top.
RegWrite = 1MemRead = 0ALUMux = 0MemWrite = 0ALUOp = 10 (R-Type)RegMux = 1Branch = 0RegWrite = 0MemRead = 0ALUMux = 1MemWrite = 1ALUOp = 00 (SW)AddRegMux = XBranch = 0For part A: Control is faster than registers, so the critical path is I-Mem, Regs, Mux, ALU, Mux.
For part B: The two long paths are equal, so both are critical.
Part A: Control is faster than registers, so the critical path is I-Mem, Regs, Mux, ALU, D-Mem, Mux.
For part B: The two long paths are equal, so both are critical.
To compute the PC, one path is to increment it by 4 (Add), add the offset (Add), and select that value as the new PC (Mux). The other path for computing the PC is to Read the instruction (to get the offset), use the branch Add unit and Mux. Both of the compute-PC paths are shorter than the critical path that determines the branch condition, because I-Mem is slower than the PC + 4 Add unit, and because ALU is slower than the branch Add.
For part A: The first path through the registers is longer.
For part B: The two long paths are equal, so both are critical.
$r4 from the second to the third instruction.
$r1 from first to second instruction and a
dependency on $r2 from the second to the third instruction.
There is also a dependency on $r1 between the
first and third instruction.
$4.
sw $16,-100($6) # lw IF ID EX MEM WB
lw $4,8($16) # add IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
add $5,$4,$4 # sw IF ID EX MEM WB
The writeback of the lw instruction needs to finish before the
decode stage of the add.
or $1,$2,$3 # or IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
or $2,$1,$4 # or IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
nop # nop IF ID EX MEM WB
or $1,$1,$2 # or IF ID EX MEM WB
MEM stage in the second
instruction to the input of the EX stage but we still need that nop to
eliminate the hazard. If we didn't have the nop the pipeline would still
stall by itself to wait. You can view the nop instruction
as a programmer controlled stall.
sw $16,-100($6) # lw IF ID EX MEM WB
lw $4,8($16) # add IF ID EX MEM WB
nop # nop IF ID EX MEM WB
add $5,$4,$4 # sw IF ID EX MEM WB
nop instructions. The pipeline does not stall at all.