Due date: On or before Thursday, May 08, 2025 Absolutely no copying others’ works |
Name: Professor Hu |
IF | ID | EX | MEM | WB |
---|---|---|---|---|
270 ps | 360 ps | 170 ps | 320 ps | 180 ps |
ALU/Logic | Jump/Branch | Load | Store |
---|---|---|---|
40% | 30% | 15% | 15% |
lw
instruction in a pipelined and non-pipelined processor?lw
and sw
need to access the data memory
lw
instruction need to use the write-register port
loop: lw $s0, 0($s3) # I1 lw $s1, 8($s3) # I2 add $s2, $s0, $s1 # I3 addi $s3, $s3, -16 # I4 bnez $s2, loop # I5Assume that perfect branch prediction is used (no stalls due to control hazards), that there are no delay slots, that the pipeline has full forwarding support, and that branches are resolved in the EX (as opposed to the ID) stage.
RAR | RAW | WAR | WAW |
---|---|---|---|
on $s3 for I1 and I2 on $s3 for I1 and I4 on $s3 for I2 and I4 |
on $s0 for I1 and I3 on $s1 for I2 and I3 on $s2 for I3 and I5 |
on $s3 for I1 and I4 on $s3 for I2 and I4 |
n+5
and ending at the cycle n+12
.
Executed Instructions | Pipeline Cycles | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
n+1 | n+2 | n+3 | n+4 | n+5 | n+6 | n+7 | n+8 | n+9 | n+10 | n+11 | n+12 | n+13 | n+14 | n+15 | n+16 | |
lw $s0, 0($s3) |
IF | ID | EX | MEM | WB | |||||||||||
lw $s1, 8($s3) |
IF | ID | EX | MEM | WB | |||||||||||
add $s2, $s0, $s1 |
IF | ID | — | EX | MEM× | WB | ||||||||||
addi $s3, $s3, -16 |
IF | — | ID | EX | MEM× | WB | ||||||||||
bnez $s2, LOOP |
— | IF | ID | EX | MEM× | WB× | ||||||||||
lw $s0, 0($s3) |
IF | ID | EX | MEM | WB | |||||||||||
lw $s1, 8($s3) |
IF | ID | EX | MEM | WB | |||||||||||
add $s2, $s0, $s1 |
IF | ID | — | EX | MEM× | WB | ||||||||||
addi $s3, $s3, -16 |
IF | — | ID | EX | MEM× | WB | ||||||||||
bnez $s2, LOOP |
IF | ID | EX | MEM× | WB× | |||||||||||
Completely busy |
$s1
for I2 and I3, and it can only be resolved by a stall.
n+5
) during which the addi
is in the IF stage.
End with the cycle (i.e., n+12
) during which the bnez
is in the IF stage.)