SlideShare ist ein Scribd-Unternehmen logo
1 von 20
PIPELINING AND HAZARDS
WHAT IS PIPELINING?
 Definition: A Pipeline is a series of stages, where
some work is done at each stage. The work is not
finished until it has passed through all stages.
 It is a technique used in advanced microprocessors
where the microprocessor begins executing a
second instruction before the first has been
completed.
 Pipeline is commonly known as an assembly line
operation.
WHY PIPELINING?
 With pipelining, the computer architecture allows
the next instructions to be fetched while the
processor is performing arithmetic operations,
holding them in a buffer close to the processor until
each instruction operation can performed.
HOW PIPELINING IS IMPLEMENTED?
 The pipeline is divided into segments and each segment can execute it
operation concurrently with the other segments. Once a segment
completes an operations, it passes the result to the next segment in the
pipeline and fetches the next operations from the preceding segment.
IMPLEMENTATION OF PIPELINING
1. .data
2. .text
3. li $t1,4
4. li $t2,6
5. li $t3,8
1. sub $t0, $t1, $t2
2. and $t4, $t0, $t3 depends on $t0
3. or $t3, $t1, $t4 depends on $t4
Continued
 Example 2:
 .data
 a: .word 2
 b1: .word 3
 .text
 lw $t0, a
 Lw $t1, b1
 add, $t0, $t0, $t1
WHAT ARE HAZARDS?
 Hazards are situations that prevent the next
instruction in the instruction stream from executing
in its designated clock cycle. Hazards reduce the
performance from the ideal speedup gained by
pipelining.
TYPES OF HAZARDS
There are three different types.
Structural Hazards – Can all stages can be
executed in parallel?
Data Hazards – One instruction might depend on
result of a previous instruction
Control Hazards – fetch cannot continue because
it does not know the outcome of an earlier
branch
DATA HAZARDS
 Data hazards occur when the pipeline must be stalled
because one step must wait for another to complete.
 In a computer pipeline, data hazards arise from the
dependence of one instruction on an earlier one that is still in
the. For example, suppose we have instruction
 add $s0, $t0, $t1
 sub $t2, $s0, $t3
DATA HAZARDS
Cycle1 Cycle2 Cycle3 Cycle4 Cycle 5 Cycle 6
Add $r3 , $r1 , $r2 Fetch Decode Execute Access
M
Store
Add $r4 , $r3 , $r4 Fetch Decode Execute Access
M
Store
Add $r5 , $r3 , $r4 Fetch Decode Execute Access
M
IMPLEMENTATION OF DATA HAZARDS
DATA HAZARDS SOLUTION
 The primary solution is based on the observation that we
don’t need to wait for the instruction to complete before
trying to resolve the data hazard. For the code sequence
above, as soon as the ALU creates the sum for the add, we
can supply it as an input for the subtract. Adding extra
hardware to retrieve the missing item early from the internal
resources is called forwarding or bypassing.
STRUCTURAL HAZARDS
The first hazard is called a “structural hazard”. It means
that the hardware cannot support the combination of
instructions that we want to execute in the same clock
cycle.
Instruction fetching and data fetching is being done in
same cycle.
STRUCTURAL HAZARDS
Cycle1 Cycle2 Cycle3 Cycle4 Cycle 5 Cycle 6 Cycle 7 Cycle 8
Inst0 Fetch Decode Execute Access M Store
Inst1 Fetch Decode Execute Access M Store
Inst2 Fetch Decode Execute Access M Store
Inst3 Fetch Decode Execute Access M Store
Inst4 Fetch Decode Execute Access M
Inst5 Fetch Decode Execute
Inst6 Fetch Decode
SOLUTION: Make separation between fetch and access memory
Solution Of Structural Hazard
IMPLEMENTATION OF STRUCTURAL
HAZARD
CONTROL HAZARD
 Control hazard, arising from the need to make a
decision based on the results of one instruction
while others are executing.
 Pipeline cannot operate normally due to non-
sequential control flow
 Common instances of structural hazards arise by
 Branch instruction(Unconditional OR Conditional) during execution time
CONTROL HAZARD
CONTROL HAZARD SOLUTION
SIMPLE TECHNIQUES TO HANDLE CONTROL
HAZARD
 For each branch, introduce a stall cycle
 Assume branch is not taken and start fetching the next instruction – if the
branch is taken , need hardware to cancel the effect of wrong path
instructions
 start fetch the next instruction (branch delay slot) and execute it anyway –
if the instruction turn out to be on the correct path, useful work was
done – if the instruction turns out to be on the wrong path, hopefully
program state is not lost
CONTROL HAZARD SOLUTION

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
TCP/IP Network ppt
TCP/IP Network pptTCP/IP Network ppt
TCP/IP Network ppt
 
Basic MIPS implementation
Basic MIPS implementationBasic MIPS implementation
Basic MIPS implementation
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
 
Data Hazard and Solution for Data Hazard
Data Hazard and Solution for Data HazardData Hazard and Solution for Data Hazard
Data Hazard and Solution for Data Hazard
 
Hazards in pipeline
Hazards in pipelineHazards in pipeline
Hazards in pipeline
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
 
Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection Network
 
Semaphores
SemaphoresSemaphores
Semaphores
 
MEDIUM ACCESS CONTROL
MEDIUM ACCESS CONTROLMEDIUM ACCESS CONTROL
MEDIUM ACCESS CONTROL
 
Pipelining , structural hazards
Pipelining , structural hazardsPipelining , structural hazards
Pipelining , structural hazards
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Arduino and its hw architecture
Arduino and its hw architectureArduino and its hw architecture
Arduino and its hw architecture
 
Subroutine
SubroutineSubroutine
Subroutine
 
Quality of Service
Quality of ServiceQuality of Service
Quality of Service
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
pipelining
pipeliningpipelining
pipelining
 
Arithmetic logic shift unit
Arithmetic logic shift unitArithmetic logic shift unit
Arithmetic logic shift unit
 

Ähnlich wie Pipeline Hazards Explained

pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesMahmudul Hasan
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazardAJAL A J
 
Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorSmit Shah
 
hazard new.ppt
hazard new.ppthazard new.ppt
hazard new.pptView20
 
Lab 1 reference manual
Lab 1 reference manualLab 1 reference manual
Lab 1 reference manualtrayyoo
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System AchitectureYashiUpadhyay3
 
A survey of paradigms for building and
A survey of paradigms for building andA survey of paradigms for building and
A survey of paradigms for building andcseij
 
CALecture3Module1.ppt
CALecture3Module1.pptCALecture3Module1.ppt
CALecture3Module1.pptBeeMUcz
 
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA   New Questions 29Tuts.Com New CCNA 200-120 New CCNA   New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2Lori Head
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfarasanlethers
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdfMadhuGupta99385
 
Pipeline Mechanism
Pipeline MechanismPipeline Mechanism
Pipeline MechanismAshik Iqbal
 
Binary obfuscation using signals
Binary obfuscation using signalsBinary obfuscation using signals
Binary obfuscation using signalsUltraUploader
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded SystemsAngela Hauber
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded SystemsMEN Mikro Elektronik GmbH
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded SystemsMEN Micro
 

Ähnlich wie Pipeline Hazards Explained (20)

Assembly p1
Assembly p1Assembly p1
Assembly p1
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelines
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazard
 
Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline Processor
 
hazard new.ppt
hazard new.ppthazard new.ppt
hazard new.ppt
 
Lab 1 reference manual
Lab 1 reference manualLab 1 reference manual
Lab 1 reference manual
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System Achitecture
 
A survey of paradigms for building and
A survey of paradigms for building andA survey of paradigms for building and
A survey of paradigms for building and
 
CALecture3Module1.ppt
CALecture3Module1.pptCALecture3Module1.ppt
CALecture3Module1.ppt
 
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA   New Questions 29Tuts.Com New CCNA 200-120 New CCNA   New Questions 2
9Tuts.Com New CCNA 200-120 New CCNA New Questions 2
 
CA UNIT III.pptx
CA UNIT III.pptxCA UNIT III.pptx
CA UNIT III.pptx
 
Pipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdfPipelining understandingPipelining is running multiple stages of .pdf
Pipelining understandingPipelining is running multiple stages of .pdf
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdf
 
Pipeline Mechanism
Pipeline MechanismPipeline Mechanism
Pipeline Mechanism
 
Binary obfuscation using signals
Binary obfuscation using signalsBinary obfuscation using signals
Binary obfuscation using signals
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems
 
5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems5 Techniques to Achieve Functional Safety for Embedded Systems
5 Techniques to Achieve Functional Safety for Embedded Systems
 

