Prof. Onur Mutlu Carnegie Mellon University Spring 2014, 1/24/2014

Slides:



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

The Processor: Datapath & Control
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Levels in Processor Design
Computer ArchitectureFall 2007 © October 3rd, 2007 Majd F. Sakr CS-447– Computer Architecture.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. Digital Architectures1 Machine instructions execution steps (1) FETCH = Read the instruction.
The Processor: Datapath & Control. Implementing Instructions Simplified instruction set memory-reference instructions: lw, sw arithmetic-logical instructions:
Chapter 4 Sections 4.1 – 4.4 Appendix D.1 and D.2 Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Gary MarsdenSlide 1University of Cape Town Chapter 5 - The Processor  Machine Performance factors –Instruction Count, Clock cycle time, Clock cycles per.
CS2100 Computer Organisation The Processor: Datapath (AY2015/6) Semester 1.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Computer Architecture Lecture 7: Microprogrammed Microarchitectures Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/30/2013.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Single-cycle CPU Control
EE204 Computer Architecture
11/4/2017 CIS-550 Advanced Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures Dr. Muhammad Abid DCIS, PIEAS Spring 2017.
Design of Digital Circuits Lecture 14: Microprogramming
Prof. Onur Mutlu Carnegie Mellon University Spring 2015, 1/26/2015
CS161 – Design and Architecture of Computer Systems
Design of Digital Circuits Lecture 13: Multi-Cycle Microarch.
CS 230: Computer Organization and Assembly Language
Single-Cycle Datapath and Control
Computer Architecture
Morgan Kaufmann Publishers
Performance of Single-cycle Design
Prof. Onur Mutlu Carnegie Mellon University Spring 2012, 1/25/2012
Computer Architecture Lecture 6: Multi-cycle Microarchitectures
Processor Architecture: Introduction to RISC Datapath (MIPS and Nios II) CSCE 230.
Morgan Kaufmann Publishers The Processor
Basic MIPS Architecture
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for Single-Cycle Instruction Execution
Samira Khan University of Virginia Feb 14, 2017
MIPS processor continued
Designing MIPS Processor (Single-Cycle) Presentation G
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for One-cycle Instruction Execution
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Levels in Processor Design
Topic 5: Processor Architecture Implementation Methodology
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
Systems Architecture I
COMS 361 Computer Organization
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Lecture 14: Single Cycle MIPS Processor
COMP541 Datapaths I Montek Singh Mar 18, 2010.
Computer Architecture Processor: Datapath
MIPS processor continued
CS/COE0447 Computer Organization & Assembly Language
Control Unit (single cycle implementation)
The Processor: Datapath & Control.
COMS 361 Computer Organization
Design of Digital Circuits Lecture 12: Microarchitecture II
Processor: Datapath and Control
CS161 – Design and Architecture of Computer Systems
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

Prof. Onur Mutlu Carnegie Mellon University Spring 2014, 1/24/2014 18-447 Computer Architecture Lecture 5: Single-Cycle Microarchitectures Prof. Onur Mutlu Carnegie Mellon University Spring 2014, 1/24/2014

Assignments Lab 1 due today Lab 2 out (start early) HW1 due next week HW0 issues Make sure your forms are correctly filled in and readable Extended deadline to resubmit: Sunday night (January 26)

A Single-Cycle Microarchitecture A Closer Look

Remember… ASNext AS Single-cycle machine Sequential Combinational Logic (State) Combinational Logic

Let’s Start with the State Elements Data and control inputs **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

For Now, We Will Assume “Magic” memory and register file Combinational read output of the read data port is a combinational function of the register file contents and the corresponding read select port Synchronous write the selected register is updated on the positive edge clock transition when write enable is asserted Cannot affect read output in between clock edges Single-cycle, synchronous memory Contrast this with memory that tells when the data is ready i.e., Ready bit: indicating the read or write is done

Instruction Processing 5 generic steps (P&H) Instruction fetch (IF) Instruction decode and register operand fetch (ID/RF) Execute/Evaluate memory address (EX/AG) Memory operand fetch (MEM) Store/writeback result (WB) WB IF ID/RF EX/AG MEM **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

What Is To Come: The Full MIPS Datapath PCSrc1=Jump PCSrc2=Br Taken bcond ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] JAL, JR, JALR omitted

