OpenCores
URL https://opencores.org/ocsvn/t6507lp/t6507lp/trunk

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_alu.v] - Blame information for rev 217

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 141 creep
////////////////////////////////////////////////////////////////////////////
2 152 gabrielosh
////                                                                    ////
3
//// T6507LP IP Core                                                    ////
4
////                                                                    ////
5
//// This file is part of the T6507LP project                           ////
6
//// http://www.opencores.org/cores/t6507lp/                            ////
7
////                                                                    ////
8
//// Description                                                        ////
9
//// 6507 ALU                                                           ////
10
////                                                                    ////
11
//// To Do:                                                             ////
12
//// - Search for TODO                                                  ////
13
////                                                                    ////
14
//// Author(s):                                                         ////
15
//// - Gabriel Oshiro Zardo, gabrieloshiro@gmail.com                    ////
16
//// - Samuel Nascimento Pagliarini (creep), snpagliarini@gmail.com     ////
17
////                                                                    ////
18 141 creep
////////////////////////////////////////////////////////////////////////////
19 152 gabrielosh
////                                                                    ////
20
//// Copyright (C) 2001 Authors and OPENCORES.ORG                       ////
21
////                                                                    ////
22
//// This source file may be used and distributed without               ////
23
//// restriction provided that this copyright statement is not          ////
24
//// removed from the file and that any derivative work contains        ////
25
//// the original copyright notice and the associated disclaimer.       ////
26
////                                                                    ////
27
//// This source file is free software; you can redistribute it         ////
28
//// and/or modify it under the terms of the GNU Lesser General         ////
29
//// Public License as published by the Free Software Foundation;       ////
30
//// either version 2.1 of the License, or (at your option) any         ////
31
//// later version.                                                     ////
32
////                                                                    ////
33
//// This source is distributed in the hope that it will be             ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied         ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ////
36
//// PURPOSE. See the GNU Lesser General Public License for more        ////
37
//// details.                                                           ////
38
////                                                                    ////
39
//// You should have received a copy of the GNU Lesser General          ////
40
//// Public License along with this source; if not, download it         ////
41
//// from http://www.opencores.org/lgpl.shtml                           ////
42
////                                                                    ////
43 141 creep
////////////////////////////////////////////////////////////////////////////
44
 
45
`include "timescale.v"
46
 
47
// TODO: verify code identation
48
 
49
module t6507lp_alu( clk, reset_n, alu_enable, alu_result, alu_status, alu_opcode, alu_a, alu_x, alu_y );
50
 
51
input wire       clk;
52
input wire       reset_n;
53
input wire       alu_enable;
54
input wire [7:0] alu_opcode;
55
input wire [7:0] alu_a;
56
output reg [7:0] alu_result;
57
output reg [7:0] alu_status;
58
output reg [7:0] alu_x;
59
output reg [7:0] alu_y;
60
 
61 183 gabrielosh
reg [7:0] A;
62 181 gabrielosh
//reg [7:0] X;
63
//reg [7:0] Y;
64 141 creep
 
65
reg [7:0] STATUS;
66
reg [7:0] result;
67 152 gabrielosh
reg [7:0] op1;
68
reg [7:0] op2;
69 161 gabrielosh
reg [7:0] bcdl;
70
reg [7:0] bcdh;
71 164 gabrielosh
reg [7:0] bcdh2;
72
reg [7:0] AL;
73
reg [7:0] AH;
74 186 gabrielosh
reg C_aux;
75 173 gabrielosh
reg sign;
76 141 creep
 
77
`include "t6507lp_package.v"
78
 
79
always @ (posedge clk or negedge reset_n)
80
begin
81
        if (reset_n == 0) begin
82
                alu_result <= 0;
83
                alu_status[C] <= 0;
84
                alu_status[N] <= 0;
85
                alu_status[V] <= 0;
86 148 gabrielosh
                alu_status[5] <= 1;
87 141 creep
                alu_status[Z] <= 1;
88
                alu_status[I] <= 0;
89
                alu_status[B] <= 0;
90
                alu_status[D] <= 0;
91 183 gabrielosh
                A <= 0;
92 141 creep
                alu_x <= 0;
93
                alu_y <= 0;
94
        end
95
        else if ( alu_enable == 1 ) begin
96
                case (alu_opcode)
97
                        ADC_IMM, ADC_ZPG, ADC_ZPX, ADC_ABS, ADC_ABX, ADC_ABY, ADC_IDX, ADC_IDY,
