Osegi
Hardware·2 min read

Tang Nano 20K 3D accelerator lifts Quake from 3.7 to 15 fps

A hobbyist built a 3D graphics accelerator inside a cheap Tang Nano 20K FPGA board. Quake on its RISC-V CPU went from 3.7 to 15 frames per second.

A small Tang Nano 20K FPGA development board connected to a monitor showing a Quake scene.
Image: Хабр

A homemade 3D accelerator on the Tang Nano 20K, a small FPGA board, takes Quake from 3.7 to 15 frames per second. The whole machine looks like something from the 90s: a 60 MHz RISC-V processor, 8 MB of SDRAM and HDMI output at 1280×720.

The project is called m20. It is the follow-up to the author's m9b, a general-purpose computer squeezed onto the Tang Nano 9K. The 20K has about 2.4 times more logic (20,736 four-input lookup tables), so the processor got faster, gained a floating-point unit and now has a graphics block next to it. Besides Quake, the board runs Descent, System Shock and Tomb Raider, all at 640 pixels wide.

How does the Tang Nano 20K 3D accelerator work?

The accelerator rasterises polygons, applies perspective-correct textures, lights them from a light map and checks depth. It outputs one pixel per clock cycle. The CPU sends it commands through an I/O window, and the accelerator reads textures from SDRAM and writes pixels there by itself. The video engine just shows whatever sits in the frame buffer. According to the author, the design was checked bit for bit against a C model. In a Quake timedemo at 640×360 it reached 15 fps.

What changed from the Tang Nano 9K version

The memory is different. Instead of two 4 MB PSRAM chips there is one 8 MB SDRAM with a 32-bit bus, peaking at 480 MB/s at 120 MHz. That looks slower than the old 576 MB/s on paper, but the author says the SDRAM controller is far more efficient and turned out to be the simplest part of the project.

There is no user flash inside this chip any more. A small boot ROM copies the main boot code from the board's 8 MB SPI flash into SDRAM and runs it from there. The video signal also needed a workaround: the serializer clock of 371.25 MHz jittered too much and one monitor kept losing the picture. Setting the board's MS5351 clock generator to 74.25 MHz, the pixel clock, left the PLL with a simple multiply by 5, and the image became stable.

USB needed hardware help too. Because the chip boots from external flash, its pins float for a while, and keyboards and mice plugged in at power-on never woke up. Two real 15 kΩ pull-down resistors on D+ and D− fixed that.

The price is independence. m9b lived entirely inside the FPGA, while m20 needs three chips on the board programmed before anything runs.

Apps worth a look

SUMO: the number puzzle

Tap the right tiles, add them up, hit the target. Easy to learn, hard to master. Free, for all ages.

Tags:tang nano 20kfpgarisc-vquake3d acceleratorretro computing

More from this day

See all →

More in: Hardware

See all →