Vhdl pong game


















When dividing by a power of 2, simply drop the number of least significant bits that are required to represent the divisor.

For our example, we are dividing by 16, which takes 4 bits to represent. So if we drop the least significant 4 bits off of the Row and Column indexes then we have divided them by Base-2 multiplying and dividing is done constantly inside of an FPGA, so it's important to understand.

If you want to multiply a number by 2, simply add on a single bit on the right of the number. To multiply by 8, add on 3 bits set to zero. Remove those bits to divide. If the current pixel is equal to the location of the paddle or the ball, those modules will drive their output high.

This tells the Pong Top to draw white on that pixel. See below for a complete description of each module. There needs to be a way to kick-off a new Pong Game, to tell the Go Board to start moving the ball. It would have been easier if there were five push-button switches on the Go Board, so that one of them could be use to start the game, but sadly there isn't.

You could have chosen to use one of the other buttons to start a new game, but I just decided to reuse the UART RX module from a previous project. To learn how each of those work go back and review that project, they are used as-is here. One thing's for sure, we can't use the raw switch inputs.

We need to debounce those buttons. This code was already written in a previous project, so just lift that and instantiate it once for each of the four switch inputs. Here's the actual first new piece of code thus far. The VGA Driver will consist of programmable memory, a clock divider, and the logic that will manipulate the output for color. The button logic module will also consist of a clock divider, and a programmable memory, as well as a binary to decimal converter for the 7-Segment Display with its respective clock divider.

For the Image Process section of the project, we will be determining the movement of the ball and the paddle. The program has ports that include the left, right, top and center pushbuttons, the present state, a clock, the X and Y positions of the ball, the left and right edge of the paddle and a fail. The present state is used to determine the enable signal. The code goes over the multiple cases that the ball can move, and has set conditions to determine the path of the ball.

The next process block determines the direction that the paddle move based on which button is pressed by the user. The code for this part of the project is attached with detailed comments describing what each section does. This section consists of files that relate to displaying the score in seconds on the 7 Segment Display on the Basys3 Board. It includes a clock divider that is used to count the seconds, a score counter counts the seconds that the user is playing, the segment driver take the score and converts it to anodes and cathodes to be displayed on the screen and also determines the position that the number will be displayed and lastly, the segment handler converts the binary digits to decimal digits to be displayed on the screen.

The score handler puts together all the pieces and maps the signals. The code for all five files is attached below. If the enable signal is on, then the clock will count on the rising edge. The numbers after "D" refer to the decimal place on the 7 segment display. The outputs are the anodes and the digit. The clock counts and assigns the numbers and it's position. For example, a "9" will be displayed in the ones place with "0"s in the thousands, hundreds and tens place. When it switches to "10", the number will now have a "1" in the tens place and "0"s in the thousands, hundreds and ones place.

The segment handler has digit as its input and cathodes as its output. It essentially the binary numbers to the cathode display to output decimal numbers on the screen.

The Score Handler consists of the previous four entities and puts it's all together and maps the signals. It also enables and disables the counter based on the present state. These files refer how to generate the images on the display monitor. The outputs are WA the address we are writing the color to , and WD the color being written at the determined address. The Refresh Image file is used to refresh the image as the position of the ball and paddle change. Active 3 years, 7 months ago.

Viewed times. Improve this question. Marcus Nielsen Marcus Nielsen Where are the pong graphics coming from?

Welcome to Stack Overflow. Please read How do ask a good question. Yes and no Add a comment. Active Oldest Votes. Sign up or log in Sign up using Google.



0コメント

  • 1000 / 1000