From: Joshua Wise Date: Sun, 11 May 2008 11:04:03 +0000 (-0400) Subject: Fix some carry-related bugs and a typo in insn_alu_a. X-Git-Url: http://git.joshuawise.com/fpgaboy.git/commitdiff_plain/25f4912ce5d2a6c70a9f604502303a17359b19ec?ds=inline Fix some carry-related bugs and a typo in insn_alu_a. --- diff --git a/core/insn_add_hl.v b/core/insn_add_hl.v index 0d85f95..bfd6880 100644 --- a/core/insn_add_hl.v +++ b/core/insn_add_hl.v @@ -25,7 +25,7 @@ `_F <= { /* Z */ `_F[7], /* N */ 1'b0, /* H */ (({`_HL} + {tmp,tmp2}) & 16'h1000) ? 1'b1 : 1'b0, - /* C */ (({1'b0,`_HL} + {1'b0,tmp,tmp2}) >> 16 == 1) ? 1'b1 : 1'b0, + /* C */ (({1'b0,`_HL} + {1'b0,tmp,tmp2}) & 17'h10000) ? 1'b1 : 1'b0, `_F[3:0] }; `_HL <= {tmp, tmp2}; diff --git a/core/insn_alu8.v b/core/insn_alu8.v index 1283a9c..26fc77e 100644 --- a/core/insn_alu8.v +++ b/core/insn_alu8.v @@ -69,21 +69,21 @@ end `INSN_alu_AND: begin `_A <= `_A & tmp; - `_F <= { /* Z */ ((`_A & tmp) == 0) ? 1'b1 : 1'b0, + `_F <= { /* Z */ ((`_A & tmp) == 8'b0) ? 1'b1 : 1'b0, 3'b010, `_F[3:0] }; end `INSN_alu_OR: begin `_A <= `_A | tmp; - `_F <= { /* Z */ ((`_A | tmp) == 0) ? 1'b1 : 1'b0, + `_F <= { /* Z */ ((`_A | tmp) == 8'b0) ? 1'b1 : 1'b0, 3'b000, `_F[3:0] }; end `INSN_alu_XOR: begin `_A <= `_A ^ tmp; - `_F <= { /* Z */ ((`_A ^ tmp) == 0) ? 1'b1 : 1'b0, + `_F <= { /* Z */ ((`_A ^ tmp) == 8'b0) ? 1'b1 : 1'b0, 3'b000, `_F[3:0] }; diff --git a/core/insn_alu_a.v b/core/insn_alu_a.v index 14ccd76..a5e1c1c 100644 --- a/core/insn_alu_a.v +++ b/core/insn_alu_a.v @@ -32,7 +32,7 @@ `_F <= {`_F[7:5],`_A[7],`_F[3:0]}; end `INSN_alu_RRA: begin - `_A <= {`_A[4],`_A[7:1]}; + `_A <= {`_F[4],`_A[7:1]}; `_F <= {`_F[7:5],`_A[0],`_F[3:0]}; end `INSN_alu_CPL: begin