I'm a little confused about the difference of the memory access and the write-back stage in a RISC pipeline
.
We learned in class these following assumptions:
arithmetic & logic: IF, OF, EX, WB
load: IF, OF, EX, MA, WB
store: IF, OF, EX, MA
branch: IF, OF, EX
IF=Instruction Fetch, OF=Operand Fetch, EX=Execution, MA=Memory Access, WB=Write-Back
Lets say we have the following code now:
I1: LD R1, 0(R2) ; load R1 from address 0 + R2I1: LD R1, 0(R2) ; load R1 from address 0 + R2
I2: ADD R1, R1, #1 ; R1 = R1 + 1I2: ADD R1, R1, #1 ; R1 = R1 + 1
I3: ST 0(R2), R1 ; Store R1 at address 0 + R2I3: ST 0(R2), R1 ; Store R1 at address 0 + R2
According to what I've learned I1
will pass all five stages, I2
won't have to access the memory, and I3
won't have a write-back.
But then I wonder, how and where does I3
store the value then? Just in the memory? And I2
fetches the value from memory, but needs to write-back to some place other than the memory? So does that mean that write-back is always to the HDD?
I think I'm missing some core concepts here, as to where the operand is fetched from and where it gets stored to.