331 W9.1Spring 2006 14:332:331 Computer Architecture and Assembly Language Spring 2006 Week 9 Building a Single-Cycle Datapath [Adapted from Dave Patterson’s.

Slides:



Advertisements
Similar presentations
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
Advertisements

The Processor: Datapath & Control
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.
Levels in Processor Design
331 Lec 14.1Fall 2002 Review: Abstract Implementation View  Split memory (Harvard) model - single cycle operation  Simplified to contain only the instructions:
Preparation for Midterm Binary Data Storage (integer, char, float pt) and Operations, Logic, Flip Flops, Switch Debouncing, Timing, Synchronous / Asynchronous.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Computer Structure - Datapath and Control Goal: Design a Datapath  We will design the datapath of a processor that includes a subset of the MIPS instruction.
331 W10.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 10 Building a Multi-Cycle Datapath [Adapted from Dave Patterson’s.
CSE431 L05 Basic MIPS Architecture.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 05: Basic MIPS Architecture Review Mary Jane Irwin.
The Processor: Datapath & Control. Implementing Instructions Simplified instruction set memory-reference instructions: lw, sw arithmetic-logical instructions:
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
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.
CSE331 W09.1Irwin Fall 2007 PSU CSE 331 Computer Organization and Design Fall 2007 Week 9 Section 1: Mary Jane Irwin (
CSE331 W10&11.1Irwin Fall 2007 PSU CSE 331 Computer Organization and Design Fall 2007 Week 10 & 11 Section 1: Mary Jane Irwin (
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Processor: Datapath and Control
Computer Architecture Chapter 5 Fall 2005 Department of Computer Science Kent State University.
CSE431 Chapter 4A.1Irwin, PSU, 2008 CSE 431 Computer Architecture Fall 2008 Chapter 4A: The Processor, Part A Mary Jane Irwin ( )
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
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
D ATA P ATH OF A PROCESSOR (MIPS) Module 1.1 : Elements of computer system UNIT 1.
CSE331 W10.1Irwin&Li Fall 2006 PSU CSE 331 Computer Organization and Design Fall 2006 Week 10 Section 1: Mary Jane Irwin (
ECE-C355 Computer Structures Winter 2008 The MIPS Datapath Slides have been adapted from Prof. Mary Jane Irwin ( )
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
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.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 2.
CS.305 Computer Architecture The Processor: Datapath and Control Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
Design a MIPS Processor
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.
1 Chapter 5: Datapath and Control (Part 2) CS 447 Jason Bakos.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Design a MIPS Processor (II)
CSE 331 Computer Organization and Design Fall 2007 Week 10 & 11
CS Computer Architecture Week 10: Single Cycle Implementation
CS 230: Computer Organization and Assembly Language
Single-Cycle Datapath and Control
Computer Architecture
Single Cycle Processor
ECS 154B Computer Architecture II Spring 2009
Basic MIPS Architecture
CS/COE0447 Computer Organization & Assembly Language
Designing MIPS Processor (Single-Cycle) Presentation G
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
CSCI206 - Computer Organization & Programming
Datapath & Control MIPS
Topic 5: Processor Architecture Implementation Methodology
Composing the Elements
Composing the Elements
The Processor Lecture 3.3: Single-cycle Implementation
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Lecture 14: Single Cycle MIPS Processor
Control Unit (single cycle implementation)
The Processor: Datapath & Control.
COMS 361 Computer Organization
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

331 W9.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 9 Building a Single-Cycle Datapath [Adapted from Dave Patterson’s UCB CS152 slides and Mary Jane Irwin’s PSU CSE331 slides]

331 W9.2Spring 2006 Head’s Up  This week’s material l Building a MIPS single-cycle datapath -Reading assignment – PH 5.4

331 W9.3Spring 2006 Review: Abstract Implementation View  Split memory (Harvard) model - single cycle operation  Simplified to contain only the instructions: memory-reference instructions: lw, sw arithmetic-logical instructions: add, sub, and, or, slt control flow instructions: beq, j  Sequential components (PC, RegFile, Memory) are edge triggered l state elements are written on every clock cycle; if not, need explicit write control signal -write occurs only when both the write control is asserted and the clock edge occurs AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data

331 W9.4Spring 2006 Example  Let’s modify the ISA and remove the ability to specify an offset for memory access instructions. Specifically, the load-store instructions would contain only two registers. In other words, all MIPS load-store instructions with offsets would become pseudoinstructions and would be implemented using two instructions: lw$t0, 104($t1) =>

331 W9.5Spring 2006 Example cont’d Instruction Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU overflow zero ALU controlRegWrite Data Memory Address Write Data Read Data Sign Extend MemWrite MemRead bit offset

331 W9.6Spring 2006 Creating a Single Datapath from the Parts  Assemble the datapath segments from the last lecture, add control lines as needed, and design the control path  Fetch, decode and execute each instructions in one clock cycle – single cycle design l no datapath resource can be used more than once per instruction, so some must be duplicated (e.g., why we have a separate Instruction Memory and Data Memory) l to share datapath elements between two different instruction classes will need multiplexors at the input of the shared elements with control lines to do the selection  Cycle time is determined by length of the longest path

331 W9.7Spring 2006 Fetch, R, and Memory Access Portions Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero ALU controlRegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 lw R R lw / sw

331 W9.8Spring 2006 Multiplexor Insertion MemtoReg Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero ALU controlRegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 ALUSrc

331 W9.9Spring 2006 Adding the Branch Portion Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero ALU controlRegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Read Address Instruction Memory Add PC 4 Shift left 2 Add PCSrc R lw / sw R lw Branch not taken, R, lw /sw

331 W9.10Spring 2006 Adding the Control  Selecting the operations to perform (ALU, Register File and Memory read/write)  Controlling the flow of data (multiplexor inputs)  Information comes from the 32 bits of the instruction I-Type: oprsrt address offset R-type: oprsrtrdfunctshamt 10  Observations l op field always in bits l addr of two registers to be read are always specified by the rs and rt fields (bits and 20-16) l addr. of register to be written is in one of two places – in rt (bits 20-16) for lw; in rd (bits 15-11) for R-type instructions l base register for lw and sw always in rs (bits 25-21) l offset for beq, lw, and sw always in bits 15-0

331 W9.11Spring 2006 (Almost) Complete Single Cycle Datapath Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr ALU ovf zero Data Memory Address Write Data Read Data MemWrite MemRead Register File Read Data 1 Read Data 2 RegWrite Sign Extend 1632 Shift left 2 Add RegDst 0 1 ALUSrc 0 1 MemtoReg 1 0 PCSrc 1 0 ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11]

331 W9.12Spring 2006 ALU Control ALU control input ( Ainvert + Binvert + Operation ) Function 0000and 0001or 0010add 0110subtract 0111set on less than  ALU's operation based on instruction type and function code

331 W9.13Spring 2006 ALU Control, Con’t  Controlling the ALU makes use of multiple levels of decoding l main control unit generates the ALUOp bits l ALU control unit generates ALU control inputs Instr opfunctALUOpdesired action ALU control input lwxxxxxx00add0010 swxxxxxx00add0010 beqxxxxxx01sub0110 add add0010 subt subtract0110 and and0000 or or0001 slt slt0111

331 W9.14Spring 2006 ALU Control Truth Table  Can make use of more don’t cares l since ALUOp does not use the encoding 11 l since F5 and F4 are always 10  Logic comes from the K-maps … F5F4F3F2F1F0ALUOp1ALUOp0Op3Op2Op1Op0 XXXXXX XXXXXX10110 XX XX XX XX XX X X X X X X

331 W9.15Spring 2006 (Almost) Complete Datapath with Control Unit Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch

331 W9.16Spring 2006 Instr[15 -11] Instr[20-16] Instr[25-21] R-type Instruction Data/Control Flow Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Control Unit Instr[31-26] Branch

331 W9.17Spring 2006 Instr[25-21] Instr[20-16] Store Word Instruction Data/Control Flow Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[15 -11] Control Unit Instr[31-26] Branch

331 W9.18Spring 2006 Load Word Instruction Data/Control Flow Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch

331 W9.19Spring 2006 Branch Instruction Data/Control Flow Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch

331 W9.20Spring 2006 Main Control Unit InstrRegDstALUSrcMemRegRegWrMemRdMemWrBranchALUOp1ALUOp0 R-type X001X lw sw X1X0X1000 beq X0X0X01X1

331 W9.21Spring 2006 Control Unit Logic  From the truth table can design the Main Control logic Instr[31] Instr[30] Instr[29] Instr[28] Instr[27] Instr[26] R-type lwswbeq RegDst ALUSrc MemtoReg RegWrite MemRead MemWrite Branch ALUOp1 ALUOp0

331 W9.22Spring 2006 Adding the Jump Operation Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch Shift left Jump 32 Instr[25-0] 26 PC+4[31-28] 28

331 W9.23Spring 2006 Single Cycle Implementation Cycle Time  Unfortunately, though simple, the single cycle approach is not used because it is inefficient  Clock cycle must have the same length for every instruction  What is the longest path (slowest instruction)?

331 W9.24Spring 2006 Instruction Critical Paths Instr.I MemReg RdALU OpD MemReg WrTotal R-type load store beq jump  Calculate cycle time assuming negligible delays (for muxes, control unit, sign extend, PC access, shift left 2, wires) except: l Instruction and Data Memory (2ns) l ALU and adders (2ns) l Register File access (reads or writes) (1ns)

331 W9.25Spring 2006 Where We are Headed  Problems with single cycle datapath design l uses clock cycle inefficiently l and what if we had a more complicated instruction like floating point multiply? l wasteful of area  Another approach l use a “smaller” cycle time l have different instructions take different numbers of cycles l a “multicycle” datapath: Address Read Data (Instr. or Data) Memory PC Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU Write Data IR MDR A B ALUout

331 W9.26Spring 2006 Complete Datapath Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch Shift left Jump 32 Instr[25-0] 26 PC+4[31-28] 28

331 W9.27Spring 2006 Example I: R instruction Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite

331 W9.28Spring 2006 Example I: lw instruction Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite

331 W9.29Spring 2006 Example I: sw instruction Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite

331 W9.30Spring 2006 Example I: beq instruction Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite

331 W9.31Spring 2006 Example II: cycle length  Calculate cycle time assuming negligible delays (for muxes, control unit, sign extend, PC access, shift left 2, wires) except: l Instruction and Data Memory (2ns) l ALU (2ns) l Register File access (reads or writes) (1ns) l Adder for PC+4 (5ns) l Adder for branch address computation (5ns)

331 W9.32Spring 2006 Example III:  Describe the effect that a single stuck-at-0 fault (I.e., regardless of what it should be, the signal is always 0) would have on the multiplexors in the single-cycle datapath. Which instruction, if any, would still work? Consider each of the following faults separately: RegDst = 0, ALUSrc = 0, MemtoReg = 0, Zero = 0;

331 W9.33Spring 2006 Example IV:  We wish to add the instruction addi to the single- cycle datapath. Add any necessary datapaths and control signals. Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite

331 W9.34Spring 2006 Complete Datapath Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch Shift left Jump 32 Instr[25-0] 26 PC+4[31-28] 28

331 W9.35Spring 2006 Example V: add jal Read Address Instr[31-0] Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 ALU ovf zero RegWrite Data Memory Address Write Data Read Data MemWrite MemRead Sign Extend 1632 MemtoReg ALUSrc Shift left 2 Add PCSrc RegDst ALU control ALUOp Instr[5-0] Instr[15-0] Instr[25-21] Instr[20-16] Instr[15 -11] Control Unit Instr[31-26] Branch Shift left Jump 32 Instr[25-0] 26 PC+4[31-28] RegDst1 1 0 MemtoReg1

331 W9.36Spring 2006 Example V: add jal (cont’d) Control Signal SettingControl Signal Setting RegDstALUOp1 JumpAlUOp0 BranchMemWrite MemReadALUSrc MemtoRegRegWrite MemtoReg1RegDst1