Retrocomputing with Clash

Haskell for FPGA Hardware Design

Haskell has become the functional programming language of choice for many developers due to its excellent tools for abstraction and principled program design. The open source Clash hardware description language now brings these features to FPGA development.

Retrocomputing with Clash takes the experienced Haskell programmer on a journey into the world of hardware design with Clash. Our approach is based on using Haskell to its fullest potential, using abstractions like monads and lenses in building a library of reusable components.

But that wouldn't put the fun in functional programming! And so we put these components to good use in implementing various retro-computing devices:

Not part of the book, but demonstrating its approach to developing fun FPGA designs with Clash, is Flappy Square from my Haskell eXchange 2022 talk.

I absolutely love the very Haskell approach to circuit design in this book, as opposed to my own write-Verilog-in-Haskell style. It leverages Haskell's type system in a very natural way to protect against many traps we as circuit designers often fall into.

The book clearly demonstrates the benefits of using a modern programming language for circuit design, where it builds reusable functionality and components at a far finer granularity than what I'm used to in traditional hardware description languages.

Another thing that's absolutely great is the book's use of SDL2 multimedia library to emulate peripherals like monitors which enables you to fully interact with the computers and games that you'll be building without having to go through the sometimes long and painful process of programming an FPGA.

– Christiaan Baaij, Clash lead developer, QBayLogic co-founder

This is the book for functional programmers looking to get into FPGAs and digital logic design. Learn Clash, the "I can’t believe it's not Haskell!" hardware description language, while indulging in nostalgia for the 1980s. Take a joyride through a variety of hands-on projects, including Pong, Space Invaders, and the Compucolor II, a personal computer based on the Intel 8080. Recommended.

– Miëtek Bak, mathematician

This book is a fascinating, knowledge-expanding work that leads to exciting domains. It is hard for me to believe that I can learn about low level designs through Haskell because it is a notoriously high-level language.

This language has been such a gift that has kept on giving.

Thanks to the clash-shake tool, I can run Haskell code on real hardware without prior knowledge of the FPGA toolchain.

– Tristan de Cacqueray, principal software developer

Where to buy

Table of contents

Sample chapters

Hardware considerations

Code from the book