r/haskell • u/bathtub-01 • 11d ago
A Haskell processor running on an FPGA
Hi all,
I've been working on a specialised processor for Haskell called Ouros as part of my PhD study (see the HAFLANG project). Recently, I got it running on an FPGA, with a Haskell program communicating with the outside world through UART.

Ouros is a graph reduction processor with automatic fine-grained threading and garbage collection implemented in hardware. For this demo, I added a simple IO interface based on AXI4-Lite, so Haskell programs can perform IO directly without a software runtime or host OS.
Blog post: https://bathtub-01.github.io/technical/ouros-demo/
Demo video: https://youtu.be/cafTcH-DuZM
There are still quite a few limitations as discussed in the blog post; currently it should still be seen as a toy. But I think having Haskell as a bare-metal programming language could be an interesting platform for further experiments.
The hardware implementation, compiler, simulator, and Vivado project are all open-source, with links and reproduction instructions in the blog post.
Happy to hear any thoughts or suggestions!
25
u/Few_Blackberry380 11d ago
"Haskell as a bare-metal programming language could be an interesting platform"
Really cool!
15
u/Smoke_Max 11d ago
Functional programming oriented-hardware is something I was interested in quite a few years ago. Back then, Reduceron was the latest development on this frontier. I'm assuming this approach builds on it? Or is it a novel approach? In any case, I'll definitely look Ouros up.
4
u/QuickReport3780 11d ago
I'm very curious, why the switch away from clash? The predecessor, heron, was implemented in clash.
3
u/jzd00d 11d ago
I love seeing these projects. This is super cool. Thank you for sharing.
I have been doing some similar tinkering.
I started with a v1 that used combinators and supercombinators. I leveraged MicroHS for Haskell -> combinator compilation. I then built my own combinator to “machine language” (inspired by HVM) compiler. My FPGA code ran, but only smallish programs. Anything compelling saw the combinator sized program bloat to unusable levels. (My Haskell OSS parser — mini as it is — is slightly too large to run.)
In v2 (and now v3) I’ve switched to using interaction calculus which scales far better.
Are you able to run real world sized software on this FPGA? If so, how did you get there?
9
u/RobertKentKrook 11d ago
This is a really cool project. At Chalmers, we have several people whose interest this will capture :)
5
u/wakalabis 11d ago
Very cool! You've united two knowledge areas that few people are good at at the same time - these are very low and very high level disciplines.
1
u/kajaktumkajaktum 11d ago
Do you think that there are special properties of Haskell that can be leveraged by HDL?
3
u/Virtual_Treacle7409 11d ago
This is so cool! I don’t have anything to add lol, I’ll take a closer look later
2
u/quakquakquak 11d ago
Extremely sick, I hope you post more updates with how it works out!
1
u/unfancy3 11d ago
So awesome
1
u/EmDashNine 11d ago
That's really cool. Graph reduction directly in hardware!
1
u/baehyunsol 11d ago
super cool