diff --git a/rtl/accum/tests/accum_full_tb.sv b/rtl/accum/tests/accum_full_tb.sv
index 156a8ba..b20f74b 100644
--- a/rtl/accum/tests/accum_full_tb.sv
+++ b/rtl/accum/tests/accum_full_tb.sv
@@ -4,12 +4,19 @@ module tb_accumulator_top;
localparam DATA_WIDTH = 12;
localparam ACCUM_WIDTH = 32;
+ localparam RW_WIDTH = 32;
localparam N_MAX = 4096;
localparam MAX_WINDOW_SIZE = 65;
- localparam PACKET_SIZE = 1024;
+ localparam PACKET_SIZE = 32;
localparam READ_BATCH_SIZE = (PACKET_SIZE*8)/ACCUM_WIDTH;
localparam MAX_WORDS = N_MAX;
localparam MAX_SEQ_NUM = 256;
+
+ localparam int WR_WORD_BYTES = ACCUM_WIDTH/8;
+ localparam int RD_WORD_BYTES = RW_WIDTH/8;
+
+ localparam int PACKET_WR_WORDS = PACKET_SIZE / WR_WORD_BYTES;
+ localparam int PACKET_RD_WORDS = PACKET_SIZE / RD_WORD_BYTES;
logic clk_in;
logic eth_clk_in;
@@ -25,7 +32,7 @@ module tb_accumulator_top;
logic req_ready;
wire send_req;
- wire [7:0] m_axis_tdata;
+ wire [RW_WIDTH-1:0] m_axis_tdata;
wire m_axis_tvalid;
logic m_axis_tready;
wire m_axis_tlast;
@@ -39,10 +46,10 @@ module tb_accumulator_top;
integer tests_passed;
integer packets_seen;
- integer current_packet_byte_count;
+ integer current_packet_word_count;
integer total_words_captured;
- byte packet_bytes [0:PACKET_SIZE-1];
+ logic [RW_WIDTH-1:0] packet_bytes [0:PACKET_RD_WORDS-1];
logic [ACCUM_WIDTH-1:0] expected_words [0:MAX_WORDS-1];
logic [ACCUM_WIDTH-1:0] captured_words_le[0:MAX_WORDS-1];
logic [ACCUM_WIDTH-1:0] captured_words_be[0:MAX_WORDS-1];
@@ -51,7 +58,8 @@ module tb_accumulator_top;
.DATA_WIDTH(DATA_WIDTH),
.ACCUM_WIDTH(ACCUM_WIDTH),
.N_MAX(N_MAX),
- .PACKET_SIZE(PACKET_SIZE)
+ .PACKET_SIZE(PACKET_SIZE),
+ .RW_WIDTH(RW_WIDTH)
) dut (
.clk_in(clk_in),
.rst(rst),
@@ -62,7 +70,7 @@ module tb_accumulator_top;
.seq_num(seq_num),
.window_size(window_size),
.eth_clk_in(eth_clk_in),
- .req_ready(req_ready),
+ .req_ready(1'b1),
.send_req(send_req),
.m_axis_tdata(m_axis_tdata),
.m_axis_tvalid(m_axis_tvalid),
@@ -85,14 +93,14 @@ module tb_accumulator_top;
integer i;
begin
packets_seen = 0;
- current_packet_byte_count = 0;
+ current_packet_word_count = 0;
total_words_captured = 0;
for (i = 0; i < MAX_WORDS; i = i + 1) begin
expected_words[i] = '0;
captured_words_le[i] = '0;
captured_words_be[i] = '0;
end
- for (i = 0; i < PACKET_SIZE; i = i + 1)
+ for (i = 0; i < PACKET_RD_WORDS; i = i + 1)
packet_bytes[i] = 8'h00;
end
endtask
@@ -184,7 +192,7 @@ module tb_accumulator_top;
smp_num = smp_num_i;
seq_num = seq_num_i;
window_size = window_size_i;
- req_ready = 1'b1; // приемник готов заранее
+ 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;
@@ -219,7 +227,7 @@ module tb_accumulator_top;
end
timeout_cnt = 0;
- while (packets_seen < exp_packet_count && timeout_cnt < 50 * PACKET_SIZE) begin
+ while (packets_seen < exp_packet_count && timeout_cnt < 50 * PACKET_RD_WORDS) begin
@(posedge eth_clk_in);
timeout_cnt = timeout_cnt + 1;
end
@@ -272,48 +280,40 @@ module tb_accumulator_top;
endtask
always @(posedge eth_clk_in) begin : CAPTURE_AXIS
- integer idx;
- logic [31:0] tmp_le;
- logic [31:0] tmp_be;
- if (rst) begin
- current_packet_byte_count = 0;
- end else if (m_axis_tvalid && m_axis_tready) begin
- if (current_packet_byte_count < PACKET_SIZE)
- packet_bytes[current_packet_byte_count] = m_axis_tdata;
- current_packet_byte_count = current_packet_byte_count + 1;
+ if (rst) begin
+ current_packet_word_count <= 0;
+ total_words_captured <= 0;
+ end
+ else if (m_axis_tvalid && m_axis_tready) begin
- if (m_axis_tlast) begin
- packets_seen = packets_seen + 1;
+ // Ñîõðàíÿåì î÷åðåäíîå ñëîâî
+ 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_byte_count != PACKET_SIZE) begin
- $display("[packet] ERROR: packet size=%0d expected=%0d", current_packet_byte_count, PACKET_SIZE);
- total_errors = total_errors + 1;
- end
+ total_words_captured <= total_words_captured + 1;
+ current_packet_word_count <= current_packet_word_count + 1;
- for (idx = 0; idx < READ_BATCH_SIZE; idx = idx + 1) begin
- tmp_le = {
- packet_bytes[idx*4 + 3],
- packet_bytes[idx*4 + 2],
- packet_bytes[idx*4 + 1],
- packet_bytes[idx*4 + 0]
- };
- tmp_be = {
- packet_bytes[idx*4 + 0],
- packet_bytes[idx*4 + 1],
- packet_bytes[idx*4 + 2],
- packet_bytes[idx*4 + 3]
- };
- 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
+ if (m_axis_tlast) begin
+ packets_seen <= packets_seen + 1;
- total_words_captured = total_words_captured + READ_BATCH_SIZE;
- current_packet_byte_count = 0;
+ if (current_packet_word_count + 1 != PACKET_RD_WORDS) begin
+ $display("[packet] ERROR: packet size=%0d expected=%0d",
+ current_packet_word_count + 1,
+ PACKET_RD_WORDS);
+ total_errors <= total_errors + 1;
end
+
+ current_packet_word_count <= 0;
end
end
+end
initial begin
seed = 32'h1badf00d;
diff --git a/rtl/accum/tests/tb_accumulator_top_behav.wcfg b/rtl/accum/tests/tb_accumulator_top_behav.wcfg
index 007c100..46c10c2 100644
--- a/rtl/accum/tests/tb_accumulator_top_behav.wcfg
+++ b/rtl/accum/tests/tb_accumulator_top_behav.wcfg
@@ -11,173 +11,185 @@
-
-
-
+
+
+
-
-
+
+
-
+
clk_in
clk_in
-
+
eth_clk_in
eth_clk_in
-
+
rst
rst
-
+
s_axis_tdata[11:0]
s_axis_tdata[11:0]
-
+
s_axis_tvalid
s_axis_tvalid
-
+
start
start
-
+
smp_num[31:0]
smp_num[31:0]
-
+
seq_num[15:0]
seq_num[15:0]
-
+
req_ready
req_ready
#E0FFFF
true
-
+
send_req
send_req
#E0FFFF
true
-
+
m_axis_tdata[7:0]
m_axis_tdata[7:0]
#008080
true
-
+
m_axis_tready
m_axis_tready
#00FFFF
true
-
+
m_axis_tlast
m_axis_tlast
#008080
true
-
+
finish
finish
#FAAFBE
true
-
+
batch_req
batch_req
#00FFFF
true
-
+
readout_begin
readout_begin
#00FFFF
true
-
+
acc
label
-
+
PACKET_SIZE[31:0]
PACKET_SIZE[31:0]
-
+
READ_BATCH_SIZE[31:0]
READ_BATCH_SIZE[31:0]
-
+
addrb[15:0]
addrb[15:0]
-
+
wr_state[3:0]
wr_state[3:0]
-
+
fifo
label
-
+
acc_din[31:0]
acc_din[31:0]
#FF0080
true
-
+
din_valid
din_valid
#FF0080
true
-
+
batch_req
batch_req
-
+
wr_state[2:0]
wr_state[2:0]
-
+
rd_state[2:0]
rd_state[2:0]
-
+
wr_unavail
wr_unavail
#FFFF00
true
-
+
wr_rst_busy
wr_rst_busy
#FFFF00
true
-
+
empty
empty
-
+
PROG_FULL_THRESH[31:0]
PROG_FULL_THRESH[31:0]
-
- wr_data_count[9:0]
- wr_data_count[9:0]
+
+ wr_data_count[7:0]
+ wr_data_count[7:0]
UNSIGNEDDECRADIX
-
- rd_data_count[11:0]
- rd_data_count[11:0]
+
+ rd_data_count[7:0]
+ rd_data_count[7:0]
UNSIGNEDDECRADIX
+
+ fifo_wr_en_r
+ fifo_wr_en_r
+ #FAAFBE
+ true
+
+
+ rd_en
+ rd_en
+ #FAAFBE
+ true
+