• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
        • Svex-stvs
        • Svex-decomposition-methodology
        • Sv-versus-esim
        • Svex-decomp
        • Svex-compose-dfs
        • Svex-compilation
        • Moddb
        • Svmods
        • Svstmt
        • Sv-tutorial
        • Expressions
          • Rewriting
          • Svex
          • Bit-blasting
          • Functions
            • 4vec-operations
              • 4vec-bit?
              • 4vec-part-install
              • 4vec-concat
              • 4vec-?
              • 4vec-rsh
              • 4vec-bit?!
              • 4vec-===*
              • 4vec-reduction-and
              • 4vec-bit-extract
              • 4vec-rev-blocks
              • 4vec-lsh
              • 4vec-resor
              • 4vec-resand
              • 4vec-parity
              • 4vec-plus
              • 4vec-<
              • 4vec-minus
              • 4vec-res
              • 4vec-override
              • 4vec-bit-index
              • 4vec-?!
              • 4vec-zero-ext
                • 4vec-part-select
                • 4vec-===
                • 4vec-remainder
                • 4vec-reduction-or
                • 4vec-idx->4v
                • 4vec-==
                • 4vec-sign-ext
                • 4vec-quotient
                • 4vec-?*
                • 4vec-bitxor
                • 4vec-wildeq
                • 4vec-times
                • 4vec-bitmux
                • 4vec-symwildeq
                • 4vec-bitand
                • 4vec-wildeq-safe
                • 4vec-bitor
                • 4vec-shift-core
                • 4vec-pow
                • 4vec-onset
                • 4vec-offset
                • 4vec-xdet
                • 4vec-uminus
                • 4vec-clog2
                • 4vec-bitnot
                • 4vec-onehot
                • 4vec-countones
                • 4veclist-p-to-stringp
                • 4vec-p-to-stringp
                • 4vec-onehot0
                • 4vec-1mask
                • 4vec-p-to-stringp-aux
                • 4v->4vec-bit
                • 4v-to-characterp
                • Bool->vec
                • Unsigned-4vec-p
              • 3vec-operations
              • *svex-op-table*
            • 4vmask
            • Why-infinite-width
            • Svex-vars
            • Evaluation
            • Values
          • Symbolic-test-vector
          • Vl-to-svex
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • 4vec-operations

    4vec-zero-ext

    Like loghead for 4vecs; the width is also a 4vec.

    Signature
    (4vec-zero-ext n x) → x-ext
    Arguments
    n — Position to truncate/zero-extend at.
        Guard (4vec-p n).
    x — The 4vec to truncate/zero-extend.
        Guard (4vec-p x).
    Returns
    x-ext — Type (4vec-p x-ext).

    When n is a natural number, we keep the least significant n bits of x and clear any bits above this to zero.

    When n has any X or Z bits or is negative, the result is all X bits.

    Definitions and Theorems

    Function: 4vec-zero-ext

    (defun 4vec-zero-ext (n x)
     (declare (xargs :guard (and (4vec-p n) (4vec-p x))))
     (let ((__function__ '4vec-zero-ext))
      (declare (ignorable __function__))
      (if
       (and (2vec-p n) (<= 0 (2vec->val n)))
       (if
        (mbe
            :logic nil
            :exec (and (>= (2vec->val n) (4vec-bit-limit))
                       (b* (((4vec x)))
                         (or (< x.upper 0) (< x.lower 0)))
                       (4vec-very-large-integer-warning (2vec->val n))))
        (4vec-x)
        (if-2vec-p (x)
                   (2vec (loghead (2vec->val n) (2vec->val x)))
                   (b* (((4vec x)) (nval (2vec->val n)))
                     (4vec (loghead nval x.upper)
                           (loghead nval x.lower)))))
       (4vec-x))))

    Theorem: 4vec-p-of-4vec-zero-ext

    (defthm 4vec-p-of-4vec-zero-ext
      (b* ((x-ext (4vec-zero-ext n x)))
        (4vec-p x-ext))
      :rule-classes :rewrite)

    Theorem: 4vec-zero-ext-of-4vec-fix-n

    (defthm 4vec-zero-ext-of-4vec-fix-n
      (equal (4vec-zero-ext (4vec-fix n) x)
             (4vec-zero-ext n x)))

    Theorem: 4vec-zero-ext-4vec-equiv-congruence-on-n

    (defthm 4vec-zero-ext-4vec-equiv-congruence-on-n
      (implies (4vec-equiv n n-equiv)
               (equal (4vec-zero-ext n x)
                      (4vec-zero-ext n-equiv x)))
      :rule-classes :congruence)

    Theorem: 4vec-zero-ext-of-4vec-fix-x

    (defthm 4vec-zero-ext-of-4vec-fix-x
      (equal (4vec-zero-ext n (4vec-fix x))
             (4vec-zero-ext n x)))

    Theorem: 4vec-zero-ext-4vec-equiv-congruence-on-x

    (defthm 4vec-zero-ext-4vec-equiv-congruence-on-x
      (implies (4vec-equiv x x-equiv)
               (equal (4vec-zero-ext n x)
                      (4vec-zero-ext n x-equiv)))
      :rule-classes :congruence)