-
-
320×240 Mandelbrot fractal computed by my simulated GPU using 8 lanes and 4 warps, with every pixel verified against a Python reference.
-
128x128 Mandelbrot fractal computed by my simulated GPU using 8 lanes and 4 warps, with every pixel verified against a Python reference.
-
16x16 Mandelbrot fractal computed by my simulated GPU using 8 lanes and 4 warps, with every pixel verified against a Python reference.
Inspiration
I previously built an RV32I core, and I wanted to explore a different kind of processor. A GPU felt like the next challenge: instead of executing one thread, how do you run the same program across multiple pieces of data?
Warps, lanes, and kernels were new to me. I wanted to understand them by building a working design and using it to compute something I could actually see.
What it does
This project is a programmable GPU written in SystemVerilog and verified in simulation. It has one core, eight execution lanes, and four resident warps, with shared instruction fetch and decode.
Its main demo computes Mandelbrot images at 16×16, 128×128, and 320×240. The GPU calculates the pixels and writes them into simulated RAM. Every pixel and iteration count is compared against an independent Python reference.
How I built it
I started with the ALU and register file, tested them individually, and connected them into an execution lane. From there, I added parallel lanes, warp scheduling, instruction decoding, and memory access.
The design uses a custom 32-bit ISA with integer operations, Q16.16 fixed-point multiplication, branches, loads and stores, and GPU-specific instructions for masks, voting, barriers, and warp spawning.
I also built a Python assembler to turn readable assembly into machine code, a Python GPU model to check instruction behavior, and performance counters to measure execution.
Challenges I faced
Deciding on the ISA was one of the first challenges. My previous experience was with RISC-V, but this design needed explicit support for parallel execution and warp control.
Creating warps and writing kernels required a different way of thinking. I had to manage separate state for each warp, route memory responses to the correct destination, and handle lanes that finished their work at different times.
Divergence was especially interesting. In Mandelbrot, some pixels escape quickly while others keep iterating. Active masks and per-warp mask stacks let those lanes stop updating, then restore them before storing the final results.
I also couldn’t get an FPGA board during the weekend, so the project remained in simulation.
What I learned
I learned how SIMD execution, warp scheduling, divergence, and synchronization fit together in a programmable processor. I also gained experience building an assembler and reference model alongside hardware.
The biggest lesson was to build and verify small pieces first. Starting with a tiny image made debugging manageable before moving to larger resolutions.
Accomplishments
- Built an integrated GPU with eight lanes and four resident warps.
- Implemented a custom ISA, assembler, and Python reference model.
- Verified complete Mandelbrot frames across three resolutions.
- Passed 26 SystemVerilog testbenches and 18 Python tests.
- Measured execution cycles, instruction counts, lane utilization, and memory waits.
What’s next
My next goal is to synthesize the design and run it on a physical FPGA. That will let me investigate timing, resource usage, and real hardware behavior.
After that, I want to improve the design bit by bit and create more kernels for rendering, shading, and image processing, while testing more edge cases along the way.