toBool method

bool toBool()

Converts a valid logical value to a boolean.

Throws an exception if the value is invalid.

Implementation

bool toBool() {
  if (!isValid) {
    throw Exception('Cannot convert value "$this" to bool');
  }
  if (width != 1) {
    throw Exception('Only single bit values can be converted to a bool,'
        ' but found width $width in $this');
  }
  return this == LogicValue.one;
}