From 9f4ac4dc09c9ccb93c6b1d9726bc7543ff09de00 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 29 Oct 2023 19:35:11 +0100 Subject: [PATCH] fix: jump according to zero flag, not LSB zero!! --- src/cpu.sv | 2 +- src/instruction_decoder.sv | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpu.sv b/src/cpu.sv index 1f4542d..c734df3 100755 --- a/src/cpu.sv +++ b/src/cpu.sv @@ -75,7 +75,7 @@ module cpu( end // pc source - assign jump_taken = jump_instruction && (alu_out[0] ^ jump_negate_zero); + assign jump_taken = jump_instruction && (alu_zero ^ jump_negate_zero); always_comb begin case (pc_src) PC_PLUS : begin diff --git a/src/instruction_decoder.sv b/src/instruction_decoder.sv index da48bfe..a33dd79 100755 --- a/src/instruction_decoder.sv +++ b/src/instruction_decoder.sv @@ -152,18 +152,18 @@ module instruction_decoder( end 3'b100 : begin // blt alu_jump_op = 3'b010; + jump_negate_zero = 1'b1; // less than 011 end 3'b101 : begin // bge alu_jump_op = 3'b010; - jump_negate_zero = 1'b1; end 3'b110 : begin // bltu alu_jump_op = 3'b011; + jump_negate_zero = 1'b1; end 3'b111 : begin // bgeu alu_jump_op = 3'b011; - jump_negate_zero = 1'b1; end default : ; endcase -- 2.48.1