Line 99... |
Line 99... |
EOR_IDY, LSR_ACC, ORA_IMM, ORA_ZPG, ORA_ZPX, ORA_ABS, ORA_ABX, ORA_ABY,
|
EOR_IDY, LSR_ACC, ORA_IMM, ORA_ZPG, ORA_ZPX, ORA_ABS, ORA_ABX, ORA_ABY,
|
ORA_IDX, ORA_IDY, ROL_ACC, ROR_ACC, SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS,
|
ORA_IDX, ORA_IDY, ROL_ACC, ROR_ACC, SBC_IMM, SBC_ZPG, SBC_ZPX, SBC_ABS,
|
SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY, LDA_IMM, LDA_ZPG, LDA_ZPX, LDA_ABS,
|
SBC_ABX, SBC_ABY, SBC_IDX, SBC_IDY, LDA_IMM, LDA_ZPG, LDA_ZPX, LDA_ABS,
|
LDA_ABX, LDA_ABY, LDA_IDX, LDA_IDY, PLA_IMP, TXA_IMP, TYA_IMP :
|
LDA_ABX, LDA_ABY, LDA_IDX, LDA_IDY, PLA_IMP, TXA_IMP, TYA_IMP :
|
begin
|
begin
|
$display("A = %h result = %h", A, result);
|
//$display("A = %h result = %h", A, result);
|
//$display("V = %b C = %b D = %b", STATUS[V], STATUS[C], STATUS[D]);
|
//$display("V = %b C = %b D = %b", STATUS[V], STATUS[C], STATUS[D]);
|
A <= result;
|
A <= result;
|
alu_result <= result;
|
alu_result <= result;
|
alu_status <= STATUS;
|
alu_status <= STATUS;
|
end
|
end
|
Line 186... |
Line 186... |
end
|
end
|
|
|
always @ (*) begin
|
always @ (*) begin
|
bcd1 = A;
|
bcd1 = A;
|
bcd2 = alu_a;
|
bcd2 = alu_a;
|
result = alu_result;
|
//result = alu_result;
|
STATUS[C] = alu_status[C];
|
//STATUS[C] = STATUS[C];
|
STATUS[V] = alu_status[V];
|
//STATUS[V] = STATUS[V];
|
STATUS[B] = alu_status[B];
|
//STATUS[B] = STATUS[B];
|
STATUS[I] = alu_status[I];
|
//STATUS[I] = STATUS[I];
|
STATUS[D] = alu_status[D];
|
//STATUS[D] = STATUS[D];
|
|
|
case (alu_opcode)
|
case (alu_opcode)
|
// BIT - Bit Test
|
// BIT - Bit Test
|
BIT_ZPG, BIT_ABS: begin
|
BIT_ZPG, BIT_ABS: begin
|
result = A & alu_a;
|
result = A & alu_a;
|
Line 317... |
Line 317... |
end
|
end
|
if (bcd2[7:4] > 9) begin
|
if (bcd2[7:4] > 9) begin
|
bcd2 = bcd2[7:4] + 6; // A = A - 10 and A = A + 16
|
bcd2 = bcd2[7:4] + 6; // A = A - 10 and A = A + 16
|
end
|
end
|
end
|
end
|
$display("op1 = %h op2 = %h result = %h", bcd1, bcd2, result);
|
//$display("op1 = %h op2 = %h result = %h", bcd1, bcd2, result);
|
$display("V = %b C = %b D = %b", STATUS[V], STATUS[C], STATUS[D]);
|
//$display("V = %b C = %b D = %b", STATUS[V], STATUS[C], STATUS[D]);
|
{STATUS[C],result} = bcd1 + bcd2 + alu_status[C];
|
{STATUS[C],result} = bcd1 + bcd2 + alu_status[C];
|
if ((bcd1[7] == bcd2[7]) && (bcd1[7] != alu_result[7]))
|
if ((bcd1[7] == bcd2[7]) && (bcd1[7] != alu_result[7]))
|
STATUS[V] = 1;
|
STATUS[V] = 1;
|
else
|
else
|
STATUS[V] = 0;
|
STATUS[V] = 0;
|