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.
What is Hardcaml?
Section titled “What is Hardcaml?”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!
What can you do here?
Section titled “What can you do here?”Learn Hardcaml
Section titled “Learn Hardcaml”Work through interactive tutorials that teach you hardware design concepts using real, runnable code.
Complete Nand2Tetris
Section titled “Complete Nand2Tetris”Implement the Part 1 of the Nand2Tetris course in Hardcaml - build a computer from NAND gates up to a CPU!
Experiment
Section titled “Experiment”Try out circuit ideas quickly without any local setup. The IDE compiles and simulates your code in the cloud.
Quick Example
Section titled “Quick Example”Here’s a simple 8-bit counter:
open! Coreopen! Hardcamlopen! 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!
Next Steps
Section titled “Next Steps”- OCaml Introduction - Learn the OCaml concepts you need for Hardcaml
- Quick Start - Get up and running
- Your First Circuit - Step-by-step tutorial
- Nand2Tetris - Build a computer from scratch