Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.

Slides:



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

Microprocessor Design Multi-cycle Datapath Nia S. Bradley Vijay.
1 Chapter Five The Processor: Datapath and 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.
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.
Week 11Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 11: Microprogramming [Adapted from Dave Patterson’s UCB CS152.
331 Lec18.1Fall :332:331 Computer Architecture and Assembly Language Fall 2003 Lecture 18 Introduction to Pipelined Datapath [Adapted from Dave.
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.
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.
Spring W :332:331 Computer Architecture and Assembly Language Spring 2005 Week 11 Introduction to Pipelined Datapath [Adapted from Dave Patterson’s.
The Multicycle Processor CPSC 321 Andreas Klappenecker.
CSE331 W11&12.1Irwin&Li Fall 2006 PSU CSE 331 Computer Organization and Design Fall 2006 Week 11&12 (Thanksgiving Week) Section 1: Mary Jane Irwin (
1. 2 Multicycle Datapath  As an added bonus, we can eliminate some of the extra hardware from the single-cycle datapath. —We will restrict ourselves.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
CMPE 421 Advanced Computer Architecture Supplementary material for Pipelining PART1.
CSE331 W10&11.1Irwin Fall 2007 PSU CSE 331 Computer Organization and Design Fall 2007 Week 10 & 11 Section 1: Mary Jane Irwin (
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.
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.
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.
EI209 Chapter 4B.1Haojin Zhu, SJTU 2015 EI 209 Computer Organization Fall 2015 Chapter 4B: The Processor, Control and Multi-cycle Datapath [Adapted from.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3 In-Class Exercises.
Design a MIPS Processor (II)
CSE 331 Computer Organization and Design Fall 2007 Week 10 & 11
Multi-Cycle Datapath and Control
Chapter 5: A Multi-Cycle CPU.
CS161 – Design and Architecture of Computer Systems
IT 251 Computer Organization and Architecture
ECE/CS 552: Multicycle Data Path
Systems Architecture I
Multi-Cycle CPU.
Extensions to the Multicycle CPU
Five Execution Steps Instruction Fetch
Single Cycle Processor
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
EI 209 Computer Organization Fall 2017
Chapter Five The Processor: Datapath and Control
Multicycle Approach Break up the instructions into steps
The Multicycle Implementation
Chapter Five The Processor: Datapath and Control
Drawbacks of single cycle implementation
CSE 331 Computer Organization and Design Fall 2007 Week 12
The Multicycle Implementation
Systems Architecture I
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
Multicycle Design.
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
Control Unit for Multiple Cycle Implementation
5.5 A Multicycle Implementation
Processor Design Datapath and Design.
Systems Architecture I
Control Unit for Multiple Cycle Implementation
FloorPlan for Multicycle MIPS
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data

u The control architecture can be treated as a Moore State Machine, with output depending only on the current state. States change at every clock cycle. u Instructions need different number of cycles (3-5) depending on the number of steps they have. u Some steps are common for all instructions. u Example - Instruction Fetch step u Also common is Instruction Decode and Register Fetch step u R-type Instruction Execution, Memory Read/Write Address Computation, Branch Completion, or Jump Completion are different u Memory Read Access, Memory Write Completion or R- type Instruction Completion u Memory Read Completion (Write Back) Five Instruction Steps

 Use PC to get instruction from the memory and put it in the Instruction Register MemoryRead =1, IRWrite =1,  Increment the PC by 4 and put the result back in the PC IorD =0 (to select PC), ALUSrcA =0, ALUSrcB =01, ALUOp =00 (add), PCWrite =1  Can be described succinctly using RTL "Register- Transfer Language“ IR = Memory[PC]; PC = PC + 4; Step 1: Instruction Fetch

Datapath Activity During Instruction Fetch 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 Sign Extend Shift left 2 ALU control Shift left 2 ALUOp Control IRWrite MemtoReg MemWrite MemRead IorD PCWrite PCWriteCond RegDst RegWrite ALUSrcA ALUSrcB zero PCSource Instr[5-0] Instr[25-0] PC[31-28] Instr[15-0] Instr[31-26] 32 28

Fetch Control Signals Settings Start Instr Fetch IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite State 0

u Don’t know what the instruction is yet, so can only –Read registers rs and rt in case we need them –Compute the branch address in case the instruction is a branch ALUSrcB =11, ALUOp =00 (add), ALUSrcA =0 (select PC)  RTL: A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC +(sign-extend(IR[15-0])<< 2); u We aren't setting any control lines based on the instruction (since we are busy "decoding" it in our control logic) Step 2: Instruction Decode and Register Fetch

Datapath Activity During Instruction Decode 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 Sign Extend Shift left 2 ALU control Shift left 2 ALUOp Control IRWrite MemtoReg MemWrite MemRead IorD PCWrite PCWriteCond RegDst RegWrite ALUSrcA ALUSrcB zero PCSource Instr[5-0] Instr[25-0] PC[31-28] Instr[15-0] Instr[31-26] 32 28

Decode Control Signals Settings Unless otherwise assigned PCWrite,IRWrite, MemWrite,RegWrite=0 others=X Start IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite Instr Fetch Decode ALUSrcA=0 ALUsrcB=11 ALUOp=00

u ALU is performing one of four functions, based on instruction type  Memory reference ( lw and sw ): ALUop =00, ALUSrcB =10, ALUSrcA =1 ALUOut = A + sign-extend(IR[15-0]); u R-type: ALUop =10 (use function field), ALUSrcA =1, ALUScrB =00 ALUOut = A op B; Step 3 (instruction dependent)

u Branch: ALUSrcB =00, ALUSrcA =1, ALUop =01 (force subtraction), PCSource =01 (use ALUout), PCwritecond =1 (in case zero=1) if (A==B) PC = ALUOut; u Jump: PCWrite =1, PCsource =10 PC = PC[31-28] || (IR[25-0] << 2); Step 3 (instruction dependent)

Datapath Activity During Instruction Execute 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 Sign Extend Shift left 2 ALU control Shift left 2 ALUOp Control IRWrite MemtoReg MemWrite MemRead IorD PCWrite PCWriteCond RegDst RegWrite ALUSrcA ALUSrcB zero PCSource Instr[5-0] Instr[25-0] PC[31-28] Instr[15-0] Instr[31-26] 32 28

Execute Control Signals Settings Execute Start Instr Fetch Decode Unless otherwise assigned PCWrite,IRWrite, MemWrite,RegWrite=0 others=X ALUSrcA=0 ALUSrcB=11 ALUOp=00 PCWriteCond=0 IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite (Op = lw or sw) ALUSrcA=1 ALUSrcB=10 ALUOp=00 PCWriteCond=0 (Op = R-type) ALUSrcA=1 ALUSrcB=00 ALUOp=10 PCWriteCond=0 (Op = beq) ALUSrcA=1 ALUSrcB=00 ALUOp=01 PCSource=01 PCWriteCond (Op = j) PCSource=10 PCWrite

u Memory reference: MemoryRead=1, IorD=1 MDR = Memory[ALUOut]; -- lw or MemoryWrite=1, IorD=1 Memory[ALUOut] = B; -- sw u R-type instruction completion RegDst=1, RegWrite=1, MemtoReg=0 Reg[IR[15-11]] = ALUOut; u Remember, the register write actually takes place at the end of the cycle on the clock edge Step 4 (instruction dependent)

Datapath Activity During Memory Access 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 Sign Extend Shift left 2 ALU control Shift left 2 ALUOp Control IRWrite MemtoReg MemWrite MemRead IorD PCWrite PCWriteCond RegDst RegWrite ALUSrcA ALUSrcB zero PCSource Instr[5-0] Instr[25-0] PC[31-28] Instr[15-0] Instr[31-26] 32 28

Memory Access Control Signals Settings Start Instr Fetch Decode Memory Access Execute (Op = R-type) (Op = beq) (Op = lw or sw) (Op = j) (Op = lw) (Op = sw) Unless otherwise assigned PCWrite,IRWrite, MemWrite,RegWrite=0 others=X IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite ALUSrcA=0 ALUSrcB=11 ALUOp=00 PCWriteCond=0 ALUSrcA=1 ALUSrcB=10 ALUOp=00 PCWriteCond=0 ALUSrcA=1 ALUSrcB=00 ALUOp=10 PCWriteCond=0 ALUSrcA=1 ALUSrcB=00 ALUOp=01 PCSource=01 PCWriteCond PCSource=10 PCWrite RegDst=1 RegWrite MemtoReg=0 PCWriteCond=0 MemWrite IorD=1 PCWriteCond=0 MemRead IorD=1 PCWriteCond=0

 All we have left is the write back into the register file the data just read from memory for lw instruction RegDst =0, RegWrite =1, MemtoReg =1 Reg[IR[20-16]]= MDR; Step 5: Memory Read Completion (Write Back)

Datapath Activity During Write Back 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 Sign Extend Shift left 2 ALU control Shift left 2 ALUOp Control IRWrite MemtoReg MemWrite MemRead IorD PCWrite PCWriteCond RegDst RegWrite ALUSrcA ALUSrcB zero PCSource Instr[5-0] Instr[25-0] PC[31-28] Instr[15-0] Instr[31-26] 32 28

Write Back Control Signals Settings Start Instr Fetch Decode RegDst=0 RegWrite MemtoReg=1 Write Back Memory Access Execute (Op = R-type) (Op = beq) (Op = lw or sw) (Op = j) (Op = lw) (Op = sw) Unless otherwise assigned PCWrite,IRWrite, MemWrite,RegWrite=0 others=X IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite ALUSrcA=0 ALUSrcB=11 ALUOp=00 PCWriteCond=0 ALUSrcA=1 ALUSrcB=10 ALUOp=00 PCWriteCond=0 ALUSrcA=1 ALUSrcB=00 ALUOp=10 PCWriteCond=0 ALUSrcA=1 ALUSrcB=00 ALUOp=01 PCSource=01 PCWriteCond PCSource=10 PCWrite RegDst=1 RegWrite MemtoReg=0 PCWriteCond=0 MemWrite IorD=1 PCWriteCond=0 MemRead IorD=1 PCWriteCond=0

StepR-typeMem RefBranchJump Instr fetch IR = Memory[PC]; PC = PC + 4; Decode A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC +(sign-extend(IR[15-0])<< 2); Execute ALUOut = A op B; ALUOut = A + sign- extend (IR[15- 0]); if (A==B) PC = ALUOut; PC = PC[31-28] ||(IR[25- 0] << 2); Memory access Reg[IR[ 15-11]] = ALUOut; MDR = Memory[ALUOut] ; or Memory[ALUOut] = B; Write-back Reg[IR[20-16]] = MDR; RTL Summary

 Add addi to the classes of instructions supported - what influence on number of states of the machine? Instruction fetch and Instruction decode states are unchanged. ALUout = A+ sign-exte.(IR[15-0]) Completion Reg(IR[20-16])=ALUout Exercise 5.15 Instr Fetch IorD=0 MemRead;IRWrite ALUSrcA=0 ALUsrcB=01 PCSource,ALUOp=00 PCWrite Op = addi RegDst=0 RegWrite=1 ALUOp=00 MemtoReg=0 State 12 State 0 Decode ALUSrcA=0 ALUSrcB=11 ALUOp=00 PCWriteCond=0 State 1

Exercise Cont.  The finite state machine with the addition of the state to handle addi RegDst=0 RegWrite=1 ALUOp=00 MemtoReg=0 State 12 OP : addi

u Multi-cycle datapath control signals are not determined solely by the bits in the instruction –e.g., op code bits tell what operation the ALU should be doing, but not what instruction cycle is to be done next u We’ll use a finite state machine for control –a set of states (current state stored in State Register) –next state function (determined by current state and the input) –output function (determined by current state and the input) Multi-cycle Control

Combinational control logic Finite State Machine Implementation Next State State Reg Inputs Outputs Inst[31-26] Op0Op1Op2Op3Op4Op5 PCWrite PCWriteCond IorD MemRead MemWrite IRWrite MemtoReg PCSource ALUOp ALUSourceB ALUSourceA RegWrite RegDst System Clock u We’ll use a Moore machine (control signals based only on current state)

Datapath Control Outputs Truth Table OutputsInput Values (Current State[3-0]) PCWrite PCWriteCondX X IorD0XX1X1XXXX MemRead1XX1XXXXXX MemWrite IRWrite MemtoRegXXXX1XX0XX PCSource00XX 0110 ALUOp00 XX 10XX01XX ALUSrcB011110XX 00XX00XX ALUSrcA001XXX1X1X RegWrite RegDstXXXX0XX1XX

Current State [3-0] Inst[31-26] (Op[5-0]) (R-type) (jmp) (beq) (lw) (sw) Any other illegal 0010XXXX illegal 0011XXXX 0100XXXXillegal 0100XXXX 0000XXXXillegal 0101XXXX 0000illegal XXXX illegal XXXX illegal 1000XXXX 0000XXXX illegal 1001XXXX0000XXXX illegal Next State Truth Table