Adder constructor

Adder(
  1. Logic a,
  2. Logic b, {
  3. Logic? carryIn,
  4. String name = 'unnamed_module',
})

Takes in input a and input b and return the sum of the addition result. The width of input a and b must be the same.

Implementation

Adder(Logic a, Logic b, {Logic? carryIn, super.name}) : super() {
  if (a.width != b.width) {
    throw RohdHclException('inputs of a and b should have same width.');
  }
  addInput('a', a, width: a.width);
  addInput('b', b, width: b.width);
  addOutput('sum', width: a.width + 1);
  if (carryIn != null) {
    addInput('carryIn', carryIn);
  }
}