• 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

    Write-pc

    Write the program counter.

    Signature
    (write-pc pc stat feat) → new-stat
    Arguments
    pc — Guard (natp pc).
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    new-stat — Type (statp new-stat).

    We pass an unsigned integer of arbitrary size, of which only the low XLEN bits are kept, and written to the program counter register.

    [ISA:1.4] says that address computations wrap around ignoring overflow, i.e. the last address in the address space is adjacent to address 0. This function handles the wrapping around, see e.g. inc4-pc.

    Definitions and Theorems

    Function: write-pc

    (defun write-pc (pc stat feat)
      (declare (xargs :guard (and (natp pc)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'write-pc))
        (declare (ignorable __function__))
        (change-stat stat
                     :pc (loghead (feat->xlen feat)
                                  (lnfix pc)))))

    Theorem: statp-of-write-pc

    (defthm statp-of-write-pc
      (b* ((new-stat (write-pc pc stat feat)))
        (statp new-stat))
      :rule-classes :rewrite)

    Theorem: stat-validp-of-write-pc

    (defthm stat-validp-of-write-pc
      (implies (stat-validp stat feat)
               (b* ((?new-stat (write-pc pc stat feat)))
                 (stat-validp new-stat feat))))

    Theorem: write-pc-of-nfix-pc

    (defthm write-pc-of-nfix-pc
      (equal (write-pc (nfix pc) stat feat)
             (write-pc pc stat feat)))

    Theorem: write-pc-nat-equiv-congruence-on-pc

    (defthm write-pc-nat-equiv-congruence-on-pc
      (implies (acl2::nat-equiv pc pc-equiv)
               (equal (write-pc pc stat feat)
                      (write-pc pc-equiv stat feat)))
      :rule-classes :congruence)

    Theorem: write-pc-of-stat-fix-stat

    (defthm write-pc-of-stat-fix-stat
      (equal (write-pc pc (stat-fix stat) feat)
             (write-pc pc stat feat)))

    Theorem: write-pc-stat-equiv-congruence-on-stat

    (defthm write-pc-stat-equiv-congruence-on-stat
      (implies (stat-equiv stat stat-equiv)
               (equal (write-pc pc stat feat)
                      (write-pc pc stat-equiv feat)))
      :rule-classes :congruence)

    Theorem: write-pc-of-feat-fix-feat

    (defthm write-pc-of-feat-fix-feat
      (equal (write-pc pc stat (feat-fix feat))
             (write-pc pc stat feat)))

    Theorem: write-pc-feat-equiv-congruence-on-feat

    (defthm write-pc-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (write-pc pc stat feat)
                      (write-pc pc stat feat-equiv)))
      :rule-classes :congruence)