Home›Industry News›FPGA Runs CPython Bytecode Directly, but Beyond Addition It's Still a Blank
← Back to Industry News
Tutorial

FPGA Runs CPython Bytecode Directly, but Beyond Addition It's Still a Blank

TutorialFPGA Runs CPythonBytecode Directly, butBeyond Addition It's…fpga.love
Illustration

An open-source project feeds raw bytecode compiled by CPython 3.14.4 into FPGA logic for execution, and add(20,22) returns 42 on physical hardware. What it proves is that bytecode decoding and a stack machine can run in RTL—not that Python is usable on FPGA: of 238 named opcode entries, only ten are currently implemented.

Bytecode Goes Into Logic Unmodified

The project is called FPGA Python, open-sourced by author llazzaro under the MIT license. On the host side, functions are compiled with CPython 3.14.4, and the unmodified co_code, along with transport metadata, is uploaded over UART; on the FPGA side, logic implements the instruction decoder, operand stack, integer arithmetic, and call frames, with results sent back to the host. There is no soft CPU in the design, and no CPython C interpreter running on-chip. The addition path preserves RESUME, the fused LOAD_FAST_BORROW, BINARY_OP, and RETURN_VALUE, and even keeps CACHE entries, because the cache layout determines how many bytes an instruction skips. The version is pinned precisely to 3.14.4; opcode numbering and cache format are implementation details that change across versions. This means it validates the feasibility of hardware executing real CPython instruction streams, not bypassing the interpreter for acceleration.

Function Calls and a Four-Frame Ceiling

The second step is Python-to-Python calls: entry calls add, and the exporter preserves the bytecode of both functions and packages a small function directory so the FPGA resolves LOAD_GLOBAL to the bundled add, CALL 2 enters a new frame, and the hardware saves the caller's continuation, locals, and operand state. The current limits are four bundled functions and four active frames (including the entry frame); exceeding them is an explicit fault. The repository also has 88 tests covering the compiler, image format, CLI, transport, software VM, RTL processor, and UART integration, and on physical hardware it verified addition across 37 parameter pairs in a single upload, function calls across 26 parameter pairs, and nested calls with fault recovery. The author explicitly states that a performance advantage over a CPU has not been established; upload time, UART serialization, core execution, and host overhead need to be measured separately.

PrincipleSetupVerify
Illustration

The Runtime Behind Ten Instructions

The real gap is not the opcode count. Addition currently supports only signed 32-bit integers, and overflow is a fault; general Python addition also involves arbitrary-precision integers, other numeric types, operator overloading, reflected operations, object lifetimes, and exceptions. LOAD_ATTR needs an object model and attribute lookup, function calls need argument binding and the callable protocol, imports need module state, and exceptions need stack unwinding and tracebacks. The author's bytecode and runtime inventory covers the 238 named entries of the pinned interpreter version, marks the ten ordinary instructions implemented, and counts cache metadata, specialized forms, tracing instructions, and compiler pseudo-ops separately to avoid a misleading compatibility percentage. Libraries with native code such as pydantic-core would still need a native execution path and CPython runtime interfaces even if their Python call sites were supported; Pydantic and FastAPI cannot currently run on this core.

Three takeaways
  • Raw CPython bytecode can execute in FPGA logic, including CACHE layout
  • Limits are four functions and four active frames; addition is signed 32-bit only
  • Ten of 238 named entries are implemented; the author claims no performance advantage

What it means for us

For engineers in China working on high-speed interfaces and boards, this project is not a short-term option: it has no performance data, no general Python support, and its UART upload path is far from a real deployment shape. What is worth borrowing is the method—separate host compilation, on-chip execution, and result return, verify with both simulation and physical hardware, and clearly distinguish upload, serialization, execution, and host overhead. If you care about the RTL-runtime boundary, the repository's compatibility inventory is more useful than the code itself, because it breaks “Python support” into checkable entries rather than a percentage. The toolchain depends on CPython 3.14.4, Verilator, and Icarus Verilog; simulation can come first, and no supply-chain substitution is involved.

FPGACPythonbytecodeRTLopen source
fpga.love

Subscribe to fpga.love

Daily Briefing · Weekly Digest · Monthly Deep Dive