Finite State Machines CS 64: Computer Organization and Design Logic Lecture #16

Similar documents
Combinatorial Logic Design Multiplexers and ALUs CS 64: Computer Organization and Design Logic Lecture #14

Course Overview. Course Overview

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

UC Berkeley CS61C : Machine Structures

I hope you have completed Part 2 of the Experiment and is ready for Part 3.

Lecture 3: Logic circuit. Combinational circuit and sequential circuit

UC Berkeley CS61C : Machine Structures

EECS150 - Digital Design Lecture 28 Course Wrap Up. Recap 1

ECE 241 Digital Systems. Basic Information

Digital Circuits Laboratory LAB no. 12. REGISTERS

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING SEMESTER TWO EXAMINATION 2017/2018

Sequential program, state machine, Concurrent process models

Digital Logic Circuits

Controller Implementation--Part I. Cascading Edge-triggered Flip-Flops

DIGITAL DESIGN WITH SM CHARTS

Types of Control. Programmed Non-programmed. Program Counter Hardwired

EECS-140/141 Introduction to Digital Logic Design Lecture 7:Sequential Logic Basics

Lecture 02: Digital Logic Review

Module -18 Flip flops

COMPUTER ORGANIZATION & ARCHITECTURE DIGITAL LOGIC CSCD211- DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY OF GHANA

EECS 150 Homework 4 Solutions Fall 2008

Lecture Topics. Announcements. Today: Pipelined Processors (P&H ) Next: continued. Milestone #4 (due 2/23) Milestone #5 (due 3/2)

1 Q' 3. You are given a sequential circuit that has the following circuit to compute the next state:

6.111 Lecture # 19. Controlling Position. Some General Features of Servos: Servomechanisms are of this form:

Gomoku Player Design

Written exam IE1204/5 Digital Design Friday 13/

First Name: Last Name: Lab Cover Page. Teaching Assistant to whom you are submitting


2014 Paper E2.1: Digital Electronics II

SRV ENGINEERING COLLEGE SEMBODAI RUKMANI VARATHARAJAN ENGINEERING COLLEGE SEMBODAI

Learning Outcomes. Spiral 2 3. DeMorgan Equivalents NEGATIVE (ACTIVE LO) LOGIC. Negative Logic One hot State Assignment System Design Examples

ENGG1015: lab 3. Sequential Logic

Chapter 9. sequential logic technologies

Course Outline Cover Page

Chapter 9. sequential logic technologies

Lab #10: Finite State Machine Design

Understanding Engineers #2

Department of Electronics and Communication Engineering

EE 280 Introduction to Digital Logic Design

Practical Workbook Logic Design & Switching Theory

UNIVERSITI MALAYSIA PERLIS

First Optional Homework Problem Set for Engineering 1630, Fall 2014

CS 61C: Great Ideas in Computer Architecture Finite State Machines, Functional Units

ECE 2300 Digital Logic & Computer Organization

Serial Addition. Lecture 29 1

Digital Electronic Concepts

Chapter 4: FLIP FLOPS. (Sequential Circuits) By: Siti Sabariah Hj. Salihin ELECTRICAL ENGINEERING DEPARTMENT EE 202 : DIGITAL ELECTRONICS 1

EE 307 Project #1 Whac-A-Mole

Brought to you by. Priti Srinivas Sajja. PS01CMCA02 Course Content. Tutorial Practice Material. Acknowldgement References. Website pritisajja.

Chapter # 1: Introduction

UNIT II: Clocked Synchronous Sequential Circuits. CpE 411 Advanced Logic Circuits Design 1

EECS150 - Digital Design Lecture 2 - CMOS

ENGIN 112 Intro to Electrical and Computer Engineering

LOGIC DIAGRAM: HALF ADDER TRUTH TABLE: A B CARRY SUM. 2012/ODD/III/ECE/DE/LM Page No. 1

Exam #2 EE 209: Fall 2017

Introduction. BME208 Logic Circuits Yalçın İŞLER

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700:

Chapter 5 Sequential Logic Circuits Part II Hiroaki Kobayashi 7/11/2011

CS302 Digital Logic Design Solved Objective Midterm Papers For Preparation of Midterm Exam

CS 110 Computer Architecture Lecture 11: Pipelining

a b y UC Berkeley CS61C : Machine Structures Hello Helo,world!

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-378:

LIST OF EXPERIMENTS. KCTCET/ /Odd/3rd/ETE/CSE/LM

UC Berkeley CS61C : Machine Structures

DIGITAL ELECTRONICS. Methods & diagrams : 1 Graph plotting : - Tables & analysis : - Questions & discussion : 6 Performance : 3

Digital Design Laboratory Lecture 7. A/D and D/A

Pipelining A B C D. Readings: Example: Doing the laundry. Ann, Brian, Cathy, & Dave. each have one load of clothes to wash, dry, and fold

Memory, Latches, & Registers

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700:

Welcome to 6.111! Introductory Digital Systems Laboratory

