A Verilog finite state machine that cycles green signals across three main roads at an intersection, simulated and fitted with Quartus Prime for an Intel Cyclone V FPGA.
Stack: Verilog HDL, Intel Quartus Prime (21.1.1 Lite), ModelSim simulation, Cyclone V (5CGXFC7C7F23C8).
- Open
Hackathon.qpfin Quartus Prime. The top-level entity isHackathon(Hackathon.qsf). - Compile the project (Processing > Start Compilation).
- To simulate, open
Waveform.vwfin Quartus Prime and run the simulator. Simulation outputs are insimulation/.
The RTL is in Hackathon.v. Hackathon.v.bak is a copy of the same code with the module named traffic_light_controller.
Name : Rhudhresh
Aim: To design and simulate a traffic light controller for an intersection of three main roads, where each road has equal priority. The controller should regulate the traffic flow efficiently, ensuring safety and smooth movement of vehicles while diverting the traffic to path 1 direction and disabling control in other directions. Apparatus Required:
- Hardware Description Language (HDL) simulation environment such as Verilog or VHDL.
- Simulation software like ModelSim for testing and verification.
- FPGA development board (optional) for hardware implementation. Procedure:
- Define the State Machine
- Implement the State Machine in HDL
- Simulate the Design
- Test the Design
- Optimize and Refine
State Table : • To define the states, inputs, outputs, and state transitions. • Let's denote the three main roads as MR1, MR2, and MR3. • Each road can have three possible states for its traffic light: Red, Yellow, and Green. Here's the state table:
• Each row represents a state transition along with the corresponding outputs for each main road.
• The "Counter" column indicates the counts for each state before transitioning to the next state.
• The "Current State" column represents the current state of the state machine.
• The "Next State" column indicates the state to transition to after completing the counts.
• The "MR1", "MR2", and "MR3" columns specify the traffic light states for each main road in the current state.
• "Red", "Yellow", and "Green" denote the states of the traffic lights.
• The lab table lists the counter as 0 to 9. The RTL in Hackathon.v counts 0 to 5, so each state lasts six clock cycles. See Status.
Code:
RTL Schematic View
Output Waveforms
- The design compiles and fits. The fitter summary reports success for
5CGXFC7C7F23C8, using 6 ALMs, 12 registers and 11 pins (output_files/Hackathon.fit.summary). - Simulation files and a programming file (
output_files/Hackathon.sof) are included. The repository does not document a run on the board. - The RTL has no yellow phase. The
yellow_MR1,yellow_MR2andyellow_MR3outputs are declared but never driven high. - The lab table shows different light patterns from the RTL. For example, the table gives MR3 green in the S_RED row, while the RTL turns all of MR3's lights off in that state.
- The RTL counts 0 to 5, not 0 to 9 as the lab table states.
GPL-3.0. See LICENSE.txt.
Built by Rhudhresh R






