extend method
- int newWidth,
- LogicValue fill
Returns a new LogicValue with width newWidth where the most
significant bits for indices beyond the original width are set
to fill.
The newWidth must be greater than or equal to the current width or an
exception will be thrown. fill must be a single bit (width=1).
Implementation
LogicValue extend(int newWidth, LogicValue fill) {
if (newWidth < width) {
throw Exception(
'New width $newWidth must be greater than or equal to width $width.');
}
if (fill.width != 1) {
throw Exception('The fill must be 1 bit, but got $fill.');
}
return [
LogicValue.filled(newWidth - width, fill),
this,
].swizzle();
}