Tetris in Hardware
Using the Nexys 3 board with Spartan 6 FPGA to output Tetris to a VGA display.
Source Code | Full Technical Report
I'm a computer science student at UCLA, and one of my most recent classes was a "Digital Design Lab" where we got to play around with programming FPGAs. For our final project we were allowed to choose what we wanted to create, and my partner and I decided to go with a clone of the popular video game Tetris.
For those who don't know, an FPGA is a "Field-Programmable Gate Array", which essentially means that it is a chip with generic logic gates that can be combined and programmed to turn into many different hardware components. The FPGA is connected to the board's high-level inputs (buttons and switches) and outputs (VGA display, seven-segment display) to prototype different types of interactive digital circuits.
In order to program the board we use a hardware description language, or HDL, which describes the "structure, design and operation of digital logic circuits." A hardware description language differs from a programming language in that the lines of code do not execute sequentially, and rather than being "compiled" to a language that processors understand, HDL code is said to be "synthesized" into the basic logic gates and connections that implement the hardware design. For this class we used Verilog as the HDL.
The Nexys 3 board.
In the photo above, the Spartan 6 FPGA is the small black square in the center of the board. The micro USB port on the top left is used to power and program the board. Along the bottom edge are eight switches and five buttons. The leftmost switch is used as the "reset" switch in our Tetris implementation, and is used to start a new game or end the old one. The rightmost switch pauses the game. The five buttons are all used; the left and right buttons are used for moving the current tetromino left and right on the screen, the down button is used for moving it down one, the up button is used to rotate it, and the middle button is used to drop the current tetromino to the bottom. The seven segment display above the buttons shows the current score. The VGA output on the left can be connected to a display to show a 640x480 playing screen.
The only video I have of our Tetris implementation in action is shown below. Unfortunately I don't have the Nexys 3 board in my possession, as the one I used is property of the school. I recently ordered a similar board, the Mimas V2, from Numato Labs. If I can get the code up and running on that then I'll get a better video.