• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Pfcs
      • Wp-gen
      • Dimacs-reader
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Riscv
        • Specification
        • Executable
        • Specialized
          • Rv64im
            • Semantics64
              • Exec64-bgeu
              • Exec64-bltu
              • Exec64-blt
              • Exec64-bge
              • Exec64-bne
              • Exec64-beq
              • Exec64-jalr
              • Exec64-branch
              • Exec64-jal
                • Exec64-op-imms-32
                • Exec64-op-32
                • Exec64-op
                • Exec64-srlw
                • Exec64-sraw
                • Exec64-op-imm-32
                • Exec64-op-imm
                • Exec64-auipc
                • Exec64-store
                • Exec64-sra
                • Exec64-sltiu
                • Exec64-remw
                • Exec64-remuw
                • Exec64-op-imms
                • Exec64-load
                • Exec64-srliw
                • Exec64-srl
                • Exec64-sraiw
                • Exec64-slti
                • Exec64-sllw
                • Exec64-remu
                • Exec64-rem
                • Exec64-divw
                • Exec64-divuw
                • Exec64-addiw
                • Exec64-xori
                • Exec64-srli
                • Exec64-srai
                • Exec64-ori
                • Exec64-divu
                • Exec64-andi
                • Exec64-addi
                • Exec64-sltu
                • Exec64-slt
                • Exec64-slliw
                • Exec64-sll
                • Exec64-mulhsu
                • Exec64-lwu
                • Exec64-lhu
                • Exec64-div
                • Exec64-xor
                • Exec64-sw
                • Exec64-slli
                • Exec64-sh
                • Exec64-mulw
                • Exec64-mulhu
                • Exec64-mulh
                • Exec64-lw
                • Exec64-lh
                • Exec64-lbu
                • Exec64-addw
                • Exec64-subw
                • Exec64-sub
                • Exec64-sd
                • Exec64-sb
                • Exec64-or
                • Exec64-ld
                • Exec64-lb
                • Exec64-and
                • Exec64-mul
                • Exec64-add
                • Exec64-instr
                • Eff64-addr
                • Exec64-lui
              • States64
              • Execution64
            • Rv32im
        • 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
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Semantics64

    Exec64-jal

    Semantics of the JAL instruction [ISA:2.5.1].

    Signature
    (exec64-jal rd imm pc stat) → new-stat
    Arguments
    rd — Guard (ubyte5p rd).
    imm — Guard (ubyte20p imm).
    pc — Guard (ubyte64p pc).
    stat — Guard (state64p stat).
    Returns
    new-stat — Type (state64p 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 64 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: exec64-jal

    (defun exec64-jal (rd imm pc stat)
      (declare (xargs :guard (and (ubyte5p rd)
                                  (ubyte20p imm)
                                  (ubyte64p pc)
                                  (state64p stat))))
      (let ((__function__ 'exec64-jal))
        (declare (ignorable __function__))
        (b* ((offset (loghead 64
                              (logext 21 (ash (ubyte20-fix imm) 1))))
             (pc (ubyte64-fix pc))
             (target-pc (+ pc offset))
             (next-pc (+ pc 4))
             (stat (write64-xreg rd next-pc stat))
             (stat (write64-pc target-pc stat)))
          stat)))

    Theorem: state64p-of-exec64-jal

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

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

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

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

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

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

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

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

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

    Theorem: exec64-jal-of-ubyte64-fix-pc

    (defthm exec64-jal-of-ubyte64-fix-pc
      (equal (exec64-jal rd imm (ubyte64-fix pc)
                         stat)
             (exec64-jal rd imm pc stat)))

    Theorem: exec64-jal-ubyte64-equiv-congruence-on-pc

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

    Theorem: exec64-jal-of-state64-fix-stat

    (defthm exec64-jal-of-state64-fix-stat
      (equal (exec64-jal rd imm pc (state64-fix stat))
             (exec64-jal rd imm pc stat)))

    Theorem: exec64-jal-state64-equiv-congruence-on-stat

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