Author
Bahdan Shakh (b.shakh@innopolis.university)
Introduction
Games can give positive emotions and provide relaxation to a person. However, the main purpose of my project is to get a better understanding of the Verilog language. In addition, coding a game into FPGA will help to define the bounds of this programming language.
Hardware and software used:
MAX 10 FPGA (and it's power cable)
7-Segment display (output device)
Switches (input device)
Quartus Prime Lite Edition 18.1
Verilog/SystemVerilog HDL
Altera USB Blaster (USB Blaster transfers configuration data from PC to FPGA)
Project description
The game itself is a simple clicker game: a moving aiming point, represented by the DP led on a 7-segment display, a target, which is represented by a vertical line and an empty space, which consists of only the bottom line. At each second, the player is expected to determine whether the space inside of their aim represents a target or an empty space and move the switch into position 1 or 0 accordingly. After the second passes, FPGA checks if the player's choice is correct and makes a decision based of player's action. If the guess of a player is correct, game adds one point to their score, and subtracts one in other case.
Game also features a pause menu, which is used to stop the game and view the score. Pause menu can be turned on and off via a switch.
Location of points of interest on the board
![](https://habrastorage.org/getpro/habr/upload_files/453/ea0/256/453ea0256b28afcc8ea4d1cf6f95ecdc.png)
Schematic representation of the program
![](https://habrastorage.org/getpro/habr/upload_files/0fc/284/e48/0fc284e483c007ac7d762fab21bde932.png)
Project flow
As predicted in the draft of the project (sent via email to TAs), one of the main problems was the lack of knowledge on operating 7-segment displays. However, while this problem only took a relatively small amount of time and documentation read, randomization was a much tougher problem. I decided to use random numbers in my game due to it being objectively boring and easy for a project. As such, I considered a few approaches to the pseudo-randomization, which I will briefly describe:
Mathematical operations on a set number
Pros: Does provide random values, relatively easy to make
Cons: The set of values will remain the same with each new launchMathematical operations on an outside number from a sensor
Pros: Provides almost truly random values, does not repeat with new launch
Cons: Requires additional gadgets/sensors (e.g. temperature)Mathematical operations on an outside number from a user
Pros: Provides almost truly random values, does not repeat with new launch
Cons: Gets stuck in a loop if user does not input anythingMathematical operations on an outside number from a user with additional module for randomization on a set number (1) (chosen)
Pros: Provides almost truly random values, does not repeat with new launch, provides new value with each update
Cons: Not found yet
Conclusion
I described the key stages that I went through to implement a clicker game using an FPGA board, Quartus Prime software and Verilog hardware description language. This work has been implemented in the scope of «Computer Architecture» course in the Innopolis University.