Running Doom on Our Custom CPU and Going Viral
The adventure of running the legendary game Doom on a from-scratch CPU design.
1Doom's Universal Appeal
Released in 1993, Doom is the legendary game that defined the FPS genre. To prove the saying 'Doom runs on anything', it's been ported to countless platforms from microcontrollers to toasters. We continued this tradition by running it on our custom CPU.
2Custom CPU Architecture
Our from-scratch CPU features a customized logic gate-level design. Initially, this FPGA-based design could only run simple programs like Pong. Running a complex game like Doom required significant memory and speed optimizations.
3Memory Challenge
Doom required 14MB WAD file plus additional runtime memory. Our FPGA's BRAM had less than 1MB capacity. DDR3 memory integration became a complex engineering problem due to latency and bus width issues.
4Cache Solution
We developed a cache mechanism to overcome DDR3's high latency. By storing active memory regions in BRAM, we significantly improved access speed. Optimized cache nearly eliminated DDR3's performance impact.
55-Stage Pipeline
Our CPU uses standard 5-stage pipeline: Instruction Fetch, Decode, Register Read, Execute, and Writeback. Each stage received custom optimizations. For example, the fetch stage was redesigned to handle DDR3's variable latency.
6Decode Improvements
The decode stage that breaks 32-bit instructions into parts was made more robust than our previous design. We replaced combinational reads with pipelined reading system to reduce critical path delay.
7Register Hazards
We developed a Register Usage Map (RUM) system to prevent Read-After-Write (RAW) hazards. This 32-bit map tracks which registers are in use at any pipeline stage, stalling operations when necessary.
8Execute Stage
The execute stage manages ALU operations, branch resolution and memory access. It can flush the pipeline on jump instructions and has special wait states for memory operations to improve system stability.
9Memory Management
DDR3's 30-60 cycle latency was the biggest bottleneck for ideal pipeline performance. We overcame this through multi-level caching and smart memory request scheduling algorithms.
10FPGA Implementation
After all optimizations, we successfully ran Doom in real-time on FPGA. While FPS rates were low by modern standards, it represented a major achievement for custom CPU design.
11Viral Impact
Our project video gained millions of views within days. The work generated significant excitement in hardware design communities, attracting attention from technology enthusiasts worldwide.
12Pushing Engineering Boundaries
This project demonstrates the possibilities of custom hardware design. Developing systems that can run complex software with limited resources embodies the essence of engineering innovation.
Original article: Hacker News: Front Page — Özel CPU'da Doom Çalıştırma ve Viral Olma