Line 100... |
Line 100... |
alu_status_expected[N] = alu_result_expected[7];
|
alu_status_expected[N] = alu_result_expected[7];
|
alu_status_expected[V] = ((alu_a[7] == DUT.A[7]) && (alu_a[7] != alu_result_expected[7]));
|
alu_status_expected[V] = ((alu_a[7] == DUT.A[7]) && (alu_a[7] != alu_result_expected[7]));
|
check();
|
check();
|
end
|
end
|
|
|
|
// ADC
|
|
alu_opcode = ASL_ABS;
|
|
for (i = 0; i < 1000; i = i + 1)
|
|
begin
|
|
alu_a = i;
|
|
@(negedge clk);
|
|
//$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
|
|
//$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
|
|
//$display("op1 = %d op2 = %d c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
|
|
{alu_status_expected[C], alu_result_expected} = {alu_a,1'b0};
|
|
alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
|
|
alu_status_expected[N] = alu_result_expected[7];
|
|
check();
|
|
end
|
|
|
|
// LDA
|
|
alu_a = 0;
|
|
alu_opcode = LDA_IMM;
|
|
//$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
|
|
//$display("op1 = %d op2 = %d c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
|
|
@(negedge clk);
|
|
alu_result_expected = 8'h00;
|
|
// NV1BDIZC
|
|
alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
|
|
alu_status_expected[N] = alu_result_expected[7];
|
|
check();
|
|
|
// SBC
|
// SBC
|
alu_opcode = SBC_IMM;
|
alu_opcode = SBC_IMM;
|
for (i = 0; i < 1000; i = i + 1)
|
for (i = 0; i < 1000; i = i + 1)
|
begin
|
begin
|
|
alu_a = 1;
|
@(negedge clk);
|
@(negedge clk);
|
//$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
|
//$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
|
//$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
|
//$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
|
//$display("op1 = %d op2 = %d c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
|
//$display("op1 = %d op2 = %d c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
|
{alu_status_expected[C], alu_result_expected} = alu_result_expected - alu_a - ~alu_status_expected[C];
|
{alu_status_expected[C], alu_result_expected} = alu_result_expected - alu_a - ~alu_status_expected[C];
|