FloatingPointMultiplier constructor
- FloatingPoint a,
- FloatingPoint b, {
- Logic? clk,
- Logic? reset,
- Logic? enable,
- FloatingPoint? outProduct,
- ParallelPrefix ppGen() = KoggeStone.new,
- String name = 'floating_point_multiplier',
- 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(FloatingPoint a, FloatingPoint b,
{Logic? clk,
Logic? reset,
Logic? enable,
FloatingPoint? outProduct,
// ignore: avoid_unused_constructor_parameters
ParallelPrefix Function(List<Logic>, Logic Function(Logic, Logic)) ppGen =
KoggeStone.new,
super.name = 'floating_point_multiplier',
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 = FloatingPoint(
exponentWidth: exponentWidth,
mantissaWidth: mantissaWidth,
name: 'product');
addOutput('product', width: exponentWidth + mantissaWidth + 1);
output('product') <= 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('clk', reset) : reset;
this.a = a.clone(name: 'a')..gets(addInput('a', a, width: a.width));
this.b = b.clone(name: 'b')..gets(addInput('b', b, width: b.width));
}