A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Problem Solving/Finite state machines

From Wikibooks, open books for an open world
Jump to: navigation, search
Fig. 1 Example of a simple finite state machine

A finite state machine consists of states, inputs and outputs. The number of states is fixed; when an input is executed, the state is changed and an output is possibly produced. Finite state machines are widely used when designing computer programs, but also have their uses in engineering, biology, linguistics and other sciences thanks to their ability to recognise sequences.

A finite state machine expressed visually is a State transition diagram. It is used to show all the states, inputs and outputs. Each state is represented with a circle, and each transition with an arrow. Transitions are labelled with an input that causes a transition and possibly an output that results from it.

A finite state machine can be with or without outputs. A Mealy Machine is an FSM with outputs. A Finite State Automaton is an FSM with no outputs.

DFAexample.svg DFA Binary Digits Semibalanced.svg FA regexp accept singlesymbol.svg

CPT-FSM-01.svg

[edit] Mealy Machines

CPT-FSM-Mealy-01.svg

[edit] State transition tables

A state transition table follows every state and input. 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. Here's a simple example of a state machine with two states, and two combinatorial inputs:

A B Current State Next State Output
0 0 S1 S2 1
0 0 S2 S1 0
0 1 S1 S2 0
0 1 S2 S2 1
1 0 S1 S1 1
1 0 S2 S1 1
1 1 S1 S1 1
1 1 S2 S2 0
Personal tools
Namespaces

Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export