Trafficlight Hardware
Trafficlight Hardware
In this lecture we will work through a design example from problem statement to digital circuits.
The Problem: The traffic department is trying out a new system of traffic lights based on the usual European
model. We have to design a synchronous digital circuit, a Moore machine, which operates this new type of traffic
light at two types of road crossing road crossing.
There are six lights to operate. The Red, Amber, and Green lights in the North-South direction will be
designated as R1, A1, G1. Similarly, the lights in the East-West direction will be called R2, A2, and G2. When
the digital signals are in the Logic-1 state they turn their respective lights on, otherwise the lights are off. A
digital clock signal will be supplied and at each clock pulse the lights should change according the schedule
given above. There are two types of road crossing: quiet crossings that use a simple sequence, and busy
crossings require a longer (delayed green) sequence. One digital input signal called J (for junction type) will
indicate whether the road crossing is considered quiet, J=0 denotes a busy junction. Thus, we have a one-input,
six-output synchronous system to design.
Step 1: Formalise the problem and decide how many states you need.
Most problems are first specified in a loose verbal form which must be made more rigorous. A good first step in
this direction is to determine the number of states required. Sometime the determination of the minimum number
of states may be very difficult. However, our problem is simple enough to determine the states easily. Looking at
the original specification, we see that there are six states (light
patterns) for the busy intersection, and four states in the quiet State R1 A1 G1 R2 A2 G2
junction. However we do not need ten states because all four states 1 1 0 0 0 0 1
required for the quiet junction are also used in the busy junction. We 2 1 0 0 0 1 0
need only six states. Let us number them 1 to 6 as shown in the 3 1 0 0 1 0 0
table. Two states (3 and 6) have exactly the same traffic light outputs. 4 0 0 1 1 0 0
Could they be merged as one state? The answer is no, unfortunately, 5 0 1 0 1 0 0
because the state after 3 is 4 while the state after 6 is 1. 6 1 0 0 1 0 0
Step 3: Select the type and number of flip-flops for the circuit.
Since the number of states is equal to six, the minimum number of flip-flops,
which can support six states, is three. The maximum number of flip-flops
one may use is six (one flip-flop per state), though this implementation
would clearly be wasteful and so we will use three D-type flip-flops. There
will be two unused states.
Step 4: Assign state numbers to flip-flop outputs and construct the transition table.
There are some heuristic rules for assigning states to flip-flop outputs, but they are difficult to apply and do not
guarantee a minimum circuit. One rule is to maximise the number of 1s. The idea is that a large number of 1s
DOC112: Computer Hardware Lecture 10 Page 1
may provide easier minimisation in the Karnaugh maps for the state sequencing logic. On this basis we will not
use the states 000 and 001. The rest of the flip-flop outputs are assigned in order while constructing the
transition table.
J State (t) Q1 Q2 Q3 State (t+1) D1 D2 D3
0 7 0 0 0 X X X X
0 8 0 0 1 X X X X
0 1 0 1 0 2 0 1 1
0 2 0 1 1 3 1 0 0
0 3 1 0 0 4 1 0 1
0 4 1 0 1 5 1 1 0
0 5 1 1 0 6 1 1 1
0 6 1 1 1 1 0 1 0
1 7 0 0 0 X X X X
1 8 0 0 1 X X X X
1 1 0 1 0 2 0 1 1
1 2 0 1 1 4 1 0 1
1 3 1 0 0 X X X X
1 4 1 0 1 5 1 1 0
1 5 1 1 0 1 0 1 0
1 6 1 1 1 X X X X
Step 6: Construct the Diagram for all States (including don't cares).
Once the minimisation has been done, we can replace the "don't care" outputs in the Karnaugh maps with the
actual values we will get out of the circuit. Any don’t care inside a circle is replaced with 1, and any outside all
circles is replaced with 0. We have now a completely defined a sequential circuit and we should check whether
the system behaves correctly even if it starts from one of the unused states. A convenient way of checking this is
by constructing the complete transition diagram in which the unused states 7 and 8 are also included.
The Karnaugh maps now have a value for each of the don’t care states we used in the design, so we can re-build
the state transition table from them and draw the finite state machine that includes the unused states.
Disaster strikes! If the J input is logic 1 (quiet crossing) and the system
finds itself in state 3, for example when switched on, then it will be stuck
in state 3. We have to go back and change some "don't care" bit(s) to fix
the problem. This will mean revising our circles and the minimal
equations. The problem occurs at Karnaugh map entry 1100. Looking at
the three maps, we can see that by changing the 0 indicated for D3 to a 1
will cause the circuit to go to state 4 from state 3 when the safe input is 1.
This fixes the problem and causes minimal damage (i.e. will add one
extra term to the expression).
State Q1 Q2 Q3 R1 A1 G1 R2 A2 G2
1 0 1 0 1 0 0 0 0 1
2 0 1 1 1 0 0 0 1 0
3 1 0 0 1 0 0 1 0 0
4 1 0 1 0 0 1 1 0 0
5 1 1 0 0 1 0 1 0 0
6 1 1 1 1 0 0 1 0 0
7 0 0 0 X X X X X X
8 0 0 1 X X X X X X
The output circuits are quite a lot simpler and smaller, but of course, we have to redesign the state sequencing
logic circuitry with the new flip-flop state assignments.
J State (t) Q1 Q2 Q3 State (t+1) D1 D2 D3
0 7 0 0 0 X X X X
0 8 0 0 1 X X X X
0 1 1 0 0 2 1 0 1
0 2 1 0 1 3 1 1 1
0 3 1 1 1 4 0 1 1
0 4 0 1 1 5 0 1 0
0 5 0 1 0 6 1 1 0
0 6 1 1 0 1 1 0 0
1 7 0 0 0 X X X X
1 8 0 0 1 X X X X
1 1 1 0 0 2 1 0 1
1 2 1 0 1 4 0 1 1
1 3 1 1 1 X X X X
1 4 0 1 1 5 0 1 0
1 5 0 1 0 1 1 0 0
1 6 1 1 0 X X X X