MultiplyAccumulate constructor
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));
}