def __abs__(self):
        """Absolute value, :py:`abs(self)`.

        ..
            >>> abs(C(-1)).shape()
            unsigned(1)
            >>> C(1).shape()
            unsigned(1)

        Return
        ------
        :class:`Value`, :py:`unsigned(len(self))`
        """
        if self.shape().signed:
            return Mux(self >= 0, self, -self)[:len(self)]
        else:
            return self
Absolute value, :py:`abs(self)`.

        ..
            >>> abs(C(-1)).shape()
            unsigned(1)
            >>> C(1).shape()
            unsigned(1)

        Return
        ------
        :class:`Value`, :py:`unsigned(len(self))`
        
amaranth/hdl/_ast.py