Control & Execution. Finite State Machines for Control. MIPS Execution. Comp 411. L14 Control & Execution 1

Similar documents
EECE 417 Computer Systems Architecture

The Processor: Datapath & Control

Processor: Multi- Cycle Datapath & Control

ECE369. Chapter 5 ECE369

Design of the MIPS Processor

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

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

Single vs. Multi-cycle Implementation

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

CPE 335. Basic MIPS Architecture Part II

Chapter 4 The Processor (Part 2)

Design of the MIPS Processor (contd)

Multicycle Approach. Designing MIPS Processor

October 24. Five Execution Steps

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Lets Build a Processor

LECTURE 6. Multi-Cycle Datapath and Control

Systems Architecture I

Topic #6. Processor Design

Processor (multi-cycle)

Chapter 5: The Processor: Datapath and Control

Multiple Cycle Data Path

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design

CSE 2021 COMPUTER ORGANIZATION

Computer Science 141 Computing Hardware

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

The MIPS Processor Datapath

ENE 334 Microprocessors

Implementing the Control. Simple Questions

CC 311- Computer Architecture. The Processor - Control

Chapter 5 Solutions: For More Practice

CSE 2021 COMPUTER ORGANIZATION

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

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

Lecture 5: The Processor

CSE Lecture In Class Example Handout

RISC Processor Design

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

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

These actions may use different parts of the CPU. Pipelining is when the parts run simultaneously on different instructions.

CSSE232 Computer Architecture I. Mul5cycle Datapath

Processor (I) - datapath & control. Hwansoo Han

RISC Architecture: Multi-Cycle Implementation

Inf2C - Computer Systems Lecture Processor Design Single Cycle

Block diagram view. Datapath = functional units + registers

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

Points available Your marks Total 100

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

Microprogrammed Control Approach

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

RISC Architecture: Multi-Cycle Implementation

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

Chapter 4. The Processor

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

Computer Organization. Structure of a Computer. Registers. Register Transfer. Register Files. Memories

CISC Processor Design

Data paths for MIPS instructions

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

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

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Levels in Processor Design

Chapter 4. The Processor

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

B.10 Finite State Machines B.10

Mapping Control to Hardware

Recitation Session 6

RISC Design: Multi-Cycle Implementation

Single Cycle Datapath

Computer Organization

ECE260: Fundamentals of Computer Engineering

Single Cycle Datapath

Introduction. Datapath Basics

CENG 3420 Lecture 06: Datapath

Multicycle conclusion

Outline of today s lecture. EEL-4713 Computer Architecture Designing a Multiple-Cycle Processor. What s wrong with our CPI=1 processor?

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

Systems Architecture

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

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

The overall datapath for RT, lw,sw beq instrucution

Single-Cycle Examples, Multi-Cycle Introduction

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

Name: ID# UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences EECS150 Fall 2001 Prof. Subramanian Midterm III

Lecture 10: Simple Data Path

CS Computer Architecture Spring Week 10: Chapter

Initial Representation Finite State Diagram. Logic Representation Logic Equations

Review: Abstract Implementation View

Chapter 4. The Processor Designing the datapath

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

CPU Design Steps. EECC550 - Shaaban

ECS 154B Computer Architecture II Spring 2009

Major CPU Design Steps

Control Unit for Multiple Cycle Implementation

CS 2461: Computer Architecture I

CPU Organization. Hardware design. Vs. Microprogramming

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

Design of Decode, Control and Associated Datapath Units

EE457. Note: Parts of the solutions are extracted from the solutions manual accompanying the text book.

5.7. Microprogramming: Simplifying Control Design 5.7

Transcription:

Control & Execution Finite State Machines for Control MIPS Execution L14 Control & Execution 1

Synchronous Systems data Latch Combinational logic Latch Clock leading edge trailing edge On the leading edge of the clock, the input of a latch is transferred to the output and held. We must be sure the output of the combinational logic has settled before the next leading clock edge. L14 Control & Execution 2

