Sequentinal INtro and Partition Refinement

73
1 Synthesis of Sequential Machines

description

FSM Partitioning

Transcript of Sequentinal INtro and Partition Refinement

Page 1: Sequentinal INtro and Partition Refinement

1

Synthesis of Sequential Machines

Page 2: Sequentinal INtro and Partition Refinement

2

Introduction

• Study of Two Level logic Synthesis

• Finite State Machine

• Optimization – Reducing the number of states and assign binary codes.

• Restrict on study of networks of machines.

Page 3: Sequentinal INtro and Partition Refinement

3

General Introduction

• Digital electronics Circuits• Combinational Logic Ciruits• Sequential Logic Circuits

• Combinational Logic • Basic element are Gates• Circuit Behavior: Output depends on the present input• Examples: Comparator, Arithmetic Circuits

• Sequential Logic• Basic elements are Flip Flops and Latches• Further Classified into Synchronous and Asynchronous based on

the clock.• Circuit Behavior: Output depends on the past history.• Examples: Counters, Shift Registers.

Page 4: Sequentinal INtro and Partition Refinement

4

Page 5: Sequentinal INtro and Partition Refinement

5

Page 6: Sequentinal INtro and Partition Refinement

6

Classification of FSM

• FSM Classification

• Class A Machines / Mealy Machine• Class B Machine / Moore Machine• Class C Machine • Class D Machine• Class E Machine.

We restrict to Class A and Class B Machines.

Page 7: Sequentinal INtro and Partition Refinement

7

Class A / Mealy machine

• Mealy Machine: M(S, I, O, δ, λ) but– λ: S x I → O (i.e. output depends on both

present state and present input)– for digital circuits, typically I = {0,1}m and O = {0,1}n

• In addition, (for both Moore and Mealy machines) certain states are classified as reset or initial states

• Finite automata are similar to FSM’s, but– they do not produce any outputs,– they just accept input sequences (an accepting

set of states is given).

Page 8: Sequentinal INtro and Partition Refinement

8

Class A/Mealy Machine

Page 9: Sequentinal INtro and Partition Refinement

9

Page 10: Sequentinal INtro and Partition Refinement

10

Class B /Moore Machine

• Moore Machine: is a quintuple: M(S, I, O, δ, λ)

– S: finite non-empty set of states

– I: finite non-empty set of inputs

– O: finite non-empty set of outputs

– δ: S x I → S transition (or next state) function

– λ: S → O output function (note: output only a function of present state)

Page 11: Sequentinal INtro and Partition Refinement

11

Class B /Moore Machine

Page 12: Sequentinal INtro and Partition Refinement

12

Page 13: Sequentinal INtro and Partition Refinement

13

Other Class Machine

Page 14: Sequentinal INtro and Partition Refinement

14

Simplified FSM Design Flow

Specification

State Minimization

State Encoding

Verification /Testing

Logic/Timing Optimization

Page 15: Sequentinal INtro and Partition Refinement

15

Steps Involved In Designing The FSM

1. Problem Analysis2. Defining the Black Box3. Draw the State Diagram (STG)/ASM4. Draw the state Table/Flow table5. Draw the State Transition Table6. Draw the excitation Table7. Using K-map/QM method find the output and

next state decoder function.8. Implement the design.

Page 16: Sequentinal INtro and Partition Refinement

16

Example

• Design an sequential circuit which detects the sequence 0101 continuously in the data sequence using D-FF.

• Solution:

Black Box

Page 17: Sequentinal INtro and Partition Refinement

17

Step 2 State Diagram

Page 18: Sequentinal INtro and Partition Refinement

18

State Table

Page 19: Sequentinal INtro and Partition Refinement

19

State Transition Table

Page 20: Sequentinal INtro and Partition Refinement

20

Reduction Using K-map

Page 21: Sequentinal INtro and Partition Refinement

21

Reduction Using K-map

Page 22: Sequentinal INtro and Partition Refinement

22

Reduction Using K-map

Page 23: Sequentinal INtro and Partition Refinement

23

Implementation

CLK

Page 24: Sequentinal INtro and Partition Refinement

24

Moore Machine

Page 25: Sequentinal INtro and Partition Refinement

25

Moore Machine-State Table

Page 26: Sequentinal INtro and Partition Refinement

26

Moore Machine

• Repeat the Steps as done for Mealy Machine.

Page 27: Sequentinal INtro and Partition Refinement

27

State Reduction

