Presentation is loading. Please wait.

Presentation is loading. Please wait.

Synthesis and Verification of Finite State Machines

Similar presentations


Presentation on theme: "Synthesis and Verification of Finite State Machines"— Presentation transcript:

1 Synthesis and Verification of Finite State Machines
Sungho Kang Yonsei University

2 Minimization of Incompletely Specified Machines
Outline Minimization Minimization of Incompletely Specified Machines Binate Covering Problem State Encoding Decomposition and Encoding

3 Synthesis of Practical FSMs
Minimization We have learned basic methods for minimizing, encoding, checking equivalence, and synthesizing circuits for realizing completely specified FSMs Now we must learn to deal with the more practical case of incomplete specification Our goal is thus to find a least cost circuit that satisfies a partial specification

4 Flow Table Compatibility Table
Incomplete specification and Compatibility MInimization Use don’t-cares to merge states. Merged states must have same output sequences Flow Table Compatibility Table Note each constraint represents pair (incompatibility)

5 Derive all prime sets of compatible states
Strategy MInimization Derive all prime sets of compatible states Solve a covering problem to obtain minimum states.

6 Compatibility Constraints
MInimization Compatibility relation: conjunction of constraints (one for each “X”) Note each constraint represents pair (incompatibility)

7 Computing the Maximal Compatibles
MInimization By recursive multiplication method, like computing the Complete Sum: The (complete) constraint sums are multiplied out, dropping absorbed terms when they arise.

8 Computing the Maximal Compatibles
MInimization x’1x’2+x’3x’4+x’1x’4 x’1x’2 ⇒ {S3, S4} Maximal compatibles are “Prime”. (No superset of these state sets are also pairwise compatible). x’1 ⇒ {S2, S3, S4} but {S2, S4} are not compatible

9 Prime Compatibles MInimization Unfortunately, some subsets of the maximal compatibles pairs are also prime compatibles. Because, selection of one compatible pair may imply selection of other compatible pairs. {S3, S4}⇒ {S1, S2}

10 Class Sets and Prime Compatibles
MInimization In minimization, we desire a minimum number of compatible sets that cover all original states. Pick from primes. Choice of conditionally compatible set implies choosing all implied pairs. Set of implied compatibles pairs is called the class set, e.g.,{S1,S2} is the class set of {S3,S4} CS(s,t)={(si,ti)}

11 We just derived maximal compatibles that are prime
Update and Strategy MInimization We just derived maximal compatibles that are prime Derive remaining prime compatibles Solve a covering problem

12 Class Sets x1 x2 x3 x4 x5 x6 x7 a a,0 -- d,0 e,1 b,0 a,-- --
MInimization x1 x2 x3 x4 x5 x6 x7 a a, d,0 e,1 b,0 a, b b,0 d,1 a, a,-- a, c b,0 d,1 a, g,0 d e, b,-- b, a,-- e b,-- e,-- a, b,-- e,-- a,1 f b,0 c, ,1 h,1 f,1 g,0 -- g c, e, g,0 f,0 h a,1 e,0 d,1 b,0 b,-- e,-- a,1 b a,d c X ~ d b,e a,b d,e d,e a,g e a,b a,d d,e a,b a,e X ~ f X X c,d X X g ~ X c,d f,g X X e,h h X X X ~ a,b a,d X X a b c d e f g

13 Class Sets and Primes Note is prime: although b a,d c X ~
MInimization Note is prime: although b a,d c X ~ d b,e a,b d,e d,e a,g e a,b a,d d,e a,b a,e X ~ f X X c,d X X g ~ X c,d f,g X X e,h h X X X ~ a,b a,d X X a b c d e f g

14 Class Sets and Primes Note is not prime: b a,d c X ~
MInimization Note is not prime: b a,d c X ~ d b,e a,b d,e d,e a,g e a,b a,d d,e a,b a,e X ~ f X X c,d X X g ~ X c,d f,g X X e,h h X X X ~ a,b a,d X X a b c d e f g

15 Class Sets Note is prime: b a,d c X ~ d b,e a,b d,e d,e a,g
MInimization Note is prime: b a,d c X ~ d b,e a,b d,e d,e a,g e a,b a,d d,e a,b a,e X ~ f X X c,d X X g ~ X c,d f,g X X e,h h X X X ~ a,b a,d X X a b c d e f g

