A state machine, which is more precisely defined as a finite state machine,
consists of a set of states and a transition function that maps to the next state.
Finite state machines have many variations. The two most common finite
state machines are the Mealy machine and the Moore machine. A Mealy
machine performs an action for each transition. A Moore machine performs
a specific action for each state in the state transition diagram. The state
machine design pattern template in LabVIEW implements any algorithm
Use state machines in applications where distinguishable states exist. Each
state can lead to one or multiple states or end the process flow. A state
machine relies on user input or in-state calculation to determine which state
to go to next. Many applications require an initialization state, followed by
a default state, where many different actions can be performed. The actions
performed can depend on previous and current inputs and states. A
shutdown state is commonly used to perform clean up actions.
described by a Moore machine.
An FSM is a digital sequential circuit that can follow a number of predefined states under the
control of one or more inputs.Note that some FSMs have a clock input and are called synchronous FSMs, i.e. those that do not belong to a type of FSM called asynchronous FSMs.A synchronous FSM can move between states only if a clock pulse occurs.Block diagram of an FSM based application is shown in the Figure 1 below :
Figure 1 : Block diagram of an FSM-based application.
Each state of the FSM needs to be identifiable. This is achieved by using a number of
internal (to the FSM block) flip-flops. An FSM with four states would require two flip-flops,
since two flip-flops can store 22 ¼ 4 state numbers.Each state has a unique state number, and states are usually assigned numbers as s0 (state 0), s1, s2, and s3 (for the four-state example). The rule here is
Number of states ¼ 2Number of flip flops;
for which
Number of flip flops ¼ log10
ðNumber of statesÞ
log10
ð2Þ :
So anFSMwith 13 states would require 24 flip-flops (i.e. 16 states, of which 13 are used in the
FSM); that is:
Number of flip flops ¼ log10
ð13Þ
log10
ð2Þ
¼ 3:7:
This must be rounded up to the nearest integer, i.e. 4.
As well as containing flip-flops to define the individual states of theFSMuniquely, there is
also combinational logic that defines the outside-world outputs. In addition, the outsideworld
inputs connect to combinational logic to supply the flip-flops inputs.