Computer Science 141 Computing Hardware

Similar documents
Processor (multi-cycle)

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

CPE 335. Basic MIPS Architecture Part II

Multiple Cycle Data Path

Processor: Multi- Cycle Datapath & Control

Systems Architecture I

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

Lecture 8: Control COS / ELE 375. Computer Architecture and Organization. Princeton University Fall Prof. David August

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

Multi-cycle Approach. Single cycle CPU. Multi-cycle CPU. Requires state elements to hold intermediate values. one clock cycle or instruction

Introduction. ENG3380 Computer Organization and Architecture MIPS: Data Path Design Part 3. Topics. References. School of Engineering 1

CENG 3420 Lecture 06: Datapath

Introduction to Pipelined Datapath

RISC Design: Multi-Cycle Implementation

ECE369. Chapter 5 ECE369

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

Review: Abstract Implementation View

CPE 335 Computer Organization. Basic MIPS Architecture Part I

The Processor: Datapath & Control

CSE 2021 COMPUTER ORGANIZATION

Multicycle Approach. Designing MIPS Processor

LECTURE 6. Multi-Cycle Datapath and Control

Topic #6. Processor Design

ENE 334 Microprocessors

CSE 2021 COMPUTER ORGANIZATION

CC 311- Computer Architecture. The Processor - Control

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

Lets Build a Processor

RISC Processor Design

ECS 154B Computer Architecture II Spring 2009

EECE 417 Computer Systems Architecture

Design of the MIPS Processor

Multicycle conclusion

Design of the MIPS Processor (contd)

Systems Architecture

Chapter 4 The Processor (Part 2)

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Chapter 5: The Processor: Datapath and Control

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

ECE 313 Computer Organization EXAM 2 November 9, 2001

RISC Architecture: Multi-Cycle Implementation

Processor (I) - datapath & control. Hwansoo Han

Chapter 5 Solutions: For More Practice

ECE 313 Computer Organization FINAL EXAM December 11, Multicycle Processor Design 30 Points

Lecture Topics. Announcements. Today: Single-Cycle Processors (P&H ) Next: continued. Milestone #3 (due 2/9) Milestone #4 (due 2/23)

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

RISC Architecture: Multi-Cycle Implementation

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Alternative to single cycle. Drawbacks of single cycle implementation. Multiple cycle implementation. Instruction fetch

Points available Your marks Total 100

ECE232: Hardware Organization and Design

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

LECTURE 5. Single-Cycle Datapath and Control

CSE 141 Computer Architecture Spring Lectures 11 Exceptions and Introduction to Pipelining. Announcements

COMP303 Computer Architecture Lecture 9. Single Cycle Control

ENGN1640: Design of Computing Systems Topic 04: Single-Cycle Processor Design

Mapping Control to Hardware

Lecture 5: The Processor

Chapter 4 The Processor 1. Chapter 4A. The Processor

Major CPU Design Steps

Computer Architecture Chapter 5. Fall 2005 Department of Computer Science Kent State University

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007

Single vs. Multi-cycle Implementation

EECS150 - Digital Design Lecture 10- CPU Microarchitecture. Processor Microarchitecture Introduction

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

Chapter 4. The Processor. Computer Architecture and IC Design Lab

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

CS Computer Architecture Spring Week 10: Chapter

Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan)

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

EECS150 - Digital Design Lecture 9- CPU Microarchitecture. Watson: Jeopardy-playing Computer

Single-Cycle Examples, Multi-Cycle Introduction

Processor Implementation in VHDL. University of Ulster at Jordanstown University of Applied Sciences, Augsburg

Fundamentals of Computer Systems

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS359: Computer Architecture. The Processor (A) Yanyan Shen Department of Computer Science and Engineering

Implementing the Control. Simple Questions

Lecture 6 Datapath and Controller

MIPS-Lite Single-Cycle Control

CS3350B Computer Architecture Quiz 3 March 15, 2018

Pipelined Processor Design

CSE Computer Architecture I Fall 2009 Lecture 13 In Class Notes and Problems October 6, 2009

Lecture 7 Pipelining. Peng Liu.

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W9-W

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W10-M

