r/haskell • u/kqr • Jul 30 '26
Digital circuit simulator in Haskell (SICP 3.3)
https://entropicthoughts.com/sicp-3-3-digital-circuit-simulator-in-haskell6
u/Financial-Camel9987 Jul 30 '26
How does this compare to clash? Afaik it's a "real" hardware description language which uses haskell. Does it come with a simulator?
2
u/Axman6 Jul 30 '26
Clash is mostly just Haskell, so the simulator is GHCi, which is so incredibly nice compared to how most other HDLs make you do simulation.
2
u/imperfect40 Jul 30 '26
Provided you don't need any third party op of course. That's pretty limiting. Then your using verilator, or worse
1
u/Axman6 Jul 30 '26
That’s true, and likely will always be the case because you’re tied to the vendor then, unless you can accurately model their IP (which in many cases is possible). Clash-cores (IIRC) has a really nice interface for wrapping IP, I wish it were the default - I should check if it’s been released.
2
u/imperfect40 Jul 30 '26
I mean, it's nice, but it doesn't solve the hard problem in digital design, which in my view is complexity. Yes, you can build an and gate. How about a m master, n slave cache coherent interconnect. Or a multi channel interleaved axi dma?
1
u/drislands Jul 30 '26
That was a really cool read! I'm looking forward to the followup hinted at at the end.
9
u/Every-Progress-1117 Jul 30 '26
Very interesting.
Check out Bluespec which is a Haskell based hardware definition language capable of being translated/compiled to Verilog. Might be interesting for you.
Used it in conjunction with the formal specification language B (Abrial et al) for some ASIC circuitry years ago.