sequential system synthesis -- finite state machine
DESCRIPTION
Sequential System Synthesis -- Finite State Machine. Outline: Finite State Machine. Definitions FSM Representations State Transition Graph (STG) Flow Table Cube Table State Minimization Completely Specified FSM Incompletely Specified Machine (ISM) State Encoding. - PowerPoint PPT PresentationTRANSCRIPT
Sequential System SynthesisSequential System Synthesis-- Finite State Machine-- Finite State Machine
ENEE 644 2
Outline: Outline: Finite State MachineFinite State Machine
DefinitionsDefinitions FSM RepresentationsFSM Representations
State Transition Graph (STG)State Transition Graph (STG) Flow TableFlow Table Cube TableCube Table
State MinimizationState Minimization Completely Specified FSMCompletely Specified FSM Incompletely Specified Machine (ISM)Incompletely Specified Machine (ISM)
State EncodingState Encoding
ENEE 644 3
Definition: Definition: Finite State MachineFinite State Machine
A A Finite State Machine (FSM)Finite State Machine (FSM) of of MealyMealy type is a type is a 6 tuple <6 tuple <I,S,I,S,,S,S00,O,,O,> > I: input alphabet, a non-empty set of input values;I: input alphabet, a non-empty set of input values; S: a non-empty, finite set of states;S: a non-empty, finite set of states; : SxI : SxI S, a function defines the next state; S, a function defines the next state; SS00: : S, the set of initial/reset states;S, the set of initial/reset states; O: output alphabet;O: output alphabet; : SxI : SxI O, a function defines the output. O, a function defines the output.
A finite state machine of A finite state machine of MooreMoore type is defined in type is defined in the same way except that the output function the same way except that the output function : S : S O O does not depend on the present inputs. does not depend on the present inputs.
ENEE 644 4
Example: Example: Finite State MachineFinite State Machine
I = {x,y}I = {x,y} S = {A,B,C}S = {A,B,C} SS00= {A}= {A}
(A,x) = A, (A,x) = A, (B,x) = A, (B,x) = A, (C,x) = C(C,x) = C(A,y) = B, (A,y) = B, (B,y) = C, (B,y) = C, (C,y) = A(C,y) = A
O = {0,1}O = {0,1} (A,x) = 0, (A,x) = 0, (B,x) = 0, (B,x) = 0, (C,x) = 0(C,x) = 0
(A,y) = 1, (A,y) = 1, (B,y) = 0, (B,y) = 0, (C,y) = 1(C,y) = 1
ENEE 644 5
FSM Representation: FSM Representation: STGSTG
In sum, a STG is a In sum, a STG is a weightedweighted, , directed directed graph where graph where self self loopsloops and and duplicated edgesduplicated edges are allowed. Each node has are allowed. Each node has at most |I| outgoing edges and |I|x|S| incoming edges. at most |I| outgoing edges and |I|x|S| incoming edges. Total number of edges is Total number of edges is |I|x|S|+|S |I|x|S|+|S00|. |.
State Transition Graph:State Transition Graph: Node Node state (S) state (S) Edge Edge transition ( transition ( : SxI : SxI S, S, : SxI : SxI O, S O, S00))
• Direction: from the current state to the next stateDirection: from the current state to the next state• Label: input/output information for the transitionLabel: input/output information for the transition• Special edges: edges without source, their ending Special edges: edges without source, their ending
nodes are initial statesnodes are initial states
ENEE 644 6
Example: Example: FSM as an STGFSM as an STG
I = {x,y}I = {x,y} S = {A,B,C}S = {A,B,C} SS00= {A}= {A} (A,x) = A, (A,x) = A, (A,y) = B, (A,y) = B,
(B,x) = A, (B,x) = A, (B,y) = C, (B,y) = C, (C,x) = C, (C,x) = C, (C,y) = A(C,y) = A
O = {0,1}O = {0,1} (A,x) = 0, (A,x) = 0, (A,y) = 1, (A,y) = 1,
(B,x) = 0, (B,x) = 0, (B,y) = 0, (B,y) = 0, (C,x) = 0(C,x) = 0, , (C,y) = 1(C,y) = 1
AA
CCBB
x/0
y/1x/0
x/0
y/0 y/1
ENEE 644 7
FSM Representation: FSM Representation: Flow TableFlow Table
The The flow tableflow table of an FSM < of an FSM <I,S,I,S,,S,S00,O,,O,> is a |S|x|I| > is a |S|x|I| table, where the i-th row represents state Stable, where the i-th row represents state Sii, the j-, the j-th column represents input value xth column represents input value xjj. The entry at . The entry at (i,j) is a 2 tuple (i,j) is a 2 tuple <<(S(Sii,x,xjj), ), (S(Sii,x,xjj)>)>. The initial states . The initial states SS00 can be specified separately. can be specified separately.
Example: Example: AA
CCBB
x/0
x/0
y/1x/0
y/0 y/1
A,1A,1C,0C,0C,0C,0A,0A,0B,1B,1A,0A,0
CCBBAA
yyxx
ENEE 644 8
FSM Representation: FSM Representation: Cube TableCube Table
The The cube tablecube table of an FSM < of an FSM <I,S,I,S,,S,S00,O,,O,> is a (|S|x|I|)x4 > is a (|S|x|I|)x4 table, where in each row, the first column represents input table, where in each row, the first column represents input value value xxjj, second column is the state , second column is the state SSii, third column is the , third column is the next state next state (S(Sii,x,xjj)), and the last column is the output , and the last column is the output (S(Sii,x,xjj)). The initial states S. The initial states S00 can be can be
specified separately.specified separately. Example: Example:
AA
CCBB
x/0
x/0
y/1x/0
y/0 y/1
11AACCyy00CCCCxx00CCBByy00AABBxx11BBAAyy00AAAAxxOONSNSPSPSII
A,1A,1C,0C,0CC
C,0C,0A,0A,0BB
B,1B,1A,0A,0AA
yyxx
ENEE 644 9
FSM with Incomplete SpecificationFSM with Incomplete Specification An FSM <An FSM <I,S,I,S,,S,S00,O,,O,> is > is incompletely specifiedincompletely specified
if if and/or and/or are incompletely specified functions. are incompletely specified functions. (I.e., they are not defined on some combinations (I.e., they are not defined on some combinations of inputs and present states.) Otherwise, it is of inputs and present states.) Otherwise, it is completely specified. completely specified. In STG, this means there exist nodes with less than |I| In STG, this means there exist nodes with less than |I|
outgoing edges;outgoing edges; In flow table, this means there exist undefined entries;In flow table, this means there exist undefined entries; In cube table, this means there exist undefined rows.In cube table, this means there exist undefined rows.
ENEE 644 10
Make Incomplete CompleteMake Incomplete Complete In STG: add a dummy state called In STG: add a dummy state called trap statetrap state.. In flow table: leave the entry empty or fill it by In flow table: leave the entry empty or fill it by
<don’t care, don’t care>.<don’t care, don’t care>. In cube table: delete the undefined row or fill the In cube table: delete the undefined row or fill the
last two columns by don’t cares. last two columns by don’t cares.
AA
CCBB
x/0
y/1x/0
y/0y/1
DD
??
-/-
AA
CCBB
x/0
y/1x/0
y/0y/1
DD
x/-
x/-
y/-
ENEE 644 11
FSM MinimizationFSM Minimization FSMs may contain FSMs may contain redundantredundant states, i.e. states states, i.e. states
whose function can be accomplished by other whose function can be accomplished by other states.states.
Removing the redundant states decreases the Removing the redundant states decreases the number of states in the FSM, and in general number of states in the FSM, and in general results in a simplification in the final results in a simplification in the final implementation.implementation.
State minimization is the transformation of a State minimization is the transformation of a given FSM into an given FSM into an equivalentequivalent FSM with no FSM with no redundant states (I.e. minimal number of states).redundant states (I.e. minimal number of states).
ENEE 644 12
Binary RelationsBinary Relations Given two sets A and B, a Given two sets A and B, a binary relationbinary relation RR
between A and B is a subset of AxB={(x,y)|between A and B is a subset of AxB={(x,y)|xxA,yA,yB}. We write xB}. We write xRR y if (x,y) y if (x,y)RR . .
Relation Relation RR BxB is BxB is reflexivereflexive iff x iff xRRx for any xx for any xB;B; symmetricsymmetric iff x iff xRR y y y yRR x; x; anti-symmetricanti-symmetric iff x iff xRR y, y y, yRR x x x=y; x=y; transitivetransitive iff x iff xRR y, y y, yRR z z x xRR z. z.
A binary relation A binary relation RR BxB is an BxB is an equivalent equivalent relationrelation if it is reflexive, symmetric, and transitive. if it is reflexive, symmetric, and transitive.
compatibility relationcompatibility relation
ENEE 644 13
Partition into Equivalent ClassesPartition into Equivalent Classes A A partitionpartition of a set of of a set of BB is a set of subsets is a set of subsets BBiiBB, ,
such that such that BBiiBBii ( (iij) j) iiBBii==BB..
Given an equivalent relation Given an equivalent relation RR BxB, the BxB, the equivalent classequivalent class of x of xB is [x]={yB is [x]={yB|xB|xRRy}. y}. x,yx,yB, [x]=[y] or [x]B, [x]=[y] or [x][y]=[y]=;; If BIf B11,B,B22,…,B,…,Bnn are all the different equivalent classes, are all the different equivalent classes,
then {Bthen {B11,B,B22,…,B,…,Bnn} is a partition of B.} is a partition of B.
An equivalent relation gives a unique partition.An equivalent relation gives a unique partition.
ENEE 644 14
Refinement of a PartitionRefinement of a Partition Given two partitions PGiven two partitions P11={B={B11
11,B,B2211,…,B,…,Bmm
11} and } and PP22={B={B11
22,B,B2222,…,B,…,Bnn
22} of a set B, P} of a set B, P11 is a is a refinementrefinement of of PP22 if every subset (block) B if every subset (block) Bii
11BBjj22 for some j. for some j.
Let PLet P11={B={B1111,B,B22
11,…,B,…,Bmm11} and P} and P22={B={B11
22,B,B2222,…,B,…,Bnn
22} be } be two sets of subsets of a set B, the two sets of subsets of a set B, the meetmeet of P of P11 and and PP22 is defined as the following set: is defined as the following set: PP11•P•P22={B={Bii
11BBjj22||
i=1,2,…m,j=1,2,…,n}i=1,2,…m,j=1,2,…,n} Theorem: If PTheorem: If P11 and P and P22 are partitions, then P are partitions, then P11•P•P22 is is
also a partition of the same set B, furthermore, it is also a partition of the same set B, furthermore, it is a refinement for both a refinement for both PP11 and P and P22..[Proof:][Proof:]
ENEE 644 15
Equivalent States of an FSMEquivalent States of an FSM Given two states s and t in an FSM, and a k-string Given two states s and t in an FSM, and a k-string
x=(xx=(x00xx11…x…xk-1k-1), suppose z), suppose zss=(z=(zss00zzss
11…z…zssk-1k-1) and z) and ztt=(z=(ztt
00zztt11…z…ztt
k-k-
11) are the corresponding output strings when states s and ) are the corresponding output strings when states s and t are used as starting state respectively. x is called a t are used as starting state respectively. x is called a length-k distinguishing sequencelength-k distinguishing sequence for states s and t iff z for states s and t iff zss
k-k-
11 z zttk-1k-1. .
xxk-1k-1…x…x11xx00ss
ttzzss
k-1k-1…z…zss11zzss
00
xxk-1k-1…x…x11xx00ss
ttzztt
k-1k-1…z…ztt11zztt
00
==== ??
ENEE 644 16
Equivalent States of an FSMEquivalent States of an FSM Two states s and t are Two states s and t are k-equivalentk-equivalent, written as s, written as skkt, t,
iff there does not exist a distinguishing sequence iff there does not exist a distinguishing sequence for s and t of length k or less. for s and t of length k or less.
Two states are Two states are equivalentequivalent iff they are |S|- iff they are |S|-equivalent.equivalent.
Define Define kk={(s,t)| s={(s,t)| skkt}, the set of all pairs of k-t}, the set of all pairs of k-equivalent states.equivalent states.
kk is an is an equivalent relationequivalent relation, I.e., it is , I.e., it is Reflexive:Reflexive: s skkss Symmetric:Symmetric: s skkt t t tkkss Transitive:Transitive: r rkks, ss, skkt t r rkktt
ENEE 644 17
Equivalent States of an FSMEquivalent States of an FSM 11={(A,C),(A,E),(C,E),(B,D),(B,F),(D,F), ={(A,C),(A,E),(C,E),(B,D),(B,F),(D,F),
(C,A),(E,A),(E,C),(D,B),(F,B),(F,D),(C,A),(E,A),(E,C),(D,B),(F,B),(F,D), (A,A),…,(F,F)}(A,A),…,(F,F)}
BB1111={A,C,E}={A,C,E}
BB2211={B,D,F}={B,D,F}
22={(A,C),(A,E),(C,E),(B,D),={(A,C),(A,E),(C,E),(B,D), (C,A),(E,A),(C,A),(E,A),(E,C),(D,B),(E,C),(D,B), (A,A),…,(F,F)}(A,A),…,(F,F)} BB11
22={A,C,E}={A,C,E} BB22
22={B,D}={B,D} BB33
22={F}={F}
33={(A,C),(B,D),={(A,C),(B,D),(C,A),(D,B),(C,A),(D,B),(A,A),…,(F,F)}(A,A),…,(F,F)}
FF
CCEE
BBDD
AA1/1
0/0
0/0
0/01/1
0/0
0/0
1/1
1/0
1/0
1/0 0/0
ENEE 644 18
Equivalent States Checking: Equivalent States Checking: TheoryTheory
Two states are Two states are equivalentequivalent iff they are |S|- iff they are |S|-equivalent.equivalent.
Theorem 1. Theorem 1. Let sLet sxx and t and txx be the x-successors of s and t in an be the x-successors of s and t in an FSM, then sFSM, then sk+1k+1t t s skkt and t and xxI, sI, sxxkkttxx..
Theorem 2. Theorem 2. Two states of a given FSM are equivalent iff they Two states of a given FSM are equivalent iff they are are (|S|)-equivalent.(|S|)-equivalent.
ENEE 644 19
State Equivalence Checking: State Equivalence Checking: PracticePractice Goal: determine Goal: determine |S||S|(S), all pairs of equivalent (S), all pairs of equivalent
states in an FSM S.states in an FSM S. Partition-Refinement procedure:Partition-Refinement procedure:
PPkk={B={B11kk,B,B22
kk,…}: the partition determined by ,…}: the partition determined by kk, the k-, the k-equivalent state pairs. (Pequivalent state pairs. (P00=S={B=S={B11
00}) }) Idea:Idea:
For each block in PFor each block in Pkk • partition it (for all xpartition it (for all xI) if its x-successors are not in I) if its x-successors are not in
the same block;the same block;• Refine the partition by taking the meet of these finer Refine the partition by taking the meet of these finer
partitions;partitions;Stop when PStop when Pk+1k+1=P=Pkk
ENEE 644 20
PP00={(A,B,C,D,E,F)}={(A,B,C,D,E,F)} (1-block)(1-block)
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}for block Pfor block P11
22=(A,C,E):=(A,C,E): on x=0: next states:on x=0: next states: EECEEC
blk indices:blk indices: 111111PbPb11
00={(A,C,E)}=P={(A,C,E)}=P1122
(no refinement)(no refinement) on x=1:on x=1: next states:next states: DBFDBF
blk indices:blk indices: 222222PbPb11
11={(A,C,E)}=P={(A,C,E)}=P1122
(no refinement)(no refinement)PP22={(A,C,E)}={(A,C,E)}
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
inputinput
blk no.blk no.
levellevel
ENEE 644 21
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}PP22={(A,C,E)}={(A,C,E)}for block Pfor block P22
22=(B,D,F):=(B,D,F): on x=0: next states:on x=0: next states: DBBDBBblk indices:blk indices: 222222PbPb22
00={(B,D,F)}=P={(B,D,F)}=P2222
on x=1:on x=1: next states:next states: FFCFFCblk indices:blk indices: 221221PbPb22
11={(B,D),(F)}={(B,D),(F)} refine:refine: PP22
22=P=P222 2 ••PbPb22
11= Pb= Pb2211
={(B,D),(F)}={(B,D),(F)}PP22={(A,C,E),(B,D),(F)}={(A,C,E),(B,D),(F)}
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
ENEE 644 22
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}PP22={(A,C,E),(B,D),(F)}={(A,C,E),(B,D),(F)}
for block Pfor block P1133=(A,C,E):=(A,C,E):
on x=0: next states:on x=0: next states: EECEECblk indices:blk indices: 111111PbPb11
00={(A,C,E)}=P={(A,C,E)}=P1133
on x=1:on x=1: next states:next states: DBFDBFblk indices:blk indices: 223223PbPb11
11={(A,C),(E)}={(A,C),(E)} refine:refine: PP11
33=P=P113 3 ••PbPb11
11= Pb= Pb1133
={(A,C),(E)}={(A,C),(E)}PP33={(A,C),(E)}={(A,C),(E)}
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
ENEE 644 23
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}PP22={(A,C,E),(B,D),(F)}={(A,C,E),(B,D),(F)}
PP33={(A,C),(E)}={(A,C),(E)}for block Pfor block P22
33=(B,D):=(B,D): on x=0: next states:on x=0: next states: DBDB
blk indices:blk indices: 2222PbPb11
00={(B,D)}=P={(B,D)}=P2233
on x=1:on x=1: next states:next states: FFFFblk indices:blk indices: 3333
PbPb111 1 ={(B,D)}=P={(B,D)}=P22
33
PP33={(A,C),(E),(B,D)}={(A,C),(E),(B,D)}
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
ENEE 644 24
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}PP22={(A,C,E),(B,D),(F)}={(A,C,E),(B,D),(F)}
PP33={(A,C),(E),(B,D)}={(A,C),(E),(B,D)}for block Pfor block P33
33=(F):=(F):contains single state, contains single state, cannot be partitioned.cannot be partitioned.
PP33={(A,C),(E),(B,D),(F)}={(A,C),(E),(B,D),(F)}PP33={(A,C),(E),(B,D),(F)}={(A,C),(E),(B,D),(F)}
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
ENEE 644 25
PSPS NS, z NS, zx=0x=0 x=1x=1
AA E, 0E, 0 D, 1D, 1BB D, 0D, 0 F, 0F, 0CC E, 0E, 0 B, 1B, 1DD B, 0B, 0 F, 0F, 0EE C, 0C, 0 F, 1F, 1FF B, 0B, 0 C, 0C, 0
Example: Example: Finding Equivalent States Finding Equivalent States
PP11={(A,C,E),(B,D,F)}={(A,C,E),(B,D,F)}PP22={(A,C,E),(B,D),(F)}={(A,C,E),(B,D),(F)}PP33={(A,C),(E),(B,D),(F)}={(A,C),(E),(B,D),(F)}
One can compute POne can compute P44 in the in the same way, which givessame way, which gives
PP44={(A,C),(E),(B,D),(F)}={(A,C),(E),(B,D),(F)}
PP44=P=P33 so we stopso we stopConclusion: Conclusion:
A and C are equivalentA and C are equivalentB and D are equivalentB and D are equivalent
FF
CCEE
BBDD
AA1/1
0/0
0/00/0
1/1
0/0
0/0
1/1
1/01/0
1/0 0/0
ENEE 644 26
FSM Minimization with Equivalent StatesFSM Minimization with Equivalent States
STG: collapse states in the same equivalent STG: collapse states in the same equivalent class to one state; update edges.class to one state; update edges.
FF
CCEE
BBDD
AA1/1
0/0
0/0
0/01/1
0/0
0/0
1/1
1/0
1/0
1/0 0/0
Equivalent classes: (A,C), (B,D), (E), (F)
CC
FF
EE
BBDD
AA1/1
0/01/1
0/0
0/0
1/1
1/0
1/0
1/00/0
0/0
0/0
0/0
1/0
0/0
0/0
FF
EE
DD
AA1/1
0/01/1
1/0
1/0
0/0
0/0
0/0
ENEE 644 27
Definition: Definition: Finite State MachineFinite State Machine
RecallRecall: A Finite State Machine (FSM) of Mealy type : A Finite State Machine (FSM) of Mealy type is a 6 tuple <is a 6 tuple <I,S,I,S,,S,S00,O,,O,> > I: input alphabet, a non-empty set of input values;I: input alphabet, a non-empty set of input values; S: a non-empty, finite set of states;S: a non-empty, finite set of states; : SxI : SxI S, a function defines the next state; S, a function defines the next state; SS00: : S, the set of initial/reset states;S, the set of initial/reset states; O: output alphabet;O: output alphabet; : SxI : SxI O, a function defines the output. O, a function defines the output.
ENEE 644 28
FSM Equivalence CheckingFSM Equivalence Checking
MM11=<=<II11,S,S11,,11,S,S0011,O,O11,,11> > MM22=<=<II22,S,S22,,22,S,S00
22,O,O22,,22>> What do we mean by What do we mean by MM11 and and MM22 are equivalent? are equivalent?
For any input, they should produce the same output.For any input, they should produce the same output. II11 = = II22
OO1 1 = = OO22
How to verify that How to verify that MM11 and and MM22 are equivalent? are equivalent? Assuming that Assuming that SS00
11={s={s0011} } and and SS00
22={s={s0022}}, then if there is , then if there is
no input string can distinguish no input string can distinguish ss001 1 and and ss00
22, we claim , we claim that that MM11 and and MM2 2 are equivalent.are equivalent.
ENEE 644 29
The Product MachineThe Product Machine The The product machineproduct machine of two FSMs, of two FSMs,
MM11=<=<I,SI,S11,,11,S,S0011,O,,O,11> and > and MM22=<=<I,SI,S22,,22,S,S00
22,O,,O,22>, >, is defined as is defined as MM1212=<=<I,SI,S1212,,1212,S,S00
1212,{0,1},,{0,1},1212>> SS1212=S=S11xSxS22={(={(ss11,s,s22)| )| ss11SS11,s,s22SS22}} 1212: S: S1212xI xI SS1212 1212(s(s1212,x)=t,x)=t1212=(t=(t11,t,t22))
1212(s(s1212,x)=(,x)=(11(s(s11,x), ,x), 22(s(s22,x)) =(t,x)) =(t11,t,t22)) SS00
12 12 =S=S0011xSxS00
22={(={(ss0011,s,s00
22)| )| ss0011SS00
11,s,s0022SS00
22}}
1212: S: S1212xI xI {0,1}{0,1} 1212(s(s1212,x)=,x)=11 iff iff 11(s(s11,x)=,x)=22(s(s22,x),x)
MM1 1 and and MM22 are equivalent are equivalentMM1212 always outputs 1.always outputs 1.
ENEE 644 30
Run and Reachable StateRun and Reachable State For an FSM For an FSM MM11=<=<II11,S,S11,,11,S,S00
11,O,O11,,11>, an input string >, an input string xx00xx11…x…xk-1k-1 produces a sequence of states produces a sequence of states ss00ss11…s…skk (called a (called a runrun, where , where ss0 0 is the starting state)is the starting state) and an and an output string output string zz00zz11…z…zk-1k-1..
A state A state t is reachable from state st is reachable from state s if there exists an if there exists an input string that produces a run with s as the input string that produces a run with s as the starting state and t as the ending state. starting state and t as the ending state.
The The reachable statesreachable states of an FSM < of an FSM <I,S,I,S,,S,S00,O,,O,> is > is defined as:defined as: {t{tSS| t is reachable from s, s| t is reachable from s, sSS00}}
We only need to check the reachable states for FSM We only need to check the reachable states for FSM equivalence.equivalence.
ENEE 644 31
FSM Equivalence CheckingFSM Equivalence Checking
MM11=<=<II11,S,S11,,11,S,S0011,O,O11,,11> > MM22=<=<II22,S,S22,,22,S,S00
22,O,O22,,22>> If If II11 II22 or or OO1 1 OO22 return not equivalentreturn not equivalent;; Build the product machine Build the product machine MM1212;; Start with the initial state sStart with the initial state s00
1212, traverse the STG of the , traverse the STG of the FSM FSM MM1212;; For each reachable state in For each reachable state in MM1212, , if it can output 0, if it can output 0, return not return not
equivalentequivalent;; Return equivalentReturn equivalent;;
To get a distinguishing sequence in the case of not To get a distinguishing sequence in the case of not equivalent, we need to store the predecessor information equivalent, we need to store the predecessor information and do backtracking.and do backtracking.
ENEE 644 32
Example: Example: FSM Equivalence CheckingFSM Equivalence Checking
MM11=<=<{x,y},{A,B,C},{x,y},{A,B,C},11,{A},{0,1},,{A},{0,1},11>> MM2 2 =<=<{x,y},{D,E,F},{x,y},{D,E,F},22,{D},{0,1},,{D},{0,1},22> > MM1212=<{x,y},=<{x,y},SS1212,,1212,{(A,D)},{0,1},,{(A,D)},{0,1},1212>>
|S|S1212| = 9, however, only 3 states are reachable: (A,D),(B,E),(C,F)| = 9, however, only 3 states are reachable: (A,D),(B,E),(C,F) Every reachable state outputs 1 on all inputs.Every reachable state outputs 1 on all inputs. So MSo M11 and M and M22 are equivalent. are equivalent.
AA
CCBB
x/0
x/0
y/1x/0
y/0 y/1
DD
FFEE
x/0
x/0
y/1x/0
y/0 y/1
A,DA,D
C,FC,FB,EB,E
x/1
x/1
y/1x/1
y/1 y/1
A,EA,Ex/1
B,FB,Fy/0
••••••
ENEE 644 33
Example: Example: FSM Equivalence CheckingFSM Equivalence Checking
Now, MNow, M11 and M and M22 are not equivalent. are not equivalent. Consequently, one of the reachable state (C,F) Consequently, one of the reachable state (C,F)
outputs 0 on input x.outputs 0 on input x. Backtracking to find the distinguishing sequence.Backtracking to find the distinguishing sequence.
AA
CCBB
x/0
x/1
y/1x/0
y/0 y/1
DD
FFEE
x/0
x/0
y/1x/0
y/0 y/1
A,DA,D
C,FC,FB,EB,E
x/1
x/0
y/1x/1
y/1 y/1
A,EA,Ex/1
B,FB,Fy/0
••••••