FloatingPointSwap<FpType extends FloatingPoint> constructor
Constructs a FloatingPointSwap module that swaps two floating point values.
Implementation
FloatingPointSwap(FpType a, FpType b,
{Logic? metaA,
Logic? metaB,
super.name = 'floating_point_swap',
super.reserveName,
super.reserveDefinitionName,
String definitionName = 'floating_point_swap'})
: super(definitionName: definitionName) {
if (a.width != b.width) {
throw RohdHclException(
'FloatingPointSwap requires inputs a and b to have the same width.');
}
if ((metaA == null) != (metaB == null)) {
throw RohdHclException(
'FloatingPointSwap requires both metaA and metaB to be either '
'both null or both non-null.');
}
this.metaA =
(metaA != null) ? addInput('inMetaA', metaA, width: metaA.width) : null;
this.metaB =
(metaB != null) ? addInput('inMetaB', metaB, width: metaB.width) : null;
if (metaA != null && metaB != null) {
// We have metadata to swap.
if (metaA.width != metaB.width) {
throw RohdHclException('FloatingPointSwap requires metaA and metaB to '
'have the same width.');
}
addOutput('outMetaA', width: metaA.width);
addOutput('outMetaB', width: metaB.width);
}
this.a = (a.clone(name: 'a') as FpType)
..gets(addInput('a', a, width: a.width));
this.b = (b.clone(name: 'b') as FpType)
..gets(addInput('b', b, width: b.width));
addOutput('outA', width: a.width);
addOutput('outB', width: b.width);
}