Single-Cycle Datapath for Arithmetic and Logical Instructions

R-Type ALU Instructions Assembly (e.g., register-register signed addition) ADD rdreg rsreg rtreg Machine encoding Semantics if MEM[PC] == ADD rd rs rt GPR[rd]  GPR[rs] + GPR[rt] PC  PC + 4 R-type 6-bit rs 5-bit rt 5-bit rd 5-bit 5-bit ADD 6-bit

ALU Datapath Combinational state update logic IF ID EX MEM WB 25:21 20:16 15:11 1 IF ID EX MEM WB if MEM[PC] == ADD rd rs rt GPR[rd]  GPR[rs] + GPR[rt] PC  PC + 4 Combinational state update logic **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

I-Type ALU Instructions Assembly (e.g., register-immediate signed additions) ADDI rtreg rsreg immediate16 Machine encoding Semantics if MEM[PC] == ADDI rt rs immediate GPR[rt]  GPR[rs] + sign-extend (immediate) PC  PC + 4 I-type ADDI 6-bit rs 5-bit rt 5-bit immediate 16-bit

Datapath for R and I-Type ALU Insts. 25:21 20:16 ALUSrc isItype RegDest 15:11 1 IF ID EX MEM WB if MEM[PC] == ADDI rt rs immediate GPR[rt]  GPR[rs] + sign-extend (immediate) PC  PC + 4 Combinational state update logic **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Single-Cycle Datapath for Data Movement Instructions

Load Instructions I-type Assembly (e.g., load 4-byte word) LW rtreg offset16 (basereg) Machine encoding Semantics if MEM[PC]==LW rt offset16 (base) EA = sign-extend(offset) + GPR[base] GPR[rt]  MEM[ translate(EA) ] PC  PC + 4 I-type LW 6-bit base 5-bit rt 5-bit offset 16-bit

LW Datapath Combinational state update logic add RegDest isItype ALUSrc 1 isItype if MEM[PC]==LW rt offset16 (base) EA = sign-extend(offset) + GPR[base] GPR[rt]  MEM[ translate(EA) ] PC  PC + 4 IF ID EX MEM WB Combinational state update logic

Store Instructions I-type Assembly (e.g., store 4-byte word) SW rtreg offset16 (basereg) Machine encoding Semantics if MEM[PC]==SW rt offset16 (base) EA = sign-extend(offset) + GPR[base] MEM[ translate(EA) ]  GPR[rt] PC  PC + 4 I-type SW 6-bit base 5-bit rt 5-bit offset 16-bit

SW Datapath Combinational state update logic add ALUSrc isItype RegDest isItype if MEM[PC]==SW rt offset16 (base) EA = sign-extend(offset) + GPR[base] MEM[ translate(EA) ]  GPR[rt] PC  PC + 4 IF ID EX MEM WB Combinational state update logic

Load-Store Datapath add isStore isItype !isStore isItype isLoad RegDest isItype !isStore ALUSrc isItype isLoad **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Datapath for Non-Control-Flow Insts. isStore RegDest isItype !isStore ALUSrc isItype isLoad MemtoReg isLoad **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Single-Cycle Datapath for Control Flow Instructions

Unconditional Jump Instructions Assembly J immediate26 Machine encoding Semantics if MEM[PC]==J immediate26 target = { PC[31:28], immediate26, 2’b00 } PC  target J-type J 6-bit immediate 26-bit

Unconditional Jump Datapath concat PCSrc isJ X ? ALUSrc **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] if MEM[PC]==J immediate26 PC = { PC[31:28], immediate26, 2’b00 } What about JR, JAL, JALR?

Conditional Branch Instructions Assembly (e.g., branch if equal) BEQ rsreg rtreg immediate16 Machine encoding Semantics (assuming no branch delay slot) if MEM[PC]==BEQ rs rt immediate16 target = PC + 4 + sign-extend(immediate) x 4 if GPR[rs]==GPR[rt] then PC  target else PC  PC + 4 I-type BEQ 6-bit rs 5-bit rt 5-bit immediate 16-bit

Conditional Branch Datapath (For You to Fix) watch out PCSrc sub concat bcond **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] How to uphold the delayed branch semantics?

Putting It All Together PCSrc1=Jump PCSrc2=Br Taken bcond ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.] JAL, JR, JALR omitted

