widen method
- FxvType fxv
Constructs a FixedPointValue from another FixedPointValue with by widening the integer and/or fraction widths.
Implementation
FxvType widen(FxvType fxv) {
if ((fxv.integerWidth > integerWidth) ||
(fxv.fractionWidth > fractionWidth)) {
throw RohdHclException('Cannot expand from $fxv to $_unpopulated');
}
var newInteger = fxv.signed
? fxv.integer
.signExtend(fxv.integer.width + integerWidth - fxv.integerWidth)
: fxv.integer
.zeroExtend(fxv.integer.width + integerWidth - fxv.integerWidth);
if (signed & !fxv.signed) {
newInteger = newInteger.zeroExtend(newInteger.width + 1);
}
final newFraction =
fxv.fraction.reversed.zeroExtend(fractionWidth).reversed;
return populate(integer: newInteger, fraction: newFraction);
}