Decision Tables
Decision Tables
Decision tables are compact and precise ways of modelling complicated logic, such
as that which you might use in a computer program. They do this by mapping the
different states of a program to an action that a program should perform. Decision
tables take on the following format:
Condition
alternatives
Actions
Action entries
Printer troubleshooter
Rules
Conditio
ns
Y Y Y Y N N N N
Y Y N N Y Y N N
Printer is unrecognised
Y N Y N Y N Y N
Actions
Check/replace ink
X X
X X
90 minutes
Y Y
Team A
Winning
Team B
Winning
Y Y
Draw
Actions
Game Over
Team A Wins
Team B Wins
Extra Time
Keep Playing
X X
Send email when Recipient address present, subject present, before 5:30pm
[Collapse]
Answer :
This question is open to interpretation, but you should have something resembling
this:
Rules
Conditio
ns
Address
Present
Y Y
Actions
Subject
Present
Before 5:30
Y Y Y
Send Mail
Error
Message
Y Y
X X
Make
pending
accept state. Not all FSMs will have an accepting state and it is possible they could
run forever.
A finite state machine can be with or without outputs:
Finite state automaton
Finite State Automaton - an FSM with no outputs
Tim
Grit
Grrrrrim
[Collapse]
Answer :
Mealy Machines
Mealy Machine - an FSM with outputs
Some FSMs output values dependant on the state and the input values:
The above Mealy Machine outputs a value for each input. You can tell which is which
by: input / ouput. So for the following input:
000101010
It outputs
000010101
Shifting all the bits right, and dividing the binary number input by two.
Exercise: Mealy Machines
For the Mealy machine above, what do the following inputs output:
1. 50
2. 20,10,20
3. 10,10,10,20
What does this machine do, what do the outputs tell you?
[Collapse]
Answer :
1. 0
2. 30,20,0
3. 40,30,20,0
This machine could be used to track the money going into a vending machine,
letting you know how much you have left to pay on a 50p chocolate bar
What is the difference between a mealy machine and a finite state automaton?
[Collapse]
Answer :
Extension: non-determinism
In this section we are learning about deterministic finite automaton. This means that
for a state and a valid input there is only one possible transition to take. There are
such things a nondeterministic finite automaton where, for a given input there are
multiple paths (or none) that could be taken:
Inp Current
ut State
Next
State
Outp
ut
S1
S2
null
S1
S1
null
S2
S1
null
S2
S3
null
[Collapse]
Answer :
Inp Current
ut State
Next
State
Outp
ut
S1
S2
null
S1
S1
null
S2
S1
null
S2
S2
null
[Collapse]
Answer :
Inp Current
ut State
Next
State
Outp
ut
S0
S2
S0
S1
S1
S2
S1
S1
S2
S2
S2
S1
Outp
ut
Timer Green
Green
null
Butto
Green
n
Yellow
null
Timer Yellow
Red
null
Timer Red
Green
null
Input
Current
State
[Collapse]
Answer :
You might have already cottoned on. This represents a traffic light system
Draw the FSM for the following state transition table:
Inp Current
ut State
Next
State
Outp
ut
q0
q0
null
q0
q1
null
q1
q2
null
q1
q1
null
q2
q1
null
q2
q1
null
[Collapse]
Answer :