From 2985909bed841b6e2617aed8c3806492f4976f40 Mon Sep 17 00:00:00 2001 From: JeanRochCoulon Date: Sun, 10 Dec 2023 21:51:18 +0100 Subject: [PATCH 1/2] Fix branch misalignement condition Related to #1300 --- core/branch_unit.sv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/branch_unit.sv b/core/branch_unit.sv index 47004fe6bc..c0dd432f86 100644 --- a/core/branch_unit.sv +++ b/core/branch_unit.sv @@ -99,6 +99,6 @@ 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[1:0] != 2'b00) && jump_taken) branch_exception_o.valid = 1'b1; end endmodule From 7e84fcce6c8ad5f539052b904fa3de7d53e9c0bf Mon Sep 17 00:00:00 2001 From: JeanRochCoulon Date: Sun, 10 Dec 2023 21:54:31 +0100 Subject: [PATCH 2/2] Update core/branch_unit.sv Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- core/branch_unit.sv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/branch_unit.sv b/core/branch_unit.sv index c0dd432f86..391b25b015 100644 --- a/core/branch_unit.sv +++ b/core/branch_unit.sv @@ -99,6 +99,7 @@ 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[1:0] != 2'b00) && jump_taken) branch_exception_o.valid = 1'b1; + if (branch_valid_i && (target_address[1:0] != 2'b00) && jump_taken) + branch_exception_o.valid = 1'b1; end endmodule