PartialProductGenerator constructor

PartialProductGenerator(
  1. Logic multiplicand,
  2. Logic multiplier,
  3. RadixEncoder radixEncoder, {
  4. bool signedMultiplicand = false,
  5. Logic? selectSignedMultiplicand,
  6. bool signedMultiplier = false,
  7. Logic? selectSignedMultiplier,
  8. String name = 'ppg',
})

Construct a PartialProductGenerator -- the partial product matrix.

signedMultiplier generates a fixed signed encoder versus using selectSignedMultiplier which is a runtime sign selection Logic in which case signedMultiplier must be false.

Implementation

PartialProductGenerator(
    Logic multiplicand, Logic multiplier, RadixEncoder radixEncoder,
    {this.signedMultiplicand = false,
    this.selectSignedMultiplicand,
    this.signedMultiplier = false,
    this.selectSignedMultiplier,
    super.name = 'ppg'}) {
  if (signedMultiplier && (selectSignedMultiplier != null)) {
    throw RohdHclException('sign reconfiguration requires signed=false');
  }
  encoder = MultiplierEncoder(multiplier, radixEncoder,
      signedMultiplier: signedMultiplier,
      selectSignedMultiplier: selectSignedMultiplier);
  selector = MultiplicandSelector(radixEncoder.radix, multiplicand,
      signedMultiplicand: signedMultiplicand,
      selectSignedMultiplicand: selectSignedMultiplicand);

  if (multiplicand.width < selector.shift) {
    throw RohdHclException('multiplicand width must be greater than '
        'or equal to ${selector.shift}');
  }
  if (multiplier.width < (selector.shift + (signedMultiplier ? 1 : 0))) {
    throw RohdHclException('multiplier width must be greater than '
        'or equal to ${selector.shift + (signedMultiplier ? 1 : 0)}');
  }
  _build();
  signExtend();
}