Adder constructor

Adder(
  1. Logic a,
  2. Logic b, {
  3. Logic? carryIn,
  4. String name = 'adder',
  5. bool reserveName = false,
  6. bool reserveDefinitionName = false,
  7. String? definitionName,
})

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 = 'adder',
    super.reserveName,
    super.reserveDefinitionName,
    String? definitionName})
    : super(definitionName: definitionName ?? 'Adder_W${a.width}') {
  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);
  }
}