# Vending machine example

The problem is to design a Nabs dispenser. The Nabs machine has two inputs, x and y, which encode the following information:

xyMeaning
00nothing is happening
01nickel inserted
01dime inserted
11Nabs button pushed

There is a single output, z. When z is 0, the machine produces nothing. When z is 1, the machine outputs a package of Nabs.

Assume that Nabs cost 15 cents. Nabs are returned only if the Nabs button is pushed after 15 cents are deposited. Assume that this %!@%\$# machine returns no change and just keeps any money you deposit over 15 cents.

Draw the finite state machine for the Nabs dispenser below.

xyABzABJAKAJBKB
00000000?0?
00010010??0
0010010?00?
0011011?0?0
01000010?1?
01010101??1
0110011?01?
0111011?0?0
10000101?0?
10010111??0
1010011?01?
1011011?0?0
11000000?0?
11010010??0
1110010?00?
1111100?1?1

## The Equations

• z = Sigma(15)
• z = x y A B
• DA = Sigma(2, 3, 5, 6, 7, 8, 9, 10, 11, 14)
• DA = x' A + x' y B + x y' + A B'
• DB = Sigma(1, 3, 4, 6, 7, 9, 10, 11,13)
• DB = x' y B' + x' A B + x y' A + x A' B + y' B
• JA = Sigma(5, 8, 9)
• JA = d(2, 3, 6, 7, 10, 11, 14, 15)
• JA = x y' + x' y B
• KA = Sigma(15)
• KA = d(0, 1, 4, 5, 8, 9, 12, 13)
• KA = x y B
• JB = Sigma(4, 6, 10)
• JB = d(1, 3, 5, 7, 9, 11, 13, 15)
• JB = x' y + x y' A
• KB = Sigma(5, 15)
• KB = d(0, 2, 4, 6, 8, 10, 12, 14)
• KB = x' y A' + x y A

## Implementation with D flip-flops

Press here to retrieve a copy.

## Implementation with JK flip-flops

Press here to retrieve a copy.