Module Hardcaml_circuits.Mul

Wallace/Dadda tree multipliers.

The Wallace/Dadda tree has three steps:

1. Multiply (that is - AND) each bit of one of the arguments, by each bit of the other, yielding n^2 results. Depending on position of the multiplied bits, the wires carry different weights, for example wire of bit carrying result of a2b3 is 32.

2. Reduce the number of partial products to two by layers of full and half adders.

3. Group the wires in two numbers, and add them with a conventional adder.

They differ in step 2 in how the results are combined.

wallace

dadda

However, when a layer carries at most 3 input wires for any weight, that layer will be the last one. In this case, the Dadda tree will use half adder more aggressively (but still not as much as in a Wallace multiplier), to ensure that there are only two outputs for any weight. Then, the second rule above changes as follows:

module type Gen = sig ... end
module Config : sig ... end
val create_gen : config:Config.t -> (module Gen with type t = 'a) -> 'a -> 'a -> 'a
val create : config:Config.t -> (module Hardcaml.Comb.S with type t = 'a) -> 'a -> 'a -> 'a