From d82670827c5db815012791311497b604805e64a3 Mon Sep 17 00:00:00 2001 From: otroubi Date: Wed, 29 Jul 2026 14:04:06 +0300 Subject: [PATCH] unification of the testbench --- rtl/accum/tests/accum_full_tb.sv | 82 ++++++++++++------- rtl/accum/tests/tb_accumulator_top_behav.wcfg | 28 ++++--- 2 files changed, 70 insertions(+), 40 deletions(-) diff --git a/rtl/accum/tests/accum_full_tb.sv b/rtl/accum/tests/accum_full_tb.sv index b20f74b..4080443 100644 --- a/rtl/accum/tests/accum_full_tb.sv +++ b/rtl/accum/tests/accum_full_tb.sv @@ -7,7 +7,7 @@ module tb_accumulator_top; localparam RW_WIDTH = 32; localparam N_MAX = 4096; localparam MAX_WINDOW_SIZE = 65; - localparam PACKET_SIZE = 32; + localparam PACKET_SIZE = 64; localparam READ_BATCH_SIZE = (PACKET_SIZE*8)/ACCUM_WIDTH; localparam MAX_WORDS = N_MAX; localparam MAX_SEQ_NUM = 256; @@ -29,8 +29,7 @@ module tb_accumulator_top; logic [15:0] seq_num; logic [31:0] window_size; - logic req_ready; - wire send_req; + logic accum_done; wire [RW_WIDTH-1:0] m_axis_tdata; wire m_axis_tvalid; @@ -69,14 +68,14 @@ module tb_accumulator_top; .smp_num(smp_num), .seq_num(seq_num), .window_size(window_size), - .eth_clk_in(eth_clk_in), + .dma_clk_in(eth_clk_in), .req_ready(1'b1), - .send_req(send_req), .m_axis_tdata(m_axis_tdata), .m_axis_tvalid(m_axis_tvalid), .m_axis_tready(m_axis_tready), .m_axis_tlast(m_axis_tlast), - .finish(finish) + .finish(finish), + .accum_done(accum_done) ); initial begin @@ -114,7 +113,6 @@ module tb_accumulator_top; smp_num = '0; seq_num = '0; window_size = 32'd1; - req_ready = 1'b0; m_axis_tready = 1'b1; clear_scoreboard(); @@ -192,7 +190,6 @@ module tb_accumulator_top; 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_i; exp_packet_count = (exp_word_count + READ_BATCH_SIZE - 1) / READ_BATCH_SIZE; @@ -274,43 +271,70 @@ module tb_accumulator_top; $display("TEST %0d FAILED: %0s", test_id, test_name); end - req_ready = 1'b0; repeat(10) @(posedge clk_in); end endtask +/////////////////////////////////////////////////////////////// +localparam int PACK_RATIO = ACCUM_WIDTH / RW_WIDTH; + +initial begin + if (ACCUM_WIDTH % RW_WIDTH != 0) + $fatal("ACCUM_WIDTH (%0d) must be multiple of RW_WIDTH (%0d)", + ACCUM_WIDTH, RW_WIDTH); +end + +always @(posedge eth_clk_in) begin : CAPTURE_AXIS + integer idx; + integer b; + logic [ACCUM_WIDTH-1:0] tmp_le; + logic [ACCUM_WIDTH-1:0] tmp_be; - always @(posedge eth_clk_in) begin : CAPTURE_AXIS if (rst) begin - current_packet_word_count <= 0; - total_words_captured <= 0; + current_packet_word_count = 0; end else if (m_axis_tvalid && m_axis_tready) begin - // Сохраняем очередное слово - if (total_words_captured < MAX_WORDS) begin - captured_words_le[total_words_captured] <= m_axis_tdata; - captured_words_be[total_words_captured] <= { - m_axis_tdata[7:0], - m_axis_tdata[15:8], - m_axis_tdata[23:16], - m_axis_tdata[31:24] - }; - end + if (current_packet_word_count < PACKET_RD_WORDS) + packet_bytes[current_packet_word_count] = m_axis_tdata; - total_words_captured <= total_words_captured + 1; - current_packet_word_count <= current_packet_word_count + 1; + current_packet_word_count = current_packet_word_count + 1; if (m_axis_tlast) begin - packets_seen <= packets_seen + 1; - if (current_packet_word_count + 1 != PACKET_RD_WORDS) begin + packets_seen = packets_seen + 1; + + if (current_packet_word_count != PACKET_RD_WORDS) begin $display("[packet] ERROR: packet size=%0d expected=%0d", - current_packet_word_count + 1, + current_packet_word_count, PACKET_RD_WORDS); - total_errors <= total_errors + 1; + total_errors = total_errors + 1; end - current_packet_word_count <= 0; + for (idx = 0; idx < READ_BATCH_SIZE; idx = idx + 1) begin + + tmp_le = '0; + tmp_be = '0; + + for (b = 0; b < PACK_RATIO; b = b + 1) begin + + // Little Endian + tmp_le[b*RW_WIDTH +: RW_WIDTH] = + packet_bytes[idx*PACK_RATIO + b]; + + // Big Endian + tmp_be[(PACK_RATIO-1-b)*RW_WIDTH +: RW_WIDTH] = + packet_bytes[idx*PACK_RATIO + b]; + + end + + if (total_words_captured + idx < MAX_WORDS) begin + captured_words_le[total_words_captured + idx] = tmp_le; + captured_words_be[total_words_captured + idx] = tmp_be; + end + end + + total_words_captured = total_words_captured + READ_BATCH_SIZE; + current_packet_word_count = 0; end end end diff --git a/rtl/accum/tests/tb_accumulator_top_behav.wcfg b/rtl/accum/tests/tb_accumulator_top_behav.wcfg index 46c10c2..93940ab 100644 --- a/rtl/accum/tests/tb_accumulator_top_behav.wcfg +++ b/rtl/accum/tests/tb_accumulator_top_behav.wcfg @@ -11,15 +11,15 @@ - - - + + + - + - + clk_in clk_in @@ -64,9 +64,15 @@ #E0FFFF true + + accum_done + accum_done + #FF0080 + true + - m_axis_tdata[7:0] - m_axis_tdata[7:0] + m_axis_tdata[31:0] + m_axis_tdata[31:0] #008080 true @@ -170,13 +176,13 @@ PROG_FULL_THRESH[31:0] - wr_data_count[7:0] - wr_data_count[7:0] + wr_data_count[5:0] + wr_data_count[5:0] UNSIGNEDDECRADIX - rd_data_count[7:0] - rd_data_count[7:0] + rd_data_count[5:0] + rd_data_count[5:0] UNSIGNEDDECRADIX