## EE 231

Homework Assignment 10
Due Nov. 5, 2008

1. Design a synchronous sequential circuit to control the operation of a vending machine. The vending machine sells a cup of coffee for 15 cents. It has two input slots, one which will take dimes and the other which will take nickels. There are two outputs -- one to dispense the cup of coffee, and the second to give a nickel in change if 20 cents is inserted. If 15 cents is inserted (one dime and one nickel in any order, or three nickels), the dispense output should go high, and the change output should stay low. If 20 cents is inserted (two dimes, or two nickels followed by a dime), both the dispense output and the change output should go high. Design this as a Moore machine.
1. Draw a state diagram for the circuit.
2. Draw a state transition table for the circuit.
3. How many flip-flops are needed?
4. Derive equations for the next state, assuming use of D flip-flops.
5. Write a Verilog program to implement the circuit.
2. Design a synchronous sequential circuit to generate a serial even parity bit. The system has one input and one output. While no data is coming in, the input is high. The input will go low (called a start bit) before the real data comes. The start bit will be followed by seven data bits, then another low bit (space for the parity bit), then a high bit (the stop bit). Your circuit should put out the same sequence of data, except it should fill in the parity bit. The parity bit should be a 0 if the seven data bits has an even number of ones, and it should be a 1 if the seven data bits has an odd number of ones. After transmitting the final bit, it should go back to the state where it is waiting for another data word to come in. It is probably easier to design this as a Mealy machine. Here is an example of the input and output from the system. The input was 10011000, which has an odd number of ones, so the system inserted another one into the eighth bit.
1. Draw a state diagrm for the circuit
2. From the state diagram, write a Verilog program to implement the circuit.

Bill Rison, <rison@ee.nmt.edu >