MIPS Processor Pipelining Concepts
MIPS Processor Pipelining Concepts
Outline
ALU instructions:
Load/store instructions:
op rs rt immediate
op rs rt offset
op rs rt address
op address
6 bit 26 bit
(opcode): identifies the jump instruction type
contains 26-bit of 32-bit absolute word
address of jump destination:
Type I (Immediate)
• Immediate Instructions
• Load/store instructions
Tipo J (jump)
• Unconditional jumps instructions
3) Execution (EX):
The ALU operates on the operands prepared in the previous
cycle depending on the instruction type:
• Register-Register ALU Instructions:
• ALU executes the specified operation on the operands read from the RF
• Register-Immediate ALU Instructions:
• ALU executes the specified operation on the first operand read from the
RF and the sign-extended immediate operand
• Memory Reference:
• ALU adds the base register and the offset to calculate the effective
address.
• Conditional branches:
• Compare the two registers read from RF and compute the possible branch
target address by adding the sign-extended offset to the incremented PC.
Load Instructions: )
Instr. Fetch Read of Base ALU Op. Read Mem. Write Back of
& PC Increm. Reg. ) Destinat. Reg.
Store Instructions: )
Conditional Branch:
Pipelining
Performance optimization technique based on the overlap of the
execution of multiple instructions deriving from a sequential
execution flow.
Pipelining exploits the parallelism among instructions in a sequential
instruction stream.
Basic idea:
The execution of an instruction is divided into different phases
(pipelines stages), requiring a fraction of the time necessary to
complete the instruction.
The stages are connected one to the next to form the pipeline:
instructions enter in the pipeline at one end, progress through the
stages, and exit from the other end, as in an assembly line.
Pipelining
IF ID EX MEM WB IF ID EX MEM WB …
10 ns 10 ns
IF ID EX MEM WB Time
2 ns IF ID EX MEM WB
2 ns
IF ID EX MEM WB
2 ns
IF ID EX MEM WB
2 ns IF ID EX MEM WB
Pipelining
The time to advance the instruction of one stage in the
pipeline corresponds to a clock cycle.
The pipeline stages must be synchronized: the duration
of a clock cycle is defined by the time requested by the
slower stage of the pipeline (i.e. 2 ns).
The goal is to balance the length of each pipeline stage
If the stages are perfectly balanced, the ideal speedup
due to pipelining is equal to the number of pipeline
stages.
Performance Improvement
is worsened: from 8 ns to 10 ns
• The throughput (number of instructions completed in
Performance Improvement
Structural Hazards
No structural hazards in MIPS architecture:
• Instruction Memory separated from Data Memory
A Time
IM REG L DM REG
U
2 ns A
IM REG L DM REG
U
2 ns A
IM REG L DM REG
U
2 ns A
IM REG DM REG
L
U
2 ns A
IM REG L DM REG
U
Data Hazards
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
Compilation Techniques:
a) Insertion of (no operation) instructions
b) Instructions scheduling to avoid that correlating
instructions are too close
• The compiler tries to insert independent instructions among
correlating instructions
• When the compiler does not find independent instructions, it
insert
Hardware Techniques:
c) Insertion of stalls or “bubbles” in the pipeline
d) Data forwarding or bypassing
a) Insertion of Example
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
b) Scheduling: Example
Example:
d) Forwarding
Forwarding: Example
EX/EX MEM/EX
path path
IF ID EX ME WB
IF ID EX ME WB
IF ID EX ME WB
MEM/ID
path
IF ID EX ME WB
IF ID EX ME WB
Forwarding Paths
EX/EX path MEM/EX path
A
IM REG DM REG
L
RD WR
U MEM/ID path
A
IM REG DM REG
L
RD WR
U
A
IM REG DM REG
L
RD WR
U
A
IM REG DM REG
L
RD WR
U
A
IM REG DM REG
L
RD WR
U
Data Hazards
Data Hazards
IF ID EX MEM1 MEM2 WB
IF ID EX WB