I’ve open-sourced FPGA Python, an experimental processor that executes a small subset of Python bytecode directly in FPGA logic.

The current native core can run this function:

def add(a, b):
    return a + b

The host compiles it with CPython 3.14.4, copies the function’s bytecode unchanged, and uploads it to the FPGA. Arguments arrive at runtime. The FPGA executes the instructions and sends back the result.

That gives me add(20, 22) = 42 and add(-7, 12) = 5 from the same uploaded program. There is still a long way to go toward a general Python runtime, but this part works on physical hardware.

What runs where

An FPGA is a chip whose digital logic can be configured. In this project, that logic implements the instruction decoder, operand stack, integer arithmetic, and call frames needed by the supported bytecode.

The execution path looks like this:

Python function
      |
CPython 3.14.4 compiler on the host
      |
Unchanged co_code plus transport metadata
      |
UART upload
      |
FPGA bytecode processor
      |
Integer result returned to the host

The host handles compilation, validation, and communication. It never calls the selected function to calculate its answer. The FPGA does the execution; there is no soft CPU running the CPython C interpreter inside this design.

A useful distinction is between the program and its inputs. Uploading code once and calling it with different arguments checks that the hardware is executing a reusable function. It also makes the interface more useful than a demo whose answer is fixed at build time.

Keeping the actual CPython instructions

For add, the instruction sequence includes:

RESUME
LOAD_FAST_BORROW_LOAD_FAST_BORROW
BINARY_OP                         # addition
CACHE                            # five cache entries
RETURN_VALUE

The fused load instruction pushes the two arguments. BINARY_OP 0 adds them, and RETURN_VALUE completes the function.

Those CACHE entries matter. CPython places inline cache data in the bytecode stream, and each owning instruction determines how much to skip. The exporter preserves those bytes. Removing them would change the instruction layout.

The project pins CPython 3.14.4 exactly because opcode numbers and cache layouts are implementation details that can change between releases. The native bytecode guide documents the format and validation rules.

Calling another Python function

The next working step is a real Python-to-Python call:

def add(a, b):
    return a + b


def entry(a, b):
    return add(a, b)

The exporter preserves both functions’ bytecode. It packages a small function directory so the FPGA can resolve LOAD_GLOBAL to the bundled add function. CALL 2 then enters a new frame with two positional arguments.

The hardware saves the caller’s continuation, locals, and operand state, executes the callee, and restores the caller when the result returns. The exporter does not inline the call.

The current implementation supports up to four bundled functions and four active frames, including the entry frame. Nested calls work within that bound. Exceeding the frame limit produces an explicit fault.

Supported operations today

The repository contains two execution paths with different instruction sets:

CapabilityNative CPython coreCustom VM
Integer additionYes, signed 32-bit argumentsYes, signed 32-bit values
Read argument localsYes, two local slotsUses its own variable slots
Integer literals and assignmentNot yetYes
Less-than comparisonsNot yetYes
while loopsNot yetYes, with a less-than condition
Integer outputFunction return valueprint(expression)
Python function callsYes, bounded static bundlesNot supported

The custom VM was the earlier prototype. It compiles a restricted Python source subset into a small stack instruction set and has a software reference interpreter. It runs the example loops that sum to 55 and 15.

The native core takes a different path: executing the original CPython instructions. A feature working in the custom VM does not automatically work in the native core.

Testing the hardware behavior

The project currently has 88 tests covering the compiler, image formats, CLI, transport, software VM, RTL processors, and UART integration. GitHub Actions runs separate software and RTL jobs.

The native tests compare exported bytes against CPython compiler output. Other checks exercise repeated calls, argument order, stack and frame limits, malformed images, arithmetic overflow, instruction budgets, and reset recovery. UART-pin simulations exercise communication through the board wrapper as well as the processor itself.

Physical hardware checks verified native addition across 37 argument pairs from one upload, and function calls across 26 argument pairs, together with nested calls and fault recovery. The repository includes addition transcripts and a function-call verification record.

These results establish functional behavior for the supported subset. I haven’t established a performance advantage over a CPU. Upload time, UART serialization, core execution, and host overhead are different measurements and need to be reported separately.

Why more opcodes will not be enough

It is tempting to treat full Python support as a list of missing instructions. That list is useful, but an opcode such as BINARY_OP hides a substantial runtime behind it.

Today, addition works on signed 32-bit integers and faults on overflow. General Python addition also involves arbitrary-precision integers, other numeric types, overloaded operators, reflected operations, object lifetimes, and exceptions.

The same gap appears elsewhere. LOAD_ATTR needs an object model and attribute lookup rules. Function calls need argument binding and callable protocols. Imports need module state and an import system. Exceptions need unwinding and traceback information.

Compiled packages introduce another problem. Libraries such as pydantic-core contain native code. Supporting their Python call sites would still leave the native execution path and CPython runtime interfaces to implement. Pydantic and FastAPI do not run on this core today.

I’ve added a bytecode and runtime checklist covering all 238 named entries in the pinned interpreter’s base and specialized opcode inventories. It marks the ten ordinary instructions with current implementations and explains their partial semantics. Cache metadata, specialized forms, tracing instructions, and compiler pseudo-ops are separated so the inventory does not become a misleading compatibility percentage.

Try it in simulation

You can explore the project without a board. Install CPython 3.14.4, Verilator, Icarus Verilog, Make, and a C++ compiler, then run:

git clone https://github.com/llazzaro/fpga_python.git
cd fpga_python
python3.14 -m venv .venv
.venv/bin/python -m pip install -e .

.venv/bin/python -m sim.run_cpython examples/add.py --a 20 --b 22

The result includes "outputs": [42] and "status": "HALTED", along with instruction and cycle counts. The first invocation builds the simulator.

To exercise the function bundle:

.venv/bin/python -m sim.run_cpython examples/function_call.py \
    --function entry --a 20 --b 22

Or start with the software reference VM, which needs no RTL tools:

.venv/bin/fpga-python run examples/sum_to_ten.py
# 55

The project is available under the MIT license. If you’re interested in Python internals, RTL, or the runtime work between a small integer core and a general interpreter, the repository and compatibility checklist are good places to start. Reproducible bug reports and focused contributions are welcome.