tests/test.sh exit code (0 → resolved); the classification below is post-hoc and cannot change it.// UART receiver with break detection and post-break framing-error propagation.
module TopModule #(
parameter BITLEN = 16
) (
input logic clk,
input logic rst,
input logic rx_i,
output logic [7:0] data_o,
output logic valid_o,
output logic frame_err_o,
output logic break_o
);
localparam int HALF = BITLEN/2; // floored half bit period
localparam int SIXBIT = 6*BITLEN; // six continuous bit periods
// synchronizer (two flops); sync1 is "the synchronized line"
logic sync0, sync1;
// FSM states
localparam logic [1:0] S_IDLE = 2'd0; // waiting for a start edge
localparam logic [1:0] S_RECV = 2'd1; // sampling data + stop bits
localparam logic [1:0] S_BREAK = 2'd2; // break asserted, line held low
localparam logic [1:0] S_RECOVER = 2'd3; // after break, waiting 6 high periods
logic [1:0] state;
// continuous low / high run lengths on the synchronized line
logic [31:0] low_run, high_run;
// per-bit sample counter and bit index within a frame
logic [31:0] samp_cnt;
logic [3:0] bit_idx; // 0..7 = data bits, 8 = stop bit
logic [7:0] data_reg;
// pending forced-framing-error count (d from the interrupting break)
logic [3:0] pend_cnt;
always_ff @(posedge clk) begin : main
logic [31:0] cur_low;
logic [31:0] cur_high;
if (rst) begin
sync0 <= 1'b1;
sync1 <= 1'b1;
state <= S_IDLE;
low_run <= 32'd0;
high_run <= 32'd0;
samp_cnt <= 32'd0;
bit_idx <= 4'd0;
data_reg <= 8'd0;
pend_cnt <= 4'd0;
data_o <= 8'd0;
valid_o <= 1'b0;
frame_err_o <= 1'b0;
break_o <= 1'b0;
end else begin
// one-cycle pulse outputs default low; break_o is a level (holds)
valid_o <= 1'b0;
frame_err_o <= 1'b0;
// two-flop synchronizer
sync0 <= rx_i;
sync1 <= sync0;
// consecutive low/high run lengths (including the current cycle)
if (sync1 == 1'b0) begin
cur_low = low_run + 32'd1;
cur_high = 32'd0;
end else begin
cur_low = 32'd0;
cur_high = high_run + 32'd1;
end
low_run <= cur_low;
high_run <= cur_high;
// ---- break detection: preempts an idle wait or an in-flight frame ----
if ((state == S_IDLE || state == S_RECV) && (cur_low == SIXBIT)) begin
break_o <= 1'b1;
state <= S_BREAK;
// d = data bits the interrupted byte sampled (0 if no frame)
pend_cnt <= (state == S_RECV) ? bit_idx : 4'd0;
end else begin
case (state)
// idle: accept a start once a fresh low reaches half a bit period
S_IDLE: begin
if (cur_low == HALF) begin
state <= S_RECV;
samp_cnt <= 32'd0;
bit_idx <= 4'd0;
end
end
// receiving: sample each bit at its centre, BITLEN cycles apart
S_RECV: begin
if (samp_cnt == BITLEN-1) begin
samp_cnt <= 32'd0;
if (bit_idx < 4'd8) begin
data_reg[bit_idx] <= sync1; // data bit, LSB first
bit_idx <= bit_idx + 4'd1;
end else begin
// stop bit: deliver the byte
valid_o <= 1'b1;
data_o <= data_reg;
frame_err_o <= (sync1 == 1'b0) || (pend_cnt != 4'd0);
if (pend_cnt != 4'd0)
pend_cnt <= pend_cnt - 4'd1;
state <= S_IDLE;
end
end else begin
samp_cnt <= samp_cnt + 32'd1;
end
end
// break held: wait for the line to return high
S_BREAK: begin
if (sync1 == 1'b1) begin
break_o <= 1'b0;
state <= S_RECOVER;
end
end
// recovery: require six continuous high bit periods; any low restarts
S_RECOVER: begin
if (cur_high >= SIXBIT)
state <= S_IDLE;
end
default: state <= S_IDLE;
endcase
end
end
end
endmodule
Compile/lint the module
(iverilog -g2012 -o /tmp/dut.out dut.sv 2>&1 && echo "iverilog OK") || (verilator --lint-only -Wall dut.sv 2>&1 && echo "verilator OK") || echo "no simulator available"
iverilog OK [stdout] iverilog OK
Run sanity testbench
cat > /tmp/tb.sv <<'EOF'
module tb;
localparam BITLEN=8;
logic clk=0, rst=1, rx=1;
logic [7:0] data; logic valid, ferr, brk;
TopModule #(.BITLEN(BITLEN)) d(.clk,.rst,.rx_i(rx),.data_o(data),.valid_o(valid),.frame_err_o(ferr),.break_o(brk));
always #1 clk=~clk;
task tick; @(posedge clk); #0; endtask
task send_bit(input logic b); integer i; begin rx=b; for(i=0;i<BITLEN;i=i+1) tick; end endtask
task send_byte(input [7:0] v, input logic stop); integer i; begin
send_bit(0); for(i=0;i<8;i=i+1) send_bit(v[i]); send_bit(stop); end endtask
initial begin
repeat(3) tick; rst=0; repeat(3) tick;
// normal byte 0xA5, good stop
send_byte(8'hA5,1'b1);
repeat(4) tick;
// framing error byte: low stop
send_byte(8'h3C,1'b0);
repeat(4) tick;
// break: hold low a long time (>6 bit periods), then high to recover
rx=0; repeat(8*BITLEN) tick;
rx=1; repeat(8*BITLEN) tick;
$finish;
end
always @(posedge clk) begin
if(valid) $display("t=%0t VALID data=%02h ferr=%b",$time,data,ferr);
if(brk) $display("t=%0t BREAK",$time);
end
endmodule
EOF
iverilog -g2012 -o /tmp/tb.out /tmp/tb.sv /app/dut.sv && vvp /tmp/tb.out 2>&1 | sort -u | head -40/tmp/tb.sv:22: $finish called at 603 (1s) t=169 VALID data=a5 ferr=0 t=337 VALID data=3c ferr=1 t=393 BREAK t=395 BREAK t=397 BREAK t=399 BREAK t=401 BREAK t=403 BREAK t=405 BREAK t=407 BREAK t=409 BREAK t=411 BREAK t=413 BREAK t=415 BREAK t=417 BREAK t=419 BREAK t=421 BREAK t=423 BREAK t=425 BREAK t=427 BREAK t=429 BREAK t=431 BREAK t=433 BREAK t=435 BREAK t=437 BREAK t=439 BREAK t=441 BREAK t=443 BREAK t=445 BREAK t=447 BREAK t=449 BREAK t=451 BREAK t=453 BREAK t=455 BREAK t=457 BREAK t=459 BREAK t=461 BREAK t=463 BREAK t=465 BREAK [stdout] /tmp/tb.sv:22: $finish called at 603 (1s) t=169 VALID data=a5 ferr=0 t=337 VALID data=3c ferr=1 t=393 BREAK t=395 BREAK t=397 BREAK t=399 BREAK t=401 BREAK t=403 BREAK t=405 BREAK t=407 BREAK t=409 BREAK t=411 BREAK t=413 BREAK t=415 BREAK t=417 BREAK t=419 BREAK t=421 BREAK t=423 BREAK t=425 BREAK t=427 BREAK t=429 BREAK t=431 BREAK t=433 BREAK t=435 BREAK t=437 BREAK t=439 BREAK t=441 BREAK t=443 BREAK t=445 BREAK t=447 BREAK t=449 BREAK t=451 BREAK t=453 BREAK t=455 BREAK t=457 BREAK t=459 BREAK t=461 BREAK t=463 BREAK t=465 BREAK
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_compiles: PASS (compiled with held-back reference/testbench)
TEST simulation_completed: PASS (Mismatches: 292 in 8633 samples)
TEST reference_equivalence: FAIL (292 mismatches in 8633 samples)
{"score": 0.000000, "results_file": "/tmp/h2t-grader-home.W71W2q/runtime/cb_verifier_314-16540-4670-23273_314/results.jsonl"}Reproduce this trial: git checkout 2f94510 && PYTHONPATH=src python3 scripts/build_site.py , then open trial/trial_3ff9658733384998. Re-running the agent live requires EVAL_PLATFORM_ENABLE_OAUTH_SMOKE=1 and is non-deterministic.
Trial trial_3ff9658733384998 · verifier authoritative; classifier explanatory.