FloatingPointConditionalSwap<FpType extends FloatingPoint> constructor

FloatingPointConditionalSwap<FpType extends FloatingPoint>(
  1. FpType a,
  2. FpType b,
  3. Logic doSwap, {
  4. Logic? metaA,
  5. Logic? metaB,
  6. String name = 'floating_point_conditional_swap',
  7. bool reserveName = false,
  8. bool reserveDefinitionName = false,
  9. String? definitionName,
})

Constructs a FloatingPointConditionalSwap module that swaps two floating point values based on the doSwap condition.

Implementation

FloatingPointConditionalSwap(
  super.a,
  super.b,
  Logic doSwap, {
  super.metaA,
  super.metaB,
  super.name = 'floating_point_conditional_swap',
  super.reserveName,
  super.reserveDefinitionName,
  String? definitionName,
}) : super(
          definitionName: definitionName ?? 'FloatingPointSwap_W${a.width}') {
  this.doSwap = addInput('swap', doSwap);

  final (swapA, swapB) = swap(this.doSwap, (super.a, super.b));
  output('outA') <= swapA;
  output('outB') <= swapB;
  if ((metaA != null) & (metaB != null)) {
    final (swapMetaA, swapMetaB) =
        swap(this.doSwap, (super.metaA!, super.metaB!));
    output('outMetaA') <= swapMetaA;
    output('outMetaB') <= swapMetaB;
  }
}