Skip to content

Commit

Permalink
fix: fix the value written to mepc so that the low bit of mepc is alw…
Browse files Browse the repository at this point in the history
…ays zero #39
  • Loading branch information
mmxsrup committed Apr 7, 2021
1 parent 8777d59 commit 6770538
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Processor/Src/Privileged/CSR_Unit.sv
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ module CSR_Unit(
CSR_NUM_MCAUSE: csrNext.mcause = wv;
CSR_NUM_MTVEC: csrNext.mtvec = wv;
CSR_NUM_MTVAL: csrNext.mtval = wv;
CSR_NUM_MEPC: csrNext.mepc = wv;
// The low bit of mepc is always zero,
// as described in Chapter 3.1.19 of RISC-V Privileged Architectures.
CSR_NUM_MEPC: csrNext.mepc = {wv[31:1], 1'b0};
CSR_NUM_MSCRATCH: csrNext.mscratch = wv;

CSR_NUM_MCYCLE: csrNext.mcycle = wv;
Expand Down

0 comments on commit 6770538

Please sign in to comment.