Chapter 5: A Multi-Cycle CPU.

Slides:



Advertisements
Similar presentations
Pipeline Example: cycle 1 lw R10,9(R1) sub R11,R2, R3 and R12,R4, R5 or R13,R6, R7.
Advertisements

1 Datapath and Control (Multicycle datapath) CDA 3101 Discussion Section 11.
Microprocessor Design Multi-cycle Datapath Nia S. Bradley Vijay.
The Processor: Datapath & Control
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.
CMPUT Computer Organization and Architecture II1 CMPUT329 - Fall 2003 TopicI: Building a Multicycle Data Path and a Control Path for a Microprocessor.
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 ( )
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.
CMPE 421 Advanced Computer Architecture Supplementary material for Pipelining PART1.
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.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
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.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 2.
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.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 10: Control 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:
Design a MIPS Processor (II)
Single-cycle CPU Control
EE204 Computer Architecture
Multi-Cycle Datapath and Control
Computer Architecture
IT 251 Computer Organization and Architecture
/ Computer Architecture and Design
ECE/CS 552: Multicycle Data Path
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
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
Multicycle Approach Break up the instructions into steps
The Multicycle Implementation
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Vishwani D. Agrawal James J. Danaher Professor
The Multicycle Implementation
Systems Architecture I
The Processor Lecture 3.2: Building a Datapath with Control
Vishwani D. Agrawal James J. Danaher Professor
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
Finite State Machine for Control
Control Unit for Multiple Cycle Implementation
5.5 A Multicycle Implementation
Systems Architecture I
Control Unit for Multiple Cycle Implementation
FloorPlan for Multicycle MIPS
Alternative datapath (book): Multiple Cycle Datapath
The Processor: Datapath & Control.
Processor: Datapath and Control
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

Chapter 5: A Multi-Cycle CPU

The Multi-cycle idea... We can use any logic block once each cycle PC Read address Read reg. 1 Read data 1 Memory Read reg. 2 Read data Registers Result Write address Write reg Read data 2 Write data Write data Memory: Holds Instructions Holds Data ALU: Computes R-type value Computes Address Computes next PC Computes Branch Registers: Hold data values

Multi-cycle Datapath Update PC=PC+4 Load Instruction:Need address Read Instruction from memory Decode,Read registers (R-type) Start: PC Do ALU Op PC 1 PC 1 Memory Read address Write address Write data Read data [25-21] Result Zero Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] 1 [15-11] 1 2 3 4 1 Write Result reg. sign extend Sh. Left 2 16 32 Branch [15-0] Read from Memory Write result Store Instr.

Breaking instructions into cycles Mem ALU Note: Some of these are unneeded, but they don’t hurt! Instruction Fetch, Increment PC Decode Instruction, Access Registers Jump Reg Update PC Compute Branch Target ALU LW,SW ALU Branch R-type Compute Memory Address ALU If condition holds update PC to Target Execute Instruction ALU Mem Read/Write Memory Write Register Reg Can use each major block (ALU,reg,mem) once each cycle Reg Write Register LW

