The game is inspired by the original Butterfly-Escape game and it is implemented by VHDL and deployed on FPGA hardware with VGA output.2
Figure 1: Initial seven-segment and board state at system startup
| Name |
|---|
| Ashkan Marali |
| Alireza Sobhdoost |
Butterfly Escape is a real-time hardware game where the player shoots colored balls into a moving chain. Matching three or more balls eliminates them and increases the score.
The entire system is designed in pure VHDL, including:
- VGA controller
- Game logic
- Memory controller
- User input handling
- Seven-segment display
- ๐ฎ Real-time gameplay on FPGA
- ๐ฅ๏ธ VGA output (640ร480 @60Hz)
- ๐ข Hardware seven-segment score display
- โ๏ธ Modular FSM-based design
- ๐ฅ Special balls and chain reactions
- ๐ฏ 5-button control system
- ๐ Score & timer system
Figure 2: Shooting sequence of red balls
Figure 3: Shooting sequence of a special ball impact
Figure 4: Ball shooting mechanism
Figure 5: Continuous ball spawning
Figure 6: Ball elimination effect
Figure 7: Random chain movement
Figure 8: Special ball behavior
Figure 9: Main game state machine
The system is based on multiple interconnected FSMs:
- Game controller
- Ball manager
- Shooting controller
- Memory handler
- VGA renderer
Figure 10: Ball handling and shooting FSMs
Figure 11: User input and memory management FSMs
Figure 12: INIT, WIN, and LOSS screens
Figure 13: Initial 7-segment display
Figure 14: Score update after special impact
Figure 15: Final game states on seven-segment display
Figure 16: Random and normal spawning boards (you can choose the type of generated board bu a switch on fpga)
| Button | Function |
|---|---|
| BTN1 | Rotate Right |
| BTN4 | Rotate Left |
| BTN2 | Shoot |
| BTN3 | Start |
| RSTN | Reset |
- GHDL
- GTKWave
- Quartus Prime
- GNU Make
make compile <entity's name>
make compile-tb <test-bench's entity name>
make simu <test-bench's entity name>
make wave <test-bench's entity name>as an example
make compile board_pkg,game_types_pkg,lfsr_pkg,graphics_pkg,led_manager,seven_seg_driver,button_ctrl,game_fsm,memory,lfsr_generator,board_gen,ball_shift_fsm,ball_shooting,vga_controller,projectile_renderer,projectile_fsm,collision_detector,vga_display,global_timer,board_to_ram,butterfly_escapemake compile-tb lfsr_tb
make simu lfsr_tbButterfly-Escape-VHDL/
โ
โโโ rtl/ # Main VHDL sources
โโโ tb/ # Testbenches
โโโ docs/ # Documentation
โโโ Imgs&Vids/ # Images and GIFs
โโโ synthesis/ # FPGA synthesis
โโโ sim/ # Simulation outputs
- 32-bit encoded ball data
- Parallel VGA and logic access
- Buffered write system
To prevent visual artifacts:
- Writes occur during blanking intervals
- Display reads are isolated
- Double-buffering logic is applied
- Synchronization with VGA clock
โ๏ธ No flicker โ๏ธ Smooth animation โ๏ธ Stable rendering โ๏ธ Efficient memory usage
| Parameter | Value |
|---|---|
| System Clock | 50 MHz |
| VGA Resolution | 640ร480 |
| FPGA Resource Use | ~8k LUTs |
| FPGA Board | Cyclone V FPGA 5CEBA4F23C7N |
| Color Depth | 12-bit |
| Projectile Speed | 8 px/frame |
| Timer Tick | 1 s |
This project is developed for educational purposes under the MIT LICENSE .
- Guilan University โ Computer Engineering
- Course: Computer Aided Digital Systems by Dr. Aminian
- Tools: Quartus, GHDL, GTKWave
- Platform: Cyclone V FPGA
Designed and implemented with passion for digital systems













