FASE #1 hardware freeze for FPGA-Neural V2, N4/P8, single external SDRAM (Alliance Memory AS4C4M16SA-6TIN) serving weights, activations, and results through one physical sdram_controller.v instance. Removes the PSRAM dependency (hardware/v1/rtl/psram_controller.v + memory_interface.v) from the V2 physical path entirely -- V1 itself remains fully unmodified, the golden reference. New RTL: sdram_unified_backend.v (2-way W/AR arbitration over one SDRAM controller, real per-byte DQM write masking added to sdram_controller.v for correct single-byte result writes with no read-modify-write), nms_neural_multiprocessor_sdram_unified.v (the frozen top-level). Two real bugs found and fixed via full-system testing before being accepted (ERR-0023): a deadlock and an off-by-one data-shift bug in the new arbitration logic. Real results: N=4 and N=2 D-Stress bit-exact (256/256 neurons), 40 real AUTO REFRESH events interleaved with zero corruption, real Yosys+nextpnr-ecp5 synthesis/P&R for LFE5U-45F-8CABGA381 (149/245 TRELLIS_IO, a real 45-pin reduction from the prior dual-memory design). Timing is MARGINAL (1/8 P&R seeds >=80MHz), reported honestly rather than masked by the best seed. Real, sourced ball-level pinout for the SDRAM bus + clk/rst (39/149 signals, P&R-verified) using the official Lattice ECP5U-45 pinout CSV found on disk during this step's own pre-commit review -- corrects an earlier draft that wrongly assumed no real pinout data was available. Chip readiness: NO. Real, disclosed blockers remain (no physical host interface exists yet -- the RTL's own reg_* ports are a 110-pin raw test-harness bus; clock source/PLL decision; power/configuration component selection) -- see hardware/v2/docs/{HARDWARE_FREEZE, CHIP_READINESS,OPEN_ITEMS}.md for the complete, itemized status. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013xXuuRUWZScuo1DeYJxs3v
86 lines
3.7 KiB
Verilog
86 lines
3.7 KiB
Verilog
// ============================================================
|
|
// NMS Weight SRAM candidates -- correctness check before trusting any
|
|
// synthesis number. No contention/arbitration exists in either
|
|
// candidate (private per-slot), so this just verifies a fill-then-
|
|
// read round trip is bit-exact per slot, per lane.
|
|
// ============================================================
|
|
`timescale 1ns/1ps
|
|
module tb_nms_weight_candidates;
|
|
parameter DATA_WIDTH = 8;
|
|
parameter P_IN = 8;
|
|
parameter N_SLOTS = 4;
|
|
parameter MAX_TILES = 8;
|
|
parameter TIW = $clog2(MAX_TILES);
|
|
|
|
reg clk = 0;
|
|
always #5 clk = ~clk;
|
|
reg rst;
|
|
|
|
reg [N_SLOTS-1:0] fill_we;
|
|
reg [N_SLOTS*TIW-1:0] fill_addr_flat;
|
|
reg [N_SLOTS*DATA_WIDTH*P_IN-1:0] fill_data_flat;
|
|
reg [N_SLOTS-1:0] rd_en;
|
|
reg [N_SLOTS*TIW-1:0] rd_addr_flat;
|
|
wire [N_SLOTS*DATA_WIDTH*P_IN-1:0] rd_data_direct;
|
|
wire [N_SLOTS*DATA_WIDTH*P_IN-1:0] rd_data_packed;
|
|
|
|
nms_weight_direct #(.DATA_WIDTH(DATA_WIDTH), .P_IN(P_IN), .N_SLOTS(N_SLOTS), .MAX_TILES(MAX_TILES)) u_direct (
|
|
.clk(clk), .rst(rst),
|
|
.fill_we(fill_we), .fill_addr_flat(fill_addr_flat), .fill_data_flat(fill_data_flat),
|
|
.rd_en(rd_en), .rd_addr_flat(rd_addr_flat), .rd_data_flat(rd_data_direct)
|
|
);
|
|
nms_weight_packed #(.DATA_WIDTH(DATA_WIDTH), .P_IN(P_IN), .N_SLOTS(N_SLOTS), .MAX_TILES(MAX_TILES)) u_packed (
|
|
.clk(clk), .rst(rst),
|
|
.fill_we(fill_we), .fill_addr_flat(fill_addr_flat), .fill_data_flat(fill_data_flat),
|
|
.rd_en(rd_en), .rd_addr_flat(rd_addr_flat), .rd_data_flat(rd_data_packed)
|
|
);
|
|
|
|
integer errors, s, t;
|
|
reg [DATA_WIDTH*P_IN-1:0] expected_val [0:N_SLOTS-1][0:MAX_TILES-1];
|
|
|
|
initial begin
|
|
errors = 0;
|
|
rst = 1'b1; fill_we = 0; rd_en = 0; fill_addr_flat = 0; fill_data_flat = 0; rd_addr_flat = 0;
|
|
repeat (3) @(posedge clk);
|
|
rst = 1'b0;
|
|
|
|
// fill every slot with a distinct pattern per tile
|
|
for (t = 0; t < MAX_TILES; t = t + 1) begin
|
|
@(posedge clk);
|
|
for (s = 0; s < N_SLOTS; s = s + 1) begin
|
|
fill_we[s] = 1'b1;
|
|
fill_addr_flat[s*TIW +: TIW] = t[TIW-1:0];
|
|
fill_data_flat[s*DATA_WIDTH*P_IN +: DATA_WIDTH*P_IN] = {P_IN{(s[3:0]<<4) | t[3:0]}};
|
|
expected_val[s][t] = {P_IN{(s[3:0]<<4) | t[3:0]}};
|
|
end
|
|
end
|
|
@(posedge clk);
|
|
fill_we = 0;
|
|
|
|
// read back every slot/tile combination, checking both candidates
|
|
for (t = 0; t < MAX_TILES; t = t + 1) begin
|
|
@(posedge clk);
|
|
for (s = 0; s < N_SLOTS; s = s + 1) begin
|
|
rd_en[s] = 1'b1;
|
|
rd_addr_flat[s*TIW +: TIW] = t[TIW-1:0];
|
|
end
|
|
@(posedge clk);
|
|
#1;
|
|
for (s = 0; s < N_SLOTS; s = s + 1) begin
|
|
if (rd_data_direct[s*DATA_WIDTH*P_IN +: DATA_WIDTH*P_IN] !== expected_val[s][t]) begin
|
|
$display("FAIL direct slot=%0d tile=%0d expected=%h got=%h", s, t, expected_val[s][t], rd_data_direct[s*DATA_WIDTH*P_IN +: DATA_WIDTH*P_IN]);
|
|
errors = errors + 1;
|
|
end
|
|
if (rd_data_packed[s*DATA_WIDTH*P_IN +: DATA_WIDTH*P_IN] !== expected_val[s][t]) begin
|
|
$display("FAIL packed slot=%0d tile=%0d expected=%h got=%h", s, t, expected_val[s][t], rd_data_packed[s*DATA_WIDTH*P_IN +: DATA_WIDTH*P_IN]);
|
|
errors = errors + 1;
|
|
end
|
|
end
|
|
end
|
|
|
|
if (errors == 0) $display("ALL TESTS PASSED (nms_weight_direct + nms_weight_packed, N_SLOTS=%0d MAX_TILES=%0d)", N_SLOTS, MAX_TILES);
|
|
else $display("%0d FAILURES", errors);
|
|
$finish;
|
|
end
|
|
endmodule
|