MultiplyAccumulate constructor
Take input a
and input b
, compute their product, add input c
to
produce the accumulate result.
The optional signedMultiplicand
parameter configures the The optional
signedMultiplicand
parameter configures the multiplicand a
statically
using a bool
as a signed multiplicand (default is false
, or unsigned)
or dynamically with a 1-bit Logic selectSignedMultiplicand input. You
can pass either a bool
(for static configuration) or a Logic
(dynamically configuring the type handled) with a signal to this
parameter, otherwise this constructor will throw.
The optional signedMultiplier
parameter configures the multiplier b
statically using a bool
as a signed multiplier (default is false
, or
unsigned) or dynamically with a 1-bit Logic selectSignedMultiplier
input. You can pass either a bool
(for static configuration) or a
Logic (dynamically configuring the type handled with a signal) to this
parameter, otherwise this constructor will throw.
The optional signedAddend
parameter configures the addend c
as a
signed addend (default is unsigned) or with a runtime configurable
selectSignedAddend input.
The optional signedAddend
parameter configures the multiplicand c
statically using a bool
as a signed multiplicand (default is false
, or
unsigned) or dynamically with a 1-bit Logic selectSignedAddend input.
You can pass either a bool
(for static configuration) or a Logic
(dynamically configuring the type handled) with a signal to this
parameter, otherwise this constructor will throw.
Implementation
MultiplyAccumulate(Logic a, Logic b, Logic c,
{Logic? clk,
Logic? reset,
Logic? enable,
dynamic signedMultiplicand,
dynamic signedMultiplier,
dynamic signedAddend,
super.name = 'multiply_accumulate',
super.reserveName,
super.reserveDefinitionName,
String? definitionName})
: super(
definitionName: definitionName ??
'MultiplyAccumulate_W${a.width}x${b.width}_'
'Acc${c.width}') {
this.clk = (clk != null) ? addInput('clk', clk) : null;
this.reset = (reset != null) ? addInput('reset', reset) : null;
this.enable = (enable != null) ? addInput('enable', enable) : null;
a = addInput('a', a, width: a.width);
b = addInput('b', b, width: b.width);
c = addInput('c', c, width: c.width);
signedMultiplicandParameter =
StaticOrRuntimeParameter.ofDynamic(signedMultiplicand);
this.signedMultiplicand = signedMultiplicandParameter.staticConfig;
signedMultiplierParameter =
StaticOrRuntimeParameter.ofDynamic(signedMultiplier);
this.signedMultiplier = signedMultiplierParameter.staticConfig;
signedAddendParameter = StaticOrRuntimeParameter.ofDynamic(signedAddend);
this.signedAddend = signedAddendParameter.staticConfig;
addOutput('accumulate', width: a.width + b.width + 1);
addOutput('isAccumulateSigned') <=
signedMultiplicandParameter.getLogic(this) |
signedMultiplierParameter.getLogic(this) |
signedAddendParameter.getLogic(this);
}