You are on page 1of 3

Measurement Automation Monitoring, May 2016, no. 05, vol.

62, ISSN 2450-2855  179

45A Wiejska St., 15-351 Bialystok, Poland

Minimization of finite state machines by states merging

Abstract transition. The ISFSM output vector is represented by ternary
vector. For example, Y(am,as)=”01-0”, where 0 denotes zero
The paper presents a method for minimization of finite state machines value, 1 denotes unity value, and dash (“-“) denotes a don’t care
(FSMs) with unspecified values of output variables. The proposed method
value of the corresponding output variable.
is based on merging of two states. In addition to reduction of the FSM
states, the method also allows reducing the number of FSM transitions and Let P(ai) be the set of transitions from a state ai, let A(ai) be the
FSM input variables. This method enables reducing the number of internal set of the next states for transitions from the state ai, and let Z(ai)
states of the initial FSM by 1.22 times on the average, and by 2.75 times be the set of transition conditions from the state ai, ai  A.
on occasion. An average reduction of the number of FSM transitions Definition 1 Two transition conditions are orthogonal if they
makes up 1.32 times, and on occasion may amount to 2.27 times. The have different significant values (“0” or “1”) at least in one
comparison of the method with the program STAMINA shows that the position.
offered method allows decreasing the number of FSM transitions by 1.55 FSM behavior does not change after states ai and aj merging, if
times on the average, and by 3.92 times on occasion.
the transition conditions from the states ai and aj that lead to
Keywords: finite state machine, minimization, state merging, FSM different states are orthogonal. If there are transitions from states
transitions, FSM input variables, digital systems. ai and aj that lead to one and the same state, then the transition
conditions for such transitions should be equal. Moreover, the
1. Introduction output vectors that are generated at these transitions should be not
orthogonal. Note also that under two FSM states merging wait
A finite state machine (FSM) is a model used in the design of states can be formed.
various computation structures like sequential circuits (digital The main strategy of the offered approach consists in finding the
control systems, microprocessor control circuits, digital set D of all the pairs of FSM states satisfying the merging
communication systems, etc.) A minimization of FSMs is an conditions. Then for each pair of states from D the trial merging is
important problem in sequential circuit synthesis. carried out. Finally a pair (ai,aj) for merging is selected in such a
For various reasons, the state transitions or outputs are not way that it leaves the maximal possibilities for other pairs of FSM
completely specified. An incompletely specified FSM (ISFSM) is states merging. The given process repeats as long as there exists
the one where either the next state or the output is not specified for a possibility of FSM states merging for at least one pair.
at least one transition.
A general theory for incompletely specified machines was first 3. Method for FSM minimization
considered in [1]. The standard approach to solution of the
problem of ISFSM state reduction is based on generation of sets of Bearing in mind the above presented observations, we present
compatible states (or compatibles) and finding a minimal closed the following general algorithm of FSM minimization.
cover. The state minimization in ISFSMs is an NP-complete
problem [2] and it has been studied by a number of authors [3-9]. Algorithm 1 (general algorithm of FSM minimization)
In [3], prime classes are proposed, and the state reduction is
solved by using an integer linear programming approach. The 1. Perform algorithm [10] to choose a state pair (ai,aj) for merging
exact and heuristic algorithms of FSM minimization meant for (ai, aj  A). If such a pair is found, go to Step 2. Otherwise, go
practical implementation are proposed in [4]. In [5], a program to Step 3.
called STAMINA that runs in exact and heuristic modes and uses 2. Perform algorithm [10] to merge the state pair (ai,aj). Go to
explicit enumeration for the solution of state minimization Step 1.
problem is presented. An exact state minimization technique by 3. Perform algorithm 2 to minimize the number of FSM
using implicit enumeration of compatibles is considered in [6]. In transitions.
[7], an exact state minimization algorithm based on mapping of 4. Perform algorithm 3 to minimize the number of FSM input
ISFSMs to FSMs tree is presented. A heuristic algorithm called variables.
void that follows a strategy of handling the closure condition first 5. End.
and satisfying the cover condition afterwards is proposed in [8]. In After merging FSM states, one can arrive at a situation
[9], a branch-and-bound search technique for the identification of admitting reduction in the number of FSM transitions. Suppose,
sets of compatible states is described. for instance, that one transition from a state a1 under condition x1
In this paper, we propose a method for minimization of leads to a state a2 and the second transition from a1 under
incompletely specified FSMs with unspecified values of output condition x1 leads to another state a3 and on each of these
variables. Our method is based on merging two states. In addition transitions not orthogonal output vectors are formed. Suppose that
to reduction of internal states, this method minimizes the number the states a2 and a3 can be merged. After merging a2 and a3, a new
of the FSM transitions and the FSM input variables. state a2_3 is formed. Now two transitions lead from a1 to a2_3, one
under condition x1 and the second under condition x1 . The latter
2. Preliminaries means that the transition from a1 to a2_3 is unconditional and two
transitions can be replaced by one unconditional transition.
Let us denote by L the number of FSM input variables of a set
X = {x1,…,xL}, by N the number of FSM output variables of a set Algorithm 2 (minimization of the number of FSM transitions)
Y = {y1,…,yN}, by M the number of FSM internal states of a set
A = {a1,…,aM}. 1. Consider the group of transitions P(ai) from some state ai
An FSM behavior is described by the state transition table (ai  A).
(STT). The STT is a table with four columns: am, as, X(am,as), and 2. If there is more than one transition into one and the same state
Y(am,as), where am is the present state, as is the next state, X(am,as)
aj (aj  A(ai)), then one determines the group of transitions
is the input vector or the transition condition, and Y(am,as) is the
P(ai,aj) (P(ai,aj)  P(ai)) such that at these transitions not
output vector. Each row of the STT corresponds to one FSM
orthogonal output vectors are generated and |P(ai,aj)| > 1, where
180  Measurement Automation Monitoring, May 2016, no. 05, vol. 62, ISSN 2450-2855

