FloatingPointSort<FpType extends FloatingPoint> constructor

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

Constructs a FloatingPointSort module that sorts two floating point values so that the larger one is first.

Implementation

FloatingPointSort(super.a, super.b,
    {super.metaA,
    super.metaB,
    super.name = 'floating_point_sort',
    super.reserveName,
    super.reserveDefinitionName,
    String? definitionName})
    : super(
          definitionName: definitionName ?? 'FloatingPointSort_W${a.width}') {
  final (sorted: (larger, smaller), didSwap: doSwap) =
      FloatingPointUtilities.sort((super.a, super.b));
  output('outA') <= larger;
  output('outB') <= smaller;
  if ((metaA != null) & (metaB != null)) {
    final (swapMetaA, swapMetaB) = swap(doSwap, (super.metaA!, super.metaB!));
    output('outMetaA') <= swapMetaA;
    output('outMetaB') <= swapMetaB;
  }
}