Adding a pair of bit lists, lsb first.
Ripple carry adder:
fun add c (nil, nil) = [c] | add c (a::at, b::bt) = let val s = gen_xor(a, b) val c1 = gen_and(a, b) val c2 = gen_and(s, c) in (gen_xor(s, c))::(add (gen_or(c2, c1)) (at, bt)) end
Faster adder: use wide gates: use functions like gen_addl
Carry argument is replaced with a list of generate and propagate pairs from the earlier stages.
The ripple carry adder is generated by the ML fragment above. The kogge stone is frequently used as a practical, synthesisable adder that is fast and not critical over its layout.