DOOM
Overview
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
MicroBlaze accesses DDR3 and the peripheral controllers through the AXI interconnect. UART provides serial debugging output.
Waveform
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
MicroBlaze accesses DDR3 through the AXI interconnect and MIG memory controller. DDR3 holds the program code, heap, stack, and software data.
The DDR3 address region spans 128 MiB, from 0x80000000 to 0x87FFFFFF.
The linker places program code, heap, and stack in the DDR3 region declared here.
VRAM
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.
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
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.
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
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.
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.