24
Sources Sources Gang Quan Gang Quan Univ. of Notre Dame Univ. of Notre Dame Finite State Finite State Machines Machines

Sources Gang Quan Univ. of Notre Dame

  • Upload
    jetta

  • View
    40

  • Download
    0

Embed Size (px)

DESCRIPTION

Sources Gang Quan Univ. of Notre Dame. Finite State Machines. Review. Data Flow Graph data dependency Control/Data Flow Graph control dependency How about a reactive system?. Finite State Machine. What ? . If the driver turns on the key, and does not - PowerPoint PPT Presentation

Citation preview

Page 1: Sources  Gang Quan  Univ. of Notre Dame

Sources Sources Gang Quan Gang Quan Univ. of Notre DameUniv. of Notre Dame

Finite State MachinesFinite State Machines

Page 2: Sources  Gang Quan  Univ. of Notre Dame

ReviewReview

Data Flow Graph– data dependency

Control/Data Flow Graph– control dependency

How about a reactive system?

Page 3: Sources  Gang Quan  Univ. of Notre Dame

Finite State MachineFinite State Machine

What ?

If the driver turns on the key, and does not fasten the seat belt within 5 secondsthen an alarm beeps for 5 seconds, or until the driver fastens the seat belt, or until the driver turns off the key

Page 4: Sources  Gang Quan  Univ. of Notre Dame

Key_on/Start timer

Key_off/Stop timer

Timer>5Timer>10, orbelt_on, orkey_off/Stop timer

Wait

AlarmOn

Alarm Off

Alarm Off

An FSMAn FSM

Page 5: Sources  Gang Quan  Univ. of Notre Dame

An FSM (Cont’d)An FSM (Cont’d)• States

• Alarm off, Alarm on, Wait• Initial State

• Alarm off• Inputs

• Turn on/off the key, fasten the seat belt, timer reads• Outputs

• Start/stop the timer• Start transitions

• Alarm off + Turn on the key Wait• Output

• Alarm off + Turn on the key start the timer

Page 6: Sources  Gang Quan  Univ. of Notre Dame

Finite State MachineFinite State Machine

FSM = ( S, I, O, s0, , )– S = {s0,s1,…,sk}– I = {i1,i2,…,im}– O = {o1,o2,…,on}– : S x I S (Transition function)– : S x I O (Output function)

Given an input sequence, an output sequence is produced which is depended on s0, ,and .

Page 7: Sources  Gang Quan  Univ. of Notre Dame

RepresentationRepresentation

• States• Alarm off (s0), Alarm on (s1), Wait (s2)

• Initial State• Alarm off (s0)

• Inputs• Turn on/off the key (i0/i1), fasten the seat belt (i2), timer > 5 (i3), time > 10 (i4)

• Outputs• Start/stop the timer (o0/o1)

• Given

Page 8: Sources  Gang Quan  Univ. of Notre Dame

Transition GraphTransition Graphi0/o0

i1/o1

i2(i1+i2+i4)/o1

S1

S2

Alarm OffS0

Page 9: Sources  Gang Quan  Univ. of Notre Dame

Transition Function Transition Function

• Transition Function s1 = s0 * i0 s0=s1*i1 s2=s1 * i3 s0=s2*(i1+i2+i4)• Output Function O0 = s0 * i0 O1=s1*i1 O1=s2*(i1+i2+i4)

Page 10: Sources  Gang Quan  Univ. of Notre Dame

Transition TableTransition Table

S0 S1 S2

i0 S1 X X

i1 X S0 S0

i2 X S2 S0

i3 X X X

i4 X X S0

S0 S1 S2

i0 o0 - -

i1 - o1 o1

i2 - - o1

i3 - - -

i4 - - o1

State Output

X: don’t care

Page 11: Sources  Gang Quan  Univ. of Notre Dame

Mealy Machine and Moore Mealy Machine and Moore MachineMachine

Mealy Machine– The output is a function of both the current

state and the inputMoore Machine

– The output is only a function of the current state

Page 12: Sources  Gang Quan  Univ. of Notre Dame

Transition Graph For Moore Transition Graph For Moore MachineMachine

Key_on

Key_off

