Webcentive RISC-V Reference

cm.jalt

Jump Via Table with Optional Link

Extension
Zcmt
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
cm.jalt index
Length
16-bit (compressed)

Encoding

151312109210
101000c_index10

Match 0xa002, mask 0xfc03. Source: cm.jalt c_index 1..0=2 15..13=5 12..10=0 in riscv-opcodes/extensions/rv_zcmt.

FieldBitsriscv-opcodes name
c_index9:2c_index

Description

Read an address from the Jump Vector Table and jump to it, linking to ra.

Description from riscv-unified-db, reformatted.

Operation

# Ensure JVT readable
check_zcmt_enabled($encoding);

if (CSR[jvt].MODE != 0) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}

# Skip over _this_ 16-bit instruction
XReg return_addr = $pc + 2;
X[1] = return_addr;

XReg jump_table_base = { CSR[jvt].BASE, 6'b000000 };
XReg virtual_address = jump_table_base + index `* (xlen() / 8);
XReg addr;
TranslationResult result;

# TODO: Correct this check when we figure out what MISA can do
if (CSR[misa].S == 1) {
  result = translate(virtual_address, MemoryOperation::Fetch, mode(), $encoding);
} else {
  result.paddr = virtual_address;
}

# may raise an exception
access_check(result.paddr, xlen(), $pc, MemoryOperation::Fetch, ExceptionCode::InstructionAccessFault, mode());

if (xlen() == 32) {
  addr = read_physical_memory(32, result.paddr);
} else {
  addr = read_physical_memory(64, result.paddr);
}  # Ensure low-order bit is clear

addr = addr & $signed(2'b10);

jump(addr);

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages