SlideShare a Scribd company logo
1 of 46
Chapter 12,
William Stallings
Computer Organization and Architecture
7th
Edition
CPU Structure and
Function
CPU Function
• CPU must:
– Fetch instructions
– Interpret/decode instructions
– Fetch data
– Process data
– Write data
CPU With Systems Bus
Registers
• CPU must have some working space
(temporary storage) - registers
• Number and function vary between
processor designs - one of the major
design decisions
• Top level of memory hierarchy
User Visible Registers
• General Purpose
• Data
• Address
• Condition Codes
General Purpose Registers (1)
• May be true general purpose
• May be restricted
• May be used for data or addressing
• Data: accumulator (AC)
• Addressing: segment (cf. virtual memory),
stack (points to top of stack, cf. implicit
addressing)
General Purpose Registers (2)
• Make them general purpose
– Increased flexibility and programmer options
– Increased instruction size & complexity,
addressing
• Make them specialized
– Smaller (faster) but more instructions
– Less flexibility, addresses implicit in opcode
How Many GP Registers?
• Between 8 - 32
• Less = more memory references
• More takes up processor real estate
• See also RISC
How big?
• Large enough to hold full address
• Large enough to hold full data types
• But often possible to combine two data
registers or two address registers by using
more complex addressing (e.g., page and
offset)
Condition Code Registers – Flags
• Sets of individual bits, flags
– e.g., result of last operation was zero
• Can be read by programs
– e.g., Jump if zero – simplifies branch taking
• Can not (usually) be set by programs
Control & Status Registers
• Program Counter (PC)
• Instruction Register (IR)
• Memory Address Register (MAR) –
connects to address bus
• Memory Buffer Register (MBR) – connects
to data bus, feeds other registers
Program Status Word
• A set of bits
• Condition Codes:
– Sign (of last result)
– Zero (last result)
– Carry (multiword arithmetic)
– Equal (two latest results)
– Overflow
• Interrupts enabled/disabled
• Supervisor/user mode
Supervisor Mode
• Intel ring zero
• Kernel mode
• Allows privileged instructions to execute
• Used by operating system
• Not available to user programs
Other Registers
• May have registers pointing to:
– Process control blocks (see OS)
– Interrupt Vectors (see OS)
• N.B. CPU design and operating system
design are closely linked
MC68000 and Intel registers
• Motorola:
– Largely general purpose registers – explicit
addressing
– Data registers also for indexing
– A7 and A7’ for user and kernel stacks
• Intel
– Largely specific purpose registers – implicit
addressing
– Segment, Pointer & Index, Data/General
purpose
– Pentium II – backward compatibility
Indirect Cycle
• Same address can refer to different
arguments (by changing the content of the
location the address is pointing to)
• Indirect addressing requires more memory
accesses to fetch operands
• Can be thought of as additional instruction
subcycle
Instruction Cycle with Indirect
Instruction Cycle State Diagram
Data Flow (Instruction Fetch)
• PC contains address of next instruction
• Address moved to MAR
• Address placed on address bus
• Control unit requests memory read
• Result placed on data bus, copied to
MBR, then to IR
• Meanwhile PC incremented by 1
Data Flow (Fetch Diagram)
Data Flow (Data Fetch)
• IR is examined
• If indirect addressing, indirect cycle is
performed
– Rightmost n bits of MBR (address part of
instruction) transferred to MAR
– Control unit requests memory read
– Result (address of operand) moved to MBR
Data Flow (Indirect Diagram)
Data Flow (Execute)
• May take many forms, depends on
instruction being executed
• May include
– Memory read/write
– Input/Output
– Register transfers
– ALU operations
Data Flow (Interrupt)
• Current PC saved to allow resumption
after interrupt
• Contents of PC copied to MBR
• Special memory location (e.g., stack
pointer) loaded to MAR
• MBR written to memory according to
content of MAR
• PC loaded with address of interrupt
handling routine
• Next instruction (first of interrupt handler)
can be fetched
Data Flow (Interrupt Diagram)
Prefetch
• Fetch involves accessing main memory
• Execution of ALU operations do not
access main memory
• Can fetch next instruction during execution
of current instruction, cf. assembly line
• Called instruction prefetch
Improved Performance
• But not doubled:
– Fetch usually shorter than execution (cf.
reading and storing operands)
• Prefetch more than one instruction?
– Any jump or branch means that prefetched
instructions are not the required instructions
• Add more stages to improve performance
Two Stage Instruction Pipeline
Pipelining (six stages)
1. Fetch instruction
2. Decode instruction
3. Calculate operands (i.e., EAs)
4. Fetch operands
5. Execute instructions
6. Write result
• Overlap these operations
Timing Diagram for Instruction Pipeline
Operation (assuming independence)
The Effect of a Conditional Branch/Interrupt
on Instruction Pipeline Operation
Six Stage
Instruction
Pipeline
Speedup
Factors
with
Instruction
Pipelining:
nk/(n+k-1)
(ideally)
Dealing with Branches
1.Prefetch Branch Target
2.Loop buffer
3.Branch prediction
4.Delayed branching (see RISC)
Prefetch Branch Target
• Target of branch is prefetched in addition
to instructions following branch
• Keep target until branch is executed
• Used by IBM 360/91
Loop Buffer
• Very fast memory
• Maintained by fetch stage of pipeline
• Check buffer before fetching from memory
• Very good for small loops or jumps
• cf. cache
Branch Prediction (1)
• Predict never taken
– Assume that jump will not happen
– Always (almost) fetch next instruction
– VAX will not prefetch after branch if a page
fault would result (OS v CPU design)
• Predict always taken
– Assume that jump will happen (at least 50%)
– Always fetch target instruction
Branch Prediction (2)
• Predict by Opcode
– Some instructions are more likely to result in a
jump than others
– Can get up to 75% success
• Taken/Not taken switch
– Based on previous history
– Good for loops
• Delayed branch – rearrange instructions
(see RISC)
Branch Prediction State Diagram (two bits)
Branch Prediction Flowchart
Intel 80486 Pipelining
1. Fetch
– Put in one of two 16-byte prefetch buffers
– Fill buffer with new data as soon as old data consumed
– Average 5 instructions fetched per load (variable size)
– Independent of other stages to keep buffers full
1. Decode stage 1
– Opcode & address-mode info
– At most first 3 bytes of instruction needed for this
– Can direct D2 stage to get rest of instruction
1. Decode stage 2
– Expand opcode into control signals
– Computation of complex addressing modes
1. Execute
– ALU operations, cache access, register update
1. Writeback
– Update registers & flags
– Results sent to cache
Pentium 4 Registers
EFLAGS Register
Control Registers
Pentium Interrupt Processing
• Interrupts (hardware): (non-)maskable
• Exceptions (software): processor detected
(error) or programmed (exception)
• Interrupt vector table
– Each interrupt type assigned a number
– Index to vector table
– 256 * 32 bit interrupt vectors (address of ISR)
• 5 priority classes: 1. exception by previous
instruction 2. external interrupt, 3.-5. faults
from fetching, decoding or executing
instruction

More Related Content

What's hot

Pipelining
PipeliningPipelining
PipeliningAJAL A J
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipeliningTech_MX
 
Pipelining , structural hazards
Pipelining , structural hazardsPipelining , structural hazards
Pipelining , structural hazardsMunaam Munawar
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of PipeliningSHAKOOR AB
 
Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptmali yogesh kumar
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentationbhavanadonthi
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of ProcessorsGaditek
 
Performance Enhancement with Pipelining
Performance Enhancement with PipeliningPerformance Enhancement with Pipelining
Performance Enhancement with PipeliningAneesh Raveendran
 
Pipeline processing - Computer Architecture
Pipeline processing - Computer Architecture Pipeline processing - Computer Architecture
Pipeline processing - Computer Architecture S. Hasnain Raza
 
Pipeline Mechanism
Pipeline MechanismPipeline Mechanism
Pipeline MechanismAshik Iqbal
 

What's hot (20)

Pipelining
PipeliningPipelining
Pipelining
 
pipelining
pipeliningpipelining
pipelining
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
pipelining
pipeliningpipelining
pipelining
 
Pipelining , structural hazards
Pipelining , structural hazardsPipelining , structural hazards
Pipelining , structural hazards
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
 
Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
 
Pipelining
PipeliningPipelining
Pipelining
 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
 
