A2Z runs a tiled racing game on a custom 16-bit FPGA CPU

FPGA, CPU, custom compiler

This is the read-only HTML version. For the full Visual Space experience, open the app.

FPGA computer, VGA graphics —

FPGA computer, VGA graphics —
FPGA computer, VGA graphics —

Source: A2Z Computer on Hackaday.io · f4hdk

Computer architecture

A2Z connects a homemade instruction set to a custom language, compiler, filesystem and graphical applications. Its deliberate simplicity makes the hardware easier to understand—and leaves software working around limits in speed, storage and compatibility.

❤️ 1

A racing game is a useful finish line for a homemade computer: it needs graphics, input, storage and enough software to make them cooperate. With A2Z Computer, creator f4hdk brought those pieces together around a custom 16-bit FPGA CPU, then wrote the language and tools used to program it. Shared on Hackaday.io, the project was an exercise in understanding the whole machine, not in making another platform for existing software.

The project page dates to November 13, 2016. In a December 17, 2017 update, f4hdk declared A2Z finished. That makes this a completed learning project to explore, rather than a new computer awaiting its next release.

A simple CPU hands more work to software

A2Z uses an Altera Cyclone IV EP4CE6 FPGA. Its Verilog CPU has a 16-bit integer ALU and data bus, a 24-bit address bus, and a Von Neumann architecture. Around it sit 2 MB of SRAM, a 2 kB boot ROM, PS/2 keyboard support and an SPI interface to 16 MB of flash storage.

The instruction set is f4hdk’s own design. There is no microcode, interrupt management or execution pipeline. In a January 2017 discussion, the creator explained the tradeoff: very low-level instructions keep decoding simple, but produce larger executables and spend substantial time fetching instructions over the bus.

That choice reaches all the way into the programming tools. Rather than adapting an existing compiler, f4hdk wrote an assembler and a cross-compiler in C. The compiler runs on a PC and accepts A2Z_Basic, a custom language combining elements of C and BASIC. The creator describes the compiler as the hardest part of the project.

The result is a connected hardware-and-software design, but not a compatibility platform. In the closing update, f4hdk rejected Linux and C-compiler porting as goals, pointing to constraints including direct-only hardware addressing, missing interrupts and no memory-management unit. Those were boundaries of the intended exercise, not promises of future features.

The racing game exposes the graphics budget

The FPGA’s video hardware supports 640 × 480 graphics at 8 bits per pixel, an 80-column by 30-line text overlay and double buffering in RAM shared with the CPU. Double buffering gives software a hidden frame to draw into before switching what the display shows.

The January 7, 2017 game log shows why that capability matters—and why it doesn't solve every performance problem. A2Z’s top-down car game uses double buffering, but f4hdk limited its viewing window to 320 × 240 pixels because of CPU speed. That entry describes a 12.5 MHz CPU; the December 2017 closing update later lists the machine at 25 MHz, without detailing that change in the excerpts available here.

The track uses two separate tile maps. Visual tiles are 128 × 128 pixels in a 40 × 40 grid, while obstacle tiles are 64 × 64 pixels in an 80 × 80 grid. This separates the track’s appearance from its collision layout. Collision checks use the vehicle’s four corners, locating each corner in an obstacle tile and testing it against that tile’s obstacles.

A PC-side C program generates the game data from two CSV files and one bitmap. Even with that tool, creating a circuit took enough work that f4hdk made only one. The game was the last application developed: a concrete demonstration of the computer’s capabilities, with its limits still visible.

Storage choices become application rules

A2Z also has a text editor, image viewer, map viewer and a file-explorer-style operating system. Their constraints make the connection between low-level design and everyday use especially clear.

The filesystem log describes a custom file-allocation table supporting folders and up to 1,024 entries. Files occupy contiguous storage, and their sizes are fixed at creation. Free space alone therefore isn't enough to create a file: there must be a sufficiently large uninterrupted region.

One small detail goes beyond the minimum demonstration. On each update, the filesystem rotates its allocation table among eight flash locations rather than repeatedly rewriting the same location. An index identifies the newest copy.

The text editor inherits other limits. It handles files up to 50 kB, within the 64 kB RAM range reserved for variables, and leaves file creation, deletion and renaming to the explorer. Copy, cut and paste inside the editor were contemplated but not implemented. These aren't abstract architecture decisions anymore; they're rules a person using the machine encounters.

Explore the machine without rebuilding it

The most accessible entry point is the PC emulator, which f4hdk describes as included in the project download with applications and example data already loaded into its emulated flash. Written in C with SFML for keyboard input and graphics, it models behavior rather than reproducing the FPGA’s internal structure.

That distinction matters when testing. The emulator omits the serial port and simplifies flash behavior, so software working there may still fail on hardware. A commenter reported getting it running on OS X in August 2018; their suggestion to use Verilator was a separate idea, not an implemented A2Z feature.

For someone studying computer design, A2Z offers a useful route through the layers: follow an application from its A2Z_Basic source, through the compiler and assembler, to the instructions the FPGA executes. The racing game supplies a particularly tangible test case. Its smaller viewport shows exactly where having a graphics mode stops being enough—and where the CPU and software must earn every frame.

Source: A2Z Computer

Hardware

3 Followers

A workshop for electronics and physical computing. Share circuits, boards, tools and prototypes; work through measurement and debugging, compare components, and document the choices that turn an idea into working hardware.

Visual Space is built for projects like this—where creators collaborate, organize goals, and grow communities around real work.