Programmable Logic Controllers (PLCs) are responsible for automating process control in many industrial systems (e.g. in manufacturing and public infrastructure), and thus it is critical to ensure that they operate correctly and safely. The majority of PLCs are programmed in languages such as Structured Text (ST). However, a lack of formal semantics makes it difficult to ascertain the correctness of their translators and compilers, which vary from vendor-to-vendor. In this work, we develop K-ST, a formal executable semantics for ST in the K framework. Defined with respect to the IEC 61131-3 standard and PLC vendor manuals, K-ST is a high-level reference semantics that can be used to evaluate the correctness and consistency of different ST implementations. We validate K-ST by executing 509 ST programs extracted from Github and comparing the results against existing commercial compilers (i.e., CODESYS, CX-Programmer, and GX Works2). We then apply K-ST to validate the implementation of the open source OpenPLC platform, comparing the executions of several test programs to uncover five bugs and nine functional defects in the compiler.
翻译:可编程的逻辑控制器(PLC)负责许多工业系统(例如制造业和公共基础设施)的流程控制自动化,因此,确保这些系统运行正确和安全至关重要。大多数PLC都用结构文本等语言编程。然而,由于缺乏正式的语义,难以确定其翻译员和编译员的正确性,这与供应商与供应商之间的差异不同。在这项工作中,我们开发了KST,这是K框架中ST的正式可执行语义。根据IEC 61131-3标准和PLC供应商手册的定义,KST是一种高层次的参考语义,可用于评价不同ST执行的正确性和一致性。我们通过执行从Github提取的509个ST程序,对照现有的商业编译员(即CODES、CX-Programer和GXWork)对结果进行比较,从而验证开放源的 OpenPLC 平台的实施情况,将一些功能性缺陷的处决与9个测试程序进行对比。