16 Maximal Compatibles maximal class
MInimization maximal class compatibles set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Note sub-compatibles {b,c} through {d,h} are added to the list of prime compatibles before maximal compatible {a,g}

17 Maximal Compatibles maximal class
MInimization maximal class compatible set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Note that subsets {b,d} and {d,e} are not prime because they are contained in {a,b,d,e}, which has an empty class set

18 Note that subset {e,h}, with
Maximal Compatibles MInimization maximal class compatible set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Note that subset {e,h}, with class set {{a,b},{a,d}}, is not prime because it is contained in {d,e,h}, whose class set is the same.

19 Note {a},{b},{c},{d},{e},{g} are all contained in primes
Maximal Compatibles MInimization maximal class compatible set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} After treating subsets of size 2, we still have to check all subsets of size 1, which have empty class sets. Note {a},{b},{c},{d},{e},{g} are all contained in primes with empty class sets, so they are not prime. But {f} is not, so it is prime.

20 Goal: To Find Prime Compatibles
MInimization maximal class compatible set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Maximal Compatibles are prime. Other prime compatibles are subsets of primes such that: S is prime iff its class set does not contain the class set of a larger prime S’⊃S e.g., {e,h} →{(a,b),(ad)} is not prime

21 Finding Prime Compatibles
MInimization Enqueue known primes of size k Test subcompatibles for primality

22 Finding Prime Compatibles
MInimization For each value of k, the for-loop of Line 1 puts the maximal compatibles of size k onto the queue of primes, P. For k=4, only {a,b,d,e} is enqueued For k=3, {b,c,d},{c,f,g},{d,e,h} are enqueued

23 Finding Prime Compatibles
MInimization For each enqueued prime p (of size k), we check every subset of size k-1. s is a prime compatible if and only if

24 Building the Reduced Machine
MInimization x1 x2 x3 x4 x x6 x7 a a, d,0 e,1 b,0 a, b b,0 d,1 a, a, a, c b,0 d,1 a, g,0 d e, b,-- b, a,-- e b,-- e,-- a, b, e,-- a,1 f b,0 c, ,1 h,1 f, g, g c, e, g,0 f,0 h a,1 e,0 d,1 b,0 b,-- e, a,1 x 1 2 3 4 5 6 7 9 ,

25 x 1 2 3 4 5 6 7 9 , x1 x2 x3 x4 x5 x6 x7 a a,0 -- d,0 e,1 b,0 a,-- --
Reduced Machine MInimization x1 x2 x3 x4 x x6 x7 a a, d,0 e,1 b,0 a, b b,0 d,1 a, a, a, c b,0 d,1 a, g,0 d e, b,-- b, a,-- e b,-- e,-- a, b, e,-- a,1 f b,0 c, ,1 h,1 f, g, g c, e, g,0 f,0 h a,1 e,0 d,1 b,0 b,-- e, a,1 Where there is a choice, choose 1 (as in x2-successor of compatible 1): {d,e} contained in c1 or c4 . x 1 2 3 4 5 6 7 9 ,

26 Closed Cover : Choosing Compatibles
MInimization Closed Cover : Choosing Compatibles Every state of the original machine must be covered Every implied compatible must be present in the solution

27 Closed Cover maximal class Coverage: Closure:
MInimization maximal class compatibles set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Let’s check if the following set of compatibles forms a closed cover: {c1,c4,c5,c9} Coverage: Closure:

28 Covering Constraints--POS FORM
MInimization maximal class compatibles set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Every state of the original machine must be covered.

29 Covering Constraints--POS FORM
MInimization maximal class compatibles set 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} remaining PCs class set 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} 8 {c,g} {{c,d}, {f,g}} 9 {f,g} {{e,h}} 10 {d,h} {} 12 {f} {} Every state of the original machine must be covered. c a b h g e f d

30 Finding a Minimum Closed Cover
MInimization Associate a variable ci to the i-th prime compatible For each s∊S, form the coverage constraint 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} a b c d e f g h c1(c1+c2)(c2+c3)(c1+c2+c3)(c1+c4)c2c3c4 = c1c3c4 This cover is not closed, since c2 is excluded

31 is the set of prime compatibles
Closure Constraints MInimization is the set of prime compatibles with non-empty class sets Note class sets 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}}

32 Covering and Closure Constraints--POS FORM
MInimization

