2 // Copyright (C) 2008 Tomasz Malesinski <tmal@mimuw.edu.pl>
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 else if (ir
[4:0] == 'h01
) begin
22 adro_sel
= adr.ADRO_PC
;
27 // TODO: add X to DREG here?
28 adro_sel
= adr.ADR0_BASE
;
34 adro_sel
= adr.ADRO_DREGIND
;
42 adro_sel
= adr.ADRO_DREGIND
;
47 adro_sel
= adr.ADR_BASE
;
52 end else if (ir
[4:0] == 'h05
) begin
56 adro_sel
= adr.ADRO_PC
;
68 end else if (ir
[4:0] == 'h09
) begin
72 adro_sel
= adr.ADRO_PC
;
76 end else if (ir
[4:0] == 'h0d
) begin
82 adro_sel
= adr.ADRO_BASE
;
87 end else if (ir
[4:0] == 'h11
) begin
91 adro_sel
= adr.ADRO_PC
;
96 adro_sel
= adr.ADRO_DREG
;
104 adro_sel
= adr.ADRO_DREG
;
110 adro_sel
= adr.ADRO_BASEIND
;
116 end else if (ir
[4:0] == 'h15
) begin
120 adro_sel
= adr.ADRO_PC
;
125 adro_sel
= ADRO_BASE
;
131 adro_sel
= ADRO_BASEIND
;
139 end else if (ir
[4:0] == 'h19
) begin
151 adro_sel
= adr.ADRO_BASEIND
;
157 end else if (ir
[4:0] == 'h1d
) begin
169 adro_sel
= adr.ADRO_BASEIND
;
175 end else if ((ir
== 'ha0 || ir
== 'ha2
)) begin
179 adro_sel
= adr.ADRO_PC
;
184 end else if (ir
== 'ha4 || ir
== 'ha6 || ir
== 'h84 || ir
== 'h86
) begin
188 adro_sel
= adr.ADRO_PC
;
193 adro_sel
= ADRO_BASE
;
196 ldxy_exec
= (ir
[7:4] == 'ha
);
197 stxy_exec
= (ir
[7:4] == 'h8
);
202 end else if (ir
== 'hac || ir
== 'hae || ir
== 'h8c || ir
== 'h8e
) begin
208 adro_sel
= adr.ADRO_BASE
;
209 ldxy_exec
= (ir
[7:4] == 'ha
);
210 stxy_exec
= (ir
[7:4] == 'h8
);
215 end else if (ir
== 'hb4 || ir
== 'hb6 || ir
== 'h94 || ir
== 'h96
) begin
216 // LDX/LDY b,y/x or ST*
219 adro_sel
= adr.ADRO_PC
;
224 adro_sel
= ADRO_BASE
;
230 adro_sel
= ADRO_BASEIND
;
233 adr_indx_sel
= (ir
== 'hb4
);
234 ldxy_exec
= (ir
[7:4] == 'hb
);
235 stxy_exec
= (ir
[7:4] == 'h9
);
240 end else if (ir
== 'hbc || ir
== 'hbe
) begin
248 adr_indx_sel
= (ir
== 'hbc
);
252 adro_sel
= adr.ADRO_BASEIND
;
253 adr_indx_sel
= (ir
== 'hbc
);
259 end else if (ir
== 'hc0 || ir
== 'he0
) begin
263 adro_sel
= adr.ADRO_PC
;
268 end else if (ir
== 'hc4 || ir
== 'he4
) begin
272 adro_sel
= adr.ADRO_PC
;
277 adro_sel
= ADRO_BASE
;
284 end else if (ir
[4:0] == 'h10
) begin
288 adro_sel
= adr.ADRO_PC
;
297 lastcyc
= (pc_c
& dreg
[7]) |
(~pc_c
& ~dreg
[7]);
305 end else if (ir
== 'h18 || ir
== 'h38 || ir
== 'h58 || ir
== 'h78 ||
306 ir
== 'hb8 || ir
== 'hd8 || ir
== 'hf8
) begin
308 // Everything is done in regf process.
314 if ((interrupt
== INT_NONE
) && (ir
[1:0] == 2'b01) &&
315 lastcyc
&& !adr_delay
) begin
316 aluop
= {1'b0, ir
[7:5]};
320 if (ir
[7:5] == 3'b100) begin
326 end else if (ir
[7:5] == alu.OPCMP
) begin
330 end else if (ir
[7:5] == alu.OPADC
) begin
331 // TODO: delay with decimal mode
334 end else if (ir
[7:5] == alu.OPSBC
) begin
341 if ((interrupt
== INT_NONE
) && ldxy_exec
&& adr_delay
== 0) begin
343 regxld
= (ir
[1] == 1);
344 regyld
= (ir
[1] == 0);
350 if ((interrupt
== INT_NONE
) && stxy_exec
&& adr_delay
== 0) begin
351 dato_sel
= (ir
[1] == 1) ? DATO_X
: DATO_Y
;