FloatingPointMultiplier<FpTypeIn extends FloatingPoint, FpTypeOut extends FloatingPoint> constructor

FloatingPointMultiplier<FpTypeIn extends FloatingPoint, FpTypeOut extends FloatingPoint>(
  1. FpTypeIn a,
  2. FpTypeIn b, {
  3. Logic? clk,
  4. Logic? reset,
  5. Logic? enable,
  6. FpTypeOut? outProduct,
  7. FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.roundNearestEven,
  8. ParallelPrefix ppGen(
    1. List<Logic>,
    2. Logic (
      1. Logic,
      2. Logic
      )
    ) = KoggeStone.new,
  9. String name = 'floating_point_multiplier',
  10. bool reserveName = false,
  11. bool reserveDefinitionName = false,
  12. 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 if clk 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));
}