Hades logo    Hades applet banner

TAMS / Java / Hades / applets (print version): contents | previous | next

Traffic light controller (3/4, one-hot encoding)

Traffic light controller (3/4, one-hot encoding) screenshot

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

Run the applet | Run the editor (via Webstart)


Impressum | 24.11.06
http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/18-fsm/10-trafficlight/ampel_44_print.html