Ch 7. Finite State Machines. VII - Finite State Machines Contemporary Logic Design 1

Similar documents
Example: vending machine

Models for representing sequential circuits

Last lecture Counter design Finite state machine started vending machine example. Today Continue on the vending machine example Moore/Mealy machines

Synchronous Sequential Circuit Design. Dr. Ehab A. H. AL-Hialy Page 1

Generalized FSM model: Moore and Mealy

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

Sequential Circuit Design

Different encodings generate different circuits

EGR224 F 18 Assignment #4

Synchronous Sequential Circuit Design. Digital Computer Design

Synchronous Sequential Circuit Design

14:332:231 DIGITAL LOGIC DESIGN

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

EECS150 - Digital Design Lecture 23 - FSMs & Counters

Module 10: Sequential Circuit Design

Finite State Machine (FSM)

Example: A vending machine

The Design Procedure. Output Equation Determination - Derive output equations from the state table

Computers also need devices capable of Storing data and information Performing mathematical operations on such data

Ch 9. Sequential Logic Technologies. IX - Sequential Logic Technology Contemporary Logic Design 1

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 9 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

14.1. Unit 14. State Machine Design

ENGG 1203 Tutorial _03 Laboratory 3 Build a ball counter. Lab 3. Lab 3 Gate Timing. Lab 3 Steps in designing a State Machine. Timing diagram of a DFF

ENGG 1203 Tutorial. Solution (b) Solution (a) Simplification using K-map. Combinational Logic (II) and Sequential Logic (I) 8 Feb Learning Objectives

CPE100: Digital Logic Design I

EEE2135 Digital Logic Design

Digital Logic and Design (Course Code: EE222) Lecture 19: Sequential Circuits Contd..

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec 09 Counters Outline.

LOGIC CIRCUITS. Basic Experiment and Design of Electronics

Lecture 10: Synchronous Sequential Circuits Design

Counters. We ll look at different kinds of counters and discuss how to build them

Let s now begin to formalize our analysis of sequential machines Powerful methods for designing machines for System control Pattern recognition Etc.

CprE 281: Digital Logic

Chapter 7. Sequential Circuits Registers, Counters, RAM

Digital Logic Design - Chapter 5

CPE100: Digital Logic Design I

CPE100: Digital Logic Design I

Appendix B. Review of Digital Logic. Baback Izadi Division of Engineering Programs

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 7 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

Topic 8: Sequential Circuits

Symbolic State Minimization

ELCT201: DIGITAL LOGIC DESIGN

10/12/2016. An FSM with No Inputs Moves from State to State. ECE 120: Introduction to Computing. Eventually, the States Form a Loop

EECS150 - Digital Design Lecture 18 - Counters

EECS150 - Digital Design Lecture 18 - Counters

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

Adders allow computers to add numbers 2-bit ripple-carry adder

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Sequential Synchronous Circuit Analysis

EECS150 - Digital Design Lecture 17 - Sequential Circuits 3 (Counters)

Appendix A: Digital Logic. Principles of Computer Architecture. Principles of Computer Architecture by M. Murdocca and V. Heuring

LOGIC CIRCUITS. Basic Experiment and Design of Electronics. Ho Kyung Kim, Ph.D.

Synchronous Sequential Logic

FSM Optimization. Counter Logic Diagram Q1 Q2 Q3. Counter Implementation using RS FF 10/13/2015

ELCT201: DIGITAL LOGIC DESIGN

FSM model for sequential circuits

EECS150 - Digital Design Lecture 16 Counters. Announcements

COEN 312 DIGITAL SYSTEMS DESIGN - LECTURE NOTES Concordia University

CSE140: Components and Design Techniques for Digital Systems. Midterm Information. Instructor: Mohsen Imani. Sources: TSR, Katz, Boriello & Vahid

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

Reg. No. Question Paper Code : B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER Second Semester. Computer Science and Engineering

Digital Electronics Sequential Logic

Sequential logic and design

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

FYSE420 DIGITAL ELECTRONICS

Sequential Logic Optimization. Optimization in Context. Algorithmic Approach to State Minimization. Finite State Machine Optimization

Lecture 7: Logic design. Combinational logic circuits

Digital Design. Sequential Logic

or 0101 Machine

COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

COE 202: Digital Logic Design Sequential Circuits Part 4. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

ALU, Latches and Flip-Flops

Lecture (08) Synchronous Sequential Logic

ELEC Digital Logic Circuits Fall 2014 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10)


COE 202: Digital Logic Design Sequential Circuits Part 3. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Logic and Computer Design Fundamentals. Chapter 8 Sequencing and Control

Latches. October 13, 2003 Latches 1

6. Finite State Machines

Asynchronous sequence circuits

ASYNCHRONOUS SEQUENTIAL CIRCUITS

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Fundamentals of Digital Design

