]> Joshua Wise's Git repositories - fpgaboy.git/blame - core/insn_alu_a.v
Merge branch 'master' of andrew:/afs/andrew/usr/czl/public/FPGABoy
[fpgaboy.git] / core / insn_alu_a.v
CommitLineData
e7fe9dc2
JW
1`define INSN_alu_RLCA 3'b000
2`define INSN_alu_RRCA 3'b001
3`define INSN_alu_RLA 3'b010
4`define INSN_alu_RRA 3'b011
5`define INSN_alu_DAA 3'b100
6`define INSN_alu_CPL 3'b101
7`define INSN_alu_SCF 3'b110
8`define INSN_alu_CCF 3'b111
9
10`define INSN_ALU_A 9'b000xxx111
11
3ad960bd
JW
12`ifdef EXECUTE
13 `INSN_ALU_A: begin
5c33c5c0
JW
14 `EXEC_NEWCYCLE
15 `EXEC_INC_PC
3ad960bd
JW
16 end
17`endif
18
19`ifdef WRITEBACK
20 `INSN_ALU_A: begin
21 case(opcode[5:3])
22 `INSN_alu_RLCA: begin
5c33c5c0
JW
23 `_A <= {`_A[6:0],`_A[7]};
24 `_F <= {`_F[7:5],`_A[7],`_F[3:0]};
3ad960bd
JW
25 end
26 `INSN_alu_RRCA: begin
5c33c5c0
JW
27 `_A <= {`_A[0],`_A[7:1]};
28 `_F <= {`_F[7:5],`_A[0],`_F[3:0]};
3ad960bd
JW
29 end
30 `INSN_alu_RLA: begin
5c33c5c0
JW
31 `_A <= {`_A[6:0],`_F[4]};
32 `_F <= {`_F[7:5],`_A[7],`_F[3:0]};
3ad960bd
JW
33 end
34 `INSN_alu_RRA: begin
1a827c5b 35 `_A <= {`_F[4],`_A[7:1]};
5c33c5c0 36 `_F <= {`_F[7:5],`_A[0],`_F[3:0]};
3ad960bd 37 end
1a827c5b
CZL
38 `INSN_alu_DAA: begin
39 if (`_F[6]) begin
40 if (`_F[4]) begin
41 if(`_A[3:0] >= 4'h6 && `_A[7:4] >= 4'h6 && `F[5]) begin
42 `_A <= `_A + 8'h9A;
43 `_F <= {((`_A + 8'h9A) == 8'b0), `_F[6:0]};
44 end
45 else begin
46 `_A <= `_A + 8'hA0;
47 `_F <= {((`_A + 8'hA0) == 8'b0), `_F[6:0]};
48 end
49 end
50 else begin
51 if(`_A[3:0] <= 4'h9 && `_A[7:4] <= 4'h9 && !`_F[5]) begin
52 `_F <= {(`_A == 8'b0), `_F[6:0]};
53 end
54 else begin
55 `_A <= `_A + 8'hFA;
56 `_F <= {((`_A + 8'hFA) == 8'b0), `_F[6:0]};
57 end
58 end
59 end
60 else begin
61 if (`_F[4]) begin
62 if(`_F[5]) begin
63 `_A <= `_A + 8'h66;
64 `_F <= {((`_A + 8'h66) == 8'b0), `_F[6:0]};
65 end
66 else if (`_A[3:0] > 4'b9) begin
67 `_A <= `_A + 8'h66;
68 `_F <= {((`_A + 8'h66) == 8'b0), `_F[6:0]};
69 end
70 else begin
71 `_A <= `_A + 8'h60;
72 `_F <= {((`_A + 8'h60) == 8'b0), `_F[6:0]};
73 end
74 end
75 else begin
76 if(`_F[5]) begin
77 if(`_A[7:4] > 4'h9) begin
78 `_A <= `_A + 8'h66;
79 `_F <= {((`_A + 8'h66) == 8'b0), `_F[6:5], 1'b1, `_F[3:0]};
80 end
81 else begin
82 `_A <= `_A + 8'h06;
83 `_F <= {((`_A + 8'h06) == 8'b0), `_F[6:0]};
84 end
85 end
86 else begin
87 if(`_A[3:0] > 4'h9) begin
88 if (`_A[7:4] > 4'h8) begin
89 `_A <= `_A + 8'h66;
90 `_F <= {((`_A + 8'h66) == 8'b0), `_F[6:5], 1'b1, `_F[3:0]};
91 end
92 else begin
93 `_A <= `_A + 8'h06;
94 `_F <= {((`_A + 8'h06) == 8'b0), `_F[6:0]};
95 end
96 end
97 else begin
98 if (`_A[7:4] > 4'h9) begin
99 `_A <= `_A + 8'h66;
100 `_F <= {((`_A + 8'h66) == 8'b0), `_F[6:5], 1'b1, `_F[3:0]};
101 end
102 else begin
103 `_F <= {(`_A == 8'b0), `_F[6:0]};
104 end
105 end
106 end
107 end
108 end
109 end
3ad960bd 110 `INSN_alu_CPL: begin
5c33c5c0
JW
111 `_A <= ~`_A;
112 `_F <= {`_F[7],1'b1,1'b1,`_F[4:0]};
3ad960bd
JW
113 end
114 `INSN_alu_SCF: begin
5c33c5c0 115 `_F <= {`_F[7:5],1'b1,`_F[3:0]};
3ad960bd
JW
116 end
117 `INSN_alu_CCF: begin
5c33c5c0 118 `_F <= {`_F[7:5],~`_F[4],`_F[3:0]};
3ad960bd
JW
119 end
120 endcase
121 end
122`endif
This page took 0.050262 seconds and 4 git commands to generate.