Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MIPS-VGPU: Virtual Graphics Processing Unit

A MIPS-based image processing system that demonstrates CPU-GPU style architecture using the MARS MIPS simulator. Images are processed through actual MIPS assembly code running on the simulator.

🎯 Features

  • Real MIPS Processing: Image filters execute as actual MIPS assembly instructions
  • Memory-Mapped I/O: Uses MMIO for CPU-GPU communication
  • Dynamic Resolution: Support for 64×64, 128×128, and 256×256 pixel processing
  • Three Filter Modes:
    • MODE_01: INVERT - XOR-based color inversion
    • MODE_02: GRAY - Weighted grayscale conversion
    • MODE_03: BRIGHT - Brightness adjustment with clamping
  • Download Output: Save processed images as PNG/JPG
  • Modern GUI: Pygame-based "Pixel Glitch" aesthetic frontend

📁 Project Structure

MIPS-VGPU/
├── cpu/                    # Python Frontend (Host)
│   ├── client.py          # Pygame GUI application
│   ├── requirements.txt   # Python dependencies
│   └── imgs/              # Sample images
│
├── vgpu/                   # VGPU Core
│   ├── brain/             # MIPS Assembly
│   │   ├── kernal.asm     # Kernel dispatcher
│   │   └── filters.asm    # Filter implementations
│   └── ...                # NetBeans project files
│
└── web_frontend/          # Alternative web interface
    ├── index.html
    ├── script.js
    └── style.css

🔧 Prerequisites

  • Java 23 (or compatible with your MARS build)
  • Python 3.8+ with Pygame
  • MARS MIPS Simulator with GpuBridge tool (included in E:\Programs\MARS-main)

🚀 Quick Start

Step 1: Compile and Start MARS

cd "E:\Programs\MARS-main"
& "C:\Program Files\Java\jdk-23\bin\javac.exe" -cp . mars\tools\GpuBridge.java
& "C:\Program Files\Java\jdk-23\bin\java.exe" Mars

Step 2: Load and Run the MIPS Kernel

  1. FileOpen → Navigate to vgpu/brain/kernal.asm
  2. Press F3 to assemble
  3. ToolsVGPU Bridge
  4. Click Connect to MIPSStart Listening
  5. Press F5 to run the kernel

Step 3: Start the Python Client

cd "MIPS-VGPU/cpu"
pip install -r requirements.txt
python client.py

Step 4: Process an Image

  1. Click LOAD_SOURCE → Select an image
  2. Click CONNECT_BUS → Connect to VGPU server
  3. Select a filter mode (INVERT / GRAY / BRIGHT)
  4. Select a resolution (64×64 / 128×128 / 256×256)
  5. Click EXECUTE_MIPS → Watch the magic!
  6. Click DOWNLOAD → Save the processed image

🏗️ Architecture

┌──────────────────┐     TCP/65432     ┌──────────────────┐
│   Python Client  │◄─────────────────►│   MARS (Java)    │
│   (Pygame GUI)   │     Pixel Data    │   GpuBridge.java │
└──────────────────┘                   └────────┬─────────┘
                                                │ MMIO
                                       ┌────────▼─────────┐
                                       │   MIPS Kernel    │
                                       │   kernal.asm     │
                                       │   + filters.asm  │
                                       └──────────────────┘

Memory Map

Address Purpose
0xFFFF0000 Command Flag (1=Ready, 0=Idle)
0xFFFF0004 Filter Mode (1=Invert, 2=Gray, 3=Bright)
0xFFFF0008 Pixel Count (set by host for dynamic resolution)
0x10040000 VRAM Start (pixel buffer, up to 256×256)

Communication Protocol

  1. Python sends: "IMG" + filter_mode (4B) + size (4B) + pixels
  2. Java writes: pixels to VRAM, pixel count, filter mode, sets flag=1
  3. MIPS kernel: detects flag, reads pixel count, processes all pixels, resets flag=0
  4. Java reads: processed pixels, sends: "RES" + size (4B) + pixels
  5. Python displays: the processed result

📝 Filter Implementations

Invert (XOR 0x00FFFFFF)

xor $t3, $t3, 0x00FFFFFF   # Flip all RGB bits

Grayscale

# gray = (R + G + B) / 3
add $t6, $t3, $t4    # R + G
add $t6, $t6, $t5    # + B
div $t6, $t7         # / 3

Brightness (+50, clamped to 255)

add $t3, $t3, 50     # R += 50
ble $t3, 255, ok     # Clamp to 255
li  $t3, 255

� GUI Controls

Button Function
LOAD_SOURCE Open file dialog to select input image
CONNECT_BUS Connect to MARS VGPU Bridge server
EXECUTE_MIPS Send image through MIPS for processing
DOWNLOAD Save processed image as PNG/JPG
Setting Options
Filter Mode INVERT, GRAY, BRIGHT
Resolution 64×64 (fast), 128×128 (medium), 256×256 (high quality)

⚡ Performance Notes

Resolution Pixels Processing Time
64×64 4,096 ~instant
128×128 16,384 ~1-2 seconds
256×256 65,536 ~5-10 seconds

Higher resolutions mean more MIPS instructions executed, resulting in longer processing times.

🔄 VGPU Bridge Controls

  • Start Listening: Begin accepting connections on port 65432
  • Connect to MIPS: Link bridge to MARS memory system
  • Reset: Close all connections and clear log (allows reconnecting)

👥 Team

  • Nathan Asif - System Architect (Kernel Dispatcher)
  • Additional team members as per project requirements

📄 License

This project is for educational purposes as part of the Computer Organization and Architecture course.


SSUET University | Semester 3 | COA Lab Project

MIPS-VGPU

About

MIPS-VGPU: Virtual Graphics Processing Unit

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages