4 ms·
There was another language kinda similar to this (functional language HDL), called Bluespec. It was originally very Haskell-like, but at some point had to chang
by lasagnaphil 6y ago
There was another language kinda similar to this (functional language HDL), called Bluespec. It was originally very Haskell-like, but at some point had to change its syntax to a more C-like version because of its unpopularity with hardware engineers. I had to use the newer version at my Computer Architecture class, and although the experience was way better than Verilog, it had very little documention/tutorials (being a commercial product and having almost no users), which made understanding the more complex parts of the language really hard.
Nowadays Chisel seems to be the best bet if you want a sane Verilog alternative (with functional-lang features) for your HDL needs. (https://www.chisel-lang.org/ https://www.chisel-lang.org/) It was originally a transpiler to Verilog, but recently it began to have its own IR code (FIRRTL) for optimization purposes.
- centimeter 6y agoAs I recall, Chisel is a very shallowly embedded HDL, which is completely different from the approach used by Clash. Clash is a subset of Haskell that is directly compiled to a hardware representation, which has some unique advantages and disadvantages. One big advantage of Clash's approach is that you can code from any regular Haskell library as long as the code is within the subset of Haskell supported by Clash. E.g. you could import `Linear.V3` and have access to a 3-dimensional vector type with all the operators and stuff already defined, and this would compile to hardware no problem. It turns out that Haskell's non-strict semantics are a shockingly close match for the semantics of hardware (the only difference I'm aware of being pretty obscure, having to do with zero-width busses).
- zozbot234 6y ago> It turns out that Haskell's non-strict semantics are a shockingly close match for the semantics of hardware Doesn't Haskell need automatic memory management in order to implement higher-order functions, that being perhaps the most prominent difference in semantics between Haskell/Ocaml and Rust? Is Clash limited to first-class functions ala C?
- centimeter 6y agoNo, clash supports higher-order functions just fine. The only thing it can’t really represent is general recursion. You need to use type-constrained recursion. Clash isn’t fully generalized yet so it provides some nice bounded recursion primitive.
- zozbot234 6y agoYes, but the Clash reference documentation states that it doesn't do behavioral synthesis. It structurally maps the representation of the supported subset of fully-applied Haskell functions to either combinational or sequential circuits, depending on whether the function takes a `Signal`-type argument. The fact that the representation is shared leads to many advantages compared to e.g. Chisel, but this is definitely a "shallow embedding" approach.
- centimeter 6y ago"Signal" is just [] without an empty constructor (i.e. a lazy corecursive stream). As far as your Haskell code is concerned, there is nothing special whatsoever about signals, and indeed it's just a normal data type until the Clash-specific Core layer kicks in. I think I mixed up "shallow" and "deep" embedding - by "deep embedding", I meant to say that there is no secondary AST manually defined for the embedded language, but I think that is actually a shallow embedding. Looks like I can't correct my earlier comment. Only the top level function has to be first order - you can use higher order functions within the body of your code.
- chas 6y agoBluespec is still around and actually got open-sourced recently! [0] The Bluespec company is focused on using their tools to build RISC-V cores: https://bluespec.com/ https://bluespec.com/ [0]: https://github.com/B-Lang-org/bsc https://github.com/B-Lang-org/bsc