Home › Practice › RTL Design › Candy machine

Candy machine

EasyRTLsequentialfsm

A candy costs 15. The machine takes nickels (5) and dimes (10), and gives 5 back if you overpay.

Concept first. The state of this machine is the credit collected so far: 0, 5 or 10 (at 15 the candy comes out, so 15 is never kept). A Mealy machine has outputs that depend on the state and on the input arriving right now: the same state of 10 gives nothing when nothing arrives, and a candy when a nickel arrives. Write the three states and, for each, what a nickel, a dime or nothing does. Which of those cases give a candy, and which also give change?

What to build.

Solve in your browser →

No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.

More in this track

← Metro gateDivisible by 3? →