Lab 4 A Traffic Light Controller

Task 1. Think about how many states the two-way traffic lights may have for each cycle. The green light on one side truns yellow and then turns red before the other light changes to green from red. The last state is crossed out because it repeats the first state.



This is a practice on combinational logic, truth table, K-map, and logic simplification. Show the code, code explanation, and demo video in your report. (20 points)
The regular mode:



G1 =
Y1 =
R1 =
G2 =
Y2 =
R2 =


Task 2. While the first problem cycles through all states with the same durations, during rush hours, the busy road has a longer duration for the green light than the red light. Use a switch to trigger the rush hour mode which keeps one of the green lights ON for double the duration compared to the other road. Show the code, code explanation, and demo video in your report. (20 points)

The rush hour mode:
The highlighted one is an added entry to keep the same state when the input is incremented by one.



G1 =
Y1 =
R1 =
G2 =
Y2 =
R2 =

The demo video



Task 3. The entire system could be easily controlled by a Finite Sate Machine (FSM).
The truth table only shows 6 different states. You can set up a 'reg' variable 'state' and direclty send a 6-digit binary number to the 6 led traffic lights based on the state.
In this task, please use the FSM strategy to implement Task 1. (20 points)

Task 4. Add a second counter just for the state when G1 and R2 are both on (rush hour mode for G1) to your FSM to implement the rush hour mode.(20 points)

Task 5. Add a switch to control your FSM rush hour mode. (20 points)