Code Generation

Learn about generating C code from a Super Block.

Attention: Available only with Twin Activate commercial edition.

The Code Generator and Export feature is used to produce C code from a Twin Activate Super Block and capture its dynamic behavior. The generated code can be used for various applications:

  • Creating new blocks: the generated code can be used for the simulation function of a CCustomBlock or a new basic Twin Activate block. These blocks can then replace the original Super Block with better performance and with the possibility to hide its content; withholding the source code of the block provides further IP protection.
  • Exporting to other simulation environments: the Super Block can be exported as a block or a functional unit to other simulation environments such as Altair Embed and PSIM, and a large number of other simulation environments natively or through FMUs based on the FMI standard.
  • Generating standalone applications for Windows and Linux operating systems, and for embedded usages for specific targets such as Arduino.

The software provides two independent code generation technologies. One is closely tied to the Twin Activate simulator, mimicking its behavior by relying on the libraries used by the simulator, in particular the libraries of the simulation functions of the blocks. The other generates specific, compact, and highly efficient code with virtually no dependence on external libraries.

For detailed information on this topic, see Chapter 22: Code Generation and Export in the Extended Definitions for Advanced Users.