MultiplyOnly constructor

MultiplyOnly(
  1. Logic a,
  2. Logic b,
  3. Logic c,
  4. Multiplier mulGen(
    1. Logic a,
    2. Logic b, {
    3. Logic? selectSignedMultiplicand,
    4. Logic? selectSignedMultiplier,
    }), {
  5. bool signedMultiplicand = false,
  6. bool signedMultiplier = false,
  7. bool signedAddend = false,
  8. Logic? selectSignedMultiplicand,
  9. Logic? selectSignedMultiplier,
  10. Logic? selectSignedAddend,
})

Construct a MultiplyAccumulate that only multiplies to enable using the same tester with zero accumulate addend c.

Implementation

MultiplyOnly(
  super.a,
  super.b,
  super.c,
  Multiplier Function(Logic a, Logic b,
          {Logic? selectSignedMultiplicand, Logic? selectSignedMultiplier})
      mulGen, {
  super.signedMultiplicand = false,
  super.signedMultiplier = false,
  super.signedAddend = false,
  super.selectSignedMultiplicand,
  super.selectSignedMultiplier,
  super.selectSignedAddend,
}) // Will be overrwridden by multiplyGenerator
: super(
          // ignore: prefer_interpolation_to_compose_strings
          name: 'Multiply Only: ' +
              _genName(mulGen, a, b, selectSignedMultiplicand,
                  selectSignedMultiplier)) {
  final accumulate = addOutput('accumulate', width: a.width + b.width + 1);

  final multiply = mulGen(a, b,
      selectSignedMultiplicand: selectSignedMultiplicand,
      selectSignedMultiplier: selectSignedMultiplier);

  accumulate <=
      mux(
          multiply.isProductSigned,
          multiply.product.signExtend(accumulate.width),
          multiply.product.zeroExtend(accumulate.width));
}