• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
        • Instructions
        • States
          • Stat
          • Stat-validp
          • Write-memory-unsigned64
          • Write-memory-unsigned32
          • Write-memory-unsigned8
          • Write-memory-unsigned16
          • Read-xreg-unsigned
          • Write-xreg-32
          • States64
          • Write-xreg
          • Read-memory-unsigned8
          • Read-memory-unsigned64
          • Read-memory-unsigned32
            • Read-memory-unsigned16
            • Read-xreg-signed
            • Read-xreg-unsigned32
            • States32
            • Write-pc
            • Read-xreg-signed32
            • Read-pc
            • Inc4-pc
          • Decoding
          • Encoding
          • Features
          • Semantics
          • Execution
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • States

    Read-memory-unsigned32

    Read an unsigned 32-bit integer from memory.

    Signature
    (read-memory-unsigned32 addr stat feat) → val
    Arguments
    addr — Guard (integerp addr).
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    val — Type (ubyte32p val).

    The memory address is the one of the first byte; we read that, and the subsequent bytes. For now we only support little endian memory, so the first byte is the lowest one.

    As in read-memory-unsigned8, we let the address be any integer. We use read-memory-unsigned8 four times. Note that if addr is close to 2^XLEN - 1, then the subsequent addresses may wrap around to addres 0.

    Definitions and Theorems

    Function: read-memory-unsigned32

    (defun read-memory-unsigned32 (addr stat feat)
      (declare (xargs :guard (and (integerp addr)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'read-memory-unsigned32))
        (declare (ignorable __function__))
        (b* ((addr (lifix addr))
             (b0 (read-memory-unsigned8 addr stat feat))
             (b1 (read-memory-unsigned8 (+ addr 1)
                                        stat feat))
             (b2 (read-memory-unsigned8 (+ addr 2)
                                        stat feat))
             (b3 (read-memory-unsigned8 (+ addr 3)
                                        stat feat)))
          (+ b0 (ash b1 8)
             (ash b2 16)
             (ash b3 24)))))

    Theorem: ubyte32p-of-read-memory-unsigned32

    (defthm ubyte32p-of-read-memory-unsigned32
      (b* ((val (read-memory-unsigned32 addr stat feat)))
        (ubyte32p val))
      :rule-classes :rewrite)

    Theorem: natp-of-read-memory-unsigned32

    (defthm natp-of-read-memory-unsigned32
      (b* ((val (read-memory-unsigned32 addr stat feat)))
        (natp val))
      :rule-classes :type-prescription)

    Theorem: read-memory-unsigned32-of-ifix-addr

    (defthm read-memory-unsigned32-of-ifix-addr
      (equal (read-memory-unsigned32 (ifix addr)
                                     stat feat)
             (read-memory-unsigned32 addr stat feat)))

    Theorem: read-memory-unsigned32-int-equiv-congruence-on-addr

    (defthm read-memory-unsigned32-int-equiv-congruence-on-addr
      (implies (acl2::int-equiv addr addr-equiv)
               (equal (read-memory-unsigned32 addr stat feat)
                      (read-memory-unsigned32 addr-equiv stat feat)))
      :rule-classes :congruence)

    Theorem: read-memory-unsigned32-of-stat-fix-stat

    (defthm read-memory-unsigned32-of-stat-fix-stat
      (equal (read-memory-unsigned32 addr (stat-fix stat)
                                     feat)
             (read-memory-unsigned32 addr stat feat)))

    Theorem: read-memory-unsigned32-stat-equiv-congruence-on-stat

    (defthm read-memory-unsigned32-stat-equiv-congruence-on-stat
      (implies (stat-equiv stat stat-equiv)
               (equal (read-memory-unsigned32 addr stat feat)
                      (read-memory-unsigned32 addr stat-equiv feat)))
      :rule-classes :congruence)

    Theorem: read-memory-unsigned32-of-feat-fix-feat

    (defthm read-memory-unsigned32-of-feat-fix-feat
      (equal (read-memory-unsigned32 addr stat (feat-fix feat))
             (read-memory-unsigned32 addr stat feat)))

    Theorem: read-memory-unsigned32-feat-equiv-congruence-on-feat

    (defthm read-memory-unsigned32-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (read-memory-unsigned32 addr stat feat)
                      (read-memory-unsigned32 addr stat feat-equiv)))
      :rule-classes :congruence)