Adder constructor
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);
}
}