Pipelined datapath Staging data. CS2504, Spring'2007 Dimitris Nikolopoulos

Similar documents
ECE260: Fundamentals of Computer Engineering

Lecture Topics. Announcements. Today: Data and Control Hazards (P&H ) Next: continued. Exam #1 returned. Milestone #5 (due 2/27)

zhandling Data Hazards The objectives of this module are to discuss how data hazards are handled in general and also in the MIPS architecture.

Processor (II) - pipelining. Hwansoo Han

Full Datapath. Chapter 4 The Processor 2

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

The Processor (3) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

ECE473 Computer Architecture and Organization. Pipeline: Data Hazards

Chapter 4 The Processor 1. Chapter 4B. The Processor

Pipeline Hazards. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSEE 3827: Fundamentals of Computer Systems

Chapter 4. The Processor

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

ECS 154B Computer Architecture II Spring 2009

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN

Chapter 4 The Processor 1. Chapter 4A. The Processor

LECTURE 9. Pipeline Hazards

EE557--FALL 1999 MIDTERM 1. Closed books, closed notes

Full Datapath. Chapter 4 The Processor 2

Outline Marquette University

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 4. The Processor

Department of Computer and IT Engineering University of Kurdistan. Computer Architecture Pipelining. By: Dr. Alireza Abdollahpouri

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

COMP2611: Computer Organization. The Pipelined Processor

ECE260: Fundamentals of Computer Engineering

14:332:331 Pipelined Datapath

ECE154A Introduction to Computer Architecture. Homework 4 solution

CENG 3420 Lecture 06: Pipeline

Design a MIPS Processor (2/2)

ELE 655 Microprocessor System Design

DEE 1053 Computer Organization Lecture 6: Pipelining

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

CPE 335 Computer Organization. Basic MIPS Pipelining Part I

Determined by ISA and compiler. We will examine two MIPS implementations. A simplified version A more realistic pipelined version

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

Chapter 4. The Processor

Thomas Polzer Institut für Technische Informatik

Chapter 4. The Processor

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Midnight Laundry. IC220 Set #19: Laundry, Co-dependency, and other Hazards of Modern (Architecture) Life. Return to Chapter 4

Chapter 4. The Processor

LECTURE 3: THE PROCESSOR

CS 2506 Computer Organization II Test 2. Do not start the test until instructed to do so! printed

EIE/ENE 334 Microprocessors

CS232 Final Exam May 5, 2001

Chapter 4. The Processor

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition. Chapter 4. The Processor

Pipelining. lecture 15. MIPS data path and control 3. Five stages of a MIPS (CPU) instruction. - factory assembly line (Henry Ford years ago)

CS 251, Winter 2018, Assignment % of course mark

Chapter 6 Exercises with solutions

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

Pipeline design. Mehran Rezaei

Codeword[1] Codeword[0]

CSE Quiz 3 - Fall 2009

Chapter 4. The Processor. Jiang Jiang

ECEC 355: Pipelining

University of Jordan Computer Engineering Department CPE439: Computer Design Lab

Processor Design Pipelined Processor (II) Hung-Wei Tseng

Designing a Pipelined CPU

EE557--FALL 1999 MAKE-UP MIDTERM 1. Closed books, closed notes

CS232 Final Exam May 5, 2001

CSE 378 Midterm 2/12/10 Sample Solution

CS 251, Winter 2019, Assignment % of course mark

Instruction word R0 R1 R2 R3 R4 R5 R6 R8 R12 R31

Data Hazards Compiler Scheduling Pipeline scheduling or instruction scheduling: Compiler generates code to eliminate hazard

ECE Exam II - Solutions October 30 th, :35 pm 5:55pm

EE2011 Computer Organization Lecture 10: Enhancing Performance with Pipelining ~ Pipelined Datapath

Computer Organization and Structure

Virtual memory. Hung-Wei Tseng

Pipelining. Pipeline performance

Pipeline Data Hazards. Dealing With Data Hazards

EECS150 - Digital Design Lecture 10- CPU Microarchitecture. Processor Microarchitecture Introduction

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

Control Hazards - branching causes problems since the pipeline can be filled with the wrong instructions.

CS3350B Computer Architecture Quiz 3 March 15, 2018

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

Forwarding. March 31, Howard Huang 1

Perfect Student CS 343 Final Exam May 19, 2011 Student ID: 9999 Exam ID: 9636 Instructions Use pencil, if you have one. For multiple choice

Processor (I) - datapath & control. Hwansoo Han

COSC121: Computer Systems. ISA and Performance

SI232 Set #20: Laundry, Co-dependency, and other Hazards of Modern (Architecture) Life. Chapter 6 ADMIN. Reading for Chapter 6: 6.1,

Outline. A pipelined datapath Pipelined control Data hazards and forwarding Data hazards and stalls Branch (control) hazards Exception

