1 / 75

Requirements Analysis and Design Engineering

Requirements Analysis and Design Engineering. Southern Methodist University CSE 7313. Module 15 – Modeling techniques – Finite state machines. Finite state machines. Finite State Machines (FSMs). Widely used specification technique Used to specify system behavior in response to events

janus
Télécharger la présentation

Requirements Analysis and Design Engineering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RequirementsAnalysis andDesignEngineering Southern Methodist University CSE 7313

  2. Module 15 – Modeling techniques – Finite state machines

  3. Finite state machines

  4. 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

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

  6. Can I interest you in our new long distance service? No thanks.

  7. Can I interest you in our new long distance service?

  8. Can I interest you in our new long distance service? Get Lost!!

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

  10. State Machines • Models how a system responds differently to events over time

  11. State Machines • Models how a system responds differently to events over time button switch

  12. States OFF ON

  13. States Press OFF ON Press

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

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

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

  17. FSM Diagram Event-1 State 1 State 2 Action-k

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

  19. ScenarioQuarters Only, 75 cents • Customer • enter quarter • Customer • enter quarter • Customer • enter quarter • Coke Machine • deliver coke

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

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

  22. State Transition Table

  23. Coke Machine Scenario 2Coin Return • Customer • enter quarter • Customer • enter quarter • Customer • press coin return (CR) • Coke Machine • return coins

  24. Enumerate Events & Actions Events:E1: Deposit 25 centsE2: Coin Return (CR) Actions: A1: Deliver coke A2: Return coins

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

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

  27. Transition Table • State E1 E2 • A B • B C A/coin return • C A/coke A/coin return

  28. Transition Table No BlanksAllowed !! • State E1 E2 • A B • B C A/coin return • C A/coke A/coin return

  29. Transition Table • State E1 E2 • A B A • B C A/coin return • C A/coke A/coin return

  30. Telephone System FSMLocal 4-digit exchange Events d: digit dialed h: hang up Actions c1: connect to caller

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

  32. Telephone System FSMLocal 4-digit exchange h d d d d/c1 A B C D E Events d: digit dialed h: hang up Actions c1: connect to caller StatesA: start B: 1 digit dialed C: 2 digits dialed D: 3 digits dialed E: call in progress

  33. Telephone System FSMLocal 4-digit exchange h d d d d/c1 A B C D E Events d: digit dialed h: hang up Actions c1: connect to caller StatesA: start B: 1 digit dialed C: 2 digits dialed D: 3 digits dialed E: call in progress

  34. 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

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

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

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

  38. Money Entered No Money (A)

  39. Money Entered 5 No Money (A) 10 CR

  40. C Money Entered 5 10 5 B 5 No Money (A) 10 CR

  41. First an Example • Safe with a combination • positions 1, 2, 3 • movements L(eft), R(ight) • combinations 1L, 2L, 3L, 1R, 2R, 3R • Combo is 1L, 3R, 2L • any other combo will set off alarm

  42. Finite State Machine representation of combination safe

  43. Transition Table for FSM

  44. Simple behavior sin(x) simple behavior does not depend on the state or history of the object State driven behavior can be divided into several disjoint sets A television can be in one of many different states (channels)

  45. State machines in software design • Ease of development; by decomposing the system into a finite number of states the problem is also decomposed. • Ease of testing; state machine representation of software systems allows testing to be done at the state level or at the system level by expanding the state machine concept. • Simple to understand; the behavior is easily decomposed into non-overlapping behavior. • Predictable behavior; each state is easier to understand than the whole system or object.

  46. Definition of a state “A state is a distinguishable, disjoint, orthogonal, ontological condition that persists for a significant period of time” - Bruce Powell Douglass, I-Logix * distinguishable; a state accepts its own set of inputs and has its own set of actions * disjoint; object can only be in one state at a time * orthogonal; states cannot overlap with one another * ontological; condition of existence

  47. Meely and Moore Models input x/output y Mealy model - outputs associated with transitions input x output y Moore model - outputs associated with states

  48. FSM in summary • FSM consists of • set of states, J • set of inputs, K • transition function, T • specifies next state given the current state and the current input • initial state, S • set of final states, F

  49. Back to the Safe example • Set of states J is {Safe Locked, A, B, Safe Unlocked, Sound Alarm} • Set of inputs K {1L, 1R, 2L, 2R, 3L, 3R} • Transition function T is the transition function • Initial state S is “Safe Locked” • Set of final states F {Safe Unlocked, Sound Alarm}

  50. More formally.. • A FSM is a 5-tuple (J, K, T, S, F) • J is a finite, nonempty set of state • K is a finite, nonempty set of inputs • T is a function from (J ~ F) X K into J called the transition function • S J in the initial state • F is the set of final states F J Î Í

More Related