[rtl] Do not update CSRs upon exceptions in debug mode

In debug mode, exceptions shall not update any CSRs including `mcause`,
`mepc`, `mtval`, `dpc` and `mstatus`, see Debug Spec v0.13.2, p.39.

This resolves lowRISC/ibex#168.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This commit is contained in:
Pirmin Vogel 2019-11-14 18:43:03 +01:00
parent 8112ba5a24
commit d117b24a17

View file

@ -522,7 +522,9 @@ module ibex_cs_registers #(
dcsr_d.prv = priv_lvl_q;
dcsr_d.cause = debug_cause_i;
depc_d = exception_pc;
end else begin
end else if (!debug_mode_i) begin
// In debug mode, "exceptions do not update any registers. That
// includes cause, epc, tval, dpc and mstatus." [Debug Spec v0.13.2, p.39]
mtval_d = csr_mtval_i;
mstatus_d.mie = 1'b0; // disable interrupts
// save current status