buildOfLogicValue<T extends FloatingPointValue> static method
- T constructor({
- required LogicValue exponent,
- required LogicValue mantissa,
- required LogicValue sign,
- int exponentWidth,
- int mantissaWidth,
- LogicValue val,
A helper function for FloatingPointValue.ofLogicValue and base classes which performs some width checks and slicing.
Implementation
@protected
static T buildOfLogicValue<T extends FloatingPointValue>(
T Function(
{required LogicValue sign,
required LogicValue exponent,
required LogicValue mantissa})
constructor,
int exponentWidth,
int mantissaWidth,
LogicValue val,
) {
final expectedWidth = 1 + exponentWidth + mantissaWidth;
if (val.width != expectedWidth) {
throw RohdHclException('Width of $val must be $expectedWidth');
}
return constructor(
sign: val[-1],
exponent: val.slice(exponentWidth + mantissaWidth - 1, mantissaWidth),
mantissa: val.slice(mantissaWidth - 1, 0));
}