In this lab, we will extend the FPGA code we developed in Labs 3 and 4 (Bouncing Ball) to build a simple version of the 1970’s arcade game known as “PONG”. In addition to the bouncing ball, we will generate an on-screen bat which will be controlled by a potentiometer. The potentiometer generates a DC voltage which is sampled into the FPGA using an outboard analog to digital converter. The A/D converter generates a serial data stream that we will convert into the on-screen bat position. Unlike the original game, this version of PONG has only one player. The object of the game is to keep the ball in play, similar to someone hitting a ball against a practice wall.
- We will be using a 2 channel, 12-bit Analog to Digital Converter module PmodAD1 (Figure 1) which plugs into one of the PMOD connectors on the Nexys4 board
- The module uses two Analog Devices AD7476 ADC chips.
- Each channel of the ADC module takes as input an analog voltage in the range of 0 – 3.3V.
- Whenever the CS input goes low, the ADC uses successive approximation to convert the analog input voltage into an unsigned 12-bit data value.
- An input of 0V generates a digital output of x“000”.
- An input of 3.3V, generates a digital output of x“FFF”. We will only be using one of these ADC channels – ADC2.
- Plug the VGA monitor into the VGA port on the Nexys4 board
- Plug the PmodAD1 ADC module into PMOD jack JA on the Nexys4 board (Figure 2)
- Plug the module into the top row of sockets on JA
- Plug the cable from the potentiometer into the J2 connector on the PmodAD1 ADC module, so that the white orientation symbol is on the left
- Using the same project settings from the previous labs, create a new project titled 'Pong'.
- Shown in Initial Project Setup in Lab 3
- Create a new source titled 'vga_sync'
- Shown in Initial Project Setup in Lab 3
- Code found in Figure 3
- Create another source titled 'bat_n_ball'
- Create another source titled 'adc_if '
- Create a top level source titled 'pong'
- Code found in Figure 6
- This is the top level that hooks it all together. In this module:
- BTN0 on the Nexys4 board is used to initiate a serve.
- The process ckp is used to generate timing signals for the VGA and ADC modules.
- The output of the adc_if module drives bat_x of the bat_n_ball module.
- Add an Implementation Constraint source file titled 'pong'
- Highlight the 'pong.vhd' module in the Hierarchy window and run Synthesis
- Run Implementation
- Generate Bitstream
- Plug in the device if it is not already and Vivado should detect the board
- Click Program Device and load the generated bitstream onto the board
- If you cannot click Program Device, click Open Target first
If everything was correctly setup, you should see a bar on the bottom of the screen. Hitting the BTNC button on the Nexys4 board will start the game, and you will see a ball come up from the bottom of the screen. Using the potentiometer to move the bar, your goal is to try and hit the bar and keep it from reaching the bottom of the screen. Our group's best score was 5.
How to set up the bitstream:
http://users.wpi.edu/~rjduck/Nexys4DDR%20Vivado%20VHDL%20Decoder%20Tutorial.pdf
How to Connect The Nexys A7 to your computer:
https://github.com/Digilent/Nexys-A7-100T-GPIO
Dr. Ackland's Lab Manual:
http://personal.stevens.edu/~backland/Courses/Course487_Spring_18_files/Labs/Lab6.pdf
GitHub:
https://github.com/kevinwlu/dsd