EECS 151/251A Fall 2017 Digital Design and Integrated Circuits. Instructor: John Wawrzynek and Nicholas Weaver. Lecture 13 EE141

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

EEM 486: Computer Architecture. Lecture 3. Designing Single Cycle Control

Using a Hardware Description Language to Design and Simulate a Processor 5.8

COMP303 - Computer Architecture Lecture 8. Designing a Single Cycle Datapath

Full Datapath. CSCI 402: Computer Architectures. The Processor (2) 3/21/19. Fengguang Song Department of Computer & Information Science IUPUI

Single Cycle CPU Design. Mehran Rezaei

Transcription:

Computer Science 4 Computing Hardware Fall 6 Harvard University Instructor: Prof. David Brooks dbrooks@eecs.harvard.edu

Upcoming topics Mon, Nov th MIPS Basic Architecture (Part ) Wed, Nov th Basic Computer Performance (/ lecture) Mon, Nov 7 th MIPS Basic architecture (Part, continued) Wed, Nov 9 th MIPS Multi-cycle architecture Mon, Dec 4 th MIPS Pipelining and Hazards (Part ) Wed, Dec 6 th MIPS Pipelining and Hazards (Part ) Mon, Dec th Memory and Caches (Part ) Wed, Dec 3 th Memory and Caches (Part ) Mon, Dec 8 th Advanced Topics (Preview CS46) [MIPS Pipeline Slides adapted from Dave Patterson s UCB CS5 slides and Mary Jane Irwin s CSE33 slides] David Brooks CS4

Flash Memory Overview Charge stored on floating gate of special nmos transistor, changes threshold voltage Can erase/store electrically, better than the old EEPROM s (UV-light exposure) David Brooks CS4

History of FLASH David Brooks CS4

Code vs. File Storage David Brooks CS4

Review: Single Cycle Data and Control Path 4 Add Instr[5-] 6 Op Instr[3-6] Control 8 3 PC+4[3-8] Jump Branch Src Add PCSrc Mem MemtoReg MemWrite PC Address Instruction Memory Instr[3-] RegDst Instr[5-] Instr[-6] Instr[5 -] RegWrite Addr Register Addr Data File Write Addr Data ovf zero Address Data Memory Data Instr[5-] Sign 6 Extend 3 control Instr[5-] David Brooks CS4

Disadvantages of the Single Cycle Datapath 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 Is wasteful of area since some functional units must be duplicated since they can not be shared during an instruction execution e.g., need separate adders to do PC update and branch target address calculations, as well as an to do R-type arithmetic/logic operations and data memory address calculations David Brooks CS4

Multicycle Implementation Overview Each step in the execution takes clock cycle An instruction takes more than clock cycle to complete Not every instruction takes the same number of clock cycles to complete Multicycle implementations allow functional units to be used more than once per instruction as long as they are used on different clock cycles, as a result only need one memory need only one /adder faster clock rates different instructions to take a different number of clock cycles David Brooks CS4

The Multicycle Datapath A High Level View Registers have to be added after every major functional unit to hold the output value until it is used in a subsequent clock cycle PC Address Memory Data (Instr. or Data) IR MDR Addr Register Addr Data File Write Addr Data A B out David Brooks CS4

Clocking the Multicycle Datapath System Clock clock cycle MemWrite RegWrite PC Address Memory Data (Instr. or Data) IR MDR Addr Register Addr Data File Write Addr Data A B out David Brooks CS4

Break up the instructions into steps where each step takes a cycle while trying to balance the amount of work to be done in each step restrict each cycle to use only one major functional unit At the end of a cycle Multicycle Approach Store values needed in a later cycle by the current instruction in a state element (internal register) not visible to the programmer IR Instruction Register MDR Memory Data Register A and B register file read data registers out output register All (except IR) hold data only between a pair of adjacent clock cycles (so don t need a write control signal) Data used by subsequent instructions are stored in programmer visible state elements (i.e., register file, PC, or memory) David Brooks CS4

The Complete Multicycle Data with Control Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Review: Control Controlling the makes use of multiple levels of decoding main control unit generates the Op bits control unit generates control inputs Instr op lw sw beq add subt and or slt funct xxxxxx xxxxxx xxxxxx Op desired action add add subtract add subtract and or slt control input David Brooks CS4

