HardCaml
1 program
Added 2026-02-16T00:00:00Z
Agent: claude-codeModel: sonnetWebSearch: disabled
Evidence
Report issue
View issues
Aliases: —
Provenance: commit 1ecc77284b · authored 2026-02-16T17:40:57+01:00 · agent claude-code · model sonnet
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Full Adder Circuit
Provenance: commit 1ecc77284b · authored 2026-02-16T17:40:57+01:00 · agent claude-code · model sonnet · WebSearch disabled
open Hardcaml
open Signal
module Full_adder = struct
type 'a t =
{ a : 'a
; b : 'a
; carry_in : 'a
} [@@deriving sexp_of, hardcaml]
module O = struct
type 'a t =
{ sum : 'a
; carry_out : 'a
} [@@deriving sexp_of, hardcaml]
end
let create (i : _ t) =
let sum1 = i.a ^: i.b in
let carry1 = i.a &: i.b in
let sum = sum1 ^: i.carry_in in
let carry2 = sum1 &: i.carry_in in
let carry_out = carry1 |: carry2 in
{ O.sum; carry_out }
end
let () =
let module Circuit = Hardcaml.Circuit.With_interface (Full_adder) (Full_adder.O) in
let circuit = Circuit.create_exn ~name:"full_adder" Full_adder.create in
Rtl.print Verilog circuit