FullAdder constructor
Constructs a FullAdder with value a
, b
and carryIn
based on
full adder truth table.
Implementation
FullAdder(
super.a,
super.b, {
required super.carryIn,
super.name = 'full_adder',
}) {
if ((a.width != 1) | (b.width != 1) | ((carryIn ?? Const(0)).width != 1)) {
throw RohdHclException('widths must all be one');
}
if (carryIn == null) {
throw RohdHclException('FullAdder must have a carryIn input');
}
sum <= [carryIn! & (a ^ b) | a & b, (a ^ b) ^ carryIn!].swizzle();
}