Draft preview. Lessons are being written and reviewed.

Verilog practice / Problem 33

HardFSM

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

NameDirectionBits
clkinput1
rstinput1
coininput2
vendoutput1
changeoutput1

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