Pipelined Datapath and Control

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

MIPS Pipelined Datapath
Pipeline Hazards CS365 Lecture 10. D. Barbara Pipeline Hazards CS465 2 Review  Pipelined CPU  Overlapped execution of multiple instructions  Each on.
ECE 445 – Computer Organization
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Pipelined Processor.
Part 2 - Data Hazards and Forwarding 3/24/04++
Review: MIPS Pipeline Data and Control Paths
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 18 - Pipelined.
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
Chapter Six Enhancing Performance with Pipelining
1 Stalling  The easiest solution is to stall the pipeline  We could delay the AND instruction by introducing a one-cycle delay into the pipeline, sometimes.
 The actual result $1 - $3 is computed in clock cycle 3, before it’s needed in cycles 4 and 5  We forward that value to later instructions, to prevent.
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
Computer Organization Lecture Set – 06 Chapter 6 Huei-Yung Lin.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
1 Stalls and flushes  So far, we have discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
Lecture 15: Pipelining and Hazards CS 2011 Fall 2014, Dr. Rozier.
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-2 Read Section 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
Chapter 4 CSF 2009 The processor: Pipelining. Performance Issues Longest delay determines clock period – Critical path: load instruction – Instruction.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2012 Revised from original slides provided by MKP.
Basic Pipelining & MIPS Pipelining Chapter 6 [Computer Organization and Design, © 2007 Patterson (UCB) & Hennessy (Stanford), & Slides Adapted from: Mary.
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
2/15/02CSE Data Hazzards Data Hazards in the Pipelined Implementation.
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
Computing Systems Pipelining: enhancing performance.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-1 Read Sections 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Pipeline Timing Issues
Stalling delays the entire pipeline
Note how everything goes left to right, except …
Morgan Kaufmann Publishers The Processor
Single Clock Datapath With Control
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
ECE232: Hardware Organization and Design
Morgan Kaufmann Publishers The Processor
Data Hazards and Stalls
Data Hazards and Stalls
Forwarding Now, we’ll introduce some problems that data hazards can cause for our pipelined processor, and show how to handle them with forwarding.
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
Csci 136 Computer Architecture II – Data Hazard, Forwarding, Stall
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Chapter 4 The Processor Part 2
Single-cycle datapath, slightly rearranged
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
Computer Organization CS224
Pipelining in more detail
Pipelined Control (Simplified)
The Processor Lecture 3.5: Data Hazards
Instruction Execution Cycle
CSC3050 – Computer Architecture
Pipeline Control unit (highly abstracted)
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Pipelined Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Systems Architecture II
Stalls and flushes Last time, we discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
MIPS Pipelined Datapath
©2003 Craig Zilles (derived from slides by Howard Huang)
Need to stall for one cycle.
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

Pipelined Datapath and Control Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

MIPS Pipelined Datapath Morgan Kaufmann Publishers 24 April, 2017 MIPS Pipelined Datapath §4.6 Pipelined Datapath and Control MEM Right-to-left flow leads to hazards WB Chapter 4 — The Processor — 2 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 Pipeline registers Need registers between stages To hold information produced in previous cycle Chapter 4 — The Processor — 3 Chapter 4 — The Processor

The Pipeline Registers IF/ID This provides an execution context for the ID (Instruction Decode and Register Fetch) stage of execution. ID/EX This provides an execution context for the EX (Execute) phase of instruction execution. In particular, the discrete control signals generated by the control unit as a result of instruction decoding are stored here. EX/MEM This provides an execution context for the MEM (Memory Access or R-Type Instruction Completion) phase of instruction execution. In addition , this register stores copies of the control signals required to complete both the MEM and WB phase of execution for this instruction. MEM/WB This provides an execution context for the WB (Write Back) phase of instruction execution.

Morgan Kaufmann Publishers 24 April, 2017 Pipeline Operation Cycle-by-cycle flow of instructions through the pipelined datapath “Single-clock-cycle” pipeline diagram Shows pipeline usage in a single cycle Highlight resources used c.f. “multi-clock-cycle” diagram Graph of operation over time We’ll look at “single-clock-cycle” diagrams for load & store Chapter 4 — The Processor — 5 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 IF for Load, Store, … Chapter 4 — The Processor — 6 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 ID for Load, Store, … Chapter 4 — The Processor — 7 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 EX for Load Chapter 4 — The Processor — 8 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 MEM for Load Chapter 4 — The Processor — 9 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 WB for Load Wrong register number Chapter 4 — The Processor — 10 Chapter 4 — The Processor

Corrected Datapath for Load Morgan Kaufmann Publishers 24 April, 2017 Corrected Datapath for Load Chapter 4 — The Processor — 11 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 EX for Store Chapter 4 — The Processor — 12 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 MEM for Store Chapter 4 — The Processor — 13 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 WB for Store Chapter 4 — The Processor — 14 Chapter 4 — The Processor

Multi-Cycle Pipeline Diagram Morgan Kaufmann Publishers 24 April, 2017 Multi-Cycle Pipeline Diagram Form showing resource usage Chapter 4 — The Processor — 15 Chapter 4 — The Processor

Multi-Cycle Pipeline Diagram Morgan Kaufmann Publishers 24 April, 2017 Multi-Cycle Pipeline Diagram Traditional form Chapter 4 — The Processor — 16 Chapter 4 — The Processor

Single-Cycle Pipeline Diagram Morgan Kaufmann Publishers 24 April, 2017 Single-Cycle Pipeline Diagram State of pipeline in a given cycle Chapter 4 — The Processor — 17 Chapter 4 — The Processor

Pipelined Control (Simplified) Morgan Kaufmann Publishers 24 April, 2017 Pipelined Control (Simplified) Chapter 4 — The Processor — 18 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 Pipelined Control Control signals derived from instruction As in single-cycle implementation Chapter 4 — The Processor — 19 Chapter 4 — The Processor

The Control Signals by Phase Instruction Fetch There are no control signals specific to this stage. Instruction Decode There are no instruction–specific control signals in this step. Execute There are three control signals associated with this step. RegDst This selects which field, IR[20:16] or IR[15:11] will be used as the register destination number for the Write Register in WB. The five bit value selected is written into EX/MEM and copied to MEM/WB. ALUOp This is the two–bit selector of the ALU operation. ALUSrc This discrete control signal selects the B input to the ALU.

Control Signals by Phase Memory Access There are three control signals associated with this step. Branch This indicates that a branch instruction is in this stage. MemRead The ALU output is used as a memory address that is read. This is set by the LW instruction. MemWrite The ALU output is used as a memory address, to which the contents of the specified register are written. This is set by the SW instruction. Write Back There are two control signals associated with this step. MemToReg This selects either the ALU output or memory output to be written back to the register file RegWrite This causes the selected value to be written to the specified register.

Morgan Kaufmann Publishers 24 April, 2017 Pipelined Control Chapter 4 — The Processor — 22 Chapter 4 — The Processor

Size of the Pipeline Registers   IF/ID ID/EX EX/MEM MEM/WB Program Counter 32 Machine Language Instruction Register 1 Read Data Register 2 Read Data Sign Extended Address Offset Discrete Control Signals 9 5 2 ALU Function Code 6 Shift Amount ALU Result ALU Discrete Output: Zero 1 Data read from memory Destination Register Number 10 TOTAL BITS 64 158 107 103

Data Hazards in ALU Instructions Morgan Kaufmann Publishers 24 April, 2017 Data Hazards in ALU Instructions Consider this sequence: sub $2, $1,$3 and $12,$2,$5 or $13,$6,$2 add $14,$2,$2 sw $15,100($2) We can resolve hazards with forwarding How do we detect when to forward? §4.7 Data Hazards: Forwarding vs. Stalling Chapter 4 — The Processor — 24 Chapter 4 — The Processor

Dependencies & Forwarding Morgan Kaufmann Publishers 24 April, 2017 Dependencies & Forwarding Chapter 4 — The Processor — 25 Chapter 4 — The Processor

Detecting the Need to Forward Morgan Kaufmann Publishers 24 April, 2017 Detecting the Need to Forward Pass register numbers along pipeline e.g., ID/EX.RegisterRs = register number for Rs sitting in ID/EX pipeline register ALU operand register numbers in EX stage are given by ID/EX.RegisterRs, ID/EX.RegisterRt Data hazards when 1a. EX/MEM.RegisterRd = ID/EX.RegisterRs 1b. EX/MEM.RegisterRd = ID/EX.RegisterRt 2a. MEM/WB.RegisterRd = ID/EX.RegisterRs 2b. MEM/WB.RegisterRd = ID/EX.RegisterRt Fwd from EX/MEM pipeline reg Fwd from MEM/WB pipeline reg Chapter 4 — The Processor — 26 Chapter 4 — The Processor

Detecting the Need to Forward Morgan Kaufmann Publishers 24 April, 2017 Detecting the Need to Forward But only if forwarding instruction will write to a register! EX/MEM.RegWrite, MEM/WB.RegWrite And only if Rd for that instruction is not $zero EX/MEM.RegisterRd ≠ 0, MEM/WB.RegisterRd ≠ 0 Chapter 4 — The Processor — 27 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 Forwarding Paths Chapter 4 — The Processor — 28 Chapter 4 — The Processor

Forwarding Conditions Morgan Kaufmann Publishers 24 April, 2017 Forwarding Conditions EX hazard if (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) ForwardA = 10 #Two bit control signal to MUX if (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) ForwardB = 10 MEM hazard if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0) and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 Chapter 4 — The Processor — 29 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 Double Data Hazard Consider the sequence: add $1,$1,$2 add $1,$1,$3 add $1,$1,$4 Both hazards occur Want to use the most recent Revise MEM hazard condition Only fwd if EX hazard condition isn’t true Chapter 4 — The Processor — 30 Chapter 4 — The Processor

Revised Forwarding Condition Morgan Kaufmann Publishers 24 April, 2017 Revised Forwarding Condition MEM hazard if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0) and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0) and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 Chapter 4 — The Processor — 31 Chapter 4 — The Processor

