Skip to content

Introduction

Hardcaml Web IDE is a browser-based environment for learning and experimenting with hardware design using Hardcaml, Jane Street’s OCaml library for digital circuit design.

Hardcaml is a powerful library for describing, simulating, and generating digital hardware. It provides:

  • Type-safe circuit descriptions - Catch errors at compile time
  • Simulation - Test your circuits without physical hardware
  • Waveform visualization - See signal behavior over time
  • RTL generation - Export to Verilog for synthesis
  • Much More!

Work through interactive tutorials that teach you hardware design concepts using real, runnable code.

Implement the Part 1 of the Nand2Tetris course in Hardcaml - build a computer from NAND gates up to a CPU!

Try out circuit ideas quickly without any local setup. The IDE compiles and simulates your code in the cloud.

Here’s a simple 8-bit counter:

open! Core
open! Hardcaml
open! Signal
module I = struct
type 'a t = { clock : 'a; clear : 'a; enable : 'a }
[@@deriving hardcaml]
end
module O = struct
type 'a t = { out : 'a [@bits 8] }
[@@deriving hardcaml]
end
let create scope (i : _ I.t) : _ O.t =
let spec = Reg_spec.create ~clock:i.clock ~clear:i.clear () in
let counter = reg_fb spec ~width:8 ~f:(fun fb ->
mux2 i.enable (fb +:. 1) fb)
in
{ out = counter }
;;
let hierarchical scope =
let module Scoped = Hierarchy.In_scope (I) (O) in
Scoped.hierarchical ~scope ~name:"counter" create
;;

Try it out in the IDE!