@@ -25,7 +25,7 @@ access:
2525 vu : always
2626operation() : |
2727 # Ensure JVT readable
28- Csr csr_handle = direct_csr_lookup(0x017 );
28+ Csr csr_handle = direct_csr_lookup(CSR[jvt].address() );
2929 XReg jvt = csr_sw_read(csr_handle);
3030
3131 if (CSR[jvt].MODE != 0) {
@@ -37,30 +37,26 @@ operation(): |
3737 X[1] = return_addr;
3838
3939 XReg jump_table_base = { CSR[jvt].BASE, 6'b000000 };
40- XReg virtual_address = jump_table_base + index * (xlen() / 8);
40+ XReg virtual_address = jump_table_base + index ` * (xlen() / 8);
4141 XReg addr;
42+ TranslationResult result;
4243
43- # TODO
44- # For a table jump instruction, the table entry that the instruction selects
45- # is considered an extension of the instruction itself. Hence, the execution
46- # of a table jump instruction involves two instruction fetches, the first to
47- # read the instruction (cm.jt/cm.jalt) and the second to read from the jump
48- # vector table (JVT). Both instruction fetches are implicit reads, and both
49- # require execute permission; read permission is irrelevant. It is
50- # recommended that the second fetch be ignored for hardware triggers and breakpoints.
51- #
52- # If an exception occurs on either instruction fetch, xEPC is set to the PC
53- # of the table jump instruction, xCAUSE is set as expected for the type of
54- # fault and xTVAL (if not set to zero) contains the fetch address which
55- # caused the fault.
44+ # TODO: Correct this check when we figure out what MISA can do
45+ if (CSR[misa].S == 1) {
46+ result = translate(virtual_address, MemoryOperation::Fetch, mode(), $encoding);
47+ } else {
48+ result.paddr = virtual_address;
49+ }
50+
51+ # may raise an exception
52+ access_check(result.paddr, xlen(), $pc, MemoryOperation::Fetch, ExceptionCode::InstructionAccessFault, mode());
5653
5754 if (xlen() == 32) {
58- addr = read_memory <32>(virtual_address, $encoding );
55+ addr = read_physical_memory <32>(result.paddr );
5956 } else {
60- addr = read_memory <64>(virtual_address, $encoding );
61- }
57+ addr = read_physical_memory <64>(result.paddr );
58+ } # Ensure low-order bit is clear
6259
63- # Ensure low-order bit is clear
6460 addr = addr & $signed(2'b10);
6561
6662 jump(addr);
0 commit comments