Chapter6 pipelining
Chapter6  pipeliningChapter6  pipelining
Chapter6 pipelining
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of Processors
 
Performance Enhancement with Pipelining
Performance Enhancement with PipeliningPerformance Enhancement with Pipelining
Performance Enhancement with Pipelining
 
Pipelining & All Hazards Solution
Pipelining  & All Hazards SolutionPipelining  & All Hazards Solution
Pipelining & All Hazards Solution
 
Presentation on risc pipeline
Presentation on risc pipelinePresentation on risc pipeline
Presentation on risc pipeline
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazard
 
Pipelining1
Pipelining1Pipelining1
Pipelining1
 
Pipeline processing - Computer Architecture
Pipeline processing - Computer Architecture Pipeline processing - Computer Architecture
Pipeline processing - Computer Architecture
 
Pipeline Mechanism
Pipeline MechanismPipeline Mechanism
Pipeline Mechanism
 

Similar to pipeline and pipeline hazards

IT209 Cpu Structure Report
IT209 Cpu Structure ReportIT209 Cpu Structure Report
IT209 Cpu Structure ReportBis Aquino
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and functiondilip kumar
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and functionSher Shah Merkhel
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and functionAnwal Mirza
 
CPU Structure and Function.pptx
CPU Structure and Function.pptxCPU Structure and Function.pptx
CPU Structure and Function.pptxnagargorv
 
Computer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and MicrocontrollerComputer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and MicrocontrollerAmrutaMehata
 
Motivation for multithreaded architectures
Motivation for multithreaded architecturesMotivation for multithreaded architectures
Motivation for multithreaded architecturesYoung Alista
 
Computer organization & architecture chapter-1
Computer organization & architecture chapter-1Computer organization & architecture chapter-1
Computer organization & architecture chapter-1Shah Rukh Rayaz
 
03 top level view of computer function and interconnection
03 top level view of computer function and interconnection03 top level view of computer function and interconnection
03 top level view of computer function and interconnectionSher Shah Merkhel
 
Advanced Pipelining in ARM Processors.pptx
Advanced Pipelining  in ARM Processors.pptxAdvanced Pipelining  in ARM Processors.pptx
Advanced Pipelining in ARM Processors.pptxJoyChowdhury30
 
03_top-level-view-of-computer-function-and-interconnection.ppt
03_top-level-view-of-computer-function-and-interconnection.ppt03_top-level-view-of-computer-function-and-interconnection.ppt
03_top-level-view-of-computer-function-and-interconnection.pptAmirZaman21
 
Basic Computer Architecture
Basic Computer ArchitectureBasic Computer Architecture
Basic Computer ArchitectureYong Heui Cho
 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsButtaRajasekhar2
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsdilip kumar
 
For students wk4_computer_function_and_interconnection
For students wk4_computer_function_and_interconnectionFor students wk4_computer_function_and_interconnection
For students wk4_computer_function_and_interconnectionlimyamahgoub
 

Similar to pipeline and pipeline hazards (20)

IT209 Cpu Structure Report
IT209 Cpu Structure ReportIT209 Cpu Structure Report
IT209 Cpu Structure Report
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
 
Cs intro-ca
Cs intro-caCs intro-ca
Cs intro-ca
 
12 processor structure and function
12 processor structure and function12 processor structure and function
12 processor structure and function
 
CPU Structure and Function.pptx
CPU Structure and Function.pptxCPU Structure and Function.pptx
CPU Structure and Function.pptx
 
Computer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and MicrocontrollerComputer Organization: Introduction to Microprocessor and Microcontroller
Computer Organization: Introduction to Microprocessor and Microcontroller
 
03_Buses (1).ppt
03_Buses (1).ppt03_Buses (1).ppt
03_Buses (1).ppt
 
Motivation for multithreaded architectures
Motivation for multithreaded architecturesMotivation for multithreaded architectures
Motivation for multithreaded architectures
 
