pub fn adder<S: Into<String>>(
g: &mut GateGraphBuilder,
cin: GateIndex,
input1: &[GateIndex],
input2: &[GateIndex],
name: S,
) -> Vec<GateIndex>Expand description
Returns the output of a ripple carry adder.
Takes two inputs of any width and a carry in, the output will be the same width as the inputs.
§Example
let input1 = constant(3u8);
let input2 = constant(5u8);
// Notice the carry in bit is on.
let result = adder(&mut g, ON, &input1, &input2, "adder");
let output = g.output(&result, "result");
let ig = &g.init();
assert_eq!(output.u8(ig), 9);
§Panics
Will panic if input1.len() != input2.len().