Simple projects are a great way to learn Verilog. This project marks my first steps with the Sipeed Tang Primer 20K FPGA, exploring its programming and practical operation.
The Verilog code implements the traffic light control logic, defining the LED activation sequence. This sequence is generated by a counter that cycles through the different states, ensuring:
Sequential LED control (red → yellow → green → red)
Precise timing for each light phase
Automatic cycling (no reset required)
-
assets/ - Images and video
-
constraints/ - Pin constraint files
-
src/ - Verilog source code
-
tb/ - Testbench code
The traffic light sequence follows a cycle where each LED stays on for 1 second and off for 0.5 seconds, as illustrated in the flowchart below:
-
Sipeed Tang Primer 20K (FPGA based on Gowin GW2A-LV18PG256C8/I7)
-
3 resistors of 10Ω to limit the LED current
-
3 LEDs to represent the traffic light colors
-
4 M-M jumper wires
-
1 breadboard
-
USB-C cable
Below is the electrical schematic showing the LED connections to the FPGA.
Available in the src
and constraints
directories.
To compile and load the code onto the FPGA, I used the Gowin IDE tool. The process was as follows:
-
Create a new project and set the GW2A-LV18PG256C8/I7 as the target.
-
Specify the correct LED pins in the constraints file (.cst).
-
Compile, synthesize, and load the bitstream onto the FPGA.
-
With the code running, the LEDs automatically alternate between red, green, and yellow.
Click the image below for a short video showing the traffic light controller in operation, demonstrating the expected system behavior as it cycles through the light sequence:
This simple project demonstrates how Verilog can be used to control LEDs on an FPGA. The Tang Primer 20K proved to be an excellent platform for learning.
-
FPGA: Sipeed Tang Primer 20K (GW2A-LV18PG256C8/I7) with Dock
-
HDL: Verilog
-
Development Tool: Gowin IDE
-
Schematic Design: Fritzing