Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finite state machines. Finite State Machines (FSMs) Widely used specification technique Used to specify system behavior in response to events Both output.

Similar presentations


Presentation on theme: "Finite state machines. Finite State Machines (FSMs) Widely used specification technique Used to specify system behavior in response to events Both output."— Presentation transcript:

1 Finite state machines

2 Finite State Machines (FSMs) Widely used specification technique Used to specify system behavior in response to events Both output and next state can be determined solely on the basis of understanding the current state and the event that caused the transition H/W engineers have been using FSM for years

3 Can I interest you in our new long distance service?

4 No thanks.

5 Can I interest you in our new long distance service?

6 Get Lost!!

7 Can I interest you in our new long distance service? Get Lost!! Same stimulus event Different response

8 State Machines Models how a system responds differently to events over time

9 State Machines Models how a system responds differently to events over time button switch

10 States ON OFF

11 States ON OFF Press

12 Finite State Machines State –the memory of previous events Events –inputs to a system Actions –output in some form mechanical, electrical or software event

13 Finite State Machines State –the memory of previous events Events –inputs to a system Actions –output in some form mechanical, electrical or software event

14 Coke Machine Events –coin insertion Actions –coke delivery –coins returned State –the memory of how much money has been deposited

15 FSM Diagram State 1 State 2 Event-1 Action-k

16 FSM State 1 State 2 Event-1 Action-k Event-1 Not all state transitions have actions associated with them

17 Scenario Quarters Only, 75 cents Customer –enter quarter Customer –enter quarter Customer –enter quarter Coke Machine –deliver coke

18 Enumerate Events & Actions Events: E1:Deposit 25 cents Actions: A1:Deliver coke

19 Define States A B C Start State E1 E1/A1 States: A:No money B:25 cents entered C:50 cents entered Events: E1:Deposit 25 cents Actions: A1:Deliver coke

20 State Transition Table

21 Coke Machine Scenario 2 Coin Return Customer –enter quarter Customer –enter quarter Customer –press coin return (CR) Coke Machine –return coins

22 Enumerate Events & Actions Events: E1:Deposit 25 cents E2:Coin Return (CR) Actions: A1:Deliver coke A2: Return coins

23 Define States A B C Start State E1 E1/A1 States: A:No money B:25 cents entered C:50 cents entered Events: E1:Deposit 25 cents E2:Coin Return (CR) Actions: A1:Deliver coke A2: Return coins E2/A2

24 Define States A B C Start State E1 E1/A1 States: A:No money B:25 cents entered C:50 cents entered Events: E1:Deposit 25 cents E2:Coin Return (CR) Actions: A1:Deliver coke A2: Return coins E2/A2

25 Transition Table StateE1E2 AB BCA/coin return CA/cokeA/coin return

26 Transition Table l StateE1E2 l AB l BCA/coin return l CA/cokeA/coin return No Blanks Allowed !!

27 Transition Table StateE1E2 ABA BCA/coin return CA/cokeA/coin return

28 Telephone System FSM Local 4-digit exchange Events d:digit dialed h:hang up Actions c1:connect to caller

29 Telephone System FSM Local 4-digit exchange ABCDE dddd/c1 States A:start B:1 digit dialed C:2 digits dialed D:3 digits dialed E:call in progress Events d:digit dialed h:hang up Actions c1:connect to caller

30 Telephone System FSM Local 4-digit exchange ABCDE dddd/c1 h States A:start B:1 digit dialed C:2 digits dialed D:3 digits dialed E:call in progress Events d:digit dialed h:hang up Actions c1:connect to caller

31 Telephone System FSM Local 4-digit exchange ABCDE dddd/c1 h States A:start B:1 digit dialed C:2 digits dialed D:3 digits dialed E:call in progress Events d:digit dialed h:hang up Actions c1:connect to caller

32 Problems with FSMs The state explosion problem Confusing when too many states Requirements: –“in all airborne states, when the yellow handle is pulled, the seat will be ejected” maps event to large collection of states –“when the selection button is pressed, enter the selected mode” implies a clustering or grouping of states

33 Harel’s State Charts Allows grouping or clustering of states a b c b c A C B a b c c A C B D Clustering into new superstate D - really an abstraction. To be in D really means to be in either A or C

34 Coke Machine E D F 10 A B 5 C 5 5 10/coke 5/coke 5

35 Coke Machine A B E D F 5 10 C 5 5 10/coke 5/coke 5 CR ouch!

36 No Money (A) Money Entered

37 No Money (A) Money Entered 5 10 CR

38 No Money (A) Money Entered 5 10 CR B 510 C 5


Download ppt "Finite state machines. Finite State Machines (FSMs) Widely used specification technique Used to specify system behavior in response to events Both output."

Similar presentations


Ads by Google