98
                        AND_IMM, AND_ZPG, AND_ZPX, AND_ABS, AND_ABX, AND_ABY, AND_IDX, AND_IDY,
99
                        ASL_ACC, EOR_IMM, EOR_ZPG, EOR_ZPX, EOR_ABS, EOR_ABX, EOR_ABY, EOR_IDX,
100
                        EOR_IDY, LSR_ACC, ORA_IMM, ORA_ZPG, ORA_ZPX, ORA_ABS, ORA_ABX, ORA_ABY,
101
                        ORA_IDX, ORA_IDY, ROL_ACC, ROR_ACC, SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS,
102
                        SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY, LDA_IMM, LDA_ZPG, LDA_ZPX, LDA_ABS,
103 184 gabrielosh
                        LDA_ABX, LDA_ABY, LDA_IDX, LDA_IDY, PLA_IMP :
104 141 creep
                        begin
105 183 gabrielosh
                                A          <= result;
106 141 creep
                                alu_result <= result;
107
                                alu_status <= STATUS;
108
                        end
109
                        LDX_IMM, LDX_ZPG, LDX_ZPY, LDX_ABS, LDX_ABY, TAX_IMP, TSX_IMP, INX_IMP, DEX_IMP :
110
                        begin
111
                                alu_x      <= result;
112
                                alu_status <= STATUS;
113
                        end
114
                        TXS_IMP :
115
                        begin
116 148 gabrielosh
                                alu_x      <= result;
117 141 creep
                        end
118 184 gabrielosh
                        TXA_IMP, TYA_IMP :
119
                        begin
120
                                A          <= result;
121
                                alu_status <= STATUS;
122
                        end
123 141 creep
                        LDY_IMM, LDY_ZPG, LDY_ZPX, LDY_ABS, LDY_ABX, TAY_IMP, INY_IMP, DEY_IMP :
124
                        begin
125
                                alu_y      <= result;
126
                                alu_status <= STATUS;
127
                        end
128 148 gabrielosh
                        CMP_IMM, CMP_ZPG, CMP_ZPX, CMP_ABS, CMP_ABX, CMP_ABY, CMP_IDX, CMP_IDY,
129 165 gabrielosh
                        CPX_IMM, CPX_ZPG, CPX_ABS, CPY_IMM, CPY_ZPG, CPY_ABS :
130 141 creep
                        begin
131
                                alu_status <= STATUS;
132
                        end
133 178 gabrielosh
                        PHA_IMP, STA_ZPG, STA_ZPX, STA_ABS, STA_ABX, STA_ABY, STA_IDX, STA_IDY : begin
134 158 gabrielosh
                                alu_result <= result;
135
                        end
136 178 gabrielosh
                        STX_ZPG, STX_ZPY, STX_ABS : begin
137
                                alu_x <= result;
138
                        end
139
                        STY_ZPG, STY_ZPX, STY_ABS : begin
140
                                alu_y <= result;
141
                        end
142 141 creep
                        SEC_IMP :
143
                        begin
144
                                alu_status[C] <= 1;
145
                        end
146
                        SED_IMP :
147
                        begin
148
                                alu_status[D] <= 1;
149
                        end
150
                        SEI_IMP :
151
                        begin
152
                                alu_status[I] <= 1;
153
                        end
154
                        CLC_IMP :
155
                        begin
156
                                alu_status[C] <= 0;
157
                        end
158
                        CLD_IMP :
159
                        begin
160
                                alu_status[D] <= 0;
161
                        end
162
                        CLI_IMP :
163
                        begin
164
                                alu_status[I] <= 0;
165
                        end
166
                        CLV_IMP :
167
                        begin
168
                                alu_status[V] <= 0;
169
                        end
170
                        BRK_IMP :
171
                        begin
172 154 gabrielosh
                                alu_status[B] <= 1;
173 141 creep
                        end
174 171 creep
                        PLP_IMP, RTI_IMP :
175 141 creep
                        begin
176 175 gabrielosh
                                alu_status[C] <= alu_a[C];
177
                                alu_status[Z] <= alu_a[Z];
178
                                alu_status[I] <= alu_a[I];
179
                                alu_status[D] <= alu_a[D];
180
                                alu_status[B] <= alu_a[B];
181
                                alu_status[V] <= alu_a[V];
182
                                alu_status[N] <= alu_a[N];
