• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
      • 100-theorems
      • Arithmetic
      • Bit-vectors
        • Sparseint
        • Bitops
          • Bitops/merge
          • Bitops-compatibility
          • Bitops-books
          • Logbitp-reasoning
          • Bitops/signed-byte-p
          • Fast-part-select
          • Bitops/integer-length
          • Bitops/extra-defs
          • Install-bit
          • Trailing-0-count
          • Bitops/defaults
          • Logbitp-mismatch
          • Trailing-1-count
          • Bitops/rotate
          • Bitops/equal-by-logbitp
          • Bitops/ash-bounds
          • Bitops/fast-logrev
          • Limited-shifts
          • Bitops/part-select
          • Bitops/parity
          • Bitops/saturate
            • Signed-saturate
              • Signed-saturate-fn
              • Signed-saturate64
              • Signed-saturate32
              • Signed-saturate16
                • Signed-saturate8
              • Unsigned-saturate
            • Bitops/part-install
            • Bitops/logbitp-bounds
            • Bitops/ihsext-basics
            • Bitops/fast-rotate
            • Bitops/fast-logext
            • Bitops/ihs-extensions
          • Bv
          • Ihs
          • Rtl
        • Algebra
      • Testing-utilities
    • Signed-saturate

    Signed-saturate16

    Optimized implementation of 16-bit signed saturation.

    Signature
    (signed-saturate16 x) → *
    Arguments
    x — Guard (integerp x).

    Definitions and Theorems

    Function: signed-saturate16$inline

    (defun signed-saturate16$inline (x)
      (declare (xargs :guard (integerp x)))
      (let ((__function__ 'signed-saturate16))
        (declare (ignorable __function__))
        (mbe :logic (signed-saturate-fn 16 x)
             :exec (cond ((>= x 32767) 32767)
                         ((<= x -32768) 32768)
                         (t (the (unsigned-byte 16)
                                 (logand (the (signed-byte 16) x)
                                         65535)))))))