GitHub - nand2mario/z86: An open-source superscaler out-of-order 32-bit x86 CPU in SystemVerilog

GitHub

8 min read Original article ↗

z86 is, to our knowledge, the first open-source superscalar out-of-order x86 (i686 + x87 FPU, without MMX/SSE) processor written in SystemVerilog, inspired by the Intel P6 and targeting Xilinx UltraScale+ FPGAs (ZCU104 XCZU7EV and Kria KV260 XCK26). Paired with the companion z86_pc PC SoC platform, it boots MS-DOS, Windows 95/98/NT4, and 32-bit Linux 6.18. Both RTL and microcode are released under the Apache 2.0 license.


Microarchitecture

z86 Microarchitecture

Key Architecture Features

Full profile Z86_PROFILE_FULL targets ZCU104; a narrower Z86_PROFILE_LITE targets Kria KV260:

  • ISA & Modes: Full IA-32 (i686, Real, protected, VM86, 4 KiB & 4 MiB paging, CR0.CD no-fill, WBINVD/INVD, fixed + 8 variable MTRRs) and full 80-bit x87 FPU (86-bit internal datapath).
  • Open-Source Microcode: Unified symbolic assembly compiling into a 2K-triad MSROM with speculative microbranch prediction (U_JCC_T/U_JCC_N), XLAT tables, integer/system CROM, and FPROM (< 0.75 ULP 2-way Horner minimax transcendentals).
  • Fetch & Branch Prediction: 16 KiB 4-way VIPT L1I with co-located 4-way BRAM ILD mark cache, 64-entry + 8-PSE ITLB, 2,048-entry 4-way BTB, 8,192-entry Gshare/Tournament predictor (11-bit checkpointed GHR), 8-entry loop predictor, and 16-entry return stack with Stage-16/17 CALL forwarding.
  • Superscalar Decode: 48B LRU instruction stream buffer, 16B/clk 4-nibble carry-select length decoder, and 4-1-1 (D0 complex + D1/D2 simple, incl. not-taken D0 pairing) decoders feeding an 8-entry decode queue.
  • Out-of-Order Core: 3-wide register renaming, 40-entry ROB (3-wide cross-macro spanning retire), 16-entry 5-port RS (P0–P4, Stage-41 3-cycle speculative load→ALU wakeup), and 3 writeback buses.
  • Execution Units: P0 (ALU0, 1c funnel shift, MUL 1/clk, Radix-16 DIV, 86-bit x87 FADD 3c / FMUL 5c, Radix-128 FDIV, Radix-4 FSQRT), P1 (ALU1 + macro/micro branch unit), P2 (Load AGU + 2-cycle segment_unit), P3 (Store AGU), and P4 (Store Data).
  • Memory & Caches: 16-load / 12-store MOB (store-to-load forwarding, 64-bit store coalescing, 32B fast strings, self-modifying-code filter), 64-entry + 8-PSE DTLB, 1,024-entry L2 TLB + hardware page-table walker & MTRR evaluator, even/odd banked 16 KiB 4-way WB VIPT L1D (3c hit), and 512 KiB 4-way URAM L2 (10–11c hit, 4 MSHRs, 8-entry stride prefetcher).
  • Live Hardware Debugger: AXI4-safe BUFGCE clock-gated halt/step, 2 HW breakpoints, exception/stall watchdog, and 512-entry BRAM retire trace (via z86-dbg in z86_pc).

FPGA Implementation Results

Routed v35 full-PC z86_pc Vivado 2024.2.2 builds (CLOCK=115, Performance_Explore, 0 routing/DRC errors, WHS > 0):

Platform Profile CLB LUTs FFs RAMB36 eq. URAM288 DSP48E2 Worst-Case Fmax
ZCU104 (XCZU7EV) Z86_PROFILE_FULL 184,958 (80.3%) 59,781 147.5 / 312 24 / 96 23 104.7 MHz
Kria KV260 (XCK26) Z86_PROFILE_LITE 95,617 (81.6%) 45,903 109.0 / 144 16 / 64 20 114.7 MHz

Both profiles clear 100 MHz worst-case timing by +0.45–1.28 ns (CPU+L2 alone is 168.8k LUTs on FULL and 79.5k LUTs on LITE); on live v35 silicon, both boards run reliably at up to 150 MHz at room temperature (z86-run --clock). In bare-metal PM32 Dhrystone (--iters 200, L1 profile), v35 FULL reaches 1.0614 DMIPS/MHz (CPI 0.819) and LITE reaches 0.5195 DMIPS/MHz (CPI 1.672).


Real-World DOS Benchmark Performance

