Space Invaders - Ece
Personal tools

Space Invaders

From Ece

Jump to: navigation, search

Contents

Phase 1

Objective

The objective is to make a Space Invaders type game using an FPGA for processing, a keyboard for input, and a VGA monitor for output.

Team Members

Frank Holland – Coordinator, Recorder, and Checker

Introduction

Space Invaders is a game with a spaceship, that shoots lasers, at the bottom of the board, left, right, and top walls, and a group of aliens that shoot lasers and move between the walls. The objective is to shoot all of the enemies by shooting them with the lasers.

Concept

A ps/2 keyboard will be used to control the spaceship at the bottom of the screen. A VGA monitor will be used to display the game. The FPGA will be used to control spaceship movement, laser movement, alien status, score keeping, and lives left. Translating all this information to the screen, and other output devices, will also be done by the FPGA. A number of points will be given if an alien is hit with the spaceship’s laser. These points will be displayed on the seven segment display. A life will be lost if an alien’s laser shot hits the spaceship. The number of lives left will be shown on the leds.

Proposed Work

Parts

  • VGA Monitor
    • Provided in lab area
  • ps/2 keyboard
    • Already owned

Modules

draw_vga

Controls display for walls, spaceship, aliens, and lasers.

  • inputs:
    • laserX(9:0) – current x coordinate of the ship’s laser
    • laserY(9:0) – current y coordinate of the ship’s laser
    • shipX(9:0) – current x coordinate of the spaceship
    • alienX(9:0) – current x coordinate of the top-left corner of the aliens group
    • alienY(9:0) – current y coordinate of the top-left corner of the alien group
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
    • status(6:0) – current status of the aliens
    • clk – system clock (50 MHz)
    • video_on – high when the row and column outputs are valid
    • row(9:0) – row coordinate for current pixel being drawn
    • column(9:0) – column coordinate for current pixel being drawn
  • outputs:
    • red – red component of vga monitor
    • green – green component of vga monitor
    • blue – blue component of vga monitor
vga_sync

Controls vertical and horizontal sync, outputs which pixel is being drawn

  • inputs:
    • clk – system clock (50 MHz)
  • outputs:
    • h_sync – horizontal synchronization
    • v_sync – vertical synchronization
    • video_on – high when the row and column outputs are valid
    • pixel_row(9:0) – row coordinate for current pixel being drawn
    • pixel_column(9:0) – column coordinate for current pixel being drawn
ps2_decode

decodes the input opcode into a smaller form

  • inputs:
    • ps2_raw(15:0) – actual opcode from ps2core module
  • outputs:
    • opcode(2:0) – decoded form of ps2_raw input
ps2_core

Translates data from keyboard into an opcode

  • inputs:
    • ps2clk – keyboard clock
    • ps2data – input data from keyboard
  • outputs:
    • opcode(15:0) – opcode for button pressed on keyboard
ship_control

Controls paddle movement.

  • inputs:
    • clk – system clock (50 MHz)
    • opcode(2:0) – opcode to determine left or right movement
  • outputs:
    • shipX(9:0) – x coordinate of the ship
score

Keeps track of score of the game. Increments the score when the positive edge of alien_hit is detected.

  • inputs:
    • alien_hit – high when an alien has been hit
  • outputs:
    • score(15:0) – score of the game
binarytobcd

Converts a binary number into binary coded decimal

  • inputs:
    • binary(13:0) – binary input
  • outputs:
    • bcd(15:0) – binary coded decimal output
segdecode

Used to display characters on the seven segment display.

  • inputs:
    • clk – system clock (50MHz)
    • char3(3:0) – fourth character on the seven segment display
    • char2(3:0) – third character on the seven segment display
    • char1(3:0) – second character on the seven segment display
    • char0(3:0) – first character on the seven segment display
  • outputs:
    • anode(3:0) – controls the anode of the seven segment display
    • sevenseg(7:0) – decodes the characters for the seven segments
lives_left

