Game ping pong vhdl


















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. It knows where the paddle is located and keeps track of that if the player moves their paddle up or down. Otherwise it's a 0. This isn't its own module. I sincerely hope that you have found your development using the Go Board to be fun and worthwhile.

I have spend thousands of hours creating this website, designing the Go Board, and writing all of these tutorials. Please post to social media and tell others about this place, that's the best way to help!

If you have any feedback, either email me using the link on the bottom of this webpage or post to the comment section. And thank you so much for your support, I could not have done all of this without you and your positive encouragement!

You've reached the end of the Go Board tutorials! Please subscribe to my YouTube channel at YouTube. Lots more content is coming, so bookmark nandland. Help Me Make Great Content!

Support me on Patreon! Buy a Go Board! The diagram below is the basic overall top-level block diagram for the system. It has a horizontal and vertical sync outputs, RBG which refers to the color of the pixel at a certain location , and Score which acts as a bus to the 7-Segment display.

The up button will be used as the start button, and the left and right pushbuttons will be used to move the paddle in their respective directions. The 7-Segment Display will be used to record the score, which is the number of seconds that the user has been playing without losing the game.

The number will be displayed as a decimal number. Our gizmo will also use at least three clock dividers, one for the score time , one for the refresh rate of the of the display and one that is hooked up to the output of a DeMux so that we can control how fast the game will proceed with increasing amounts of difficulty.

The game will move much faster the longer you play. We will have the control input of the DeMux be present state of the sub-FSM so that we can control how fast the game will go by how long that you play it. We will be using a few counters, one to refresh the display and one to count up the score as you continue to play. This project has two main modules and an array of submodules that will manipulate the input data. The two main submodules are the VGA Driver, as well as the button logic module.

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. It maps the signals from each component and uses state logic to determine the signals and output addresses.



0コメント

  • 1000 / 1000