FloatingPointAdder constructor

FloatingPointAdder(
  1. FloatingPoint a,
  2. FloatingPoint b, {
  3. Logic? clk,
  4. Logic? reset,
  5. Logic? enable,
  6. String name = 'floating_point_adder',
  7. String? definitionName,
})

Add two floating point numbers a and b, returning result in sum.

  • clk, reset, enable are optional inputs to control a pipestage (only inserted if clk is provided).

Implementation

FloatingPointAdder(FloatingPoint a, FloatingPoint b,
    {Logic? clk,
    Logic? reset,
    Logic? enable,
    super.name = 'floating_point_adder',
    String? definitionName})
    : exponentWidth = a.exponent.width,
      mantissaWidth = a.mantissa.width,
      super(
          definitionName: definitionName ??
              'FloatingPointAdder_E${a.exponent.width}'
                  'M${a.mantissa.width}') {
  if (b.exponent.width != exponentWidth ||
      b.mantissa.width != mantissaWidth) {
    throw RohdHclException('FloatingPoint widths must match');
  }
  this.clk = (clk != null) ? addInput('clk', clk) : null;
  this.reset = (reset != null) ? addInput('reset', reset) : null;
  this.enable = (enable != null) ? addInput('enable', enable) : null;
  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));

  addOutput('sum', width: exponentWidth + mantissaWidth + 1);
}