fix: correct byte/word address conversion in neuron_memory_tb preload tasks

preload_vector and preload_weights wrote using base as a word address
instead of a byte address (base + (k>>1) instead of (base>>1) + (k>>1)),
misaligning X/W data in PSRAM relative to what int8_memory_access expects.
Also adds a PATTERN test (X=1..32) to exercise mixed even/odd byte reads
and catch this class of bug going forward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQV3vS9TXaGDJ5cRfnfidt
This commit is contained in:
2026-09-02 14:08:13 +02:00
co-authored by Claude Sonnet 5
parent 16769eaa4b
commit 896f56c675
4 changed files with 75645 additions and 23769 deletions
+48109 -1032
View File
File diff suppressed because it is too large Load Diff
+27437 -22723
View File
File diff suppressed because one or more lines are too long
+75 -14
View File
@@ -308,12 +308,7 @@ module tb;
begin
for (k = 0; k < 32; k = k + 2) begin
tb_write_word(
base + (k >> 1),
{value, value}
);
tb_write_word( (base >> 1) + (k >> 1), {value, value} );
end
end
@@ -335,10 +330,7 @@ module tb;
for (k = 0; k < 32; k = k + 2) begin
tb_write_word(
base + (k >> 1),
{value, value}
);
tb_write_word( (base >> 1) + (k >> 1), {value, value} );
end
@@ -346,6 +338,32 @@ module tb;
endtask
task preload_x_pattern;
input [ADDR_WIDTH-1:0] base;
integer k;
reg signed [7:0] v0;
reg signed [7:0] v1;
begin
for (k = 0; k < 32; k = k + 2) begin
v0 = k + 1;
v1 = k + 2;
tb_write_word(
(base >> 1) + (k >> 1),
{v1, v0}
);
end
end
endtask
// ============================================================
// PRELOAD BIAS
// ============================================================
@@ -482,10 +500,9 @@ module tb;
// TB is the ONLY memory master.
// ========================================================
$display("PRELOAD: X = 1");
preload_vector(
x_base,
8'sd1
$display("PRELOAD: X = 1..32");
preload_x_pattern(
x_base
);
$display("PRELOAD: W = 1");
@@ -512,6 +529,49 @@ module tb;
$display("MEMORY MASTER -> neuron_memory");
$display("");
// ========================================================
// TEST 0 - PATTERN
//
// X = 1..32
// W = 1
// BIAS = 0
//
// SUM = 1 + 2 + ... + 32 = 528
// Output saturates to 127.
// ========================================================
run_neuron(
8'sd127,
"PATTERN X=1..32"
);
// ========================================================
// RESTORE ORIGINAL VECTOR
//
// X = 1
// W = 1
// BIAS = 0
// ========================================================
use_neuron_master = 1'b0;
preload_vector(
x_base,
8'sd1
);
preload_weights(
w_base,
8'sd1
);
preload_bias(
bias_addr,
8'sd0
);
use_neuron_master = 1'b1;
// ========================================================
// TEST 1
//
@@ -611,6 +671,7 @@ module tb;
$display("NEURON MEMORY TEST PASSED");
$display("========================================");
$display("PSRAM -> INT8 -> NEURON : PASS");
$display("PATTERN X=1..32 : PASS");
$display("SUM : PASS");
$display("BIAS : PASS");
$display("ReLU : PASS");