Docsity

Sample Design: A Controller for a Simple Traffic Light | CPSC 5155G, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Sample Design: A Controller for a Simple Traffic Light | CPSC 5155G and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Sample Design:

A Controller for a Simple Traffic Light

Assumption: Two Linked Pairs of Traffic Lights

If one light is Green, the “cross light” must be Red.

Name the States

State Light 1 Light 2 Alias

0 Red Red RR

1 Red Green RG

2 Red Yellow RY

3 Red Red RR

4 Green Red GR

5 Yellow Red YR

Step 1a: State Diagram for the System

Notation: L 1 L 2 , so RG  Light 1 is Red and Light 2 is Green The six–state design is more easily implemented.

Step 2: Count the States and

Determine the Flip–Flop Count

There are six states, so we have N = 6. Solve 2 P– < N  2 P for P, the number of flip–flops. 2 P– < 6  2 P gives P = 3, because 2 2 < 6  2 3 . We denote the states by Q 2 Q 1 Q 0 , because the symbol “Y” is taken to indicate the color Yellow.

Step 3: Assign a 3–bit Binary Number

to Each State

This is a modified counter, so the assignments are quite obvious. State Q 2 Q 1 Q 0 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 We have two possible additional states: 6 and 7. Normally, these are ignored, but we consider them due to safety constraints.

Step 4a: Derive the Output Equations.

Alias Q 2 Q 1 Q 0 R1 G1 Y1 R2 G2 Y

0 RR 0 0 0 1 0 0 1 0 0

1 RG 0 0 1 1 0 0 0 1 0

2 RY 0 1 0 1 0 0 0 0 1

3 RR 0 1 1 1 0 0 1 0 0

4 GR 1 0 0 0 1 0 1 0 0

5 YR 1 0 1 0 0 1 1 0 0

6 RR 1 1 0 1 0 0 1 0 0

7 RR 1 1 1 1 0 0 1 0 0

Here are the output equations G1 = Q 2 Q 1 ’Q 0 ’ G2 = Q 2 ’Q 1 ’Q 0 Y1 = Q 2 Q 1 ’Q 0 Y2 = Q 2 ’Q 1 Q 0 ’ R1 = (G1 + Y1)’ R2 = (G2 + Y2)’

Step 4a: Derive the Output Equations.

(page 2)

Here are the equations again. G1 = Q 2 Q 1 ’Q 0 ’ G2 = Q 2 ’Q 1 ’Q 0 Y1 = Q 2 Q 1 ’Q 0 Y2 = Q 2 ’Q 1 Q 0 ’ R1 = (G1 + Y1)’ R2 = (G2 + Y2)’ We derive the Green and Yellow signals, which are easier. We stipulate that if a light is not Green or Yellow, it must be Red. Now add a safety constraint: If a light is Green or Yellow, the cross light must be Red. R1 = (G1 + Y1)’ + G2 + Y2, and R2 = (G2 + Y2)’ + G1 + Y These equations may lead to a light showing two colors. This is obviously an error situation.

Step 5: Separate the Table into Three Tables

Q 2 Q 1 Q 0

PS NS PS NS PS NS

Q 2 Q 1 Q 0 Q 2 Q 2 Q 1 Q 0 Q 1 Q 2 Q 1 Q 0 Q 0

Color added to emphasize the transitions of interest.

Step 6: Select the Flip–Flops to Use

Use JK flip–flops. What a surprise! The excitation table for a JK flip-flop is given again. Q(T) Q(T + 1) J K 0 0 0 d 0 1 1 d 1 0 d 1 1 1 d 0

Step 8: Derive the Input Equations

Here they are J 2 = Q 1  Q 0 J 1 = Q 2 ’  Q 0 J 0 = Q 2 ’ + Q 1 ’ K 2 = Q 1 + Q 0 K 1 = Q 2 + Q 0 K 0 = 1 There is no need to summarize the equations.

Step 10: Draw the Circuit