Keeps track of lives left.

  • inputs:
    • life_lost – high if a life has been lost
  • outputs:
    • led(7:0) – show how many lives are left on the leds
board_control

Controls lasers and aliens.

  • inputs:
    • clk – system clock (50MHz)
    • shipX(9:0) – current x coordinate of the paddle
    • opCode(2:0) – opcode to determine if the button has been pressed to fire a laser
  • outputs:
    • life_lost – high if a life has been lost
    • alien_hit – high if a brick has been hit
    • which_alien(6:0) – the brick that has been hit
    • laserX(9:0) – current x coordinate for the ball
    • laserY(9:0) – current y coordinate for the ball
    • alienX(9:0) – current x coordinate of the top-left corner of the aliengroup
    • alienY(9:0) – current y coordinate of the top-left corner of the aliengroup
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
alien_status

Controls output for the status of all the aliens.

  • inputs:
    • clk – system clock (50 MHz)
    • alien_hit – high if an alien has been hit
    • which_alien(6:0) – which alien has been hit
  • outputs:
    • status(6:0) – current status of the aliens

Top-Level Block Diagram

tlbd.JPG

Expected Deliverables

I intend to show a similar game to Space Invaders. The ship should fire lasers. Aliens should disappear when hit and the score should be updated. The aliens should also move back and forth across the screen. Lives should be lost if the ship gets hit by an alien’s laser.

Phase 2

Objective

The objective is to make a Space Invaders type game using an FPGA for processing, a keyboard for input, and a VGA monitor for output.

Team Members

Frank Holland – Coordinator, Recorder, and Checker

Introduction

Space Invaders is a game with a spaceship, that shoots lasers, at the bottom of the board, left, right, and top walls, and a group of aliens that shoot lasers and move between the walls. The objective is to shoot all of the enemies by shooting them with the lasers.

Concept

A ps/2 keyboard will be used to control the spaceship at the bottom of the screen. A VGA monitor will be used to display the game. The FPGA will be used to control spaceship movement, laser movement, alien status, score keeping, and lives left. Translating all this information to the screen, and other output devices, will also be done by the FPGA. A number of points will be given if an alien is hit with the spaceship’s laser. These points will be displayed on the seven segment display. A life will be lost if an alien’s laser shot hits the spaceship. The number of lives left will be shown on the leds.

Proposed Work

Parts

  • VGA Monitor
    • Provided in lab area
  • ps/2 keyboard
    • Already owned

Modules

draw_vga

Controls display for walls, spaceship, aliens, and lasers. It displays top, left, and right walls. There will be 40 aliens which will be displayed if they have not been hit. The lasers will be displayed as a line which moves. The ship will be displayed at the bottom.

  • inputs:
    • laserX(9:0) – current x coordinate of the ship’s laser
    • laserY(9:0) – current y coordinate of the ship’s laser
    • shipX(9:0) – current x coordinate of the spaceship
    • alienX(9:0) – current x coordinate of the top-left corner of the aliens group
    • alienY(9:0) – current y coordinate of the top-left corner of the alien group
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
    • status(40:0) – current status of the aliens
    • clk – system clock (50 MHz)
    • video_on – high when the row and column outputs are valid
    • row(9:0) – row coordinate for current pixel being drawn
    • column(9:0) – column coordinate for current pixel being drawn
  • outputs:
    • red – red component of vga monitor
    • green – green component of vga monitor
    • blue – blue component of vga monitor
  • Verification: To verify that this module works properly, the different inputs will be connected to switches. The vga monitor should display all components of the board with movement if inputs change.
vga_sync

Controls vertical and horizontal sync, outputs which pixel is being drawn

  • inputs:
    • clk – system clock (50 MHz)
  • outputs:
    • h_sync – horizontal synchronization
    • v_sync – vertical synchronization
    • video_on – high when the row and column outputs are valid
    • pixel_row(9:0) – row coordinate for current pixel being drawn
    • pixel_column(9:0) – column coordinate for current pixel being drawn
  • Verification: Provided in previous labs.