|A| is the capacity of the set A. If one can find several groups of Tab. 1. The STT of the initial FSM from the example
such transitions, they are successively considered.
am X(am , as) as Y(am, as)
3. For the recurrent group of transitions P(ai,aj), one determines
the set Z(ai,aj) of the transition conditions from the state ai to aj. a1 1-- a2 1-
4. On the basis of the set Z(ai,aj) one forms the Boolean function a1 0-- a3 -0
B(ai,aj) that expresses the transition condition from ai to aj. To a2 -1- a3 -0
do it, all the elements of Z(ai,aj) are combined via a logic OR
a2 -00 a4 01
operation: B(ai,aj) = z1 + z2 + … + zK, where the sign “+”
a2 -01 a5 10
denotes the logical OR operator (zk  Z(ai,aj), K = |Z(ai, aj)|).
5. The shortest (containing the smallest number of terms) a3 -1- a2 1-
disjunctive normal form (DNF) of the function B(ai,aj) is a3 -00 a4 01
determined by means of one of the known methods, e.g. [11]. a3 -01 a5 10
6. For the shortest DNF of the function B(ai,aj), the set Z*(ai,aj) of
a4 --- a5 11
its terms is found.
7. If |Z*(ai,aj)| < |Z(ai,aj)|, then the transitions corresponding to the a5 --- a1 00
conditions of the set Z(ai,aj) are excluded from the group of
transitions P(ai,aj) and replaced by the transitions corresponding Performing the algorithm [10] of finding the set D of the state
to the conditions of the set Z*(ai,aj). The output vectors that are pairs which meet the conditions for merging for the states a2 and
formed at new transitions, are determined by combining the a3, we have Z(a2) = {x2, x 2 x3 , x2 x3 } and Z(a3) = {x2, x 2 x3 ,
output vectors at the transitions of the set P(ai,aj).
x2 x3 }. For the transition conditions X(a2,a3) = x2 and X(a3,a2) =
8. Steps 3-7 of this algorithm are performed for each group of the
transitions found at Step 2. x2, we have that the transition conditions are equal and the formed
9. Steps 1-8 of this algorithm are performed for all states of the set A. output vectors are not orthogonal (Y(a2,a3) = “-0” and Y(a3,a2) =
10. End. “1-”). The merging conditions are satisfied for states a2 and a3 in
At minimization of the number of FSM transitions one can the case to generate a wait state.
arrive at a situation when certain input variables have no impact Verification of the remaining transition conditions for the sets
on the transition conditions. Suppose, for instance, that one Z (a2) and Z (a3) also admits merging the states a2 and a3. Thus,
transition from a state a1 under condition x1 leads to a state a2 and the pair (a2, a3) can be merged. Table 2 represents the STT after
another transition from a1 under condition x1 leads to a state a3 merging a2 and a3. There are no more pairs of the states in the set
of FSM internal states such that the merging conditions are met.
and the variable x1 does not meet anywhere else in transition Algorithm 2 allows us to minimize the number of transitions from
conditions of the FSM. Suppose that after the states a2 and a3 have the state a1 (by one), and in addition the transition from the state a1
been merged, the transition from the state a1 to the state a2_3 to the state a2_3 becomes unconditional. At transition from the
becomes unconditional, i.e. it does not depend on the values of state a1 the output vector “10” is formed, it is the result of
input variables. The latter means that the variable x1 has no impact combining the output vectors “1-“ and “-0”.
on any FSM transition and therefore it is redundant.
Tab. 2. The STT of the FSM after merging of the states a2 and a3
Algorithm 3 (minimization of the number of FSM input
variables) am X(am , as) as Y(am, as)
a1 1-- a2_3 1-
1. Consider certain FSM input variable xi (xi  X). a1 0-- a2_3 -0
2. Check whether the variable xi is in the column X(am,as) of the
a2_3 -1- a2_3 10
STT (in direct or inversed form).
3. If the column X(am,as) of the STT does not contain xi, than the a2_3 -00 a4 01
input variable xi is excluded from set X of FSM input variables. a2_3 -01 a5 10
Put X := X\{xi}. a4 --- a5 11
4. Steps 1-3 of this algorithm are performed for all FSM input
a5 --- a1 00
variables of the set X.
5. End.
Algorithm 3 excludes the variable x1 from the set X. Fig. 2 and
Example Table 3 show the FSM state diagram and FSM STT after
minimization, respectively.
Suppose we need to minimize the FSM given by the state
diagram in Fig. 1, where the transition conditions and the formed
output vectors are assigned to the graph arcs (via a slash). a4
---/10 ---/11
a1 a2_3 -01/1 0
a2 -00/01
1- -/
1 - 1/ 1

