1  2004 Morgan Kaufmann Publishers Chapter Five.

Slides:



Advertisements
Similar presentations
Multicycle Datapath & Control Andreas Klappenecker CPSC321 Computer Architecture.
Advertisements

1  1998 Morgan Kaufmann Publishers We will be reusing functional units –ALU used to compute address and to increment PC –Memory used for instruction and.
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
1 Chapter Five The Processor: Datapath and Control.
CS-447– Computer Architecture Lecture 12 Multiple Cycle Datapath
The Processor: Datapath & Control
1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control.
L14 – Control & Execution 1 Comp 411 – Fall /04/09 Control & Execution Finite State Machines for Control MIPS Execution.
Embedded Systems in Silicon TD5102 MIPS design Datapath and Control Henk Corporaal Technical University.
Fall 2007 MIPS Datapath (Single Cycle and Multi-Cycle)
1 Chapter Five. 2 We're ready to look at an implementation of the MIPS Simplified to contain only: –memory-reference instructions: lw, sw –arithmetic-logical.
1  1998 Morgan Kaufmann Publishers & Ing-Jer Huang Chapter Five last upate: 6/24/2015.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
10/18/2005Comp 120 Fall October Questions? Instruction Execution.
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.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Advanced Computer Architecture 5MD00 / 5Z033 MIPS Design data path and control Henk Corporaal TUEindhoven 2007.
Chapter Five The Processor: Datapath and Control.
L15 – Control & Execution 1 Comp 411 – Spring /25/08 Control & Execution Finite State Machines for Control MIPS Execution.
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  1998 Morgan Kaufmann Publishers We're ready to look at an implementation of the MIPS Simplified to contain only: –memory-reference instructions: lw,
CPU Architecture Why not single cycle? Why not single cycle? Hardware complexity Hardware complexity Why not pipelined? Why not pipelined? Time constraints.
Class 9.1 Computer Architecture - HUJI Computer Architecture Class 9 Microprogramming.
Processor I CPSC 321 Andreas Klappenecker. Midterm 1 Thursday, October 7, during the regular class time Covers all material up to that point History MIPS.
1 We're ready to look at an implementation of the MIPS Simplified to contain only: –memory-reference instructions: lw, sw –arithmetic-logical instructions:
The Multicycle Processor CPSC 321 Andreas Klappenecker.
The Processor Andreas Klappenecker CPSC321 Computer Architecture.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Computing Systems The Processor: 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.
Chapter 5 Processor Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides We're ready to look at an implementation of the MIPS Simplified.
1 Computer Organization & Design Microcode for Control Sec. 5.7 (CDROM) Appendix C (CDROM) / / pdf / lec_3a_notes.pdf.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
1 CS/COE0447 Computer Organization & Assembly Language Multi-Cycle Execution.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
1  1998 Morgan Kaufmann Publishers Simple Implementation Include the functional units we need for each instruction Why do we need this stuff?
COM181 Computer Hardware Lecture 6: The MIPs CPU.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3.
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.
1. 2 MIPS Hardware Implementation Full die photograph of the MIPS R2000 RISC Microprocessor. The 1986 MIPS R2000 with five pipeline stages and 450,000.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
CS161 – Design and Architecture of Computer Systems
CS161 – Design and Architecture of Computer Systems
Control & Execution Finite State Machines for Control MIPS Execution.
Chapter 5 The Processor: Datapath and Control
Computer Organization & Design Microcode for Control Sec. 5
Five Execution Steps Instruction Fetch
MIPS Instructions.
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
Chapter Five.
Control & Execution Finite State Machines for Control MIPS Execution.
Chapter Five The Processor: Datapath and Control
Chapter Five The Processor: Datapath and Control
Rocky K. C. Chang 6 November 2017
Multicycle Approach We will be reusing functional units
Systems Architecture I
Processor (II).
Processor: Multi-Cycle Datapath & Control
Simple Implementation
Multicycle Design.
Basic MIPS Implementation
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
The Processor: Datapath & Control.
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

1  2004 Morgan Kaufmann Publishers Chapter Five

2  2004 Morgan Kaufmann Publishers We're ready to look at an implementation of the MIPS Simplified to contain only: –memory-reference instructions: lw, sw –arithmetic-logical instructions: add, sub, and, or, slt –control flow instructions: beq, j Generic Implementation: –use the program counter (PC) to supply instruction address –get the instruction from memory –read registers –use the instruction to decide exactly what to do All instructions use the ALU after reading the registers Why? memory-reference? arithmetic? control flow? The Processor: Datapath & Control

3  2004 Morgan Kaufmann Publishers Abstract / Simplified View: Two types of functional units: –elements that operate on data values (combinational) –elements that contain state (sequential) More Implementation Details

