Computer System Organization
Computer System Organization
Improve the hardware by introducing Arrange the hardware such that more
faster circuits. than one operation can be performed
at the same time.
WHAT IS PIPELINING
Let us see a real life example that works on the concept of pipelined operation.
Consider a water bottle packaging plant. Let there be 3 stages that a bottle should
pass through, Inserting the bottle(I), Filling water in the bottle(F), and Sealing the
bottle(S). Let us consider these stages as stage 1, stage 2 and stage 3 respectively.
Let each stage take 1 minute to complete its operation.
Now, in a non pipelined operation, a bottle is first inserted in the plant, after 1
minute it is moved to stage 2 where water is filled. Now, in stage 1 nothing is
happening. Similarly, when the bottle moves to stage 3, both stage 1 and stage 2
are idle. But in pipelined operation, when the bottle is in stage 2, another bottle
can be loaded at stage 1. Similarly, when the bottle is in stage 3, there can be one
bottle each in stage 1 and stage 2. So, after each minute, we get a new bottle at
the end of stage 3.
DESIGN OF PIPELINE
In a pipelined processor, a pipeline has two ends, the input end and the output
end. Between these ends, there are multiple stages/segments such that output of
one stage is connected to input of next stage and each stage performs a specific
operation.
Interface registers are used to hold the intermediate output between two stages.
These interface registers are also called latch or buffer.
All the stages in the pipeline along with the interface registers are controlled by a
common clock.
EXECUTION IN PIPELINED PROCESSOR
A reduced instruction set computer, or RISC (/rɪsk/), is one whose instruction set
architecture (ISA) allows it to have fewer cycles per instruction (CPI) than a
complex instruction set computer (CISC)
Most common processor Alpha, ARC, ARM, AVR, MIPS, PA-RISC, PIC
5 PIPELINE STAGES
Following are the 5 stages of RISC pipeline with their respective operations
STAGE 1 (INSTRUCTION FETCH)
In this stage the CPU reads instructions from the address in the memory whose
value is present in the program counter
STAGE 2 (INSTRUCTION DECODE)
In this stage, instruction is decoded and the register file is accessed to get the
values from the registers used in the instruction.
STAGE 3 (INSTRUCTION EXECUTE)
In this stage, memory operands are read and written from/to the memory that is
present in the instruction.
STAGE 5 (WRITE BACK)
In this stage, computed/fetched value is written back to the register present in the
instructions.
DEPENDENCIES IN A PIPELINED
PROCESSOR
Structural Dependency
Control Dependency
Data Dependency
This dependency arises due to the resource conflict in the pipeline. A resource
conflict is a situation when more than one instruction tries to access the same
resource in the same cycle. A resource can be a register, memory, or ALU.
HOW TO SOLVE STRUCTURAL
DEPENDENCY?
To avoid this problem, we have to keep the instruction on wait until the required
resource (memory in our case) becomes available. This wait will introduce stalls in
the pipeline as shown below:
SOLUTION FOR STRUCTURAL
DEPENDENCY
To minimize structural dependency stalls in the pipeline, we use a hardware
mechanism called Renaming.
we need to stop the Instruction fetch until we get target address of branch
instruction. This can be implemented by introducing delay slot until we get the
target address.
SOLUTION FOR CONTROL DEFICIENCY
Branch Prediction is the method through which stalls due to control dependency
can be eliminated. In this at 1st stage prediction is done about which branch will
be taken.For branch prediction Branch penalty is zero.
Branch penalty : The number of stalls introduced during the branch operations in
the pipelined processor is known as branch penalty.
3. DATA DEPENDENCY (DATA HAZARD)
Data hazards occur when instructions that exhibit data dependence, modify data
in different stages of a pipeline. Hazard cause delays in the pipeline. There are
mainly three types of data hazards:
1) RAW (Read after Write) [Flow/True data dependency]
2) WAR (Write after Read) [Anti-Data dependency]
3) WAW (Write after Write) [Output data dependency]