Single-Cycle Control Logic

Single-Cycle Hardwired Control As combinational function of Inst=MEM[PC] Consider All R-type and I-type ALU instructions LW and SW BEQ, BNE, BLEZ, BGTZ J, JR, JAL, JALR 31 26 21 16 11 6 R-type 6-bit rs 5-bit rt rd 5-bit shamt funct 6-bit 31 26 21 16 I-type opcode 6-bit rs 5-bit rt immediate 16-bit 31 26 J-type opcode 6-bit immediate 26-bit

Single-Bit Control Signals When De-asserted When asserted Equation RegDest GPR write select according to rt, i.e., inst[20:16] GPR write select according to rd, i.e., inst[15:11] opcode==0 ALUSrc 2nd ALU input from 2nd GPR read port 2nd ALU input from sign-extended 16-bit immediate (opcode!=0) && (opcode!=BEQ) && (opcode!=BNE) MemtoReg Steer ALU result to GPR write port steer memory load to GPR wr. port opcode==LW RegWrite GPR write disabled GPR write enabled (opcode!=SW) && (opcode!=Bxx) && (opcode!=J) && (opcode!=JR)) JAL and JALR require additional RegDest and MemtoReg options

Single-Bit Control Signals When De-asserted When asserted Equation MemRead Memory read disabled Memory read port return load value opcode==LW MemWrite Memory write disabled Memory write enabled opcode==SW PCSrc1 According to PCSrc2 next PC is based on 26-bit immediate jump target (opcode==J) || (opcode==JAL) PCSrc2 next PC = PC + 4 next PC is based on 16-bit immediate branch target (opcode==Bxx) && “bcond is satisfied” JR and JALR require additional PCSrc options

ALU Control case opcode Example ALU operations ‘0’  select operation according to funct ‘ALUi’  selection operation according to opcode ‘LW’  select addition ‘SW’  select addition ‘Bxx’  select bcond generation function __  don’t care Example ALU operations ADD, SUB, AND, OR, XOR, NOR, etc. bcond on equal, not equal, LE zero, GT zero, etc.

R-Type ALU 1 funct PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond funct PCSrc2=Br Taken bcond ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

I-Type ALU 1 opcode PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond bcond opcode ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

LW 1 1 Add PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond bcond 1 Add ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

