I1: add $t1, $t2, $t3 I2: add $s2, $t2, $t3 I3: sw $t1, 0($s2)
Time | IF | ID | ALU | MEM | WB |
---|---|---|---|---|---|
1 | add $t1, $t2, $t3 | ||||
2 | add $s2, $t2, $t3 | add $t1, $t2, $t3 | |||
3 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
4 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
5 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
6 | sw $t1, 0($s2) | add $s2, $t2, $t3 | |||
7 | sw $t1, 0($s2) |
Time | IF | ID | ALU | MEM | WB |
---|---|---|---|---|---|
1 | add $t1, $t2, $t3 | ||||
2 | add $s2, $t2, $t3 | add $t1, $t2, $t3 | |||
3 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
4 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
5 | sw $t1, 0($s2) | add $s2, $t2, $t3 | add $t1, $t2, $t3 | ||
6 | sw $t1, 0($s2) | add $s2, $t2, $t3 | |||
7 | sw $t1, 0($s2) | ||||
7 | sw $t1, 0($s2) | ||||
7 | sw $t1, 0($s2) |
noop
into the pipeline.
lw
is a problem.
I1: lw $rx, xxx I2: add $XX, $rx, $rx
Time | IF | ID | ALU | MEM | WB |
---|---|---|---|---|---|
1 | I1 | ||||
2 | I1 | I1 | |||
3 | I2 | I1 | |||
4 | I2 | I1 |
.data MYDATA: .word 100 200 300 400 MAX_SIZE: .word 4 .text .globl main main: la $a0, MYDATA # base address of the array li $t0, 0 # offset into the array li $t1, 0 # index into the array lw $t2, MAX_SIZE # loop limit top: beq $t1, $t2, done add $t3, $a0, $t0 lw $a1, 0($t3) addi $a1, $a1, 101 sw $a1, 0($t3) addi $t0, $t0, 4 addi $t1, $t1, 1 b top done: li $v0, 10 syscall
noop
in the load delay slot.