Timer>5Timer>10, orbelt_on, orkey_off

Wait

Alarm/Start Alarm

Init/stop timerstop alarm

Timer/Start Timer Timer<=5

Page 13: Sources  Gang Quan  Univ. of Notre Dame

Mealy/Moore MachineMealy/Moore MachineAn FSM can be realized either by Mealy or

Moore machineMealy machine may use less flip-flops and

output signals are immediately after the transition

Moore machine may use more flip-flops and output signals valid except during the transition

Page 14: Sources  Gang Quan  Univ. of Notre Dame

Nondeterministic FSMNondeterministic FSM

Deterministic FSM– Given a state and input, there is exactly one next state

Nondeterministic FSM (NFSM)– Given a state and input, there maybe more than one

next state, or a state can transform from one state to anther without any input, or for some given input there no next state at all

For any NFSM, there is always one equivalent FSM

Page 15: Sources  Gang Quan  Univ. of Notre Dame

Nondeterministic FSMNondeterministic FSM

• For unknown/unspecified behavior• Less states, more compact• Useful for

• Optimization• Verification

• Can be refined• For any NFSM, there is always one

equivalent DFSM

Page 16: Sources  Gang Quan  Univ. of Notre Dame

NFSM and FSMNFSM and FSM

i0/o0

i1/o1

i2(i1+i2+i4)/o1

S1

S2

S0

i0/o0

i1/o1

i2i1/o1

S1

S2

S0

i2/o1

i4/o1

i0/i3/

i1/i2/

i3/

i4/

i0/i2/

i4/

Page 17: Sources  Gang Quan  Univ. of Notre Dame

EquivalenceEquivalence

Two FSMs are equivalent iff iff for any given input sequence, identical output sequences are produced

Page 18: Sources  Gang Quan  Univ. of Notre Dame

EquivalenceEquivalence

1/1

1/1

S1

S2

S0

S3

0/0 0/0

0/0

1/1

1/1

0/0

1/1 S1S0

0/0 1/1

0/0

Page 19: Sources  Gang Quan  Univ. of Notre Dame

MinimizationMinimization

What– Given an FSM, find the equivalent FSM with a

minimum number of states Two states s1 and s2 in an FSM are equivalent iff

each input sequence beginning from s1 yields an output sequence identical to that obtained by starting from s2

How

Page 20: Sources  Gang Quan  Univ. of Notre Dame

Minimization(Moore Machine)Minimization(Moore Machine) For each pair of the states (si,sj) If si and sj have different output Mark si and si as not equivalent End for Do for each unmarked pair for each input, si and sj are transferred to states which are not equivalent Mark si and sj as not equivalent end for end for until no mark is possible Unmarked pairs are equivalent

Page 21: Sources  Gang Quan  Univ. of Notre Dame

MinimizationMinimization

S0/0

S2/1 S3/1

S1/11

1

1

1

0

0

0

0

(s0, s1) (s0,s2) (s0,s3) (s1,s2) (s1,s3) (s2,s3)

Page 22: Sources  Gang Quan  Univ. of Notre Dame

MinimizationMinimization

S0/0

S2/1 S3/1

1

10

0,1 0

(s0, s1) (s0,s2) (s0,s3) (s1,s2) (s1,s3) (s2,s3)

Page 23: Sources  Gang Quan  Univ. of Notre Dame

•Review for Exams (1)Review for Exams (1)1. Finite State Machine Types

– Mealy– Moore– Rabin-Scott

2. Timing of Machine Synchronous Asynchronous Globally Asynchronous Locally Synchronous Memory in Logic

3. Determinism Deterministic Non-deterministic Probabilistic Entangled (only in quantum)

4. What is attached to Machine– Reactive Subsumption Architecture– Stack Machine– Turing Machine– Hybrid Machine

Page 24: Sources  Gang Quan  Univ. of Notre Dame

•Review for Exams (2)Review for Exams (2)1. What is minimization of a Finite State Machine?2. Show example of state minimization3. Show example of output minimization4. Show example of input minimization5. What is state assignment of FSM?

Remember that I do not require full procedures for minimization, verification, partitioning, decomposition or state assignment.

I require only understanding of these concepts.