Line 66... |
Line 66... |
// Reset
|
// Reset
|
clk = 0;
|
clk = 0;
|
reset_n = 0;
|
reset_n = 0;
|
@(negedge clk);
|
@(negedge clk);
|
@(negedge clk);
|
@(negedge clk);
|
//reset_n = 1;
|
reset_n = 1;
|
alu_enable = 1;
|
alu_enable = 1;
|
alu_result_expected = 8'h00;
|
alu_result_expected = 8'h00;
|
alu_status_expected = 8'b00100010;
|
alu_status_expected = 8'b00100010;
|
alu_x_expected = 8'h00;
|
alu_x_expected = 8'h00;
|
alu_y_expected = 8'h00;
|
alu_y_expected = 8'h00;
|
Line 90... |
Line 90... |
alu_opcode = ADC_IMM;
|
alu_opcode = ADC_IMM;
|
alu_a = 1;
|
alu_a = 1;
|
for (i = 0; i < 1000; i = i + 1)
|
for (i = 0; i < 1000; i = i + 1)
|
begin
|
begin
|
@(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], DUT.result);
|
{alu_status_expected[C], alu_result_expected} = alu_a + alu_result_expected + alu_status_expected[C];
|
{alu_status_expected[C], alu_result_expected} = alu_a + alu_result_expected + alu_status_expected[C];
|
alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
|
alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
|
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
|
// ASL
|
alu_opcode = ASL_ABS;
|
alu_opcode = ASL_ABS;
|
for (i = 0; i < 1000; i = i + 1)
|
for (i = 0; i < 1000; i = i + 1)
|
begin
|
begin
|
alu_a = i;
|
alu_a = i;
|
@(negedge clk);
|
@(negedge clk);
|