This project was created in my Digital Systems Design course for the final project. The project is an interactive pong game for two players using a Field Programmable Gate Arrays (FPGA). The game is displayed using the VGA port on the FPGA and played using the digital buttons on the FPGA panel. The FPGA is programmed using a hardware descriptive language called Verilog. For the project we were provided sample code that supports monitors with a pixel resolution of 1280x1024 and a 60 Hz refresh rate. By adjusting one pixel using the buttons we could correctly calculate the resolution of the monitor we were using. After the resolution was correctly formatted we could create the pong game.
The design for this game was separated into four main modules. The top level of our design was the interface module that controls the color scheme and rendering of the game. Inside of this module is where the size and color of the borders and paddles were made. Another important module was the seven segment displays to show the current score for both players on the FPGA. The most important modules were the paddles and ball modules which are explained more below.
To design the paddles module we started by creating a state transition diagram and black box to understand our desired inputs and outputs. For this module we separated the left and right paddle into two separate modules. This module was a sequential circuit that operated on a slowClock from the interface module. The four states we had for this module were based on the paddles hitting the top and bottom of the screen or just moving up and down. To transition between states we received values from the buttons and the current updated paddle position. This allowed us to move the paddles in each state by assigning the updated paddle position to a new value and direction.
The design for the moving ball module was created in a similar method as we first created a state transition diagram and black box for reference. This module included a lot more inputs and outputs as the ball needs to interact with the borders on the screen, paddles, and updated player points. The states that we created are four different diagonal directions that the ball can move. Therefore, to have the ball bounce off the walls and paddles, we set up conditional statements. If the correct pixels align, then the ball bounces in the new direction. As a result, we needed to constantly acquire the updated paddle position from the paddle module and updated ball position. Furthermore, to allow one of the players to score, a conditional statement is set to when the ball goes into the scoring goal. In result, one of the players score is increased and the ball is reset. Overall, the ball module was the most complex and gave us the most problems to troubleshoot.