Multi-cycle Implementations Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology January 13, 2012L6-1

Slides:



Advertisements
Similar presentations
CS/COE1541: Introduction to Computer Architecture Datapath and Control Review Sangyeun Cho Computer Science Department University of Pittsburgh.
Advertisements

Computer Architecture: A Constructive Approach Six Stage Pipeline/Bypassing Joel Emer Computer Science & Artificial Intelligence Lab. Massachusetts Institute.
1 RISC Pipeline Han Wang CS3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 4.6.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture Pipelining III Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture MIPS Review & Pipelining I Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture ISAs and MIPS Steve Ko Computer Sciences and Engineering University at Buffalo.
CS-447– Computer Architecture Lecture 12 Multiple Cycle Datapath
CS 152 Computer Architecture and Engineering Lecture 4 - Pipelining Krste Asanovic Electrical Engineering and Computer Sciences University of California.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
January 26, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 3 - From CISC to RISC Krste Asanovic Electrical Engineering and.
January 26, 2010CS152, Spring 2010 CS 152 Computer Architecture and Engineering Lecture 3 - From CISC to RISC Krste Asanovic Electrical Engineering and.
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
January 31, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 4 - Pipelining Krste Asanovic Electrical Engineering and Computer.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
CS 152 Computer Architecture and Engineering Lecture 4 - Pipelining Krste Asanovic Electrical Engineering and Computer Sciences University of California.
Computer Architecture: A Constructive Approach Instruction Representation Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute.
CSE431 L05 Basic MIPS Architecture.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 05: Basic MIPS Architecture Review Mary Jane Irwin.
Non-Pipelined Processors Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology March 6, 2013
Asanovic/Devadas Spring Simple Instruction Pipelining Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Computer Architecture: A Constructive Approach One-Cycle Implementation Joel Emer Computer Science & Artificial Intelligence Lab. Massachusetts Institute.
Pipelined Datapath and Control
1 COMP541 Multicycle MIPS Montek Singh Apr 4, 2012.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
Computer Organization CS224 Chapter 4 Part b The Processor Spring 2010 With thanks to M.J. Irwin, T. Fountain, D. Patterson, and J. Hennessy for some lecture.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
Electrical and Computer Engineering University of Cyprus LAB3: IMPROVING MIPS PERFORMANCE WITH PIPELINING.
CS 152 Computer Architecture and Engineering Lecture 3 - From CISC to RISC Krste Asanovic Electrical Engineering and Computer Sciences University of California.
Electrical and Computer Engineering University of Cyprus LAB 2: MIPS.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
EECE 476: Computer Architecture Slide Set #5: Implementing Pipelining Tor Aamodt Slide background: Die photo of the MIPS R2000 (first commercial MIPS microprocessor)
Datapath and Control Unit Design
COMP541 Multicycle MIPS Montek Singh Mar 25, 2010.
ECE-C355 Computer Structures Winter 2008 The MIPS Datapath Slides have been adapted from Prof. Mary Jane Irwin ( )
CMPE 421 REVIEW: MIDTERM 1. A MODIFIED FIVE-Stage Pipeline PC A Y R MD1 addr inst Inst Memory Imm Ext add rd1 GPRs rs1 rs2 ws wd rd2 we wdata addr wdata.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Computer Architecture: A Constructive Approach Multi-Cycle and 2 Stage Pipelined SMIPS Implementations Teacher: Yoav Etsion Taken (with permission) from.
Spr 2016, Mar 9... ELEC / Lecture 7 1 ELEC / Computer Architecture and Design Spring 2016 Pipeline Control and Performance.
Computer Architecture and Parallel Computing 并行结构与计算 Lecture 2 - Pipelining Peng Liu Dept. of Info. Sci. & Elec. Engg. Zhejiang University
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Electrical and Computer Engineering University of Cyprus
Non-Pipelined Processors
Multi-Cycle CPU.
ECS 154B Computer Architecture II Spring 2009
CS 152 Computer Architecture and Engineering Lecture 4 - Pipelining
CS 152 Computer Architecture and Engineering Lecture 4 - Pipelining
MIPS processor continued
Review: MIPS Pipeline Data and Control Paths
Chapter 4 The Processor Part 2
Non-Pipelined Processors
Non-Pipelined Processors
Non-Pipelined Processors
Multi-cycle SMIPS Implementations
Systems Architecture II
Lecture 5. MIPS Processor Design
COMS 361 Computer Organization
Pipelined Processors Constructive Computer Architecture: Arvind
Computer Architecture Processor: Datapath
Modular Refinement Arvind
Introduction to Computer Organization and Architecture
Control Unit (single cycle implementation)
Non-Pipelined Processors
Branch Predictor Interface
The Processor: Datapath & Control.
COMS 361 Computer Organization
Processor: Datapath and Control
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

Multi-cycle Implementations Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology January 13, 2012L6-1

Harvard-Style Datapath for MIPS 0x4 RegWrite Add clk WBSrcMemWrite addr wdata rdata Data Memory we RegDst BSrc ExtSelOpCode z OpSel clk zero? clk addr inst Inst. Memory PC rd1 GPRs rs1 rs2 ws wd rd2 we Imm Ext ALU Control 31 PCSrc br rind jabs pc+4

At least the instruction fetch and a Load (or Store) cannot be executed in the same cycle What problem arises if instructions and data reside in the same memory? Structural hazard

Princeton Microarchitecture Datapath & Control Fetch phase on off = PC

Two-State Controller: Princeton Architecture fetch phase execute phase AddrSrc=ALU IRen=off PCen=on Wen=on AddrSrc=PC IRen=on PCen=off Wen=off A flipflop can be used to remember the phase