ps2_decode

decodes the input opcode into a smaller form

  • inputs:
    • ps2_raw(15:0) – actual opcode from ps2core module
  • outputs:
    • opcode(2:0) – decoded form of ps2_raw input
  • Verification: To verify that this module works properly, the generated opcode will be displayed on the seven-segment display to be sure it corresponds to key pressed.
ps2_core

Translates data from keyboard into an opcode

  • inputs:
    • ps2clk – keyboard clock
    • ps2data – input data from keyboard
  • outputs:
    • opcode(15:0) – opcode for button pressed on keyboard
  • Verification: Provided in previous labs.
ship_control

Controls paddle movement. Decrements x coordinate when left arrow button is pressed and increments if the right arrow is pressed.

  • inputs:
    • clk – system clock (50 MHz)
    • opcode(2:0) – opcode to determine left or right movement
  • outputs:
    • shipX(9:0) – x coordinate of the ship
  • Verification: To verify that this module works properly, the output should be connected to the seven-segment display. If the module is working, then the output should change when the left and right arrows are pressed.
score

Keeps track of score of the game. Increments the score when the positive edge of alien_hit is detected.

  • inputs:
    • alien_hit – high when an alien has been hit
  • outputs:
    • score(15:0) – score of the game
  • Verification: To verify that this module works properly, a switch will be used to simulate the signal that an alien has been hit which will cause the output to increment.
binarytobcd

Converts a binary number into binary coded decimal

  • inputs:
    • binary(13:0) – binary input
  • outputs:
    • bcd(15:0) – binary coded decimal output
  • Verification: Provided in previous labs.
segdecode

Used to display characters on the seven segment display

  • inputs:
    • clk – system clock (50MHz)
    • char3(3:0) – fourth character on the seven segment display
    • char2(3:0) – third character on the seven segment display
    • char1(3:0) – second character on the seven segment display
    • char0(3:0) – first character on the seven segment display
  • outputs:
    • anode(3:0) – controls the anode of the seven segment display
    • sevenseg(7:0) – decodes the characters for the seven segments
  • Verification: Provided in previous labs.
lives_left

Keeps track of lives left. Decrements the number of lives left on the positive edge of the signal life_lost.

  • inputs:
    • life_lost – high if a life has been lost
  • outputs:
    • led(7:0) – show how many lives are left on the leds
  • Verification: To verify that this module works properly, a switch will be used to simulate the signal that a life has been lost which will cause the most significant led to turn off.
board_control

Controls lasers and aliens. Also determines if an alien has been hit or a life has been lost. The ship's laser will be fired when the space bar is pressed. Life_lost and alien_ hit will be set high for one clock cycle when the appropriate actions have occurred.

  • inputs:
    • clk – system clock (50MHz)
    • shipX(9:0) – current x coordinate of the paddle
    • opCode(2:0) – opcode to determine if the button has been pressed to fire a laser
    • status(40:0) - current status of the aliens
  • outputs:
    • life_lost – high if a life has been lost
    • alien_hit – high if a brick has been hit
    • which_alien(6:0) – the brick that has been hit
    • laserX(9:0) – current x coordinate for the ball
    • laserY(9:0) – current y coordinate for the ball
    • alienX(9:0) – current x coordinate of the top-left corner of the aliengroup
    • alienY(9:0) – current y coordinate of the top-left corner of the aliengroup
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
  • Verification: To verify that this module works properly, the inputs will be simulated using switches and the outputs should change appropriately.
alien_status

Controls output for the status of all the aliens. Status of the appropriate alien will be changed when a positve edge of alien_hit has occured.

  • inputs:
    • clk – system clock (50 MHz)
    • alien_hit – high if an alien has been hit
    • which_alien(6:0) – which alien has been hit
  • outputs:
    • status(40:0) – current status of the aliens
  • Verification: To verify that this module works properly, the alien_hit and which_alien signals will be simulated which should cause the corresponding bit of the output to go low.

