DEV Community

Cover image for Doom Runs on a Scratch-Built RISC-V CPU on an FPGA
circuitrocks
circuitrocks

Posted on • Originally published at blog.circuit.rocks

Doom Runs on a Scratch-Built RISC-V CPU on an FPGA

Two weeks after wiring up a processor that existed only as logic gates, an MIT student team watched Doom crawl to life on it. The 1993 shooter has already been forced onto calculators, cameras, and printers, but this port lands somewhere rarer: a CPU the team designed themselves, gate by gate, then dropped onto an FPGA.

Armaan Gomes led the build. The group wrote a five-stage pipelined CPU around the open RISC-V instruction set, wired it to peripherals, and adapted the Doom engine source id Software released years ago so it would compile for their machine. Before this, the chip had only run their own small programs, a Pong clone and some Mandelbrot sets. Jumping from those to a full commercial game engine is a large leap, and it surfaced bugs that could live in either the game code or the silicon. As Gomes puts it, when it breaks "you don't know if the code is wrong, or if your CPU is incorrect."

From 0.7 FPS to actually playable

The first working build ran at 0.7 frames per second, technically Doom but practically a slideshow. Gomes refused to leave it there. Overclocking the core by 25 percent and tightening the instruction fetch stage pushed it to 2.5 FPS. Adding hardware multiply instructions the CPU had been missing took it to 3.5 FPS. Writing video data straight to block RAM while pipelining cache reads landed 6.7 FPS. The biggest jump came from software, not hardware: compiler optimization alone dragged the game up to 15–20 FPS, which Gomes calls "very playable and quite fun."

Want to design a CPU yourself?

You don't need an MIT lab to start. A hobby FPGA board and an open toolchain are enough to begin writing your own logic:

  • Pick up a low-cost FPGA dev board and learn Verilog or VHDL. Blink an LED first, then build a counter, then a simple RISC-V core.
  • Port a tiny program before a big one. Gomes ran Pong and Mandelbrot sets long before Doom, and each caught real bugs in the pipeline.
  • Doom already runs on a $4 RP2040 Pico, so you have a cheap yardstick to benchmark your homebrew chip against a stock microcontroller.

For the pipeline diagrams and the exact optimizations behind each frame-rate gain, read the full breakdown of the build on Hackster.


Originally published on blog.circuit.rocks.

maker #electronics #diy #engineering #circuitrocks

Top comments (0)