Multi-cycle Control Note: The control signals will be constant during each cycle, but may change during the multi-cycle instruction Control ALUOp IorD Inst[31-26] ALUSelB MemRead MemWrite MemToReg RegDest RegWrite ALUSelA PC PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] 1 [15-11] 1 2 3 4 1 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Issues 1. Memory reads overwrite the instruction - Add Instr. Reg. 2. ALU overwrites PC every cycle - Add PCWrite Signal PCWrite Add PCWriteCond Signal Control 3. Branches? PCWriteCond Zero ALUOp IorD Inst[31-26] ALUSelB MemRead MemWrite IRWrite MemToReg RegWrite ALUSelA RegDest PC PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] Instr. Reg Instr. [31-0] 1 [15-11] 1 2 3 4 1 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Issues On branches, the PC is always written with Zero! Sh. Left 2 26 28 Concat. PCSource 32 PCWrite Control 4 PCWriteCond 2 1 Zero ALUOp Inst[31-26] IorD Inst[25-0] [31-28] MemRead Logic for Jumps MemWrite ALUSelA IRWrite MemToReg RegDest RegWrite PC or PC+4 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB [15-11] B 1 2 3 4 MDR 1 ALU Out: Save result of ALU for use on next cycle MDR: Save result of read for use on next cycle A, B: Save registers for use on next cycle sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Instruction Fetch 1 x 1 1 x x 1 Cycle 1 All instructions Sh. Left 2 26 28 Concat. PCSource 32 1 PCWrite x Control 4 PCWriteCond 2 1 Zero ALUOp IorD Inst[31-26] Inst[25-0] [31-28] MemRead 1 1 x x MemWrite IRWrite MemToReg RegDest RegWrite ALUSelA PC or PC+4 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB 1 [15-11] B 1 2 3 4 IorD=0 MemRead=1 MemWrite=0 IRWrite=1 ALUSelA=0 ALUSelB=1 MDR 1 ALUOp=00 PCWrite=1 PCSource=0 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Instr. Decode/Reg. Fetch Cycle 2 All instructions Sh. Left 2 26 28 Concat. PCSource 32 x PCWrite Control 4 PCWriteCond 2 1 Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x MemWrite IRWrite MemToReg RegDest RegWrite ALUSelA PC or PC+4 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB 3 [15-11] B 1 2 3 4 MDR 1 MemRead=0 MemWrite=0 IRWrite=0 ALUSelA=0 ALUSelB=3 ALUOp=00 PCWrite=0 PCWriteCond=0 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

R-type Execution x 2 x x x 1 Cycle 3 R-Type Sh. Left 2 26 28 Concat. PCSource 32 PCWrite Control 4 PCWriteCond 2 1 2 Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x MemWrite IRWrite MemToReg RegDest RegWrite ALUSelA PC or PC+4 1 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB [15-11] B 1 2 3 4 MemRead=0 MemWrite=0 IRWrite=0 ALUSelA=1 ALUSelB=0 MDR 1 ALUOp=10 PCWrite=0 PCWriteCond=0 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

R-type Completion x x x x 1 1 x x Cycle 4 R-Type MemRead=0 MemWrite=0 Sh. Left 2 26 28 Concat. PCSource x 32 PCWrite Control 4 PCWriteCond 2 1 x Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x 1 1 MemWrite IRWrite MemToReg RegDest RegWrite ALUSelA PC or PC+4 x PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB x [15-11] B 1 2 3 4 MemRead=0 MemWrite=0 RegDest=1 MDR 1 PCWrite=0 PCWriteCond=0 RegWrite=1 MemToReg=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Branch if Equal 1 1 1 x x x x 1 Cycle 3 BEQ Sh. Left 2 PCSource 1 26 28 Concat. 32 PCWrite 1 Control 4 PCWriteCond 2 1 1 Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x x MemWrite ALUSelA IRWrite MemToReg RegDest RegWrite PC or PC+4 1 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB [15-11] B 1 2 3 4 MemRead=0 MemWrite=0 ALUSelA=1 ALUSelB=0 PCSource=1 MDR 1 ALUOp=01 PCWrite=0 PCWriteCond=1 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Jump 2 1 x x x x x x x x Cycle 3 Jump MemRead=0 MemWrite=0 Sh. Left 2 26 28 Concat. PCSource 32 2 1 PCWrite Control 4 PCWriteCond 2 1 x x Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x x MemWrite IRWrite MemToReg RegDest RegWrite ALUSelA PC or PC+4 x PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB x [15-11] B 1 2 3 4 MDR 1 MemRead=0 MemWrite=0 PCWrite=1 RegWrite=0 PCSource=2 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Memory Addr. Completion Cycle 3 LW,SW Sh. Left 2 x 26 28 Concat. PCSource 32 PCWrite Control 4 PCWriteCond 2 1 Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x MemWrite IRWrite MemToReg RegWrite ALUSelA RegDest PC or PC+4 1 PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB 2 [15-11] B 1 2 3 4 MemRead=0 MemWrite=0 IRWrite=0 ALUSelA=1 ALUSelB=2 MDR 1 ALUOp=00 PCWrite=0 PCWriteCond=0 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Memory Read x x 1 1 x x x x Cycle 4 LW MemRead=1 MemWrite=0 IRWrite=0 Sh. Left 2 26 28 Concat. PCSource 32 x PCWrite Control 4 PCWriteCond 2 1 x Zero ALUOp 1 IorD Inst[31-26] Inst[25-0] [31-28] MemRead 1 x x MemWrite IRWrite MemToReg RegWrite ALUSelA RegDest PC or PC+4 x PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB x [15-11] B 1 2 3 4 MDR 1 MemRead=1 MemWrite=0 IRWrite=0 PCWrite=0 PCWriteCond=0 RegWrite=0 IorD=1 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

