FloatingPointMultiplier<FpTypeIn extends FloatingPoint, FpTypeOut extends FloatingPoint> constructor
- FpTypeIn a,
- FpTypeIn b, {
- Logic? clk,
- Logic? reset,
- Logic? enable,
- FpTypeOut? outProduct,
- FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.roundNearestEven,
- ParallelPrefix ppGen() = KoggeStone.new,
- String name = 'floating_point_multiplier',
- bool reserveName = false,
- bool reserveDefinitionName = false,
- String? definitionName,
Multiply two floating point numbers a
and b
, returning result in
product.
If you specify the optional outProduct
, the multiplier
will output into the specified output allowing for a wider output.
clk
,reset
,enable
are optional inputs to control a pipestage (only inserted ifclk
is provided).ppGen
is the type of ParallelPrefix used in internal adder generation.
Implementation
FloatingPointMultiplier(FpTypeIn a, FpTypeIn b,
{Logic? clk,
Logic? reset,
Logic? enable,
FpTypeOut? outProduct,
this.roundingMode = FloatingPointRoundingMode.roundNearestEven,
// ignore: avoid_unused_constructor_parameters
ParallelPrefix Function(List<Logic>, Logic Function(Logic, Logic)) ppGen =
KoggeStone.new,
super.name = 'floating_point_multiplier',
super.reserveName,
super.reserveDefinitionName,
String? definitionName})
: super(
definitionName: definitionName ??
'FloatingPointMultiplier_E${a.exponent.width}'
'M${a.mantissa.width}') {
if (b.exponent.width != a.exponent.width ||
b.mantissa.width != a.mantissa.width) {
throw RohdHclException('FloatingPoint widths must match');
}
exponentWidth =
(outProduct == null) ? a.exponent.width : outProduct.exponent.width;
mantissaWidth =
(outProduct == null) ? a.mantissa.width : outProduct.mantissa.width;
internalProduct = (outProduct ?? a).clone(name: 'outSum') as FpTypeOut;
addOutput('product', width: exponentWidth + mantissaWidth + 1) <=
internalProduct;
if (outProduct != null) {
outProduct <= output('product');
}
this.clk = (clk != null) ? addInput('clk', clk) : clk;
this.enable = (enable != null) ? addInput('enable', enable) : enable;
this.reset = (reset != null) ? addInput('reset', reset) : reset;
this.a = (a.clone(name: 'a') as FpTypeIn)
..gets(addInput('a', a, width: a.width));
this.b = (b.clone(name: 'b') as FpTypeIn)
..gets(addInput('b', b, width: b.width));
}