9781111306366 ppt ch3
9781111306366 ppt ch39781111306366 ppt ch3
9781111306366 ppt ch3
 
Ch8 main memory
Ch8   main memoryCh8   main memory
Ch8 main memory
 
Computer organization & architecture chapter-1
Computer organization & architecture chapter-1Computer organization & architecture chapter-1
Computer organization & architecture chapter-1
 
03 top level view of computer function and interconnection
03 top level view of computer function and interconnection03 top level view of computer function and interconnection
03 top level view of computer function and interconnection
 
07 input output
07 input output07 input output
07 input output
 
Advanced Pipelining in ARM Processors.pptx
Advanced Pipelining  in ARM Processors.pptxAdvanced Pipelining  in ARM Processors.pptx
Advanced Pipelining in ARM Processors.pptx
 
03_top-level-view-of-computer-function-and-interconnection.ppt
03_top-level-view-of-computer-function-and-interconnection.ppt03_top-level-view-of-computer-function-and-interconnection.ppt
03_top-level-view-of-computer-function-and-interconnection.ppt
 
Basic Computer Architecture
Basic Computer ArchitectureBasic Computer Architecture
Basic Computer Architecture
 
UNIT 3 - General Purpose Processors
UNIT 3 - General Purpose ProcessorsUNIT 3 - General Purpose Processors
UNIT 3 - General Purpose Processors
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
For students wk4_computer_function_and_interconnection
For students wk4_computer_function_and_interconnectionFor students wk4_computer_function_and_interconnection
For students wk4_computer_function_and_interconnection
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 