33 Covering Constraints--Matrix FORM
MInimization Row Dominance Col Dominance?

34 Closure Constraints--Matrix FORM
MInimization class sets 1 {a,b,d,e} {} 2 {b,c,d} {{a,b},{a,g},{d,e}} 3 {c,f,g} {{c,d}, {e,h}} 4 {d,e,h} {{a,b}, {a,d}} 11 {a,g} {} 5 {b,c} {} 6 {c,d} {{a,g}, {d,e}} 7 {c,f} {{c,d}} For each pair pj in the class set of each compatible ci, form the clause c’i+Σkck where k ranges over the indices of compatibles that contain pj

35 Closure Constraints--Matrix FORM
MInimization Cover rows by including a 1-col OR excluding a 0-col

36 Closed Covering Problem
Minimization Find a minimum set of columns which cover all rows: {1,4,5,9} Covering Constraints A row is covered by either including a 1-col or excluding a 0-col. Closure Constraints

37 Binate Covering Problem
Similar to unate covering Matrix Variables on columns Sum expressions on the rows Solution may not exist when product is 0

38 Binate Covering Problem
Note: M replaced by F to emphasize POS semantics Also there is one addition (for empty solution space)

39 Formulation of BCP Binate Covering Find a subset of S of columns of minimum cost according to min(Σwjxj) such that for every row of fi, either 1. ∃j : (fij=1) ∧ (Fj ∊ S); or 2. ∃j : (fij=0) ∧ (Fj ∉ S)

40 Unacceptable (anti-essential) Variables
Binate Covering An essential row F is a row fi, where only one coefficient is different from – Alternatively it is a clause of F consisting of a single literal When x’2 is essential we say that x2 is unacceptable When x’i is essential, we may delete all rows of the matrix which has a zero in the i-th column

41 Row Dominance Row 1 (f1) dominates row 2 (f2) since row 2 matches
Binate Covering Row 1 (f1) dominates row 2 (f2) since row 2 matches row 1 at all care entries. Row 1 may be deleted. Formally: Row f1 dominates row f2 if f1 is satisfied, in a Boolean sense, whenever f2 is satisfied, that is, f1≤f2.

42 Let Fj and Fk be two columns of F. We say that Fj
Column Dominance Binate Covering Let Fj and Fk be two columns of F. We say that Fj Dominates Fk if, for each row fi of F, one of the following conditions hold: Example: reduced column F1 dominates F4

43 If Fj ≥ Fk and wj ≤ wk then there is at lest one
Column Dominance Binate Covering Let F be satisfiable If Fj ≥ Fk and wj ≤ wk then there is at lest one minimum solution with xk = 0 Row dominance has to do with the identification of a subset of clauses of F that is sufficient to express all constraints Column dominance is used to extract a subset of the variables that contains a minimum cost solution if exists

44 Choice of Splitting Variable
Decomposition and Encoding If the reduced problem is cyclic, it is necessary to branch by temporarily assigning a chosen variable to 0 (or 1) and finding the minimum solution and then repeating this when the variable is assigned to 1 or (0) The choice of the branching variable is usually a heuristic, but a very important one

45 Maximal Independent Set
Binate Covering Two rows are independent if it is not possible to satisfy both clauses by assigning one variable to 1 Thus in finding the MIS, we ignore rows (clauses) that contain 0s, since these are satisfied by assigning variables to 0

46 Infeasible Subproblems
Binate Covering F=0 cannot occur in original problem (first call to the recursive procedure). But it can happen after one or more recursions: This is detected by REDUCTION, which discovers that both x2 and x’2 are essential ⇒ F is not satisfiable

47 F2 dominates F3 x - f Reduction F1 dominates F4 f1 dominates f2
Binate Covering x f 1 2 3 4 - F1 dominates F4 f1 dominates f2 x1 is essential x3=0 Solution: x=(1,0,0,0) F2 dominates F3 x4=0

48 Reduction x1=0 and x6=1 x2=x3=0 By column dominance x4=0
Binate Covering x1=0 and x6=1 x1 x2 x3 x4 x5 x6 - 1 x2 x3 x4 x5 - 1 x2=x3=0 By column dominance x4=0 x5 1 x2 x3 x5 - 1 x1=x2=x3=x4=0 and x5=x6=1

