FPGA

DOOM

Overview

Spartan-7 FPGA and keyboard connected to a monitor running DOOM

I implemented a playable version of DOOM on a Spartan-7 FPGA. The game engine runs as C software on a MicroBlaze processor implemented in FPGA logic. The system combines DDR3 memory, SD card storage, USB keyboard input, and HDMI video output.

Block Diagram

Vivado block diagram showing MicroBlaze, the AXI interconnect, DDR3 controller, and peripheral interfaces

MicroBlaze accesses DDR3 and the peripheral controllers through the AXI interconnect. UART provides serial debugging output.

Waveform

Vivado simulation waveform showing sequential AXI writes to the HDMI controller with address, data, and response handshakes

The testbench writes incrementing 32-bit values through the HDMI controller's AXI interface. Addresses advance four bytes per word, while the address, data, and response signals show each write transaction.

DDR3

Vivado connections between MicroBlaze, the AXI interconnect, and the MIG DDR3 controller

MicroBlaze accesses DDR3 through the AXI interconnect and MIG memory controller. DDR3 holds the program code, heap, stack, and software data.

Vivado Address Editor showing the MIG DDR3 region from 0x80000000 to 0x87FFFFFF

The DDR3 address region spans 128 MiB, from 0x80000000 to 0x87FFFFFF.

Linker script declaring local BRAM and the external DDR3 memory region

The linker places program code, heap, and stack in the DDR3 region declared here.

VRAM

SystemVerilog Block Memory Generator instantiation with an AXI-facing port and a pixel-clock read port

Dual-port BRAM lets the processor write through AXI while the display reads on the pixel clock. Byte write strobes allow individual bytes to be updated.

The 320 × 200 framebuffer stores one 8-bit palette index per pixel: 64,000 bytes packed into 16,000 32-bit words.

C video_update function copying rendered framebuffer words into the memory-mapped HDMI framebuffer

video_update() copies each rendered frame into the HDMI controller's memory-mapped BRAM. The processor copies eight 32-bit words per loop iteration.

Keyboard

C code polling the USB keyboard, checking the USB host state, and reading HID modifier keys

Software polls USB keyboard reports and converts key changes into queued press and release events. DG_GetKey() supplies these events to DOOM. If the USB host becomes unavailable, held keys are released.

Vivado diagram showing the separate axi_quad_spi_0 and spi_usb AXI Quad SPI controllers

Two AXI Quad SPI controllers handle the peripherals: spi_usb connects to the MAX3421E USB host controller, while axi_quad_spi_0 connects to the SD card.

SD Card

C ensure_fatfs_mounted function mounting the SD card filesystem and checking the result

FATFS mounts the SD card so DOOM can read DOOM1.WAD, which contains the maps, graphics, and other game assets. A syscall adapter maps the game's file operations to FATFS. The mount helper checks for errors and reuses the mounted filesystem.

SystemVerilog assignments connecting SPI data, clock, and chip-select signals to the SD card pins

The top-level HDL maps SPI data, clock, and chip select to the SD card pins. Tri-state controls release the data pins when they are not being driven.

HDMI and Gameplay

DOOM gameplay displayed on the external monitor

DOOM renders at 320 × 200. We adapted an HDMI controller from an earlier lab to upscale it 2× in both directions to 640 × 400. Each source pixel becomes a 2 × 2 block, and a palette converts the stored indices into RGB colors.