Introduction: Make Your Own 2-Player Simon Says Game

This Instructable explains how to make a Simon Says game using an Altera DE2-115 Cyclone IV FPGA board. This project was done for ECE2220 (Digital Logic) at the University of Manitoba.

The video above shows the working VGA output and how it changes depending on the input to the board.

Things you will need:

  1. A Rock Band drum kit that you don’t mind modifying and the following items to modify it:
    1. 1 bread board
    2. 4x 10kOhm resistors
    3. 4x 5nF capacitors
    4. 2x HC123A Dual retriggerable monostable multivibrators
    5. wire
    6. 1 expansion header ribbon
  2. An Altera DE2-115 FPGA board
  3. Quartus II Web Edition (download here: http://dl.altera.com/?edition=lite)
  4. A VGA monitor for output

The project is written using Verilog HDL.

The game consists of three major sections:

  1. User input from a modified Rock Band / Guitar Hero drum kit - interfaced using a breadboard
  2. VGA output using the VGA port on the Altera DE2-115 Board
  3. Store and check capabilities that store the input from player 1 and player 2 and compare them to see if they match.

The complete project file can be downloaded from this page.

Game Creators:
Keeley Edwards
Ainslee Heim
Evan Kerr
Samuel Rohatynsky

Step 1: Structure Map

Step 2: The Drum Kit: Modifications

Created by: Evan Kerr

Hardware

Before the Rock Band drum kit can be interfaced with the DE2 board, the following modifications must be made:

  1. Remove the drum pads by pulling on them with both hands.
  2. Using needle nose pliers, remove the wire from the connectors being careful not to damage the circuitry.
  3. Connect wires to the female socket of each drum.
  4. Using a hand saw, saw a slit into the side of the case at each drum to ensure that the wires are not damaged during use.
  5. Connect the drum wires to the correct pins on the DE2 board expansion header using the bread board. (This can be done according to the breadboard schematic shown. The GPIO expansion header's pinout is also shown here, and can be found in the DE2 User Manual.)

HDL

The verilog code for the integration and storing of user inputs can be found in the main module of the project. Because the drumkit outputs signals as an active low square pulse, the drums can be treated exactly as the push buttons on the board.

Step 3: VGA Output

Created by: Keeley Edwards

The VGA output has a resolution of 640x480 and a 25MHz clock. The timing specifications used can also be found in the user manual for the board:

ftp://ftp.altera.com/up/pub/Altera_Material/12.1/B...

This series of modules accepts inputs from the top module. It requires:

- state: is the game or the user playing, or is the game in a static mode?
- colour: which button is being activated
- clk: the board's internal 50MHz clock. which is converted to a 25MHz clock in the code.
- level: the current level that the player is on
- match: the signal to indicate that a player has correctly matched the computer
- win: a signal to indicate that the player has won the game

The top module of the VGA Output series is shared with the main module of the project outputs to the screen and to the board's digital analog converter (DAC):

- hsync: controls the horizontal sync pin on the VGA connector
- vsync: controls the vertical sync pin on the VGA connector
- vga_R: passes an 8 bit binary number to the DAC for the red channel
- vga_G: passes an 8 bit binary number to the DAC for the green channel
- vga_B: passes an 8 bit binary number to the DAC for the blue channel
- vga_sync: passes the sync signal to the DAC
- vga_blank: passes the blank signal to the DAC
- vga_clk: passes the 25MHz VGA clock to the DAC

The top module passes information to a display module that describes the location and bit pattern of each of the items on the display, along with their colour.

The full VGA section can be downloaded from this page.

Special thanks to:

Brandon Hill for access to his VGA control code
Paul White, Ramin Soltanzadeh, Ahmad Byagowi and Jose Mijares Chan for their help with troubleshooting.

Step 4: Store and Check User Inputs

Created by: Ainslee Heim and Keeley Edwards

This module verifies that the player 2 has entered the correct sequence of colours as displayed by player 1.

Each player's sequence is stored in a vector of 4-bit binary numbers. The colours are as follows:

4'b0001: Red

4'b0010: Yellow

4'b0100: Blue

4'b1000: Green

These colours correspond to the rock band drum kit.

The store function fills each player's vector on the positive edge of the drum kit signal. On each positive edge, a register "colourStore" in the main module of the game is updated to the colours listed above. colourStore is passed to the store module where each player vector is filled. Each player inputs a sequence of colours. Once Player1 and Player2 are filled, they are passed back to the main module and checked for a match.

The store module takes the following inputs and outputs:
Inputs:

- colourStore: the most recent colour input by the user
- player: a switch controlled variable that indicates if Player1 or Player2 is playin

Outputs:

- Player1, Player2: n-bit vectors, initially empty, to be filled with the user inputs as they come in

Step 5: Future Improvements

This is the first version of "Simon Says" and while it is fully operational, there is plenty of room for improvement. ColourComplement recommends the following changes to be made in the future:

  1. Convert the VGA output to an image buffer array - similar to how screens are mapped by GPUs.
  2. Output text to the VGA display using a font ROM (this was started, and some code can be downloaded from this page).
  3. Use bitmap images for the buttons, instead of simple squares.
  4. Implement audio cues that correspond to the visual cues.
  5. Add multiple levels and more complex input sequences.

Step 6: Random Number Generation (not Included)

Created by: Samuel Rohatynsky

This module was not included in the project, but could be implemented in place of Player 1.

The Random Number Generation (RNG) is handled by a modified Linear Feedback Shift Register. The number generation is not truly random, being merely pseudo-random, but for the purposes of this project pseudo-random numbers work just as well.

The inputs of the RNG module are as follows:
- One 22 bit number which serves as the data to be randomized
- The number can be inputted via a noise generator or switches to start and then afterwards the output of the module can be used as the new input.
- The current Round Number of the game
- The current Level Number of the game

The outputs of the RNG module are as follows:

-A randomized 22 bit number.

This module works by polynomial multiplication. By multiplying bits by the power of other bits many times, a very long sequence is created. The same “seeds” or starting number inputs will create the same sequence, but the sequence can be interrupted by changing Rounds and Levels or by losing at the game.

An additional module takes this 22 bit input and uses it to create a vector containing nine 2 bit numbers. This vector is then outputted and passed to the rest of the project.

The complete random number generation code can be downloaded from this page.

Step 7: References

  1. DE2-115 User Manual (Altera) [Online] ftp://ftp.altera.com/up/pub/Altera_Material/12.1/B... . Accessed on: 26 November, 2015
  2. Pong P. Chu, FPGA Prototyping by Verilog Examples Xilinx Spartan-3 Version, John Wiley & Sons, Sep 20, 2011
  3. P. Schaumont, 'A Random Number Generator in Verilog, A Design Lecture', 2008. [Online]. Available: http://rijndael.ece.vt.edu/schaum/slides/ddii/lec... [Accessed: 28- Nov- 2015]
  4. Outputlogic.com, 'OutputLogic.com » About', 2015. [Online]. Available: http://rijndael.ece.vt.edu/schaum/slides/ddii/lec... [Accessed: 28- Nov- 2015]
  5. Easics.be, 'Easics', 2015. [Online]. Available: http://rijndael.ece.vt.edu/schaum/slides/ddii/lec... [Accessed: 28- Nov- 2015].
  6. National Semiconductor Corporation, Logic Databook Volume 1