Datapath with Forwarding Morgan Kaufmann Publishers 24 April, 2017 Datapath with Forwarding Chapter 4 — The Processor — 32 Chapter 4 — The Processor

Morgan Kaufmann Publishers 24 April, 2017 Load-Use Data Hazard Need to stall for one cycle Chapter 4 — The Processor — 33 Chapter 4 — The Processor

Load-Use Hazard Detection Morgan Kaufmann Publishers 24 April, 2017 Load-Use Hazard Detection Check when using instruction is decoded in ID stage ALU operand register numbers in ID stage are given by IF/ID.RegisterRs, IF/ID.RegisterRt Load-use hazard when ID/EX.MemRead and ((ID/EX.RegisterRt = IF/ID.RegisterRs) or (ID/EX.RegisterRt = IF/ID.RegisterRt)) If detected, stall and insert bubble Chapter 4 — The Processor — 34 Chapter 4 — The Processor

How to Stall the Pipeline Morgan Kaufmann Publishers 24 April, 2017 How to Stall the Pipeline Force control values in ID/EX register to 0 EX, MEM and WB do nop (no-operation) Prevent update of PC and IF/ID register Using instruction is decoded again Following instruction is fetched again 1-cycle stall allows MEM to read data for lw Can subsequently forward to EX stage Chapter 4 — The Processor — 35 Chapter 4 — The Processor

Stall/Bubble in the Pipeline Morgan Kaufmann Publishers 24 April, 2017 Stall/Bubble in the Pipeline Stall inserted here Chapter 4 — The Processor — 36 Chapter 4 — The Processor

Stalls and Performance Morgan Kaufmann Publishers 24 April, 2017 Stalls and Performance The BIG Picture Stalls reduce performance But are required to get correct results Compiler can arrange code to avoid hazards and stalls Requires knowledge of the pipeline structure Chapter 4 — The Processor — 37 Chapter 4 — The Processor