Professional Documents
Culture Documents
Digital Systems: Topic 14: Vending Machine Design Problem
Digital Systems: Topic 14: Vending Machine Design Problem
Objectives
To design a Vending Machine Controller
Design the state diagram
Design the state table
Write the VHDL code
Simulate/test each module
8/18/2010
2 of 26
Design Description/Specifications
Vending Machine Controller
1.
2.
3.
4.
5.
6.
7.
8.
8/18/2010
3 of 26
3.
4.
5.
6.
8/18/2010
4 of 26
State Diagram
1.
2.
Reset
A
C
Qi
Cr
Qi
Cr
Qo
8.
Qi
Co
7.
Cr
D
E
3.
4.
5.
6.
CRo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
5 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
6 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
7 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
8 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
9 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
10 of 26
State Diagram
Reset
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
E
Qi
Co
K
Qo
C
B
B
Bo
H
Wo
G
W
Qi
I
Qo
J
Qo
8/18/2010
11 of 26
State Diagram
Reset
Qi
CRo
Cr
Qi
Cr
D
C
Cr
Qi
Co
C/Qo
B
F
Bo
B/Qo
G
W
Qi/Qo
H
Wo
8/18/2010
12 of 26
3.
4.
5.
6.
8/18/2010
13 of 26
State Table
Reset
We have:
8 states (3 state bits)
5 inputs (Cr, Qi, C, B, or W)
5 outputs (CRo, Qo, Wo, Bo, and Co)
A
C
Qi
CRo
Cr
Qi
Cr
Cr
D
C
Qi
Co
C/Qo
B
F
Bo
B/Qo
G
W
Qi/Qo
H
Wo
8/18/2010
14 of 26
3.
4.
5.
6.
8/18/2010
15 of 26
8/18/2010
16 of 26
8/18/2010
17 of 26
Simulation/Test
This is the 1st Test Bench
8/18/2010
18 of 26
Simulation/Test: Results
1st set of results
8/18/2010
19 of 26
Simulation/Test 2
This is the 2nd Test Bench
8/18/2010
20 of 26
Simulation/Test: Results 2
2nd set of results
RED:
5 quarters in: after 3, they start being returned
8/18/2010
21 of 26
Simulation/Test: Results 2
2nd set of results
RED:
5 quarters in: after 3, they start being returned
BLUE:
Buy a beer: another quarter is returned and a beer is dispensed
8/18/2010
22 of 26
Simulation/Test: Results 2
2nd set of results
RED:
4 more quarters in: after 3, they start being returned
8/18/2010
23 of 26
Simulation/Test: Results 2
2nd set of results
RED:
4 more quarters in: after 3, they start being returned
YELLOW:
Buy a cola, a quarter is returned and a cola is dispensed
8/18/2010
24 of 26
Simulation/Test: Results 2
2nd set of results
Magenta:
No quarters in: Buy water, nothing happens
Green:
Hit Coin Return, nothing happens
8/18/2010
25 of 26
Summary
In this topic we:
Designed a state machine that controls a
vending machine
Designed the state diagram
Designed the state table
Wrote the VHDL code
Looked at two new keywords
falling_edge
after Xns
Simulated and tested each module
8/18/2010
26 of 26