tests/test.sh exit code (0 → resolved); the classification below is post-hoc and cannot change it.module TopModule (
input clk,
input rst,
input [3:0] req,
input lock,
output logic [3:0] grant,
output logic grant_valid
);
// Sequential state
logic [1:0] start_ptr; // scan starts here (just past last winner)
logic locked; // currently holding a locked winner
logic [1:0] lock_idx; // the held winner index
// Combinational: scan req from start_ptr for first asker
logic win_found;
logic [1:0] win_idx;
logic [1:0] idx;
integer i;
always_comb begin
win_found = 1'b0;
win_idx = 2'b00;
idx = 2'b00;
for (i = 0; i < 4; i = i + 1) begin
idx = start_ptr + i[1:0];
if (!win_found && req[idx]) begin
win_found = 1'b1;
win_idx = idx;
end
end
end
// Combinational: this cycle's grant decision
logic cur_valid;
logic [1:0] cur_idx;
always_comb begin
cur_valid = 1'b0;
cur_idx = 2'b00;
if (locked) begin
// Held winner owns the cycle only while it keeps asking.
if (req[lock_idx]) begin
cur_valid = 1'b1;
cur_idx = lock_idx;
end
// else: dead air -> stays 0
end else begin
if (win_found) begin
cur_valid = 1'b1;
cur_idx = win_idx;
end
end
end
// Outputs
always_comb begin
grant_valid = cur_valid;
grant = 4'b0000;
if (cur_valid)
grant[cur_idx] = 1'b1;
end
// Next-state
always_ff @(posedge clk) begin
if (rst) begin
start_ptr <= 2'b00;
locked <= 1'b0;
lock_idx <= 2'b00;
end else if (locked) begin
if (req[lock_idx]) begin
// held requester still asking; it owns this cycle
start_ptr <= lock_idx + 2'd1;
if (lock) begin
// keep holding
locked <= 1'b1;
lock_idx <= lock_idx;
end else begin
// lock dropped: owned this cycle, sharing resumes next
locked <= 1'b0;
end
end else begin
// dead air: hold is over, held slot counts as served
start_ptr <= lock_idx + 2'd1;
locked <= 1'b0;
end
end else begin
if (win_found) begin
start_ptr <= win_idx + 2'd1;
if (lock) begin
// latch this winner
locked <= 1'b1;
lock_idx <= win_idx;
end else begin
locked <= 1'b0;
end
end else begin
// idle: keep place
start_ptr <= start_ptr;
locked <= 1'b0;
end
end
end
endmodule
Compile dut.sv with iverilog
iverilog -g2012 -o /tmp/dut.out dut.sv 2>&1 && echo "COMPILE OK"
dut.sv:21: sorry: constant selects in always_* processes are not currently supported (all bits will be included). COMPILE OK [stdout] dut.sv:21: sorry: constant selects in always_* processes are not currently supported (all bits will be included). COMPILE OK
/app/dut.sv
idx = start_ptr + i[1:0];
idx = start_ptr + i;
Recompile dut.sv
iverilog -g2012 -o /tmp/dut.out dut.sv 2>&1 && echo "COMPILE OK"
COMPILE OK [stdout] COMPILE OK
Run behavioral sanity testbench
cat > /tmp/tb.sv << 'EOF'
module tb;
logic clk=0, rst, lock;
logic [3:0] req;
logic [3:0] grant;
logic grant_valid;
TopModule d(.clk,.rst,.req,.lock,.grant,.grant_valid);
always #5 clk=~clk;
task step; @(posedge clk); #1; endtask
initial begin
rst=1; req=0; lock=0; step;
rst=0;
// Test 1: all four forever -> 0,1,2,3,0,1
req=4'b1111; lock=0;
for(int k=0;k<6;k++) begin
$display("all4: gv=%b grant=%b (expect one-hot cycling 0..3)", grant_valid, grant); step;
end
// reset
rst=1; step; rst=0;
// Test 2: lone requester req2
req=4'b0100;
for(int k=0;k<3;k++) begin
$display("lone2: gv=%b grant=%b (expect 0100)", grant_valid, grant); step;
end
// Test 3: idle keeps place -> was granting 2, ptr=3. idle a cycle, then all4 -> should grant 3
req=0; $display("idle: gv=%b grant=%b (expect gv=0)", grant_valid, grant); step;
req=4'b1111; $display("resume: gv=%b grant=%b (expect 1000 idx3)", grant_valid, grant); step;
// Test 4: lock hold. reset, then req all, lock high on grant of 0 -> hold 0
rst=1; step; rst=0;
req=4'b1111; lock=1;
$display("lockgrant: gv=%b grant=%b (expect 0001 idx0)", grant_valid, grant); step;
$display("held1: gv=%b grant=%b (expect 0001 held)", grant_valid, grant); step;
$display("held2: gv=%b grant=%b (expect 0001 held)", grant_valid, grant); step;
// lock drops now, held still owns this cycle
lock=0;
$display("lockdrop: gv=%b grant=%b (expect 0001 owns)", grant_valid, grant); step;
$display("afterdrop: gv=%b grant=%b (expect 0010 idx1 resume past 0)", grant_valid, grant); step;
// Test 5: dead air. reset, hold req0 with lock, then drop req0 while locked
rst=1; step; rst=0;
req=4'b1111; lock=1;
$display("dl_grant: gv=%b grant=%b (expect 0001)", grant_valid, grant); step;
// now req0 goes low while locked -> dead air
req=4'b1110;
$display("deadair: gv=%b grant=%b (expect gv=0 grant=0)", grant_valid, grant); step;
$display("resume2: gv=%b grant=%b (expect 0010 idx1)", grant_valid, grant); step;
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb.out /tmp/tb.sv /app/dut.sv && vvp /tmp/tb.outall4: gv=0 grant=0000 (expect one-hot cycling 0..3) all4: gv=1 grant=0010 (expect one-hot cycling 0..3) all4: gv=1 grant=0100 (expect one-hot cycling 0..3) all4: gv=1 grant=1000 (expect one-hot cycling 0..3) all4: gv=1 grant=0001 (expect one-hot cycling 0..3) all4: gv=1 grant=0010 (expect one-hot cycling 0..3) lone2: gv=1 grant=0001 (expect 0100) lone2: gv=1 grant=0100 (expect 0100) lone2: gv=1 grant=0100 (expect 0100) idle: gv=1 grant=0100 (expect gv=0) resume: gv=0 grant=0000 (expect 1000 idx3) lockgrant: gv=1 grant=0001 (expect 0001 idx0) held1: gv=1 grant=0001 (expect 0001 held) held2: gv=1 grant=0001 (expect 0001 held) lockdrop: gv=1 grant=0001 (expect 0001 owns) afterdrop: gv=1 grant=0010 (expect 0010 idx1 resume past 0) dl_grant: gv=1 grant=0001 (expect 0001) deadair: gv=1 grant=0001 (expect gv=0 grant=0) resume2: gv=1 grant=0010 (expect 0010 idx1) /tmp/tb.sv:45: $finish called at 226 (1s) [stdout] all4: gv=0 grant=0000 (expect one-hot cycling 0..3) all4: gv=1 grant=0010 (expect one-hot cycling 0..3) all4: gv=1 grant=0100 (expect one-hot cycling 0..3) all4: gv=1 grant=1000 (expect one-hot cycling 0..3) all4: gv=1 grant=0001 (expect one-hot cycling 0..3) all4: gv=1 grant=0010 (expect one-hot cycling 0..3) lone2: gv=1 grant=0001 (expect 0100) lone2: gv=1 grant=0100 (expect 0100) lone2: gv=1 grant=0100 (expect 0100) idle: gv=1 grant=0100 (expect gv=0) resume: gv=0 grant=0000 (expect 1000 idx3) lockgrant: gv=1 grant=0001 (expect 0001 idx0) held1: gv=1 grant=0001 (expect 0001 held) held2: gv=1 grant=0001 (expect 0001 held) lockdrop: gv=1 grant=0001 (expect 0001 owns) afterdrop: gv=1 grant=0010 (expect 0010 idx1 resume past 0) dl_grant: gv=1 grant=0001 (expect 0001) deadair: gv=1 grant=0001 (expect gv=0 grant=0) resume2: gv=1 grant=0010 (expect 0010 idx1) /tmp/tb.sv:45: $finish called at 226 (1s)
Run clean-sampled testbench
cat > /tmp/tb.sv << 'EOF'
module tb;
logic clk=0, rst, lock;
logic [3:0] req;
logic [3:0] grant;
logic grant_valid;
TopModule d(.clk,.rst,.req,.lock,.grant,.grant_valid);
always #5 clk=~clk;
// drive at negedge, sample just before posedge
task drive(input logic r, input [3:0] q, input logic l);
@(negedge clk); rst=r; req=q; lock=l;
#1; $display("t=%0t rst=%b req=%b lock=%b -> gv=%b grant=%b", $time, r,q,l, grant_valid, grant);
endtask
initial begin
// reset
drive(1,4'b0000,0);
$display("-- all four forever (expect 0,1,2,3,0,1) --");
for(int k=0;k<6;k++) drive(0,4'b1111,0);
$display("-- lone req2 (expect 0100 x3) --");
drive(1,0,0);
for(int k=0;k<3;k++) drive(0,4'b0100,0);
$display("-- idle keeps place: grant2 -> ptr=3; idle; all4 -> expect idx3 --");
drive(0,4'b0100,0); // grant2, ptr->3
drive(0,4'b0000,0); // idle -> gv0
drive(0,4'b1111,0); // expect 1000 (idx3)
drive(0,4'b1111,0); // expect 0001 (idx0)
$display("-- lock hold idx0, then drop --");
drive(1,0,0);
drive(0,4'b1111,1); // grant0, latch
drive(0,4'b1111,1); // held0
drive(0,4'b1111,1); // held0
drive(0,4'b1111,0); // lock drop: still owns idx0
drive(0,4'b1111,0); // resume idx1
$display("-- dead air: hold idx0, drop its req while locked --");
drive(1,0,0);
drive(0,4'b1111,1); // grant0 latch
drive(0,4'b1110,1); // req0 low while locked -> dead air gv0
drive(0,4'b1111,1); // resume idx1, and lock still high re-latches
drive(0,4'b1111,1); // held1
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb.out /tmp/tb.sv /app/dut.sv && vvp /tmp/tb.outt=11 rst=1 req=0000 lock=0 -> gv=0 grant=0000 -- all four forever (expect 0,1,2,3,0,1) -- t=21 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=31 rst=0 req=1111 lock=0 -> gv=1 grant=0010 t=41 rst=0 req=1111 lock=0 -> gv=1 grant=0100 t=51 rst=0 req=1111 lock=0 -> gv=1 grant=1000 t=61 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=71 rst=0 req=1111 lock=0 -> gv=1 grant=0010 -- lone req2 (expect 0100 x3) -- t=81 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=91 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=101 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=111 rst=0 req=0100 lock=0 -> gv=1 grant=0100 -- idle keeps place: grant2 -> ptr=3; idle; all4 -> expect idx3 -- t=121 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=131 rst=0 req=0000 lock=0 -> gv=0 grant=0000 t=141 rst=0 req=1111 lock=0 -> gv=1 grant=1000 t=151 rst=0 req=1111 lock=0 -> gv=1 grant=0001 -- lock hold idx0, then drop -- t=161 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=171 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=181 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=191 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=201 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=211 rst=0 req=1111 lock=0 -> gv=1 grant=0010 -- dead air: hold idx0, drop its req while locked -- t=221 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=231 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=241 rst=0 req=1110 lock=1 -> gv=0 grant=0000 t=251 rst=0 req=1111 lock=1 -> gv=1 grant=0010 t=261 rst=0 req=1111 lock=1 -> gv=1 grant=0010 /tmp/tb.sv:39: $finish called at 261 (1s) [stdout] t=11 rst=1 req=0000 lock=0 -> gv=0 grant=0000 -- all four forever (expect 0,1,2,3,0,1) -- t=21 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=31 rst=0 req=1111 lock=0 -> gv=1 grant=0010 t=41 rst=0 req=1111 lock=0 -> gv=1 grant=0100 t=51 rst=0 req=1111 lock=0 -> gv=1 grant=1000 t=61 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=71 rst=0 req=1111 lock=0 -> gv=1 grant=0010 -- lone req2 (expect 0100 x3) -- t=81 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=91 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=101 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=111 rst=0 req=0100 lock=0 -> gv=1 grant=0100 -- idle keeps place: grant2 -> ptr=3; idle; all4 -> expect idx3 -- t=121 rst=0 req=0100 lock=0 -> gv=1 grant=0100 t=131 rst=0 req=0000 lock=0 -> gv=0 grant=0000 t=141 rst=0 req=1111 lock=0 -> gv=1 grant=1000 t=151 rst=0 req=1111 lock=0 -> gv=1 grant=0001 -- lock hold idx0, then drop -- t=161 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=171 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=181 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=191 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=201 rst=0 req=1111 lock=0 -> gv=1 grant=0001 t=211 rst=0 req=1111 lock=0 -> gv=1 grant=0010 -- dead air: hold idx0, drop its req while locked -- t=221 rst=1 req=0000 lock=0 -> gv=0 grant=0000 t=231 rst=0 req=1111 lock=1 -> gv=1 grant=0001 t=241 rst=0 req=1110 lock=1 -> gv=0 grant=0000 t=251 rst=0 req=1111 lock=1 -> gv=1 grant=0010 t=261 rst=0 req=1111 lock=1 -> gv=1 grant=0010 /tmp/tb.sv:39: $finish called at 261 (1s)
No file changes, the agent left the workspace untouched.
TEST dut_present: PASS (/app/dut.sv exists)
TEST dut_forbidden: PASS (no forbidden constructs)
TEST dut_elaborates: PASS (DUT elaborates standalone)
TEST dut_compiles: PASS (compiled with held-back reference/testbench)
TEST simulation_completed: PASS (Mismatches: 0 in 4583 samples)
TEST reference_equivalence: PASS (all 4583 samples matched reference)
{"score": 1.000000, "results_file": "/tmp/h2t-grader-home.9z7F1C/runtime/cb_verifier_325-24459-31879-20187_325/results.jsonl"}Reproduce this trial: git checkout 2f94510 && PYTHONPATH=src python3 scripts/build_site.py , then open trial/trial_208bea750e8b4442. Re-running the agent live requires EVAL_PLATFORM_ENABLE_OAUTH_SMOKE=1 and is non-deterministic.
Trial trial_208bea750e8b4442 · verifier authoritative; classifier explanatory.