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.

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.
331 W9.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 9 Building a Single-Cycle Datapath [Adapted from Dave Patterson’s.
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:
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.
1 The Processor: Datapath and Control We will design a microprocessor that includes a subset of the MIPS instruction set: –Memory access: load/store word.
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.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Processor: Datapath and Control
Gary MarsdenSlide 1University of Cape Town Chapter 5 - The Processor  Machine Performance factors –Instruction Count, Clock cycle time, Clock cycles per.
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]
Datapath and Control Unit Design
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.
MIPS processor continued. In Class Exercise Question Show the datapath of a processor that supports only R-type and jr reg instructions.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
December 26, 2015©2003 Craig Zilles (derived from slides by Howard Huang) 1 A single-cycle MIPS processor  As previously discussed, an instruction set.
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.
February 22, 2016©2003 Craig Zilles (derived from slides by Howard Huang) 1 A single-cycle MIPS processor  As previously discussed, an instruction set.
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
MIPS processor continued
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.
Single Cycle Controller Design
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:
Single-cycle CPU Control
Access the Instruction from Memory
CS Computer Architecture Week 10: Single Cycle Implementation
CS161 – Design and Architecture of Computer Systems
Single-Cycle Datapath and Control
Computer Architecture
Processor Design & Implementation
Basic MIPS Architecture
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
MIPS processor continued
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Levels in Processor Design
The Processor Lecture 3.2: Building a Datapath with Control
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Lecture 14: Single Cycle MIPS Processor
MIPS processor continued
CS/COE0447 Computer Organization & Assembly Language
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:

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

Outline Introduction Clocking Single-cycle Datapath Single-cycle Control Performance Analysis 2

Introduction 3 So far, we have built a small ALU ADD, SUB, SLT, AND, OR, … What about Memory and registers? Control operations? Interpreting (decoding) instructions? The big picture The CPU’s datapath deals with moving data around The CPU’s control manages the data Generic implementation Fetch PC = PC+4 Decode Execute

The clocking methodology defines when signals can be read and when they are written An edge-triggered methodology Typical execution read contents of state elements send values through combinational logic write results to one or more state elements Assumes 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 Clocking 4 State Element State Element Combinational logic clock one clock cycle

Single-Cycle Datapath 5 The first implementation considered All instructions start and finish execution in one cycle! This include the time required to fetch, decode, and execute the instruction In the following, we will consider the datapath of each of these steps

Single-Cycle Datapath 6 Fetch Datapath Fetching the instruction from memory requires Sending the PC to memory to read the instruction Update the PC to point to the next instruction Do we need an explicit write signal for writing the PC? Do we need an explicit read signal for reading the memory? PC Read Address Data Instruction Memory + 4 Instruction

Single-Cycle Datapath 7 Decode Datapath Regardless of the instruction Send the opcode (31-26) and the function (5-0) fields of the instruction to the control unit Read two registers; rs (25-21) and rt (20-16) Reading is not harmful! Instruction Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 Control Unit R[rs] R[rt]

Single-Cycle Datapath 8 Inside the Register File How can we read a register out of 32 registers? Register 0 Register 1 Register 2 …. Register to-1 MUX Read Register 1 Read Register 2 Read Data 1 Read Data

Single-Cycle Datapath 9 Inside the Register File How can we write a register out of 32 registers? Register Number 5-to-32 Decoder Write Data Register 0 D C Register 1 D C Register 2 D C ….. D C Register 31 D C Write Clock

