Morgan Kaufmann Publishers The Processor

Slides:



Advertisements
Similar presentations
Pipeline Exceptions & ControlCSCE430/830 Pipelining in MIPS MIPS architecture was designed to be pipelined –Simple instruction format (makes IF, ID easy)
Advertisements

Pipeline Example: cycle 1 lw R10,9(R1) sub R11,R2, R3 and R12,R4, R5 or R13,R6, R7.
Pipelined Processor II (cont’d) CPSC 321
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
 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.
Lecture 28: Chapter 4 Today’s topic –Data Hazards –Forwarding 1.
Supplementary notes for pipelining LW ____,____ SUB ____,____,____ BEQ ____,____,____ ; assume that, condition for branch is not satisfied OR ____,____,____.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
Pipelined Datapath and Control
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.
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
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.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Lecture 9 Pipeline Hazards.
Stalling delays the entire pipeline
Note how everything goes left to right, except …
Computer Architecture
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Single Clock Datapath With Control
Morgan Kaufmann Publishers The Processor
ECS 154B Computer Architecture II Spring 2009
\course\cpeg323-08F\Topic6b-323
ECE232: Hardware Organization and Design
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
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
CSCI206 - Computer Organization & Programming
Single-cycle datapath, slightly rearranged
Morgan Kaufmann Publishers Enhancing Performance with Pipelining
Computer Organization CS224
A pipeline diagram Clock cycle lw $t0, 4($sp) IF ID
CSCI206 - Computer Organization & Programming
Systems Architecture II
\course\cpeg323-05F\Topic6b-323
Pipelined Control (Simplified)
Pipeline control unit (highly abstracted)
The Processor Lecture 3.2: Building a Datapath with Control
The Processor Lecture 3.5: Data Hazards
Instruction Execution Cycle
Pipeline control unit (highly abstracted)
Pipeline Control unit (highly abstracted)
Pipelining (II).
Morgan Kaufmann Publishers The Processor
Pipelining - 1.
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.
The Processor: Datapath & Control.
©2003 Craig Zilles (derived from slides by Howard Huang)
Pipelined datapath and control
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

Morgan Kaufmann Publishers The Processor 10 November, 2018 Chapter 4 The Processor Chapter 4 — The Processor

Pipelined Control (Simplified) Morgan Kaufmann Publishers Pipelined Control (Simplified) 10 November, 2018 Chapter 4 — The Processor

Pipelined Control We need only set the control values during each pipeline stage: Instruction fetch: The control signals to read instruction memory and to write the PC are always asserted, so there is nothing special to control in this pipeline stage. Instruction decode/register file read: We need to select the correct register number for read register 2, so the signal Reg2Loc is set. The signal selects instruction bits 20:16 (Rm) or 4:0 (Rt). Execution/address calculation: The signals to be set are ALUOp and ALUSrc. The signals select the ALU operation and either Read data 2 or a sign-extended immediate as inputs to the ALU. Memory access: The control lines set in this stage are Branch, MemRead, and MemWrite. The compare and branch on zero, load, and store instructions set these signals, respectively. Recall that PCSrc selects the next sequential address unless control asserts Branch and the ALU result was 0. Write-back: The two control lines are MemtoReg, which decides between sending the ALU result or the memory value to the register file, and RegWrite, which writes the chosen value.

Pipelined Control Nine control lines grouped by pipeline stage: Reg2Loc to read the right register instruction bit 28 is a 0 for R-format instructions and a 1 for the rest connect instruction bit 28 to Reg2Loc Extend the pipeline registers to include control information these control signals are then used in the appropriate pipeline stage as the instruction moves down the pipeline

Morgan Kaufmann Publishers Pipelined Control 10 November, 2018 Control signals derived from instruction as in single-cycle implementation Three of the eight control lines are used in the EX phase, with the remaining five control lines passed on to the EX/MEM pipeline register Chapter 4 — The Processor

Morgan Kaufmann Publishers Pipelined Control 10 November, 2018 Full datapath with the extended pipeline registers and with the control lines connected to the proper stage along with the instruction bit 28 controlling the Reg2Loc register address multiplexor Chapter 4 — The Processor

