CSCI206 - Computer Organization & Programming

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
ELEN 468 Advanced Logic Design
CMPT 334 Computer Organization
1 A few words about the quiz Closed book, but you may bring in a page of handwritten notes. –You need to know what the “core” MIPS instructions do. –I.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Pipeline Hazards See: P&H Chapter 4.7.
Chapter Six Enhancing Performance with Pipelining
Pipelining Andreas Klappenecker CPSC321 Computer Architecture.
CSCE 212 Quiz 9 – 3/30/11 1.What is the clock cycle time based on for single-cycle and for pipelining? 2.What two actions can be done to resolve data hazards?
Appendix A Pipelining: Basic and Intermediate Concepts
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
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.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
Chapter 4 The Processor. Chapter 4 — The Processor — 2 Introduction We will examine two MIPS implementations A simplified version A more realistic pipelined.
Pipeline Hazards. CS5513 Fall Pipeline Hazards Situations that prevent the next instructions in the instruction stream from executing during its.
CMPE 421 Parallel Computer Architecture
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 4: Pipelining * Jeremy R. Johnson Wed. Oct. 18, 2000 *This lecture was derived.
1. Convert the RISCEE 1 Architecture into a pipeline Architecture (like Figure 6.30) (showing the number data and control bits). 2. Build the control line.
11 Pipelining Kosarev Nikolay MIPT Oct, Pipelining Implementation technique whereby multiple instructions are overlapped in execution Each pipeline.
CSE431 L06 Basic MIPS Pipelining.1Irwin, PSU, 2005 MIPS Pipeline Datapath Modifications  What do we need to add/modify in our MIPS datapath? l State registers.
Introduction to Computer Organization Pipelining.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
Simulator Outline of MIPS Simulator project  Write a simulator for the MIPS five-stage pipeline that does the following: Implements a subset of.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Lecture 5. MIPS Processor Design Pipelined MIPS #1 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE222, COMP212 Computer Architecture.
Chapter Six.
Pipeline Timing Issues
Computer Organization
Exceptions Another form of control hazard Could be caused by…
Stalling delays the entire pipeline
Pipelining Chapter 6.
CSCI206 - Computer Organization & Programming
Morgan Kaufmann Publishers
ELEN 468 Advanced Logic Design
Single Clock Datapath With Control
CDA 3101 Spring 2016 Introduction to Computer Organization
\course\cpeg323-08F\Topic6b-323
Processor Pipelining Yasser Mohammad.
Morgan Kaufmann Publishers The Processor
Pipelining review.
Single-cycle datapath, slightly rearranged
Pipelining Chapter 6.
Current Design.
Design of the Control Unit for One-cycle Instruction Execution
Pipelining in more detail
CSCI206 - Computer Organization & Programming
CSC 4250 Computer Architectures
\course\cpeg323-05F\Topic6b-323
Data Hazards Data Hazard
Pipeline control unit (highly abstracted)
Chapter Six.
The Processor Lecture 3.6: Control Hazards
Chapter Six.
Pipelining Chapter 6.
Daxia Ge Friday February 9th, 2007
Pipeline control unit (highly abstracted)
COMP541 Datapaths I Montek Singh Mar 18, 2010.
Pipelining: Basic Concepts
Pipeline Control unit (highly abstracted)
Pipelining Chapter 6.
Morgan Kaufmann Publishers The Processor
Introduction to Computer Organization and Architecture
Pipelining Chapter 6.
Guest Lecturer: Justin Hsia
Pipelining - 1.
MIPS Pipelined Datapath
Problem ??: (?? marks) Consider executing the following code on the MIPS pipelined datapath: add $t5, $t6, $t8 add $t9, $t5, $t4 lw $t3, 100($t9) sub $t2,
Need to stall for one cycle.
Pipelining Hazards.
Presentation transcript:

CSCI206 - Computer Organization & Programming Pipeline Datapath and Control zyBook: 11.6

The MIPS Pipeline

Implementation MIPS was designed to be pipelined All instructions are the same length (bits) allows fetch of next instruction immediately Operands aligned in memory constant length memory access Few (3) instruction formats simplifies decode Few addressing modes simplifies address generation

Splitting the datapath

Add Pipeline Registers Pipeline registers are clocked, just like the PC register. How many bits? Add Pipeline Registers

Executing a lw - cycle 1

Executing a lw - cycle 2

Executing a lw - cycle 3

Executing a lw - cycle 4

Executing a lw - cycle 5

Pipeline Registers with Control Control signals are computed in ID (decode) and then passed down the pipeline.

Pipeline Hazards Data Hazard Definition: when one instruction depends on the result of another: sub needs the result of the add ($s0)! add $s0, $t0, $t1 sub $t2, $s0, $t3

Pipeline diagram Sub tries to read $s0 and $t3 in cycle 3. clock cycle 1 2 3 4 5 6 7 8 add $s0, $t0, $t1 F D E M W sub $t2, $s0, $t3 Instructions Register write happens before read, so we can write and read in cycle 5! Sub tries to read $s0 and $t3 in cycle 3. The add doesn’t write the result until cycle 5! In the diagram above, the decode stage fails in cycle 3 and 4 (shown with a --) until $s0 is written in cycle 5 This is called a pipeline stall and should be avoided!

draw the pipeline diagrams Data Hazards→Reorder The best solution is to reorder instructions add $s0, $t0, $t1 sub $t2, $s0, $t3 addi $t4, $t4, 32 sll $t5, $t5, 5 add $s0, $t0, $t1 addi $t4, $t4, 32 sub $t2, $s0, $t3 sll $t5, $t5, 5 add $s0, $t0, $t1 addi $t4, $t4, 32 sll $t5, $t5, 5 sub $t2, $s0, $t3 Bad! Good! Better! draw the pipeline diagrams

Data Hazards→Forwarding Ex to Ex forward Consider the pipeline diagram, the sub needs $s0 at the beginning of cycle 4. Add computes this result in cycle 3. So we can forward (or bypass) the rest of the pipeline to deliver the value for $s0 just in time!

Data Hazards→Forwarding Mem to Ex forward The lw instruction is not complete until the end of the MEM stage. If the result is used immediately, we must insert a one cycle stall (or bubble). Then, we can forward the result directly from mem to ex.

Control Hazards Control Hazard When the result of one instruction changes the next instruction (i.e. branches) beq is computed using the ALU in the Ex stage What instruction do we fetch after the beq? add $4, $5, $5 beq $1, $2, 40 ???

Control Hazard Solution: beq calculation is easy (sub), so add a dedicated adder to the decode stage to immediately compute the zero result (in ID) Results in a one-cycle stall

Control Hazard Delay slot In MIPS, this obligatory stall after a branch is utilized for an instruction. The CPU will always execute the next assembly instruction and then execute the branch. (this is why we put a nop after branches & jumps in lab!)

Structural Hazard Structural Hazard If hardware cannot execute certain instructions at the same time MIPS avoids this for all integer instructions some floating point operations have structural hazards Reorder instructions to avoid else the CPU will stall to avoid

Pipeline Metrics Instructions per clock (IPC) or Ideally on a single core CPU we want IPC == 1, but hazards make this impossible in practice Instructions per clock (IPC) or clocks per instruction (CPI) recall