Skip to content

Ohtears/Butterfly-Escape-VHDL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฆ‹ 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

About

Butterfly Escape is a real-time hardware game implemented in VHDL where the player shoots colored balls into a moving chain. Matching three or more balls eliminates them and increases the score.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors