FSM Example - Vending Machine Controller

Block Diagram

State Diagram

Next State Table

PS NS NS NS release candy return all coins return change
0 0 if (coin = 0) and (return = 0) 1 if (coin=1) and (return = 0) 5 if (coin= 0) and (return= 1) 0 0 0
1 0 if sum < 75 2 if sum=75 3 if sum>75 0 0 0
2 0 - - 1 0 0
3 4 if change available = 1 5 if change available = 0 - 0 0 0
4 2 - - 0 0 1
5 0 - - 0 1 0

Simulator

the machine at state S0.

Coin no yes

Return no yes

Change available no yes

Money sum < 75 sum = 75 sum > 75

and see the result:

coin return change available sum < 75 sum = 75 sum > 75 staterelease candy return all coins return change

Continue: select a new input value and simulate (clicking simulate applies the CLOCK signal, unshown).

Reference: M. Ercegovac, T. Lang, and J.H. Moreno, Introduction to Digital Systems, Wiley, 1998.