Back to rankings

clash-lang/clash-compiler

Haskellclash-lang.org

Haskell to VHDL/Verilog/SystemVerilog compiler

haskellhardware-description-languagefpgavhdlverilogsystemverilogasic
Star Growth
Stars
1.6k
Forks
166
Weekly Growth
Issues
378
5001k1.5k
Aug 2013Nov 2017Mar 2022Jul 2026
README

Clash - A functional hardware description language

Pipeline status Hackage Documentation Status

Clash is a functional hardware description language that borrows both its syntax and semantics from the functional programming language Haskell. The Clash compiler transforms these high-level descriptions to low-level synthesizable VHDL, Verilog, or SystemVerilog.

Features of Clash:

  • Strongly typed, but with a very high degree of type inference, enabling both safe and fast prototyping using concise descriptions.

  • Interactive REPL: load your designs in an interpreter and easily test all your component without needing to setup a test bench.

  • Higher-order functions, with type inference, result in designs that are fully parametric by default.

  • Synchronous sequential circuit design based on streams of values, called Signals, lead to natural descriptions of feedback loops.

  • Support for multiple clock domains, with type safe clock domain crossing.

Open-source community

Clash benefits from an active community. Whether you need a question answered or want to contribute to open-source features, browse the features below to make the most of Clash.

Get Clash

Check out clash-lang.org/install to install the latest stable release of Clash, or to setup a Clash project.

Get Clash from source

Get the source code using Git and enter the cloned directory:

git clone git@github.com:clash-lang/clash-compiler.git

# Alternatively, if you haven't setup SSH keys with GitHub:
# git clone https://github.com/clash-lang/clash-compiler.git

cd clash-compiler

To check out a released version, use:

git checkout v1.2.3

To checkout a release branch use:

git checkout 1.2

Note that release branches might contain non-released patches.

GHC compatibility

Linux Windows macOS Clash (released) Clash (development version)
8.6 ✔️ ✔️ ✔️ 1.0 - 1.8
8.8 ✔️ ✔️ 1.0 - 1.8
8.10 ✔️ ✔️ 1.2 - 1.8
9.0 ✔️ ✔️2 ✔️ 1.4 - 1.8
9.2 ⚠️1 ⚠️1 ⚠️1 1.8
9.4 ⚠️3 ⚠️3 ️⚠️3 1.8
9.6 ✔️3 ✔️3,4 ✔️3 1.8 - 1.10 ✔️
9.8 ✔️ ✔️4 ✔️ 1.8 - 1.10 ️✔️
9.10 ✔️ ✔️4 ✔️ 1.8 - 1.10 ️✔️
9.12 ✔️ ✔️4 ✔️ 1.10 ️✔️

1 GHC 9.2 contains a regression, rendering Clash error messages indecipherable. This change was reverted in 9.4.

2 GHC 9.0.2 on Windows fails to compile clash-cores. We therefore don't run the Clash test suite on CI for this combination.

3 Clash starts extremely slowly when compiled with 9.4.8 up to and including 9.6.2. Consider downgrading to 9.4.7 or upgrading to 9.6.3 and up.

4 Clash starts extremely slowly on Windows with GHC 9.6 through 9.12, consider downgrading to 9.4.7

Cabal

To use Cabal you need both Cabal and GHC installed on your system. We recommend using ghcup. For more information, see https://www.haskell.org/downloads/.

To run clash use:

cabal v2-run -- clash

If this fails, make sure you've got an up-to-date package index:

cabal update

Stack

Install Stack and run:

stack run -- clash

Nix

Or use Nix to get a shell with the clash and clashi binaries on your PATH:

# Start the default dev shell
nix develop .

# Start a dev shell with a specific GHC version
nix develop .#ghc9103

You will need a modern version of nix with support for the new-style nix command and flakes (2.4 or newer). Support for these must still be manually enabled, this can be done by setting

experimental-features = nix-command flakes

in your nix.conf.

The flake is configured to use the clash-lang Cachix binary cache. When you first run nix develop, Nix will ask whether to allow and trust the cache. Accepting avoids having to build Clash from source.

To automatically enter and exit the nix environment on directory change, you can install direnv and nix-direnv and write the following to a .envrc file in the root of this repository:

use flake

watch_file nix/*

Upon adding or changing this file you must direnv allow in order for the file to be automatically loaded / reloaded on project changes.

Individual packages / applications can also be built or run using the nix build and nix run commands, i.e.

nix build .#clash-ghc
nix run .#clashi

Hacking

Want to start hacking on Clash? Read HACKING.md for tips and tricks.

Related libraries and initiatives

  • Clashilator: tooling to integrate Clash with Verilator. Enables fast, multithreaded simulation by compiling Clash designs to C++.
  • Clash Protocols: experimental library for writing Clash circuits with bidirectional communication - such as AXI or Avalon.
  • Clash Starters: starter projects to quickly get you up and running.
  • Clash WaveDrom: generate wave diagrams from Clash using WaveDrom

Projects built with Clash

Related repositories
jgm/pandoc

Universal markup converter

HaskellGNU General Public License v2.0pandochaskell
pandoc.org
45.5k3.9k
koalaman/shellcheck

ShellCheck, a static analysis tool for shell scripts

HaskellGNU General Public License v3.0haskellshell
shellcheck.net
39.7k1.9k
hasura/graphql-engine

Blazing fast, instant realtime GraphQL APIs on all your data with fine grained access control, also trigger webhooks on database events.

TypeScriptnpmApache License 2.0graphqlgraphql-server
hasura.io
32k2.9k
PostgREST/postgrest

REST API for any Postgres database

HaskellMIT Licensehaskelldatabase
postgrest.org
27.5k1.2k
compiler-explorer/compiler-explorer

Run compilers interactively from your web browser and interact with the assembly

TypeScriptnpmBSD 2-Clause "Simplified" Licenserustc-plus-plus
godbolt.org
18.9k2.1k
simplex-chat/simplex-chat

SimpleX - the first messaging network operating without user identifiers of any kind - 100% private by design! iOS, Android and desktop apps 📱!

HaskellGNU Affero General Public License v3.0chatprotocol
simplex.chat
18.9k1.2k
hadolint/hadolint

Dockerfile linter, validate inline bash, written in Haskell

HaskellGNU General Public License v3.0dockerfilelinter
12.3k498
hmemcpy/milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source

TeXOtherhaskellcategory-theory
bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
11.7k645
lk-geimfari/awesomo

Cool open source projects. Choose your project and get involved in Open Source development now.

GoGo ModulesCreative Commons Zero v1.0 Universalawesomeocaml
9.9k690
purescript/purescript

A strongly-typed language that compiles to JavaScript

HaskellOtherhaskellpurescript
purescript.org
8.9k571
unisonweb/unison

A friendly programming language from the future

HaskellOtherhaskellprogramming-language
unison-lang.org
6.7k305
liuxinyu95/AlgoXY

Book of Elementary Functional Algorithms and Data structures

TeXalgorithmshaskell
6.3k764