• 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
      • Riscv
        • Semantics
          • Exec-bgeu
          • Exec-bltu
          • Exec-blt
          • Exec-bge
          • Exec-jalr
          • Exec-bne
          • Exec-beq
          • Exec-sra
          • Exec-op-imms-32
          • Exec-srl
          • Exec-branch
          • Exec-sll
          • Exec-op-imms64
          • Exec-op-imms32
          • Exec-op-imm-32
          • Exec-op-32
          • Exec-op
          • Exec-srlw
          • Exec-srliw
          • Exec-sraw
          • Exec-sraiw
          • Exec-sltiu
          • Exec-remuw
          • Exec-op-imm
          • Exec-jal
          • Exec-store
          • Exec-srli64
          • Exec-srli32
          • Exec-srai64
          • Exec-srai32
          • Exec-sllw
          • Exec-remw
          • Exec-load
          • Exec-divuw
          • Exec-addiw
          • Exec-xori
          • Exec-slti
          • Exec-slliw
          • Exec-remu
          • Exec-rem
          • Exec-divw
          • Exec-sw
          • Exec-slli64
          • Exec-slli32
          • Exec-ori
          • Exec-mulhsu
          • Exec-divu
          • Exec-andi
          • Exec-addi
          • Exec-sltu
          • Exec-slt
          • Exec-mulhu
          • Exec-div
          • Exec-auipc
          • Exec-addw
          • Exec-xor
          • Exec-mulw
          • Exec-mulh
          • Exec-lwu
          • Exec-and
          • Exec-subw
          • Exec-sub
          • Exec-sh
          • Exec-sd
          • Exec-sb
          • Exec-or
          • Exec-lhu
          • Exec-lh
          • Exec-ld
          • Exec-lbu
          • Exec-lb
          • Exec-mul
          • Exec-add
          • Exec-lw
          • Exec-lui
          • Eff-addr
            • Exec-instr
          • Instructions
          • Decoding
          • States
          • Encoding
          • Features
          • Rv32im
          • Rv64im
          • Execution
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • 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
      • Community
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Semantics

    Eff-addr

    Effective address for a load or store instruction [ISA:2.6].

    Signature
    (eff-addr rs1 imm stat feat) → addr
    Arguments
    rs1 — Guard (ubyte5p rs1).
    imm — Guard (ubyte12p imm).
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    addr — Type (integerp addr).

    We read an unsigned XLEN-bit integer from rs1; this is the base. We sign-extend the 12-bit immediate to XLEN bits; this is the offset. We return the sum of base and offset, as an integer; the functions to read and write memory use the low XLEN bits of this integer.

    Definitions and Theorems

    Function: eff-addr

    (defun eff-addr (rs1 imm stat feat)
      (declare (xargs :guard (and (ubyte5p rs1)
                                  (ubyte12p imm)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (stat-validp stat feat)))
      (let ((__function__ 'eff-addr))
        (declare (ignorable __function__))
        (b* ((base (read-xreg-unsigned (ubyte5-fix rs1)
                                       stat feat))
             (offset (loghead (feat->xlen feat)
                              (logext 12 (ubyte12-fix imm)))))
          (+ base offset))))

    Theorem: integerp-of-eff-addr

    (defthm integerp-of-eff-addr
      (b* ((addr (eff-addr rs1 imm stat feat)))
        (integerp addr))
      :rule-classes :rewrite)

    Theorem: eff-addr-of-ubyte5-fix-rs1

    (defthm eff-addr-of-ubyte5-fix-rs1
      (equal (eff-addr (ubyte5-fix rs1)
                       imm stat feat)
             (eff-addr rs1 imm stat feat)))

    Theorem: eff-addr-ubyte5-equiv-congruence-on-rs1

    (defthm eff-addr-ubyte5-equiv-congruence-on-rs1
      (implies (ubyte5-equiv rs1 rs1-equiv)
               (equal (eff-addr rs1 imm stat feat)
                      (eff-addr rs1-equiv imm stat feat)))
      :rule-classes :congruence)

    Theorem: eff-addr-of-ubyte12-fix-imm

    (defthm eff-addr-of-ubyte12-fix-imm
      (equal (eff-addr rs1 (ubyte12-fix imm)
                       stat feat)
             (eff-addr rs1 imm stat feat)))

    Theorem: eff-addr-ubyte12-equiv-congruence-on-imm

    (defthm eff-addr-ubyte12-equiv-congruence-on-imm
      (implies (acl2::ubyte12-equiv imm imm-equiv)
               (equal (eff-addr rs1 imm stat feat)
                      (eff-addr rs1 imm-equiv stat feat)))
      :rule-classes :congruence)

    Theorem: eff-addr-of-stat-fix-stat

    (defthm eff-addr-of-stat-fix-stat
      (equal (eff-addr rs1 imm (stat-fix stat) feat)
             (eff-addr rs1 imm stat feat)))

    Theorem: eff-addr-stat-equiv-congruence-on-stat

    (defthm eff-addr-stat-equiv-congruence-on-stat
      (implies (stat-equiv stat stat-equiv)
               (equal (eff-addr rs1 imm stat feat)
                      (eff-addr rs1 imm stat-equiv feat)))
      :rule-classes :congruence)

    Theorem: eff-addr-of-feat-fix-feat

    (defthm eff-addr-of-feat-fix-feat
      (equal (eff-addr rs1 imm stat (feat-fix feat))
             (eff-addr rs1 imm stat feat)))

    Theorem: eff-addr-feat-equiv-congruence-on-feat

    (defthm eff-addr-feat-equiv-congruence-on-feat
      (implies (feat-equiv feat feat-equiv)
               (equal (eff-addr rs1 imm stat feat)
                      (eff-addr rs1 imm stat feat-equiv)))
      :rule-classes :congruence)