COSC 2021: Computer Organization Instructor: Dr. Amir Asif

Slides:



Advertisements
Similar presentations
Adding the Jump Instruction
Advertisements

1 Datapath and Control (Multicycle datapath) CDA 3101 Discussion Section 11.
Microprocessor Design Multi-cycle Datapath Nia S. Bradley Vijay.
1 Chapter Five The Processor: Datapath and Control.
The Processor: Datapath & Control
The Processor Data Path & Control Chapter 5 Part 2 - Multi-Clock Cycle Design N. Guydosh 2/29/04.
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
EECE476 Lecture 9: Multi-cycle CPU Datapath Chapter 5: Section 5.5 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
CSE378 Multicycle impl,.1 Drawbacks of single cycle implementation All instructions take the same time although –some instructions are longer than others;
1 5.5 A Multicycle Implementation A single memory unit is used for both instructions and data. There is a single ALU, rather than an ALU and two adders.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
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.
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
Computer Architecture Chapter 5 Fall 2005 Department of Computer Science Kent State University.
Datapath and Control: MultiCycle Implementation. Performance of Single Cycle Machines °Assume following operation times: Memory units : 200 ps ALU and.
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.
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
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.
Multicycle Implementation
LECTURE 6 Multi-Cycle Datapath and Control. SINGLE-CYCLE IMPLEMENTATION As we’ve seen, single-cycle implementation, although easy to implement, could.
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.
Fall 2015, Sep ELEC / Lecture 5 1 ELEC / Computer Architecture and Design Fall 2015 Datapath and Control (Chapter.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
RegDst 1: RegFile destination No. for the WR Reg. comes from rd field. 0: RegFile destination No. for the WR Reg. comes from rt field.
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)
Multi-Cycle Datapath and Control
Chapter 5: A Multi-Cycle CPU.
IT 251 Computer Organization and Architecture
/ Computer Architecture and Design
Systems Architecture I
Multi-Cycle CPU.
Extensions to the Multicycle CPU
Single Cycle Processor
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
Basic MIPS Architecture
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
CSCE 212 Chapter 5 The Processor: Datapath and Control
Chapter Five The Processor: Datapath and Control
Multicycle Approach Break up the instructions into steps
The Multicycle Implementation
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
Chapter Five The Processor: Datapath and Control
Drawbacks of single cycle implementation
The Multicycle Implementation
Systems Architecture I
The Processor Lecture 3.2: Building a Datapath with Control
Vishwani D. Agrawal James J. Danaher Professor
Multicycle Approach We will be reusing functional units
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
CS/COE0447 Computer Organization & Assembly Language
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
5.5 A Multicycle Implementation
Processor Design Datapath and Design.
Systems Architecture I
FloorPlan for Multicycle MIPS
The Processor: Datapath & Control.
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 11 Multicycle Implementation of a MIPS Processor Topics: A multiple cycle implementation Distributed Notes

Functional units used (Steps involved) Why Multicycle? Example: Assume that the operation times for major functional unit in a microprocessor are: Memory unit ~ 2ns, ALU and adders ~ 2ns, Register file ~ 1ns Compare the performance of the following instruction mix Loads: 24%; Stores: 12%; ALU instructions: 44%; Branches: 18%; Jumps: 2% on the two implementations Implementation I: Each instruction operates in 1 clock cycle Implementation II: Each instruction is as long as it needs to be. Instruction Class Functional units used (Steps involved) ALU type Instruction fetch Register Access ALU 6ns Load word Memory Access 8ns Store word 7ns Branch 5ns 2ns Average time per instruction: Implementation 1: ~ 8ns Implementation 2: ~0.24(8)+0.12(7)+0.44(6)+0.18(5)+0.02(2) = 6.34ns

Multicycle Implementation Instruction: Execution of each instruction is broken into different steps Each step requires 1 clock cycle Each instruction takes multiple clock cycles Functional Unit: Can be used more than once in an instruction (but still only once in a clock cycle) Advantages: Functional units can be shared ALU and adder is combined Single memory is used for instructions and data

Multicycle Implementation: Abstract Diagram # L U B O One ALU is used for incrementing PC and for arithmetic operations Data memory and Instruction memory are combined 5 additional registers are added An instruction register (IR) to hold instructions before distributing data to register file or ALU A memory data register (MDR) to hold data before distributing to register file or ALU Regsiters A and B that hold data before the ALU Register ALUout that hold data computed by ALU

Multicycle Implementation: Multiplexers added h i f t l e 2 P C M m o r y D a W d u x 1 R g s 4 I n c [ 5 – ] 3 6 A L U Z B O Because functional units are shared, multiplexers are added to select data between different devices MUX before memory selects either the PC output (fetch instruction) or ALU output (storing data) MUX before “write register” selects write-register number (instruction [15-11] or instruction[20-16]) MUX before “write data” selects data from “ALUOut” (R-type instruction) or “MemData” (lw instruction) Upper MUX before ALU selects PC output (increment PC) or “Read data 1” (R-type instruction) Lower MUX before ALU selects “Read data 2”, or “sign extended instruction[15-0]” or shift left sign extended instruction[15-0], or 4

Multicycle Implementation: Controls added h i f t l e 2 M m o R g I r D a d W P C y u x 1 s n c [ 5 – ] 4 A L U O p B 3 6 Z Because functional units are shared, multiplexers are added to select data between different devices MUX before memory selects either the PC output (fetch instruction) or ALU output (storing data) MUX before “write register” selects write-register number (instruction [15-11] or instruction[20-16])

Multicycle Implementation: Control Units added h i f t l e 2 P C M u x 1 R g s r W d a I n c o [ 5 – ] 4 3 6 A L U Z m y B D O p - J 8

Action of 1-bit Control Signals Control Input Effect when Deasserted (0) Effect when asserted (1) IorD PC supplies address to memory (instruction fetch) ALUout supplies address to memory (lw/sw) MemRead None Memory content specified by address is placed on “Memdata” o/p (lw/any instruction) MemWrite I/p “Write data” is stored at specified address (sw) IRWrite “MemData” o/p is written on IR (instruction fetch) RegDst “Write Register” specified by Instruction[20-16] (lw) “WriteRegister” specified by Instruction[15-11] (R-type) RegWrite Data from “WriteData” i/p is written on the register specified by “WriteRegister” number ALUSrcA PC is the first operand in ALU (increment PC) Register A is the first operand in ALU MemtoReg “WriteData” of the register file comes from ALUOut “WriteData” of the register file comes from MDR PCWrite Operation at PC depends on PCWriteCond and zero output of ALU PC is written; Source is determined by PCSource PCWriteCond Operation at PC depends on PCWrite PC is written if zero o/p of ALU = 1; Source is determined by PCSource

Action of 2-bit Control Signals Control Input Value Effect ALUOp 00 ALU performs an add operation 01 ALU performs a subtract operation 10 The function field of Instruction defines the operation of ALU ALUSrcB The second operand of ALU comes from Register B The second operand of ALU = 4 The second operand of ALU is sign extended Instruction[15-0] 11 The second operand of ALU is sign extended, 2-bit left shifted Instruction[15-0] PCSource Output of ALU (PC + 4) is sent to PC Contents of ALUOut (branch target address = PC + 4 + 4 x offset) is sent to PC Contents of Instruction[25-0], shift left by 2, and concatenated with the MSB 4-bits of PC is sent to PC (jump instruction)

Breaking the Instruction Execution into Clock Cycles Execution of each instruction is broken into a series of steps Each step is balanced to do almost equal amount of work Each step takes one clock cycle Each step contains at the most 1 ALU operation, or 1 register file access, or 1 memory access Operations listed in 1 step occurs in parallel in 1 clock cycle Different steps occur in different clock cycles Different steps are: Instruction fetch step Instruction decode and register fetch step Execution, memory address computation, or branch completion step Memory access of R-type instruction completion step Memory read completion step

Multicycle Implementation: Control Units added h i f t l e 2 P C M u x 1 R g s r W d a I n c o [ 5 – ] 4 3 6 A L U Z m y B D O p - J 8

Step 1: Instruction Fetch Fetch instruction from memory and compute the address of next sequential instruction IR = Memory[PC]; PC = PC + 4; Operation: Send PC to the memory as address (IorD = 0) Read memory cell defined by PC (MemRead = 1) Copy output of memory (MeMdata) into IR (IRwrite = 1) Increment PC by 4 (ALUSrcA = 0, ALUSrcB = 01, PCSrc = 00) Store (PC + 4) into PC (PCWrite = 1)

Step 2: Instruction Decode and Register Fetch Read register rs in register file and store content of rs in register A Read rt in register file and store content of rt from register file Compute branch target address A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(IR[15-0]) << 2); Operation: Access register file to write rs in A. Access register file to write rt in B. Compute branch target address and store in ALUOut (ALUSrcA = 0; ALUSrcB = 11) Remember that ALU must add (ALUOp = 00) After this step, one of the four actions are possible: Memory reference (lw/sw), R-type, Branch, or Jump

