• 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
                • Rev-blocks
                  • Rev-block-index
                • 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-rev-blocks

    Rev-blocks

    Reverses blocks, like the streaming concatenation operator in SystemVerilog.

    Signature
    (rev-blocks nbits blocksz x) → res
    Arguments
    nbits — Guard (natp nbits).
    blocksz — Guard (posp blocksz).
    x — Guard (integerp x).
    Returns
    res — Type (natp res).

    Example:

    (equal (rev-blocks 28 8 #xaabbccdd) #xddccbba)

    This essentially truncates x to nbits bits, then divides this into blocks of size blocksz, starting from least significant bits, where the last block (corresponding to the most significant bits of x) may be smaller. Then it reverses the order of these blocks. So in the example above, the most significant #xa is dropped, and the rest is divided into the blocks a bb cc dd, which are then reversed.

    Definitions and Theorems

    Function: rev-blocks

    (defun rev-blocks (nbits blocksz x)
      (declare (xargs :guard (and (natp nbits)
                                  (posp blocksz)
                                  (integerp x))))
      (let ((__function__ 'rev-blocks))
        (declare (ignorable __function__))
        (b* ((nbits (lnfix nbits))
             (blocksz (mbe :logic (pos-fix blocksz)
                           :exec blocksz))
             ((when (< nbits blocksz))
              (loghead nbits x))
             (next-nbits (- nbits blocksz))
             (rest (rev-blocks next-nbits
                               blocksz (ash x (- blocksz)))))
          (logapp next-nbits rest (loghead blocksz x)))))

    Theorem: natp-of-rev-blocks

    (defthm natp-of-rev-blocks
      (b* ((res (rev-blocks nbits blocksz x)))
        (natp res))
      :rule-classes :type-prescription)

    Theorem: rev-blocks-of-nfix-nbits

    (defthm rev-blocks-of-nfix-nbits
      (equal (rev-blocks (nfix nbits) blocksz x)
             (rev-blocks nbits blocksz x)))

    Theorem: rev-blocks-nat-equiv-congruence-on-nbits

    (defthm rev-blocks-nat-equiv-congruence-on-nbits
      (implies (nat-equiv nbits nbits-equiv)
               (equal (rev-blocks nbits blocksz x)
                      (rev-blocks nbits-equiv blocksz x)))
      :rule-classes :congruence)

    Theorem: rev-blocks-of-pos-fix-blocksz

    (defthm rev-blocks-of-pos-fix-blocksz
      (equal (rev-blocks nbits (pos-fix blocksz) x)
             (rev-blocks nbits blocksz x)))

    Theorem: rev-blocks-pos-equiv-congruence-on-blocksz

    (defthm rev-blocks-pos-equiv-congruence-on-blocksz
      (implies (pos-equiv blocksz blocksz-equiv)
               (equal (rev-blocks nbits blocksz x)
                      (rev-blocks nbits blocksz-equiv x)))
      :rule-classes :congruence)

    Theorem: rev-blocks-of-ifix-x

    (defthm rev-blocks-of-ifix-x
      (equal (rev-blocks nbits blocksz (ifix x))
             (rev-blocks nbits blocksz x)))

    Theorem: rev-blocks-int-equiv-congruence-on-x

    (defthm rev-blocks-int-equiv-congruence-on-x
      (implies (int-equiv x x-equiv)
               (equal (rev-blocks nbits blocksz x)
                      (rev-blocks nbits blocksz x-equiv)))
      :rule-classes :congruence)