State Machine Design State Machine Design Digital Electronics

Slides:



Advertisements
Similar presentations
Lecture 15 Finite State Machine Implementation
Advertisements

State-machine structure (Mealy)
Digital Design - Sequential Logic Design Chapter 3 - Sequential Logic Design.
ECE 331 – Digital System Design Latches and Flip-Flops (Lecture #17) The slides included herein were taken from the materials accompanying Fundamentals.
Sequential Circuits1 DIGITAL LOGIC DESIGN by Dr. Fenghui Yao Tennessee State University Department of Computer Science Nashville, TN.
Flip-Flops and Related Devices Wen-Hung Liao, Ph.D.
Sequential logic circuits. 2 Outline Sequential Circuit Models –Asynchronous –Synchronous Latches Flip-Flops.
Chapter 3 Digital Logic Structures
1 Lecture 23 More Sequential Circuits Analysis. 2 Analysis of Combinational Vs. Sequential Circuits °Combinational : Boolean Equations Truth Table Output.
ECE 331 – Digital System Design Introduction to and Analysis of Sequential Logic Circuits (Lecture #20) The slides included herein were taken from the.
ECE 331 – Digital System Design
08/07/041 CSE-221 Digital Logic Design (DLD) Lecture-8:
Overview Finite State Machines - Sequential circuits with inputs and outputs State Diagrams - An abstraction tool to visualize and analyze sequential circuits.
Overview Finite State Machines - Sequential circuits with inputs and outputs State Diagrams - An abstraction tool to visualize and analyze sequential circuits.
Overview Finite State Machines
Digital Logic Design Lecture 26. Announcements Exams will be returned on Thursday Final small quiz on Monday, 12/8. Final homework will be assigned Thursday,
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
1 Synchronous Sequential Circuit Analysis. 2 Synchronous Sequential Circuit State Memory – A set of n edge-triggered flip-flops that store the current.
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic CMOS logic elements Combinational logic elements and design.
Sequential Circuit  It is a type of logic circuit whose output depends not only on the present value of its input signals but on the past history of its.
Chapter 9 Counters.
Lecture 21 Overview Counters Sequential logic design.
Sequential Circuits Chapter 4 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Digital Computer Design Fundamental
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Elevator Controller We’re hired to design a digital elevator controller for a four-floor building st try: Design a counter that counts up.
Chap 4. Sequential Circuits
Digital Logic Design Sequential circuits
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Introduction to Sequential Logic Design Finite State-Machine Design.
1 Lecture #12 EGR 277 – Digital Logic Synchronous Logic Circuits versus Combinational Logic Circuits A) Combinational Logic Circuits Recall that there.
Counters Dr. Rebhi S. Baraka Logic Design (CSCI 2301) Department of Computer Science Faculty of Information Technology The Islamic University.
2017/4/24 CHAPTER 6 Counters Chapter 5 (Sections )
1 Lecture 22 Sequential Circuits Analysis. 2 Combinational vs. Sequential  Combinational Logic Circuit  Output is a function only of the present inputs.
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits Previously, we described the basic building blocks of sequential circuits,
Review of Digital Logic Design Concepts OR: What I Need to Know from Digital Logic Design (EEL3705)
9/15/09 - L21 Sequential Circuit Analaysis Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Analysis.
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Complete Example.
Chapter 3 Digital Logic Structures. 3-2 Combinational vs. Sequential Combinational Circuit always gives the same output for a given set of inputs  ex:
DLD Lecture 26 Finite State Machine Design Procedure.
1 Finite State Machines (FSMs) Now that we understand sequential circuits, we can use them to build: Synchronous (Clocked) Finite State Machines Finite.
ANALYSIS OF SEQUENTIAL CIRCUITS by Dr. Amin Danial Asham.
State Table Problem #1 An electronic lock is controlled by a keypad, which has three buttons labeled A, B, and R. The keypad is restricted such that, at.
Registers; State Machines Analysis Section 7-1 Section 5-4.
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
A sequential logic circuit (a.k.a. state machine) consists of both combinational logic circuit(s) and memory devices (flip flops). The combinational circuits.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
State Machine Design State Machine Design Digital Electronics
ECE 331 – Digital System Design Introduction to Sequential Circuits and Latches (Lecture #16)
TOPIC : Introduction to Sequential Circuits UNIT 1: Modeling and Simulation Module 4 : Modeling Sequential Circuits.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
Lecture 1 Gunjeet kaur Dronacharya group of institutions.
Digital Logic Structures: Chapter 3 COMP 2610 Dr. James Money COMP
LATCHED, FLIP-FLOPS,AND TIMERS
COMP541 Sequential Logic – 2: Finite State Machines
Asynchronous Inputs of a Flip-Flop
ECE 301 – Digital Electronics
FINITE STATE MACHINES (FSMs)
Sequential logic circuits
29-Nov-18 Counters Chapter 5 (Sections ).
Introduction to Sequential Circuits
Analysis of Synchronous Sequential Circuits
CSE 370 – Winter Sequential Logic-2 - 1
State Machine Design State Machine Design Digital Electronics
MTE 202, Summer 2016 Digital Circuits Dr.-Ing. Saleh Hussin
FINITE STATE MACHINES.
State Machine Design State Machine Design Digital Electronics
Presentation transcript:

State Machine Design State Machine Design Digital Electronics Lesson 3.4 State Machine Design State Machine Design Digital Electronics © 2014 Project Lead The Way, Inc. Project Lead The Way, Inc. Copyright 2009

State Machine Design This presentation will Digital Electronics Lesson 3.4 State Machine Design This presentation will Define a state machine and Illustrate the block diagram for a state machine. Provide several examples of everyday items that are controlled by state machines. Describe the steps in the state machine design process. Provide an example of a state machine design. Introductory Slide / Overview of Presentation Project Lead The Way, Inc. Copyright 2009

State Machine State Machine Design Digital Electronics Lesson 3.4 State Machine Design A synchronous sequential circuit, consisting of a sequential logic section and a combinational logic section, whose outputs and internal flip-flops progress through a predictable sequence of states in response to a clock and other input signals. Floyd, T. (2006). Digital fundamentals. Upper Saddle River, NY: Pearson Education. A state machine uses combinational and sequential logic to make decisions on outputs based on the inputs. A state machine will “hold” a state until a new set of inputs are given. Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

Parts of a State Machine State Machine Design Digital Electronics Lesson 3.4 State Machine Design Input Combinational Logic Memory Output Combinational Logic Floyd, T. (2006). Digital fundamentals. Upper Saddle River, NY: Pearson Education. Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

Input Combinational Logic State Machine Design Input Combinational Logic Digital Electronics Lesson 3.4 State Machine Design What should happen next based on the buttons, switches, and other inputs? Floyd, T. (2006). Digital fundamentals. Upper Saddle River, NY: Pearson Education. Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

State Machine Design Memory Digital Electronics Lesson 3.4 State Machine Design Flip-Flops determine the number of states in the design and trigger the state transitions based on the inputs. Floyd, T. (2006). Digital fundamentals. Upper Saddle River, NY: Pearson Education. Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

Output Combinational Logic State Machine Design Output Combinational Logic Digital Electronics Lesson 3.4 State Machine Design What should motors, indicators, and other outputs do once the flip-flops have caused the transition to a new state? Floyd, T. (2006). Digital fundamentals. Upper Saddle River, NY: Pearson Education. Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

Examples of State Machines State Machine Design Examples of State Machines Digital Electronics Lesson 3.4 State Machine Design Many everyday devices are controlled by state machines. Traffic Lights Garage Door Numeric Keypads Vending Machines This slide provides three simple state machine applications. Ask students to consider other applications that they think may utilize state machines. Project Lead The Way, Inc. Copyright 2009

State Machine Design Create a State Graph Digital Electronics Lesson 3.4 State Machine Design Create a State Graph Determine the number of States and label Determine the number of State Variables and label (How many flip-flops needed?) Label Outputs and Encode Outputs to States Create State Transition Table from the State Graph Write and Simplify Design Equations from the State Transition Table Design Circuit Project Lead The Way, Inc. Copyright 2009

State Machine Design State Graphs Digital Electronics Lesson 3.4 State Machine Design A state graph shows the sequence of states that the state machine will transition to on each clock transition. This is an example of a state graph with four states (S0-S3). We will study this state graph in detail later. Right now, just focus on the parts of the state graph and how they are related. Project Lead The Way, Inc. Copyright 2009

State Graphs State Machine Design Digital Electronics Lesson 3.4 State Machine Design Each state “bubble” is labeled (S0,S1,S2,S3). These labels are arbitrary. Each transition arc is labeled with the values of the input variables that make the transition occur. Project Lead The Way, Inc. Copyright 2009

Anatomy of a State Graph State Machine Design Anatomy of a State Graph Digital Electronics Lesson 3.4 State Machine Design Transition Arc (For Input X=0) Hold State S0 Qa Qb 0 0 Y=0 & Z=1 X = 0 X = 1 Input Variable (X) State (S0) State “Bubble” Transition Arc (For Input X=1) Next State State Variables (Qa & Qb) A state graph shows the sequence of states that the state machine will transition to on each clock transition. Each state “bubble” is labeled (S0, S1, S2). (These labels are arbitrary.) Each transition arc is labeled with the value(s) of the input variable(s) that make the transition occur. The state variables are the outputs of the flip-flops, so they are typically called Qa, Qb, Qc, Qd, etc. (These labels are arbitrary.) The number of state variables is determined by the number of states according the following function: # States <= 2(# state variables) ; For example: 2 States Requires - 1 State Variable 4 States Requires - 2 State Variable 8 States Requires - 3 State Variable 16 States Requires - 4 State Variable There will be the occasion when a design has unused states. For example, if your design requires 6 states, you will need 3 state variables (6 <= 23). Thus, there will be a total of eight states (23 = 8), and only six will be used. Each state is assigned output values for when the state machine is in that state. Next State “Bubble” Output Variables (Y & Z) Project Lead The Way, Inc. Copyright 2009

State Variables State Machine Design Digital Electronics Lesson 3.4 State Machine Design The state variables are actually the outputs of the memory flip-flops. For that reason they are typically labeled Qa, Qb, etc. S0 Qa Qb 0 0 This four state example would require (2) flip-flip (Qa and Qb) to clock through four states (S0-S3). 1st State (SO) Qa Qb = 0 0 2nd State (S1) Qa Qb = 0 1 3rd State (S2) Qa Qb = 1 0 4th State (S3) Qa Qb = 1 1 Project Lead The Way, Inc. Copyright 2009

State Variables State Machine Design Digital Electronics Lesson 3.4 State Machine Design If a 5th state was needed: Can you guess how many flip-flops and state variables you would need? (It is not possible to have exactly 5 states) How many states would go un-used? 1st State (SO) Qa Qb = 0 0 2nd State (S1) Qa Qb = 0 1 3rd State (S2) Qa Qb = 1 1 4th State (S3) Qa Qb = 1 1 5th Sate (S4) ??????? = ????? 3 flip-flops = 8 possible states 5 states = 3 unused Project Lead The Way, Inc. Copyright 2009

Output Variables State Machine Design Digital Electronics Lesson 3.4 State Machine Design Each state “bubble” is assigned output variables. This example has 4 output variables based on what state it is in. Project Lead The Way, Inc. Copyright 2009

State Graphs to State Transition Tables State Machine Design Digital Electronics Lesson 3.4 State Machine Design Project Lead The Way, Inc. Copyright 2009

State Transition Tables State Machine Design Digital Electronics Lesson 3.4 State Machine Design State Transition Tables are then created from the State Graph. They describe the Present State (inputs) and the Next State (outputs) associated with each state (S0-S3). Project Lead The Way, Inc. Copyright 2009

State Transition Tables State Machine Design Digital Electronics Lesson 3.4 State Machine Design Notice that each state occupies 2 lines on the State Transition Table. That is because (in this example) each transition is triggered by only one of 4 possible inputs at any time. For: Input that causes transition: S0 OS = 0 ;OS = 1 S1 OL = 0 ;OS = 1 S2 CS = 0 ;CS =1 S3 CL = 0 ;CL = 1 Project Lead The Way, Inc. Copyright 2009

State Transition Tables State Machine Design Digital Electronics Lesson 3.4 State Machine Design In a state machine, the Next State is actually the output from the Memory flip-flops (Qa* Qb*) when an input is changed. Qa* = Da for the next state on one flip-flop and Qb* = Db for the next state on the other flip-flop Project Lead The Way, Inc. Copyright 2009

State Transition Tables State Machine Design State Transition Tables Digital Electronics Lesson 3.4 State Machine Design The outputs from the Memory flip-flops are linked to the Input Combinational Logic. That way a transition is made on the next clock signal to the next state. Qa* = Da for the next state on one flip-flop and Qb* = Db for the next state on the other flip-flop Input Combo Logic Memory Flip-Flops Output Combo Logic Output(s) Input(s) Clock Project Lead The Way, Inc. Copyright 2009

Design Equations State Machine Design Digital Electronics Lesson 3.4 State Machine Design From the State Transition Table you can now determine the un-simplified expressions for the: Input Combinational Logic Da=Qa* Db=Qb* Output Combinational Logic This example has (4) outputs MO – Motor Open Signal MC – Motor Close Signal GO – Gate Open Indicator GC – Gate Closed Indicator Project Lead The Way, Inc. Copyright 2009

State Machine Design Example Digital Electronics Lesson 3.4 State Machine Design Design a state machine that will count out the last four digits of a phone number ONLY when an Enable pushbutton is pressed. The output should hold the last number until the Enable button is pressed again. (Example 585-476-4691) Whenever the Enable is a logic (1), the outputs will continuously cycle through the four values 4,6,9,1. Whenever the Enable is a logic (0), the outputs will hold at their current values. For this design any form of combinational logic may be used, but the sequential logic must be limited to D flip-flops. “4”  “6”  “9”  “1” Phone Numbers Enable Clock C3 C2 C1 C0 Project Lead The Way, Inc. Copyright 2009

Step 1: Create State Graph (# of States?) State Machine Design Digital Electronics Lesson 3.4 State Machine Design EN = 0 S0 “4” EN = 1 EN = 1 EN = 0 S3 “1” S1 “6” EN = 0 This design has only one input (EN), so each state bubble should have two transition arcs, one for EN=0 and one for EN=1. This design has four possible output conditions (“4” – “6” – “9” – “1”); thus, the design requires four state bubbles. S2 “9” EN = 1 EN = 1 EN = 0 Project Lead The Way, Inc. Copyright 2009

Step 2: Determine # of State Variables and Assign State Machine Design Digital Electronics Lesson 3.4 State Machine Design EN = 0 S0 Qa Qb 0 0 “4” EN = 1 EN = 1 EN = 0 S3 Qa Qb 1 1 “1” S1 Qa Qb 0 1 “6” EN = 0 With four states, this design requires two state variables (4 = 22). These state variables are labeled Qa and Qb. This labeling is arbitrary but does use the recommended Q notation (these are the flip-flop outputs). Note: Qx and Qy or Q0 and Q1 would also work. The four combinations of the two state variables (00, 01, 10, and 11) are assigned to the four states (S0, S1, S2, S3). S2 Qa Qb 1 0 “9” EN = 1 EN = 1 EN = 0 Project Lead The Way, Inc. Copyright 2009

Step 3: Encode Outputs to States (# Displayed?) State Machine Design Digital Electronics Lesson 3.4 State Machine Design EN = 0 S0 Qa Qb 0 0 “4” EN = 1 EN = 1 0100 C3=0 C2=1 C1=0 C0=0 EN = 0 S3 Qa Qb 1 1 “1” S1 Qa Qb 0 1 “6” EN = 0 In order to display the output in binary, encode from base-ten output count into base-two (binary). Because the largest output count is “9”, four output variables are needed to represent this number in binary (“9” = 1001). These output variables will be labeled C3, C2, C1, and C0. Thus, for example, in state S0 the output “4” encoded into binary would be 0100 (C3=0, C2=1, C1=0, and C0=0). Repeat this process for the three remaining states. 1001 C3=1 C2=0 C1=0 C0=1 0001 C3=0 C2=0 C1=0 C0=1 S2 Qa Qb 1 0 “9” 0110 C3=0 C2=1 C1=1 C0=0 EN = 1 EN = 1 EN = 0 Project Lead The Way, Inc. Copyright 2009

Step 4: Create State Transition Table State Machine Design Digital Electronics Lesson 3.4 State Machine Design State Inputs Outputs Present Input Next F/F Encoded Qa Qb EN Qa* Qb* Da Db C3 C2 C1 C0 S0 1 S1 S2 S3 State transition table for the design example. Each state has 2 lines on the state transition table. One line for EN=0 (hold state) and one line for EN=1 (next state). Note: Even though the EN may have switched from EN=0 to EN=1 in the first 2 lines of the table, the encoded output DOES NOT CHANGE until the clock signal transitions the circuit to the next state. The encoded outputs for both lines of SO are the same. You will designate the NEXT STATE Qa* Qb* on the outputs side of the table, but you DO not change the Encoded Output. (Imagine that the clock signal occurs when you reach the far right of the table and can then move down to the next line with a new encoded output.) See Slide Notes for a detailed description Project Lead The Way, Inc. Copyright 2009

Step 5: Write and Simplify Design Equations State Machine Design Digital Electronics Lesson 3.4 State Machine Design These are the design equations. The simplification (Boolean or K-Mapping) is left as a potential exercise for the students. Project Lead The Way, Inc. Copyright 2009

Step 6: Circuit Design – AOI Simplified State Machine Design Step 6: Circuit Design – AOI Simplified Digital Electronics Lesson 3.4 State Machine Design Can you think of a better way to impliment the logic for Db ? Can you think of a better way to impliment the logic for Db ? Project Lead The Way, Inc. Copyright 2009

Step 7: Circuit Design – Simplified Further? State Machine Design Digital Electronics Lesson 3.4 State Machine Design These are the design equations. The simplification (Boolean or K-Mapping) is left as a potential exercise for the students. Project Lead The Way, Inc. Copyright 2009

Step 8: Circuit Design – Simplified Further XOR State Machine Design Digital Electronics Lesson 3.4 State Machine Design Student should recognize the exsclusive or logic. Project Lead The Way, Inc. Copyright 2009

State Machine Block Diagram / Schematic State Machine Design Digital Electronics Lesson 3.4 State Machine Design Mapping of the final state machine design to the general block diagram for a state machine. The final output from the state machine can then be the input into a BCD seven segment decoder. This will allow the phone number to be viewed on a 7-segment display. Project Lead The Way, Inc. Copyright 2009