Hardwired Controller: Princeton Architecture old combinational logic (Harvard) op code zero? ExtSel, BSrc, OpSel, WBSrc, RegDest, PCsrc1, PCsrc2 MemWrite IR new combinational logic PCen IRen AddrSrc S 1-bit Toggle FF I-fetch / Execute RegWrite Wen

Two-Cycle SMIPS 7 PC Inst Memory Decode Register File Execute Data Memory +4 ir stage January 13, 2012 L6-7http://csg.csail.mit.edu/SNU

Two-Cycle SMIPS module mkProc(Proc); Reg#(Addr) pc <- mkRegU; RFile rf <- mkRFile; Memory mem <- mkMemory; PipeReg#(FBundle) ir <- mkPipeReg; Reg#(Bit#(1)) stage <- mkReg(0); let pcir = ir.first(); let pc = pcir.pc; let inst = pcir.inst; rule doProc; if(stage==0 && ir.notFull) begin //fetch let instResp <- mem(MemReq{op:Ld, addr:pc, data:?}); ir.enq(FBundle{pc:pc, inst:instResp}); stage <= 1; end January 13, 2012 L6-8http://csg.csail.mit.edu/SNU

if(stage==1 && ir.notEmpty) begin //decode let decInst = decode(inst); Data rVal1 = rf.rd1(decInst.rSrc1); Data rVal2 = rf.rd2(decInst.rSrc2); //execute let execInst = exec(decInst, pc, rVal1, rVal2); if(execInst.instType==Ld || execInst.instType==St) execInst.data <- mem(MemReq{op:execInst.instType, addr:execInst.addr, data:execInst.data}); pc <= execInst.brTaken ? execInst.addr : pc+4; //writeback  Two-Cycle SMIPS cont-1 January 13, 2012 L6-9http://csg.csail.mit.edu/SNU

//writeback if(execInst.instType==Alu || execInst.instType==Ld) rf.wr(execInst.rDst, execInst.data); ir.deq; stage <= 0; end endrule endmodule;  Two-Cycle SMIPS cont-2 January 13, 2012 L6-10http://csg.csail.mit.edu/SNU

Processor Performance MicroarchitectureCPIcycle time Microcoded>1short Single-cycle unpipelined1long Pipelined1short Time = Instructions Cycles Time Program Program * Instruction * Cycle –Instructions per program depends on source code, compiler technology and ISA –Cycles per instructions (CPI) depends upon the ISA and the microarchitecture –Time per cycle depends upon the microarchitecture and the base technology

Single-Cycle Hardwired Control: Harvard architecture We will assume clock period is sufficiently long for all of the following steps to be “completed”: 1. instruction fetch 2. decode and register fetch 3. ALU operation 4. data fetch if required 5. register write-back setup time  t C > t IFetch + t RFetch + t ALU + t DMem + t RWB At the rising edge of the following clock, the PC, the register file and the memory are updated

Clock Period t C-Princeton > max {t M, t RF + t ALU + t M + t WB } t C-Princeton > t RF + t ALU + t M + t WB while in the hardwired Harvard architecture t C-Harvard > t M + t RF + t ALU + t M + t WB which will execute instructions faster?

Clock Rate vs CPI Is it possible to design a controller for the Princeton architecture with CPI < 2 ? CPI = Clock cycles Per Instruction Suppose t M >> t RF + t ALU + t WB t C-Princeton = 0.5 * t C-Harvard CPI Princeton = 2 CPI Harvard = 1 No difference in performance!

Princeton microarchitecture (redrawn) The same (mux not shown) Only one of the phases is active in any cycle  a lot of datapath is not in use at any given time fetch phase execute phase addr wdata rdata Memory we ALU Imm Ext PC 0x4 Add IR addr wdata rdata Memory we rd1 GPRs rs1 rs2 ws wd rd2 we

Princeton Microarchitecture Overlapped execution Yes, unless IR contains a Load or Store What do we do with Fetch? fetch phase execute phase addr wdata rdata Memory we ALU Imm Ext PC 0x4 Add IR addr wdata rdata Memory we rd1 GPRs rs1 rs2 ws wd rd2 we How? Can we overlap instruction fetch and execute? ExecuteWhich action should be prioritized? Stall it

Stalling the instruction fetch Princeton Microarchitecture When stall condition is indicated don’t fetch a new instruction and don’t change the PC insert a nop in the IR set the Memory Address mux to ALU (not shown) fetch phase execute phase addr wdata rdata Memory we ALU Imm Ext rd1 GPRs rs1 rs2 ws wd rd2 we PC 0x4 Add addr wdata rdata Memory we stall? nop IR What if IR contains a jump or branch instruction?

Need to stall on branches Princeton Microarchitecture When IR contains a jump or branch-taken no “structural conflict” for the memory but we do not have the correct PC value in the PC memory cannot be used – Address Mux setting is irrelevant insert a nop in the IR insert the nextPC (branch-target) address in the PC addr wdata rdata Memory we ALU Imm Ext rd1 GPRs rs1 rs2 ws wd rd2 we PC 0x4 Add addr wdata rdata Memory we Jump? nop IR

Pipelined Princeton Microarchitecture IR 0x4 clk RegDst PCSrc RegWrite BSrczero? WBSrc 31 ExtSelOpCode Add rd1 GPRs rs1 rs2 ws wd rd2 we Imm Ext addr wdata rdata Data Memory z ALU Add OpSel ALU Control clk we MemWrite clk PC PCen MAddrSrc clk nop IRSrc PCSrc2 stall? stall

Pipelined Princeton Architecture Clock:t C-Princeton > t RF + t ALU + t M CPI:(1- f) + 2f cycles per instruction where f is the fraction of instructions that cause a stall What is a likely value of f?