Data Hazards in ALU Instructions Morgan Kaufmann Publishers Data Hazards in ALU Instructions 10 November, 2018 Consider this sequence: SUB X2, X1,X3 AND X12,X2,X5 OR X13,X6,X2 ADD X14,X2,X2 STUR X15,[X2,#100] We can resolve hazards with forwarding How do we detect when to forward? Forward to an operation in the EX stage, which may be either an ALU operation or an effective address calculation. When an instruction tries to use a register in its EX stage that an earlier instruction intends to write in its WB stage, we actually need the values as inputs to the ALU. §4.7 Data Hazards: Forwarding vs. Stalling Chapter 4 — The Processor

Notation for Dependence Morgan Kaufmann Publishers Notation for Dependence 10 November, 2018 A notation that names the fields of the pipeline registers E.g. ID/EX.RegisterRn1 = number of one register whose value is found in the pipeline register ID/EX ID/EX: name of pipeline register, RegisterRn1: name of the field in the pipeline register ALU operand register numbers in EX stage are given by ID/EX.RegisterRn1, ID/EX.RegisterRm2 Data hazards when 1a. EX/MEM.RegisterRd = ID/EX.RegisterRn1 1b. EX/MEM.RegisterRd = ID/EX.RegisterRm2 2a. MEM/WB.RegisterRd = ID/EX.RegisterRn1 2b. MEM/WB.RegisterRd = ID/EX.RegisterRm2 Fwd from EX/MEM pipeline reg Fwd from MEM/WB pipeline reg Chapter 4 — The Processor

Dependence Detection Class dependencies in the following sequence: SUB X2, X1,X3 AND X12,X2,X5 OR X13,X6,X2 ADD X14,X2,X2 STUR X15,[X2,#100] The SUB-AND is a type 1a hazard because X2 in the AND instruction is in EX stage and SUB is in the MEM stage. EX/MEM.RegisterRd =ID/EX.RegisterRn1 =X2 The SUB–ORR is a type 2b hazard: MEM/WB.RegisterRd =ID/EX.RegisterRm2 =X2 The two dependences on SUB–ADD are not hazards because the register file supplies the proper data during the ID stage of ADD. There is no data hazard between SUB and STUR because STUR reads X2 the clock cycle after SUB writes X2.

Detecting the Need to Forward Morgan Kaufmann Publishers 10 November, 2018 Detecting the Need to Forward But only if forwarding instruction will write to a register! Check to see if the RegWrite signal will be active: examine the WB control field of the pipeline register during the EX and MEM stages EX/MEM.RegWrite, MEM/WB.RegWrite If an instruction in the pipeline has XZR as its destination, avoid forwarding its possibly nonzero result value. E.g. SUBS XZR,X1,2 The conditions work properly as long as we add EX/MEM.RegisterRd ≠ 31 to the first hazard condition, and MEM/WB.RegisterRd ≠ 31 to the second hazard condition Chapter 4 — The Processor

Dependencies & Forwarding Morgan Kaufmann Publishers Dependencies & Forwarding 10 November, 2018 Chapter 4 — The Processor

Morgan Kaufmann Publishers Forwarding Paths 10 November, 2018 By adding multiplexors to the input of the ALU, and with the proper controls, we can run the pipeline at full speed in the presence of these data hazards. Chapter 4 — The Processor

Forwarding Conditions Morgan Kaufmann Publishers Forwarding Conditions 10 November, 2018 Mux control Source Explanation ForwardA = 00 ID/EX The first ALU operand comes from the register file. ForwardA = 10 EX/MEM The first ALU operand is forwarded from the prior ALU result. ForwardA = 01 MEM/WB The first ALU operand is forwarded from data memory or an earlier ALU result. ForwardB = 00 The second ALU operand comes from the register file. ForwardB = 10 The second ALU operand is forwarded from the prior ALU result. ForwardB = 01 The second ALU operand is forwarded from data memory or an earlier ALU result. Chapter 4 — The Processor

Hazard Conditions and Control Signals EX hazard: if (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 31) and (EX/MEM.RegisterRd = ID/EX.RegisterRn1)) ForwardA = 10 and (EX/MEM.RegisterRd = ID/EX.RegisterRm2)) ForwardB = 10 This case forwards the result from the previous instruction to either input of the ALU.

Hazard Conditions and Control Signals MEM hazard: if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 31) and (MEM/WB.RegisterRd = ID/EX.RegisterRn1)) ForwardA = 01 and (MEM/WB.RegisterRd = ID/EX.RegisterRm2)) ForwardB = 01 As mentioned above, there is no hazard in the WB stage, because we assume that the register file supplies the correct result if the instruction in the ID stage reads the same register written by the instruction in the WB stage. Such a register file performs another form of forwarding, but it occurs within the register file.

Morgan Kaufmann Publishers 10 November, 2018 Double Data Hazard Consider the sequence: add X1,X1,X2 add X1,X1,X3 add X1,X1,X4 Both hazards occur Want to use the most recent, i.e. results forwarded from MEM stage Revise MEM hazard condition Only fwd if EX hazard condition isn’t true Chapter 4 — The Processor