Chapter 6. Synchronous Sequential Circuits

Digital Circuit Engineering

Chapter 3. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 3 <1>

Chapter 3. Chapter 3 :: Topics. Introduction. Sequential Circuits

Digital Control of Electric Drives

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output of

Chapter #7: Sequential Logic Case Studies Contemporary Logic Design

Week-5. Sequential Circuit Design. Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.

WORKBOOK. Try Yourself Questions. Electrical Engineering Digital Electronics. Detailed Explanations of

Problem Set 9 Solutions

Mealy & Moore Machines

Analysis of Clocked Sequential Circuits

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

Appendix A: Digital Logic. CPSC 352- Computer Organization

Transcription:

Ch 7. Finite State Machines VII - Finite State Machines Contemporary Logic esign 1

Finite State Machines Sequential circuits primitive sequential elements combinational logic Models for representing sequential circuits finite-state machines (Moore and Mealy) Basic sequential circuits revisited shift registers counters esign procedure state diagrams state transition table next state functions VII - Finite State Machines Contemporary Logic esign 2

Counters Sequential logic circuit that proceed through a well defined sequence of states 3-bit binary up-counter 000, 001, 010, 011, 100, 101, 110, 111; and return to 000 ecade counter 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001; and return to 0000 (binary-coded decimal) Gray-code counter Only a single bit of the counter changes at a time to avoid circuit hazard 0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100, 1100, 1101, 1111, 1110, 1010, 1011, 1001, 1000 and repeat VII - Finite State Machines Contemporary Logic esign 3

Counters (cont d) Ring counters Shift registers can also be used as a kind of primitive counter Uses minimal hardware for its implementation Not efficient state encoding VII - Finite State Machines Contemporary Logic esign 4

Counters (cont d) Johnson counter (aka Mobius counter) Requires only one inverter more than the basic ring counter Can sequence through twice as many states VII - Finite State Machines Contemporary Logic esign 5

Counter esign Procedure 3-bit binary up-counter escribe state transition diagram and table VII - Finite State Machines Contemporary Logic esign 6

Counter esign Procedure (cont d) 3-bit binary up-counter esign combinational logic through K-map methods OUT1 OUT2 OUT3 CLK Q Q Q "1" VII - Finite State Machines Contemporary Logic esign 7

More complex counter example Complex counter repeats 5 states in sequence not a binary number representation Step 1: derive the state transition diagram count sequence: 000, 010, 011, 101, 110 Step 2: derive the state transition table from the state transition diagram 010 000 110 011 101 Present State Next State C B A C+ B+ A+ 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 note the don't care conditions that arise from the unused state codes VII - Finite State Machines Contemporary Logic esign 8

More complex counter example (cont d) Step 3: K-maps for next state functions C+ C B+ C A+ C 0 0 0 X 1 1 0 X 0 1 0 X A X 1 X 1 A X 0 X 1 A X 1 X 0 B B B C+ <= A B+ <= B + A C A+ <= BC Present State Next State C B A C+ B+ A+ 0 0 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 0 0 VII - Finite State Machines Contemporary Logic esign 9

Self-starting counters Start-up states at power-up, counter may be in an unused or invalid state designer must guarantee that it (eventually) enters a valid state Self-starting solution design counter so that invalid states eventually transition to a valid state may limit exploitation of don't cares 001 111 111 implementation on previous slide 001 000 110 000 110 100 100 010 101 010 101 011 VII - Finite State Machines Contemporary Logic esign 10 011

Self-starting counters (cont d) Re-deriving state transition table from don't care assignment C+ C B+ C A+ C 0 0 0 0 1 1 0 1 0 1 0 0 A 1 1 1 1 A 1 0 0 1 A 0 1 0 0 B B B Present State Next State C B A C+ B+ A+ 0 0 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 0 0 100 111 010 000 110 011 101 001 VII - Finite State Machines Contemporary Logic esign 11

Abstraction of state elements ivide circuit into combinational logic and state Localize the feedback loops and make it easy to break cycles Implementation of storage elements leads to various forms of sequential logic Inputs Combinational Logic Outputs State Inputs Storage Elements State Outputs VII - Finite State Machines Contemporary Logic esign 12

Finite state machine representations States: determined by possible values in sequential storage elements Transitions: change of state Clock: controls when state can change by controlling storage elements Sequential logic sequences through a series of states based on sequence of values on input signals clock period defines elements of sequence 001 In = 0 In = 1 100 010 In = 0 110 In = 1 111 VII - Finite State Machines Contemporary Logic esign 13

Example finite state machine diagram Combination lock from introduction to course 5 states 5 self-transitions 6 other transitions between states 1 reset transition (from all states) to state S1 closed ERR reset not equal not equal & new not equal & new & new S1 S2 S3 OPEN closed closed closed open mux=c1 equal mux=c2 equal mux=c3 equal & new & new & new not new not new not new VII - Finite State Machines Contemporary Logic esign 14

