Finite state machine

Source: Internet
Author: User
Tags fsm

Source: Wikipedia

Finite state machine
Figure 1 Finite state machine

Finite state machine ( English:finite-state machine, abbreviation:FSM) also known as finite state automata , abbreviated state machines , is a mathematical model that represents a finite state and the behavior of transitions and actions between these States.

Concepts and terminology

State stores information about the past, which means that it reflects input changes from the beginning of the system to the present moment. The transfer indicates a state change and describes it with conditions that must be met to make the transfer happen. An action is a description of the activity to be performed at a given moment. There are several types of actions:

Enter action ( entry action): When entering a State
Exit action: When exiting a state
Input action: dependent on the current state and the input conditions
Transfer action: In the case of a specific transfer

FSM (finite state machine) can be represented by a state diagram (or state transition diagram) as shown in Figure 1 above. You can also use several types of state transfer tables. The most common representations are shown below: The combination of the current state (B) and the condition (Y) indicates the next state (C). The complete action information can be added using only footnotes. The FSM definition, which includes complete action information, can use the state table.

state
State transfer Table
Current status →
Condition ↓
State ab status C
Condition X ... ... ...
Condition y ... Status C ...
Condition Z ... ... ...

In addition to modeling the reaction systems described here, finite state automata are important in many different fields, including electronic engineering, linguistics, computer science, philosophy, biology, mathematics, and logic. Finite state machine is a kind of automata which is researched in automata theory and computational theory. In computer science, finite state machines are widely used for modeling application behavior, hardware circuit system design, software engineering, compilers, network protocols, and computational and language research.

Classification

There are two different groups: the receiver/recognizer and the converter.

Receiver and Recognizer [edit ] Figure 2 Receiver FSM: parse the word "nice"

the receiver and the recognizer (also called the sequence detector ) produce a two-yuan output that says either "yes" or "no" to answer whether the input is accepted by the machine. The state of all FSM is known as either accept or not accept. When all inputs have been processed, if the current state is accepted, the input is accepted, otherwise it is rejected. As a rule, the input is a symbol (character), and the action is not used. The example in Figure 2 shows a finite state automaton that accepts the word "nice", where the only accepted state is state 7.

