Code and Test Generation for I4.0 State Machines with LLM-based Diagram Recognition

Björn Otto, Assanali Aidarkhan, Marko Ristin, Nico Braunisch, Christian Diedrich, Hans Wernher van de Venn, Martin Wollschlaeger · 2025

In the context of Industry 4.0, the automatic code and test generation from state diagrams embedded in specifications is a critical challenge for software correctness. In this paper we present an approach that leverages Large Language Models (LLMs) for the recognition of state diagrams to generate code and unit tests automatically. We compare the performance of LLMs with traditional computer vision models, highlighting the advantages of LLMs in terms of generalization and simplicity of setup. The results on two prominent industrial communication protocols, PROFINET and OPC UA, demonstrate the applicability of the approach, achieving significant reductions in manual effort and improving the accuracy of code and test generation.

Read the paper · More papers on PaperTik