zeroExtend method

Logic zeroExtend(
  1. int newWidth
)

Returns a new Logic with width newWidth where new bits added are zeros as the most significant bits.

The newWidth must be greater than or equal to the current width or an exception will be thrown.

Implementation

Logic zeroExtend(int newWidth) {
  if (newWidth < width) {
    throw Exception(
        'New width $newWidth must be greater than or equal to width $width.');
  }
  return [
    Const(0, width: newWidth - width),
    this,
  ].swizzle();
}