Hades logoHades applet banner
Traffic light controller (3/4, one-hot encoding)

applet icon

The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)

Circuit Description

Another traffic light controller based on a state machine with one-hot encoding. (Click the clock and nreset switches, or type the 'c' and 'r' bindkeys).

In a one-hot encoding, the number of flipflops is the same as the number of states of the automaton, only one of which is active. One advantage of this design style is that the design is straightforward and can be easily automated by design tools. It is also well matched to many programmable devices like FPGAs, which often include a flipflop in each of their basic blocks. Second, exactly two flipflops change state during a state transition, which often translates into high clock rates and low power consumption. A third advantage is that the output circuits are often very simple; for example, only two additional gates are required to drive the output LEDs of the traffic light controller.

The obvious drawback of the one-hot encoding is the required number of flipflops, which limits this design style to automata with a few dozen states.

Note that the one-hot state-machine used here is actually realized as a simple shift-register.

In order to initialize the circuit to a one-hot state after a reset, special care has to be taken for one of the flipflops. In the example circuit, the first flipflop (corresponding to the 'red' state) includes a preset input (DFFRS), while all other flipflops only have a reset input (DFFR). This ensures that only the first flipflop is set after a reset inpulse. Alternatively, we could have used the negative (NQ) output for the first flipflop. Naturally, for a traffic light controller, the all-red state is chosen as the reset state.

state       encoding       next state
            z3 z2 z1 z0   z3* z2* z1* z0*
red          0  0  0  1     0   0   1   0
red+yellow   0  0  1  0     0   1   0   0
green        0  1  0  0     1   0   0   0
yellow       1  0  0  0     0   0   0   1

Print version | Run this demo in the Hades editor (via Java WebStart)
Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German)
Impressum http://tams.informatik.uni-hamburg.de/applets/hades/webdemos/18-fsm/10-trafficlight/ampel_44.html