formatBitRange static method

String formatBitRange(
  1. int startBit,
  2. int width
)

Format a bit-range label from startBit and width.

Returns e.g. [7:4] for startBit=4, width=4 or [0] for width=1.

Implementation

static String formatBitRange(int startBit, int width) {
  final highBit = startBit + width - 1;
  return highBit == startBit ? '[$startBit]' : '[$highBit:$startBit]';
}