4  2004 Morgan Kaufmann Publishers Unclocked vs. Clocked Clocks used in synchronous logic – when should an element that contains state be updated? State Elements cycle time

5  2004 Morgan Kaufmann Publishers The set-reset latch –output depends on present inputs and also on past inputs An unclocked state element

6  2004 Morgan Kaufmann Publishers Output is equal to the stored value inside the element (don't need to ask for permission to look at the value) Change of state (value) is based on the clock Latches: whenever the inputs change, and the clock is asserted Flip-flop: state changes only on a clock edge (edge-triggered methodology) "logically true", — could mean electrically low A clocking methodology defines when signals can be read and written — wouldn't want to read a signal at the same time it was being written Latches and Flip-flops

7  2004 Morgan Kaufmann Publishers Two inputs: –the data value to be stored (D) –the clock signal (C) indicating when to read & store D Two outputs: –the value of the internal state (Q) and it's complement D-latch

8  2004 Morgan Kaufmann Publishers D flip-flop Output changes only on the clock edge

9  2004 Morgan Kaufmann Publishers Our Implementation An edge triggered methodology Typical execution: –read contents of some state elements, –send values through some combinational logic –write results to one or more state elements

10  2004 Morgan Kaufmann Publishers Built using D flip-flops Register File Do you understand? What is the “Mux” above?

11  2004 Morgan Kaufmann Publishers Abstraction Make sure you understand the abstractions! Sometimes it is easy to think you do, when you don’t

12  2004 Morgan Kaufmann Publishers Register File Note: we still use the real clock to determine when to write

13  2004 Morgan Kaufmann Publishers Simple Implementation Include the functional units we need for each instruction Why do we need this stuff?

14  2004 Morgan Kaufmann Publishers Building the Datapath Use multiplexors to stitch them together

15  2004 Morgan Kaufmann Publishers Control Selecting the operations to perform (ALU, read/write, etc.) Controlling the flow of data (multiplexor inputs) Information comes from the 32 bits of the instruction Example: add $8, $17, $18 Instruction Format: op rs rt rd shamt funct ALU's operation based on instruction type and function code

16  2004 Morgan Kaufmann Publishers e.g., what should the ALU do with this instruction Example: lw $1, 100($2) op rs rt 16 bit offset ALU control input 0000 AND 0001OR 0010add 0110subtract 0111set-on-less-than 1100NOR Why is the code for subtract 0110 and not 0011? Control

17  2004 Morgan Kaufmann Publishers Must describe hardware to compute 4-bit ALU control input –given instruction type 00 = lw, sw 01 = beq, 10 = arithmetic –function code for arithmetic Describe it using a truth table (can turn into gates): ALUOp computed from instruction type Control

19  2004 Morgan Kaufmann Publishers Control Simple combinational logic (truth tables)

20  2004 Morgan Kaufmann Publishers All of the logic is combinational We wait for everything to settle down, and the right thing to be done –ALU might not produce “right answer” right away –we use write signals along with clock to determine when to write Cycle time determined by length of the longest path Our Simple Control Structure We are ignoring some details like setup and hold times

21  2004 Morgan Kaufmann Publishers Single Cycle Implementation Calculate cycle time assuming negligible delays except: –memory (200ps), ALU and adders (100ps), register file access (50ps)

22  2004 Morgan Kaufmann Publishers Where we are headed Single Cycle Problems: –what if we had a more complicated instruction like floating point? –wasteful of area One Solution: –use a “smaller” cycle time –have different instructions take different numbers of cycles –a “multicycle” datapath:

23  2004 Morgan Kaufmann Publishers We will be reusing functional units –ALU used to compute address and to increment PC –Memory used for instruction and data Our control signals will not be determined directly by instruction –e.g., what should the ALU do for a “subtract” instruction? We’ll use a finite state machine for control Multicycle Approach

24  2004 Morgan Kaufmann Publishers Break up the instructions into steps, each step takes a cycle –balance the amount of work to be done –restrict each cycle to use only one major functional unit At the end of a cycle –store values for use in later cycles (easiest thing to do) –introduce additional “internal” registers Multicycle Approach

25  2004 Morgan Kaufmann Publishers Instructions from ISA perspective Consider each instruction from perspective of ISA. Example: –The add instruction changes a register. –Register specified by bits 15:11 of instruction. –Instruction specified by the PC. –New value is the sum (“op”) of two registers. –Registers specified by bits 25:21 and 20:16 of the instruction Reg[Memory[PC][15:11]] <= Reg[Memory[PC][25:21]] op Reg[Memory[PC][20:16]] –In order to accomplish this we must break up the instruction. (kind of like introducing variables when programming)

26  2004 Morgan Kaufmann Publishers Breaking down an instruction ISA definition of arithmetic: Reg[Memory[PC][15:11]] <= Reg[Memory[PC][25:21]] op Reg[Memory[PC][20:16]] Could break down to: –IR <= Memory[PC] –A <= Reg[IR[25:21]] –B <= Reg[IR[20:16]] –ALUOut <= A op B –Reg[IR[20:16]] <= ALUOut We forgot an important part of the definition of arithmetic! –PC <= PC + 4

27  2004 Morgan Kaufmann Publishers Idea behind multicycle approach We define each instruction from the ISA perspective (do this!) Break it down into steps following our rule that data flows through at most one major functional unit (e.g., balance work across steps) Introduce new registers as needed (e.g, A, B, ALUOut, MDR, etc.) Finally try and pack as much work into each step (avoid unnecessary cycles) while also trying to share steps where possible (minimizes control, helps to simplify solution) Result: Our book’s multicycle Implementation!

28  2004 Morgan Kaufmann Publishers Instruction Fetch Instruction Decode and Register Fetch Execution, Memory Address Computation, or Branch Completion Memory Access or R-type instruction completion Write-back step INSTRUCTIONS TAKE FROM CYCLES! Five Execution Steps

29  2004 Morgan Kaufmann Publishers Use PC to get instruction and put it in the Instruction Register. Increment the PC by 4 and put the result back in the PC. Can be described succinctly using RTL "Register-Transfer Language" IR <= Memory[PC]; PC <= PC + 4; Can we figure out the values of the control signals? What is the advantage of updating the PC now? Step 1: Instruction Fetch

30  2004 Morgan Kaufmann Publishers Read registers rs and rt in case we need them Compute the branch address in case the instruction is a branch RTL: A <= Reg[IR[25:21]]; B <= Reg[IR[20:16]]; ALUOut <= PC + (sign-extend(IR[15:0]) << 2); We aren't setting any control lines based on the instruction type (we are busy "decoding" it in our control logic) Step 2: Instruction Decode and Register Fetch

31  2004 Morgan Kaufmann Publishers ALU is performing one of three functions, based on instruction type Memory Reference: ALUOut <= A + sign-extend(IR[15:0]); R-type: ALUOut <= A op B; Branch: if (A==B) PC <= ALUOut; Step 3 (instruction dependent)

32  2004 Morgan Kaufmann Publishers Loads and stores access memory MDR <= Memory[ALUOut]; or Memory[ALUOut] <= B; R-type instructions finish Reg[IR[15:11]] <= ALUOut; The write actually takes place at the end of the cycle on the edge Step 4 (R-type or memory-access)

33  2004 Morgan Kaufmann Publishers Reg[IR[20:16]] <= MDR; Which instruction needs this? Write-back step

34  2004 Morgan Kaufmann Publishers Summary:

35  2004 Morgan Kaufmann Publishers How many cycles will it take to execute this code? lw $t2, 0($t3) lw $t3, 4($t3) beq $t2, $t3, Label#assume not add $t5, $t2, $t3 sw $t5, 8($t3) Label:... What is going on during the 8th cycle of execution? In what cycle does the actual addition of $t2 and $t3 takes place? Simple Questions

37  2004 Morgan Kaufmann Publishers Finite state machines: –a set of states and –next state function (determined by current state and the input) –output function (determined by current state and possibly input) –We’ll use a Moore machine (output based only on current state) Review: finite state machines

38  2004 Morgan Kaufmann Publishers Review: finite state machines Example: B. 37 A friend would like you to build an “electronic eye” for use as a fake security device. The device consists of three lights lined up in a row, controlled by the outputs Left, Middle, and Right, which, if asserted, indicate that a light should be on. Only one light is on at a time, and the light “moves” from left to right and then from right to left, thus scaring away thieves who believe that the device is monitoring their activity. Draw the graphical representation for the finite state machine used to specify the electronic eye. Note that the rate of the eye’s movement will be controlled by the clock speed (which should not be too great) and that there are essentially no inputs.

39  2004 Morgan Kaufmann Publishers Value of control signals is dependent upon: –what instruction is being executed –which step is being performed Use the information we’ve accumulated to specify a finite state machine –specify the finite state machine graphically, or –use microprogramming Implementation can be derived from specification Implementing the Control

40  2004 Morgan Kaufmann Publishers Note: –don’t care if not mentioned –asserted if name only –otherwise exact value How many state bits will we need? Graphical Specification of FSM

41  2004 Morgan Kaufmann Publishers Implementation: Finite State Machine for Control