4.2. The Clash Compiler¶
Hacking on Clash requires more dependencies than simply running Clash. The test suite requires having a tool available to synthesize any backend being tested. This means you need
The Clash compiler consists of different cabal libraries, which together provide a complete compiler. Primarily, this consists of
The front-end of the compiler, using parts of the GHC front-end. This provides the ability to load modules, translate GHC Core to Clash Core, and implements the
A lot of the code in this library is separated by the version of GHC it works with. For example,
src-841is specific to GHC 8.4.x.
The back-end of the compiler, exposed as a library. This is the largest library in the project, and includes the various ASTs (e.g. Core, Netlist), normalization, code generation, and primitives / black boxes.
The standard library for Clash as a language. This includes anything that is used to develop hardware in Clash, such as Signals, Clocks and combinators for common forms of state machine.
clash-preludelibrary also re-exports parts of the Haskell
baselibrary, allowing circuit designs to re-use common functions and definitions.
The repository also contains other libraries. These either provide additional functionality which is not required, or are not yet production-ready. These are
A collection of IP cores for use in Clash designs. Currently, this includes only Lattice Ice IO cores, and SPI (with slaves implemented with the Lattice SBIO found on Lattice FPGAs).
This library is optional, and is not required to use Clash. In the future it may be extended with additional IP cores.
Co-simulation for Clash, allowing Verilog to be run inline as though it were a normal Haskell function. This provides a QuasiQuoter for use in Haskell.
This library is very experimental, and is not guaranteed to work with the most recent development version of Clash.
A development tool for analysing how the normalizer in
clash-libaffects the core of a particular design. It allows the result of each different optimizer pass to be seen for debugging purposes.