Make a Pong Game With FPGA by Verilog
by RegisHsu in Circuits > Electronics
2893 Views, 2 Favorites, 0 Comments
Make a Pong Game With FPGA by Verilog
I'd like share a fun and simple code can learn about the VGA signal programing, let's go.
Reference site: projectf.io
FPGA Development Kit: Altera Cyclone EP4CE6 board with VGA port
Tools: Quartus Prime Lite Edition 20.1.1
HDL: SystemVerilog
Host OS: Ubuntu 64bits 20.04
Prepare the Development Environment
Picture 1:
I am using Quartus Prime Lite Edition which is free for
Download and Install Quartus, https://fpgasoftware.intel.com/20.1.1/?edition=lite
Follow the quick start guide to setup the tools and also the JTAG programmer connection are working well.
Picture 2:
try to get a FPGA development kit and also study the schematics for each pin connection.
Load the Pong Project File
Download the pong projects from my github, https://github.com/regishsu/fpga
There are two ways to restore back the pong project:
Way 1: automatic restore
Copy these 2 files(fpga_pong_demo.qar and fpga_pong_demo.qarlog) into a folder which your project folder, i.e pong.
Refer to picture 1, from Project -> Restore Archived Project to select this file "fpga_pong_demo.qar" to restore whole project files.
Way 2: menual
Refer to picture 2, create an new project and then select all of files in source into your new project file list.
Code Explain
Here I do some explain for the code,
Top_pong.sv, the main code for the pong game.
clock_gen.v, using the Quartus' IP to generate VGA 25Mhz colck.
display_timings_480p.sv, generate the VGA timing as the picture 4 and 5.
debounce.sv, handle the key press noise.
There are some parameters to you if you may try.
// ball
localparam B_SIZE = 8;
// paddles
localparam P_H = 40; // height in pixels
localparam P_W = 8; // width in pixels
localparam P_SP = 4; // speed
localparam P_OFFS = 32; // offset from screen edge
Compilation and Upload to FPGA
Be sure the pin assignment to correct the ports before do the compilation.
I found that the R/G/B port of VGA is just 1bit of my dev board.
One More Thing...
you may modify the color/size for ball and paddle, and also add sound feature.