Top-Level Block Diagram

tlbd.JPG

Expected Deliverables

I intend to show a similar game to Space Invaders. The ship should fire lasers. Aliens should disappear when hit and the score should be updated. The aliens should also move back and forth across the screen. Lives should be lost if the ship gets hit by an alien’s laser.

Phase 3

Review of Proposed Work

  • All module are the same as in Phase 2 with these exceptions
    • board_control module has been split into three modules.
      • board_control - controls alien movement and whether a life has been lost or an alien has been hit.
      • laser_control - controls the ship's laser
      • alien_laser_control - control's the alien's laser
    • All modules that have a status(40:0) input or output have been changed to status(39:0).

Module Descriptions

draw_vga

  • Controls display for walls, spaceship, aliens, and lasers. It displays top, left, and right walls. There will be 40 aliens which will be displayed if they have not been hit. The lasers will be displayed as a line which moves. The ship will be displayed at the bottom.
  • inputs:
    • laserX(9:0) – current x coordinate of the ship’s laser
    • laserY(9:0) – current y coordinate of the ship’s laser
    • shipX(9:0) – current x coordinate of the spaceship
    • alienX(9:0) – current x coordinate of the top-left corner of the aliens group
    • alienY(9:0) – current y coordinate of the top-left corner of the alien group
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
    • status(39:0) – current status of the aliens
    • clk – system clock (50 MHz)
    • video_on – high when the row and column outputs are valid
    • row(9:0) – row coordinate for current pixel being drawn
    • column(9:0) – column coordinate for current pixel being drawn
  • outputs:
    • red – red component of vga monitor
    • green – green component of vga monitor
    • blue – blue component of vga monitor

vga_sync

  • Controls vertical and horizontal sync, outputs which pixel is being drawn
  • inputs:
    • clk – system clock (50 MHz)
  • outputs:
    • h_sync – horizontal synchronization
    • v_sync – vertical synchronization
    • video_on – high when the row and column outputs are valid
    • pixel_row(9:0) – row coordinate for current pixel being drawn
    • pixel_column(9:0) – column coordinate for current pixel being drawn

ps2_decode

  • Decodes the input ps2_raw into an opcode that corresponds to specific key presses.
  • Opcode:
    • 001 : Left Arrow
    • 010 : Right Arrow
    • 011 : Space
    • 101 : Escape
  • inputs:
    • ps2_raw(15:0) – actual opcode from ps2core module
  • outputs:
    • opcode(2:0) – decoded form of ps2_raw input

ps2_core

  • Translates data from keyboard into an opcode
  • inputs:
    • ps2clk – keyboard clock
    • ps2data – input data from keyboard
  • outputs:
    • opcode(15:0) – opcode for button pressed on keyboard

ship_control

  • Controls ship movement.
  • Decrements x coordinate when left arrow button is pressed and increments if the right arrow is pressed.
  • inputs:
    • clk – system clock (50 MHz)
    • opcode(2:0) – opcode to determine left or right movement
  • outputs:
    • shipX(9:0) – x coordinate of the ship


score

  • Keeps track of score of the game.
  • Increments the score by 100 when the positive edge of alien_hit is detected.
  • inputs:
    • alien_hit – high when an alien has been hit
  • outputs:
    • score(15:0) – score of the game

binarytobcd

  • Converts a binary number into binary coded decimal
  • inputs:
    • binary(13:0) – binary input
  • outputs:
    • bcd(15:0) – binary coded decimal output

segdecode

  • Used to display characters on the seven segment display
  • inputs:
    • clk – system clock (50MHz)
    • char3(3:0) – fourth character on the seven segment display
    • char2(3:0) – third character on the seven segment display
    • char1(3:0) – second character on the seven segment display
    • char0(3:0) – first character on the seven segment display
  • outputs:
    • anode(3:0) – controls the anode of the seven segment display
    • sevenseg(7:0) – decodes the characters for the seven segments

