From 2b33926900447d5c1952a6e02187f33bdb318dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me?= <124148386+cathales@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:03:11 +0100 Subject: [PATCH] fix: exception on misaligned branch if no RVC (#1719) --- core/branch_unit.sv | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/branch_unit.sv b/core/branch_unit.sv index 47004fe6b..dfcb1c767 100644 --- a/core/branch_unit.sv +++ b/core/branch_unit.sv @@ -99,6 +99,8 @@ module branch_unit #( branch_exception_o.tval = {{riscv::XLEN - riscv::VLEN{pc_i[riscv::VLEN-1]}}, pc_i}; // Only throw instruction address misaligned exception if this is indeed a `taken` conditional branch or // an unconditional jump - if (branch_valid_i && target_address[0] != 1'b0 && jump_taken) branch_exception_o.valid = 1'b1; + if (branch_valid_i && (target_address[0] || (!CVA6Cfg.RVC && target_address[1])) && jump_taken) begin + branch_exception_o.valid = 1'b1; + end end endmodule