logic system Outputs The addition of feedback means that the state of the circuit may change with time; it is sequential. logic system Outputs

DIGITAL ELECTRONICS: LOGIC AND CLOCKS

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Chapter 3 Digital Logic Structures

Digital Design and System Implementation. Overview of Physical Implementations

CS101 Lecture 01: Introduction. What You ll Learn Today

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700:

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. Digital Logic

Computer Arithmetic (2)

SYLLABUS of the course BASIC ELECTRONICS AND DIGITAL SIGNAL PROCESSING. Master in Computer Science, University of Bolzano-Bozen, a.y.

EC4205 Microprocessor and Microcontroller

CS302 - Digital Logic Design Glossary By

COURSE LEARNING OUTCOMES AND OBJECTIVES

Gates and Circuits 1

ICS 151 Final. (Last Name) (First Name)

CS429: Computer Organization and Architecture

Solutions. ICS 151 Final. Q1 Q2 Q3 Q4 Total Credit Score. Instructions: Student ID. (Last Name) (First Name) Signature

Vol. 5, No. 6 June 2014 ISSN Journal of Emerging Trends in Computing and Information Sciences CIS Journal. All rights reserved.

ECE 124 Digital Circuits and Systems Winter 2011 Introduction Calendar Description:

Electronics for Scientists V and G (Spring 2007)

Switching Circuits & Logic Design

A B C D. Ann, Brian, Cathy, & Dave each have one load of clothes to wash, dry, and fold. Time

Module-20 Shift Registers

Data Logger by Carsten Kristiansen Napier University. November 2004

