From bb9ebeb9e37bc6103f527b434a13d9b4889a796b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 18 May 2017 17:19:08 +0200 Subject: [PATCH] Fixed jalr, c_jalr, and c_jr insns (bug discovered by riscv-formal) --- picorv32.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/picorv32.v b/picorv32.v index ba9fc0a..8c7b5b8 100644 --- a/picorv32.v +++ b/picorv32.v @@ -1175,7 +1175,7 @@ module picorv32 #( reg [regindex_bits-1:0] latched_rd; reg [31:0] current_pc; - assign next_pc = latched_store && latched_branch ? reg_out : reg_next_pc; + assign next_pc = latched_store && latched_branch ? reg_out & ~1 : reg_next_pc; reg [3:0] pcpi_timeout_counter; reg pcpi_timeout; @@ -1430,7 +1430,7 @@ module picorv32 #( (* parallel_case *) case (1'b1) latched_branch: begin - current_pc = latched_store ? (latched_stalu ? alu_out_q : reg_out) : reg_next_pc; + current_pc = latched_store ? (latched_stalu ? alu_out_q : reg_out) & ~1 : reg_next_pc; `debug($display("ST_RD: %2d 0x%08x, BRANCH 0x%08x", latched_rd, reg_pc + (latched_compr ? 2 : 4), current_pc);) end latched_store && !latched_branch: begin