Install Clash on macOS
1. Choose your platform
2. Install Stack
Use brew install haskell-stack
or manually install it. Stack is a build tool for Haskell / Clash projects.
3. Setup Clash
To setup a new project based on the provided starter projects, run:
stack new my-clash-project clash-lang/simple
This will create a new project called my-clash-project
in a folder with the same name. The folder will contain a README.md
to get you up and running. Alternatively, you can read it online.
Alternatives
A starter project using Stack is the recommended way to use Clash, and is fully supported. Alternative methods sometimes exhibit issues that can be confusing even to people used to working with GHC, since Clash is pretty non-standard. Clash is a modification to the GHC compiler rather than a normal Haskell package, and it uses several GHC plugins to extend the functionality of type-level naturals, which are extensively used in Clash designs.
Starter project with Cabal
People familiar with the Haskell ecosystem might prefer to use Cabal instead of Stack. To do so, download the starter project as a zip and follow the instructions in README.md
.
Run Clash on its own
The following compiles the file ShortBlinker.hs
to VHDL:
stack exec --resolver nightly-2025-03-07 --package clash-ghc -- clash ShortBlinker.hs --vhdl
The resulting HDL should be very similar to the following:
--vhdl
:topEntity.vhdl
--verilog
:topEntity.v
--systemverilog
:topEntity.sv