diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-10-15 19:35:31 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-10-15 19:35:31 -0600 |
| commit | 5b0872c995ddd7f581730ff9c7e145b5228e211d (patch) | |
| tree | d8ae320a22874d807e8b9329916119c546a2ea69 /rtl/core/cycles.sv | |
| parent | ec152d814af82524cf68df95d7f06b9b70c0d0d0 (diff) | |
Fix branch target calculation
Diffstat (limited to '')
| -rw-r--r-- | rtl/core/cycles.sv | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/rtl/core/cycles.sv b/rtl/core/cycles.sv index c416187..2302c64 100644 --- a/rtl/core/cycles.sv +++ b/rtl/core/cycles.sv @@ -62,14 +62,14 @@ module core_cycles word saved_base, mem_offset; reg_num r_shift, final_rd, popped_upper, popped_lower, popped; reg_list mem_regs, next_regs_upper, next_regs_lower; - ptr pc; + ptr pc, next_pc_visible; assign stall = (next_cycle != ISSUE) | bubble; - assign pc_visible = pc + 2; assign reg_mode = `MODE_SVC; //TODO assign trivial_shift = shifter_shift == 0; assign mem_data_wr = rd_value_b; assign popped = ldst_increment ? popped_lower : popped_upper; + assign next_pc_visible = fetch_insn_pc + 2; core_cycles_ldst_pop ldst_pop ( @@ -157,7 +157,7 @@ module core_cycles | (final_writeback & ((rd == dec_data.rn) | (rd == dec_snd.r))); branch <= dec_branch; - branch_target <= pc_visible + dec_branch_offset; + branch_target <= next_pc_visible + dec_branch_offset; alu <= dec_data.op; ra <= dec_data.rn; @@ -196,6 +196,7 @@ module core_cycles writeback <= final_writeback; rd <= final_rd; pc <= fetch_insn_pc; + pc_visible <= next_pc_visible; end RD_INDIRECT_SHIFT: begin @@ -249,6 +250,8 @@ module core_cycles bubble = 0; pc = 0; + pc_visible = 2; + c_in = 0; branch = 1; writeback = 0; |