Asynchronous Systems data valid Latch Combinational logic Latch No clock! The data carries a valid signal along with it System goes at greatest possible speed. Only computes when necessary. Everything we look at in this class will be synchronous L14 Control & Execution 3

Fetching Sequential Instructions 4 + P C Read Address latch Instruction Instruction Memory How about branch? L14 Control & Execution 4

Datapath for R-type Instructions ALU Operation Inst Bits 25-21 Inst Bits 20-16 Inst Bits 15-11 5 5 5 32 Read Reg. 1 (rs) Read Reg. 2 (rt) Write Reg. (rd) Write Data data 1 data 2 32 32 3 RegWrite L14 Control & Execution 5

Input MUX Blocks 0 1 2 3 4 5 6 7 Select 2 1 0 Out In 8 Select 3 Out The select signal determines which of the inputs is connected to the output L14 Control & Execution 6

Inside there is a 32 way MUX per bit Read Reg 1 5 Register 0 Register 1 Register 2 Register 3 Register 4 Register... Register 30 Register 31 32 to1 MUX Data 1 LOT S OF CONNECTIONS! For EACH bit in the 32 bit register And this is just one port! Remember, we have data1 and data2 coming out of the register file! L14 Control & Execution 7

Our Register File has 3 ports 2 Read Ports This is one reason we have only a small number of registers What s another reason? Inst Bits 25-21 Inst Bits 20-16 Inst Bits 15-11 5 5 5 32 Read Reg. 1 Read Reg. 2 Write Reg. Write Data data 1 data 2 32 32 1 Write Port REALLY LOTS OF CONNECTIONS! RegWrite L14 Control & Execution 8

Implementing Logical Functions Suppose we want to map M input bits to N output bits For example, we need to take the OPCODE field from the instruction and determine what OPERATION to send to the ALU. OPCODE bits from instruction Map to ALU op ALU Control 32 5 32 L14 Control & Execution 9

Remember our ALU? A B That s a lot of stuff Sub Add/Sub Bidirectional Shifter Boolean Bool Shft 1 0 Math 1 0 Flags V,C N Flag R Z Flag L14 Control & Execution 10

Implementing Logical Functions Suppose we want to map M input bits to N output bits For example, we need to take the OPCODE field from the instruction and determine what OPERATION to send to the ALU. OPCODE bits from instruction Map to ALU op ALU Control 32 5 32 L14 Control & Execution 11

Input We can get 1 bit out with a MUX Put the INPUT HERE Wire these to HIGH or LOW depending on the value you want OUT for that INPUT Select 2 1 0 For example, 3 input AND has INPUT 7 wired HIGH and all the others wired LOW. 0 1 2 3 4 5 6 7 Out L14 Control & Execution 12

Or use a ROM M-bit Address Read-Only Memory N-bit Result L14 Control & Execution 13

Or use sum-of-products M-bit Input AND layer Product Terms OR layer N-bit Output Think of the SUM of PRODUCTS form. The AND layer generates the products of various input bits The OR layer combines the products into various outputs You could also use two NAND layers instead Could be implemented using Boolean gates, or also using a programmable logic array (PLA) [similar to a PROM, but both the AND and the OR parts are programmable]. L14 Control & Execution 14

Finite State Machines A set of STATES A set of INPUTS A set of OUTPUTS A function to map the STATE and the INPUT into the next STATE and an OUTPUT Remember automata? L14 Control & Execution 15

Traffic Light Controller L14 Control & Execution 16

Controller State Table Inputs Outputs State NScar Ewcar Next NSlight EWlight NSgreen 0 0 NSgreen 1 0 NSgreen 0 1 EWgreen 0 1 NSgreen 1 0 NSgreen 1 0 NSgreen 1 1 EWgreen 0 1 EWgreen 0 0 EWgreen 0 1 EWgreen 0 1 EWgreen 0 1 EWgreen 1 0 NSgreen 1 0 EWgreen 1 1 NSgreen 1 0 L14 Control & Execution 17

