open-standards/wai/wai-quantum-landscape-fpga/tb/tb_landscape.v
Transaction Science d4867b1b83 wai-quantum-landscape-fpga: the review of #677 answered
The lock and reloads. load takes the board lock before it reconfigures, and the session check sees
other runs of this tool and its scripts (their own parents excepted), so a reload waits for the job
that holds the board. The scripts do not hold the lock across the steps they run. A reload of the
same design, which passes the signature and the ID, is seen by the engine's uptime counter and its
reset BOUND register: the engine checks both before it takes a workload or a table as loaded and
after every job, and refuses a result read across a reload. A batch that comes back short, and a
sampled chain whose sweep count is wrong, are refused.

The AXI port. It checks the port's write width as well as its read width; it fills a result page
with the illegal cell pair before a write-back and refuses a result still holding it; it refuses a
transfer whose page moved. It is written against two traits, so a software link tests it off the
board: the guard, the DMA, the sequencer's count, the write-back's layout, dropped accesses.

Tests. lowered_settle's five cases and 300 random workloads with fields to 2^40 against the
reference; the joint test counts against the chains requested and checks the control's cell family.
CI gates on the change, requires tests to run, denies clippy warnings, certifies the model member,
runs a job on it, builds on linux-arm64, and replays both testbenches in Icarus Verilog
(scripts/run_tb.sh). The names check reads .v, .tcl, .xdc and .dat files.

The build. The tool version and each block's version are enforced; the multi-core build refuses the
AXI link. The documents. The latency table says how each row was timed; the engine's share of a
chain is its own clock count; the sampling energy carries its error and its floor; the known answer
is placed in time; the step response is reported; derived figures are marked; the scope of the
meter, the guard's window and the DMA's locked pages are stated; provenance says what the private
code declared; old names are gone; the build and simulator results have a raw record.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 03:22:22 -05:00

81 lines
3 KiB
Verilog

// SPDX-License-Identifier: Apache-2.0
// Replays a session recorded from the host's software model (`wai-quantum-landscape-fpga gen-tb landscape_tb.script`) against the RTL,
// through the EMIO port and its synchroniser, with the PS side deliberately off the PL clock.
// Every read must return what the model returned. A mismatch names the script line.
`timescale 1ns/1ps
module tb;
reg clk = 0;
always #5 clk = ~clk; // pl_clk0, 100 MHz
reg [94:0] emio_o = 95'd0;
wire [94:0] emio_i;
`ifdef MULTI
landscape_multi #(.K(4)) dut (.clk(clk), .emio_o(emio_o), .emio_i(emio_i));
`else
landscape_port dut (.clk(clk), .emio_o(emio_o), .emio_i(emio_i));
`endif
integer fd, r, errors, reads, line, t;
reg [31:0] op, a, d, m, got;
reg req;
task txn(input we, input [15:0] addr, input [31:0] wdata, output [31:0] rdata);
reg ack0;
begin
ack0 = emio_i[82];
emio_o[31:0] = wdata;
#37; // a PS bus write, some time before the next
req = ~req;
emio_o[81] = we;
emio_o[79:64] = addr;
emio_o[80] = req;
t = 0;
while (emio_i[82] == ack0) begin
#13;
t = t + 1;
if (t > 20000) begin
$display("TIMEOUT waiting for ack at script line %0d", line);
$finish;
end
end
rdata = emio_i[63:32];
#29;
end
endtask
initial begin
errors = 0; reads = 0; line = 0; req = 0;
#3000; // past the port's power-on hold-off
fd = $fopen("landscape_tb.script", "r");
if (fd == 0) begin $display("no script"); $finish; end
r = $fscanf(fd, "%s", op);
while (r == 1) begin
line = line + 1;
if (op == "W") begin
r = $fscanf(fd, " %h %h", a, d);
txn(1'b1, a[15:0], d, got);
end else if (op == "R") begin
r = $fscanf(fd, " %h %h %h", a, d, m);
txn(1'b0, a[15:0], 32'd0, got);
reads = reads + 1;
if ((got & m) !== (d & m)) begin
errors = errors + 1;
if (errors <= 25) $display("MISMATCH line %0d: R %h got %h want %h", line, a[15:0], got, d);
end
end else if (op == "I") begin
t = 0;
while (emio_i[83]) begin
#50;
t = t + 1;
if (t > 2000000) begin $display("TIMEOUT busy at line %0d", line); $finish; end
end
#20;
end else begin
$display("bad op at line %0d", line);
$finish;
end
r = $fscanf(fd, "%s", op);
end
$display("TB DONE: %0d lines, %0d checked reads, %0d mismatches, sim time %0t", line, reads, errors, $time);
$finish;
end
endmodule