Hardware Reference
In-Depth Information
section 1.3. However, it exhibits a major problem, which is state bypass (see section
4.2.4). For example, if the door is closed and a long (lasting several clock cycles) remt
= '1' command is received, the machine goes around the entire loop. Of course, if a
one-shot circuit (section 5.4.3) is used to reduce the duration of remt to a single clock
period, then this machine is i ne.
A corrected diagram is presented in i gure 5.9c, containing additional states that
wait for remt to return to zero before proceeding, thus eliminating the state-bypass
problem. This is a Moore machine because there is no reason to employ an asynchro-
nous solution in this kind of application. Glitches at the output are not a problem
here, so the optional output register is not needed.
A good practice in this kind of application is to include debouncers for the signals
coming from the remote control and from the sensors, which not only eliminate the
need for synchronizers but also prevent short input glitches (due to lightning or the
switching of large electric currents, for example) from activating the machine (in this
case, it has to be a full debouncer, like that in section 8.11.3, for example).
Because the machine of i gure 5.9c has M FSM = 8 states, the required number of DFFs
is N FSM = 3 if sequential or Gray encoding is used, 4 for Johnson, or 8 for one-hot.
VHDL and SystemVerilog implementations for this garage door controller are pre-
sented in sections 6.7 and 7.6, respectively.
5.4.6 Vending Machine Controller
This example deals with a controller for a vending machine. It is assumed that it sells
candy bars for the single price of $0.40, accepting nickel, dime, and quarter coins.
The circuit ports are depicted in i gure 5.10a. The inputs nickel_in , dime_in , and
quarter_in are generated by the coin collector, informing the type of coin that was
deposited by the customer. The inputs nickel_out and dime_out are generated by the
coin dispenser mechanism, informing the type of coin that was returned to the cus-
tomer. The last nonoperational input is candy_out , produced by the candy dispenser
mechanism, informing that a candy was delivered to the customer. The outputs
disp_nickel and disp_dime tell the coin dispenser mechanism that a nickel or a dime
must be returned to the customer, while the output disp_candy tells the candy bar
dispenser mechanism that a candy bar must be delivered to the customer.
A corresponding Moore machine is presented in i gure 5.10b. To simplify the nota-
tion, numbers were used instead of names (see other examples of equivalent state
diagram representations in section 1.4). The state names correspond to the accumu-
lated amount ( credit ). The transition conditions refer to the last coin entered, with
negative values indicating change returned to the customer. In the coin-return opera-
tions it was opted to deliver the largest coins possible. After the machine reaches the
state 40 (thick circle), the only way to return to the initial state is by receiving a
Search WWH ::




Custom Search