Now on GitHub · Open-source gateware

A 486-class PC on an FPGA, written from scratch.

Mach86 is a clean-room PC-compatible computer in plain Verilog. It boots DOS from an SD card and runs DOS software and games on small ECP5 boards, with its own CPU core, BIOS, VGA, sound and USB input.

Mach86 booting FreeDOS: BIOS banner, SD card partitions, HimemX and the Mach86 mouse driver loading
Mach86 BIOS · FreeDOS640×480 · DVI
33MHz
486SX-class CPU
21.4MIPS
Measured on a board
16KB
Original BIOS
1.7M
Instruction tests from a real 386
DOOM
Shareware episode runs
00 / Clean room

The CPU, its microcode and the BIOS are original work, written from scratch against public documentation (clean-room policy) and checked instruction by instruction against a reference model and against test vectors captured from real hardware.

01 / Features

Everything a DOS game expects.

CPU, memory, graphics, sound, input and storage, all implemented in gateware and firmware written for this project.

CPU

486SX-class at 33 MHz

The 486SX instruction set, 16- and 32-bit, including BSWAP, CMPXCHG and XADD, at about 21 million instructions a second, measured on a board. A decoded-instruction cache and microcode make most instructions one or two clock cycles. How the CPU works →

Memory

Protected mode & DOS/4GW

32-bit code and stacks, interrupts and faults through gates: enough for DOS/4GW, and DOOM's shareware episode runs. Extended memory through HimemX. Details →

Video

VGA graphics

Text, CGA, EGA and VGA modes, up to 640×480 in 16 colours and 320×200 in 256 colours, over DVI/HDMI.

Audio

PC speaker & AdLib

PC speaker and AdLib (OPL2) sound, delivered over HDMI audio, S/PDIF or a one-pin DAC.

Input

USB keyboard & mouse

Low-speed USB keyboards and mice that speak the HID boot protocol. Includes an INT 33h mouse driver.

Storage

SD card

The microSD card is the hard disk: a boot partition, FAT32 for your programs, and MOUNT file.ISO to put a CD image on E:.

Firmware

Its own 16 KB BIOS

Written from scratch for Mach86. Boots FreeDOS.

Compat

Speed control

SLOW n slows the CPU for programs that break on fast machines, like the Monkey Island demo's sound driver.

Tools

Open toolchain

Plain Verilog that builds with Yosys and nextpnr. No vendor tools required.

02 / Screenshots

Running on real gateware.

Captured from Mach86 itself, not an emulator. Click to enlarge.

The Secret of Monkey Island running in EGA mode on Mach86
The Secret of Monkey Island demoEGA graphics and AdLib music, under SLOW 5
Mach86 BIOS booting FreeDOS from an SD card
Booting FreeDOSMach86 BIOS, FAT32 on SD, HimemX, mouse driver
Simtel MS-DOS archive directory browser running on Mach86
Simtel MS-DOS archiveBrowsing a CD image mounted as drive E:
03 / Verification

Heavily verified.

An x86 is only as good as its corner cases. Mach86 is tested at every level, from single instructions up to the pins.

1.7M

Instruction tests from real hardware

Test vectors captured from a real 386, run against the reference model, instruction by instruction.

1:1

Lockstep against a C model

The gateware runs alongside a reference model written in C, and the two are compared after every instruction.

SoC

Full-system simulation

The whole machine is simulated down to its pins, and booted in simulation before it goes on a board. How it is tested →

04 / Hardware

Runs on Machdyne computers.

Mach86 runs on the three primary computers from Machdyne.

$ yosys$ nextpnr-ecp5$ ecppackFully open-source build flow
05 / Get started

Build it, flash it, boot DOS.

The source, the BIOS, the tests and the documentation are on GitHub. To build you need a recent OSS CAD Suite, a C compiler, NASM, Python 3 and mtools; the tests also use Verilator and Icarus Verilog.

C:\>git clone https://github.com/machdyne/mach86
C:\>make lakritz rem the bitstream
C:\>tools/fetch_dos.sh rem FreeDOS + HimemX
C:\>make card rem the boot disk
C:\>make check rem run the test suite
C:\>