ing/writing to Multicycle Approach, con t any of the internal registers or the PC occurs (quickly) at the end of a clock cycle reading/writing to the register file takes ~5% of a clock cycle since it has additional control and access overhead (reading can be done in parallel with decode) Have to add multiplexors in front of several of the functional unit inputs because the functional units are shared by different instruction cycles All operations occurring in one step occur in parallel within the same clock cycle This limits us to one operation, one memory access, and one register file access per step (per clock cycle) David Brooks CS4

Instruction Fetch Five Instruction Steps Instruction Decode and Register Fetch R-type Instruction Execution, Memory /Write Address Computation, Branch Completion, or Jump Completion Memory Access, Memory Write Completion or R-type Instruction Completion Memory Completion (Write Back) INSTRUCTIONS TAKE FROM 3-5 CYCLES! David Brooks CS4

Step : Instruction Fetch Use PC to get instruction from the memory 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? David Brooks CS4

Datapath Activity During Instruction Fetch Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During Instruction Fetch Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Fetch Control Signals Settings Start Instr Fetch David Brooks CS4

Fetch Control Signals Settings Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= Instr Fetch David Brooks CS4

Step : Instruction Decode and Register Fetch Don t know what the instruction is yet, so can only registers rs and rt in case we need them Compute the branch address in case the instruction is a branch RTL: A = Reg[IR[5-]]; B = Reg[IR[-6]]; Out = PC +(sign-extend(ir[5-])<< ); Note we aren't setting any control lines based on the instruction (since we are busy "decoding" it in our control logic) David Brooks CS4

Datapath Activity During Instruction Decode Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During Instruction Decode Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= Decode Control Signals Settings IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= Instr Fetch Decode David Brooks CS4

Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= Decode Control Signals Settings IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= Instr Fetch Decode SrcA= SrcB= Op= Cond= David Brooks CS4

Step 3 (instruction dependent) is performing one of four functions, based on instruction type Memory reference (lw and sw): Out = A + sign-extend(ir[5-]); R-type: Out = A op B; Branch: if (A==B) PC = Out; Jump: PC = PC[3-8] (IR[5-] << ); David Brooks CS4