Live hardware measurements (in FPS) on Kria KV260 (Z86_PROFILE_LITE) and ZCU104 (Z86_PROFILE_FULL) compared against median real-hardware results from Phil's Ultimate VGA Benchmark Database. At 150 MHz, the LITE profile (KV260) sits between a Pentium 100 and a Pentium 133, while FULL (ZCU104) at 150 MHz is close to a Pentium Pro 200 (matching or beating it on VGA-heavy 3DBench, PC Player, and DOOM, where the integrated zero-wait-state VGA/DDR4 path also helps, while Quake reflects pure CPU + x87 throughput):

System / CPU Clock 3DBench 1.0c PC Player (320×200) DOOM demo3 (MAX) Quake demo1 (320×200)
i486DX4-100 (median) 100 MHz 62.6 15.8 36.4 9.4
z86 LITE (KV260) 100 MHz 67.1 24.6 38.1 15.1
Intel Pentium 100 (median) 100 MHz 91.3 27.5 54.2 23.0
z86 LITE (KV260) 150 MHz 100.8 36.6 56.2 22.5
Intel Pentium 133 (median) 133 MHz 101.2 31.5 50.7 24.2
z86 FULL (ZCU104) 100 MHz 102.9 41.4 61.3 25.6
Intel Pentium 166 (median) 166 MHz 113.5 34.8 65.3 28.1
z86 FULL (ZCU104) 150 MHz 154.7 61.8 90.0 37.8
Intel Pentium Pro 200 (median) 200 MHz 144.0 60.1 71.2 41.9

i686 Linux 6.18 Benchmarks (ZCU104)

Measured live on ZCU104 (v35, Z86_PROFILE_FULL, 128 MiB RAM, 32-bit i686 Linux 6.18.54-z86 + musl, GCC 14.3 -march=pentiumpro -mfpmath=387 -mno-mmx -mno-sse):

Benchmark 100 MHz 150 MHz Per-MHz (150 MHz)
CoreMark 1.01 (-O2, CRC validated) 281.87 426.44 2.84 / MHz
CoreMark-PRO Overall (9 workloads) 71.86 107.68 0.72 / MHz
↳ Integer (5 workloads) / FP (4 workloads) 75.79 / 67.24 114.05 / 100.22 0.76 / 0.67
Dhrystone 2.1 (DMIPS) 104.9 157.9 1.05 DMIPS/MHz
Whetstone (Double x87, MWIPS) 166.7 250.0 1,667 KWIPS/MHz

Comparisons

Open-Source x86 FPGA Cores

z86 is the fastest open-source x86 FPGA core as of December 2026, delivering 3×–5× the per-MHz integer performance of in-order z486 and ao486, plus a full 80-bit x87 FPU that pushes Quake to 37.8 FPS:

Processor Pipeline & FPU Target FPGA Area Clock DMIPS/MHz 3DBench DOOM demo3 Quake demo1
ao486 (MiSTer) 486SX in-order, no FPU Cyclone V 15.2k CPU ALMs 90 MHz 0.19 43.6 21.0 FPS —
z386 (MiSTer) 80386 microcoded, no FPU Cyclone V 15.5k CPU ALMs 85 MHz 0.23 34.0 23.0 FPS —
z486 (MiSTer) 486DX in-order + 53-bit x87 Cyclone V 21.9k CPU ALMs 85 MHz 0.33 53.1 31.3 FPS 6.8 FPS
z486 XL (KV260) 486DX in-order + 53-bit x87 + L2 UltraScale+ XCK26 50.3k PC LUTs 100 MHz — 65.1 38.5 FPS 8.1 FPS
TetriumSX (MiSTer) High-IPC 486SX in-order, no FPU Cyclone V 18.5k CPU ALMs 69 MHz — 100.1 37.5 FPS —
z86 (LITE) 1-dec/2-issue OOO IA-32 + 80-bit x87 UltraScale+ XCK26 95.6k PC LUTs 100 / 150 MHz 0.52 67.1 / 100.8 38.1 / 56.2 FPS 15.1 / 22.5 FPS
z86 (FULL) 3-wide OOO IA-32 + 80-bit x87 UltraScale+ XCZU7EV 185.0k PC LUTs 100 / 150 MHz 1.05 102.9 / 154.7 61.3 / 90.0 FPS 25.6 / 37.8 FPS

Notes: Cyclone V uses 8-input ALMs (~1.5–2× Xilinx 6-LUTs). z86 full-PC LUTs include ~16.2k LUTs of PC peripherals (VGA, SB16, IDE, DMA, PS/2, AXI); CPU+L2 alone is 79.5k (LITE) and 168.8k (FULL). For prior academic work on out-of-order x86 soft processors, see Henry Ting-Hei Wong's 2017 University of Toronto Ph.D. dissertation ("A Superscalar Out-of-Order x86 Soft Processor for FPGA", ~28.7k Stratix IV ALMs, 2-issue OOO); its RTL was not released as open source.

