parseBinaryMathLogicValue function

({BigInt value, int width}) parseBinaryMathLogicValue(
  1. LogicValue value
)

Converts a value into a packed, two-state binary math value.

Binary math descriptors do not represent x or z, so invalid LogicValues are rejected.

Implementation

({BigInt value, int width}) parseBinaryMathLogicValue(LogicValue value) {
  if (value.width <= 0) {
    throw RohdHclException(
        'Binary math radix strings must have a positive width.');
  }
  if (!value.isValid) {
    throw RohdHclException(
        'Binary math radix strings cannot contain x or z values.');
  }
  return (value: value.toBigInt(), width: value.width);
}