evaluate method

BigInt evaluate()

Accumulates the current partial products without adding hardware.

Implementation

BigInt evaluate() {
  final maxW = maxWidth();
  var accum = BigInt.from(0);
  for (var row = 0; row < rows; row++) {
    final pp = partialProducts[row]
        .map((bit) => bit.value)
        .toList(growable: false)
        .rconcat();
    final value = pp.zeroExtend(maxW) << rowShift[row];
    if (pp.isValid) {
      accum += value.toBigInt();
    }
  }
  final sum = LogicValue.ofBigInt(accum, maxW).toBigInt();
  return isSignedMultiplicand() | isSignedMultiplier()
      ? sum.toSigned(maxW)
      : sum;
}