-1 -

0- - 01 ---/00

/ -1 /
-1 -/1

-01/10 Fig. 2. The state diagram of the FSM after minimization
a3 a5
The FSM parameters are now L = 2, N = 2, M = 4, R = 2, and
Q = 6. Thus, by means of the proposed method of FSM
Fig. 1. State diagram of the initial FSM from an example
minimization, we have not only reduced the number of internal
states but also diminished the number of transitions from 10 to 6,
Table 1 represents the FSM STT. The initial FSM has and the number of input variables has been decreased by one.
parameters L = 3, N = 2, M = 5, R = 3, and Q = 10, where Q is the
number of FSM transitions.
Measurement Automation Monitoring, May 2016, no. 05, vol. 62, ISSN 2450-2855  181

Tab. 3. The STT of the FSM after minimization

5. Conclusions
am X(am , as) as Y(am, as)
In the offered method of FSM minimization, only two states
a1 --- a2_3 10
merging is considered. The given algorithm can be modified so as
a2_3 -1- a2_3 10 to merge a group of states containing more than two states.
a2_3 -00 a4 01 Besides, the further perfection of the presented algorithm can be
a2_3 -01 a5 10 implemented by consideration of incompletely specified values for
the transition functions as additional conditions for merging
a4 --- a5 11
possibility of FSM internal states.
a5 --- a1 00
The present study was supported by the grant S/WI/1/2013 from the Bialystok
University of Technology and funded from the resources for research by the Ministry
4. Experimental research results of Science and Higher Education.

The method for minimization of incompletely specified finite state