49 The number of possible assignments is very high
State Encoding State Encoding The number of possible assignments is very high If one uses k bits to encode p states, there are (2k)!/(2k - p)! possible assignments If one considers two assignments obtained by permutation or complementation of some of the bits as essentially the same assignment, then there are (2k -1)! / (2k - p)! k! distinct assignments

50 Practical Encoding Algorithms
State Encoding Mustang tries to identify pairs of states by receiving adjacent pairs Two codes are adjacent if they only differ in one bit The first objective is to build a graph representing the attraction between each pair of states Two states that have a strong attraction should be given adjacent codes How to build attraction graph In the fanout-oriented algorithm, whenever two states, si and sj have a common fanout state, the weight of the edge (si, sj) of the attraction graph is increased In the fanin-oriented algorithm, if si and sj have a common fanin state, the weight of the edge (si, sj) of the attraction graph is increased Once the graph of the attractions is found, we try to assign codes to pairs of states that have strong attractions

51 Encoding Example Example Attraction graph 0/0 1/0 1/1 S1 S2 S3 S1 S2
State Encoding Example Attraction graph 0/0 1/0 1/1 S1 S2 S3 S1 S2 S3 W(1,3) W(1,2) W(2,3)

52 Fanout Oriented Algorithm
State Encoding Build two matrices The first with one row for each present state and one column for each next state The second with one row for each present state and one column for each output Example S1 S2 S3 3 4 2

53 Embedding Algorithm Assign codes to states
State Encoding Assign codes to states Select first the node for which the sum of the weights of the Nb heaviest incident edges is maximum Arbitrarily assign a code to it and adjacent codes to the Nb adjacent states connected by the heaviest edges Example S1 S2 S3 3 4 2 01 00 10

54 Fanin Oriented Algorithm
State Encoding Build two matrices The first with one row for each next state and one column for each present state The second with one row for each next state and two columns for each output One column is for the true input and the other is for the complement Example S1 S2 S3 3 1 7 01 00 10

55 Decomposition and Encoding
Rather than aiming directly at minimizing the number of literals in the next-state functions, one may actually try to minimize the support of the functions Reduction of the number of literals and simplification of the interconnections

56 Ba  Bb =  for a  b and  { Ba } = S
Partitions Decomposition A partition  is on a set S is a collection of disjoint subsets of S whose set union is S, i.e.  = { Ba } such that Ba  Bb =  for a  b and  { Ba } = S Each subset is called a block of the partition If 1 and 2 are partitions on S, then 1 2 is the partition on S such that s  t(1 2 ) if and only if s  t(1 ) and s  (2 ), whereas, 1 + 2 is the partition on S such that s  t(1 + 2) if and only if there exists a sequence in S s=s0 s1 s2… sn = t for which either si  si+1 (1) or si  si+1 (2), 0  i  n-1

57 Partition Example S={1,2,3,4,5,6,7,8,9} 1 = {1,2; 3,4; 5,6; 7,8,9}
Decomposition S={1,2,3,4,5,6,7,8,9} 1 = {1,2; 3,4; 5,6; 7,8,9} 2 = {1,6; 2,3; 4,5; 7,8; 9} 1 2 = {1; 2; 3; 4; 5; 6; 7,8; 9} 1 + 2 {1,2,3,4,5,6; 7,8,9}

58 Partitions with Substitution Property
Decomposition A partition  on the set of states of the machine is said to have the substitution property if and only if s  t() implies that (s,a)  (t,a) () a  I A sequential machine M has a non-trivial parallel decomposition of its state behavior if and only if there exist two nontrivial S.P. partitions 1 and 2 on M such that 1 2 = 0 Independent component Dependent component

59 Computation of SP Partitions
Decomposition First generate the minimal SP partitions and then sum them until considering all possible sums The minimal partitions are those obtained by requiring that two states only are included in a block

60 General Decomposition and Encoding
Need to resort to something more general than SP partitions, namely, partition pairs A partition pair (, ’) on the machine is an ordered pair of partitions on S such that s  t() implies that (s,a)  (t,a) (’) a  I The knowledge of the block of  containing the present state and of the current input allows one to compute the block ’ of that will contain the next state. It is evident that if (, ) is a partition pair, then  has substitution property Partition pairs generalize SP partitions


Download ppt "Synthesis and Verification of Finite State Machines"

Similar presentations


Ads by Google