Virtual memory. Hung-Wei Tseng

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

(Basic) Processor Pipeline

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Unresolved data hazards. CS2504, Spring'2007 Dimitris Nikolopoulos

COMPUTER ORGANIZATION AND DESIGN

EECS150 - Digital Design Lecture 9- CPU Microarchitecture. Watson: Jeopardy-playing Computer

Slides for Lecture 15

1 Hazards COMP2611 Fall 2015 Pipelined Processor

Microprogrammed Control Approach

CS 2506 Computer Organization II Test 2

Question 1: (20 points) For this question, refer to the following pipeline architecture.

Basic Instruction Timings. Pipelining 1. How long would it take to execute the following sequence of instructions?

CS/CoE 1541 Exam 1 (Spring 2019).

Pipelined Datapath. Reading. Sections Practice Problems: 1, 3, 8, 12

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

Transcription:

Pipelined datapath Staging data b 55

Life of a load in the MIPS pipeline Note: both the instruction and the incremented PC value need to be forwarded in the next stage (in case the instruction is a beq) Note:works in the same way for stores. 56

Life of a load in the MIPS pipeline Note: ALU uses the sign-extended 16-bit immediate operand and reg1. Latches keep forwarding all register values and PC+4. 57

Life of a load in the MIPS pipeline Note: Latches keep forwarding all register values and PC+4. 58

Life of a store in the MIPS pipeline Note:Third stage differs from load in that the value of the second register needs to be forwarded to the MEM stage 59

Life of a store in the MIPS pipeline Note:MEM stage differs because memory is written. Write back stage differs because nothing is written to the register file. 60

Designing the pipeline All needed information needs to be forwarded through the pipeline registers, e.g. register 2 in the store instruction Each resource can be used in a single pipeline stage, or else we will have structural hazards. 61

Fixing the pipeline for load 62

Alternative pipeline representation 63

Pipeline control No write control needed in IF stage since PC is always written. Multilpexor needed to decide between branch target and PC+4 64

Pipeline control No control in ID/reg. read stage. Register write is asserted in writeback steage. 65

Pipeline control EX stage needs ALUSrc to decide whether operand comes from register file or is immediate.regdst signal decides which is the destination register (different field in R-instructions and instructions with < 3 reg. operand). Finally, ALUOp controls ALU operation 66

Pipeline control MEM stage controls branch, loads and stores. WB stage controls MemToReg to send memory or register value to register file. WB also sets RegWrite signal 67

Data Hazards A Bad Sequence sub $2,$1,$3 and $12,$2,$5 or $13,$6,$2 add $14,$2,$2 sw $15,100($2) 68

Data Hazards A Bad Sequence Only add and sw get the correct result. Backward lines are trouble! Data hazard can be resolved by forwarding from the EX stage of earlier instruction to the EX stage of later instruction. 69

Formally Detecting Hazards EX/MEM.RegisterRd = ID/EX.RegisterRs EX/MEM.RegisterRd = ID/EX.RegisterRt MEM/WB.RegisterRd = ID/EX.RegisterRs MEM/WB.RegisterRd = ID/EX.RegisterRt sub $2,$1,$3 and $12,$2,$5 MEM/WB.RegisterRd = ID/EX.RegisterRs = $2 70

Accurate Detection of Hazards Some instructions do not write back to registers. Therefore, we need forwards only if MEM/WB.RegisterRd 0. $0 pinned to zero, therefore we do not forward values destined to $0, i.e. EX/MEM.RegisterRd 0 71

Implementing Forwarding The trick is to use the pipeline registers (EX/MEM, MEM/WB) to hold the calculated values from the ALU and forward them to later instructions. To do that we need to take inputs in the ALU from EX/MEM, MEM/WB 72

Implementing Forwarding More potential inputs to the ALU, therefore we need a multiplexer. 73

Implementing Forwarding More potential inputs to the ALU, therefore we need a multiplexer. 74

Implementing Forwarding Logic: Forwarding possibly for R-instructions. Need to pass register numbers in the IF/ID and ID/EX stage and detect whether the source register of a later instruction has the same number as the Rd registers of an earlier instruction 75

Forwarding Logic if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (Ex/MEM.RegisterRd = ID/EXRegisterRs)) Forward A = 10 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (Ex/MEM.RegisterRd = ID/EXRegisterRt)) Forward B = 10 76

Forwarding Logic 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 77

Forwarding Logic No hazard in WB stage, because instruction can write to and read from register file in the same stage. One more complication: add $1, $1, $2 add $1, $1, $3 add $1, $1, $4 Forwarding simultaneously from the WB and the MEM stage. Need to obtain latest value of $1! 78

Corrected forwarding Logic if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0) and (EX/MEM.RegisterRd ID/EX.RegisterRs) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA =01 79

Corrected forwarding logic 80