Open-Source Out-of-Order Processor Cores

Comparing z86 against full-featured, Linux-capable open-source out-of-order RISC-V cores with hardware floating-point on UltraScale+ FPGAs, z86 is roughly in-line with academic OOO cores like SonicBOOM (similar FPGA LUT footprint and higher FPGA clock speed, offsetting IA-32's heavier CISC decode/microcode/x87 complexity) and less capable than commercial open-source cores like OpenC910:

Core ISA & FPU Issue Width Target FPGA LUTs FPGA Clock CoreMark/MHz Effective FPGA CoreMark
z86 (LITE) IA-32 + 80-bit x87 1-decode / 2-issue XCK26 79.5k (CPU+L2) 100–150 MHz 1.68* ~168–252
z86 (FULL) IA-32 + 80-bit x87 3-wide (4-1-1) XCZU7EV 168.8k (CPU+L2) 100–150 MHz 2.84–2.97* 282 @ 100 / 426 @ 150
SonicBOOM Small RV64GC + IEEE F/D 1-wide ZCU106 ~96k 50–75 MHz 2.41 ~120–180
SonicBOOM Medium RV64GC + IEEE F/D 2-wide ZCU106 ~144k 50–75 MHz 3.90 ~195–290
SonicBOOM Large RV64GC + IEEE F/D 3-wide ZCU106 / VU9P ~238k 50–75 MHz 4.9–5.0 ~245–375
OpenC910 (XuanTie C910) RV64GC(V) + IEEE F/D 3-wide (12-stage) VU9P / VCU128 ~670k ~50–100 MHz (2.5 GHz ASIC) 4.9–7.1 ~250–710

*z86 CoreMark/MHz: 2.84 is live -O2 on i686 Linux (282 @ 100 MHz, 426 @ 150 MHz); 2.97 (FULL) and 1.68 (LITE) are bare-metal -O3 RTL simulation.


Development Methodology and Microcode

Building on the lineage of open-source FPGA x86 cores (ao486, z386, z486), z86 is an independent implementation authored from published primary sources — the Intel IA-32 Software Developer's Manuals (Volumes 1–3), Shen & Lipasti's Modern Processor Design (Ch. 7), Intel's AP-526 timing reference, and public P6-era patents — cross-checked against live experiments on real Pentium Pro hardware:

  • Live Real-CPU Experiments: Ambiguous IA-32 edge cases, fault priorities, control/debug register masks, x87 rounding/exception semantics, and micro-op behavior were probed directly on live Pentium Pro hardware to pin down architectural contracts alongside RTL and microcode development.
  • Open-Source Microcode (microcode/): 100% open-source microcode written from scratch in unified @inst + [MS] symbolic assembly across 12 domain-grouped .asm files, compiling into XLAT tables, a 2K-triad MSROM, CROM, and a Remez/Chebyshev FPROM (microcode/tools/gen_fprom.py, < 0.75 ULP across all 8 IA-32 transcendentals). See microcode/MANUAL.md.
  • Co-simulation & Hardware Verification: RTL and microcode are verified primarily through lockstep Verilator --cosim against 86Box with portable architectural snapshots in z86_pc, backed by live FPGA execution across MS-DOS, Windows 3.11/95/98/NT 4.0, and i686 Linux 6.18 (z86-torture & z86-bench).

Quick Start & Verification

# 1. Open-source microcode assembly & <0.75 ULP verification
make -C microcode check

# 2. Generate RTL microcode images & Verilator lint (FULL and LITE profiles)
make rtl-lint

For the full PC-compatible SoC, interactive Verilator/SDL2 simulator, lockstep --cosim, PC verification suite, ZCU104 / Kria KV260 Vivado bitstreams, and the SD card image, see nand2mario/z86_pc.

Documentation


Credits

  • Primary Architecture & Microarchitecture References: Intel IA-32 Software Developer's Manuals (Volumes 1–3), John P. Shen & Mikko H. Lipasti (Modern Processor Design, Chapter 7), Intel AP-526, and public P6-era patents.
  • Open-Source FPGA x86 & P6 Research Community: Aleksander Osman (ao486) and the MiSTer FPGA community, Henry Ting-Hei Wong (A Superscalar Out-of-Order x86 Soft Processor for FPGA, University of Toronto Ph.D. dissertation, 2017), and the x86 microcode research community — including Rudolf Marek (ruik, utools), Martin Hinner, and Peter Bosch.
  • Verification & Tooling: 86Box (lockstep --cosim reference in z86_pc), Verilator, and NASM.