Tic-Tac-Toe is one of the best known games in the world. A group of students port Tic Tac Toe to Field Programmable Gate Array (FPGA) platform. The game uses the classical Tic Tac Toe grid of 9 squares, running on a VGA monitor using a 640x480 resolution. Players can use a PS/2 keyboard as the game controller. Pressing up, down, left and right select a square on the game board and hitting “ENTER” or “SPACE” place the square on the board. A player push “ESC” to restart the game at any time. LEDs on Arty A7 are used to keep track the score.
- • FPGA Development Board
- • Pmod PS/2 to connect to PS/2 Keyboards
- • to connect to VGA Display
- • PS/2 Keyboard
- • VGA Display
Toolchain & Language:
- Xilinx Vivado Design Suite
- Verilog Hardware Description Language
The top modules include the following inputs and ouputs:
The clock of the board (100 MHz in case of the Arty A7)
|PS2||PS2_CLK clock PS clock signal and PS_DATA PS2 data|
|RST_BTN||The reset button of the board|
|VGA||VGA_HS_0 H-sync, VGA_VS_0 V-sync, VGA_R to VGA_B VGA RGB|
|LED||Enable LED on Arty A7|
There are four submodules:
- vga640x480: used for interfacing with the VGA port at a 640x480 resolution, using a 25MHz clock
- keyboard_controller: used for reading keyboard inputs from the PS/2 port
- graphics_display: used for displaying the Tic tac toe game board as well as the squares placed on the screen
- check_winner: used for checking whether a player has won the game
Let's do a game demonstration. You can watch the demo video too. The game starts out with the middle square selected. Players can move the cursor by the arrow keys. When the player wants to make a selection, he/she presses "ENTER" or "SPACE". In this particular game, Player 1 is on blue while Player 2 is on red. After a player select the grid and presses the key to lock the selection, the game automatically jumps to the other player's turn. If the board is filled up, the game is draw. This leads to a new game. If a player wins, LEDs on Arty A7 will be updated to show the latest score. The player can push the reset button to reset the score.
The project file can be downloaded at https://github.com/Norkal/Ultimate-Tic-Tac-Toe/blob/Release/37MSRO.zip.