muxAbsolute method

void muxAbsolute(
  1. int row,
  2. int col,
  3. Logic condition,
  4. Logic val,
)

Mux the Logic at absolute position (row, col) conditionally by condition to val.

Implementation

void muxAbsolute(int row, int col, Logic condition, Logic val) {
  final product = partialProducts[row];
  final i = col - rowShift[row];
  if (product.length > i) {
    if (val is SignBit || product[i] is SignBit) {
      var inv = false;
      if (val is SignBit) {
        inv = val.inverted;
      }
      if (product[i] is SignBit) {
        inv = (product[i] as SignBit).inverted;
      }
      product[i] = SignBit(mux(condition, val, product[i]), inverted: inv);
    } else {
      product[i] = mux(condition, val, product[i]);
    }
  } else {
    while (product.length < i) {
      product.add(Const(0));
    }
    partialProducts[row].add(val);
  }
}