Tetris PDF
Tetris PDF
Tetris PDF
Abstract—Tetris game is a classic game of logic control. This article share VGA control through multiplexing units; game control
gives a programming design of Tetris game based on the FPGA modules, graphic display module and text display module
using VHDL. Game players can move and rotate blocks with the complete data exchange through the storage units. The specific
PS/2 interface keyboard, and the game video is showed in a VGA module structure diagram is shown in Figure 1.
monitor. The game realized the function of the movement and
JUDSKLF
rotation of blocks, randomly generating next blocks, eliminating GLVSOD\
rows, getting scores and speeding up. It also contained the normal
mode corresponding to 7 types of blocks and the expert mode
corresponding to 11 types of blocks. The successful transplant of
NH\ERDUG JDPH PHPRU\ PXOWLSOH[LQJ 9*$
Tetris game provides a template for the development of other FRQWURO FRQWURO XQLW XQLW PRGXOH
visual control systems in the FPGA.
Tetris game is a popular television and handheld game. A. Keyboard control module
Because of its strict logic, simple operation, appropriate The keyboard control module is identified by the keyboard
programming difficulty, strong entertainment and other recognition and the filter of key value. Among them, the
characteristics. Tetris game has been transplanted to various keyboard recognition part completes one-way communication
platforms, such as personal computers, mobile phones, handheld from PS/2 keyboard to FPGA. When reading the scan code, tip
game consoles. It spawns a variety of different versions, and signal “an” turns from ‘0’ to ‘1’, or from ‘1’ to ‘0’; Components
becomes one of the classic programming training and game which been connected with this module, can determine whether
development theme. the scan codes has been read through the value of the signal
This programming of Tetris game on the FPGA can provide “an” change.
templates for the similar development of visual control system The key value filter can filter the scan codes of the keyboard.
and game development. And then other values are filtered out with the needed scan
codes left. Keys that are used in table 1.
II. OVERVIEW OF THE GAME DESIGN
Table 1. Game key function table
The main body of the game is composed of three parts: Keys Function description
controlling input, processing logic, and displaying output. F1 Stop game
Controlling input part includes PS/2 interface keyboard.
F2 Normal game mode
Players use keyboards to select the game mode, control the game
process, and complete the movement and rotation of the blocks. F3 Expert game mode
Logic processing part is using a FPGA chip to complete. The A Move blocks left
program is totally realized in the FPGA chip, and communicates D Move blocks right
with the controlling input and displaying output part through the space Rotate blocks
corresponding interface.
Display part transmits the VGA signals to outer. With an B. Game control module
external monitor shows games screen, visual operation is The game control module is the main body of the game.
complete. Through the “state machine” describes the process of the game.
A total of 15 States are in the game, which means 15 kinds of
III. STRUCTURE OF THE GAME MODULES
values of the corresponding state. Figure 2 shows the game state
The game is composed of 7 modules: keyboard control transition diagram. Table 2 describes state machine.
module, game control module, text display module, and graphic Whether in the normal or expert mode, the blocks are
display module, storage unit, multiplexing unit and VGA composed of four sub-blocks. All blocks operation is achieved
modules. The graphic display module and text display module by changing the coordinate values of sub-blocks.
2926
F[
This module also helps divide game and feature area on the
screen, as shown in Figure 4.
HC and VC, is respectively the VGA Line synchronizing
signal Field synchronizing signal.When HC and VC scanned are
into two specific areas, return '1' as vid and text values, which
\
F
means this two range is a legal area. Graphic display module
operates the area vid='1', and text display module operates the
area text='1'.
KF
display unit. In a graphic display unit, the outermost layer (white YLG þÿ
square area) pixel is set to:
pix (2 downto 0) <= “000”;
The outer layer (light gray area) pixels set to:
2927
[6] Fuqi Liu. FPGA embedded project development practice. Beijing: Publishing House of electronics industry, 2009.
2928