pipeline and pipeline hazards

  • 1. Chapter 12, William Stallings Computer Organization and Architecture 7th Edition CPU Structure and Function
  • 2. CPU Function • CPU must: – Fetch instructions – Interpret/decode instructions – Fetch data – Process data – Write data
  • 4. Registers • CPU must have some working space (temporary storage) - registers • Number and function vary between processor designs - one of the major design decisions • Top level of memory hierarchy
  • 5. User Visible Registers • General Purpose • Data • Address • Condition Codes
  • 6. General Purpose Registers (1) • May be true general purpose • May be restricted • May be used for data or addressing • Data: accumulator (AC) • Addressing: segment (cf. virtual memory), stack (points to top of stack, cf. implicit addressing)
  • 7. General Purpose Registers (2) • Make them general purpose – Increased flexibility and programmer options – Increased instruction size & complexity, addressing • Make them specialized – Smaller (faster) but more instructions – Less flexibility, addresses implicit in opcode
  • 8. How Many GP Registers? • Between 8 - 32 • Less = more memory references • More takes up processor real estate • See also RISC
  • 9. How big? • Large enough to hold full address • Large enough to hold full data types • But often possible to combine two data registers or two address registers by using more complex addressing (e.g., page and offset)
  • 10. Condition Code Registers – Flags • Sets of individual bits, flags – e.g., result of last operation was zero • Can be read by programs – e.g., Jump if zero – simplifies branch taking • Can not (usually) be set by programs
  • 11. Control & Status Registers • Program Counter (PC) • Instruction Register (IR) • Memory Address Register (MAR) – connects to address bus • Memory Buffer Register (MBR) – connects to data bus, feeds other registers
  • 12. Program Status Word • A set of bits • Condition Codes: – Sign (of last result) – Zero (last result) – Carry (multiword arithmetic) – Equal (two latest results) – Overflow • Interrupts enabled/disabled • Supervisor/user mode
  • 13. Supervisor Mode • Intel ring zero • Kernel mode • Allows privileged instructions to execute • Used by operating system • Not available to user programs
  • 14. Other Registers • May have registers pointing to: – Process control blocks (see OS) – Interrupt Vectors (see OS) • N.B. CPU design and operating system design are closely linked
  • 15.
  • 16. MC68000 and Intel registers • Motorola: – Largely general purpose registers – explicit addressing – Data registers also for indexing – A7 and A7’ for user and kernel stacks • Intel – Largely specific purpose registers – implicit addressing – Segment, Pointer & Index, Data/General purpose – Pentium II – backward compatibility
  • 17. Indirect Cycle • Same address can refer to different arguments (by changing the content of the location the address is pointing to) • Indirect addressing requires more memory accesses to fetch operands • Can be thought of as additional instruction subcycle
  • 20. Data Flow (Instruction Fetch) • PC contains address of next instruction • Address moved to MAR • Address placed on address bus • Control unit requests memory read • Result placed on data bus, copied to MBR, then to IR • Meanwhile PC incremented by 1
  • 21. Data Flow (Fetch Diagram)
  • 22. Data Flow (Data Fetch) • IR is examined • If indirect addressing, indirect cycle is performed – Rightmost n bits of MBR (address part of instruction) transferred to MAR – Control unit requests memory read – Result (address of operand) moved to MBR
  • 24. Data Flow (Execute) • May take many forms, depends on instruction being executed • May include – Memory read/write – Input/Output – Register transfers – ALU operations
  • 25. Data Flow (Interrupt) • Current PC saved to allow resumption after interrupt • Contents of PC copied to MBR • Special memory location (e.g., stack pointer) loaded to MAR • MBR written to memory according to content of MAR • PC loaded with address of interrupt handling routine • Next instruction (first of interrupt handler) can be fetched
  • 27. Prefetch • Fetch involves accessing main memory • Execution of ALU operations do not access main memory • Can fetch next instruction during execution of current instruction, cf. assembly line • Called instruction prefetch
  • 28. Improved Performance • But not doubled: – Fetch usually shorter than execution (cf. reading and storing operands) • Prefetch more than one instruction? – Any jump or branch means that prefetched instructions are not the required instructions • Add more stages to improve performance
  • 30. Pipelining (six stages) 1. Fetch instruction 2. Decode instruction 3. Calculate operands (i.e., EAs) 4. Fetch operands 5. Execute instructions 6. Write result • Overlap these operations
  • 31. Timing Diagram for Instruction Pipeline Operation (assuming independence)
  • 32. The Effect of a Conditional Branch/Interrupt on Instruction Pipeline Operation
  • 35. Dealing with Branches 1.Prefetch Branch Target 2.Loop buffer 3.Branch prediction 4.Delayed branching (see RISC)
  • 36. Prefetch Branch Target • Target of branch is prefetched in addition to instructions following branch • Keep target until branch is executed • Used by IBM 360/91
  • 37. Loop Buffer • Very fast memory • Maintained by fetch stage of pipeline • Check buffer before fetching from memory • Very good for small loops or jumps • cf. cache
  • 38. Branch Prediction (1) • Predict never taken – Assume that jump will not happen – Always (almost) fetch next instruction – VAX will not prefetch after branch if a page fault would result (OS v CPU design) • Predict always taken – Assume that jump will happen (at least 50%) – Always fetch target instruction
  • 39. Branch Prediction (2) • Predict by Opcode – Some instructions are more likely to result in a jump than others – Can get up to 75% success • Taken/Not taken switch – Based on previous history – Good for loops • Delayed branch – rearrange instructions (see RISC)
  • 40. Branch Prediction State Diagram (two bits)
  • 42. Intel 80486 Pipelining 1. Fetch – Put in one of two 16-byte prefetch buffers – Fill buffer with new data as soon as old data consumed – Average 5 instructions fetched per load (variable size) – Independent of other stages to keep buffers full 1. Decode stage 1 – Opcode & address-mode info – At most first 3 bytes of instruction needed for this – Can direct D2 stage to get rest of instruction 1. Decode stage 2 – Expand opcode into control signals – Computation of complex addressing modes 1. Execute – ALU operations, cache access, register update 1. Writeback – Update registers & flags – Results sent to cache
  • 46. Pentium Interrupt Processing • Interrupts (hardware): (non-)maskable • Exceptions (software): processor detected (error) or programmed (exception) • Interrupt vector table – Each interrupt type assigned a number – Index to vector table – 256 * 32 bit interrupt vectors (address of ISR) • 5 priority classes: 1. exception by previous instruction 2. external interrupt, 3.-5. faults from fetching, decoding or executing instruction