183 173 gabrielosh
                                alu_status[5] <= 1;
184 141 creep
                        end
185
                        BIT_ZPG, BIT_ABS :
186
                        begin
187
                                alu_status[Z] <= STATUS[Z];
188
                                alu_status[V] <= alu_a[6];
189
                                alu_status[N] <= alu_a[7];
190
                        end
191 148 gabrielosh
                        INC_ZPG, INC_ZPX, INC_ABS, INC_ABX, DEC_ZPG, DEC_ZPX, DEC_ABS, DEC_ABX,
192
                        ASL_ZPG, ASL_ZPX, ASL_ABS, ASL_ABX, LSR_ZPG, LSR_ZPX, LSR_ABS, LSR_ABX,
193
                        ROL_ZPG, ROL_ZPX, ROL_ABS, ROL_ABX, ROR_ZPG, ROR_ZPX, ROR_ABS, ROR_ABX :
194 141 creep
                        begin
195
                                alu_result <= result;
196
                                alu_status <= STATUS;
197
                        end
198
                        default : begin
199
                        end
200
                endcase
201
        end
202
end
203
 
204
always @ (*) begin
205 175 gabrielosh
if (alu_enable == 1) begin
206 183 gabrielosh
        op1      = A;
207 152 gabrielosh
        op2      = alu_a;
208 150 gabrielosh
        result    = alu_result;
209
        STATUS[N] = alu_status[N];
210
        STATUS[C] = alu_status[C];
211
        STATUS[V] = alu_status[V];
212
        STATUS[B] = alu_status[B];
213
        STATUS[I] = alu_status[I];
214
        STATUS[D] = alu_status[D];
215
        STATUS[Z] = alu_status[Z];
216 151 gabrielosh
        STATUS[5] = 1;
217 141 creep
 
218 171 creep
        bcdl = 0;
219
        bcdh = 0;
220
        bcdh2 = 0;
221
        AL = 0;
222
        AH = 0;
223 173 gabrielosh
        sign = op2[7];
224 171 creep
 
225 141 creep
        case (alu_opcode)
226
                // BIT - Bit Test
227
                BIT_ZPG, BIT_ABS: begin
228 183 gabrielosh
                        result = A & alu_a;
229 141 creep
                end
230
 
231
                // BRK - Force Interrupt
232 181 gabrielosh
                //BRK_IMP: begin
233
                //      STATUS[B] = 1'b1;
234
                //end
235 141 creep
 
236
                // CLC - Clear Carry Flag
237 181 gabrielosh
                //CLC_IMP: begin
238
                //      STATUS[C] = 1'b0;
239
                //end
240 141 creep
 
241
                // CLD - Clear Decimal Flag
242 181 gabrielosh
                //CLD_IMP: begin
243
                //      STATUS[D] = 1'b0;
244
                //end
245 141 creep
 
246
                // CLI - Clear Interrupt Disable
247 181 gabrielosh
                //CLI_IMP: begin
248
                //      STATUS[I] = 1'b0;
249
                //end
250 141 creep
 
251
                // CLV - Clear Overflow Flag
252 181 gabrielosh
                //CLV_IMP: begin
253
                //      STATUS[V] = 1'b0;
254
                //end
255 141 creep
 
256
                // NOP - No Operation
257
                //NOP_IMP: begin
258
                        // Do nothing :-D
259
                //end
260
 
261
                // PLP - Pull Processor Status Register
262 175 gabrielosh
                // RTI - Return from Interrupt
263 176 gabrielosh
                //PLP_IMP, RTI_IMP: begin
264
                //      STATUS = alu_a;
265
                //end
266 157 gabrielosh
 
267
                PLA_IMP : begin
268
                        result = alu_a;
269
                end
270 141 creep
 
271
                // STA - Store Accumulator
272
                // PHA - Push A
273
                // TAX - Transfer Accumulator to X
274
                // TAY - Transfer Accumulator to Y
275
                TAX_IMP, TAY_IMP, PHA_IMP, STA_ZPG, STA_ZPX, STA_ABS, STA_ABX, STA_ABY, STA_IDX, STA_IDY : begin
276 183 gabrielosh
                        result = A;
277 141 creep
                end
278
 
279
                // STX - Store X Register
280
                // TXA - Transfer X to Accumulator
281
                // TXS - Transfer X to Stack pointer
282
                STX_ZPG, STX_ZPY, STX_ABS, TXA_IMP, TXS_IMP : begin
