Taking a look at Clash HDL

Posted on Nov 10, 2022

I really need a solid hardware description language, and bluespec has some issues that make me want to consider Clash.

Here are some potential paths:

1. MASSIVE Bluespec Overhaul

  • I basically have to reverse engineer bluespec, and then document all of it
  • Support for type hints in IDE
  • Package building
  • Automatic HTML documentation

Bluespec Pros

  • Excellent type system with first class support for tagged lowerings for sum types
  • Explicit handling of CDC
  • Atomic rules
  • Bluespec Haskell is very pretty and encourages modularity - I even think it supports partial functions

Bluespec Cons

  • It's not practical to work with BH without a language server, and BH currently lacks a language server.
  • The standard/prelude library needs better documentation
  • It's unclear what is good stylistics/idiomatic BH
  • There is example BH code that uses sugar or custom operators might inform what idiomatic BH ought to be, but it can be hard to read as syntax can be hard to parse(the BH user guide doesn't contain an exhaustive BH grammar AFAICT).
  • Basically, to make timely progress working with BH, you'll need to interact with BH experts, which are only a handful, and are often busy.
  • You can learn BH by reading the compiler source code - and the source code is approachable - but this is a difficult way to go about this as haskell source code tends to be dense and general like mathematical equations.
  • Supposing you did figure out how to write idomatic BH, you'd then have to document your findings as well as a good chunk of the standard/prelude library so that your code could be accessible to others... This could take quite some time.

To summarize, my concern with bluespec is that anything I build in it won't be accessible to anybody. Bluespec has no support tooling, no IDE, and no consolidated documentation. Also, as bluespec is a fairly complex language, it's really hard to read a bluespec codebase without any documentation.

2. Add Atomics and a Prelude/Standard Library to Clash

Clash is another haskell like language that compiles into hardware that could be worth looking into.

Similarities to Bluespec

Clash is like bluespec in the following ways:

  • Haskell like language that compiles to hardware - in fact, a good chunk of valid Haskell is valid Clash.
  • Comes with its own built in simulator
  • Emits verilog

Bluespec Problems Clash May Solve

I believe Clash also solves some problems that Bluespec has(I'm still confirming this however):

  • IDE support
  • Better documentation

Things to Confirm about Clash

  • Does it have first class clock domain crossing support?
  • Does it have FIFOs and asynchronous FIFOS?
  • Does it have a good standard library?

Things I May Want to Add to Clash

I would think it should be possible to add an atomic rules based system to the Clash compiler.