RippleCarryAdder constructor
Constructs an n-bit adder based on inputs List of inputs.
Implementation
RippleCarryAdder(super.a, super.b,
{Logic? carryIn, super.name = 'ripple_carry_adder_carry_in'}) {
if (carryIn != null) {
carryIn = addInput('carry_in', carryIn, width: carryIn.width);
}
Logic? carry;
final sumList = <Logic>[];
for (var i = 0; i < a.width; i++) {
final fullAdder =
FullAdder(a: a[i], b: b[i], carryIn: carry ?? (carryIn ?? Const(0)));
carry = fullAdder.carryOut;
sumList.add(fullAdder.sum);
}
sumList.add(carry!);
sum <= sumList.rswizzle();
}