A hardware-software co-design implementation of the classic Space Invaders game using SystemC for system-level modeling and simulation. This project demonstrates transaction-level modeling (TLM), hardware acceleration, neural network processing, and power modeling in a SystemC environment.
The system implements a modular architecture using SystemC TLM sockets for inter-module communication:
GameTop (Top-level module)
├── CPU (Game logic processor)
├── Bus (TLM interconnect)
├── Display (SDL2 rendering)
├── Input (Keyboard handling)
├── Memory (System memory)
├── Accelerator (Collision detection HW)
├── NNAccelerator (Neural network processing)
└── PowerModel (Power consumption modeling)
- CPU (
modules/cpu.{h,cpp}
): Main game logic processor implementing Space Invaders gameplay, including player movement, bullet physics, collision detection, and game state management - Bus (
modules/bus.{h,cpp}
): TLM-based interconnect routing transactions between CPU and peripheral modules using address decoding - Display (
modules/display.{h,cpp}
): SDL2-based graphics renderer with command queue processing for draw and text operations - Input (
modules/input.{h,cpp}
): Keyboard input handler with interrupt generation capabilities - Accelerator (
modules/accelerator.{h,cpp}
): Hardware accelerator for collision detection and row boundary calculations with parallel processing - NNAccelerator (
modules/nn_accelerator.{h,cpp}
): Neural network processing unit implementing MLP for AI-based game behavior - Memory (
modules/memory.{h,cpp}
): System memory module with TLM interface - PowerModel (
modules/power_model.{h,cpp}
): Dynamic power consumption modeling and DVFS control
- Transaction-Level Modeling: TLM 2.0 sockets for communication between modules
- Hardware Acceleration: Dedicated accelerator for computationally intensive collision detection
- Neural Network Integration: On-chip MLP for adaptive gameplay mechanics
- Power Modeling: Dynamic power tracking with frequency scaling simulation
- Quantum Random Number Generation: QRNG implementation for enhanced randomness
- Debug Support: Comprehensive debug mode with performance metrics
- Input Controller:
0x1000
- Display Controller:
0x2000
- Power Manager:
0x3000
- Accelerator:
0x4000
- System Memory:
0x5000-0x6FFF
- NN Accelerator:
0x6000
- 5x11 invader formation with row-based movement patterns
- Destructible bunkers with pixel-level damage tracking
- Multi-bullet system (100 player, 200 invader bullets max)
- Adaptive difficulty through neural network-based speed control
The collision detection accelerator processes invader rows in parallel, computing:
- Row boundary calculations (min/max positions)
- Bullet-invader collision detection
- Bunker collision and damage modeling
- SystemC 2.3+: System-level modeling framework
- SDL2: Graphics and input handling
- SDL2_ttf: Text rendering support
- SDL2_mixer: Audio support (linked but optional)
- C++17 compatible compiler (GCC recommended)
- POSIX-compliant system (Linux/macOS)
- SystemC installation with TLM support
sudo apt-get install libsystemc-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
- Install SystemC from https://systemc.org
- Install SDL2 development libraries
- Set
SYSTEMC_HOME
environment variable if needed
make clean
make all
make all
: Build the executablemake run
: Build and run the simulationmake debug
: Build and run with debug outputmake clean
: Remove build artifacts
./space_invaders
./space_invaders -debug
Debug mode provides detailed logging of:
- SystemC simulation events
- TLM transaction details
- Performance metrics
- Power consumption data
- Left/Right Arrow: Move player
- Spacebar: Fire bullets
- ESC: Quit game
The simulator includes several performance optimizations:
- TLM Direct Memory Interface (DMI) for high-speed memory access
- Parallel collision detection using hardware acceleration
- Optimized SDL2 rendering with command queues
- Quantum keeper for SystemC simulation performance
- Uses TLM 2.0 blocking transport for simplicity and determinism
- Implements approximate timing for realistic hardware modeling
- Neural network training occurs during gameplay for adaptive behavior
- Power modeling includes both static and dynamic components
- QRNG provides quantum-inspired randomness for enhanced gameplay variety
This project is intended for educational and research purposes, demonstrating SystemC-based hardware-software co-design methodologies.