Compilation Is Not Correctness: Scan-by-Scan Evaluation of LLM-Generated PLC Programs
Jinyun Chen, Juntao Hu, Haochen Li, Wentao Song, Ningbo Gu, Jianwei Niu, Qing Gao, Rui Wang
Key points
From the paper's conclusion- We introduce CycleBench, a benchmark of 301 ST tasks with behavioral requirements, public interfaces, reference programs, and executable scenarios.
Abstract
Programmable logic controllers (PLCs) automate industrial processes through repeated scans, each reading inputs, executing control logic, and updating outputs. Engineers write this logic in Structured Text (ST), a high-level textual language defined in IEC 61131-3. Large language models (LLMs) can now generate ST from natural-language requirements, yet compilation success and checks on selected properties or sampled scans can leave behavioral errors undetected. We introduce CycleBench, a benchmark of 301 ST tasks with behavioral requirements, public interfaces, reference programs, and executable scenarios. Its runtime executes each generated program and its reference under aligned inputs, initialization, and logical time, comparing their outputs after every scan. Across eight LLMs and baseline generation methods, execution pass rate trails compilation pass rate by 11.92 percentage points; observed failures include output-update, arithmetic, and timing errors. On fixed traces of programs directly generated by five LLMs, checking outputs only at every fifth scan misses 21.66% of the 157 failures detected by per-scan comparison; across sampling phases, the missed-failure rate ranges from 12.10% to 28.03%. These misses stem from transient output discrepancies, whose detection depends on the sampling phase. Building on this evaluation, we propose CycleGen, which generates multiple candidate ST programs, repairs their compilation errors with bounded compiler feedback, and selects one using runtime self-tests generated in a separate model context. CycleGen improves the execution pass rate over direct generation by 8.68 percentage points. Component ablations distinguish repair and self-test selection; candidate-count analysis shows diminishing returns, with no execution-pass-rate improvement beyond five candidates in our experiments despite 38.8% higher token consumption at eight.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Trace2ST: Recovering PLC Structured Text from I/O Traces with LLM Generation and VerificationarXiv · 2026
- SemaPLC: A Project-Grounded, Verification-Gated Agent Harness for PLC Code GenerationarXiv · 2026
- PLCWorld: Benchmarking LLM-Generated PLC Programs in Closed-Loop Plant SimulationarXiv · 2026
- Agents4PLC: Automating Closed-Loop PLC Code Generation and Verification in Industrial Control Systems Using LLM-Based AgentsIEEE Transactions on Software Engineering · 2026
- Beyond Compilation with Runtime Diagnosis and Repair of Function Block Diagrams Generated by LLMsElectronics · 2026
- Benchmarking and validation of prompting techniques for AI-assisted industrial PLC programmingMachine Learning with Applications · 2025