FullAdder constructor
Constructs a FullAdder with value a
, b
and carryIn
based on
full adder truth table.
Implementation
FullAdder({
required Logic a,
required Logic b,
required Logic carryIn,
super.name = 'full_adder',
}) {
a = addInput('a', a, width: a.width);
b = addInput('b', b, width: b.width);
carryIn = addInput('carry_in', carryIn, width: carryIn.width);
final carryOut = addOutput('carry_out');
final sum = addOutput('sum');
final and1 = carryIn & (a ^ b);
final and2 = b & a;
sum <= (a ^ b) ^ carryIn;
carryOut <= and1 | and2;
}