Beyond Compilation with Runtime Diagnosis and Repair of Function Block Diagrams Generated by LLMs
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.
Authors
- Jun Ting Lin (ORCID: https://orcid.org/0000-0003-2760-4333)
- Qunxin Liu
- Yue Liu (ORCID: https://orcid.org/0000-0002-3292-4211)
- Hao Yuan (ORCID: https://orcid.org/0000-0003-0969-1808)
- Yuyi Wang (ORCID: https://orcid.org/0000-0001-7273-9873)
Institutions
- Hunan University (CN)
- China Railway Rolling Stock Corporation Zhuzhou Institute (China) (CN)
Publication Details
- Journal
- Electronics
- Published
- 2026-11-02
- DOI
- https://doi.org/10.3390/electronics15215079
- Primary Topic
- Software Testing and Debugging Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00