An entire collection of useful table-driven algorithms makes use of a theoretical concept known as a finite state machine (FSM). Example Algorithm Input.

Slides:



Advertisements
Similar presentations
ENGIN112 L23: Finite State Machine Design Procedure October 27, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 23 Finite State Machine.
Advertisements

Modeling Computation Chapter 13.
Lecture 21 State minimization via implication charts.
4b Lexical analysis Finite Automata
Finite State Machines (FSMs)
1 Steps towards State assignment Slides of Mark Schulz used.
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
Circuits require memory to store intermediate data
Lecture 22: Sequential Circuits Today’s topic –Clocks and sequential circuits –Finite state machines 1.
Chapter 3 Digital Logic Structures
FSM examples.
Finite state machines.
ECE 331 – Digital System Design
Fall 2007CS 2251 Miscellaneous Topics Cloning Patterns Recursion and Grammars.
Give qualifications of instructors: DAP
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design Finite State.
CSCI 3301 Transparency No. 9-1 Chapter #9: Finite State Machine Optimization Contemporary Logic Design.
Lecture 10 Topics: Sequential circuits Basic concepts Clocks
Digital Logic Lecture 08 By Amr Al-Awamry. Combinational Logic 1 A combinational circuit consists of an interconnection of logic gates. Combinational.
IKI c-Synthesis of Sequential Logic Bobby Nazief Semester-I The materials on these slides are adopted from: Prof. Daniel Gajski’s transparency.
CPSC 388 – Compiler Design and Construction Scanners – Finite State Automata.
Elevator Controller We’re hired to design a digital elevator controller for a four-floor building st try: Design a counter that counts up.
Finite-State Machines with Output
Finite State Machines Chapter 5. Languages and Machines.
CMPS 3223 Theory of Computation
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
Moore machine and Mealy machine (P.274)
Lecture 18 More Moore/Mealy machines.
CPEN Digital System Design Chapter 5 - Sequential Circuits Sequential Circuit Design C. Gerousis © Logic and Computer Design Fundamentals, 4 rd Ed.,
Example Consider the following class specification for a class that stores a bunch of characters. /* class invariant *this bunch contains one or more char.
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
CS 321 Programming Languages and Compilers Lectures 16 & 17 Introduction to Formal Languages Regular Languages Lexical Analysis.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter
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.
Computer Science 101 Theory of Computing. Computer Science is... The study of algorithms, with respect to –their formal properties –their linguistic realizations.
 initially Treat data as N sorted collections that are each one datum long.  merge Merge each consecutive pair of collections to form sorted collections.
Finite State Machines CS147 : Presentation by Mabel Thong (9/25/07)
SM2220 – Class 06 Finite Automata. SM2220 – Class 06 Topic in theoretical computing. A subset of computation machines. Closely related to formal language.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
Digital System Design using VHDL

Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Computing Machinery Chapter 4: Finite State Machines.
Sahar Mosleh California State University San MarcosPage 1 Finite State Machine.
Lecture 22: Finite State Machines with Output. Moore Machine - A Moore machine is a 6-tuple (Q, , , , q 0,  ) where, (1) Q is a finite set of states.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
Nondeterministic Finite State Machines Chapter 5.
Finite State Machines Chapter 5. Languages and Machines.
 initially Treat data as N sorted collections that are each one datum long.  merge Merge each consecutive pair of collections to form sorted collections.
Lecture 2 Compiler Design Lexical Analysis By lecturer Noor Dhia
Computer Science 516 A Little On Finite State Machines.
State Diagrams Tuesday, 12 September State diagram Graphical representation of a state table. –Provides the same information as a state table. –A.
Mealy Machines Finite State Machines with Outputs given on the transitions.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Finite Automata.
1.3 Finite State Machines.
Finite State Machines Dr K R Bond 2009
Theory of Computation Turing Machines.
Finite State Machines.
Deterministic Finite Automaton (DFA)
Counters.
Lecture 20 State minimization via row matching.
EGR 2131 Unit 12 Synchronous Sequential Circuits
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

An entire collection of useful table-driven algorithms makes use of a theoretical concept known as a finite state machine (FSM). Example Algorithm Input a stream of “bits” (‘0’ or ‘1’ characters) from a text stream. Output to the standard output stream, according to the following rules: 1) Write an ‘X’ for every odd-numbered bit (i.e., 1st, 3rd, 5th, etc.) 2) Write a ‘Z’ for every even-numbered bit with value of ‘0’. 3) Write an ‘N’ for every even-numbered bit with value of ‘1’. Sample input stream  resulting output  0 X Z Question How could we draw a picture of this algorithm? The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

A graphical model for the preceding algorithm is shown below. After Even After Odd 1 / X 0 / X 0 / Z 1 / N Notation  Each circle is a separate __________.  Each arc represents a potential transition from one state to another. The label a / b denotes an input symbol of a and output of b.  One state has an incoming arc without a state on the opposite end. This state is called the _________________________. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Sample input stream  resulting output  After Even After Odd 1 / X 0 / X 0 / Z 1 / N The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

An (Finite State Machine) FSM is a 6-tuple: 1) A set of states 2) A start state 3) A set of input symbols 4) A set of output symbols 5) A next state function ( State  Input  State) 6) An output function ( State  Input  Output) NextState (AfterEven, 0)  AfterOdd NextState (AfterEven, 1)  AfterOdd NextState (AfterOdd, 0)  AfterEven NextState (AfterOdd, 1)  AfterEven Output (AfterEven, 0)  X Output (AfterEven, 1)  X Output (AfterOdd, 0)  Z Output (AfterOdd, 1)  N After Even After Odd 1 / X 0 / X 0 / Z 1 / N Name the parts below Actions other than output are also permitted in some FSMs. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

How many states? 0 / 0 1 / 1 0 / 2 1 / 3 0 / 0 0 / 2 1 / 1 Which is the start state? What is the input alphabet? What is the output alphabet? Select meaningful state labels. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

A 4-Step Strategy 1) Select the states. 2) Identify the start state. 3) Complete the Next State function. 4) Complete the Output function. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

 Input consists of individual bits (0 or 1).  Input is partitioned into packets consisting of four consecutive bits.  A dash (-) is output for each of the first three bits in a packet.  An ‘E’ is output for each packet that has even parity.  A ‘D’ is output for each packet that has odd parity. Sample input stream  resulting output  D---E D (Note that even parity occurs when the count of 1-valued bits in the packet is even, and odd parity occurs when the count is odd.) The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

A 4-Step Strategy 1) Select the states. 2) Identify the start state. 3) Complete the Next State function. 4) Complete the Output function. What is a state? A state is a kind of memory.  A state “remembers” the most recent input(s).  A state “remembers” a count. What does the 4-bit parity checker need to remember? Hints for Selecting States  Partition the algorithm into all possible situations (states).  Try tracing FSM execution until states appear to repeat. What are the states of a 4-bit parity checker? The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

What is the start state of the 4-bit parity checker? A 4-Step Strategy 1) Select the states. 2) Identify the start state. 3) Complete the Next State function. 4) Complete the Output function. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Think of the NextState function as a table. 01 input symbol previous state A 4-Step Strategy 1) Select the states. 2) Identify the start state. 3) Complete the Next State function. 4) Complete the Output function. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Think of the Output function as a table. 01 input symbol previous state NoBits Even1 Odd1 Even2 Odd2 Even3 Odd3 A 4-Step Strategy 1) Select the states. 2) Identify the start state. 3) Complete the Next State function. 4) Complete the Output function. The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.

Using table-driven code for the NextState and Output functions, makes it possible to create a general-purpose FSM simulator. currentState = startState(); input = readInputSymbol(); while (! endOfInput() ) { performOutput( outputTable[currentState][input] ); currentState = nextStateTable[currentState][input]; input = readInputSymbol(); } The Object of Data Abstraction and Structure, David D. Riley © Addison Wesley pub.