+ All Categories
Home > Documents > 3.1.1 Fundamentals of Problem Solving

3.1.1 Fundamentals of Problem Solving

Date post: 23-Feb-2016
Category:
Upload: angeni
View: 51 times
Download: 0 times
Share this document with a friend
Description:
AQA Computing COMP1. 3.1.1 Fundamentals of Problem Solving. Finite State Machines Denise Landau 2013. What is a Finite State Machine?. - PowerPoint PPT Presentation
Popular Tags:
21
Denise Landau 2013 Denise Landau 2013 3.1.1 Fundamentals of Problem Solving Finite State Machines Denise Landau 2013 AQA Computing COMP1
Transcript
Page 1: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013Denise Landau 2013

3.1.1 Fundamentals of Problem Solving

Finite State Machines

Denise Landau 2013

AQA Computing COMP1

Page 2: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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.

Page 3: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Mealy MachineMealy 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.

Page 4: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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

Page 5: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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

Page 6: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Finite State Machines with Outputs• When an FSM produces a response when making a transition, this is

an output.

Page 7: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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

Page 8: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Extension – Stretch and ChallengeTCP has been modelled using an Extended FSM1- 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 these 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.

Follow this link for more information: http://www.lisha.ufsc.br/teaching/dos/ine5357-2009-1/work/g2/final/TR2005-07-22-tcp-EFSM.pdf

Page 9: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

State Transition Diagrams• You must be able to draw and

interpret simple state transition diagrams• A finite state machine expressed

visually is a State transition diagram• Shows 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.

Page 10: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

State Transition DiagramsIn 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

110011001001110011

Page 11: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

State Transition DiagramsIt 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.

Page 12: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

State Transition DiagramsTry:

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

Page 13: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

State Transition Diagrams- ExerciseWhich of these inputs are valid:1. aaacdb2. ababacdaaac3. abcdb4. acda5. acdbdb

Page 14: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Exercise AnswerAnswer :1. aaacdb (CORRECT)2. ababacdaaac(CORRECT)3. abcdb (ERROR no input that accepts b then c)4. acda (ERROR S1 is not a accepting state)5. ac (CORRECT)

Page 15: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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.

Page 16: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

ExerciseCreate a state transition table for the following FSM:

Page 17: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Exercise Answer

Page 18: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

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]

Page 19: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Example: TurnstileThere 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.

Page 20: 3.1.1 Fundamentals of Problem Solving

Denise Landau 2013

Example: TurnstileThe 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


Recommended