ReadWriteBack x x x x 1 1 x x Cycle 5 LW Sh. Left 2 26 28 Concat. PCSource x 32 PCWrite Control 4 PCWriteCond 2 1 x Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x 1 1 MemWrite IRWrite MemToReg RegWrite ALUSelA RegDest PC or PC+4 x PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB x [15-11] B 1 2 3 4 MemRead=0 MemWrite=0 RegDest=0 MemtoReg=1 MDR 1 PCWrite=0 PCWriteCond=0 RegWrite=1 MemToReg=1 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Memory Write x x x x x x 1 x x Cycle 4 SW MemRead=0 MemWrite=1 Sh. Left 2 26 28 Concat. PCSource x 32 PCWrite Control 4 PCWriteCond 2 1 x Zero ALUOp x IorD Inst[31-26] Inst[25-0] [31-28] MemRead x x x 1 MemWrite IRWrite MemToReg RegWrite ALUSelA RegDest PC or PC+4 x PC 1 1 [25-21] Result Zero Memory Address Write data Read data Registers Read reg num B Write reg num Write reg data Read reg data A Read reg data B Read reg num A [20-16] A Instr. Reg Instr. [31-0] ALU Out 1 ALUSelB x [15-11] B 1 2 3 4 MemRead=0 MemWrite=1 MDR 1 PCWrite=0 PCWriteCond=0 RegWrite=0 sign extend Sh. Left 2 16 32 ALU control [15-0] [5-0]

Control Finite State Machine ALUSelA=0 ALUSelB=11 ALUOp=0 IorD=0 MemRead=1 IRWrite=1 ALUSelA=0 ALUSelB=1 ALUOp=00 PCWrite=1 PCSource=00 Instr. Fetch t1 Instr. Decode/ Register Fetch t0 LW or SW Jump t2 ALUSelA=1 ALUSelB=2 ALUOp=0 BEQ Jump Branch Execution Mem. Addr. Completion R-type t8 t9 ALUSelA=1 ALUSelB=0 PCSource=1 ALUOp=1 PCWriteCond=1 ALUSelA=1 ALUSelB=0 ALUOp=2 PCWrite=1 PCSource=10 t6 t3 MemRead=1 IorD=1 LW Memory Access SW t7 t4 t5 RegDest=1 RegWrite=1 MemToReg=0 MemWrite=1 IorD=1 RegDest=0 RegWrite=1 MemToReg=1 Memory Access R-type Completion Write-back

Implementing the Control Implementing a Finite State Machine is straightforward 10 states --> 4 flipflops Choose binary representations for each state Create state transition table Map to flipflop type Using K-maps, build a function for each control output 50-70 Gates Or..., Put the FSM into a computer program and trust it

Evaluation Multi-cycle goals: Reuse common parts Merge the memories Only one ALU in the design, but more complexity Merge the memories Success! Get rid of worst-case cycle time constraint R-type: 4 cycles, Branch: 3 cycles, Jump: 3 cycles, LW: 5 cycles, SW: 4 cycles Will cycle time be 1/5 that of single cycle? No, more like 1/3 or 1/4 of the cycle time We still will win in most cases