Learning the Art of Electronics: 19L.1.3 State Transition Diagram

The only uncertainty is, what should happen if both buttons are pressed simultaneously (i.e. within a single state cycle) while in State A? However, the directions state that “[i]f the second player presses the STOP pushbutton before the DURATION LED lights, the red CHEAT LED should light.” The duration LED does not light until State B, so if both buttons are pressed simultaneously in State A, it is a cheat.

To test if your directed graph is correct, read the specification and apply it against the graph. Remember that the clock will have multiple rising edges while you are pressing the buttons. If you follow the directed graph and see what happens if a button bounces, you should find that you do not have to debounce the stop or start pushbuttons. The only state that looks at the start pushbutton is A. Once out of State A, it is ignored so bounces have no ill effect. Similarly, once stop is pressed in States A or B, it is ignored and bounces have no effect on the operation of the FSM.

Since the FSM only looks at the state of the buttons on the rising edge of the clock, there could be as much as slightly less than two full clock cycles error in the timing of the logic worst case. That means that you want to run the FSM at the highest clock frequency possible. Since the breadboard function generator can run as high as 100kHz, you probably will not be concerned about a 10uSec error given that human reaction time is on the order of 200mSec in the fastest individuals, but if you really want to minimize the error, use the 16MHz wr_clk on pin 13 of the WebFPGA.

image