Single-Cycle Datapath 10 Execution Datapath R-type instructions (ADD, SUB, SLT, AND, OR) The two registers are read already! Perform operation based on OPCODE and FUNC fields Store the result back into the register file (the destination register is specified in rd field of the instruction (15-11) ! The register file is not written on every cycle! Need an explicit write signal Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 R[rs] R[rt] Instruction Write ALU RegWrite ALU Control

Single-Cycle Datapath 11 Execution Datapath Load Instruction Compute the load address Store the loaded data in the register file. The destination register is the rt field of the instruction (20-16) Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 R[rs] R[rt] Instruction Write ALU RegWrite ALU Control Address Data Data Memory Sign Ext. Write Data MemRead MemWrite

Single-Cycle Datapath 12 Execution Datapath Store Instruction Compute the load address Store register in the memory Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 R[rs] R[rt] Instruction Write ALU RegWrite ALU Control Address Data Data Memory Sign Ext. Write Data MemRead MemWrite

Single-Cycle Datapath 13 Execution Datapath Branch Instruction Compare the two registers Compute the branch address Change PC if true ! Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 Instruction Write RegWrite Sign Ext. ALU ALU Control PC + 4 x4 + Zero Branch Address 1 0 Zero

Single-Cycle Datapath 14 Execution Datapath Jump Instruction Compute the jump address Store it in the PC PC Read Address Data Instruction Memory + 4 Instruction x4 jump address 1 0 Jump

Single-Cycle Datapath 15 Creating the Single Datapath Assemble the datapath segments and add control lines and multiplexors as needed Single cycle design Fetch, decode and execute each instructions in one clock cycle No datapath resource can be used more than once per instruction, so some must be duplicated (e.g., separate Instruction Memory and Data Memory, several adders) Multiplexors needed at the input of shared elements with control lines to do the selection Write signals to control writing to the Register File and Data Memory Cycle time is determined by length of the longest path

Single-Cycle Datapath 16 Read Address Instr[31-0] Instruction Memory + 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 + 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 0 1 Shift left 2 Instr[25-0] PC[31-28] Jump

Single-Cycle Control 17 Need to design the control that generates the appropriate control signals based on the Opcode and Function fields to Specify the operation of the ALU Control the data flow by selecting the appropriate input of the multiplexors With the following observations across different instructions Op field is always in bits of the instruction Address of registers to be read are always specified by The rs field (bits 25-21) The rt field (bits 20-16) For LW and SW, the rs field is the base register Address of register to be written is in one of two places For LW, the address is the rt field (bits ) For R-type, the address is the rd field (bits 15-11) Offset for BEQ, LW, and SW is always in bits 15-0 of the instruction

Single-Cycle Control 18 Signal NameEffect when Deassereted (0)Effect when Asserted (1) RegDst The destination register is from rt field The destination register is from rd field RegWriteNone Enable writing to the register selected by the Write register port ALUSrc The second ALU operand comes from the second register file output The second ALU operand is the sign extended offset PCSrcPC value is PC+4PC is the branch address MemReadNone Contents of memory address are put on Read data output MemWriteNone Data on the Write data input is placed in the specified address MemtoReg The data fed to the register file Write data input comes from ALU The data fed to the register file Write data input comes from memory ALUOp Used with the function field of the instruction to generate the ALUOp signal that specify the ALU operation

R-type Instruction Data/Control Flow 19 Read Address Instr[31-0] Instruction Memory + 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 + 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 0 1 Shift left 2 Instr[26-0] PC[31-28] Jump

Load Word Instruction Data/Control Flow 20 Read Address Instr[31-0] Instruction Memory + 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 + 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 0 1 Shift left 2 Instr[26-0] PC[31-28] Jump

Branch Equal Instruction Data/Control Flow 21 Read Address Instr[31-0] Instruction Memory + 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 + 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 0 1 Shift left 2 Instr[26-0] PC[31-28] Jump

Jump Instruction Data/Control Flow 22 Read Address Instr[31-0] Instruction Memory + 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 + 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 0 1 Shift left 2 Instr[26-0] PC[31-28] Jump

Single-Cycle Control 23 The Main Control Unit The input is the Op field (6 bits) from the instruction The output is nine control signals The truth table ! InputsOutputs Op5Op4Op3Op2Op1Op0 RegDist ALUsrc MemtoReg RegWrite MemRead MemWrite Branch ALUop1ALUop0 R-type LW SW101011X1X BEQ000100X0X000101

Single-Cycle Control 24 The Main Control Unit To design the logic circuit, generate the appropriate minterms for each output signal Simply, use a PLA!

Single-Cycle Control 25 The ALU Control Unit It has two inputs ALUop (2 bits) from Main control Func (6 bits) from the instruction It has two outputs Bengate (1 bits) Operation (2 bits) Supported Operations FunctionBnegateOperation and000 or001 add010 sub110 slt111 ALU control ALUop Func Bnegate Operation

Single-Cycle Control 26 The ALU Control Unit Truth Table ! InputsOutputs ALUop1ALUop0 F5F4F3F2F1F0 Bnegate Operation 1 Operation 0 AND OR ADD SUB SLT LW00n/a010 SW00n/a010 BEQ01n/a110

Single-Cycle Control 27 The ALU Control Unit Hardware Implementation Generating minterms!! Minimization!! By inspection!

Performance Analysis 28 All instructions have to finish in one cycle! How long is the cycle time? Different units are used in different instructions Each unit has its own delay Need to find the longest path! Assume the following times Thus, the cycle time should be at least 8 ns R-type: Instr. FetchRegister ReadALU Register Write 6ns 8ns 7ns 5ns 2ns Branch: Instr. FetchRegister ReadALU LW: Instr. FetchRegister ReadALU Memory ReadRegister Write SW: Instr. FetchRegister ReadALU Memory Write Jump: Instr. Fetch UnitDelay ALU2 ns Memory2 ns Register File1 ns

Performance Analysis 29 The cycle time is fixed! However, not all instructions require the same time! There is a wasted time for some instructions?! Possible Solution? Clock LWSW Cycle 1 Cycle 2 waste

Performance Analysis 30 Example 1. Example 1. consider the following two implementations of a single cycle machine: Machine A : all instructions execute in one cycle of fixed length Machine B: all instructions execute in one cycle, however, the cycle time adapts to instruction types Use the information given in the tables to compare the two machines UnitTime (ps) Memory200 ALU and adders100 Register File50 Instruction typePercentage % ALU45 Load25 Store10 Branch15 Jump5

Performance Analysis 31 Example 1. Continued. CPU Execution Time = IC x CPI x Clock cycle time CPI A = CPI B = 1 IC A = IC B CC A = 600 ns CC B = 600 x x x x x 0.05 = ps Performanc B / Performance A = 600 / = 1.34 So, adaptive clock cycle is faster; however it is hard to implement ! Instruction Type Inst. Memory Register Read ALU Data Memory Register Write Total R-type Load Store Branch Jump200

Single Cycle Disadvantages & Advantages 32 Single-cycle implementation assumes that all instructions can execute in one cycles Advantages Simple and easy to understand Disadvantages Hardware duplication! Uses the clock cycle inefficiently – the clock cycle must be timed to accommodate the slowest instruction ( especially problematic for more complex instructions like floating point multiply)