Verilog practice / Problem 33
Vending machine
An item costs 15. On each rising edge coin shows what was inserted: 0 for nothing, 1 for a 5 coin, 2 for a 10 coin. When the money collected, including this coin, reaches 15 or more, the machine sets vend to 1 for the next cycle, sets change to 1 in that same cycle if it collected 20, and starts again from 0. Otherwise vend and change are 0. Reset clears everything.
Ports
| Name | Direction | Bits |
|---|---|---|
clk | input | 1 |
rst | input | 1 |
coin | input | 2 |
vend | output | 1 |
change | output | 1 |
How it's checked
Each cycle: the test sets the inputs, waits for your logic to settle, checks the outputs, then gives one rising clock edge. It holds rst high for the first two cycles and once more later on.
Stuck? Read the lesson Traffic light and vending machine.
vending.vCtrl + Enter runs