• 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-unsigned8

    Read an unsigned 8-bit integer from memory.

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

    The address is an integer of arbitrary size, of which we consider only the low XLEN bits, as an unsigned address. Allowing any integer is convenient for callers. We return the byte at that address.

    Since we read a single byte, there is no difference between little and big endian.

    Definitions and Theorems

    Function: read-memory-unsigned8

    (defun read-memory-unsigned8 (addr stat feat)
      (declare (xargs :guard (and (integerp addr)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'read-memory-unsigned8))
        (declare (ignorable __function__))
        (b* ((addr (loghead (feat->xlen feat)
                            (lifix addr))))
          (ubyte8-fix (nth addr (stat->memory stat))))))

    Theorem: ubyte8p-of-read-memory-unsigned8

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

    Theorem: natp-of-read-memory-unsigned8

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

    Theorem: read-memory-unsigned8-upper-bound

    (defthm read-memory-unsigned8-upper-bound
      (b* ((?val (read-memory-unsigned8 addr stat feat)))
        (<= val 255))
      :rule-classes :linear)

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

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

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

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

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

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

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

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

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

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

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

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