machines proposed in the paper was implemented in a program 6. References
called ZUBR [11]. To estimate the efficiency of the offered method,
we used MCNC FSM benchmarks. The proposed method was also [1] Paull M.C., Unger S.H.: Minimizing the number of states in
compared with the program STAMINA [5]. The experimental incompletely specified sequential switching functions. IRE Trans. on
results are presented in Table 4, where Name is the name of the Electronic Computers, 1959, Vol. EC-8, No. 3, pp. 356-367.
benchmark example; M0 and P0 are the number of internal states and [2] Pfleeger C.P.: State reduction in incompletely specified finite-state
transitions of the initial FSM; M1 and P1 are the number of internal machines. IEEE Trans. on Computers, 1973, Vol. C-22, No. 12, pp.
states and transitions of FSM after applying the offered method; P2 1099-1102.
are the number of FSM transitions after applying the program [3] Grasselli A., Luccio F.: A method for minimizing the number of
STAMINA; M0/M1, P0/P1, and P2/P1 are ratios of the corresponding internal states in incompletely specified sequential networks. IEEE
parameters; and mid is the arithmetic mean value. Trans. on Electronic Computers, 1965, Vol. EC-14, No. 3, pp. 350-
Tab. 4. The results of experimental research of the offered method [4] De Micheli G.: Synthesis and optimization of digital circuits. New
York: McGraw Hill, 1994.
Name M0 P0 M1 P1 P2 M 0/ P0/P1 P2/P1
[5] Rho J.K., Hachtel G.D., Somenzi F., Jacoby R.M.: Exact and heuristic
algorithms for the minimization of incompletely specified state
bbara 10 60 7 35 42 1.43 1.71 1.20 machines. IEEE Trans. on Computer-Aided Design of Integrated
bbsse 16 56 13 53 208 1.23 1.06 3.92 Circuits and Systems, 1994, Vol.13, No. 2, pp. 167-177.
bbtas 6 24 6 19 24 1.00 1.26 1.26 [6] Kam T., Villa T., Brayton R., Sangiovanni-Vincentelli A.: Synthesis
of FSMs: functional optimization. Norwell, MA: Kluwer Academic
dk15 4 32 4 30 32 1.00 1.07 1.07
Publishers, 1997.
ex1 18 233 18 120 233 1.00 1.94 1.94 [7] Pena J.M., Oliveira A.L.: A new algorithm for exact reduction of
keyb 19 170 19 167 170 1.00 1.02 1.02 incompletely specified finite state machines. IEEE Trans. on
lion9 9 25 4 11 16 2.25 2.27 1.45 Computer-Aided Design, 1999, Vol. 18, No. 11, pp. 1619-1632.
[8] Ahmad I., Das A.S.: A heuristic algorithm for minimization of
s1488 48 251 48 236 251 1.00 1.06 1.06
incompletely specified finite state machines. Computers and Electrical
s1494 48 250 48 236 250 1.00 1.06 1.06
Engineering, 2001, Vol. 27, pp. 159-172.
s208 18 153 18 122 153 1.00 1.25 1.25 [9] Gören S., Ferguson F.: On state reduction of incompletely specified
s27 6 34 5 25 30 1.20 1.36 1.20 finite state machines. Computers and Electrical Engineering, 2007,
s386 13 64 13 56 64 1.00 1.14 1.14
Vol. 33, No. 1, pp. 58-69.
[10] Salauyou V.: FSM state merging for low power. Measurement,
s420 18 137 18 122 137 1.00 1.12 1.12
Automation, Monitoring, 2015, Vol. 61, nr 7, s. 337-339.
s510 47 77 47 75 77 1.00 1.03 1.03 [11] Salauyou V., Klimowicz A., Grzes T., Bulatowa I., Dimitrowa-
sand 32 184 32 125 184 1.00 1.47 1.47 Grekow T.: Synthesis methods of finite state machines implemented
sse 16 56 13 53 208 1.23 1.06 3.92 in package ZUBR. Proc. of the Sixth International Conference
Computer-Aided Design of Discrete Devices (CAD DD’7), Minsk,
styr 30 166 30 156 166 1.00 1.06 1.06
Belarus, November 14-15, 2007, pp. 53-56.
tma 20 44 18 44 89 1.11 1.00 2.02 _____________________________________________________
train11 11 25 4 12 15 2.75 2.08 1.25 Received: 20.02.2016 Paper reviewed Accepted: 04.04.2016
mid 1.22 1.2 1.55

The analysis of Table 4 shows that the application of the Valery SALAUYOU, DSc, PhD, eng.
proposed method allows reducing the number of internal states of
the initial FSM on the average by 1.22 times, and on occasion Valery Salauyou received the PhD and DSc degrees in
computer science from the Belarusian State University
(example train11) by 2.75 times. Similarly, the average reduction Informatics and Radioelectronics, in 1986 and 2003,
in the number of the FSM transitions makes 1.32 times, and on respectively. From 1992 he is Associate Professor at the
occasion (example lion9) 2.27 times. Besides, the application of Bialystok University of Technology. His research
the algorithm 6 led to reduction in the number of input variables interests are in the area of VLSI design, with emphasis
on logic synthesis, Embedded Systems, architectures of
from 11 to 8 in example s208 and from 19 to 8 in example s420. programmable logic (CPLD/FPGA/SoC), and
The comparison of the proposed method with the program optimization of FSMs.
STAMINA shows that after applying the proposed method the
number of FSM states is the same as after applying the program e-mail:
STAMINA. However, the offered method, unlike the program
STAMINA, allows reducing significantly the number of FSM
transitions, on the average by 1.55 times and on occasion
(examples bbsse and sse) by 3.92 times.