4.2. The Clash Compiler

4.2.1. Prerequisites

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

  • ghdl installed to test VHDL

  • iverilog installed to test Verilog

  • ModelSim installed to test System Verilog

  • SymbiYosys and Z3 installed to test Verilog and System Verilog

4.2.2. Subprojects

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 clash and clashi executables.

A lot of the code in this library is separated by the version of GHC it works with. For example, src-bin-9.0 is specific to GHC 9.0.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.

The clash-prelude library also re-exports parts of the Haskell base library, 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 Lattice Ice IO cores, SPI (with slaves implemented with the Lattice SBIO found on Lattice FPGAs), a UART and support for Xilinx floating point IP.


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-lib affects the core of a particular design. It allows the result of each different optimizer pass to be seen for debugging purposes.


Hedgehog Generators for clash-lib.


Hedgehog Generators for clash-prelude.