Spaces:
Sleeping
Sleeping
CRITICAL: Fix boundary score in reset() and re-enforce 0.02-0.98 bounds across all grading paths
1c425c6 Download test.html from cybertronak/rtlrepair-env: direct link, hf CLI and curl.
- Browser
- Download file 28 kB
-
https://huggingface.co/spaces/cybertronak/rtlrepair-env/resolve/main/test.html
- Command line
-
hf download hf://spaces/cybertronak/rtlrepair-env/test.html
-
curl -L -o test.html https://huggingface.co/spaces/cybertronak/rtlrepair-env/resolve/main/test.html
28 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>RTLRepair | Live Hardware Debugger</title> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet"> | |
| <style> | |
| :root { | |
| --p:#6366f1; --bg:#0b0f1a; --c:#161b2c; --c2:#1e2537; | |
| --t:#f8fafc; --acc:#38bdf8; --g:#4ade80; --r:#fb7185; --y:#fbbf24; | |
| } | |
| * { box-sizing: border-box; margin: 0; padding: 0; } | |
| body { background:var(--bg); color:var(--t); font-family:'Inter',sans-serif; padding:2rem; } | |
| .hero { text-align:center; margin-bottom:3rem; } | |
| .hero h1 { font-size:2.8rem; font-weight:800; color:var(--acc); } | |
| .hero p { opacity:.6; margin-top:.5rem; } | |
| .badge { display:inline-block; margin-top:1rem; font-size:.75rem; | |
| background:rgba(99,102,241,.15); padding:.3rem 1rem; | |
| border-radius:9999px; border:1px solid var(--p); } | |
| .task-panel { background:var(--c); border:1px solid rgba(255,255,255,.08); | |
| border-radius:1.5rem; padding:2rem; margin-bottom:2.5rem; } | |
| .task-header { display:flex; justify-content:space-between; align-items:flex-start; | |
| margin-bottom:1.5rem; gap:1rem; flex-wrap:wrap; } | |
| .task-title h2 { font-size:1.3rem; font-weight:700; } | |
| .task-title p { opacity:.5; font-size:.85rem; margin-top:.2rem; } | |
| .btn-group { display:flex; gap:.5rem; flex-wrap:wrap; } | |
| .btn { padding:.5rem 1.1rem; border-radius:.7rem; font-weight:700; | |
| font-size:.82rem; cursor:pointer; border:none; transition:.15s; } | |
| .btn:hover { transform:scale(1.04); filter:brightness(1.1); } | |
| .btn-broken { background:rgba(255,255,255,.1); color:var(--t); | |
| border:1px solid rgba(255,255,255,.2); } | |
| .btn-fixed { background:var(--p); color:#fff; } | |
| .btn-run { background:var(--acc); color:#000; } | |
| .editor-grid { display:grid; grid-template-columns:1fr 1fr; gap:1rem; | |
| margin-bottom:1rem; } | |
| .editor-box { display:flex; flex-direction:column; gap:.4rem; } | |
| .editor-box label { font-size:.7rem; font-weight:700; opacity:.5; | |
| text-transform:uppercase; letter-spacing:.05em; } | |
| textarea.verilog-editor { | |
| background:#000; color:#e2e8f0; border:1px solid rgba(255,255,255,.1); | |
| border-radius:.8rem; padding:1rem; font-family:'JetBrains Mono',monospace; | |
| font-size:.78rem; resize:vertical; min-height:180px; outline:none; | |
| transition:border .2s; | |
| } | |
| textarea.verilog-editor:focus { border-color:var(--p); } | |
| .log-panel { background:#05070a; border:1px solid #1e2537; border-radius:1rem; | |
| padding:1.2rem; margin-top:1rem; display:none; } | |
| .log-header { display:flex; justify-content:space-between; align-items:center; | |
| font-size:.7rem; font-weight:700; opacity:.4; | |
| text-transform:uppercase; margin-bottom:.8rem; } | |
| .log-scroll { max-height:320px; overflow-y:auto; padding-right:.4rem; } | |
| .log-scroll::-webkit-scrollbar { width:4px; } | |
| .log-scroll::-webkit-scrollbar-track { background:transparent; } | |
| .log-scroll::-webkit-scrollbar-thumb { background:var(--p); border-radius:2px; } | |
| .log-body { font-family:'JetBrains Mono',monospace; font-size:.78rem; | |
| white-space:pre-wrap; line-height:1.7; } | |
| .fix-tip { margin-top:.8rem; padding:.6rem 1rem; background:rgba(251,191,36,.1); | |
| border:1px solid var(--y); border-radius:.6rem; font-size:.78rem; | |
| color:var(--y); display:none; } | |
| .score-badge { display:inline-block; font-family:'JetBrains Mono'; font-weight:700; | |
| padding:.25rem .75rem; border-radius:.4rem; font-size:.9rem; | |
| margin-bottom:.5rem; } | |
| .score-pass { background:var(--g); color:#000; } | |
| .score-fail { background:var(--r); color:#fff; } | |
| .score-warn { background:var(--y); color:#000; } | |
| .btn-ai { background:linear-gradient(135deg,#7c3aed,#6366f1); color:#fff; } | |
| .btn-ai:disabled { opacity:.5; cursor:not-allowed; } | |
| @media(max-width:700px) { | |
| .editor-grid { grid-template-columns:1fr; } | |
| .task-header { flex-direction:column; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="hero"> | |
| <h1>π οΈ RTLRepair Platform</h1> | |
| <p>Interactive Hardware Bug Diagnosis & Live Simulation Benchmark</p> | |
| <div class="badge">π‘ <b>LIVE:</b> Edit any module and click Run to grade in real-time</div> | |
| </div> | |
| <!-- βββ EASY βββ --> | |
| <div class="task-panel"> | |
| <div class="task-header"> | |
| <div class="task-title"> | |
| <h2>Level 01: 4-bit Synchronous Counter</h2> | |
| <p>Syntax & Port Sensitivities β 5 test vectors</p> | |
| </div> | |
| <div class="btn-group"> | |
| <button class="btn btn-broken" onclick="loadPreset('easy','broken')">Load Broken</button> | |
| <button class="btn btn-fixed" onclick="loadPreset('easy','fixed')">Load Solution</button> | |
| <button class="btn btn-run" onclick="runGrade('easy')">▶ Run & Grade</button> | |
| <button class="btn btn-ai" id="ai-btn-easy" onclick="autoFix('easy')">🤖 Auto-Fix</button> | |
| </div> | |
| </div> | |
| <div class="editor-grid"> | |
| <div class="editor-box"> | |
| <label>βοΈ Your Verilog (editable)</label> | |
| <textarea class="verilog-editor" id="code-easy">// easy/broken.v | |
| // Task: 4-bit synchronous counter with synchronous reset | |
| // BUGS INJECTED (3 total): | |
| // 1. Line 10: output port declared as 'input' instead of 'output' | |
| // 2. Line 18: undeclared wire 'carry' used but never declared | |
| // 3. Line 20: sensitivity list uses 'negedge' instead of 'posedge' | |
| // | |
| // The agent must fix all 3 bugs so the module compiles and simulates correctly. | |
| module counter_4bit ( | |
| input wire clk, | |
| input wire rst, // synchronous reset, active high | |
| input wire [3:0] count // BUG 1: should be 'output reg [3:0] count' | |
| ); | |
| always @(negedge clk) begin // BUG 3: should be 'posedge clk' | |
| if (rst) begin | |
| count <= 4'b0000; | |
| end else begin | |
| count <= count + carry; // BUG 2: 'carry' is undeclared, should be 4'b0001 | |
| end | |
| end | |
| endmodule</textarea> | |
| </div> | |
| <div class="editor-box"> | |
| <label>π Repair Reference (read-only)</label> | |
| <textarea class="verilog-editor" id="ref-easy" readonly style="opacity:.55">// easy/correct.v β reference solution (NOT given to agent) | |
| // Used to generate golden_output.txt | |
| module counter_4bit ( | |
| input wire clk, | |
| input wire rst, | |
| output reg [3:0] count | |
| ); | |
| always @(posedge clk) begin | |
| if (rst) begin | |
| count <= 4'b0000; | |
| end else begin | |
| count <= count + 4'b0001; | |
| end | |
| end | |
| endmodule</textarea> | |
| </div> | |
| </div> | |
| <div class="log-panel" id="log-easy"> | |
| <div class="log-header"> | |
| <span>Simulation Log</span> | |
| <span style="opacity:.5;font-weight:400">Scroll to see all output β</span> | |
| </div> | |
| <div class="log-scroll"> | |
| <div class="log-body" id="log-body-easy"></div> | |
| </div> | |
| <div class="fix-tip" id="fix-tip-easy"> | |
| 💡 <b>Errors detected!</b> Edit the code above and re-run, or click | |
| <b>🤖 Auto-Fix</b> to let the AI repair it automatically. | |
| </div> | |
| </div> | |
| </div> | |
| <!-- βββ MEDIUM βββ --> | |
| <div class="task-panel"> | |
| <div class="task-header"> | |
| <div class="task-title"> | |
| <h2>Level 02: 4-bit ALU Unit</h2> | |
| <p>Behavioral Arithmetic Logic β 10 test vectors</p> | |
| </div> | |
| <div class="btn-group"> | |
| <button class="btn btn-broken" onclick="loadPreset('medium','broken')">Load Broken</button> | |
| <button class="btn btn-fixed" onclick="loadPreset('medium','fixed')">Load Solution</button> | |
| <button class="btn btn-run" onclick="runGrade('medium')">▶ Run & Grade</button> | |
| <button class="btn btn-ai" id="ai-btn-medium" onclick="autoFix('medium')">🤖 Auto-Fix</button> | |
| </div> | |
| </div> | |
| <div class="editor-grid"> | |
| <div class="editor-box"> | |
| <label>βοΈ Your Verilog (editable)</label> | |
| <textarea class="verilog-editor" id="code-medium">// medium/broken.v | |
| // Task: 4-bit ALU supporting ADD, SUB, AND, OR operations | |
| // | |
| // BUGS INJECTED (2 semantic β compiles fine, wrong simulation output): | |
| // 1. SUB operation uses '+' instead of '-' (line 24) | |
| // 2. AND operation uses '|' instead of '&' (line 27) | |
| // | |
| // The module compiles cleanly with iverilog. | |
| // The agent cannot see compile errors β it must deduce bugs from | |
| // simulation output mismatches. | |
| module alu_4bit ( | |
| input wire [3:0] a, | |
| input wire [3:0] b, | |
| input wire [1:0] op, // 00=ADD 01=SUB 10=AND 11=OR | |
| output reg [3:0] result, | |
| output reg zero // 1 when result == 0 | |
| ); | |
| always @(*) begin | |
| case (op) | |
| 2'b00: result = a + b; // ADD β correct | |
| 2'b01: result = a + b; // SUB β BUG 1: should be a - b | |
| 2'b10: result = a | b; // AND β BUG 2: should be a & b | |
| 2'b11: result = a | b; // OR β correct | |
| default: result = 4'b0000; | |
| endcase | |
| zero = (result == 4'b0000) ? 1'b1 : 1'b0; | |
| end | |
| endmodule</textarea> | |
| </div> | |
| <div class="editor-box"> | |
| <label>π Repair Reference (read-only)</label> | |
| <textarea class="verilog-editor" id="ref-medium" readonly style="opacity:.55">// medium/correct.v β reference solution (NOT given to agent) | |
| module alu_4bit ( | |
| input wire [3:0] a, | |
| input wire [3:0] b, | |
| input wire [1:0] op, | |
| output reg [3:0] result, | |
| output reg zero | |
| ); | |
| always @(*) begin | |
| case (op) | |
| 2'b00: result = a + b; | |
| 2'b01: result = a - b; | |
| 2'b10: result = a & b; | |
| 2'b11: result = a | b; | |
| default: result = 4'b0000; | |
| endcase | |
| zero = (result == 4'b0000) ? 1'b1 : 1'b0; | |
| end | |
| endmodule</textarea> | |
| </div> | |
| </div> | |
| <div class="log-panel" id="log-medium"> | |
| <div class="log-header"> | |
| <span>Simulation Log</span> | |
| <span style="opacity:.5;font-weight:400">Scroll to see all output β</span> | |
| </div> | |
| <div class="log-scroll"> | |
| <div class="log-body" id="log-body-medium"></div> | |
| </div> | |
| <div class="fix-tip" id="fix-tip-medium"> | |
| 💡 <b>Errors detected!</b> Edit the code above and re-run, or click | |
| <b>🤖 Auto-Fix</b> to let the AI repair it automatically. | |
| </div> | |
| </div> | |
| </div> | |
| <!-- βββ HARD βββ --> | |
| <div class="task-panel"> | |
| <div class="task-header"> | |
| <div class="task-title"> | |
| <h2>Level 03: Traffic Light FSM</h2> | |
| <p>Finite State Machine Transitions β 20 test vectors</p> | |
| </div> | |
| <div class="btn-group"> | |
| <button class="btn btn-broken" onclick="loadPreset('hard','broken')">Load Broken</button> | |
| <button class="btn btn-fixed" onclick="loadPreset('hard','fixed')">Load Solution</button> | |
| <button class="btn btn-run" onclick="runGrade('hard')">▶ Run & Grade</button> | |
| <button class="btn btn-ai" id="ai-btn-hard" onclick="autoFix('hard')">🤖 Auto-Fix</button> | |
| </div> | |
| </div> | |
| <div class="editor-grid"> | |
| <div class="editor-box"> | |
| <label>βοΈ Your Verilog (editable)</label> | |
| <textarea class="verilog-editor" id="code-hard">// hard/broken.v | |
| // Task: Traffic light FSM controller | |
| // | |
| // States: RED(00) -> GREEN(01) -> YELLOW(10) -> RED(00) -> ... | |
| // Each state holds for N clock cycles (configured via parameter) | |
| // Outputs: red, green, yellow β exactly one HIGH at a time | |
| // | |
| // BUGS INJECTED (3 FSM bugs): | |
| // 1. YELLOW state next-state transition goes to GREEN instead of RED (line 44) | |
| // 2. In GREEN state, the 'green' output is not asserted (missing assign) (line 55) | |
| // 3. Counter reset missing in RED state transition β counter never resets (line 36) | |
| // | |
| // The module compiles. Simulation output will be wrong. | |
| module traffic_light ( | |
| input wire clk, | |
| input wire rst, | |
| output reg red, | |
| output reg green, | |
| output reg yellow | |
| ); | |
| parameter HOLD_CYCLES = 3; | |
| // State encoding | |
| localparam RED_S = 2'b00; | |
| localparam GREEN_S = 2'b01; | |
| localparam YELLOW_S = 2'b10; | |
| reg [1:0] state, next_state; | |
| reg [2:0] counter; // counts cycles in current state | |
| // State register | |
| always @(posedge clk) begin | |
| if (rst) begin | |
| state <= RED_S; | |
| counter <= 3'd0; | |
| end else begin | |
| if (counter == HOLD_CYCLES - 1) begin | |
| state <= next_state; | |
| // BUG 3: counter <= 3'd0 is missing here | |
| end else begin | |
| counter <= counter + 3'd1; | |
| end | |
| end | |
| end | |
| // Next state logic | |
| always @(*) begin | |
| case (state) | |
| RED_S: next_state = GREEN_S; | |
| GREEN_S: next_state = YELLOW_S; | |
| YELLOW_S: next_state = GREEN_S; // BUG 1: should be RED_S | |
| default: next_state = RED_S; | |
| endcase | |
| end | |
| // Output logic | |
| always @(*) begin | |
| red = 1'b0; | |
| green = 1'b0; | |
| yellow = 1'b0; | |
| case (state) | |
| RED_S: red = 1'b1; | |
| GREEN_S: green = 1'b0; // BUG 2: should be green = 1'b1 | |
| YELLOW_S: yellow = 1'b1; | |
| default: red = 1'b1; | |
| endcase | |
| end | |
| endmodule</textarea> | |
| </div> | |
| <div class="editor-box"> | |
| <label>π Repair Reference (read-only)</label> | |
| <textarea class="verilog-editor" id="ref-hard" readonly style="opacity:.55">// hard/correct.v β reference solution (NOT given to agent) | |
| module traffic_light ( | |
| input wire clk, | |
| input wire rst, | |
| output reg red, | |
| output reg green, | |
| output reg yellow | |
| ); | |
| parameter HOLD_CYCLES = 3; | |
| localparam RED_S = 2'b00; | |
| localparam GREEN_S = 2'b01; | |
| localparam YELLOW_S = 2'b10; | |
| reg [1:0] state, next_state; | |
| reg [2:0] counter; | |
| always @(posedge clk) begin | |
| if (rst) begin | |
| state <= RED_S; | |
| counter <= 3'd0; | |
| end else begin | |
| if (counter == HOLD_CYCLES - 1) begin | |
| state <= next_state; | |
| counter <= 3'd0; // fixed: counter resets on transition | |
| end else begin | |
| counter <= counter + 3'd1; | |
| end | |
| end | |
| end | |
| always @(*) begin | |
| case (state) | |
| RED_S: next_state = GREEN_S; | |
| GREEN_S: next_state = YELLOW_S; | |
| YELLOW_S: next_state = RED_S; // fixed: back to RED | |
| default: next_state = RED_S; | |
| endcase | |
| end | |
| always @(*) begin | |
| red = 1'b0; | |
| green = 1'b0; | |
| yellow = 1'b0; | |
| case (state) | |
| RED_S: red = 1'b1; | |
| GREEN_S: green = 1'b1; // fixed: assert green | |
| YELLOW_S: yellow = 1'b1; | |
| default: red = 1'b1; | |
| endcase | |
| end | |
| endmodule</textarea> | |
| </div> | |
| </div> | |
| <div class="log-panel" id="log-hard"> | |
| <div class="log-header"> | |
| <span>Simulation Log</span> | |
| <span style="opacity:.5;font-weight:400">Scroll to see all output β</span> | |
| </div> | |
| <div class="log-scroll"> | |
| <div class="log-body" id="log-body-hard"></div> | |
| </div> | |
| <div class="fix-tip" id="fix-tip-hard"> | |
| 💡 <b>Errors detected!</b> Edit the code above and re-run, or click | |
| <b>🤖 Auto-Fix</b> to let the AI repair it automatically. | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| </script> | |
| </body> | |
| </html> |