finite-state machines

Post on 05-Jan-2016

23 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Finite-state Machines. Chapter 14. Designing with FSMs. Finite state machines are ideal for reactive systems. A typical way of thinking about an FSM is “state-stimulus-response”: In a particular state , a stimulus will provoke a particular response. Formal Finite-state Automata. - PowerPoint PPT Presentation

TRANSCRIPT

Finite-state Machines

Chapter 14

Designing with FSMs Finite state machines are ideal for reactive

systems. A typical way of thinking about an FSM is

“state-stimulus-response”: In a particular state, a stimulus will provoke a particular response.

Formal Finite-state Automata Simple graphical representation:

State A State B

Simulus/Response

Example FSM specification The controller will respond to a over-

temperature condition with a system shutdown reaction.

Normal Operation

Emergency Shutdown

System over temperature / Emergency Shutdown

Model Checking FSM has a basis in mathematics: Finite state

automata. This allows checking for forbidden conditions.

FSMs must be deterministic: for each and every state, there must be one and only one response for that simulus in that state.

As FSMs become more complex, manual checking for determinism becomes more and more difficult, so automation of checking is more desirable.

Coding an FSM Design FSM code lends itself to automatic generation

by tools. Hand-coded FSMs are often table driven, with

two sets of tables, one representing the state-response relationship (indexed by stimulus), the other representing the current state-next state relationship (also indexed by stimulus).

Finite State Machine with Pseudo code

A B C

z/S

s/Q y/R

A: Get next event E CASE E OF x: Do action Q GOTO B z: Do action S GOTO C ESAC Print ‘Illegal first event’ and abortB: Get next event if not y THEN Print ‘Event must be y’ and abort FI Do action R GOTO C C: IF any next event THEN Print ‘No more events allow3ed’ and abort FI

Page 55, Figure 2.2 State Diagrams for Alarm Clock Example

States for the Tool Booth Controller

State Diagram for Toll Booth Controller

top related