SW * * 1 Add PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond 1 bcond * * Add ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Branch Not Taken * * bcond Some control signals are dependent on the processing of data PCSrc1=Jump PCSrc2=Br Taken bcond * * bcond ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Branch Taken * * bcond Some control signals are dependent on the processing of data PCSrc1=Jump PCSrc2=Br Taken bcond * * bcond ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Jump * * * * * PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond bcond * * * * ALU operation **Based on original figure from [P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

What is in That Control Box? Combinational Logic  Hardwired Control Idea: Control signals generated combinationally based on instruction Necessary in a single-cycle microarchitecture… Sequential Logic  Sequential/Microprogrammed Control Idea: A memory structure contains the control signals associated with an instruction Control Store

Evaluating the Single-Cycle Microarchitecture

A Single-Cycle Microarchitecture Is this a good idea/design? When is this a good design? When is this a bad design? How can we design a better microarchitecture?

A Single-Cycle Microarchitecture: Analysis Every instruction takes 1 cycle to execute CPI (Cycles per instruction) is strictly 1 How long each instruction takes is determined by how long the slowest instruction takes to execute Even though many instructions do not need that long to execute Clock cycle time of the microarchitecture is determined by how long it takes to complete the slowest instruction Critical path of the design is determined by the processing time of the slowest instruction

What is the Slowest Instruction to Process? Let’s go back to the basics All six phases of the instruction processing cycle take a single machine clock cycle to complete Fetch Decode Evaluate Address Fetch Operands Execute Store Result Do each of the above phases take the same time (latency) for all instructions? 1. Instruction fetch (IF) 2. Instruction decode and register operand fetch (ID/RF) 3. Execute/Evaluate memory address (EX/AG) 4. Memory operand fetch (MEM) 5. Store/writeback result (WB)

Single-Cycle Datapath Analysis Assume memory units (read or write): 200 ps ALU and adders: 100 ps register file (read or write): 50 ps other combinational logic: 0 ps steps IF ID EX MEM WB Delay resources mem RF ALU R-type 200 50 100 400 I-type LW 600 SW 550 Branch 350 Jump

Let’s Find the Critical Path PCSrc1=Jump PCSrc2=Br Taken bcond ALU operation [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

R-Type and I-Type ALU 100ps 200ps 250ps 400ps 350ps PCSrc1=Jump PCSrc2=Br Taken PCSrc1=Jump ALU operation bcond [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

LW 200ps 250ps 350ps 600ps 100ps 550ps PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

SW 100ps 200ps 250ps 350ps 550ps PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Branch Taken 100ps 350ps 200ps 250ps PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

Jump 100ps 200ps PCSrc1=Jump PCSrc2=Br Taken ALU operation bcond [Based on original figure from P&H CO&D, COPYRIGHT 2004 Elsevier. ALL RIGHTS RESERVED.]

What About Control Logic? How does that affect the critical path? Food for thought for you: Can control logic be on the critical path? A note on CDC 5600: control store access too long…

What is the Slowest Instruction to Process? Memory is not magic What if memory sometimes takes 100ms to access? Does it make sense to have a simple register to register add or jump to take {100ms+all else to do a memory operation}? And, what if you need to access memory more than once to process an instruction? Which instructions need this? Do you provide multiple ports to memory?

Single Cycle uArch: Complexity Contrived All instructions run as slow as the slowest instruction Inefficient Must provide worst-case combinational resources in parallel as required by any instruction Need to replicate a resource if it is needed more than once by an instruction during different parts of the instruction processing cycle Not necessarily the simplest way to implement an ISA Single-cycle implementation of REP MOVS, INDEX, POLY? Not easy to optimize/improve performance Optimizing the common case does not work (e.g. common instructions) Need to optimize the worst case all the time

Microarchitecture Design Principles Critical path design Find the maximum combinational logic delay and decrease it Bread and butter (common case) design Spend time and resources on where it matters i.e., improve what the machine is really designed to do Common case vs. uncommon case Balanced design Balance instruction/data flow through hardware components Balance the hardware needed to accomplish the work How does a single-cycle microarchitecture fare in light of these principles?

Multi-Cycle Microarchitectures

Multi-Cycle Microarchitectures Goal: Let each instruction take (close to) only as much time it really needs Idea Determine clock cycle time independently of instruction processing time Each instruction takes as many clock cycles as it needs to take Multiple state transitions per instruction The states followed by each instruction is different

Remember: The “Process instruction” Step ISA specifies abstractly what A’ should be, given an instruction and A It defines an abstract finite state machine where State = programmer-visible state Next-state logic = instruction execution specification From ISA point of view, there are no “intermediate states” between A and A’ during instruction execution One state transition per instruction Microarchitecture implements how A is transformed to A’ There are many choices in implementation We can have programmer-invisible state to optimize the speed of instruction execution: multiple state transitions per instruction Choice 1: AS  AS’ (transform A to A’ in a single clock cycle) Choice 2: AS  AS+MS1  AS+MS2  AS+MS3  AS’ (take multiple clock cycles to transform AS to AS’)

Multi-Cycle Microarchitecture AS = Architectural (programmer visible) state at the beginning of an instruction Step 1: Process part of instruction in one clock cycle Step 2: Process part of instruction in the next clock cycle … AS’ = Architectural (programmer visible) state at the end of a clock cycle

Benefits of Multi-Cycle Design Critical path design Can keep reducing the critical path independently of the worst-case processing time of any instruction Bread and butter (common case) design Can optimize the number of states it takes to execute “important” instructions that make up much of the execution time Balanced design No need to provide more capability or resources than really needed An instruction that needs resource X multiple times does not require multiple X’s to be implemented Leads to more efficient hardware: Can reuse hardware components needed multiple times for an instruction

Remember: Performance Analysis Execution time of an instruction {CPI} x {clock cycle time} Execution time of a program Sum over all instructions [{CPI} x {clock cycle time}] {# of instructions} x {Average CPI} x {clock cycle time} Single cycle microarchitecture performance CPI = 1 Clock cycle time = long Multi-cycle microarchitecture performance CPI = different for each instruction Average CPI  hopefully small Clock cycle time = short Now, we have two degrees of freedom to optimize independently