JuliaCon 2025

JuliaC for Model-Based Engineering
2025-07-24 , Main Room 1 (Main stage)

We demonstrate how recent compiler developments allow users of Julia and the equation-based modeling language ModelingToolkit to compile and deploy binaries for real-time model-based estimation and control. Contrary to the approach taken by a majority of modeling-and simulation tools, we do not generate C code, and instead demonstrate how we may use the native Julia code-generation pipeline.


Model-based engineering (MBE) has emerged as a cornerstone of modern engineering, enabling the efficient design, analysis, and deployment of complex systems. By representing systems as mathematical or graphical models, engineers can simulate, test, and validate designs prior to physical implementation, reducing development time and cost. Central to the MBE workflow is the use of high-level modeling languages to describe systems, followed by the automatic generation of low-level C-code for deployment on embedded hardware or other real-time systems.

Although this workflow has proven highly effective, it presents several issues. Code-generation capabilities often come with a significant price tag, presenting a financial incentive to find competitive alternatives. Furthermore, high-level modeling languages with code-generation capabilities often impose restrictions on expressiveness to ensure compatibility with C-code generation, such as limitations on which functions may be called, use of variable-sized arrays, and use of flexible data structures, operator overloading, and arrays of objects. Additionally, integrating preexisting libraries or leveraging cutting-edge algorithms and hardware accelerators in these environments can be cumbersome, as it requires significant manual effort to make them code-generation compatible or the hardware support is missing etc. These limitations can hinder the pace of development and stifle innovation, particularly in domains that require flexibility or powerful computing.

Historically, Julia lacked support for compiling small, standalone binaries or shared libraries, a feature critical for deploying code to resource-constrained environments such as embedded systems. Recent advancements in Julia’s compiler technology have stared addressing this gap, enabling an alternative approach to MBSE workflows. In this talk, we demonstrate how these developments, combined with the ModelingToolkit equation-based (acausal) modeling framework, enable the compilation and deployment of Julia programs directly to the target system without relying on C-code generation. By leveraging Julia's native code generation pipeline, we eliminate the restrictions typically imposed by traditional workflows, offering greater flexibility and enabling the use of Julia's rich ecosystem of already existing libraries. To illustrate this capability, we design a simple equation-based model and a nonlinear state estimator, compile the resulting program, and deploy it on a Raspberry Pi for real-time state estimation. We also convert a Julia package implementing PID controllers into a C-callable shared library.

Fredrik received his MSc and Ph.D. from Dept. Automatic Control at Lund University. He has a background in robotics and an interest in developing software tools for control, identification, and simulation, and is a co author of the JuliaControl suite of software for analysis and design of control systems in the Julia programming language. He is currently leading the control-systems team at JuliaHub, developing tools for model-based design and deployment of control systems.