(CSC-3501) Lecture 6 (31 Jan 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

Welcome to 6.111! Introductory Digital Systems Laboratory

Number system: the system used to count discrete units is called number. Decimal system: the number system that contains 10 distinguished

5. (Adapted from 3.25)

Digital Electronics. A. I can list five basic safety rules for electronics. B. I can properly display large and small numbers in proper notation,

Transcription:

Finite State Machines CS 64: Computer Organization and Design Logic Lecture #16 Ziad Matni Dept. of Computer Science, UCSB

Lecture Outline Review of Latches vs. FFs Finite State Machines Moore vs. Mealy types State Diagrams One Hot Method 3/13/18 Matni, CS64, Wi18 2

Latches vs. FFs D D Flip-Flop (D-FF) Q Latches capture data on an entire 1 or 0 level of the clock FFs capture data on the edge of the clock This example shows the positive (0à1) edge used > CLK Q Latch out FF out FFs give out less glitchy outputs 3/13/18 Matni, CS64, Wi18 3

If a combinational logic circuit is an implementation of a Boolean function, then a sequential logic circuit can be considered an implementation of a finite state machine. 3/13/18 Matni, CS64, Wi18 4

Finite State Machines (FSM) An abstract machine that can be in exactly one of a finite number of states at any given time It s a very simple model of a computational machine, unlike Pushdown Automatons and Turing Machines You ll discover these in other CS upper-div classes The FSM can change from one state to another in response to some external inputs The change from one state to another is called a transition. An FSM is defined by a list of its states, its initial state, and the conditions for each transition. 3/13/18 Matni, CS64, Wi18 5

Example of a Simple FSM: The Turnstile initial state State Transition Table Current State Input Next State Output Locked Coin Unlocked Unlocks the turnstile so that the customer can push through. Locked Push Locked Nothing you re locked! J Unlocked Coin Unlocked Nothing you just wasted a coin! J Unlocked Push Locked When the customer has pushed through, locks the turnstile. 3/13/18 Matni, CS64, Wi18 6 Source: Wikipedia

Example of a Simple FSM: The Turnstile initial state State Transition Table Current State Input Next State Output Locked Coin Unlocked Unlocks the turnstile so that the customer can push through. Locked Push Locked Nothing you re locked! J Unlocked Coin Unlocked Nothing you just wasted a coin! J Unlocked Push Locked When the customer has pushed through, locks the turnstile. 3/13/18 Matni, CS64, Wi18 7 Source: Wikipedia

General Form of FSMs 3/13/18 Matni, CS64, Wi18 8

Example Output-to-input feedback Combinatorial logic A CLK Clock signal Q* State register Q Q* = Q O.A On the next rising edge of the clock, the output of the D-FF Q (Q*) will become the previous value of Q (Q O ) AND the value of input A 3/13/18 Matni, CS64, Wi18 9

FSM Types There are 2 types/models of FSMs: Moore machine Output is function of present state only Mealy machine Output is function of present state and present input 3/13/18 Matni, CS64, Wi18 10

Moore Machine 3/13/18 Matni, CS64, Wi18 11

Example of a Moore Machine (with 1 state) A Q Z CLK B Z = (Q* + B) = (Q O.A + B) On the next rising edge of the clock, the output of the entire circuit (Z) will become (the previous value of Q (Q O ) AND the value of input A) NOR B 3/13/18 Matni, CS64, Wi18 12

Mealy Machine 3/13/18 Matni, CS64, Wi18 13

Example of a Mealy Machine (with 1 state) A CLK B Q Z Z = (Q* + A + B) = (Q O XOR A) + (A + B) On the next rising edge of the clock, the output of the entire circuit (Z) will become etc 3/13/18 Matni, CS64, Wi18 14

Diagraming State Machines A simple FSM example 2 states: Door opened Door closed This is called a state diagram 3/13/18 Matni, CS64, Wi18 15

Example of a Moore Machine 1 WASHER_DRYER Let s build a sequential logic FSM that acts as a controller to a washer/dryer machine SO: Before we begin, the machine is in an initial state that is waiting for you to insert a coin. We ll call that state the Initial State (inventive, no?) The machine will start a washer timer as soon as a coin is inserted. The timer is controlled by a signal (i.e. input var) called TIMER_LT_30, which is always initialized to be 1. 3/13/18 Matni, CS64, Wi18 16

Example of a Moore Machine 1 WASHER_DRYER Upon inserting a coin in the machine, we will begin the wash cycle. We ll call that state Wash. This state will output a signal to fill the washer with water (FILL_WATER). As long as the timer is below 30 mins (TIMER_LT_30 = 1), the cycle continues. When the timer surpasses 30 mins (i.e. TIMER_LT_30 = 0), this state will end 3/13/18 Matni, CS64, Wi18 17

Example of a Moore Machine 1 WASHER_DRYER When the timer hits 30 mins, we will begin the rinse cycle. We ll call that Rinse. This will output a signal to drain the water and refill with new water (DRAIN_REFILL = 1). As long as the soap sensor is on (SOAP = 1), the cycle continues. When the soap sensor turns off (i.e. SOAP= 0), this state will end 3/13/18 Matni, CS64, Wi18 18

Example of a Moore Machine 1 WASHER_DRYER When the soap sensor goes off, we will begin the dry cycle. We ll call that Dry. This state will output a signal to drain the water and begin drying (DRAIN = 1). As long as the wet clothes sensor is on (WET = 1), the cycle continues. When the wet clothes sensor is off (WET = 0), we will stop! This means going back to the Initial State 3/13/18 Matni, CS64, Wi18 19

State Diagram 1 TIMER_LT_30 = 1 SOAP = 1 COIN = 0 Wash TIMER_LT_30 = 0 Rinse Initial State TIMER_LT_30 = 1 FILL_WATER = 1 DRAIN_REFILL = 1 WET = 0 Dry WET = 1 DRAIN = 1 3/13/18 Matni, CS64, Wi18 20

Example of a Moore Machine 2 DETECT_1101 Let s build a sequential logic FSM that always detects a specific serial sequence of bits: 1101 SO: We ll start at an Initial state (S0) We ll first look for a 1. We ll call that State 1 (S1) Don t go to S1 if all we find is a 0! We ll then keep looking for another 1. We ll call that State 11 (S2) Then a 0. We ll call that State 110 (S3) Then another 1. We ll call that State 1101 (S4) this will output a FOUND signal We will always be detecting 1101 (it doesn t end) 3/13/18 Matni, CS64, Wi18 21

State Diagram 2 Input = 1 Input = 0 Input = 1 1 11 S1 S2 Initial State S0 Input = 0 Input = 0 1101 S4 Input = 1 110 S3 FOUND = 1 3/13/18 Matni, CS64, Wi18 22

Going from State Diagram to Circuit There s more than 1 way to do this, but the most popular is the One Hot Method Give each state it s own D-FF output # of FFs needed = # of states Inputs to the FFs are combinatorial logic that can simplified into a sum-of-products type of Boolean expression Current CAD software can do this automatically Implementation is usually done on a simulator (software), or prototype hardware Integrated Circuit (FPGA) 3/13/18 Matni, CS64, Wi18 23

Encoding our States Per the last example: We had 5 separate states: NAME Binary Code One Hot Code OUTPUT Initial State S0 000 00001 1 S1 001 00010 11 S2 010 00100 110 S3 011 01000 1101 S4 100 10000 FOUND Advantage of this One Hot approach? When we implement the machine with circuits, we can use a D-FF for every state (so, in this example, we d use 5 of them) 3/13/18 Matni, CS64, Wi18 24

Using the One Hot Code to Determine the Circuit Design Every state has 1 D-FF We can see that (follow the arrows!!): S1* = S0.I S2* = S1.I + S2.I + S4.I S3* = S2.I S4* = S3.I S0* = S0.I + S1.I + S3.I + S4.I Input = 0 Input = 1 1 11 Initial State S0 S1 1101 S4 FOUND = 1 Input = 0 Input = 1 S2 110 S3 Input = 1 Input = 0 also, when S4 happens, FOUND = 1, i.e. FOUND = S4 3/13/18 Matni, CS64, Wi18 25

Implementing the Circuit 3/13/18 Matni, CS64, Wi18 26

Your To Dos Lab #8 is due end of day Friday 3/13/18 Matni, CS64, Wi18 27

3/13/18 Matni, CS64, Wi18 28