The objective of this project is to a game called “tank duel” that could be displayed on the VGA monitor and controlled by two players by one PS2 keyboard.
The tanks are realized as square boxes on the VGA monitor. They keep continuously moving back and forth on a horizontal line on the screen. Each tank can move with three different speeds. The direction of the tanks can be controlled using left and right keys. Both tanks shoot one bullet at a time; if it hits the opponent’s tank, it scores one point. A tank can shoot the second bullet only when the previous bullet goes out of the screen or hits the opponent. The score of both players is displayed on the LEDs. Whoever first scores 3 points wins. When a player wins, only the winner’s tank is displayed and the winner message is displayed in the LCD screen. The game resets on pressing the reset button.
– Two square shaped tanks facing each other on VGA screen with different colors (red and green). One tank appears on the top of the screen and the other appears on the bottom.
– Both tanks continuously move back and forth on a horizontal line on the screen. The directions of the tanks can be changed by pressing a button on the keyboard.
– Both tanks have 3 different moving speeds that are adjusted by keyboard inputs by the player.
-Both tanks shoot one bullet at a time; if it hits the opponent’s tank, it scores one point. A tank can shoot the second bullet only when the previous bullet goes out of the screen or hits the opponent.
– The score of both players are displayed on the 7-segment display. Whoever first scores 3 points wins.
-When one player reaches three points: Only the winner’s tank is displayed on the screen. A message declaring the winner should print out on the 16X2 screen.
– There is a reset button to resart the game
1. VGA Monitor
2. PS/2 Keyboard
3. 16X2 LCD Display (On Board)
4. 7-Segment Display (On Board)
5. Push Button and LEDs (On board)
The project was designed and developed on the ALTERA DE-2 FPGA board. The coding was done using VHDL. The details of the entities are as follows:
VGA_top_level: This is the top level entity that structurally connects the VGA, LED and LCD components that display the output.
lcd : The lcd component maps de2lcd component and displays the winner message based on a_win and b_win values.
leddcd: This component decodes the hexadecimal score into seven-segment display for both the tanks.
pixelGenerator : The provided pixelGenerator component was modified to map ps2 component to read keyboard press values, decode them accordingly and make changes in the pixel values sent to the VGA control. To indentify keyboard values, scan_readyo, scan_code and hist1 signals were compared. As the clock speed is too high for human eye perception, counters were used to reduce the speed at which the bullet moves.
procedure: MY package was used to store two procedures SQ and SQ_B that display the tanks and bullet respectively.
15 thoughts on “Dual Tank Game using FPGA”
hi where can i get the vhdl codes of the components oneshot, colorROM, ps2, keyboard, VGA_SYNC and leddcd
I can email you the VGA_SYNC. Please provide me with your email address.
Hi ! ^0^
Send it to me Please..
e-mail : email@example.com
The code is already on the project page. Here is the link: https://mahimrajgupta.files.wordpress.com/2014/06/355-final-project-report.pdf
Mahim Raj Gupta
firstname.lastname@example.org thank you 🙂
how did you create the procedure.vhd? i tried compiling it but i encountered an error “Top Level Design entity “procedure” is undefined. thanks 🙂
I saw the link to the code and it is pretty much everything that you need. I would suggest you to use the following steps and let me know if it works or not.
1. Make different .vhd files example procedure.vhd pixelGenerator,vhd and add it to your project.
2. Then add VGA_top_level.vhd and make it your top level file. Compile and Run.
– I was using QuartusII 13.0sp1 which is a student licence to burn and compile the code on FPGA board using ALTERA DE-2 Board.
– I used Model SIM for trace evaluation.
Hope this will help. Sorry for the delay in the reply.
hi thanks for the suggestion, the game’s already working only that the 16×2 lcd display of the de2 board does not display the “winner”. and still, i’m planning to speed up the firing of the bullet. which code should i edit and what do i need to change? thanks 🙂
Hey I am glad that it is working. So to speed up the bullet. In pixelGenerator.vhd you can go to the bullet logic section of the code and change SQ_B_Y3<=SQ_Y2+15; to
This would speed up the bullet by 5 in case you need it faster you can change 15 to a higher number.
Secondly, is the 16×2 not working at all or only the winner is not displayed?
Could you send me the vhdl codes of the components oneshot, colorROM, ps2, keyboard, VGA_SYNC? I am studying FPGA at my university (Brazil). My email is email@example.com.
Thank you so much!
The code is on the project page. Here is the link: https://mahimrajgupta.files.wordpress.com/2014/06/355-final-project-report.pdf
Could you send me the vhdl codes of the components oneshot, colorROM, ps2, keyboard, VGA_SYNC please i am trying to do a project at my university
please send me the codes my email is firstname.lastname@example.org.
The code can be found in Final Project Report and code link provided at the bottom of the page.
Hey. What software did you use for the code implementation ?
Hey Dan, I used Model Sim and Quartus.