Step 3: Execution, Memory address Computation, or Branch Completion Memory Reference (sw/lw): ALUOut = A + sign-extend(IR[15-0]) ALU adds content of A and sign-extend(IR[15-0]) (ALUSrcA = 1, ALUSrcB = 10), (ALUOp = 00) R-type (add/sub/or/and): ALUOut = A op B ALU performs specified operation on A and B (ALUSrcA = 1, ALUSrcB = 00), Operation of ALU is determined by the function field code (ALUOp = 10) Branch (beq): if (A == B) PC = ALUOut; ALU does the equal comparison operation on A and B (ALUSrcA = 1, ALUSrcB = 00), ALU must subtract (ALUOp = 01) Update PC with ALUOut if A == B (PCWriteCond = 1, PCSource = 01) . Complete. Jump (j): PC = PC[31-28] || (IR[25-0) << 2); PC gets overwritten by output of jump address MUX (PCSource = 10, PCWrite = 1). Complete.

Step 4: Memory Access or R-type Instruction Completion Memory Reference (sw/lw): MDR = Memory[ALUOut]; (for lw) or Memory[ALUOut] = B; (for sw) Address from ALUOut is applied at “address” i/p of memory (IorD = 1) For sw, MemWrite = 1. For lw, MemRead = 1. sw is complete. R-type Instruction (add/sub/or/and): Reg[IR[15-11]] = ALUOut; ALUOut is stored into the register specified by IR[15-11] (MemtoReg = 0, RegWrite = 1). Complete.

Step 5: Memory Read Completion load (lw): Reg[IR[20-16]] = MDR; MDR is stored into the register specified by IR[20-16] (MemtoReg = 1, RegWrite = 1, RegDst = 0)

Summary of Steps used in different Instructions Step Name Action for R-type Instruction Memory Reference Instruction Branch Jump Instruction fetch IR = Memory[PC]; PC = PC + 4; Instruction decode / Register fetch A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(IR[15-0])<<2); R-type Execution / address computation / Branch / Jump ALUOut = A op B ALUOut = A + sign-extend(IR[15-0]) if(A == B) then PC = ALUOut; PC = PC[31-28]|| (IR[25-0)<<2); Memory Access / R-type Completion Reg[IR[15-11]] = ALUOut; lw: MDR = Memory[ALUOut] or sw: Memory[ALUOut] = B Memory Read Completion lw: Reg[IR[20-16]]=MDR;

Multipath Datapath Implementation: Control Recall that design of single cycle datapath was based on a combinational circuit Design of multicycle datapath is more complicated Instructions are executed in a series of steps Each step must occur in a sequence Control of multicycle must specify both the control signals and the next step The control of a multicycle datapath is based on a sequential circuit referred to as a finite state machine 00 10 01 11 State 0 State 1 State 2 State 3 A finite state diagram for a 2-bit counter Each state specifies a set of output By default, unspecified outputs are assumed disabled The number of the arrows identify inputs

Finite State Machine Control of Multicycle Datapath (1) g 5 . 3 8 ) R - p 9 B h 4 J 41 I f / d 7 S High-Level View

Finite State Machine Control of Multicycle Datapath (2) = B 1 O p M e m R a d I o D W i t P C u n s f h / g ( ' ) - y E Q J F 5 . 3 8 9 4 Fig. 5.37: Steps 1 and 2: Instruction Fetch and Decode Instructions

Finite State Machine Control of Multicycle Datapath (3) W r i t I o D = 1 R a d A L U S c B O p g s y u n ( ' ) - b k 4 2 5 3 F T . Fig. 5.38: Finite State Machine for Memory Reference Instructions

Finite State Machine Control of Multicycle Datapath (4) = 1 B O p R e g D s t W i M m o E x u n - y l 6 7 ( ) F a T 5 . 3 2 Fig. 5.39: Finite State Machines for R-type Instructions

Finite State Machine Control of Multicycle Datapath (5) Fig. 5.40: Finite State Machine for Branch Instruction B r a n c h o m p l e t i 8 ( O = ' E Q ) F s 1 T g u 5 . 3 2 A L U S P C W d J u m p c o l e t i n 9 ( O = ' ) F r s a 1 T g 5 . 3 2 P C W S Fig. 5.41: Finite State Machine for Jump Instruction

P C W r i t e S o u c = 1 A L U B O p n d R g D s M m I a f h / J l E x y - b k ( ' ) Q 4 9 8 6 2 7 5 3

Multicycle Implementation: Control Units added h i f t l e 2 P C M u x 1 R g s r W d a I n c o [ 5 – ] 4 3 6 A L U Z m y B D O p - J 8

Finite State Machine Control of Multicycle Datapath (5) W r i t e o n d I D M m R g S u c A L U O p B s N 3 2 1 5 4 a f l