Can any sequential system be represented with a state diagram? Shift register input value shown on transition arcs output values shown within state node IN CLK OUT1 OUT2 OUT3 Q Q Q 1 100 110 1 0 1 1 1 0 000 1 010 101 0 111 1 0 0 0 1 0 001 0 011 VII - Finite State Machines Contemporary Logic esign 15

FSM design procedure Step 1. Understand the problem escribe a finite state machine in an unambiguous manner Step 2. Obtain an abstract representation of the FSM State diagram Step 3. Perform state minimization Certain paths through the state machine can be eliminated Step 4. Perform state assignment Counter: the state and the output are identical General FSM: good state encoding often leads to a simpler implementation Step 5. Implement the finite state machine Using Boolean equations or K-maps VII - Finite State Machines Contemporary Logic esign 16

Counter/shift-register model Values stored in registers (flip-flops) represent the state of the circuit Next state is function of current state and inputs Outputs are the state Combinational logic implements the function for next state Inputs next state logic Next State Current State Outputs VII - Finite State Machines Contemporary Logic esign 17

General state machine model Values stored in registers represent the state of the circuit Next state is function of current state and inputs Outputs are function of current state and inputs (Mealy machine) function of current state only (Moore machine) Combinational logic implements the functions for next state and outputs Inputs output logic next state logic Next State Outputs Current State VII - Finite State Machines Contemporary Logic esign 18

State machine model (cont d) States: S 1, S 2,..., S k Inputs: I 1, I 2,..., I m Outputs: O 1, O 2,..., O n Transition function: F s (S i, I j ) Output function: F o (S i ) or F o (S i, I j ) Inputs output logic next state logic Next State Outputs Current State Next State State Clock 0 1 2 3 4 5 VII - Finite State Machines Contemporary Logic esign 19

Comparison of Mealy and Moore machines Mealy machines tend to have less states different outputs on arcs (n 2 ) rather than states (n) Moore machines are safer to use outputs change at clock edge (always one cycle later) in Mealy machines, input change can cause output change as soon as logic is done a big problem when two machines are interconnected asynchronous feedback may occur if one isn t careful Mealy machines react faster to inputs react in same cycle don't need to wait for clock in Moore machines, more logic may be necessary to decode state into outputs more gate delays after clock edge VII - Finite State Machines Contemporary Logic esign 20

Comparison of Mealy and Moore machines (cont d) Moore inputs combinational logic for next state reg logic for outputs outputs state feedback Mealy inputs logic for outputs outputs combinational logic for next state reg Synchronous Mealy state feedback inputs logic for outputs outputs combinational logic for next state reg state feedback VII - Finite State Machines Contemporary Logic esign 21

Specifying outputs for a Moore machine Output is only function of state reset specify in state bubble in state diagram example: sequence detector for 01 or 10 A/0 0 1 0 B/0 C/0 1 0 1 0 1 1 /1 E/1 0 current next reset input state state output 1 A 0 0 A B 0 0 1 A C 0 0 0 B B 0 0 1 B 0 0 0 C E 0 0 1 C C 0 0 0 E 1 0 1 C 1 0 0 E B 1 0 1 E 1 VII - Finite State Machines Contemporary Logic esign 22

Specifying outputs for a Mealy machine Output is function of state and inputs specify output on transition arc between states example: sequence detector for 01 or 10 reset/0 A 0/0 1/0 0/0 B 0/1 1/1 C current next reset input state state output 1 A 0 0 0 A B 0 0 1 A C 0 0 0 B B 0 0 1 B C 1 0 0 C B 1 0 1 C C 0 1/0 VII - Finite State Machines Contemporary Logic esign 23

Registered Mealy machine (really Moore) Synchronous (or registered) Mealy machine registered state AN outputs avoids glitchy outputs easy to implement in PLs Moore machine with no output decoding outputs computed on transition to next state rather than after entering view outputs as expanded state vector Inputs output logic next state logic Outputs Current State VII - Finite State Machines Contemporary Logic esign 24

Example: vending machine Release item after 15 cents are deposited Single coin slot for dimes, nickels No change Reset Coin Sensor N Vending Machine FSM Open Release Mechanism Clock VII - Finite State Machines Contemporary Logic esign 25

Example: vending machine (cont d) Suitable abstract representation tabulate typical input sequences: Reset 3 nickels nickel, dime S0 dime, nickel N two dimes draw state diagram: S1 S2 inputs: N,, reset N N output: open chute assumptions: assume N and asserted for one cycle each state has a self loop for N = = 0 (no coin) N S7 [open] S3 S8 [open] S4 [open] S5 [open] S6 [open] VII - Finite State Machines Contemporary Logic esign 26

