Retrocomputing with Clash
Retrocomputing with Clash
Haskell for FPGA Hardware Design
Haskell has become the functional programming language of choice<br>for many developers due to its excellent tools for abstraction<br>and principled program design. The open source Clash hardware description<br>language now brings these features to FPGA development.
Retrocomputing with Clash takes the experienced<br>Haskell programmer on a journey into the world of hardware<br>design with Clash. Our approach is based on using Haskell to its<br>fullest potential, using abstractions like monads and lenses in<br>building a library of reusable components.
But that wouldn't put the fun in functional programming! And so we<br>put these components to good use in implementing various<br>retro-computing devices:
Pocket calculator
Pong (sample chapter)
A simple, but Turing-complete computer that uses Brainfuck as its machine code
An implementation of the CHIP-8 virtual computer specification
Intel 8080 CPU
Space Invaders arcade machine
Compucolor II, a home computer from 1977 complete with keyboard, color video, and a floppy drive
Not part of the book, but demonstrating its approach to<br>developing fun FPGA designs with Clash, is Flappy Square from my Haskell<br>eXchange 2022 talk.
I absolutely love the very Haskell approach to circuit design<br>in this book, as opposed to my own write-Verilog-in-Haskell<br>style. It leverages Haskell's type system in a very<br>natural way to protect against many traps we as circuit<br>designers often fall into.
The book clearly demonstrates the benefits of using a modern<br>programming language for circuit design, where it builds<br>reusable functionality and components at a far finer<br>granularity than what I'm used to in traditional hardware<br>description languages.
Another thing that's absolutely great is the book's use of SDL2 multimedia library to<br>emulate peripherals like monitors which enables you to fully interact with the<br>computers and games that you'll be building without having to go through the sometimes<br>long and painful process of programming an FPGA.
– Christiaan Baaij, Clash lead developer, QBayLogic co-founder
This is the book for functional programmers<br>looking to get into FPGAs and digital logic design. Learn<br>Clash, the "I can’t believe it's not Haskell!" hardware<br>description language, while indulging in nostalgia for the<br>1980s. Take a joyride through a variety of hands-on projects,<br>including Pong, Space Invaders, and the Compucolor II, a<br>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.<br>It is hard for me to believe that I can learn about low level designs through Haskell<br>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<br>on real hardware without prior knowledge of the FPGA toolchain.
– Tristan de Cacqueray, principal software developer
Where to buy
Electronic version (PDF, e-book, and HTML) from Leanpub
Print<br>version from Lulu (Color hardcover edition)
Print<br>version from Lulu (B&W paperback edition)
Table of contents
Sample chapters
Chapter 8: Generative Graphics
Chapter 9: Project: Pong
Hardware considerations
My other Clash projects
Advent<br>of Clash 2025: FPGA circuits implementing solutions to the<br>Advent of Code<br>2025 problems. Heavily inspired by Tristan de<br>Cacqueray's great blog post on the same topic.
Clash Course in Solving Sudoku:<br>Functional Pearl from Haskell Symposium 2025. Watch my talk on<br>YouTube or look at the<br>code.
Flappy Square, a<br>minimalistic Flappy Bird
Code from the book
retroclash-lib:<br>Library of code shared between repositories, available from Hackage
retroclash-sim:<br>Library of simulation code shared between repositories, available from Hackage
clash-shake:<br>Shake build system rules for driving hardware synthesis from<br>Clash all the way to FPGA bitfile, supporting Xilinx, Intel<br>and SymbiFlow toolchains
Calculator
Pong
Brainfuck computer
CHIP-8
Intel 8080
Space Invaders
Compucolor II
All the rest:<br>smaller programs
Home<br>RetroClash<br>Blog<br>Papers<br>Talks<br>Open Source<br>GPG PubKey
This<br>page is created by Gergő Érdi.<br>Send your comments to gergo@erdi.hu.