Current Design
InterstageBuffers 1
CS@VT Computer Organization II ý2005-2017 McQuain
Consider executing:
add $t2, $t1, $t0
sub $t3, $t1, $t0
or $t4, $t1, $t0
sw $t2, 0($t0)
time 0
…1 sw 2or3sub4add
Pipeline Timing Issues
InterstageBuffers 2
CS@VT Computer Organization II ý2005-2017 McQuain
What happens during cycle 4? Among other things…
– sw reaches the ID stage, and Control sets MemWrite to 1
– so, a memory write will occur while sub is in the MEM stage
– and that¡¯s bad news…
time 0
…1 sw 2or3sub4add
Pipeline Timing Issues
InterstageBuffers 3
CS@VT Computer Organization II ý2005-2017 McQuain
Pipeline Timing Issues
What needs to happen instead?
– thevalueofMemWritethatgoeswithsw…
– … needs to travel forward, stage to stage as sw does
time 0
InterstageBuffers 4
time 0
…1 …2sw3or4sub
CS@VT
Computer Organization II ý2005-2017 McQuain
…1 sw 2or3sub4add
What needs to happen instead?
– thevalueofMemWritethatgoeswithsw…
– … needs to travel forward, stage to stage as sw does
time 0
… 1 … 2 … 3 sw 4 or
So how do we make this happen?
Pipeline Timing Issues
InterstageBuffers 5
CS@VT Computer Organization II ý2005-2017 McQuain
Put storage buffers between adjacent stages:
Control writes/reads with the clock signal.
Write values exiting a stage to the ¡°outbound¡± buffer. Read values entering a stage from the ¡°inbound¡± buffer.
So no signal (or data value) arrives before its time…
Adding Buffers
InterstageBuffers 6
CS@VT Computer Organization II ý2005-2017 McQuain
PC+4 is computed, stored back into the PC,
stored in the IF/ID buffer although it will not be needed in a later stage for LW or SW
Instruction word is fetched from memory,
and stored in the IF/ID buffer because it will be needed in the next stage.
Write into the buffer
IF for Load, Store, …
InterstageBuffers 7
CS@VT Computer Organization II ý2005-2017 McQuain
PC+4 is passed forward to ID/EX buffer…
Read register #1 and #2 contents are fetched and stored in ID/EX buffer until needed in next stage… #2 won’t be needed.
16-bit field is fetched from IF/ID buffer, then sign-extended, then stored in the ID/EX buffer for use in a later stage.
Read from the buffer
Bits of load instruction are taken from IF/ID buffer, while
new instruction is being fetched back in stage 1.
ID for Load
InterstageBuffers 8
CS@VT Computer Organization II ý2005-2017 McQuain
PC+4 is taken from ID/EX buffer and added to branch offset…
Computed branch target address is stored in EX/MEM buffer to await decision in next stage… but won’t be needed.
Read register #1 contents are taken from ID/EX buffer and provided to ALU.
16-bit literal is provided to ALU as second operand
ALU result and Zero line are stored in EX/MEM buffer for use as memory address in next stage.
Read register #2 is passed forward to EX/MEM buffer, for possible use in later stage… but won’t be needed.
EX for Load
InterstageBuffers 9
CS@VT Computer Organization II ý2005-2017 McQuain
Zero line taken from EX/MEM buffer for branch control logic in this stage…
Value on Read data port of data memory is stored in MEM/WB buffer, awaiting decision in last stage..
ALU result is taken from EX/MEM buffer and passed to Address port of data memory.
ALU result also stored in MEM/WB buffer for possible use in last stage…
Read register #2 contents taken from EX/MEM buffer and passed to Write data port of data memory.
MEM for Load
Interstage Buffers 10
CS@VT Computer Organization II ý2005-2017 McQuain
But the Write register port is now seeing the register number from a different, later instruction.
Since load instruction, value from data memory is selected and passed back to register file.
WB for Load
Interstage Buffers 11
CS@VT Computer Organization II ý2005-2017 McQuain
So we fix the register number problem by passing the Write register # from the load instruction through the various inter-stage buffers…
…and then back, on the correct clock cycle.
Corrected Datapath for Load
Interstage Buffers 12
CS@VT Computer Organization II ý2005-2017 McQuain
Almost the same as for LW…
Read register #2 is passed forward to EX/MEM buffer, for use in later stage… for SW this will be needed.
EX for Store
Interstage Buffers 13
CS@VT Computer Organization II ý2005-2017 McQuain
Zero line taken from EX/MEM buffer for branch control logic in this stage…
Value on Read data port of data memory is stored in MEM/WB buffer, awaiting decision in last stage..
ALU result is taken from EX/MEM buffer and passed to Address port of data memory.
ALU result also stored in MEM/WB buffer for possible use in last stage…
Read register #2 contents taken from EX/MEM buffer and passed to Write data port of data memory.
MEM for Store
Interstage Buffers 14
CS@VT Computer Organization II ý2005-2017 McQuain
Since SW instruction, neither value will be written to the register file… doesn’t really matter which value we send back…
WB for Store
Interstage Buffers 15
CS@VT Computer Organization II ý2005-2017 McQuain
Can you repeat this analysis for other sorts of instructions, identifying in each stage what’s relevant and what’s not?
How much storage space does each interstage buffer need? Why?
Do the interstage buffers have any effect on the overall time required for an instruction to migrate through the pipeline? Why?
Questions to Ponder
Interstage Buffers 16
CS@VT Computer Organization II ý2005-2017 McQuain
Summary
Here¡¯s our preliminary configuration for the buffers:
Interstage Buffers 17
CS@VT Computer Organization II ý2005-2017 McQuain