2048 is a single-player sliding tile puzzle video game. Your goal is to slide numbered tiles on a grid to combine them and create a tile with the number 2048. The game is won when a tile with the number 2048 appears on the board, hence the name of the game. The game is lost when the board is full and no more moves can be made.
The game is played on a 4x4 grid, with numbered tiles that slide when a player moves them using ui_in
pins. The game starts with two tiles with the number 2 on the board. The player can move the tiles in four directions: up, down, left, and right. When the player moves the tiles in a direction, the tiles slide as far as they can in that direction until they hit the edge of the board or another tile. If two tiles with the same number collide, they merge into a single tile with the sum of the two numbers. The resulting tile cannot merge with another tile again in the same move.
Use the ui_in
pins to move the tiles on the board:
ui_in pin |
Direction |
---|---|
0 | Up |
1 | Down |
2 | Left |
3 | Right |
After resetting the game, you will see a jumping "2048" animation on the screen. Press any of the ui_in[3:0]
pins to start the game. The game will start with two tiles with the number 2 on the board. Use the ui_in
pins to move the tiles in the desired direction. The game will end when the board is full and no more moves can be made.
Setting ui_in[7]
to 1 will enter unit test mode. In this mode, the game displays a colorful rectangle on the top of the screen, and accepts debug commands on the uio
pins. Check out the test bench for more information.
# | Input | Output | Bidirectional |
---|---|---|---|
0 | btn_up | R1 | debug_cmd |
1 | btn_down | G1 | debug_cmd |
2 | btn_left | B1 | debug_cmd |
3 | btn_right | VSync | debug_cmd |
4 | R0 | debug_data | |
5 | G0 | debug_data | |
6 | B0 | debug_data | |
7 | debug_mode | HSync | debug_data |