283 181 gabrielosh
                        result = alu_x;
284 141 creep
                end
285
 
286
                // STY - Store Y Register
287
                // TYA - Transfer Y to Accumulator
288
                STY_ZPG, STY_ZPX, STY_ABS, TYA_IMP : begin
289 181 gabrielosh
                        result = alu_y;
290 141 creep
                end
291
 
292
                // SEC - Set Carry Flag
293 181 gabrielosh
                //SEC_IMP: begin
294
                //      STATUS[C] = 1'b1;
295
                //end
296 141 creep
 
297
                // SED - Set Decimal Flag
298 181 gabrielosh
                //SED_IMP: begin
299
                //      STATUS[D] = 1'b1;
300
                //end
301 141 creep
 
302
                // SEI - Set Interrupt Disable
303 181 gabrielosh
                //SEI_IMP: begin
304
                //      STATUS[I] = 1'b1;
305
                //end
306 141 creep
 
307
                // INC - Increment memory
308
                INC_ZPG, INC_ZPX, INC_ABS, INC_ABX : begin
309
                        result = alu_a + 1;
310
                end
311
 
312
                // INX - Increment X Register
313
                INX_IMP: begin
314 181 gabrielosh
                        result = alu_x + 1;
315 141 creep
                end
316
 
317
                // INY - Increment Y Register
318
                INY_IMP : begin
319 181 gabrielosh
                        result = alu_y + 1;
320 141 creep
                end
321
 
322
                // DEC - Decrement memory
323
                DEC_ZPG, DEC_ZPX, DEC_ABS, DEC_ABX : begin
324
                        result = alu_a - 1;
325
                end
326
 
327
                // DEX - Decrement X register
328
                DEX_IMP: begin
329 181 gabrielosh
                        result = alu_x - 1;
330 141 creep
                end
331
 
332
                // DEY - Decrement Y Register
333
                DEY_IMP: begin
334 181 gabrielosh
                        result = alu_y - 1;
335 141 creep
                end
336
 
337
                // ADC - Add with carry
338 162 gabrielosh
                // TODO: verify synthesis for % operand
339 141 creep
                ADC_IMM, ADC_ZPG, ADC_ZPX, ADC_ABS, ADC_ABX, ADC_ABY, ADC_IDX, ADC_IDY : begin
340
                        if (alu_status[D] == 1) begin
341 171 creep
                                //$display("MODO DECIMAL");
342 181 gabrielosh
                                //AL = A[3:0] + alu_a[3:0] + alu_status[C];
343
                                AL = op1[3:0] + op2[3:0] + alu_status[C];
344 186 gabrielosh
                                //$display("op1[3:0] + op2[3:0] + alu_status[C]",op1[3:0], op2[3:0], alu_status[C]);
345 181 gabrielosh
                                //AH = A[7:4] + alu_a[7:4];
346 186 gabrielosh
                                AH = op1[7:4] + op2[7:4] + AL[4];
347
                                //$display("op1[7:4] + op2[7:4] + AL[4]",op1[7:4], op2[7:4], AL[4]);
348
                                if (AL > 9) bcdl = AL + 6;
349
                                else bcdl = AL;
350
                                STATUS[Z] =
351
                                if (bcdh > 9)
352
                                        bcdh2 = bcdh + 6;
353
                                else bcdh2 = bcdh;
354 171 creep
                                //$display("bcdh2 = %d", bcdh2);
355
                                //$display("bcdl = %d", bcdl);
356 186 gabrielosh
                                STATUS[C] = AH[4];
357 164 gabrielosh
                                result = {bcdh2[3:0],bcdl[3:0]};
358 141 creep
                        end
359 165 gabrielosh
                        else begin
360 171 creep
                                //$display("MODO NORMAL");
361 161 gabrielosh
                                {STATUS[C],result} = op1 + op2 + alu_status[C];
362 165 gabrielosh
                        end
363 162 gabrielosh
 
364 152 gabrielosh
                        if ((op1[7] == op2[7]) && (op1[7] != result[7]))
365 141 creep
                                STATUS[V] = 1;
366
                        else
367
                                STATUS[V] = 0;
368
                end
369
 
370
                // AND - Logical AND
371
                AND_IMM, AND_ZPG, AND_ZPX, AND_ABS, AND_ABX, AND_ABY, AND_IDX, AND_IDY : begin
372 183 gabrielosh
                        result = A & alu_a;
