232
+ Chapter 7: Soquential Logie Design
‘Example: Vending Machine Controle (Part 1)
Word Descsition
We are going to design a simple vending machine controller. The vending machine wil
sell bottles of water for 75¢. Customers can enter either a dolar bil or quarters. Once a
efficient smount of money i entered, the vending machine wil dlepence a bottle of water.
{the user entered a dolar i will return one quarter in change. "Money Receiver’ detects
When money has been entered, The receiver sends two logic signals to our ercut
indicating whether a dollar bil or quarter was received. A "Bottle Dispenser" system holds
the water Bates and wil release one bottle when is input signal is asserted. "Coin
Return” system holds quarters for change and will release one quarter wen its input signal
is asserted. The money receiver wil reject money fa dollar and quarter are entered
simultaneously or if dollars entered once the user has started entering quarters.
"Money Receiver —_ ‘Finite State Machine! Fe Ceene
Tht peel
om Ee
@ fous hn “CONE nrg
Change | Oe Waly oY
‘Slate Diagram and State Transition Table
“To implement this state machine, we will need an inal state that the machine wil walt in
unti a customer enters money (Wait). if dollaris entered, the machine wil assert the
Dispense’ signal to release a botle of water and assert the "Change" signal to give ane
{quarter in chenge. We do not need an adsitional state forthe condition of when a dollar is
‘ontored bocauco the machino wil eimply accor tho output eignale and rturn to tho Wait
‘slate. When the customer pays with quarters, our machine needs to keep track of how
many quarters have been received. We'll need two interim Stale that Keep track of how
many quarters have been entered (25¢ and 502). Once the third quarter has been entered,
‘our machine will asset the “Dispense” signal and retum tothe Wait state.
‘inpus) (Outputs)
|Current Statol@_in|O_in|Next State Dispense|Change
Wat 70) 0] wat | o 0
wat | o) 1] wat | 1 1
(oseense-s | wat | 1 | 0 | ase | o o
cee ae | O] x | 25¢ | 0 0
ae |i{x| so | o 0
soe | 0 x | Soe | 0 0
soe | 1 |x| wat | 4 0
‘Stato diagrams can be simplified by only drawing
lranstons wnen a signal is asserted.
Example 7.12
Vending Machine Controller (Part 1)74 Finte-State Machines = 233,
Example 7.13 provides the state encoding and next state logic synthesis for the simple vending
‘machine controler.
‘Slate Encoding
‘me current state ana te inputs To ma
Example: Vending Machine Controller (Part 2)
Let's encode the states in binary and name the current sta variables Q1_cur and Q0_cur
and the next state variables Q'1_nxt and Q0_nxt. In this table we ist out sl possible values
he table mare compete.
‘minimize the logic.
tar
tor, olLmat
i\ co or 110
of oo
ofofo
ufofo
who [
Example 713.
Vending Machine Controller (Part 2)
Curent Sisto [Input | Nox! Stato Cuts
[Or ear [OO cax]O af a] —[O% vat [ OO ra Dapenss [Charge]
Wary 0] 0 | 0] 0 |watlo | o ] 0 | 0
State Code Jwat| o | 0 | o| 3 |wat! o | o | 4 | 4
wat =o Jwat} o | o | {alae} o | 1 | o Jo
25¢ wat! o | o [1| 4% |wer! o | o | o | o
506 [25] -o-|-1 | o] 0 |zel-o | 1} 0] 0
ze) 0 | 1 [ol 1|ae} o | 1 | 0 | o
ze! o | 1 | t}ofse] 1} o | o | o
o| 1{i|4 fase] o | i | o | o
Se] a ose
soe) 1 | 0 Jo] 1 Jee] 1 | o | 0 | o
se! 1 | 0 | 1] o war] o | o | + | o
sel i | oliii|sel + |ol]olo
Next State Loaic
“The next state logic for this counter depends on both the current state variables and the
‘system input Up. We can again take advantage of don't cares forthe unused state code to
ora
qe Voie Sls
“bin coor i110
of ola
oto234 + Chaptor7: Sequential Logie Design
Example 7.14 shows the output logic synthesis and final logic diagram for the vending machine
controller,
Example: Vending Machine Controller (Part 3)
oui
ay Cie Pomme ge Stina
oof O 01x o oo] 0 o]x 0
oftofo Tx Po of@Po Px to
sof 0} O 1K TT vol ofofxfo
co out
ures
aerg cme
a tao
‘Next Stato Logic” “State Memory? “Output Logic’
Example 7.14
Vending Machine Controller (Part 3)