Skip to content

Commit 0e04a86

Browse files
authored
Fix tval reported values in some exception cases (#3226)
* Set tval to zero on ecall See #3019 * Set tval to instruction address on ebreak See #3019 * Report target not pc in tval on misaligned jump See #3018
1 parent ea31c7a commit 0e04a86

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

core/branch_unit.sv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ module branch_unit #(
120120
branch_exception_o.cause = riscv::INSTR_ADDR_MISALIGNED;
121121
branch_exception_o.valid = 1'b0;
122122
if (CVA6Cfg.TvalEn)
123-
branch_exception_o.tval = {{CVA6Cfg.XLEN - CVA6Cfg.VLEN{pc_i[CVA6Cfg.VLEN-1]}}, pc_i};
123+
branch_exception_o.tval = {
124+
{CVA6Cfg.XLEN - CVA6Cfg.VLEN{target_address[CVA6Cfg.VLEN-1]}}, target_address
125+
};
124126
else branch_exception_o.tval = '0;
125127
branch_exception_o.tval2 = {CVA6Cfg.GPLEN{1'b0}};
126128
branch_exception_o.tinst = '0;

core/decoder.sv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ module decoder
18771877
end else if (priv_lvl_i == riscv::PRIV_LVL_M) begin
18781878
instruction_o.ex.cause = riscv::ENV_CALL_MMODE;
18791879
end
1880+
if (CVA6Cfg.TvalEn) instruction_o.ex.tval = '0;
18801881
end else if (ebreak) begin
18811882
// this exception is valid
18821883
instruction_o.ex.valid = 1'b1;
@@ -1885,6 +1886,7 @@ module decoder
18851886
// set gva bit
18861887
if (CVA6Cfg.RVH) instruction_o.ex.gva = v_i;
18871888
else instruction_o.ex.gva = 1'b0;
1889+
if (CVA6Cfg.TvalEn) instruction_o.ex.tval = pc_i;
18881890
end
18891891
// -----------------
18901892
// Interrupt Control

0 commit comments

Comments
 (0)