Page 28: Sequentinal INtro and Partition Refinement

28

State Reduction

Page 29: Sequentinal INtro and Partition Refinement

29

Page 30: Sequentinal INtro and Partition Refinement

30

Page 31: Sequentinal INtro and Partition Refinement

31

Page 32: Sequentinal INtro and Partition Refinement

32

Incompletely Specified FSM

• An FSM is incompletely specified if the next state function and/or the output functions are specified only for some combinations of inputs and present states.

Page 33: Sequentinal INtro and Partition Refinement

33

Page 34: Sequentinal INtro and Partition Refinement

34

Page 35: Sequentinal INtro and Partition Refinement

35

Finite Automata

• Similar to FSM whose task is only to declare inputs accepted or rejected.

• Classification– Deterministic– Non-deterministic

Page 36: Sequentinal INtro and Partition Refinement

36

Page 37: Sequentinal INtro and Partition Refinement

37

Page 38: Sequentinal INtro and Partition Refinement

38

State Equivalence and State Minimization

• K-equivalence– Two State Si and Sj, of Machine M are distinguishable

if and only if there exists at least one finite input sequence which can be applied to M,causes different output sequences, depending on whether Si and Sj is the initial state.

– If there exists for pair (Si,Sj) a distinguishing sequence of length k,the states in (Si,Sj) are said to be k-distinguishtable.

Page 39: Sequentinal INtro and Partition Refinement

39

Flow Table

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 B,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 40: Sequentinal INtro and Partition Refinement

40

Contd..

• states A and B are 1-distinguishable, since a 1 input applied to A yields an output 1, versus an output 0 from B.

• states A and E are 3-distinguishable, since input sequence 111 applied to A yields output 100, versus an output 101 from E.

Page 41: Sequentinal INtro and Partition Refinement

41

Definition

• States Si and Sj of Machine M are said to be equivalent if and only if ,for every possible input sequence, the same output sequence will be produced regardless of whether Si and Sj is the initial state.

Page 42: Sequentinal INtro and Partition Refinement

42

Minimization Procedure

• Objective: – To describe a procedure for determining the

sets of equivalent states of as specified machine M.

Page 43: Sequentinal INtro and Partition Refinement

43

Step One

• Partition the states of M into subsets such that all states in the same subset are 1-equivalent.

• Consider the example shown

Page 44: Sequentinal INtro and Partition Refinement

44

Example

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 45: Sequentinal INtro and Partition Refinement

45

Minimization Procedure

P0=(ABCDEF)

0-distinguistablility

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 46: Sequentinal INtro and Partition Refinement

46

Minimization Procedure

P0=(ABCDEF) P1=(ACE)

(BDF)

• 1-equivalent• Obtained by

inspecting table and placing those states having same outputs under all inputs, in the same block.

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 47: Sequentinal INtro and Partition Refinement

47

Minimization Procedure

P0=(ABCDEF) P1=(ACE)

(BDF)

P2=(ACE)(BD)(F)

• 2-equivalent• Observed iff states

are 1-equivalent.

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 48: Sequentinal INtro and Partition Refinement

48

Minimization Procedure

P0=(ABCDEF)

P1=(ACE)(BDF)

P2=(ACE)(BD)(F)

P3=(AC)(E)(BD)(F)

P4=(AC)(E)(BD)(F)

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D F,0 B,0

E C,0 F,1

F B,0 C,0

Page 49: Sequentinal INtro and Partition Refinement

49

In General

• PK+1 partition is obtained from PK by placing in the same block of PK and whose Ii –successors for every possible Ii are also common block of PK .

Page 50: Sequentinal INtro and Partition Refinement

50

Theorem

• The equivalence partition is unique

• If two states Si and Sj of machine M are distinguishable then they are distinguishable by a sequence of length

n-1 or less ,where n is the number of states in M.

Page 51: Sequentinal INtro and Partition Refinement

51

Machine equivalence

• Two Machines M1 and M2 are said to be equivalent iff for every state in M1,there is a corresponding equivalent state in M2 and vice versa.

Page 52: Sequentinal INtro and Partition Refinement

52

Machine equivalence

P3=(AC)(E)(BD)(F)

(AC) s1

(E) s2

(BD) s3

(F) s4

Page 53: Sequentinal INtro and Partition Refinement

53

Reduced Flow Table

PS NS,Z

X=0 X=1

s1 s2,0 s3,1

s2 s1,0 s4,1

