Readit News logoReadit News
hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
tsukikage · 8 months ago
> A custom toolchain compiles a .py file into CPython ByteCode, translates it to a custom assembly, and produces a binary that runs on a pipelined processor built from scratch.

> Runs a subset of Python

What's the advantage of using a new custom toolchain, custom instruction set and custom processor over existing tools that compile a subset of Python for existing CPUs? - e.g. Cython, Nuitka etc?

hwpythonner · 8 months ago
Compilers and optimizers are great tools for some use cases, but not all.

Just to name a few limitations:

- Many rely heavily on the CPython runtime, meaning garbage collection, interoperability, and object semantics are still governed by CPython’s model.

- They’re rarely designed with embedded or real-time use cases in mind: large binaries, non-deterministic execution (due to the underlying architecture or GC behavior), and limited control over timing.

If these solutions were truly turnkey and broadly capable, CPython wouldn't still dominate—and there’d be no reason for MicroPython to exist either.

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
_kidlike · 8 months ago
After a quick search I found that even Raspberry makes the same claim...

"runs directly on embedded hardware"

https://www.raspberrypi.com/documentation/microcontrollers/m...

I don't understand why they have the need to do this...

hwpythonner · 8 months ago
PyXL is a bit more direct :)
hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
wormius · 8 months ago
Yeah that was my first thing. Wait a minute you run a compiler on it? It's literally compiled code, not direct. Which is fine, but yeah, overselling what it is/does.

Still cool, but I would definitely ease back the first claim.

I was going to say it does make me wonder how much a pain a direct processor like this would be in terms of having to constantly update it to adapt to the new syntax/semantics everytime there's a new release.

Also - are there any processors made to mimic ASTs directly? I figure a Lisp machine does something like that, but not quite... Though I've never even thought to look at how that worked on the hardware side.

EDIT: I'm not sure AST is the correct concept, exactly, but something akin to that... Like building a physical structure of the tree and process it like an interpreter would. I think something like that would require like a real-time self-programming FPGA?

hwpythonner · 8 months ago
PyXL deliberately avoids tying itself to Python’s high-level syntax or rapid surface changes.

The system compiles Python source to CPython ByteCode, and then from ByteCode to a hardware-friendly instruction set. Since it builds on ByteCode—not raw syntax—it’s largely insulated from most language-level changes. The ByteCode spec evolves slowly, and updates typically mean handling a few new opcodes in the compiler, not reworking the hardware.

Long-term, the hardware ISA is designed to remain fixed, with most future updates handled entirely in the toolchain. That separation ensures PyXL can evolve with Python without needing silicon changes.

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
zik · 8 months ago
This is a very cool project but I feel like the claim is overstated: "PyXL is a custom hardware processor that executes Python directly — no interpreter, no JIT, and no tricks. It takes regular Python code and runs it in silicon."

Reading further down the page it says you have to compile the python code using CPython, then generate binary code for its custom ISA. That's neat, but it doesn't "execute python directly" - it runs compiled binaries just like any other CPU. You'd use the same process to compile for x86, for example. It certainly doesn't "take regular python code and run it in silicon" as claimed.

A more realistic claim would be "A processor with a custom architecture designed to support python".

hwpythonner · 8 months ago
Fair point if you're looking at it through a strict compiler-theory lens, but just to clarify—when I say "runs Python directly," I mean there is no virtual machine or interpreter loop involved. The processor executes logic derived from Python ByteCode instructions.

What gets executed is a direct mapping of Python semantics to hardware. In that sense, this is more “direct” than most systems running Python.

This phrasing is about conveying the architectural distinction: Python logic executed natively in hardware, not interpreted in software.

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
focusgroup0 · 8 months ago
Incredible work. This is a paradigm shift for ML and embedded workflows. And congratulations, you are going to ring the bell with this one.
hwpythonner · 8 months ago
Thank you so much — that really means a lot!

It's still early days and there’s a lot more work ahead, but I'm very excited about the possibilities.

I definitely see areas like embedded ML and TinyML as a natural fit — Python execution on low-power devices opens up a lot of doors that weren't practical before.

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
crest · 8 months ago
A "480ns GPIO roundtrip" @ 100MHz implies 48 cycles for a single GPIO access. I would understand one or two cycles, but what does it spend the other ~46 cycles on? Does Python really have a >40x overhead compared to assembler or C even on optimised hardware or is the benchmark code that bad?
hwpythonner · 8 months ago
Great question!

You're right that it can definitely be faster — there's real room for optimization.

When I have time, I may write a blog post that will explain where the cycles go, why it's different from raw assembler toggling, and how it could be improved.

Also, just to keep things in perspective — don't forget to compare apples to apples: On a Pyboard running MicroPython, a simple GPIO roundtrip takes about 14 microseconds. PyXL is already achieving 480 nanoseconds, so it’s a very different baseline.

Thanks for raising it — it's a very good point.

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
throwup238 · 8 months ago
Are you planning on licensing the IP core? It would be great to have your core integrated with ESP32, running alongside their other architectures, so they can handle the peripheral integration, wifi, and Python code loading into your core, while it sits as another master on the same bus as the other peripherals.

Do you plan to have AMBA or Wishbone Bus support?

hwpythonner · 8 months ago
Thanks — yes, licensing is something I'm open to exploring in the future.

PyXL already communicates with the ARM side over AXI today (Zynq platform).

hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
rangerelf · 8 months ago
Incredible work :-)

Congratulations!!

hwpythonner · 8 months ago
Thank you!
hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
yeahwhatever10 · 8 months ago
How are you simulating the designs for the FPGA? Are you paying for ModelSim?
hwpythonner · 8 months ago
No, I'm not paying for ModelSim. I've been using free tools like Icarus Verilog — it was good enough for my needs so far. If I need more performance later, I might migrate to Verilator. I could also use Vivado’s built-in XSim, but coming from a software background, I generally prefer more Unix-style tools rather than heavier hardware IDEs.
hwpythonner commented on Show HN: I built a hardware processor that runs Python   runpyxl.com/gpio... · Posted by u/hwpythonner
larusso · 8 months ago
This sounds like your ‚arch‘ (sorry don‘t 100% know the correct term here) could potentially also run ruby/js if the toolchain can interpret it into your assembly language?
hwpythonner · 8 months ago
Good question — I’m not 100% sure. I'm not an expert on Ruby or JS internals, and I haven’t studied their execution models deeply. But in theory, if the language is stack-based (or can be mapped cleanly onto a stack machine), and if the ISA is broad enough to cover their needs, it could be possible. Right now, PyXL’s ISA is tuned around Python’s patterns — but generalizing it for other languages would definitely be an interesting challenge.

u/hwpythonner

KarmaCake day568April 13, 2025View Original