Implementing an FSM L14 Control & Execution 18

FSM Example: Recognizing Numbers Recognize the regular expression for floating point numbers [ \t]* [-+]?[0-9]*(. [0-9]*)? (e[-+]?[0 9]+)? Examples: +123.456e23.456 1.5e-10-123 a matches itself [abc] matches one of a, b, or c [a-z] matches one of a, b, c, d,..., x, y, or z 0* matches zero or more 0 s (, 0, 00, 0000 ) Z? matches zero or 1 Z s L14 Control & Execution 19

FSM Diagram start. + - 0 9 sign 0 9 whole.. 0 9 done frac e 0 9 e exp L14 Control & Execution 20

FSM Table IN : STATE NEW STATE : start start 0 1... 9 : start whole + - : start sign. : start frac 0 1... 9 : sign whole. : sign frac 0 1... 9 : whole whole. : whole frac : whole done e : whole exp e : frac exp 0 1... 9 : frac frac : frac done 0 1... 9 : exp exp : exp done STATE ASSIGNMENTS start = 0 = 000 sign = 1 = 001 whole = 2 = 010 frac = 3 = 011 exp = 4 = 100 done = 5 = 101 error = 6 = 110 L14 Control & Execution 21

FSM Implementation char in 7 error ROM or PLA or comb. logic ok state 3 3 Our ROM has: 10 inputs 5 outputs L14 Control & Execution 22

FSM Summary With JUST a register and some logic, we can implement complicated sequential functions like recognizing a FP number. This is useful in its own right for compilers, input routines, etc. The reason we re looking at it here is to see how designers implement the complicated sequences of events required to implement instructions Think of the OP-CODE as playing the role of the input character in the recognizer. The character AND the state determine the next state (and action). L14 Control & Execution 23

Programming also Finite State Machines are great for encoding actions in games and graphical user interfaces. https://gamedevelopment.tutsplus.com/tutorials/finite- state-machines-theory-and-implementation--gamedev- 11867 http://gameprogrammingpatterns.com/state.html L14 Control & Execution 24

1. Instruction Fetch Five Execution Steps 2. Instruction Decode and Register Fetch 3. Execution, Memory Address Computation, or Branch Completion 4. Memory Access or R-type instruction completion 5. Memory Read Completion INSTRUCTIONS TAKE FROM 3-5 CYCLES! An FSM looks at the op-code to determine how many... L14 Control & Execution 25

Step 1: Instruction Fetch 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]; IR is Instruction Register PC = PC + 4; L14 Control & Execution 26

Step 2: Instruction Decode and Register Fetch 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) L14 Control & Execution 27

Step 3 (instruction dependent) 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; L14 Control & Execution 28

Step 4 (R-type or memory-access) Loads and stores access memory MDR = Memory[ALUOut]; MDR is Memory Data Register or Memory[ALUOut] = B; R-type instructions finish Reg[IR[15-11]] = ALUOut; L14 Control & Execution 29

Step 5 Memory Read Completion Reg[IR[20-16]]= MDR; L14 Control & Execution 30

Step name Instruction fetch Instruction decode/register fetch Action for R-type instructions Summary: Action for memory-reference Action for instructions branches IR = Memory[PC] PC = PC + 4 A = Reg [IR[25-21]] B = Reg [IR[20-16]] ALUOut = PC + (sign-extend (IR[15-0]) << 2) Action for jumps Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [31-28] II computation, branch/ (IR[15-0]) PC = ALUOut (IR[25-0]<<2) jump completion Memory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut] completion ALUOut or Store: Memory [ALUOut] = B Memory read completion Load: Reg[IR[20-16]] = MDR L14 Control & Execution 31