An Introduction to Finite State Machine Design

In any case,I never disallow beer outside class. Feel free to grab a cold can from your fridge before continuing the discussion. The bug we encounter at this point is well-known with contacts such as those in mechanical switches. As shown in Figure 6, at the instant a switch is pressed or released, it does not provide a clean transition between 0 and 1 logic. There is some transient period called the contact bounce that causes intermittent, indeterminate logic. Manufacturers may give worst-case bounce time in the datasheets. A good estimation could be around 20 milliseconds or so.

Figure 6: Contact bounces in a switch

To avoid reading the invalid logic, a switch debouncing scheme is needed. One could google for an implementation that suits his/her application. For example, our design above is in Verilog, so I prefer a debounce module written in the same language. Searching with “switch debounce Verilog” keyword gives me several URLs. I just pick the first one Debounce Logic Circuit (with Verilog example) and add the module DeBounce_v.v provided there in my project (the website also provides useful information on switch debounce so please read). The code fits in seemlessly. Click the file below to download the modified Verilog code (you must add the DeBounce_v.v from the link above to the XISE project yourself.)

This last video demonstrates the 3-way lighting FSM after the switch debouncing modules are added to both switches. Reliability is improved significantly. There are still some minor glitches when I pressed those switches like crazy, but that kind of operation is somewhat too extreme for sane humankind.

Eventually, the FSM now works as desired. The house owner is happy. And now the demanding dude asks if a 4-way lighting is possible. In addition to the A, B push button switches, he wants to be able to turn the light bulb on/off by touching the third button on the screen of his mobile phone. How could you modify the state diagram or ASM to accommodate his new request?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s