Skip to content

Generate Functional Mock-up Unit (FMU) from statecharts

The Functional Mock-up Interface (FMI) standard addresses the exchange and joint execution of models for co-simulation. It mainly is applied for system level simulation of complex systems. CREATE Statecharts can be exported as Functional Mock-up Units (FMUs) and as such can participate in FMI based simulations. As FMUs provide binary executables and only bundle source code or models as an option FMUs can be provided to other parties without exposing inellectual property. Concretely itemis CREATE supports FMI 2.0 for Co-Simulation FMU export. By the support of the FMI standard CREATE Statecharts are interoperable with a wide range of simulation tools .


The FMU export is implemented by a itemis CREATE code generator. The generator supports building FMUs for Windows, Linux and MacOS 64Bit platforms. The generator builds a complete FMU and relies on Eclipse C development infrastructure. So as a precondition you have to make sure that CDT features are installed. For Windows platform the Cygwin toolchain must be installed.

If the code generator is not yet installed then simply install the “ itemis CREATE FMU Code Generator”. Follow the steps in How to Install More Code Generators .

Setting up the FMU generator

If everything is in place a FMU can be created in a few simple steps:

  • Create a C project within your workspace. Ensure the C nature is set for the project.
  • Choose an existing or create a new statechart. To create a new one:
    • Right-click on your project, select New -> Other -> itemis CREATE -> Statechart Model.
    • Choose between Default Domain or C/C++ Domain.
  • Create a code generator model
    • Right-click on your project, select New -> Other -> itemis CREATE -> Code generator model.
    • Enter a filename for the .sgen file and select Next.
    • Choose itemis CREATE FMU Code Generator from the dropdown menu and tick the statechart you previously created.
    • The generated .sgen file should have the following content. If not, modify it accordingly. Replace ‘machine’ by the name of your statechart and replace ‘example’ by the name of your target project. The target project may be different from the project in which the statechart is located.
GenenratorModel for yakindu::c::fmu {
    statechart machine {
        feature Outlet {
            targetProject =  "example"
            targetFolder =  "src"
  • Now generate the .fmu file by right-click on the .sgen file and select Generate Code Artifacts.
    • The internal build of your project should be triggered, indicating that the target FMU has been built successfully into the Debug/Release folder of your project.
    • Due to convention the .fmu file will always be named according to your project name.
    • Copy this FMU file to deploy it to your FMI compatible simulation environment.

Mapping between statechart and FMU concepts

The generated FMU includes a XML based descriptor which defines the elements which are visible in the FMUs interface. This descriptor is derived from the statechart’s interface by applying standard mapping rules. Currently, the FMU generator has the following functional constraints:

  • only variables defined in the statechart interface are exposed to FMI
  • time events are mapped to FMIs time event concept
  • the statechart should be defined as @CycleBased(period) with a proper cycle period
  • integer, real and boolean types are supported
  • no statechart events are mapped, which implies the need for cycle based execution schema
  • no statechart states are mapped

It is planned to support statechart events and state mapping in future versions of the generator.

All variables you declare in your statechart will be used as FMU input variables by default. To define FMU output variables you need to specify the readonly modifier for the variable. Here is an example for declaring FMU input/output variables:

Default Domain:

interface IO:
var x: integer = 0 		//input variable
var y: boolean = true 		//input variable
var readonly z: real = 5.2 	//output variable

C/C++ Domain:

interface IO:
var x: int8_t = 0 		//input variable
var y: bool = true 		//input variable
var readonly z: double = 5.2 	//output variable


For a quick start simply install the following example: FMU Generator Example