lives_left

  • Keeps track of lives left.
  • Decrements the number of lives left on the positive edge of the signal life_lost.
  • inputs:
    • life_lost – high if a life has been lost
  • outputs:
    • led(7:0) – show how many lives are left on the leds

board_control

  • Controls alien movement by incrementing or decrementing the X coordinate of the alienX output.
  • Determines if an alien has been hit by checking to see if the laser's coordinates are within the range of an alien. If this is true, then the alien_hit output will be set high for one clock cycle. which_alien will be set to the alien that has been hit for one clock cycle.
  • Determines if a life has been lost by checking to see if the alien laser's coordinates are within the range of the ship. If this is true, then the life_lost output will be set high for one clock cycle. which_alien will be set to the alien that has been hit for one clock cycle.
  • inputs:
    • clk – system clock (50MHz)
    • shipX(9:0) – current x coordinate of the paddle
    • status(39:0) - current status of the aliens
    • laserX(9:0) – current x coordinate for the laser
    • laserY(9:0) – current y coordinate for the laser
    • alien_laserX(9:0) – current x coordinate of the alien’s laser
    • alien_laserY(9:0) – current y coordinate of the alien’s laser
  • outputs:
    • life_lost – high if a life has been lost
    • alien_hit – high if a brick has been hit
    • which_alien(6:0) – the brick that has been hit
    • alienX(9:0) – current x coordinate of the top-left corner of the aliengroup
    • alienY(9:0) – current y coordinate of the top-left corner of the aliengroup


alien_status

  • Controls output for the status of all the aliens. Status of the appropriate alien will be changed when a negative edge of alien_hit has occured.
  • inputs:
    • clk – system clock (50 MHz)
    • alien_hit – high if an alien has been hit
    • which_alien(6:0) – which alien has been hit
  • outputs:
    • status(39:0) – current status of the aliens

laser_control

  • Controls the ship's laser.
  • Fires a laser if the opCode is 3. If a laser is currently active then the laser will not fire.
  • The laser will reset if an alien has been hit or it reaches the top wall.
  • inputs:
    • alien_hit - high if an alien has been hit
    • opCode(2:0) – opcode to determine if the button has been pressed to fire a laser
    • shipX - current x coordinate of the ship
    • clk – system clock (50 MHz)
  • outputs:
    • laserX(9:0) - current x coordinate of the laser
    • laserY(9:0) - current y coordinate of the laser

alien_laser_control

  • Controls the alien's laser.
  • Fires a laser from random alien's at specific time increments.
  • The laser will reset if a life has been lost or it reaches the bottom wall.
  • inputs:
    • life_lost - high if a life has been lost
    • alienX - current x coordinate of the ship
    • status(9:0) - current status of the aliens
    • clk – system clock (50 MHz)
  • outputs:
    • alien_laserX(9:0) - current x coordinate of the laser
    • alien_laserY(9:0) - current y coordinate of the laser

Phase 4

Analysis of Proposed Work

First off, some things had to be changed because of limitations with the fpga. I ran out of slices because of the logic associated with all of the aliens. If I put any more logic into the system, weird thing would happen. Alien_laser_control had to be changed from aliens shooting lasers to lasers being fired from the top of the board. The aliens have no faces. They are only green blocks. Lastly, I was not able to restart the game when all lives had been lost. It would have been nice to have done everything as I had planned but I would have needed a fpga with more LUTs. These problems aside, everything works as planned. The aliens move back and forth across the screen. The ship fires lasers which make the aliens disappear if hit. The aliens kind of fire lasers which cause a life to be lost if it hits the ship. The score and life_lost outputs are updated when the appropriate actions have occurred.

Top-Level Block Diagram

finalschem.JPG

Project Snapshots

IMG_0314.JPG IMG_0315.JPG

Project Files

http://pluto.cse.msstate.edu:10010/dcsp/DSDFinalProj.zip