Beyond Compilation with Runtime Diagnosis and Repair of Function Block Diagrams Generated by LLMs
Qunxin Liu, Jun Lin, Hao Yuan, Yue Liu, Yuyi Wang
Key points
From the paper's conclusion- We present a runtime diagnosis and repair pipeline that connects a topology with typed pins, PLCopen XML import, CODESYS compilation, and SoftPLC execution.
Abstract
Function Block Diagrams (FBDs) generated by large language models (LLMs) can compile in an industrial integrated development environment (IDE) while still violating the intended control behavior. We present a runtime diagnosis and repair pipeline that connects a topology with typed pins, PLCopen XML import, CODESYS compilation, and SoftPLC execution. The pipeline returns structured compilation diagnostics and runtime state observations that guide localized repair. Across a benchmark of 20 cases, the full configuration achieves 20/20 compilations on the first pass, compared with 8/20 without retrieval and 5/20 for a naive baseline. Repair raises the setting without retrieval to 13/20 within five attempts. The ablation shows that retrieved function block interfaces are the main driver of first pass compilation, while repair provides complementary recovery. For runtime evidence, a compiled pump cascade program initially passed 2 of 6 diagnostic assertions. After two cycles of diagnosis and repair, it passed all 18 assertions in an expanded final verification suite. Across the benchmark suite, 118/118 executed assertions derived from requirements were satisfied after repair. A targeted defect injection study detected 7/8 defects not visible at compilation across four mechanisms. These results demonstrate a practical path for compiling, testing, and repairing control logic generated through FBD workflows.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Compilation Is Not Correctness: Scan-by-Scan Evaluation of LLM-Generated PLC ProgramsarXiv · 2026
- Trace2ST: Recovering PLC Structured Text from I/O Traces with LLM Generation and VerificationarXiv · 2026
- Agents4PLC: Automating Closed-Loop PLC Code Generation and Verification in Industrial Control Systems Using LLM-Based AgentsIEEE Transactions on Software Engineering · 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
- Simple Test-Time Refinement for Plot-to-Code Generation via Visual-Code DiagnosticsarXiv · 2026