Kürzlich hochgeladen

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 

Kürzlich hochgeladen (20)

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 

Pipeline Hazards Explained

  • 2. WHAT IS PIPELINING?  Definition: A Pipeline is a series of stages, where some work is done at each stage. The work is not finished until it has passed through all stages.  It is a technique used in advanced microprocessors where the microprocessor begins executing a second instruction before the first has been completed.  Pipeline is commonly known as an assembly line operation.
  • 3. WHY PIPELINING?  With pipelining, the computer architecture allows the next instructions to be fetched while the processor is performing arithmetic operations, holding them in a buffer close to the processor until each instruction operation can performed.
  • 4. HOW PIPELINING IS IMPLEMENTED?  The pipeline is divided into segments and each segment can execute it operation concurrently with the other segments. Once a segment completes an operations, it passes the result to the next segment in the pipeline and fetches the next operations from the preceding segment.
  • 5. IMPLEMENTATION OF PIPELINING 1. .data 2. .text 3. li $t1,4 4. li $t2,6 5. li $t3,8 1. sub $t0, $t1, $t2 2. and $t4, $t0, $t3 depends on $t0 3. or $t3, $t1, $t4 depends on $t4
  • 6. Continued  Example 2:  .data  a: .word 2  b1: .word 3  .text  lw $t0, a  Lw $t1, b1  add, $t0, $t0, $t1
  • 7. WHAT ARE HAZARDS?  Hazards are situations that prevent the next instruction in the instruction stream from executing in its designated clock cycle. Hazards reduce the performance from the ideal speedup gained by pipelining.
  • 8. TYPES OF HAZARDS There are three different types. Structural Hazards – Can all stages can be executed in parallel? Data Hazards – One instruction might depend on result of a previous instruction Control Hazards – fetch cannot continue because it does not know the outcome of an earlier branch
  • 9. DATA HAZARDS  Data hazards occur when the pipeline must be stalled because one step must wait for another to complete.  In a computer pipeline, data hazards arise from the dependence of one instruction on an earlier one that is still in the. For example, suppose we have instruction  add $s0, $t0, $t1  sub $t2, $s0, $t3
  • 10. DATA HAZARDS Cycle1 Cycle2 Cycle3 Cycle4 Cycle 5 Cycle 6 Add $r3 , $r1 , $r2 Fetch Decode Execute Access M Store Add $r4 , $r3 , $r4 Fetch Decode Execute Access M Store Add $r5 , $r3 , $r4 Fetch Decode Execute Access M
  • 12. DATA HAZARDS SOLUTION  The primary solution is based on the observation that we don’t need to wait for the instruction to complete before trying to resolve the data hazard. For the code sequence above, as soon as the ALU creates the sum for the add, we can supply it as an input for the subtract. Adding extra hardware to retrieve the missing item early from the internal resources is called forwarding or bypassing.
  • 13. STRUCTURAL HAZARDS The first hazard is called a “structural hazard”. It means that the hardware cannot support the combination of instructions that we want to execute in the same clock cycle. Instruction fetching and data fetching is being done in same cycle.
  • 14. STRUCTURAL HAZARDS Cycle1 Cycle2 Cycle3 Cycle4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Inst0 Fetch Decode Execute Access M Store Inst1 Fetch Decode Execute Access M Store Inst2 Fetch Decode Execute Access M Store Inst3 Fetch Decode Execute Access M Store Inst4 Fetch Decode Execute Access M Inst5 Fetch Decode Execute Inst6 Fetch Decode SOLUTION: Make separation between fetch and access memory
  • 17. CONTROL HAZARD  Control hazard, arising from the need to make a decision based on the results of one instruction while others are executing.  Pipeline cannot operate normally due to non- sequential control flow  Common instances of structural hazards arise by  Branch instruction(Unconditional OR Conditional) during execution time
  • 19. CONTROL HAZARD SOLUTION SIMPLE TECHNIQUES TO HANDLE CONTROL HAZARD  For each branch, introduce a stall cycle  Assume branch is not taken and start fetching the next instruction – if the branch is taken , need hardware to cancel the effect of wrong path instructions  start fetch the next instruction (branch delay slot) and execute it anyway – if the instruction turn out to be on the correct path, useful work was done – if the instruction turns out to be on the wrong path, hopefully program state is not lost