MultiplyAccumulate constructor

MultiplyAccumulate(
  1. Logic a,
  2. Logic b,
  3. Logic c, {
  4. bool signedMultiplicand = false,
  5. bool signedMultiplier = false,
  6. bool signedAddend = false,
  7. Logic? selectSignedMultiplicand,
  8. Logic? selectSignedMultiplier,
  9. Logic? selectSignedAddend,
  10. String name = 'unnamed_module',
})

Take input a and input b, compute their product, add input c to produce the accumulate result.

Optional selectSignedMultiplicand allows for runtime configuration of signed or unsigned operation, overriding the signedMultiplicand static configuration.

Optional selectSignedMultiplier allows for runtime configuration of signed or unsigned operation, overriding the signedMultiplier static configuration.

Optional selectSignedAddend allows for runtime configuration of signed or unsigned operation, overriding the signedAddend static configuration.

Implementation

MultiplyAccumulate(Logic a, Logic b, Logic c,
    {this.signedMultiplicand = false,
    this.signedMultiplier = false,
    this.signedAddend = false,
    Logic? selectSignedMultiplicand,
    Logic? selectSignedMultiplier,
    Logic? selectSignedAddend,
    super.name}) {
  a = addInput('a', a, width: a.width);
  b = addInput('b', b, width: b.width);
  c = addInput('c', c, width: c.width);
  selectSignedMultiplicand = (selectSignedMultiplicand != null)
      ? addInput('selectSignedMultiplicand', selectSignedMultiplicand)
      : null;
  selectSignedMultiplier = (selectSignedMultiplier != null)
      ? addInput('selectSignedMultiplier', selectSignedMultiplier)
      : null;
  selectSignedAddend = (selectSignedAddend != null)
      ? addInput('selectSignedAddend', selectSignedAddend)
      : null;
  addOutput('isAccumulateSigned') <=
      (signedMultiplicand | signedMultiplier | signedAddend
              ? Const(1)
              : Const(0)) |
          ((selectSignedMultiplicand != null)
              ? selectSignedMultiplicand
              : Const(0)) |
          ((selectSignedMultiplier != null)
              ? selectSignedMultiplier
              : Const(0)) |
          ((selectSignedAddend != null) ? selectSignedAddend : Const(0));
}