tests: update accum TB
This commit is contained in:
@ -20,6 +20,7 @@ module tb_accumulator_top;
|
||||
logic start;
|
||||
logic [31:0] smp_num;
|
||||
logic [15:0] seq_num;
|
||||
logic [31:0] window_size;
|
||||
|
||||
logic req_ready;
|
||||
wire send_req;
|
||||
@ -60,6 +61,7 @@ module tb_accumulator_top;
|
||||
.start(start),
|
||||
.smp_num(smp_num),
|
||||
.seq_num(seq_num),
|
||||
.window_size(window_size),
|
||||
.eth_clk_in(eth_clk_in),
|
||||
.req_ready(req_ready),
|
||||
.send_req(send_req),
|
||||
@ -104,6 +106,7 @@ module tb_accumulator_top;
|
||||
s_axis_tvalid = 1'b0;
|
||||
smp_num = '0;
|
||||
seq_num = '0;
|
||||
window_size = 32'd1;
|
||||
req_ready = 1'b0;
|
||||
m_axis_tready = 1'b1;
|
||||
clear_scoreboard();
|
||||
@ -141,13 +144,14 @@ module tb_accumulator_top;
|
||||
|
||||
task automatic run_test(
|
||||
input integer test_id,
|
||||
input integer window_size_i,
|
||||
input integer seq_num_i,
|
||||
input integer smp_num_i,
|
||||
input bit randomize_data,
|
||||
input integer base_value,
|
||||
input string test_name
|
||||
);
|
||||
logic [DATA_WIDTH-1:0] sample_mem [0:MAX_SEQ_NUM-1][0:(N_MAX*WINDOW_SIZE)-1];
|
||||
logic [DATA_WIDTH-1:0] sample_mem [0:MAX_SEQ_NUM-1][0:(N_MAX*MAX_WINDOW_SIZE)-1];
|
||||
integer seq_idx;
|
||||
integer sample_idx;
|
||||
integer word_idx;
|
||||
@ -165,22 +169,25 @@ module tb_accumulator_top;
|
||||
tests_total = tests_total + 1;
|
||||
errors_before = total_errors;
|
||||
|
||||
if (smp_num_i <= 0 || smp_num_i > N_MAX * WINDOW_SIZE || (smp_num_i % WINDOW_SIZE) != 0)
|
||||
$fatal(1, "[%0s] invalid smp_num=%0d", test_name, smp_num_i);
|
||||
if (window_size_i <= 0 || window_size_i > MAX_WINDOW_SIZE)
|
||||
$fatal(1, "[%0s] invalid window_size=%0d", test_name, window_size_i);
|
||||
if (smp_num_i <= 0 || smp_num_i > N_MAX * window_size_i || (smp_num_i % window_size_i) != 0)
|
||||
$fatal(1, "[%0s] invalid smp_num=%0d for window_size=%0d", test_name, smp_num_i, window_size_i);
|
||||
if (seq_num_i <= 0 || seq_num_i > MAX_SEQ_NUM)
|
||||
$fatal(1, "[%0s] invalid seq_num=%0d", test_name, seq_num_i);
|
||||
|
||||
$display("\n========================================");
|
||||
$display("TEST %0d: %0s", test_id, test_name);
|
||||
$display("seq_num=%0d smp_num=%0d randomize=%0d", seq_num_i, smp_num_i, randomize_data);
|
||||
$display("window_size=%0d seq_num=%0d smp_num=%0d randomize=%0d", window_size_i, seq_num_i, smp_num_i, randomize_data);
|
||||
$display("========================================");
|
||||
|
||||
reset_dut();
|
||||
smp_num = smp_num_i;
|
||||
seq_num = seq_num_i;
|
||||
window_size = window_size_i;
|
||||
req_ready = 1'b1; // приемник готов заранее
|
||||
|
||||
exp_word_count = smp_num_i / WINDOW_SIZE;
|
||||
exp_word_count = smp_num_i / window_size_i;
|
||||
exp_packet_count = (exp_word_count + READ_BATCH_SIZE - 1) / READ_BATCH_SIZE;
|
||||
|
||||
for (seq_idx = 0; seq_idx < seq_num_i; seq_idx = seq_idx + 1) begin
|
||||
@ -196,8 +203,8 @@ module tb_accumulator_top;
|
||||
for (word_idx = 0; word_idx < exp_word_count; word_idx = word_idx + 1) begin
|
||||
local_sum = 0;
|
||||
for (seq_idx = 0; seq_idx < seq_num_i; seq_idx = seq_idx + 1) begin
|
||||
for (k = 0; k < WINDOW_SIZE; k = k + 1)
|
||||
local_sum = local_sum + sample_mem[seq_idx][word_idx * WINDOW_SIZE + k];
|
||||
for (k = 0; k < window_size_i; k = k + 1)
|
||||
local_sum = local_sum + sample_mem[seq_idx][word_idx * window_size_i + k];
|
||||
end
|
||||
expected_words[word_idx] = local_sum[ACCUM_WIDTH-1:0];
|
||||
$display(" expected[%0d] = %0d (0x%08x)", word_idx, expected_words[word_idx], expected_words[word_idx]);
|
||||
|
||||
Reference in New Issue
Block a user