Code Generation by Using Embedded Coder
Code Generation Technology
MathWorks® code generation technology produces C or C++ code and executable programs for algorithms. You can write algorithms programmatically by using MATLAB® or graphically in the Simulink® environment. You can generate code for MATLAB functions and Simulink blocks that are useful for real-time and embedded applications. Generated source code and executable programs for floating-point algorithms match the functional behavior of MATLAB code execution and Simulink simulations to a high degree of fidelity. Using the Fixed-Point Designer product, you can generate fixed-point code that provides a bitwise match to model simulation results. Such broad support and high degree of accuracy are possible because code generation is tightly integrated with the MATLAB and Simulink execution and simulation engines. The built-in accelerated simulation modes in Simulink use code generation technology.
When designing components or a complete application in the Simulink environment, you can generate code from your models by using Simulink Coder™ or Embedded Coder®.
Use Simulink Coder to generate code for rapid prototyping and hardware-in-the-loop (HIL) testing of real-time and nonreal-time applications. You can tune and monitor the generated code by using Simulink or run and interact with the code outside of MATLAB and Simulink.
Use Embedded Coder to generate readable, compact, and fast C or C++ code for embedded processors that are used in production. You can apply customizations for controlling the efficiency and appearance of the generated code. For example, you can simply integration by configuring data and function code interfaces and how the code is packaged in files. Embedded Coder provides tools for tuning parameters, analyzing code performance, testing numeric equivalence, and performing code coverage and traceability analysis.
Code generation technology and related products provide tooling that you can apply to the V-model for system development. The V-model is a representation of system development that highlights verification and validation steps in the development process. For more information, see Validation and Verification for System Development.
Code Generation Workflows with Embedded Coder
The Embedded Coder product extends the MATLAB Coder and Simulink Coder products with features that you can use for embedded software development. Using the Embedded Coder product, you can generate code that has the clarity and efficiency of user-written code. For example, you can:
Generate code that is compact and fast, which is essential for real-time simulators, rapid prototyping boards, microprocessors used in mass production, and embedded systems.
Integrate existing applications, functions, and data.
Customize the appearance of generated code.
Optimize generated code for a specific target environment.
Enable tracing, reporting, and testing options that facilitate code verification.
You can design, implement, and verify generated C or C++ code from Simulink models or MATLAB code.
Other products that support code generation, such as Stateflow® software, are available.
Code Generation from Simulink Models
To generate C or C++ code from Simulink models by using Embedded Coder, you need these products:
MATLAB
MATLAB Coder
Simulink
Simulink Coder
Embedded Coder
You can implement algorithms as Simulink blocks and Stateflow charts in a Simulink model. Embedded Coder provides features for designing, configuring, and verifying a model for C or C++ code generation.
If you have algorithms written in MATLAB code, you can include the MATLAB code in a Simulink model or subsystem by using the MATLAB Function block. When you generate C or C++ code for the model, the MATLAB code in the MATLAB Function block is included in the generated code as C or C++ source code.
To get started generating code from Simulink models by using Embedded Coder, see Generate C Code from Simulink Models.
Code Generation from MATLAB Code
To generate code C or C++ code from MATLAB code by using Embedded Coder, you need these products:
MATLAB
MATLAB Coder
Embedded Coder
MATLAB
Coder supports a subset of core MATLAB language features, including
program control constructs, functions, and matrix operations. To generate C or
C++ code, you can use MATLAB Coder projects or enter the function codegen
in the MATLAB Command Window. Embedded Coder provides additional options and advanced optimizations for
fine-grain control of generated code functions, files, and data. For more
information about these options and optimizations , see Embedded Coder Capabilities for Code Generation from MATLAB Code.
For more information about generating code from MATLAB code, see Generate C/C++ Code From MATLAB Code Using MATLAB Coder.
To get started generating code from MATLAB code by using Embedded Coder, see Embedded Coder Capabilities for Code Generation from MATLAB Code.