abs method

Logic abs()

Calculates the absolute value of a signal, assuming that the number is a two's complement.

Implementation

Logic abs() {
  if (width == 0) {
    return this;
  }
  return mux(this[-1], ~this + 1, this);
}