In this lab, we will program the FPGA on the Nexys2 board to display a “bouncing ball” on a 640 x 480 VGA monitor connected to the VGA interface on the board. This will requires us to generate the required sync and video signals consistent with the VGA standard.
This module allows to generate the horizontal and vertical sync waveforms, and also the pixel to and column addressing. It uses a clock of 25 MHz to drive horizontal and vertical counters h_cnt and v_cnt respectively, which generates the various timing signals.
This module allows to generate the red, green and blue video which can paint the ball on to the VGA display at its current position.
This module keeps signals ball_x and ball_y that represent the current position of the ball on the screen. The initialization location is (320, 240) in this code, which locates in the center of the screen. The ball_y_motion represent the number of pixels that the ball should move in one frame period, which is initialized to +4 pixels/frame. The signal ball_on is used to set the color (R,G,B) of the ball, which is initialized to red ball.
This module allows to connect the vga_sync and ball modules together and connect the appropriate signals to the Nexys2 VGA port.
To change the color of the ball, make the change below on the ball.vhd file. The following example changes the color of the ball to green.
If you turn two colors on, you can get a mix. For example, red and green both on becomes a dark yellow color.
To change the shape of the ball, make the change below on the ball.vhd file. The following example changes the shape of the ball to circle.
To change the motion of the ball, modify the motion part of the ball.vhd file to make it move in different directions.