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 reg [3:0] grant,
output reg grant_valid
);
// Round-robin pointer: last served index. Search starts at last+1.
// After reset, last=3 so the first search starts at index 0.
reg [1:0] last;
// Hold latch: when high, grant is nailed to held_idx.
reg held;
reg [1:0] held_idx;
integer k;
reg [1:0] cand;
// Combinational round-robin arbitration starting just past `last`.
reg arb_valid;
reg [1:0] arb_idx;
always @(*) begin
arb_valid = 1'b0;
arb_idx = 2'd0;
for (k = 0; k < 4; k = k + 1) begin
cand = last + 2'd1 + k[1:0];
if (!arb_valid && req[cand]) begin
arb_valid = 1'b1;
arb_idx = cand;
end
end
end
// Output logic (combinational).
always @(*) begin
if (held) begin
// In a hold: nailed to held_idx while it keeps asking.
if (req[held_idx]) begin
grant = 4'b0001 << held_idx;
grant_valid = 1'b1;
end else begin
// Held requester dropped: dead air this cycle.
grant = 4'b0000;
grant_valid = 1'b0;
end
end else begin
if (arb_valid) begin
grant = 4'b0001 << arb_idx;
grant_valid = 1'b1;
end else begin
grant = 4'b0000;
grant_valid = 1'b0;
end
end
end
// State update (synchronous, active-high reset).
always @(posedge clk) begin
if (rst) begin
last <= 2'd3;
held <= 1'b0;
held_idx <= 2'd0;
end else begin
if (held) begin
if (req[held_idx]) begin
if (lock) begin
// Hold continues.
held <= 1'b1;
end else begin
// Lock dropped: held winner owns this cycle,
// sharing resumes next cycle just past it.
held <= 1'b0;
last <= held_idx;
end
end else begin
// Dead air: hold over, counts as served.
held <= 1'b0;
last <= held_idx;
end
end else begin
if (arb_valid) begin
if (lock) begin
// Latch this winner.
held <= 1'b1;
held_idx <= arb_idx;
end else begin
held <= 1'b0;
last <= arb_idx;
end
end else begin
// No grant: idle keeps our place; lock does nothing.
held <= 1'b0;
end
end
end
end
endmodule
Compile dut.sv with iverilog -g2012
iverilog -g2012 -o /tmp/dut.out dut.sv 2>&1 && echo "COMPILE OK"
COMPILE OK [stdout] COMPILE OK
Run behavioral self-test
cat > /tmp/tb.sv <<'EOF'
module tb;
reg clk=0, rst; reg [3:0] req; reg lock;
wire [3:0] grant; wire grant_valid;
TopModule d(.clk(clk),.rst(rst),.req(req),.lock(lock),.grant(grant),.grant_valid(grant_valid));
always #5 clk=~clk;
task step; begin @(posedge clk); #1; $display("t=%0t req=%b lock=%b -> grant=%b gv=%b",$time,req,lock,grant,grant_valid); end endtask
initial begin
rst=1; req=0; lock=0; @(posedge clk); #1; rst=0;
$display("-- all four asking (expect 0,1,2,3,0) --");
req=4'b1111; lock=0;
step; step; step; step; step;
$display("-- lone requester 2 keeps winning --");
req=4'b0100; step; step;
$display("-- lock hold on req1 --");
req=4'b1111; lock=1; step; // grant should follow arb (resume just past 2 -> 3)
$display("-- now hold whoever, drop others --");
// set up a clean lock test
rst=1; @(posedge clk); #1; rst=0;
req=4'b1111; lock=1; step; // grant0, arm hold on 0
req=4'b1111; lock=1; step; // held on 0
req=4'b1111; lock=1; step; // held on 0
lock=0; step; // lock drops, still grant0, resume past0
step; // grant1
$display("-- dead air: hold on 0 then req0 low --");
rst=1; @(posedge clk); #1; rst=0;
req=4'b1111; lock=1; step; // grant0 arm hold
req=4'b1110; lock=1; step; // req0 low -> dead air, gv0
step; // resume past0 -> grant1, lock high re-arm
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb.out /tmp/tb.sv /app/dut.sv && vvp /tmp/tb.out-- all four asking (expect 0,1,2,3,0) -- t=16 req=1111 lock=0 -> grant=0010 gv=1 t=26 req=1111 lock=0 -> grant=0100 gv=1 t=36 req=1111 lock=0 -> grant=1000 gv=1 t=46 req=1111 lock=0 -> grant=0001 gv=1 t=56 req=1111 lock=0 -> grant=0010 gv=1 -- lone requester 2 keeps winning -- t=66 req=0100 lock=0 -> grant=0100 gv=1 t=76 req=0100 lock=0 -> grant=0100 gv=1 -- lock hold on req1 -- t=86 req=1111 lock=1 -> grant=1000 gv=1 -- now hold whoever, drop others -- t=106 req=1111 lock=1 -> grant=0001 gv=1 t=116 req=1111 lock=1 -> grant=0001 gv=1 t=126 req=1111 lock=1 -> grant=0001 gv=1 t=136 req=1111 lock=0 -> grant=0010 gv=1 t=146 req=1111 lock=0 -> grant=0100 gv=1 -- dead air: hold on 0 then req0 low -- t=166 req=1111 lock=1 -> grant=0001 gv=1 t=176 req=1110 lock=1 -> grant=0010 gv=1 t=186 req=1110 lock=1 -> grant=0010 gv=1 /tmp/tb.sv:29: $finish called at 186 (1s) [stdout] -- all four asking (expect 0,1,2,3,0) -- t=16 req=1111 lock=0 -> grant=0010 gv=1 t=26 req=1111 lock=0 -> grant=0100 gv=1 t=36 req=1111 lock=0 -> grant=1000 gv=1 t=46 req=1111 lock=0 -> grant=0001 gv=1 t=56 req=1111 lock=0 -> grant=0010 gv=1 -- lone requester 2 keeps winning -- t=66 req=0100 lock=0 -> grant=0100 gv=1 t=76 req=0100 lock=0 -> grant=0100 gv=1 -- lock hold on req1 -- t=86 req=1111 lock=1 -> grant=1000 gv=1 -- now hold whoever, drop others -- t=106 req=1111 lock=1 -> grant=0001 gv=1 t=116 req=1111 lock=1 -> grant=0001 gv=1 t=126 req=1111 lock=1 -> grant=0001 gv=1 t=136 req=1111 lock=0 -> grant=0010 gv=1 t=146 req=1111 lock=0 -> grant=0100 gv=1 -- dead air: hold on 0 then req0 low -- t=166 req=1111 lock=1 -> grant=0001 gv=1 t=176 req=1110 lock=1 -> grant=0010 gv=1 t=186 req=1110 lock=1 -> grant=0010 gv=1 /tmp/tb.sv:29: $finish called at 186 (1s)
Self-test sampling combinational output per cycle
cat > /tmp/tb2.sv <<'EOF'
module tb;
reg clk=0, rst; reg [3:0] req; reg lock;
wire [3:0] grant; wire grant_valid;
TopModule d(.clk(clk),.rst(rst),.req(req),.lock(lock),.grant(grant),.grant_valid(grant_valid));
always #5 clk=~clk;
// drive at negedge, sample the combinational output for this cycle, then let posedge advance state
task cyc(input [3:0] r, input l); begin
@(negedge clk); req=r; lock=l; #1;
$display("req=%b lock=%b -> grant=%b gv=%b",req,lock,grant,grant_valid);
end endtask
initial begin
rst=1; req=0; lock=0; @(negedge clk); #1; @(posedge clk); rst=0;
$display("-- all four (expect 0,1,2,3,0) --");
cyc(4'b1111,0);cyc(4'b1111,0);cyc(4'b1111,0);cyc(4'b1111,0);cyc(4'b1111,0);
$display("-- lone requester 2 --");
cyc(4'b0100,0);cyc(4'b0100,0);
$display("-- lock hold on 0, then drop --");
@(negedge clk); rst=1; @(posedge clk); rst=0;
cyc(4'b1111,1); // grant0 arm hold
cyc(4'b1111,1); // held 0
cyc(4'b1111,1); // held 0
cyc(4'b1111,0); // lock drops: still grant0, resume past0
cyc(4'b1111,0); // grant1
cyc(4'b1111,0); // grant2
$display("-- dead air --");
@(negedge clk); rst=1; @(posedge clk); rst=0;
cyc(4'b1111,1); // grant0 arm hold
cyc(4'b1110,1); // req0 low -> dead air gv0
cyc(4'b1110,1); // resume past0 -> grant1, re-arm
cyc(4'b1110,1); // held1
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb2.out /tmp/tb2.sv /app/dut.sv && vvp /tmp/tb2.out-- all four (expect 0,1,2,3,0) -- req=1111 lock=0 -> grant=0001 gv=1 req=1111 lock=0 -> grant=0010 gv=1 req=1111 lock=0 -> grant=0100 gv=1 req=1111 lock=0 -> grant=1000 gv=1 req=1111 lock=0 -> grant=0001 gv=1 -- lone requester 2 -- req=0100 lock=0 -> grant=0100 gv=1 req=0100 lock=0 -> grant=0100 gv=1 -- lock hold on 0, then drop -- req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=0 -> grant=1000 gv=1 req=1111 lock=0 -> grant=0001 gv=1 req=1111 lock=0 -> grant=0010 gv=1 -- dead air -- req=1111 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 /tmp/tb2.sv:31: $finish called at 201 (1s) [stdout] -- all four (expect 0,1,2,3,0) -- req=1111 lock=0 -> grant=0001 gv=1 req=1111 lock=0 -> grant=0010 gv=1 req=1111 lock=0 -> grant=0100 gv=1 req=1111 lock=0 -> grant=1000 gv=1 req=1111 lock=0 -> grant=0001 gv=1 -- lone requester 2 -- req=0100 lock=0 -> grant=0100 gv=1 req=0100 lock=0 -> grant=0100 gv=1 -- lock hold on 0, then drop -- req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=1 -> grant=1000 gv=1 req=1111 lock=0 -> grant=1000 gv=1 req=1111 lock=0 -> grant=0001 gv=1 req=1111 lock=0 -> grant=0010 gv=1 -- dead air -- req=1111 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 req=1110 lock=1 -> grant=1000 gv=1 /tmp/tb2.sv:31: $finish called at 201 (1s)
Probe internal state during lock test
cat > /tmp/tb3.sv <<'EOF'
module tb;
reg clk=0, rst; reg [3:0] req; reg lock;
wire [3:0] grant; wire grant_valid;
TopModule d(.clk(clk),.rst(rst),.req(req),.lock(lock),.grant(grant),.grant_valid(grant_valid));
always #5 clk=~clk;
task cyc(input [3:0] r, input l); begin
@(negedge clk); req=r; lock=l; #1;
$display("req=%b lock=%b -> grant=%b gv=%b | last=%0d held=%b hidx=%0d",
req,lock,grant,grant_valid,d.last,d.held,d.held_idx);
end endtask
task doreset; begin @(negedge clk); rst=1; @(posedge clk); #1; rst=0; end endtask
initial begin
rst=1; req=0; lock=0; @(posedge clk); #1; rst=0;
$display("-- lock hold on 0, then drop --");
doreset;
cyc(4'b1111,1);
cyc(4'b1111,1);
cyc(4'b1111,0);
cyc(4'b1111,0);
cyc(4'b1111,0);
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb3.out /tmp/tb3.sv /app/dut.sv && vvp /tmp/tb3.out-- lock hold on 0, then drop -- req=1111 lock=1 -> grant=0001 gv=1 | last=3 held=0 hidx=0 req=1111 lock=1 -> grant=0001 gv=1 | last=3 held=1 hidx=0 req=1111 lock=0 -> grant=0001 gv=1 | last=3 held=1 hidx=0 req=1111 lock=0 -> grant=0010 gv=1 | last=0 held=0 hidx=0 req=1111 lock=0 -> grant=0100 gv=1 | last=1 held=0 hidx=0 /tmp/tb3.sv:21: $finish called at 61 (1s) [stdout] -- lock hold on 0, then drop -- req=1111 lock=1 -> grant=0001 gv=1 | last=3 held=0 hidx=0 req=1111 lock=1 -> grant=0001 gv=1 | last=3 held=1 hidx=0 req=1111 lock=0 -> grant=0001 gv=1 | last=3 held=1 hidx=0 req=1111 lock=0 -> grant=0010 gv=1 | last=0 held=0 hidx=0 req=1111 lock=0 -> grant=0100 gv=1 | last=1 held=0 hidx=0 /tmp/tb3.sv:21: $finish called at 61 (1s)
Verify dead-air and lock-with-no-grant
cat > /tmp/tb4.sv <<'EOF'
module tb;
reg clk=0, rst; reg [3:0] req; reg lock;
wire [3:0] grant; wire grant_valid;
TopModule d(.clk(clk),.rst(rst),.req(req),.lock(lock),.grant(grant),.grant_valid(grant_valid));
always #5 clk=~clk;
task cyc(input [3:0] r, input l); begin
@(negedge clk); req=r; lock=l; #1;
$display("req=%b lock=%b -> grant=%b gv=%b",req,lock,grant,grant_valid);
end endtask
task doreset; begin @(negedge clk); rst=1; @(posedge clk); #1; rst=0; end endtask
initial begin
rst=1; req=0; lock=0; @(posedge clk); #1; rst=0;
$display("-- dead air: hold on 0, then req0 drops (lock still high) --");
doreset;
cyc(4'b1111,1); // grant0, arm hold
cyc(4'b1110,1); // req0 low while held -> dead air
cyc(4'b1110,1); // resume past0 -> grant1, lock high re-arms
cyc(4'b1110,1); // held on 1
$display("-- lock with no grant does nothing --");
doreset;
cyc(4'b0000,1); // nobody asks, lock high
cyc(4'b1111,0); // should be grant0 (place kept)
$finish;
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb4.out /tmp/tb4.sv /app/dut.sv && vvp /tmp/tb4.out-- dead air: hold on 0, then req0 drops (lock still high) -- req=1111 lock=1 -> grant=0001 gv=1 req=1110 lock=1 -> grant=0000 gv=0 req=1110 lock=1 -> grant=0010 gv=1 req=1110 lock=1 -> grant=0010 gv=1 -- lock with no grant does nothing -- req=0000 lock=1 -> grant=0000 gv=0 req=1111 lock=0 -> grant=0001 gv=1 /tmp/tb4.sv:23: $finish called at 81 (1s) [stdout] -- dead air: hold on 0, then req0 drops (lock still high) -- req=1111 lock=1 -> grant=0001 gv=1 req=1110 lock=1 -> grant=0000 gv=0 req=1110 lock=1 -> grant=0010 gv=1 req=1110 lock=1 -> grant=0010 gv=1 -- lock with no grant does nothing -- req=0000 lock=1 -> grant=0000 gv=0 req=1111 lock=0 -> grant=0001 gv=1 /tmp/tb4.sv:23: $finish called at 81 (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.vA5jSn/runtime/cb_verifier_337-25257-4370-4310_337/results.jsonl"}Reproduce this trial: git checkout 2f94510 && PYTHONPATH=src python3 scripts/build_site.py , then open trial/trial_4f11083e74914b7e. Re-running the agent live requires EVAL_PLATFORM_ENABLE_OAUTH_SMOKE=1 and is non-deterministic.
Trial trial_4f11083e74914b7e · verifier authoritative; classifier explanatory.