Download presentation
Presentation is loading. Please wait.
Published byPhillip Thomas Modified over 9 years ago
1
Finite State Machines CS147 : Presentation by Mabel Thong (9/25/07)
2
A finite state machine (FSM) or finite state automaton (plural: automata) or simply a state machine is a model of behavior composed of a finite number of states, transitions between those states, and actions. A state is a particular set of instructions which will be executed in response to the machine's input.
3
An initial state or record of something stored someplace A set of possible input events A set of new states that may result from the input A set of possible actions or output events that result from a new state
4
A deterministic finite state machine or deterministic finite automaton (DFA) is a finite state machine where for each pair of state and input symbol there is one and only one transition to a next state. 1 1 0 0 Start state The start state is usually shown drawn with an arrow into s1. Accept state is the end state and is usually represented by a double circle, shown on the left. S 1 (which is also the start state) indicates the state at which an even number of 0s has been input and is therefore defined as an accepting state. :
5
A FSM can also be represented using a ‘State Transition Table’. As shown below: the combination of current state (B) and condition (Y) shows the next state (C). Current State ---------------------> Condition State AState BState C Condition X-- Condition Y--State C-- Condition Z-- A state table is essentially a truth table in which some of the inputs are the current state, and the outputs include the next state, along with other outputs.
6
Complete state table must include each possible combination of present states and input values, and no such combination may match more than one row of the table.
7
Also called characteristic tables, single- dimension state tables are much more like truth tables than the two-dimensional versions. Inputs are usually placed on the left, and separated from the outputs, which are on the right. The outputs will represent the next state of the machine.
8
Here's a simple example of a state machine with two states, and two combinatorial inputs: S 1 and S 2 represent the single bits 0 and 1, since a single bit can only have two states. AB Current State Next StateOutput 00S1S1 S2S2 1 00S2S2 S1S1 0 01S1S1 S2S2 0 01S2S2 S2S2 1 10S1S1 S1S1 1 10S2S2 S1S1 1 11S1S1 S1S1 1 11S2S2 S2S2 0
9
State transition tables are typically two- dimensional tables. The vertical dimension indicates current states. The horizontal dimension indicates events. The cells (row/column intersections) in the table contain the next state if an event happens (and possibly the action linked to this state transition).
10
Events State E1E1 E2E2... EnEn S1S1 -A y /S j...- S2S2 -- A x /S i... SmSm A z /S k -...- (S: state, E: event, A: action, -: illegal transition) The vertical dimension indicates current states, the horizontal dimension indicates next states, and the row/column intersections contain the event which will lead to a particular next state.
11
a state diagram for a finite state machine is a directed graph with the following elements: States Q: a finite set of vertices normally represented by circles and labelled with unique designator symbols or words written inside them Edges : represent the "transitions" between two states as caused by the input (identified by their symbols drawn on the "edges"). An 'edge' is usually drawn as an arrow directed from the present-state toward the next-state. Start state Q 0: The start state qo is usually represented by an arrow pointing at it. Accepting state(s) F: If used -- a collection of double circles used to designate accept states or final states.
12
STATE TRANSITION TABLE STATE TRANSITION DIAGRAM Input State 10 S1S1 S1S1 S2S2 S2S2 S2S2 S1S1 The state diagram for Mstate diagram M = (S, Σ, S = {S 1, S 2 }, Σ = {0, 1}, T, s, A) T is defined by the following state transition table state transition table The state S 1 represents that there has been an even number of 0s in the input so far, while S 2 signifies an odd number. A 1 in the input does not change the state of the automaton. When the input ends, the state will show whether the input contained an even number of 0s or not.
13
State diagram has same situation as state table. Their conditions should be mutually exclusive, no input values should meet the condition of more than one arc.
14
From this state diagram, an input of 1 into D will result in a transition to the 1 state an output of 1 on Q. An input of 0 into D will result in a transition to the 0 state an output of 0 on Q.
15
In this state Diagram: an input of 0 into T will cause it to stay in the (same) state an output of the same state on Q. An input of 1 into T will cause it to transition into the other state. The output on Q will be the opposite state that it was before.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.