Slug Invaders Verilog Game
FPGA VGA displayed Verilog Game
Introduction
Slug Invaders is an FPGA VGA displayed Verilog game based on the classic video game Space Invaders. Slug Invaders is the final project of UCSC's CSE 100 Logic Design course and consists of creating the game entirely from scratch coded in Verilog. The game was coded on Vivado IDE and programmed on the Basys 3 FPGA development board. The criteria consisted of a moveable player who is bound by the screen and must avoid falling "ships" which after a second of landing on the floor despawn except for its point which stayed for another two seconds. The "ships" which are just shaped as blocks with a different colored point in the middle must be of random location on the screen and consist of a randomly selected size from 6 different options. The seven-segment display is incremented as the player gathers points and the border around the screen flashes when the player touches a ship and dies.
Approach
Slug invaders consist of many moving parts when referring to digital components such as counters, multiplexers, ring/non-ring selectors, etc. All of these components were coded entirely from scratch and properly tested with timing diagrams and used throughout the course for this project. For the sake of relevance, I will only be describing in detail the high components such as the state machines.
The most central verilog file is RGB_still.v with all state machines and pixel coloring. The coloring is done by defining the RGB colors based on the horizontal and verticle pixel addresses which are incremented by respective counters. The main approach is by setting a counter for the player and all ships and performing logic equations that refer to the pixel address and color pixels if desired. Logic for addresses of ships, boarders, points, and the player is used for the game's state machine responsible for incrementing score, gaining points, or ending the game.
State Machines
This game consists of many specific requirements and my approach to meeting them was to split up the logic into six different state machines. There is a "big" state machine that controls 5 identical other "ship" state machines. The "ship" state machine has states chill, falling, still, still2, the ship hit, freeze, flash occupant, and occupant only. The point is often referred to as the ship occupant. The big state machine on the other hand has states chill, release ship A, release ship B, and so on until ship E, and restart the game. The abstraction allows for easier development where the ship state machine can be perfected by itself before adding multiple instances. They also work together well because the ship location and what size the ship is is determined by flip flops storing clock selected selectors. This makes the combination of ship size and location dependent on when the game was started and a MHz clock which is essentially random. Each instance of the ship state machine has its own instance of the RGB ship module or Verilog function, and an instance of their own time counter. The big state machine triggers the ship state machines which pretty much are the game itself, depending on if a ship state machine game ends it can trigger the larger big state machine to end all the other ships' games. The six-state machines are all intertwined but abstraction and correct logic work together to produce a properly running game.
All files are included in the Github Repo linked below. I am missing a video of the game working, but am currently seeking out a Basys board to take one and post.