Ref(01_Adder):Доб-ие инфы в тб для 32 битного сумматора

This commit is contained in:
alexkharl
2024-02-08 13:46:36 +03:00
parent 34670f21f8
commit 96380b56dc

View File

@@ -42,7 +42,7 @@ module tb_fulladder32();
assign carry_o_dump = running_line[32]; assign carry_o_dump = running_line[32];
initial begin initial begin
$timeformat(-9, 2, " ns"); $timeformat(-9, 2, " ns", 0);
#1; // wait initial line_dump #1; // wait initial line_dump
@@ -50,11 +50,26 @@ module tb_fulladder32();
$display("You should run simmulation until the message 'FINISH simulation' appears in the log."); $display("You should run simmulation until the message 'FINISH simulation' appears in the log.");
$display("If you don't see the message then click the button 'Run All'"); $display("If you don't see the message then click the button 'Run All'");
for ( i = 0; i < TEST_VALUES; i = i + 1 ) begin for ( i = 0; i < TEST_VALUES; i = i + 1 ) begin
bit fail;
fail = 1'b0;
running_line = line_dump[i*98+:98]; running_line = line_dump[i*98+:98];
#TIME_OPERATION; #TIME_OPERATION;
if( (tb_carry_o !== carry_o_dump) || (tb_sum_o !== sum_dump) ) begin if (tb_carry_o !== carry_o_dump) begin
$display("ERROR! carry_i = %b; (a)%h + (b)%h = ", tb_carry_i, tb_a_i, tb_b_i, "(carry_o)%b (sum_o)%h;", tb_carry_o, tb_sum_o, " carry_o_dump: %b, sum_dump: %h", carry_o_dump, sum_dump, " time == %t", $realtime); $write("ERROR! time == %t. ", $realtime, "Carry mismatch. Received: carry = %b, but Expected: carry = %b. ",
err_count = err_count + 1'b1; tb_carry_o, carry_o_dump);
fail = 1'b1;
end
if (tb_sum_o !== sum_dump) begin
if (!fail) $write("ERROR! time == %t. ", $realtime);
$write("Sum mismatch. Received: sum = 0x%x, but Expected: sum = 0x%x. ",
tb_sum_o, sum_dump);
fail = 1'b1;
end
if (fail) begin
$display("It should be: 0x%x + 0x%x + %d = {sum: 0x%x, carry: %d}. ",
tb_a_i, tb_b_i, tb_carry_i, sum_dump, carry_o_dump);
++err_count;
end end
end end
$display("Number of errors: %d", err_count); $display("Number of errors: %d", err_count);