Figure 78 shows a single lane road with a pedestrian crossing. Road traffic and pedestrians are controlled by light signals. Pedestrians may request to cross the road by pressing a walk button W.
The traffic lights are controlled by a synchronous state machine, with state diagram as shown in Figure 79.
This is very much idealised. The system should go to the state corresponding to R, HALT on RESET or power up.
The next state/output table for the pedx controller is as follows:
Present state | next state | output |
s0 | s0 if , | G, HALT |
else s1 if W | ||
s1 | s2 | Y, HALT |
s2 | s3 | R, WALK |
s3 | s0 | R, HALT |
Let's do something different and use two falling edge triggered JK flip flops with active low preset and preclear as memory elements. Use AB as a pair of state variables to label the flip flops, with natural binary as our coding (in this example this turns out not to be the best choice, as we will see). We need to work out the next state and output logic, making use of the state transition table for the JK flip flop.
The binary version of the next state/output table is as follows:
Present state | next state | G | Y | R | WALK | HALT |
00 | 00 if W=0, | 1 | 0 | 0 | 0 | 1 |
else 01 if W=1 | ||||||
01 | 10 | 0 | 1 | 0 | 0 | 1 |
10 | 11 | 0 | 0 | 1 | 1 | 0 |
11 | 00 | 0 | 0 | 1 | 0 | 1 |
The k-maps for the Boolean functions JA, KA, JB, KB are shown in Figure 80.
This gives:
The k-maps for the output signals are shown in Figure 81.
This gives:
A circuit diagram of the pedx controller is given in Figure 82.
Some practical issues.
Output race glitches may occur in the output signals, e.g. HALT.
Consider the transition
Since we can't predict which path the machine will take, we may or may not get a glitch as the figure shows.
Exercise. Examine other outputs for possible glitches (either due to races, or hazards in the output logic).
Question? Will glitches cause problems?
This depends on what the signals are used for.
How to avoid problems with glitches (if necessary).
A better choice of code in this example would be the Gray code:
State | old code | new (Gray) code |
s0 | 00 | 00 |
s1 | 01 | 01 |
s2 | 10 | 11 |
s3 | 11 | 10 |
Use of this new coding will result in a design free of races, and race glitches.
Sometimes it might be necesssary to add additional states called fly states to achieve this, Figure 84.
ANU Engineering - ENGN3213