Example: vending machine (cont d) Minimize number of states - reuse states whenever possible 0 5 Reset N N 10 N + present inputs next output state N state open 0 0 0 0 0 0 1 5 0 1 0 10 0 1 1 5 0 0 5 0 0 1 10 0 1 0 15 0 1 1 10 0 0 10 0 0 1 15 0 1 0 15 0 1 1 15 15 1 15 [open] symbolic state table VII - Finite State Machines Contemporary Logic esign 27

Example: vending machine (cont d) Uniquely encode states present state inputs next state output Q1 Q0 N 1 0 open 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 1 VII - Finite State Machines Contemporary Logic esign 28

Example: Moore implementation Mapping to logic 1 Q1 0 0 1 1 0 Q1 0 1 1 0 Open Q1 0 0 1 0 0 1 1 1 X X 1 X 1 1 1 1 N 1 0 1 1 X X 1 X 0 1 1 1 N 0 0 1 0 X X 1 X 0 0 1 0 N Q0 Q0 Q0 0 = Q0 N + Q0 N + Q1 N + Q1 1 = Q1 + + Q0 N OPEN = Q1 Q0 VII - Finite State Machines Contemporary Logic esign 29

Equivalent Mealy and Moore state diagrams Moore machine outputs associated with state Mealy machine outputs associated with transitions Reset N + Reset Reset/0 (N + Reset)/0 0 [0] N 0 N /0 N N/0 5 [0] N /0 5 N /0 N N/0 10 [0] N /1 10 N /0 N+ N+/1 15 [1] Reset 15 Reset /1 VII - Finite State Machines Contemporary Logic esign 30

Example: Mealy implementation Reset/0 Reset/0 0 N/0 /0 5 N/0 /1 10 N+/1 15 N /0 N /0 N /0 Reset /1 present state inputs next state output Q1 Q0 N 1 0 open 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 Open Q1 0 0 1 0 0 0 1 1 X X 1 X 0 1 1 1 N 0 1 OPEN = Q0 N + Q0N + Q1N + Q1 = Q1 + + Q0N = Q1Q0 + Q1N + Q1 + Q0 VII - Finite State Machines Q0 Contemporary Logic esign 31

Example: Mealy implementation 0 1 OPEN = Q0 N + Q0N + Q1N + Q1 = Q1 + + Q0N = Q1Q0 + Q1N + Q1 + Q0 make sure OPEN is 0 when reset by adding AN gate VII - Finite State Machines Contemporary Logic esign 32

Vending machine: Moore to synch. Mealy OPEN = Q1Q0 creates a combinational delay after Q1 and Q0 change in Moore implementation This can be corrected by retiming, i.e., move flip-flops and logic through each other to improve delay OPEN.d = (Q1 + + Q0N)(Q0'N + Q0N' + Q1N + Q1) = Q1Q0N' + Q1N + Q1 + Q0'N + Q0N' Implementation now looks like a synchronous Mealy machine it is common for programmable devices to have FF at end of logic VII - Finite State Machines Contemporary Logic esign 33

Vending machine: Mealy to synch. Mealy OPEN.d = Q1Q0 + Q1N + Q1 + Q0 OPEN.d = (Q1 + + Q0N)(Q0'N + Q0N' + Q1N + Q1) = Q1Q0N' + Q1N + Q1 + Q0'N + Q0N' Open.d Q1 0 0 1 0 Open.d Q1 0 0 1 0 0 0 1 1 1 0 1 1 0 1 1 1 N 0 0 1 1 X X 1 X 0 1 1 1 N Q0 Q0 VII - Finite State Machines Contemporary Logic esign 34

Mealy and Moore examples Recognize A,B = 0,1 Mealy or Moore? A B out A B clock Q Q out A Q out Q B Q clock Q VII - Finite State Machines Contemporary Logic esign 35

Mealy and Moore examples (cont d) Recognize A,B = 1,0 then 0,1 Mealy or Moore? out A B Q Q Q clock Q out A Q Q Q Q B Q Q Q Q clock VII - Finite State Machines Contemporary Logic esign 36

Example: reduce-1-string-by-1 Remove one 1 from every string of 1s on the input Moore Mealy zero [0] 1 0 zero 0/0 0 0 one1 [0] 1 two1s [1] 1 0/0 one1 1/0 1/1 VII - Finite State Machines Contemporary Logic esign 37

Finite state machines summary Models for representing sequential circuits abstraction of sequential elements finite state machines and their state diagrams inputs/outputs Mealy, Moore, and synchronous Mealy machines Finite state machine design procedure deriving state diagram deriving state transition table determining next state and output functions implementing combinational logic VII - Finite State Machines Contemporary Logic esign 38