FloatingPointSortByExp<FpType extends FloatingPoint> constructor

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

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

Implementation

FloatingPointSortByExp(
  super.a,
  super.b, {
  super.metaA,
  super.metaB,
  super.name = 'floating_point_sort_by_exp',
  super.reserveName,
  super.reserveDefinitionName,
  String? definitionName,
}) : super(
          definitionName:
              definitionName ?? 'FloatingPointSortByExp_W${a.width}') {
  final (sorted: (larger, smaller), didSwap: doSwap) =
      FloatingPointUtilities.sortByExp((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;
  }
}