373 141 creep
                end
374
 
375
                // CMP - Compare
376
                CMP_IMM, CMP_ZPG, CMP_ZPX, CMP_ABS, CMP_ABX, CMP_ABY, CMP_IDX, CMP_IDY : begin
377 183 gabrielosh
                        result = A - alu_a;
378
                        STATUS[C] = (A >= alu_a) ? 1 : 0;
379 141 creep
                end
380
 
381
                // EOR - Exclusive OR
382
                EOR_IMM, EOR_ZPG, EOR_ZPX, EOR_ABS, EOR_ABX, EOR_ABY, EOR_IDX, EOR_IDY : begin
383 183 gabrielosh
                        result = A ^ alu_a;
384 141 creep
                end
385
 
386
                // LDA - Load Accumulator
387
                // LDX - Load X Register
388
                // LDY - Load Y Register
389
                // TSX - Transfer Stack Pointer to X
390
                LDA_IMM, LDA_ZPG, LDA_ZPX, LDA_ABS, LDA_ABX, LDA_ABY, LDA_IDX, LDA_IDY,
391
                LDX_IMM, LDX_ZPG, LDX_ZPY, LDX_ABS, LDX_ABY,
392
                LDY_IMM, LDY_ZPG, LDY_ZPX, LDY_ABS, LDY_ABX,
393
                TSX_IMP : begin
394
                        result = alu_a;
395
                end
396
 
397
                // ORA - Logical OR
398
                ORA_IMM, ORA_ZPG, ORA_ZPX, ORA_ABS, ORA_ABX, ORA_ABY, ORA_IDX, ORA_IDY : begin
399 181 gabrielosh
                        //result = A | alu_a;
400 183 gabrielosh
                        result = A | alu_a;
401 141 creep
                end
402
 
403
                // SBC - Subtract with Carry
404
                SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS, SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY : begin
405 174 gabrielosh
                        if (alu_status[D] == 1) begin
406 183 gabrielosh
/*                              //AL = A[3:0] + alu_a[3:0] + alu_status[C];
407 181 gabrielosh
                                AL = op1[3:0] + op2[3:0] + alu_status[C];
408
                                //AH = A[7:4] + alu_a[7:4];
409
                                AH = op1[7:4] + op2[7:4];
410 179 gabrielosh
                                if (AL > 9) begin
411
                                        bcdh = AH + (AL / 10);
412
                                        bcdl = AL % 10;
413
                                end
414
                                else begin
415
                                        bcdh = AH;
416
                                        bcdl = AL;
417
                                end
418
                                if (bcdh > 9) begin
419
                                        STATUS[C] = 1;
420
                                        bcdh2 = bcdh % 10;
421
                                end
422
                                else begin
423
                                        STATUS[C] = 0;
424
                                        bcdh2 = bcdh;
425
                                end
426 183 gabrielosh
                                result = {bcdh2[3:0],bcdl[3:0]};*/
427
        //C := P_In(Flag_C) or not Op(0);
