Main Content

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.

GoalProject SettingCode Configuration Object PropertyMore Information
Execution Time
Control generation of floating-point data and operationsSupport only purely-integer numbersPurelyIntegerCodeN/A
Simplify array indexing in loops in the generated codeSimplify array indexingEnableStrengthReductionSimplify Multiply Operations for Array Indexing in Loops
Replace functions and operators in the generated code to meet application-specific code requirementsCode replacement library on the Custom Code tabCodeReplacementLibraryEmbedded 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 operatorsN/AN/ACode Replacement Customization
Code Appearance
Specify use of single-line or multiline comments in the generated codeComment StyleCommentStyleSpecify 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 codeMATLAB source code as commentsMATLABSourceCommentsInclude Comments in Generated C/C++ Code
Generate MATLAB function help text in the function banner MATLAB function help textMATLABFcnDescInclude Comments in Generated C/C++ Code
Convert if-elseif-else patterns to switch-case statementsConvert if-elseif-else patterns to switch-case statementsConvertIfToSwitchControlling C Code Style
Specify that the extern keyword is included in declarations of generated external functionsPreserve extern keyword in function declarationsPreserveExternInFcnDeclsN/A
Specify the level of parenthesization in the generated codeParenthesesParenthesesLevelN/A
Specify whether to replace multiplications by powers of two with signed left bitwise shifts in the generated codeUse signed shift left for fixed-point operations and multiplication by powers of 2EnableSignedLeftShiftsControl Signed Left Shifts in Generated Code
Specify whether to allow signed right bitwise shifts in the generated codeAllow right shifts on signed integersEnableSignedRightShiftsN/A
Control data type casts in the generated codeCasting mode on the All Settings tabCastingModeControl Data Type Casts in Generated Code
Specify the indent style for the generated codeIndent 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 codeColumn limit on the All Settings tabColumnLimitN/A
Specify custom names for MATLAB data types in generated codeEnable custom data type replacementEnableCustomReplacementTypes
ReplacementTypes
Customize Data Type Replacement
Import custom data type definitions from external header files Import custom types from external header filesIsExtern
HeaderFiles
Import Custom Data Type Definitions from External Header Files
Customize generated C/C++ file namesGenerated source and header file name formatCustomFileNameStrCustomize C/C++ File Names Generated from MATLAB Code
Customize generated global variable identifiers Global variablesCustomSymbolStrGlobalVarCustomize Generated Identifiers
Customize generated global type identifiersGlobal typesCustomSymbolStrTypeCustomize Generated Identifiers
Customize generated field names in global type identifiersField name of global typesCustomSymbolStrFieldCustomize Generated Identifiers
Customize generated local functions identifiersLocal functionsCustomSymbolStrFcnCustomize Generated Identifiers
Customize generated identifiers for local temporary variablesLocal temporary variablesCustomSymbolStrTmpVarCustomize Generated Identifiers
Customize generated identifiers for constant macrosConstant macrosCustomSymbolStrMacroCustomize Generated Identifiers
Customize generated identifiers for EMX Array types (Embeddable mxArray types)EMX Array TypesCustomSymbolStrEMXArrayCustomize Generated Identifiers
Customize generated identifiers for EMX Array (Embeddable mxArrays) utility functionsEMX Array Utility FunctionsCustomSymbolStrEMXArrayFcnCustomize Generated Identifiers
Customize function interface in the generated codeInitialize function required on the All Settings tab
Terminate function required on the All Settings tab
IncludeInitializeFcn
IncludeTerminateFcn
N/A
Customize file and function bannersN/ACodeTemplate
Control declarations and definitions of global variables in the generated codeN/AN/A
Debugging
Generate a static code metrics report including generated file information, number of lines, and memory usageStatic code metricsGenerateCodeMetricsReportGenerating 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 libraryCode replacementsGenerateCodeReplacementReport
Highlight single-precision, double-precision, and expensive fixed-point operations in the code generation reportHighlight potential data type issuesHighlightPotentialDataTypeIssuesHighlight Potential Data Type Issues in a Report
Custom Code
Replace functions and operators in the generated code to meet application-specific code requirementsCode replacement libraryCodeReplacementLibraryEmbedded 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 operatorsN/AN/ACode Replacement Customization
Verification
Interactively trace between MATLAB source code and generated C/C++ codeEnable Code TraceabilityEnableTraceabilityInteractively Trace Between MATLAB Code and Generated C/C++ Code
Verify generated code using software-in-the-loop and processor-in-the-loop executionN/AVerificationModeCode Verification Through Software-in-the-Loop and Processor-in-the-Loop Execution
Debug code during software-in-the-loop executionEnable source-level debugging for SIL on the Debugging paneSILDebuggingDebug Generated Code During SIL Execution
Profile execution times during software-in-the-loop and processor-in-the-loop executionEnable entry point execution profiling for SIL/PIL on the Debugging paneCodeExecutionProfilingExecution Time Profiling for SIL and PIL
Verify and profile ARM optimized code Hardware Board on the Hardware paneHardware
Run Polyspace® verification on generated C/C++ code by using the integrated workflowN/AN/APolyspace Verification of C/C++ Code Generated by MATLAB Coder