As you construct a model, to prevent issues later in the development process, determine whether the Simulink® Coder™ and Embedded Coder® code generators support the products and blocks that you want to use.
The following table summarizes MathWorks® products that extend and complement Simulink
Coder software. For information about these products and how code generation
supports them, refer to their product documentation at www.mathworks.com
.
Product | Extends Code Generation Capabilities for ... |
---|---|
Aerospace Blockset™ | Aircraft, spacecraft, rocket, propulsion systems, and unmanned airborne vehicles |
Audio Toolbox™ | Audio processing systems |
Automated Driving Toolbox™ | Designing, simulating, and testing ADAS and autonomous driving systems |
AUTOSAR Blockset | Modeling and simulation of AUTOSAR Classic and Adaptive ECU software |
Communications Toolbox™ | Physical layer of communication systems |
Computer Vision Toolbox™ | Video processing, image processing, and computer vision systems |
Control System Toolbox™ | Linear control systems |
DSP System Toolbox™ | Signal processing systems |
Embedded Coder | Embedded systems, rapid prototyping boards, and microprocessors in mass production |
Fixed-Point Designer™ | Fixed-point systems |
Fuzzy Logic Toolbox™ | System designs based on fuzzy logic |
HDL Verifier™ | Direct programming interface (DPI) component and transaction-level model (TLM) generation from Simulink |
IEC Certification Kit | ISO 26262 and IEC 61508 certification |
Model-Based Calibration Toolbox™ | Developing processes for systematically identifying optimal balance of engine performance, emissions, and fuel economy, and reusing statistical models for control design, hardware-in-the-loop (HIL) testing, or powertrain simulation |
Model Predictive Control Toolbox™ | Model predictive controllers |
Deep Learning Toolbox™ | Neural networks |
Parallel Computing Toolbox™ | Parallel builds for large Simulink models |
Phased Array System Toolbox™ | Sensor array systems in radar, sonar, wireless communications, and medical imaging applications |
Polyspace® Bug Finder™ | MISRA-C compliance and static analysis of generated code |
Polyspace Code Prover™ | Formal analysis of generated code |
Powertrain Blockset™ | Real-time testing of powertrain applications |
Robotics System Toolbox™ | Design, simulate, and test robotics applications |
ROS Toolbox | Design, simulate, and deploy ROS-based applications |
Simscape™ | Systems spanning mechanical, electrical, hydraulic, and other physical domains as physical networks |
Simscape Driveline™ | Driveline (drivetrain) systems |
Simscape Electrical™ | Electronic, electromechanical, and electrical power systems |
Simscape Fluids™ | Hydraulic power and control systems |
Simscape Multibody™ | Three-dimensional mechanical systems |
Simulink 3D Animation™ | Systems with 3D visualizations |
Simulink Check™ | Model standards compliance checking and metrics |
Simulink Code Inspector™ | Automated reviews of generated code |
Simulink Control Design™ | Autotuning of PID controllers and online frequency response estimation |
Simulink Coverage™ | Model and code structural coverage analysis |
Simulink Design Optimization™ | Tuning adaptive lookup tables and checking signal characteristics |
Simulink Desktop Real-Time™ | Rapid prototyping or hardware-in-the-loop (HIL) simulation of control system and signal processing algorithms |
Simulink Real-Time™ | Rapid control prototyping, hardware-in-the-loop (HIL) simulation, and other real-time testing applications |
Simulink Report Generator™ | Automatically generating project documentation in a standard format |
Simulink Requirements™ | Authoring and tracing requirements to design and code |
Simulink Test™ | Software-in-the-loop (SIL), processor-in-the-loop (PIL), and real-time hardware-in-the-loop (HIL) testing of generated code |
SoC Blockset™ | Designing, evaluating, and implementing SoC hardware and software architectures |
Stateflow® | State machines and flow charts |
System Identification Toolbox™ | Systems identified from measured input-output data |
Vehicle Dynamics Blockset™ | Modeling and simulation of vehicle dynamics in 3D environment |
Vehicle Network Toolbox™ | CAN blocks for Accelerator and Rapid Accelerator simulations and code deployment on Windows® |
The following tables summarize code
generator support for Simulink blocks. There is a table for each block library. For more detail, including
data types each block supports, in the MATLAB® Command Window, type showblockdatatypetable
, or consult
the block reference pages. For some blocks, the generated code might rely on
memcpy
or memset
(string.h
).
Additional Math and Discrete: Additional Discrete
Block | Support Notes |
---|---|
Fixed-Point State-Space | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Transfer Fcn Direct Form II | |
Transfer Fcn Direct Form II Time Varying |
Additional Math and Discrete: Increment/Decrement
Block | Support Notes |
---|---|
Decrement Real World | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Decrement Stored Integer | |
Decrement Time To Zero | Supports code generation. |
Decrement To Zero | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Increment Real World | |
Increment Stored Integer |
Continuous
Block | Support Notes |
---|---|
Derivative | Not recommended for production-quality code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. The code generated can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. In general, consider using the Simulink Model Discretizer to map continuous blocks into discrete equivalents that support production code generation. Use the Model Discretizer app. One exception is the Second-Order Integrator block because, for this block, the Model Discretizer produces an approximate discretization. |
Integrator | |
Integrator, Integrator Limited | |
PID Controller | |
PID Controller (2DOF) | |
Second-Order Integrator, Second-Order Integrator Limited | |
State-Space | |
Transfer Fcn | |
Transport Delay | |
Variable Time Delay, Variable Transport Delay | |
Zero-Pole |
Discontinuities
Block | Support Notes |
---|---|
Backlash | Supports code generation. |
Coulomb and Viscous Friction | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Dead Zone | Supports code generation. |
Dead Zone Dynamic | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Hit Crossing | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Quantizer | Supports code generation. |
Rate Limiter | Cannot use inside a triggered subsystem hierarchy. |
Rate Limiter Dynamic | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Relay | Support code generation. |
Saturation | |
Saturation Dynamic | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Wrap To Zero |
Discrete
Block | Support Notes |
---|---|
Delay | Supports code generation. |
Difference |
|
Discrete Derivative |
|
Discrete Filter | Support code generation. |
Discrete FIR Filter | |
Discrete PID Controller |
|
Discrete PID Controller (2DOF) | |
Discrete State-Space | Support code generation. |
Discrete Transfer Fcn | |
Discrete Zero-Pole | |
Discrete-Time Integrator | Depends on absolute time when used inside a triggered subsystem hierarchy. |
Enabled Delay | Supports code generation. |
First Order Hold | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Memory | Support code generation. |
Resettable Delay | |
Tapped Delay | |
Transfer Fcn First Order | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Transfer Fcn Lead or Lag | |
Transfer Fcn Real Zero | |
Unit Delay | Support code generation. |
Variable Integer Delay | |
Zero-Order Hold |
Logic and Bit Operations
Lookup Tables
Block | Support Notes |
---|---|
Cosine | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting the Treat as atomic unit check box. |
Direct Lookup Table (n-D) | Support code generation. |
Interpolation Using Prelookup | |
1-D Lookup Table | |
2-D Lookup Table | |
n-D Lookup Table | |
Lookup Table Dynamic | |
Prelookup | |
Sine | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Math Operations
Model Verification
Block | Support Notes |
---|---|
Assertion | Supports code generation. |
Check Discrete Gradient | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Check Dynamic Gap | Support code generation. |
Check Dynamic Lower Bound | |
Check Dynamic Range | |
Check Dynamic Upper Bound | |
Check Input Resolution | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Check Static Gap | |
Check Static Lower Bound | |
Check Static Range | |
Check Static Upper Bound |
Model-Wide Utilities
Block | Support Notes |
---|---|
Block Support Table | Ignored during code generation. |
DocBlock | Uses the template symbol you specify for the Embedded Coder Flag block parameter to add comments to generated code. Requires an Embedded Coder license. For more information, see Use a Simulink DocBlock to Add a Comment. |
Model Info | Ignored during code generation. |
Timed-Based Linearization | |
Trigger-Based Linearization |
Ports & Subsystems
Signal Attributes
Block | Support Notes |
---|---|
Bus to Vector | Support code generation. |
Data Type Conversion | |
Data Type Conversion Inherited | |
Data Type Duplicate | |
Data Type Propagation | |
Data Type Scaling Strip | |
IC | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Probe | Supports code generation. |
Rate Transition |
|
Signal Conversion | Support code generation. |
Signal Specification | |
Unit Conversion | |
Weighted Sample Time | |
Width |
Signal Routing
Block | Support Notes |
---|---|
Bus Assignment | Support code generation. |
Bus Creator | |
Bus Selector | |
Data Store Memory | |
Data Store Read | |
Data Store Write | |
Demux | |
Environment Controller | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
From | Support code generation. |
Goto | |
Goto Tag Visibility | |
Index Vector | |
Manual Switch | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Manual Variant Sink | Support code generation. |
Manual Variant Source | |
Merge | When multiple signals connected to a Merge block have a
non-Auto storage class, all
non-Auto signals connected to that block must be
identically labeled and have the same storage
class. When Merge blocks connect directly to one another, these rules
apply to all signals connected to Merge blocks in the
group. |
Multiport Switch | Support code generation. |
Mux | |
Selector | |
State Reader | |
State Writer | |
Switch | |
Variant Sink | |
Variant Source | |
Vector Concatenate |
Sinks
Block | Support Notes |
---|---|
Display | Ignored for code generation. |
Floating Scope and Scope Viewer | |
Outport (Out1) | Supports code generation. |
Scope | Ignored for code generation. |
Stop Simulation |
|
Terminator | Supports code generation. |
To File | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
To Workspace | Ignored for code generation. |
XY Graph |
Sources
Block | Support Notes |
---|---|
Band-Limited White Noise | Cannot use inside a triggered subsystem hierarchy. |
Chirp Signal | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Clock | |
Constant | Supports code generation. |
Counter Free-Running | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Counter Limited |
|
Digital Clock | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Enumerated Constant | Supports code generation. |
From File | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
From Spreadsheet | |
From Workspace | Ignored for code generation. |
Ground | Support code generation. |
Inport (In1) | |
Pulse Generator | Cannot use inside a triggered subsystem hierarchy. Does not refer to absolute time when configured for sample-based operation. Depends on absolute time when in time-based operation. |
Ramp | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Random Number | Supports code generation. |
Repeating Sequence |
|
Repeating Sequence Interpolated |
|
Repeating Sequence Stair | The code generator does not explicitly group primitive blocks that constitute a nonatomic masked subsystem block in the generated code. This flexibility allows for more efficient code generation. In certain cases, you can achieve grouping by configuring the masked subsystem block to execute as an atomic unit by selecting block parameter Treat as atomic unit. |
Signal Builder | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Signal Generator | |
Sine Wave |
|
Step | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
Uniform Random Number | Supports code generation. |
Waveform Generator | Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable. |
User-Defined
Block | Support Notes |
---|---|
Function Caller | Support code generation. |
Initialize Function | |
Interpreted MATLAB Function | Consider using the MATLAB Function block instead. |
Level-2 MATLAB S-Function | If a corresponding TLC file is available, the Level-2 MATLAB S-Function block uses the TLC file to generate code, otherwise code generation throws an error. |
MATLAB Function | Support code generation. |
MATLAB System | |
S-Function | S-functions that call into MATLAB are not supported for code generation. |
S-Function Builder | |
Simulink Function | Support code generation. |
Terminate Function |
The Simulink Block Data Type Support table summarizes characteristics of blocks in the
Simulink and Fixed-Point Designer block libraries, including whether or not they are recommended for use in
production code generation. To view this table, in the MATLAB Command Window, type showblockdatatypetable
, or consult
the block reference pages.
Several products that include blocks are available for you to consider for code generation. However, before using the blocks for one of these products, consult the documentation for that product to confirm which blocks support code generation.