The machine can also be described as defining a language that contains all the words that the machine accepts rather than rejects; we call this language accepted by this machine. By definition, the FSM accepts a regular language-that is, if a language is accepted by an FSM, then it is regular (cf. Kleene's theorem).

Start state

The start state is usually indicated with "arrows without starting point" (Sipser (2006) p.34)

Accept Status
Figure 3: A state machine that detects a binary number with an odd or even number of 0

The acceptance state is the state after the machine has successfully carried out its program, which is usually represented as a double circle.

The acceptance status appears below the left side of the state diagram that determines the finite state automaton example, which determines whether the binary input contains even several 0: S1 (which is also the start state) indicating that an even number of 0 states have been entered so that it is defined as an accept state.

Converters

The converter uses actions to generate output based on the given input and/or state. They are used to control the application. are often divided into two types:

Moore Machine
Main article: Moore type finite state machine

Only the FSM that enters the action is used, which means that the output depends only on the state. The advantage of the Moore model is the simplicity of the behavior. The example in Figure 1 shows a Moore FSM for an elevator door. This state machine recognizes two commands: "Command_open" and "command_close" trigger state changes. In the state "Opening" in the Entry action (E:) Open the motor door, in the state "Closing" in the entry action in the opposite direction to open the motor door. The status "opened" and "Closed" do not perform any action. They signal to the outside world (such as other State machines) The situation: "The door is open" or "the door is closed".

mealy Machine
Figure 4 Converter Fsm:mealy Model example main article: Miriam Type finite state machine

Only the FSM using the input action, that is, the output depends on the input and state. The use of Mealy FSM often results in a simple number of states. The example shown in Figure 4 shows the mealy FSM that implements the same behavior as the above Moore machine (the behavior relies on an implementation-dependent FSM execution model, such as working with virtual FSM but not for event-driven FSM). There are two input actions (I:): "Open the motor door if Command_close release" and "Reverse open the motor open if Command_open released."

Mixed models are often used in practice.

Further distinguish between deterministic (DFA) and non-deterministic (NDFA, Gnfa) automata. In a deterministic automaton, each state has only one exact transfer for each possible input. In a non-deterministic automaton, a given state can have no or more than one transfer for a given possible input. This distinction is more useful in practice than in theory, because there are algorithms that convert any NDFA into an equivalent DFA, although this conversion generally increases the complexity of the automata.

An FSM with only one state is called a combo FSM and uses only input actions. This concept is useful in situations where multiple FSM work together, and it may be convenient to consider a purely composite part as a form of FSM to fit the design tool.

FSM Logic
Figure 5 FSM Logic

The next state and output of the FSM is determined by the input and the current state. The FSM logic is shown in Figure 5.

Mathematical Models

There are multiple definitions depending on the type. the receiver finite state machine is a five-tuple, here:

    • is to enter the alphabet (a non-empty finite set of symbols).
    • is a non-empty finite set of states.
    • Is the initial state, which is the element. In a non-deterministic finite state automaton, it is the set of initial states.
    • is the state transfer function:.
    • Is the set of final states, (possibly empty) subset.

Converter Finite state automata is a six-tuple, here's:

    • is to enter the alphabet (a non-empty finite set of symbols).
    • is the output alphabet (the non-empty finite set of symbols).
    • is a non-empty finite set of states.
    • Is the initial state, which is the element. In a non-deterministic finite state automaton, it is the set of initial states.
    • is the state transfer function:.
    • is the output function.

If the output function is a function of the state and the input alphabet (), the definition corresponds to the mealy model , which can be modeled as a mealy machine. If the output function depends only on the state (), then the definition corresponds to the Moore model , which can be modeled as a Moore machine. A finite state machine with no output function is called a semiautomatic machine or a transfer system.

Optimized

Optimizing an FSM means finding a machine with a very small number of States to perform the same function. One possibility is to use the implication table or the Moore minimalist process. Another possibility is the bottom-up algorithm for the non-ring FSA.

Implement
Hardware applications
Figure 6 Circuit diagram of the 4-bit TTL counter

In digital circuits, FSM can be built with programmable logic devices, programmable logic controllers, logic gates, and triggers or relays. More specifically, hardware implementations require registers to store state variables, to determine a piece of combinational logic for state transitions, and to determine another piece of combinational logic for the FSM output. A class of classic hardware implementations is the Richard Controller.

software applications

The following concepts are often used to build software applications with finite state machines:

    • Event-driven FSM
    • Virtual FSM (VFSM)
    • Automatic programming based on machine
Reference Books
  • Wagner, F., "Modeling software with finite state machines:a practical Approach", Auerbach Publications, 2006, ISBN 0-8493 -8086-3.
  • Samek, M., practical Statecharts in C + +, CMP Books, 2002, ISBN 1-57820-110-1.
  • Samek, M., practical UML statecharts in C + +, 2nd Edition, Newnes, $, ISBN 0-7506-8706-1.
  • Cassandras, C., LaFortune, S., "Introduction to discrete Event Systems". Kluwer, 1999, ISBN 0-7923-8609-4.
  • Timothy Kam, Synthesis of finite state machines:functional optimization. Kluwer Academic Publishers, Boston 1997, ISBN 0-7923-9842-4
  • Tiziano Villa, Synthesis of finite state machines:logic optimization. Kluwer Academic Publishers, Boston 1997, ISBN 0-7923-9892-0
  • Carroll, J., Long, D., theory of finite automatawith a Introduction to formal Languages. Prentice Hall, Englewood Cliffs, 1989.
  • Kohavi, Z., switching and finite automata theory. Mcgraw-hill, 1978.
  • Gill, A., Introduction to the theory of finite-state machines. Mcgraw-hill, 1962.
  • Ginsburg, S., an Introduction-mathematical machine theory. Addison-wesley, 1962.
External Links
    • Description from the free on-line Dictionary of Computing
    • NIST Dictionary of algorithms and Data structures entry
    • Hierarchical state machines
    • Round-trip Engineering State machines
    • Using state machines in practical applications
    • Flash based demonstration of finite state machines being used in regular expressions
    • "Moore or Mealy model?" Details on the differences between using the Moore and Mealy models, including examples of execution
See
    • Self-Motive
    • Deterministic finite state automata
    • Non-deterministic finite state automata
    • Mealy Machine
    • Moore Machine
    • Algorithm state machine

Finite state machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.