s3 s4,0 s3,0

s4 s3,0 s1,0

Page 54: Sequentinal INtro and Partition Refinement

54

Page 55: Sequentinal INtro and Partition Refinement

55

Page 56: Sequentinal INtro and Partition Refinement

56

Example

PS NS,Z

X=0 X=1

A E,0 D,1

B F,0 D,0

C E,0 B,1

D B,0 F,0

E C,0 F,1

F B,0 C,0

Page 57: Sequentinal INtro and Partition Refinement

57

State Equivalence

P1=P0={B1}={A,B,C,D,E,F}

X=0=> O0={0,0,0,0,0,0}

X=1=>O1={1,0,1,0,1,0}

P11={{A,C,E}{B,D,F}}

B1={B,D,F}

t0= {D,B,B} when x=0 => b0= {1,1,1}

t1={F,F,C} when x=1 => b1={1,1,2}

Page 58: Sequentinal INtro and Partition Refinement

58

State Equivalence

P2={{B,D},{F}}B2={A,C,E} yield no refinement.P2={{B,D},{F},{A,C,E}}For k=3 first two blocks yield no refinement

B3={A,C,E} t0={E,E,C} when x=0; b0={3,3,3}t1={D,B,F} when x=1; b1={1,1,2}P3={{B,D},{F},{A,C},{E}}

Page 59: Sequentinal INtro and Partition Refinement

59

Page 60: Sequentinal INtro and Partition Refinement

60

Page 61: Sequentinal INtro and Partition Refinement

61

Page 62: Sequentinal INtro and Partition Refinement

62

State Equivalence

• P1=P0={{A,B,C,D,E,F,G}}

• O0=(0,0,0,0,1,0,0)

• O1=(0,1,1,0,0,0,0)

• P1={{A,B,C,D,F,G},{E}} when x=0 --- 1

• P1={{A,D,E,F,G}{BC}} when x=1 ---- 2

• Refine=> 1 Intersection 2

• P1={{A,D,F,G}{B,C}{E}}

Page 63: Sequentinal INtro and Partition Refinement

63

State Equivalence

• Consider B1

• t0={E,G,E,D} b0=(3,1,3,1) when x=0

• t1={C,A,D,G} b1=(2,1,1,1) when x=1

• Pb0={{A,F}{D,G}} Pb1={{A},{D,F,G}}

• Refine P2={{A}{D,G}{F}}.

• So P2={{A}{B,C}{D,G}{E}{F}}

• IIIlarly P3={{A}{B}{C}{D}{E}{F}{G}}

Page 64: Sequentinal INtro and Partition Refinement

64

Moore Machine

Page 65: Sequentinal INtro and Partition Refinement

65

Partition for a Moore Machine

• Similar as done with Mealy Machine.• Imagine for the different inputs same output.

• P0= (3,4,5,6)(1,2,7,8)

• P1= (3,4,5,6)(1,2)(7,8)

a=(1,2) b=(3,4,5,6) c=(7,8)

Page 66: Sequentinal INtro and Partition Refinement

66

Page 67: Sequentinal INtro and Partition Refinement

67

Iterative Collapsing Approach

• Collapsed Flow table is constructed, in which each occurrence of any member of a given class as a next is replaced by its representative.

• One Checks if the partition P1 is consistent with the modified table ie all members of each equivalence class must have identical entries in the new flow table.

Page 68: Sequentinal INtro and Partition Refinement

68

Example

Page 69: Sequentinal INtro and Partition Refinement

69

Iterative Collapsed Method

• P1={{A,D,F,G},{B,C},{E}}

• We select representives A,B,E and construct the collapsed flow table.

Page 70: Sequentinal INtro and Partition Refinement

70

This is not consistent, since rows A,D,F,G are not identical, although rows D and G are and B and C are.

Page 71: Sequentinal INtro and Partition Refinement

71

Iterative Collapsed Method

• The partition is refined into

P2 = {{A},{B,C}{D,G}{E},{F}}

as before.

The next step is to collapse the original table by replacing G by block 3 representive D and C by block 2 representive B.

Page 72: Sequentinal INtro and Partition Refinement

72

This flow table is still not consistent ,since rows D,G are not identical,neither B,C.

Page 73: Sequentinal INtro and Partition Refinement

73

Iterative Collapsed Method

• At this point the partition is refined to the minimum partition ,which of course is consistent ,so

P3 = {{A},{B},{C},{D},{E},{F},{G}}