Design the control for a newspaper vending machine. The newspaper costs 35 cents, which can be paid in any combination of nickels, dimes, and quarters. The customer presses a "start" button and then begins entering coins. Coin sorter logic indicates to the FSM whether a nickel, dime, or quarter has been deposited by asserting the corresponding signal when appropriate. If exact change is entered, the control asserts "unlatch" so the customer can take a paper. If the amount of money the customer inserts exceeds 35 cents, change is given if possible. If insufficient change is availiable, all money inserted by the customer is refunded.
Assume that the money inserted by the customer is kept separated from money inserted by previous customers, which are held in a coin repository. Change is given only in dimes and nickels; the number of nickels and dimes availiable for refund are decimally encoded in the signals "nickelChange2..nickelChange0" and "dimeChange1..dimeChange0". In the case that the customer inserts more money than the newspaper costs, the FSM pulses a "nickelRelease" and/or "dimeRelease" signal to release one coin of change at a time (it would jam the machine to release more than one coin at a time).
If insufficient change is available, all coins the customer has inserted are refunded by the FSM by asserting a "refundMoney" signal. Otherwise the customer's 35 cents are deposited in the coin repository as the FSM asserts a "depositCoins" signal.
A block diagram of the module would look as follows:
Implement the FSM as a synchronous Mealy machine and test it for two cases: (1) when two quarters are inserted and there is sufficient change, and (2) when two quarters are inserted and there is not sufficient change.
This problem is based on 8.27 of Katz.
We will implement the FSM using ABEL-HDL rather than using a schematic.
Now we will write a test fixture corresponding to the cases outlined in the problem definition.
Now we will simulate our design. Below are the waveforms corresponding to the first test case, where two quarters are inserted and there is sufficent change.
Here is a summary of what you see above:
Below are the waveforms for the second test case, where two quarters are inserted an insufficient change is availaible.
Here is a summary of what you see above:
t = 132: our FSM has returned to its wait state.