Skip to content

Commit

Permalink
Improve the comments about mtval
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Oct 27, 2023
1 parent 3f1d8ac commit 87f11c2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ static void rv_exception_default_handler(riscv_t *rv)
rv->PC = rv->csr_mepc; /* mret */
}

/* When a trap occurs in M-mode, mtval is either initialized to zero or
* populated with exception-specific details to assist software in managing
* the trap. Otherwise, the implementation never modifies mtval, although
* software can explicitly write to it. The hardware platform will define
* which exceptions are required to informatively set mtval and which may
* consistently set it to zero.
*
* When a hardware breakpoint is triggered or an exception like address
* misalignment, access fault, or page fault occurs during an instruction
* fetch, load, or store operation, mtval is updated with the virtual address
* that caused the fault. In the case of an illegal instruction trap, mtval
* might be updated with the first XLEN or ILEN bits of the offending
* instruction. For all other traps, mtval is simply set to zero. However,
* it is worth noting that a future standard could redefine how mtval is
* handled for different types of traps.
*/
#define EXCEPTION_HANDLER_IMPL(type, code) \
static void rv_except_##type(riscv_t *rv, uint32_t mtval) \
{ \
Expand Down

1 comment on commit 87f11c2

@jserv
Copy link
Contributor Author

@jserv jserv commented on 87f11c2 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Benchmark suite Current: 87f11c2 Previous: 666b7eb Ratio
Dhrystone 1174.25 Average DMIPS over 10 runs 1404.12 Average DMIPS over 10 runs 1.20
Coremark 1053.546 Average iterations/sec over 10 runs 1164.239 Average iterations/sec over 10 runs 1.11

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.