• Top
    • Documentation
      • Xdoc
        • Missing-parents
          • Exec-bgeu
          • Exec-bltu
          • Exec-blt
          • Exec-bge
          • Exec-jalr
          • Exec-bne
          • Exec-beq
          • Exec-sra
          • Exec-op-imms-32
          • Exec-srl
          • Exec-sll
          • Exec-op-imms64
          • Exec-op-imms32
          • Exec-op-imm-32
          • Exec-op-32
          • Exec-op
          • Exec-branch
          • 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-lwu
            • Exec-div
            • Exec-auipc
            • Exec-addw
            • Exec-xor
            • Exec-mulw
            • Exec-mulh
            • 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
            • Missing-parents-test
          • Undocumented
          • Save
          • Defsection
          • Markup
          • Preprocessor
          • Terminal
          • Emacs-links
          • Defxdoc
          • Katex-integration
          • Constructors
          • Entities
          • Defxdoc+
          • Save-rendered
          • Add-resource-directory
          • Testing
          • Order-subtopics
          • Save-rendered-event
          • Archive-matching-topics
          • Archive-xdoc
          • Xdoc-extend
          • Set-default-parents
          • Defpointer
          • Defxdoc-raw
          • Xdoc-tests
          • Xdoc-prepend
          • Defsection-progn
          • Gen-xdoc-for-file
        • ACL2-doc
        • Recursion-and-induction
        • Loop$-primer
        • Operational-semantics
        • Pointers
        • Doc
        • Documentation-copyright
        • Course-materials
        • Publications
        • Args
        • ACL2-doc-summary
        • Finding-documentation
        • Broken-link
        • Doc-terminal-test-2
        • Doc-terminal-test-1
      • Books
      • Boolean-reasoning
      • Projects
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Missing-parents

    Exec-jal

    Semantics of the JAL instruction [ISA:2.5.1].

    Signature
    (exec-jal rd imm pc stat feat) → new-stat
    Arguments
    rd — Guard (ubyte5p rd).
    imm — Guard (ubyte20p imm).
    stat — Guard (statp stat).
    feat — Guard (featp feat).
    Returns
    new-stat — Type (statp 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 XLEN 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: exec-jal

    (defun exec-jal (rd imm pc stat feat)
      (declare (xargs :guard (and (ubyte5p rd)
                                  (ubyte20p imm)
                                  (statp stat)
                                  (featp feat))))
      (declare (xargs :guard (and (stat-validp stat feat)
                                  (cond ((feat-32p feat) (ubyte32p pc))
                                        ((feat-64p feat) (ubyte64p pc))
                                        (t (impossible))))))
      (let ((__function__ 'exec-jal))
        (declare (ignorable __function__))
        (b* ((offset (loghead (feat->xlen feat)
                              (logext 21 (ash (ubyte20-fix imm) 1))))
             (target-pc (+ pc offset))
             (next-pc (+ pc 4))
             (stat (write-xreg (ubyte5-fix rd)
                               next-pc stat feat))
             (stat (write-pc target-pc stat feat)))
          stat)))

    Theorem: statp-of-exec-jal

    (defthm statp-of-exec-jal
      (b* ((new-stat (exec-jal rd imm pc stat feat)))
        (statp new-stat))
      :rule-classes :rewrite)

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

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

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

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

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

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

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

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

    Theorem: exec-jal-of-stat-fix-stat

    (defthm exec-jal-of-stat-fix-stat
      (equal (exec-jal rd imm pc (stat-fix stat)
                       feat)
             (exec-jal rd imm pc stat feat)))

    Theorem: exec-jal-stat-equiv-congruence-on-stat

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

    Theorem: exec-jal-of-feat-fix-feat

    (defthm exec-jal-of-feat-fix-feat
      (equal (exec-jal rd imm pc stat (feat-fix feat))
             (exec-jal rd imm pc stat feat)))

    Theorem: exec-jal-feat-equiv-congruence-on-feat

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