Skip to content

Latest commit

 

History

History
330 lines (240 loc) · 7.16 KB

File metadata and controls

330 lines (240 loc) · 7.16 KB

🦋 Butterfly Escape – VHDL FPGA Game

VHDL License Platform

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


📸 Initialization


Figure 1: Initial seven-segment and board state at system startup


👨‍💻 Contributors

Name
Ashkan Marali
Alireza Sobhdoost

📖 Overview

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

⭐ Features

  • 🎮 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

🎥 Gameplay Demonstration

Shooting and Impact


Figure 2: Shooting sequence of red balls


Figure 3: Shooting sequence of a special ball impact

Gameplay Animations (GIFs)

Shooting


Figure 4: Ball shooting mechanism

Spawning


Figure 5: Continuous ball spawning

Explosion


Figure 6: Ball elimination effect

Random Movement


Figure 7: Random chain movement

Special Ball Impact


Figure 8: Special ball behavior


🏗️ System Architecture


Figure 9: Main game state machine

The system is based on multiple interconnected FSMs:

  • Game controller
  • Ball manager
  • Shooting controller
  • Memory handler
  • VGA renderer

📊 Internal State Machines

Ball & Shooting States

Figure 10: Ball handling and shooting FSMs

User & Memory States

Figure 11: User input and memory management FSMs


🕹️ Game States on VGA Monitor

Figure 12: INIT, WIN, and LOSS screens


🔢 Seven-Segment Display

Initial State


Figure 13: Initial 7-segment display

Score & Timer

Figure 14: Score update after special impact

Win & Lose

Figure 15: Final game states on seven-segment display


🎲 Random & Normal Board Generation

Figure 16: Random and normal spawning boards (you can choose the type of generated board bu a switch on fpga)


🎮 Controls

Button Function
BTN1 Rotate Right
BTN4 Rotate Left
BTN2 Shoot
BTN3 Start
RSTN Reset

🧪 Build & Simulation

Requirements

  • GHDL
  • GTKWave
  • Quartus Prime
  • GNU Make

Commands

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_escape
make compile-tb lfsr_tb
make simu lfsr_tb

📁 Project Structure

Butterfly-Escape-VHDL/
│
├── rtl/          # Main VHDL sources
├── tb/           # Testbenches
├── docs/         # Documentation
├── Imgs&Vids/    # Images and GIFs
├── synthesis/    # FPGA synthesis
├── sim/          # Simulation outputs

💾 Memory Architecture

  • 32-bit encoded ball data
  • Parallel VGA and logic access
  • Buffered write system

🖥️ VGA Caching Technique

To prevent visual artifacts:

  • Writes occur during blanking intervals
  • Display reads are isolated
  • Double-buffering logic is applied
  • Synchronization with VGA clock

Benefits

✔️ No flicker ✔️ Smooth animation ✔️ Stable rendering ✔️ Efficient memory usage


⚙️ Technical Specifications

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

📜 License

This project is developed for educational purposes under the MIT LICENSE .


🙏 Acknowledgments

  • 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