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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_alu.v] - Diff between revs 178 and 179

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 178 Rev 179
Line 416... Line 416...
                end
                end
 
 
                // SBC - Subtract with Carry
                // SBC - Subtract with Carry
                SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS, SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY : begin
                SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS, SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY : begin
                        if (alu_status[D] == 1) begin
                        if (alu_status[D] == 1) begin
                                bcdl = op1[3:0] - op2[3:0] - (1 - alu_status[C]);
                                op2 = ~op2;
                                bcdh = op1[7:4] - op2[7:4];
                                AL = A[3:0] + alu_a[3:0] + alu_status[C];
                                if (bcdl > 9) begin
                                AH = A[7:4] + alu_a[7:4];
                                        bcdh = bcdh + bcdl[5:4];
                                if (AL > 9) begin
                                        bcdl = bcdl % 10;
                                        bcdh = AH + (AL / 10);
 
                                        bcdl = AL % 10;
 
                                end
 
                                else begin
 
                                        bcdh = AH;
 
                                        bcdl = AL;
                                end
                                end
                                if (bcdh > 9) begin
                                if (bcdh > 9) begin
                                        STATUS[C] = 1;
                                        STATUS[C] = 1;
                                        bcdh = bcdh % 10;
                                        bcdh2 = bcdh % 10;
                                end
                                end
                                result = {bcdh[3:0],bcdl[3:0]};
                                else begin
 
                                        STATUS[C] = 0;
 
                                        bcdh2 = bcdh;
 
                                end
 
                                result = {bcdh2[3:0],bcdl[3:0]};
                        end
                        end
                        else begin
                        else begin
                                op2 = ~alu_a;
                                //$display("MODO NORMAL");
                                result = op1 + op2 + alu_status[C];
                                {STATUS[C],result} = op1 + op2 + alu_status[C];
                                STATUS[C] = ~result[7];
 
                        end
                        end
 
/*                      if (alu_status[D] == 1) begin
 
                                bcdl = op1[3:0] - op2[3:0] - (1 - alu_status[C]);
 
                                bcdh = op1[7:4] - op2[7:4];
 
                                if (bcdl > 9) begin
 
                                        bcdh = bcdh + bcdl[5:4];
 
                                        bcdl = bcdl % 10;
 
                                end
 
                                if (bcdh > 9) begin
 
                                        STATUS[C] = 1;
 
                                        bcdh = bcdh % 10;
 
                                end
 
                                result = {bcdh[3:0],bcdl[3:0]};
 
                        end
 
                        else begin
 
                                op2 = ~alu_a;
 
                                result = op1 + op2 + alu_status[C];
 
                                STATUS[C] = ~result[7];
 
                        end
 
*/
 
 
                        if ((op1[7] == sign) && (op1[7] != result[7]))
                        if ((op1[7] == sign) && (op1[7] != result[7]))
                                STATUS[V] = 1;
                                STATUS[V] = 1;
                        else
                        else
                                STATUS[V] = 0;
                                STATUS[V] = 0;

powered by: WebSVN 2.1.0

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