SYSC3313 - Chapter 7 Finite State Machines

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:54 PM on 4/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

31 Terms

1
New cards

Reactive system

Continuously responds to events from the environment. Behavior can be defined in terms of states and transitions rather than sequential computations.

2
New cards

Finite state machine

Mathematical and graphical framework for modelling reactive behavior. Uses states and describes how inputs trigger state changes.

3
New cards

Reactive System context

Can be described using a finite set of states

4
New cards

FSM basics

  • finite set of states describe a system

  • always in only one state at a time

  • state transitions happen due to events or conditions

  • state diagrams can visualize states and transitions as nodes and directed edges

5
New cards

Light bulb FSM example

2 states: ON and OFF

ON to OFF transition: Press button

OFF to ON transition: Press button

<p>2 states: ON and OFF</p><p>ON to OFF transition: Press button</p><p>OFF to ON transition: Press button</p>
6
New cards

Safe FSM example
A safe that is locked with the code 2-0-1-7

knowt flashcard image
7
New cards

Deterministic Finite state machine (Deterministic Finite automation)

The next state is uniquely determine by the current state and input. A single, well-defined execution path.

Also called finite acceptors because they accept or reject input strings.

8
New cards

Finite acceptor

A deterministic FSM. It accepts or rejects input strings. Suitable for embedded systems because of deterministic behavior.

9
New cards

DFA Key elements

  • finite set of states

  • finite set of input symbols

  • transition function

  • initial state specifies execution start

  • set of final states defines acceptance conditions

10
New cards

DFA transition function

Maps state and input symbol pair to a unique next state.

11
New cards

DFA benefits

Rigorous reasoning about system behavior. Supports formal analysis and verification.

12
New cards

Mathematical model of DFA

M = (Q, sum, delta, q0, F)

Q: set of finite states

sum: a finite set of symbols for inputs

delta: Q * delta aka transition function

q0: initial state which is in the set Q

F: is the set of final states

<p>M = (Q, sum, delta, q0, F)</p><p>Q: set of finite states</p><p>sum: a finite set of symbols for inputs</p><p>delta: Q * delta aka transition function</p><p>q0: initial state which is in the set Q</p><p>F: is the set of final states</p><p></p>
13
New cards
<p>Example Mathematical model for DFA</p>

Example Mathematical model for DFA

knowt flashcard image
14
New cards

State transition table

Tabular form of state transition diagramB

15
New cards

Benefit of state transition tables

Useful for implementation and analysis. Compact and precise representation of system behavior.

16
New cards

Types of FSMs that generate outputs

  • Moore

  • Mealy

The two can be converted from one to the other

17
New cards

Moore machine

A DFA whose output depends only on the current state.

The output is generated when entering the state.

18
New cards

Mealy Machine

A DFA whose output depends on the current input as well as the current state.

Outputs are associated with transitions rather than states. As opposed to Mealy machines where the output is within the state node.

19
New cards

Moore machine benefits

Easy to analyze because output timing is state based.

20
New cards

Moore machine uses

When outputs should be stable between transitions

21
New cards

Moore machine mathematical model

M = (Q, sum, O, delta, lambda, q0)

Q is a finite set of states

sum is a finite set of input symbols

O is a finite set of output symbols

delta is Qxsum aka transition function that produces Q

lambda is Q→O, the output function

q0 is the initial state that is in the set Q

Notice how there is no final state, since it’s not an acceptor (language recognizer) but a producer of outputs.

22
New cards

Mealy Machine mathematical model

M = (Q, sum, O, delta, lambda, q0)

Q is a finite set of states

sum is a finite set of input symbols

O is a finite set of output symbols

delta is Qxsum→Q aka transition function

lambda is Qxsum→O, the output function

q0 is the initial state that is in the set Q

Notice how there is no final state. The difference with Moore is in the lambda function which also uses the input.

23
New cards

Moore vs Mealy machine decision flow

knowt flashcard image
24
New cards

Moore Machine Vending Machine Example

A vending machine sells candy bars for 20 cents and accepts 5c, 10c, and 25c coins. The states represent the accumulated balance (0c, 5c, 10c, 15c). When the total inserted reaches or exceeds 20 cents it should dispense the candy bar and any change then return to state 0c. No output otherwise.

Draw the state diagram

knowt flashcard image
25
New cards

Mealy Machine of a Seat Belt reminder system

  • Initial state is car engine off

  • The driver can turn the car on or put the seat belt on

  • If engine is on and driver is not seat belted, buzzer timer turns on. If driver put the belt on before timer expiry, the the timer turns off

  • If timer expires, buzzer turns on. When belted, buzzer turns off

  • If the car is turned off at any point, the timer or buzzer is turned off

  • The driver can unbuckle at any point

  • The drive cannot leave the seat while buckled or engine is on

Draw the FSM diagram

<p></p>
26
New cards

Nondeterministic finite automation

A state and input may lead to multiple possible next states. Transitions can also occur without any input event.

Every NDFA has an equivalent DFA

<p>A state and input may lead to multiple possible next states. Transitions can also occur without any input event.</p><p>Every NDFA has an equivalent DFA</p>
27
New cards

Uses for NDFA

Model unspecified or uncertain behavior. More compact but not directly implementable.

28
New cards

How to program FSM

  • conditional statements, handling state and input combinations →difficult to maintain with more complexity

29
New cards

Downsides of using conditional statements for FSM code

Difficult to maintain as system complexity grows

30
New cards

Table based FSM cocde

Table indexes states and input events to determine the transition function. Control logic is separate from state transition data.

State machine diagram becomes a matrix of actions.

Table row has current states, the columns have inputs events. Each entry contain what should happen, aka the function that should be called.

You would make the entries into pointers (ie just put function name).

What should be in the function? Any required actions + change the current state (global variable)

To define/implement:

  • states and events as enums

  • define the transtion table as an array of arrays

  • define each function in the transition table

  • in main(), in a loop, get the event, then call the function from the table according to the gotten event.

<p>Table indexes states and input events to determine the transition function. Control logic is separate from state transition data.</p><p>State machine diagram becomes a matrix of actions.</p><p>Table row has current states, the columns have inputs events. Each entry contain what should happen, aka the function that should be called.</p><p>You would make the entries into pointers (ie just put function name).</p><p>What should be in the function? Any required actions + change the current state (global variable)</p><p>To define/implement:</p><ul><li><p>states and events as enums</p></li><li><p>define the transtion table as an array of arrays</p></li><li><p>define each function in the transition table</p></li><li><p>in main(), in a loop, get the event, then call the function from the table according to the gotten event.</p></li></ul><p></p>
31
New cards

Benefit of table driven implementation of FSM

No need for long, nested, complex switch statements

Control logic is separate from state transition data. Improved readability and maintainability.