Chapter 7: Pipelining & RISCs
What is pipelining?
A technique used
in advanced microprocessors where the microprocessor begins executing a
second instruction before the first has been completed. That is,
several instructions are in the pipeline simultaneously, each at a
different processing stage.
·
The pipeline is divided into segments and each
segment can execute its operation concurrently with the other segments. When a
segment completes an operation, it passes the result to the next segment in the
pipeline and fetches the next operation from the preceding segment. The final
results of each instruction emerge at the end of the pipeline in rapid succession.
·
Although formerly a feature only of
high-performance and RISC -based microprocessors, pipelining is now
common in microprocessors used in personal computers. Intel's Pentium chip,
for example, uses pipelining to execute as many as six instructions
simultaneously.
·
Pipelining is also called pipeline
processing.
In a non-pipelined processing;
- The next data/instruction is processed after the
entire processing of the previous data/instruction is complete.
INSTRUCTION PIPELINING
- First stage fetches the instruction and buffers
it
- When the second stage is free, the first stage
passes it buffered instruction.
- While the second stage is executing the
instruction, the first stage takes advantages of any unused memory cycles to
fetch and buffer the next instruction
- This is called instruction pre-fetch or fetch
overlap.
Two Stage Instruction Pipeline
2 stage pipelining:
- Instruction divided to 2 parts:
- fetch
- Execution
- Throughput is higher while latency is still the
same
Example of 2 stage pipelining
Six Stage
Pipelining
Stage 1: Fetch instruction (FI)
·
Read the next expected instruction into a buffer.
Stage 2: Decode instruction (DI)
·
Determine the opcode and the operand specifiers.
Stage 3: Calculate Operands (CO)
·
Calculate the effective address of each source
operand.
Stage 4: Fetch Operands (FO)
·
Fetch operand from memory. Operands in registers
need not to be fetched.
Stage 5: Execute instructions (EI)
·
Perform the indicated operation and store the
result.
Stage 6: Write operand (WO)
·
Store the result in memory.
Example
of 6 stage pipelining
Pipelining of Unequal Stages
v Always take
the largest of the stage delay to be the cycle time.
v No stage
overlaps and latency must be constant.
v Ensure that
instruction overlap is the same as the cycle time else get timing diagram is
wrong.
TIMING DIAGRAM :
Wrong timing diagram: Overlaps!
Wrong timing diagram: Latencies
not constant
Correct timing diagram
Pipeline
Performance
Total time
for equal stages
Total time
for unequal stages
Speedup
Calculating
speedup
Example 1: Based on the 2 stage timing diagram.
Based
on the above example 1 and 2, the speedup improves when the number of stage
increase with the other values being same.
Example 3: Based n the 3 unequal stages example
Calculating
throughput
Pipelined Throughput= n/Tk (n)
Non-pipeline Throughput = n/To (n)
- Where n= total no of
instructions
- To (n) is the Total Time
for Non-pipelining, Tk (n) is the Total Time for Pipelining
- Both throughputs is in
instructions/per unit time(s)
Limits to
Pipelining
- Unequal duration/delay of stages
- Conditional branch instruction or interrupts
The
next diagram illustrates a branch penalty. Instruction 3 is a conditional
branch to instruction 20, which is taken. As soon as it is executed in step 6,
the pipeline is flushed (instruction 3 is able to complete) and instructions
starting at #20 are loaded into the pipeline. Note that no instructions are
completed during cycles 7 through 10. Click on the image to see an animated
view and the bubble generated.
Hazards as
limitations to pipelining
- Resource
hazards -HW cannot support this
combination of instructions (single person to fold and put clothes away,
washer-drier)
- Data hazards - Instruction depends
on result of prior instruction still in the pipeline
Data dependencies example
A = B + C
D = E + A
C = G x H
- Control hazard - Caused by delay
between the fetching of instructions and decisions about changes in control
flow (branches and jumps).
CISC and
RISC
Key features of CSIC
|
Key features of RISC
|
- Large number of predefined
instructions making high level programming languages easy to design and
implement.
- Supports microprogramming to
simplify computer architecture
|
- Limited and simple instruction
set
- Large number of general purpose
registers or use of compiler technology to optimize register use.
- Emphasis on optimizing the
instruction pipeline
|
Characteristics
of CISC and RISC
CISC characteristics
|
RISC Characteristics
|
·
Varying number of
instructions per cycle
·
Small number of
general purpose registers
·
More addressing
modes
·
More instruction
formats : fewer instructions can be used to implement a given task
·
Use microcode
·
Variable length
instruction
·
Simplified compiler:
microprogram instructions could be written to match constructs of high level
languages
|
·
One instruction per
cycle
·
Register to register
operations
·
Few, simple
addressing modes
·
Few, simple
instruction formats
·
Hardwired design (no
microcode)
·
Fixed instruction
format
·
More compile
time/effort
·
|
RISC vs.
CISC
|