Hello FPGA lovers. I am sure you are going to love today´s post: How to implement Snake Game on your FPGA. Maybe some of you are too young to remember this everlasting game that has been popular generation after generation on a wide variety of formats. And as it couldn´t be less, Snake Game deserves to be played on a FPGA.
The tutorial I am presenting today was developed by a group of students from the University of Manitoba. The project has 4 simple steps and all the hardware that you will need is your FPGA, a VGA monitor, a PS/2 keyboard, a USB cable and a power cable. Easy stuff here. Sorry for those hand-work lovers. More on that in future posts.
Well, getting back to the snake. According to the authors the more difficult parts to develop where the VGA output and the PS/2 keyboard input, as there is not too much information available on internet for its coding using Verilog. Read this, if you want to learn useful basics that will help you in future projects.
The FPGA that they used was an Altera DE2 Cyclone IV. Thus you may need to adapt the Verilog program to your FPGA. You can download the whole code here.
Another aspect I would like to highlight for you, it is their approach for coding the snake itself and what it eats, apples (funny uh). No they are not from IBM. Anyway, you may like to make your snake carnivore or a sweet lover so read these steps up and play with the code. Make your snake a dragon that eats carrots or whatever you want. This is the magic of coding.
Today´s article presents a very detailed project of a Cornell student who wanted to play with Pyro Sand Game. He did not want his laptop to overheat due to high power consumption, the fan to go crazy or the screen to freeze up once a lot of particles were on screen. To solve this he created a hardware version taking advantage of an FPGA and its great parallelization capabilities.
As the author describes it, this piece of software is more a 2D particle simulator than a game. In this sense, he chose to model the particle as a cellular automaton. Each pixel on a 480×640 screen is a cell. The whole screen is drawn on a VGA screen and this determines the kind an amount of memory required. More details here. Also, a VGA logic module is needed.
A great deal of this project is implemented as hardware directly downloaded on the FPGA, using Verilog code (every line is provided). Pictures and diagrams are provided to help the reader properly understand the designing process. Even gif graphs have been used in order to correctly explain how he managed to solve a problem with the RAM storage of rows of pixels in order to update the state of any pixel.
Don´t jump between sections and read the testing and debugging if you want to avoid unnecessary headaches!
This a very interesting project to use as a starting point for a particle dynamics simulator. As it can be seen in the pictures, the physical behavior of some particles is not real. So…
Thanks to reader Sowbug, who sent us this nice tidbit about how he got Pac-Man running on his Papilio Arcade via Linux. Sowbug says,
“Just got the Papilio on Sunday and was going through converting the Windows-based .bat and tools for merging/loading the Pac-Man bitfile. The first time I ran the loader with the bitfile, it paused for what seemed like maybe 250 milliseconds — far too short in the opinion of someone coming from an Arduino background. Then I looked to my side and saw Pac-Man running on my old VGA monitor. I almost jumped out of my seat! I didn’t expect it to work the first time, and especially with so little time elapsed since loading. Fun stuff!”
Check out Sowbug’s original blog post for an in-depth look at what went in to the project, and for access to the fork he wrote for Linux. I have to say, I really like Sowbug’s photo on that post. Great composition!