• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Riscv
          • Specification
          • Executable
          • Specialized
            • Specialized-features
            • Rv64im
            • Rv32im
              • Semantics32
                • Exec32-bgeu
                • Exec32-bltu
                • Exec32-blt
                • Exec32-bge
                • Exec32-bne
                • Exec32-beq
                • Exec32-jalr
                • Exec32-branch
                • Exec32-jal
                  • Exec32-op
                  • Exec32-store
                  • Exec32-op-imm
                  • Exec32-load
                  • Exec32-sra
                  • Exec32-sltiu
                  • Exec32-op-imms
                  • Exec32-srl
                  • Exec32-slti
                  • Exec32-remu
                  • Exec32-rem
                  • Exec32-auipc
                  • Exec32-xori
                  • Exec32-srli
                  • Exec32-srai
                  • Exec32-ori
                  • Exec32-divu
                  • Exec32-andi
                  • Exec32-addi
                  • Exec32-sltu
                  • Exec32-slt
                  • Exec32-sll
                  • Exec32-mulhsu
                  • Exec32-lhu
                  • Exec32-div
                  • Exec32-xor
                  • Exec32-slli
                  • Exec32-sh
                  • Exec32-mulhu
                  • Exec32-mulh
                  • Exec32-lh
                  • Exec32-lbu
                  • Exec32-sw
                  • Exec32-sub
                  • Exec32-sb
                  • Exec32-or
                  • Exec32-lw
                  • Exec32-lb
                  • Exec32-and
                  • Exec32-mul
                  • Exec32-add
                  • Exec32-instr
                  • Eff32-addr
                  • Exec32-lui
                • States32
                • Execution32
              • Specialized-states
            • Optimized
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Semantics32

    Exec32-jal

    Semantics of the JAL instruction [ISA:2.5.1].

    Signature
    (exec32-jal rd imm pc stat) → new-stat
    Arguments
    rd — Guard (ubyte5p rd).
    imm — Guard (ubyte20p imm).
    pc — Guard (ubyte32p pc).
    stat — Guard (stat32ip stat).
    Returns
    new-stat — Type (stat32ip new-stat).

    We use the 20 bits of the immediate as the high bits of an unsigned 21-bit integer, whose low bit is 0 (i.e. the immediate measures multiples of 2); the unsigned 21-bit integer is sign-extended to 32 bits, obtaining an offset. We add the offset to the address of the instruction, which is passed as the pc input to this function; this is the jump target. We write the address of the instruction just after this to rd; since instructions are 32-bit long, the address of the next instruction is obtained by adding 4 to pc. We write the jump target to the program counter.

    Definitions and Theorems

    Function: exec32-jal

    (defun exec32-jal (rd imm pc stat)
      (declare (xargs :guard (and (ubyte5p rd)
                                  (ubyte20p imm)
                                  (ubyte32p pc)
                                  (stat32ip stat))))
      (let ((__function__ 'exec32-jal))
        (declare (ignorable __function__))
        (b* ((offset (loghead 32
                              (logext 21 (ash (ubyte20-fix imm) 1))))
             (pc (ubyte32-fix pc))
             (target-pc (+ pc offset))
             (next-pc (+ pc 4))
             (stat (write32-xreg rd next-pc stat))
             (stat (write32-pc target-pc stat)))
          stat)))

    Theorem: stat32ip-of-exec32-jal

    (defthm stat32ip-of-exec32-jal
      (b* ((new-stat (exec32-jal rd imm pc stat)))
        (stat32ip new-stat))
      :rule-classes :rewrite)

    Theorem: exec32-jal-of-ubyte5-fix-rd

    (defthm exec32-jal-of-ubyte5-fix-rd
      (equal (exec32-jal (ubyte5-fix rd) imm pc stat)
             (exec32-jal rd imm pc stat)))

    Theorem: exec32-jal-ubyte5-equiv-congruence-on-rd

    (defthm exec32-jal-ubyte5-equiv-congruence-on-rd
      (implies (ubyte5-equiv rd rd-equiv)
               (equal (exec32-jal rd imm pc stat)
                      (exec32-jal rd-equiv imm pc stat)))
      :rule-classes :congruence)

    Theorem: exec32-jal-of-ubyte20-fix-imm

    (defthm exec32-jal-of-ubyte20-fix-imm
      (equal (exec32-jal rd (ubyte20-fix imm)
                         pc stat)
             (exec32-jal rd imm pc stat)))

    Theorem: exec32-jal-ubyte20-equiv-congruence-on-imm

    (defthm exec32-jal-ubyte20-equiv-congruence-on-imm
      (implies (acl2::ubyte20-equiv imm imm-equiv)
               (equal (exec32-jal rd imm pc stat)
                      (exec32-jal rd imm-equiv pc stat)))
      :rule-classes :congruence)

    Theorem: exec32-jal-of-ubyte32-fix-pc

    (defthm exec32-jal-of-ubyte32-fix-pc
      (equal (exec32-jal rd imm (ubyte32-fix pc)
                         stat)
             (exec32-jal rd imm pc stat)))

    Theorem: exec32-jal-ubyte32-equiv-congruence-on-pc

    (defthm exec32-jal-ubyte32-equiv-congruence-on-pc
      (implies (acl2::ubyte32-equiv pc pc-equiv)
               (equal (exec32-jal rd imm pc stat)
                      (exec32-jal rd imm pc-equiv stat)))
      :rule-classes :congruence)

    Theorem: exec32-jal-of-stat32i-fix-stat

    (defthm exec32-jal-of-stat32i-fix-stat
      (equal (exec32-jal rd imm pc (stat32i-fix stat))
             (exec32-jal rd imm pc stat)))

    Theorem: exec32-jal-stat32i-equiv-congruence-on-stat

    (defthm exec32-jal-stat32i-equiv-congruence-on-stat
      (implies (stat32i-equiv stat stat-equiv)
               (equal (exec32-jal rd imm pc stat)
                      (exec32-jal rd imm pc stat-equiv)))
      :rule-classes :congruence)