Datapath Activity During Instruction Execute Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During lw & sw Execute Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During R-type Execute Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During beq Execute Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During j Execute Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= Execute Control Signals Settings (Op = lw or sw) IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= Instr Fetch (Op = R-type) (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= Execute David Brooks CS4

Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= Execute Control Signals Settings (Op = lw or sw) Execute IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= SrcA= SrcB= Op= Cond= Instr Fetch (Op = R-type) SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= David Brooks CS4

Step 4 (instruction dependent) Memory reference: MDR = Memory[Out]; -- lw or Memory[Out] = B; -- sw R-type instruction completion Reg[IR[5-]] = Out; Remember, the register write actually takes place at the end of the cycle on the clock edge David Brooks CS4

Datapath Activity During Memory Access Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During lw Memory Access Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During sw Memory Access Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During R-type Memory Access Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Memory Access Control Signals Settings Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= (Op = lw) (Op = sw) Memory Access (Op = lw or sw) Execute IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= SrcA= SrcB= Op= Cond= Instr Fetch (Op = R-type) SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= David Brooks CS4

Memory Access Control Signals Settings Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= (Op = lw) Mem IorD= Cond= (Op = sw) Memory Access (Op = lw or sw) Execute MemWrite IorD= Cond= IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= SrcA= SrcB= Op= Cond= RegDst= RegWrite MemtoReg= Cond= Instr Fetch (Op = R-type) SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= David Brooks CS4

Step 5: Memory Completion (Write Back) All we have left is the write back into the register file the data just read from memory for lw instruction Reg[IR[-6]]= MDR; What about all the other instructions? David Brooks CS4

Datapath Activity During Write Back Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Datapath Activity During lw Write Back Cond IorD Mem MemWrite MemtoReg IRWrite PCSource Op Control SrcB SrcA RegWrite RegDst PC Address Memory Data (Instr. or Data) IR MDR Instr[3-6] Instr[5-] Instr[5-] Addr Register Addr Data File Write Addr Data Sign Extend 3 Instr[5-] A B 4 3 PC[3-8] zero control 8 out David Brooks CS4

Write Back Control Signals Settings Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= (Op = lw) Mem IorD= Cond= (Op = sw) Memory Access (Op = lw or sw) Execute MemWrite IorD= Cond= IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= SrcA= SrcB= Op= Cond= RegDst= RegWrite MemtoReg= Cond= Instr Fetch (Op = R-type) SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= Write Back David Brooks CS4

Write Back Control Signals Settings Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= (Op = lw) Mem IorD= Cond= (Op = sw) Memory Access (Op = lw or sw) Execute MemWrite IorD= Cond= IorD= Mem;IRWrite SrcA= srcb= PCSource,Op= SrcA= SrcB= Op= Cond= RegDst= RegWrite MemtoReg= Cond= Instr Fetch (Op = R-type) SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= RegDst= RegWrite MemtoReg= Cond= Write Back David Brooks CS4

RTL Summary Step Instr fetch Decode Execute Memory access R-type Out = PC +(sign-extend(ir[5-])<< ); Out = if (A==B) A + sign-extend PC = (IR[5-]); Out; Out = A op B; Writeback Reg[IR[5- ]] = Out; Mem Ref Branch IR = Memory[PC]; PC = PC + 4; A = Reg[IR[5-]]; B = Reg[IR[-6]]; MDR = Memory[Out]; or Memory[Out] = B; Reg[IR[-6]] = MDR; Jump PC = PC[3-8] (IR[5-] << ); David Brooks CS4

Simple Questions How many cycles will it take to execute this code? lw $t, ($t3) lw $t3, 4($t3) beq $t, $t3, Label #assume not add $t5, $t, $t3 sw $t5, 8($t3) Label:... What is going on during the 8 th cycle of execution? In what cycle does the actual addition of $t and $t3 takes place? In what cycle is the branch target address calculated? David Brooks CS4

Simple Questions How many cycles will it take to execute this code? lw $t, ($t3) 5 lw $t3, 4($t3) 5 beq $t, $t3, Label 3 #assume not add $t5, $t, $t3 4 sw $t5, 8($t3) 4 Label:... = cycles What is going on during the 8 th cycle of execution? address for second lw being calculated In what cycle does the actual addition of $t and $t3 takes place? 6 th cycle In what cycle is the branch target address calculated? th cycle David Brooks CS4

Multicycle Control Multicycle datapath control signals are not determined solely by the bits in the instruction e.g., op code bits tell what operation the should be doing, but not what instruction cycle is to be done next 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 Combinational current state and the input) control logic... Datapath control points Inst Opcode We ll use a Moore machine (so control signals based only on current state) David Brooks CS4...... State Reg Next State

Multicycle Datapath Finite State Machine Unless otherwise assigned Start,IRWrite, MemWrite,RegWrite= others= SrcA= SrcB= Op= Cond= 3 (Op = lw) Mem IorD= Cond= (Op = sw) Memory Access (Op = lw or sw) Execute IorD= Instr Fetch 5 MemWrite IorD= Cond= Mem;IRWrite SrcA= srcb= PCSource,Op= 6 SrcA= SrcB= Op= Cond= 7 RegDst= RegWrite MemtoReg= Cond= (Op = R-type) 8 9 SrcA= SrcB= Op= PCSource= Cond (Op = beq) (Op = j) Decode SrcA= SrcB= Op= Cond= PCSource= 4 RegDst= RegWrite MemtoReg= Cond= Write Back David Brooks CS4

Finite State Machine Implementation Combinational control logic Inputs Outputs Cond IorD Mem MemWrite IRWrite MemtoReg PCSource Op SourceB SourceA RegWrite RegDst Op5 Op4 Op3 Op Op Op Inst[3-6] System Clock State Reg Next State David Brooks CS4

David Brooks CS4 Datapath Control Outputs Truth Table RegDst RegWrite SrcA SrcB Op PCSource MemtoReg IRWrite MemWrite Mem IorD Cond Input Values (Current State[3-]) Outputs

David Brooks CS4 Next State Truth Table illegal illegal illegal illegal illegal illegal illegal illegal illegal Any other (sw) (lw) (beq) (jmp) (R-type) Inst[3-6] (Op[5-]) Current State [3- ]