Embedded Coder Capabilities for Code Generation from MATLAB Code
The Embedded Coder® product extends the MATLAB® Coder™ product with capabilities that you can use for embedded software development. You can generate code that has the clarity and efficiency of professional handwritten code. For example, you can:
Generate code that is compact and fast, which is essential for real-time simulators, on-target rapid prototyping boards, microprocessors used in mass production, and embedded systems.
Customize the appearance of generated code.
Optimize generated code for application-specific requirements.
Enable tracing options that help you to verify the generated code.
The Embedded Coder product extends the MATLAB Coder product with the following options and optimizations for C/C++ code generation.
Goal | Project Setting | Code Configuration Object Property | More Information |
---|---|---|---|
Execution Time | |||
Control generation of floating-point data and operations | Support only purely-integer numbers | PurelyIntegerCode | N/A |
Simplify array indexing in loops in the generated code | Simplify array indexing | EnableStrengthReduction | Simplify Multiply Operations for Array Indexing in Loops |
Replace functions and operators in the generated code to meet application-specific code requirements | Code replacement library on the Custom Code tab | CodeReplacementLibrary | Embedded Coder offers additional libraries and the ability to create and use custom code. See Code Replacement Customization. |
Create and register application-specific implementations of functions and operators | N/A | N/A | Code Replacement Customization |
Code Appearance | |||
Specify use of single-line or multiline comments in the generated code | Comment Style | CommentStyle | Specify Comment Style for C/C++ Code |
Include MATLAB source code as comments with traceability tags. In the code generation report, the traceability tags link to the corresponding MATLAB source code | MATLAB source code as comments | MATLABSourceComments | Include Comments in Generated C/C++ Code |
Generate MATLAB function help text in the function banner | MATLAB function help text | MATLABFcnDesc | Include Comments in Generated C/C++ Code |
Include comments in the generated code that contain summaries for requirements linked to MATLAB code. In the code generation report, the comments are hyperlinks that to the requirements in the Requirements Editor | Requirement summaries as comments | ReqsInCode | Requirements Traceability for Code Generated from MATLAB Code (Requirements Toolbox) |
Convert if-elseif-else patterns to switch-case statements | Convert if-elseif-else patterns to switch-case statements | ConvertIfToSwitch | Controlling C Code Style |
Specify that the extern keyword is included in declarations of generated external functions | Preserve extern keyword in function declarations | PreserveExternInFcnDecls | N/A |
Specify the level of parenthesization in the generated code | Parentheses | ParenthesesLevel | N/A |
Specify whether to replace multiplications by powers of two with signed left bitwise shifts in the generated code | Use signed shift left for fixed-point operations and multiplication by powers of 2 | EnableSignedLeftShifts | Control Signed Left Shifts in Generated Code |
Specify whether to allow signed right bitwise shifts in the generated code | Allow right shifts on signed integers | EnableSignedRightShifts | N/A |
Control data type casts in the generated code | Casting mode on the All Settings tab | CastingMode | Control Data Type Casts in Generated Code |
Specify the indent style for the generated code | Indent style on the All
Settings tab Indent size on the All Settings tab | IndentStyle IndentSize | Specify Indent Style for C/C++ Code |
Specify the maximum number of columns before a line break in the generated code | Column limit on the All Settings tab | ColumnLimit | N/A |
Specify custom names for MATLAB data types in generated code | Enable custom data type replacement | EnableCustomReplacementTypes ReplacementTypes | Customize Data Type Replacement |
Import custom data type definitions from external header files | Import custom types from external header files | IsExtern HeaderFiles | Import Custom Data Type Definitions from External Header Files |
Customize generated C/C++ file names | Generated source and header file name format | CustomFileNameStr | Customize C/C++ File Names Generated from MATLAB Code |
Customize generated global variable identifiers | Global variables | CustomSymbolStrGlobalVar | Customize Generated Identifiers |
Customize generated global type identifiers | Global types | CustomSymbolStrType | Customize Generated Identifiers |
Customize generated field names in global type identifiers | Field name of global types | CustomSymbolStrField | Customize Generated Identifiers |
Customize generated local functions identifiers | Local functions | CustomSymbolStrFcn | Customize Generated Identifiers |
Customize generated identifiers for local temporary variables | Local temporary variables | CustomSymbolStrTmpVar | Customize Generated Identifiers |
Customize generated identifiers for constant macros | Constant macros | CustomSymbolStrMacro | Customize Generated Identifiers |
Customize generated identifiers for EMX Array types (Embeddable mxArray types) | EMX Array Types | CustomSymbolStrEMXArray | Customize Generated Identifiers |
Customize generated identifiers for EMX Array (Embeddable mxArrays) utility functions | EMX Array Utility Functions | CustomSymbolStrEMXArrayFcn | Customize Generated Identifiers |
Customize function interface in the generated code | Initialize function required on the
All Settings
tab Terminate function required on the All Settings tab | IncludeInitializeFcn IncludeTerminateFcn | N/A |
Customize file and function banners | N/A | CodeTemplate | |
Control declarations and definitions of global variables in the generated code | N/A | N/A | |
Generate code that is compliant with MISRA™ C/C++ and AUTOSAR C++ guidelines | MISRA Compliance pane | See coder.setupMISRAConfig
reference page | Generate C/C++ Code with Improved MISRA and AUTOSAR Compliance |
Debugging | |||
Generate a static code metrics report including generated file information, number of lines, and memory usage | Static code metrics | GenerateCodeMetricsReport | Generating a Static Code Metrics Report for Code Generated from MATLAB Code |
Generate a code replacement report that summarizes the replacements used from the selected code replacement library | Code replacements | GenerateCodeReplacementReport | |
Highlight single-precision, double-precision, and expensive fixed-point operations in the code generation report | Highlight potential data type issues | HighlightPotentialDataTypeIssues | Highlight Potential Data Type Issues in a Report |
Custom Code | |||
Replace functions and operators in the generated code to meet application-specific code requirements | Code replacement library | CodeReplacementLibrary | Embedded Coder offers additional libraries and the ability to create and use custom code. See Code Replacement Customization. |
Create and register application-specific implementations of functions and operators | N/A | N/A | Code Replacement Customization |
Verification | |||
Interactively trace between MATLAB source code and generated C/C++ code | Enable Code Traceability | EnableTraceability | Interactively Trace Between MATLAB Code and Generated C/C++ Code |
Verify generated code using software-in-the-loop and processor-in-the-loop execution | N/A | VerificationMode | Code Verification Through Software-in-the-Loop and Processor-in-the-Loop Execution |
Debug code during software-in-the-loop or processor-in-the-loop execution | Enable source-level debugging for SIL or PIL on the Debugging pane | SILPILDebugging | Debug Generated Code During SIL or PIL Execution |
Profile execution times during software-in-the-loop and processor-in-the-loop execution | Enable entry point execution profiling for SIL/PIL on the Debugging pane | CodeExecutionProfiling | Execution Time Profiling for SIL and PIL |
Verify and profile ARM optimized code | Hardware Board on the Hardware pane | Hardware | |
Run Polyspace® verification on generated C/C++ code by using the integrated workflow | N/A | N/A | Polyspace Verification of C/C++ Code Generated by MATLAB Coder |
Extract coverage data for generated C/C++ code and custom C/C++ code | Enable C/C++ code coverage on the All Settings tab | CodeCoverage | getCodeCoverageData |