428
                                AL = {op1[3:0],alu_status[C]} - {op2[3:0],1'b1};
429
                                AH = {op1[7:4],1'b0} - {op2[7:4],AL[5]};
430
 
431
                                if (AL[5] == 1) begin
432
                                        bcdl[5:1] = AL[5:1] - 6;
433
                                end
434
                                AH = {op1[7:4],1'b0} - {op2[7:4],bcdl[6]};
435
                                if (AH[5] == 1) begin
436
                                        bcdh[5:1] = AH[5:1] - 6;
437
                                end
438
                                result = {bcdh[4:1],bcdl[4:1]};
439
                                STATUS[C] = ~result[7];
440 179 gabrielosh
                        end
441
                        else begin
442 183 gabrielosh
                                op2 = ~op2;
443 179 gabrielosh
                                //$display("MODO NORMAL");
444 181 gabrielosh
                                result = op1 + op2 + alu_status[C];
445
                                STATUS[C] = ~result[7];
446 179 gabrielosh
                        end
447
/*                      if (alu_status[D] == 1) begin
448 178 gabrielosh
                                bcdl = op1[3:0] - op2[3:0] - (1 - alu_status[C]);
449
                                bcdh = op1[7:4] - op2[7:4];
450 162 gabrielosh
                                if (bcdl > 9) begin
451
                                        bcdh = bcdh + bcdl[5:4];
452
                                        bcdl = bcdl % 10;
453
                                end
454
                                if (bcdh > 9) begin
455
                                        STATUS[C] = 1;
456
                                        bcdh = bcdh % 10;
457
                                end
458 163 gabrielosh
                                result = {bcdh[3:0],bcdl[3:0]};
459 162 gabrielosh
                        end
460 173 gabrielosh
                        else begin
461 178 gabrielosh
                                op2 = ~alu_a;
462
                                result = op1 + op2 + alu_status[C];
463 174 gabrielosh
                                STATUS[C] = ~result[7];
464 173 gabrielosh
                        end
465 179 gabrielosh
*/
466 162 gabrielosh
 
467 173 gabrielosh
                        if ((op1[7] == sign) && (op1[7] != result[7]))
468 162 gabrielosh
                                STATUS[V] = 1;
469
                        else
470
                                STATUS[V] = 0;
471
 
472 141 creep
                end
473
 
474
                // ASL - Arithmetic Shift Left
475
                ASL_ACC : begin
476 145 gabrielosh
                        //{STATUS[C],result} = A << 1;
477 181 gabrielosh
                        //{STATUS[C],result} = {A,1'b0};
478 183 gabrielosh
                        {STATUS[C],result} = {A,1'b0};
479 141 creep
                end
480
                ASL_ZPG, ASL_ZPX, ASL_ABS, ASL_ABX : begin
481 145 gabrielosh
                        //{STATUS[C],result} = alu_a << 1;
482
                        {STATUS[C],result} = {alu_a,1'b0};
483 141 creep
                end
484
 
485
                // LSR - Logical Shift Right
486
                LSR_ACC: begin
487 145 gabrielosh
                        //{result, STATUS[C]} = A >> 1;
488 181 gabrielosh
                        //{result,STATUS[C]} = {1'b0,A};
489 183 gabrielosh
                        {result,STATUS[C]} = {1'b0,A};
490 141 creep
                end
491
                LSR_ZPG, LSR_ZPX, LSR_ABS, LSR_ABX : begin
492 145 gabrielosh
                        //{result, STATUS[C]} = alu_a >> 1;
493
                        {result,STATUS[C]} = {1'b0,alu_a};
494 141 creep
                end
495
 
496
                // ROL - Rotate Left
497
                ROL_ACC : begin
498 181 gabrielosh
                        //{STATUS[C],result} = {A,alu_status[C]};
499 183 gabrielosh
                        {STATUS[C],result} = {A,alu_status[C]};
500 141 creep
                end
501
                ROL_ZPG, ROL_ZPX, ROL_ABS, ROL_ABX : begin
502
                        {STATUS[C],result} = {alu_a,alu_status[C]};
503
                end
504
 
505 152 gabrielosh
                // ROR - Rotate Right
506 141 creep
                ROR_ACC : begin
507 181 gabrielosh
                        //{result,STATUS[C]} = {alu_status[C],A};
508 183 gabrielosh
                        {result,STATUS[C]} = {alu_status[C],A};
509 141 creep
                end
510
                ROR_ZPG, ROR_ZPX, ROR_ABS, ROR_ABX : begin
511
                        {result, STATUS[C]} = {alu_status[C], alu_a};
512
                end
513
 
514
                // CPX - Compare X Register
515
                CPX_IMM, CPX_ZPG, CPX_ABS : begin
516 181 gabrielosh
                        //result = X - alu_a;
517
                        result = alu_x - alu_a;
518
                        //STATUS[C] = (X >= alu_a) ? 1 : 0;
519
                        STATUS[C] = (alu_x >= alu_a) ? 1 : 0;
520 141 creep
                end
521
 
522
                // CPY - Compare Y Register
523
                CPY_IMM, CPY_ZPG, CPY_ABS : begin
524 181 gabrielosh
                        //result = Y - alu_a;
525
                        result = alu_y - alu_a;
526
                        //STATUS[C] = (Y >= alu_a) ? 1 : 0;
527
                        STATUS[C] = (alu_y >= alu_a) ? 1 : 0;
528 141 creep
                end
529
 
530
                default: begin // NON-DEFAULT OPCODES FALL HERE
531 142 gabrielosh
                end
532 141 creep
        endcase
533 142 gabrielosh
        STATUS[Z] = (result == 0) ? 1 : 0;
534
        STATUS[N] = result[7];
535 141 creep
end
536 175 gabrielosh
end
537 141 creep
endmodule
538
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.