4.2. Finite State Machines (FSMS)
4.2. Finite State Machines (FSMS)
www.pmt.education
Specification:
www.pmt.education
Finite State Machines
A finite state machine (or FSM for short) is a model for a machine that is always in a fixed
state. Each finite state machine has a set number of states and can only ever be in one
state at once.
Data can be input to a finite state machine and if the input data is valid, the finite state
machine will terminate in what’s known as an accepting state.
A finite state machine’s state can change and does so according to transition rules, rules
that describe what a finite state machine should do given certain criteria.
For example, the state transition diagram above has four states: S0, S1, S2 and S3. S3 is an
accepting state.
The transition functions are each represented by an arrow from one state to another.
The finite state machine represented by the state transition diagram will only accept input
data that starts with 11
. For example: 11
, 110
, 11101and 11001100.
www.pmt.education
State Transition Tables
The transition function between S0 and S1 in the previous diagram could be described in
English as “If the finite state machine is in state S0 and the input is 1, move to state S1. ”
The transition functions in a finite state machine can be notated more formally using a
state transition table, with columns for current state, input and next state, like the one
below.
S0 1 S1
S0 0 S2
S1 1 S3
S1 0 S2
The finite state machine shown by the state transition diagram below represents a parking
machine which requires 50p to be payed. The machine is only designed to take coins
worth 10p or more.
If the customer first pays 10p, the machine moves into the 10p state, from which the
customer can input another 10p or 20p. The 50p state is the accepting state.
www.pmt.education