Video Demonstration

VGA technology

Each line of the video begins with an active video region, in which RGB values are output for each pixel in the line. Then a blanking region follows in which a horizontal sync pulse is transmitted in the middle of the blanking interval. The interval before the sync pulse is known as front porch and after the sync pulse back porch.

Hsync timing

Vsync timing

For our project we had a resolution of 640×480@60Hz, so we created a 50 MHz clock, from the 100 MHz clock input of the Zedboard and the horizontal and the vertical count have a total value of 800 and 524 respectively. Based on these numbers we calculate the exact time that the hsync and vsync are set active high (both signals on this resolution must be active high) and we connect them to the FPGA pins.

Game Logic

The game elements are the spaceship, the 15 aliens (5 per row), the spaceship and alien rockets(6 of them are shooting). The movement of the spaceship is controlled by 2 buttons of the fpga(left and right) and the upper one is for firing the bullet. The bullet moves vertically with a fixed speed until it collides with an alien( or spaceship) or reaches the upper(or lower) border of the screen (screenY/X == 0). The aliens move horizontally and then vertically when they reach the side borders of the screen. Finally the game ends when all the aliens are dead(victory), or the spaceship is destroyed(been hit twice), or if one(or more) alien reach the height of the spaceship.

The spaceship movement is limited by the side borders so if it has reached the left border for example and we press the left button, it will remain at its position.

The spaceship rocket launches when the fire button(upper one) is pressed. It is positioned at the center of the spaceship and flies vertically with the speed of 10 pixels/25mhzClk.

The alien rocket launches with a fix period(3s) from the center of the alien only if there is not alive alien in front of the one who launches it. The aliens that can shoot are the first and last of the bottom row, the second and fourth of the middle and top row.

Game Sound

In order to add some sound effects to the game, we used a sound module that in case of an alien hit produces the A note and a G note at a spaceship hit.

Game Interface

When the game starts, the startup screen is printed of the vga output. After when we press the start button(bottom), we proceed to the game screen. There in the upper left corner is a progress bar which indicates how many aliens have been killed. The points are 3 for the bottom row, 6 for the middle and 9 for the upper row adding up to the 90 points(90 pixels printed) total. At the upper right corner is the remaining life the player has. In case of an alien hit one life is reduced and the remaining life indicator disappears. The background of the game is a starry sky suited to the concept of the game. If the player wins a victory screen appears. In case of defeat the gameover screen appears.


In order to use pictures for the elements of the game, we made the the following sprites.

The steps to load the sprites in the fpga are:

1)Download the image you want and crop it to the appropriate dimensions.

2)Use the coetool to export the 8bit file of the image.

3)Using vivado load the coe file in the block ram memory generator.

And now the image can be accessed by reading the bram module.

spaceinvadersor Spaceship sprite : 30×16 pixels.

alien Alien1 sprite: 30×22 pixels

alien2 Alien2 sprite: 30×30 pixels.

alien3 Alien3 sprite: 33×22 pixels.


Background sprite: 640×480 pixels.

How to map the sprites to the Block Ram

blk_mem_gen_0 corresponds to spaceship.coe

blk_mem_gen_1 corresponds to alien.coe

blk_mem_gen_2 corresponds to alien2.coe

blk_mem_gen_3 corresponds to alien3.coe

blk_mem_gen_4 corresponds to space.coe

blk_mem_gen_5 corresponds to gameover.coe

blk_mem_gen_6 corresponds to spaceinvaders.coe

blk_mem_gen_7 corresponds to win.coe

Here are the specs of every block ram

And the dimensions of each blk_mem_gen

Block Diagram