# 3.1.1 Fundamentals of Problem Solving PowerPoint Presentation

2016-08-01 38K 38 0 0

##### Description

Finite State . Machines. Denise Landau 2013. AQA Computing COMP1. What is a Finite State Machine?. A state machine is any device that stores the status of something at a given time, and can operate on input to change the status and/or cause to take place for any given change.. ID: 427902

Embed code:

DownloadNote - The PPT/PDF document "3.1.1 Fundamentals of Problem Solving" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

### Presentations text content in 3.1.1 Fundamentals of Problem Solving

Slide1

3.1.1 Fundamentals of Problem Solving

Finite State MachinesDenise Landau 2013

AQA Computing COMP1

Slide2

What is a Finite State Machine?

A state machine is any device that stores the status of something at a given time, and can operate on input to change the status and/or cause to take place for any given change.It consists of: states, input, and outputs

Suitable

for controlling processes that react to local conditions only

.

The machine is in only one state at a time – the

current

state

.

It can change from one state to another when initiated by a triggering event or condition – the

transition

.

Have

limited memory – which is limited by the number of states

.

Slide3

Mealy Machine

Mealy machine

is a

finite-state machine

whose output values are determined both by its current state and the current inputs

The Mealy machine is named after George H. Mealy, who presented the concept in a 1955 paper, “A Method for Synthesizing Sequential Circuits”.

This is in contrast to a Moore machine, which is an FSM whose output values are determined solely by its current state.

Slide4

Mealy Machine

A simple Mealy machine has one input and one output.

More complex Mealy machines can have multiple inputs as well as multiple outputs.

Mealy machines provide a rudimentary mathematical model for

cipher

machines - a Mealy machine can be designed that given a string of letters (a sequence of inputs) can process it into a ciphered string (a sequence of outputs

Slide5

Examples of FSM

Vending machines (dispense products when the proper combination of coins is deposited)Lifts (stop at the upper floors before going down)Traffic lights (change sequence when cars are waiting)Combination locks (numbers must be input in the right order)Protocols and communication systems (WLAN, Bluetooth, 3G, 4G)Satellites critical systems – modelled, implemented or tested using FSM

KEYWORD: Automation

Slide6

Finite State Machines with Outputs

When an FSM produces a response when making a transition, this is an output.

Slide7

Finite State Machines without Outputs

An FSM without outputs is called a Finite State Automaton (FSA)

Slide8

Extension – Stretch and Challenge

TCP has been modelled using an Extended FSM

1- Always remembers the current state in the variable (

CurrState

) and the previous state in the

variable (

PrevState

)

2- The TCP endpoint has unlimited buffer space (e.g., buffer space to queue SENDs and RECEIVEs is

always available

)

3- In any state, whenever a segment is sent, the segment is added to the Retransmission Queue (

Rexmt

Queue

) and

the retransmission timer (REXMT) is started.

4- The (REXMT TIMEOUT) event has been

modeled

in all states except (FIN-WAIT-2, TIME-WAIT,

CLOSED), since in the

s

e states the endpoint have already received an ACK of its FIN segment (i.e.,

will not

transmit any segments afterwards).

5- The (TIMEWAIT TIMEOUT)

event has been

modeled

in (TIME-WAIT) state only. In all other states,

this timer

is irrelevant

.

:

http://

www.lisha.ufsc.br/teaching/dos/ine5357-2009-1/work/g2/final/TR2005-07-22-tcp-EFSM.pdf

Slide9

State Transition Diagrams

You must be able to draw and interpret simple state transition diagramsA finite state machine expressed visually is a State transition diagramShows all the states, inputs and outputs. Not all FSMs will have an accept states and it is possible they could run for ever

1. Each

state is represented with a

circle

2. Each

transition

is shown with an arrow. Transitions are labelled with an input that causes a transition and possibly an output that results from it.

3. Double

circle signifies the accept state.

Slide10

State Transition Diagrams

In this diagram we can see that it starts in state S1An input of 1 will keep it in state oneAn input of 0 will move it to state S2Once in S2 an input of 1 will keep it there, and an input of 0 will switch it back to S1. This means that the following inputs are valid:

A finite state automaton (no outputs) accepting binary input

110011001

001110011

Slide11

State Transition Diagrams

It might appear to accept any binary value, but this isn't true. The only state it can accept in is state S1. This places the following rule on all accepted inputs: "A combination of binary digits involving an even number of zeros". This is useful for parity checks.

Slide12

State Transition Diagrams

Try: You will be stuck in state S2 and the FSM has not accepted.

110011011

The rules:

An

input of 1 will keep it in state one

An input of 0 will move it to state S2

Once in S2 an input of 1 will keep it there, and an input of 0 will switch it back to S1.

Slide13

State Transition Diagrams- Exercise

Which of these inputs are valid:aaacdbababacdaaacabcdbacdaacdbdb

Slide14

aaacdb

(CORRECT)

ababacdaaac

(CORRECT)

abcdb

(ERROR no input that accepts b then c)

acda

(ERROR S1 is not a accepting state)

ac (CORRECT)

Slide15

State Transition Tables

You must be able to draw and interpret simple state transition tables

A state

transition table is a table showing what state (or states

) finite

state machine will move to, based on the current state and other inputs.

It is essentially

a truth table in which some of the inputs are the current state, and the outputs include the next state, along with other outputs.

Slide16

Exercise

Create a state transition table for the following FSM:

Slide17

Slide18

Example: Turnstile

State diagram for a turnstile

A turnstile, used to control access to subways and amusement park rides, is a gate with three rotating arms at waist height, one across the entryway.

Initially the arms are locked, barring the entry, preventing customers from passing through. Depositing a coin or token in a slot on the turnstile unlocks the arms, allowing a single customer to push through. After the customer passes through, the arms are locked again until another coin is inserted.

Considered as a state machine, the turnstile has two states:

Locked

and

Unlocked

.

[2]

Slide19

Example: Turnstile

There are two inputs that affect its state: putting a coin in the slot (

coin

) and pushing the arm (

push

).

In the locked state, pushing on the arm has no effect; no matter how many times the input

push

is given, it stays in the locked state.

Putting a coin in – that is, giving the machine a

coin

input – shifts the state from

Locked

to

Unlocked

.

In the unlocked state, putting additional coins in has no effect; that is, giving additional

coin

inputs does not change the state.

However, a customer pushing through the arms, giving a

push

input, shifts the state back to

Locked

.

Slide20

Example: Turnstile

The turnstile state machine can be represented by a state transition table, showing for each state the new state and the output (action) resulting from each input

Slide21

References

http://www.swisseduc.ch/compscience

/

http://www.swisseduc.ch/compscience/karatojava/docs/programming_general_education.pdf

https://en.wikibooks.org/wiki/A-level_Computing/AQA/Problem_Solving,_Programming,_

Data_Representation_and_Practical_Exercise/Problem_Solving/Finite_state_machines