This repository contains a VHDL project that simulates a traffic light controller. This kind of traffic light controller, which includes functionality to detect the presence of emergency vehicles and alter the normal operation cycle of traffic signals, can be considered a "smart" traffic system. The incorporation of sensors and logic to prioritize emergency vehicles is an innovative feature that is becoming more common in modern traffic systems.
The core of the traffic light controller is a state machine that navigates through a series of states to control the lights according to a set of defined rules. The SM logic takes into account the following sequence:
- Normal Operation: The green light on University Avenue stays on for five cycles unless interrupted by an emergency vehicle on 17th Street (EV signal is high), which causes an immediate transition to yellow.
- Car Waiting: After five green cycles, if a car is waiting (CW signal is high), the light transitions to yellow; otherwise, it cycles back to green.
- Yellow Phase: The yellow light remains active for two cycles before switching to red.
- Red Phase: The red light is on for four cycles.
- Emergency Override: If an emergency vehicle is detected, the red light stays on until the vehicle clears the intersection. The VHDL design strictly adheres to these operational stages, ensuring that:
- Only one light is active at any time.
- There is always one light on.
- The presence of emergency vehicles is given priority in the state transitions.
This chart describes the behavior above.
This table describes the ASM Chart above, with all the cases and stages.
Included are simulation files from Intel Quartus Prime software that detail the state machine's reaction to a series of input events, showcasing how the controller manages state transitions. The simulation verifies the proper function of the controller under different scenarios, including emergency vehicle interruptions.
This design features a smart traffic light control system utilizing VHDL for combinational logic and D flip-flops to handle state transitions. Inputs include signals for emergency vehicles (EV) and waiting cars (CW), which are processed to determine the traffic light's next state. This state is then captured by D flip-flops with each clock pulse and fed back as the current state for continuous operation. The outputs control the Green, Yellow, and Red traffic lights, adapting in real-time to traffic conditions. The design ensures efficient traffic flow and emergency vehicle prioritization, all within a cyclical logic framework.