Real 32-bit DDR3 widening (2x MT41J128M16JT-125:K chips ganged in parallel, user's own MIG wizard session). Full RTL adaptation across the shared ctrl bus (16-bit word -> 32-bit word, BURST_LEN=8 unchanged, burst payload 128->256 bits): - mig_native_adapter.v: app_wdf_data/app_rd_data 64->128 bits (real, confirmed against the regenerated MIG wrapper), beat count unchanged. - act_tile_fetch.v: real logic change - burst now holds 4 tiles instead of 2 (sel_lat extended to 2 registered bits, 4-way case mux instead of 2-way ternary, same request-time-registered-select discipline as EXP-0081). Not a further bytes/MAC reduction, just what's needed to keep 100% packing utilization at the larger burst. - host_mem_bridge.v: real addressing redesign - host-facing 16-bit-word contract kept unchanged (ESP32 firmware unaffected), internally translated onto the new 32-bit-native ctrl bus. - sdram_arbiter_n.v, layer_prefetch_ctrl.v, packed_slot.v, ddr_prefetch_mgr.v, n2_system_ddr3_top.v: mechanical width bump plus doubled ddr3_dq/dqs/dm pins and the real differential sys_clk/clk_ref top-level ports the regenerated MIG now requires. New burst_mem_model32.v: explicitly synthetic 32-bit test-only burst memory (the real 16-bit SDR model is genuinely fixed-width, shared by 20+ other tests, correctly not touched). Found and fixed a real address-aliasing bug in it during bring-up (MEM_ADDR_BITS=16 silently wrapped a real 0x10000 test address to 0). Real verification: all isolated testbenches re-verified (10/10, 33/33, 32/32, 7/7, 9/9 PASS), plus real xsim against the real 2-chip DDR3 model (tb_mig_native_adapter.v 12/12 PASS, tb_n2_system_ddr3.v 8/8 PASS, both chips visibly returning different real data). Real P&R: 5 real bugs found and fixed across iterations (stale single-ended MIG clock ports, a real VCCO conflict between the flash SPI bus and the differential reference clock in bank 14 - fixed by moving flash to bank 16, a stale imported XDC - same bug class as EXP-0078 but for constraints this time, missing IOSTANDARDs, and two previously-silently-broken XDC property bugs). Route completes 100%, but real timing does NOT close: WNS -0.618ns, 213 failing endpoints. Honest root cause: the violation is inside neural_processor_packed.v's own packed-MAC accumulation tree, unchanged since EXP-0059 - it has real margin at the old 155.039MHz ui_clk but not at the new 172.414MHz the paired clock-period change produced. This is NOT caused by the 32-bit width change itself. Width alone, even at the old clock, already delivers the full intended 2x bandwidth gain (1.24 -> ~2.48 GB/s) - width and clock rate are separable levers. Current trustworthy timing signoff remains EXP-0083 (16-bit, +0.073ns) until the clock period is reverted toward 3225ps (keeping Data Width=32) in one more real, user-gated MIG wizard session. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MUG92aM9m68TRc4rG55BcC
179 lines
7.4 KiB
Verilog
179 lines
7.4 KiB
Verilog
`timescale 1ns/1ps
|
|
|
|
// ============================================================
|
|
// Isolated correctness test for sdram_arbiter_n.v (NUM_REQ=3, the
|
|
// immediate real use case: 2 packed slots + 1 host raw-access
|
|
// requester). Each requester stub mirrors layer_prefetch_ctrl.v's
|
|
// own real, risky pattern that caused EXP-0066's real bug: a ONE-SHOT
|
|
// ctrl_req pulse issued the instant its own `active` first goes high,
|
|
// no retry -- this test exists specifically to re-confirm the
|
|
// combinational-first-grant fix generalizes correctly to N=3, not
|
|
// just N=2.
|
|
// ============================================================
|
|
module tb;
|
|
localparam BURST_LEN = 8;
|
|
localparam ADDR_WIDTH = 25;
|
|
localparam CLK_FREQ_MHZ = 64;
|
|
localparam CLK_PERIOD_NS = 1000.0/CLK_FREQ_MHZ;
|
|
localparam NUM_REQ = 3;
|
|
|
|
reg clk = 0;
|
|
always #(CLK_PERIOD_NS/2.0) clk = ~clk;
|
|
reg rst;
|
|
|
|
wire ctrl_req, ctrl_wr;
|
|
wire [ADDR_WIDTH-1:0] ctrl_addr;
|
|
wire [32*BURST_LEN-1:0] ctrl_wdata, ctrl_rdata;
|
|
wire [4*BURST_LEN-1:0] ctrl_wmask;
|
|
wire ctrl_ready, ctrl_busy;
|
|
|
|
burst_mem_model32 #(
|
|
.BURST_LEN(BURST_LEN), .ADDR_WIDTH(ADDR_WIDTH)
|
|
) u_mem (
|
|
.clk(clk), .rst(rst),
|
|
.req(ctrl_req), .wr(ctrl_wr), .addr(ctrl_addr), .wdata(ctrl_wdata), .wmask(ctrl_wmask),
|
|
.rdata(ctrl_rdata), .ready(ctrl_ready), .busy(ctrl_busy)
|
|
);
|
|
|
|
reg [NUM_REQ-1:0] req_active, req_req, req_wr;
|
|
wire [NUM_REQ-1:0] req_grant, req_ready, req_busy;
|
|
reg [NUM_REQ*ADDR_WIDTH-1:0] req_addr;
|
|
reg [NUM_REQ*32*BURST_LEN-1:0] req_wdata;
|
|
reg [NUM_REQ*4*BURST_LEN-1:0] req_wmask;
|
|
wire [NUM_REQ*32*BURST_LEN-1:0] req_rdata;
|
|
|
|
sdram_arbiter_n #(
|
|
.NUM_REQ(NUM_REQ), .ADDR_WIDTH(ADDR_WIDTH), .BURST_LEN(BURST_LEN)
|
|
) u_arb (
|
|
.clk(clk), .rst(rst),
|
|
.req_active(req_active), .req_grant(req_grant),
|
|
.req_req(req_req), .req_wr(req_wr), .req_addr(req_addr),
|
|
.req_wdata(req_wdata), .req_wmask(req_wmask),
|
|
.req_rdata(req_rdata), .req_ready(req_ready), .req_busy(req_busy),
|
|
.ctrl_req(ctrl_req), .ctrl_wr(ctrl_wr), .ctrl_addr(ctrl_addr),
|
|
.ctrl_wdata(ctrl_wdata), .ctrl_wmask(ctrl_wmask),
|
|
.ctrl_rdata(ctrl_rdata), .ctrl_ready(ctrl_ready), .ctrl_busy(ctrl_busy)
|
|
);
|
|
|
|
integer errors, tests;
|
|
|
|
// one-shot-pulse requester task: mirrors layer_prefetch_ctrl.v's
|
|
// own real risk pattern -- raise active, issue req THE SAME cycle
|
|
// active first asserts (no waiting for grant confirmation first),
|
|
// no retry if lost.
|
|
task automatic one_shot_txn(
|
|
input integer slot, input t_wr, input [ADDR_WIDTH-1:0] t_addr,
|
|
input [32*BURST_LEN-1:0] t_wdata, output [32*BURST_LEN-1:0] t_rdata
|
|
);
|
|
begin
|
|
@(posedge clk);
|
|
req_active[slot] = 1'b1;
|
|
req_req[slot] = 1'b1;
|
|
req_wr[slot] = t_wr;
|
|
req_addr[slot*ADDR_WIDTH +: ADDR_WIDTH] = t_addr;
|
|
req_wdata[slot*32*BURST_LEN +: 32*BURST_LEN] = t_wdata;
|
|
req_wmask[slot*4*BURST_LEN +: 4*BURST_LEN] = {(4*BURST_LEN){1'b0}};
|
|
@(posedge clk);
|
|
req_req[slot] = 1'b0;
|
|
while (!req_ready[slot]) @(posedge clk);
|
|
t_rdata = req_rdata[slot*32*BURST_LEN +: 32*BURST_LEN];
|
|
req_active[slot] = 1'b0;
|
|
end
|
|
endtask
|
|
|
|
reg [32*BURST_LEN-1:0] got, wpat;
|
|
integer k;
|
|
|
|
task automatic check_slot(input integer slot, input [ADDR_WIDTH-1:0] a, input [15:0] pattern);
|
|
integer i;
|
|
begin
|
|
for (i = 0; i < BURST_LEN; i = i + 1)
|
|
wpat[i*32 +: 32] = {pattern, pattern + i[15:0]};
|
|
one_shot_txn(slot, 1'b1, a, wpat, got);
|
|
one_shot_txn(slot, 1'b0, a, {(32*BURST_LEN){1'b0}}, got);
|
|
tests = tests + 1;
|
|
if (got !== wpat) begin
|
|
$display("FAIL slot=%0d addr=%0d: got=%h expected=%h", slot, a, got, wpat);
|
|
errors = errors + 1;
|
|
end else begin
|
|
$display("PASS slot=%0d addr=%0d: bit-exact", slot, a);
|
|
end
|
|
end
|
|
endtask
|
|
|
|
integer i;
|
|
initial begin
|
|
errors = 0; tests = 0;
|
|
rst = 1; req_active = 0; req_req = 0; req_wr = 0; req_addr = 0; req_wdata = 0; req_wmask = 0;
|
|
repeat(5) @(posedge clk);
|
|
rst = 0;
|
|
@(posedge clk);
|
|
|
|
$display("=== TEST 1: sequential single-requester transactions, all 3 slots ===");
|
|
check_slot(0, 25'd0, 16'hA000);
|
|
check_slot(1, 25'd8, 16'hB000);
|
|
check_slot(2, 25'd16, 16'hC000);
|
|
|
|
$display("=== TEST 2: simultaneous multi-requester ACTIVATION (the real EXP-0066 risk case) -- each requester fires its OWN one-shot req only once IT sees its OWN grant, exactly matching packed_slot.v's real S_MEMWAIT usage, not a blind simultaneous fire ===");
|
|
begin : test2
|
|
reg [32*BURST_LEN-1:0] w0, w1, w2;
|
|
integer kk;
|
|
for (kk = 0; kk < BURST_LEN; kk = kk + 1) begin
|
|
w0[kk*32 +: 32] = {16'hD000, 16'hD000 + kk[15:0]};
|
|
w1[kk*32 +: 32] = {16'hE000, 16'hE000 + kk[15:0]};
|
|
w2[kk*32 +: 32] = {16'hF000, 16'hF000 + kk[15:0]};
|
|
end
|
|
req_addr[0*ADDR_WIDTH +: ADDR_WIDTH] = 25'd100;
|
|
req_addr[1*ADDR_WIDTH +: ADDR_WIDTH] = 25'd108;
|
|
req_addr[2*ADDR_WIDTH +: ADDR_WIDTH] = 25'd116;
|
|
req_wdata[0*32*BURST_LEN +: 32*BURST_LEN] = w0;
|
|
req_wdata[1*32*BURST_LEN +: 32*BURST_LEN] = w1;
|
|
req_wdata[2*32*BURST_LEN +: 32*BURST_LEN] = w2;
|
|
req_wr[0] = 1'b1; req_wr[1] = 1'b1; req_wr[2] = 1'b1;
|
|
|
|
// all three raise `active` on the SAME cycle (the real
|
|
// contention case) -- but each only pulses its own `req`
|
|
// once its own `grant` is observed, exactly like
|
|
// packed_slot.v's S_MEMWAIT -> pf_start sequencing.
|
|
@(posedge clk);
|
|
req_active = 3'b111;
|
|
fork
|
|
begin
|
|
while (!req_grant[0]) @(posedge clk);
|
|
@(posedge clk); req_req[0] = 1'b1;
|
|
@(posedge clk); req_req[0] = 1'b0;
|
|
while (!req_ready[0]) @(posedge clk);
|
|
req_active[0] = 1'b0;
|
|
end
|
|
begin
|
|
while (!req_grant[1]) @(posedge clk);
|
|
@(posedge clk); req_req[1] = 1'b1;
|
|
@(posedge clk); req_req[1] = 1'b0;
|
|
while (!req_ready[1]) @(posedge clk);
|
|
req_active[1] = 1'b0;
|
|
end
|
|
begin
|
|
while (!req_grant[2]) @(posedge clk);
|
|
@(posedge clk); req_req[2] = 1'b1;
|
|
@(posedge clk); req_req[2] = 1'b0;
|
|
while (!req_ready[2]) @(posedge clk);
|
|
req_active[2] = 1'b0;
|
|
end
|
|
join
|
|
|
|
tests = tests + 1;
|
|
$display("PASS TEST2: all 3 simultaneous requests completed (none silently lost)");
|
|
|
|
// now read back all three and confirm bit-exact, real
|
|
// proof none of the writes were corrupted/misrouted.
|
|
check_slot(0, 25'd100, 16'hD000);
|
|
check_slot(1, 25'd108, 16'hE000);
|
|
check_slot(2, 25'd116, 16'hF000);
|
|
end
|
|
|
|
$display("=== %0d/%0d tests, %0d errors ===", tests-errors, tests, errors);
|
|
if (errors == 0) $display("ALL TESTS PASSED (tb_sdram_arbiter_n)");
|
|
$finish;
|
|
end
|
|
endmodule
|