Package: coder
Superclasses: coder.CodeConfig
codegen
configuration object that
specifies code generation parameters for code generation with an Embedded Coder license
A coder.EmbeddedCodeConfig
object contains
the configuration parameters that the codegen
function
requires to generate standalone C/C++ libraries and executables for
an embedded target. Use the -config
option to pass
this object to the codegen
function.
creates a code generation configuration
object for C/C++ static library generation. If the Embedded Coder® product
is installed, it creates a cfg
=
coder.config('lib') coder.EmbeddedCodeConfig
object.
Otherwise, it creates a coder.CodeConfig
object.
creates a code generation configuration
object for C/C++ dynamic library generation. If the Embedded Coder product
is installed, it creates a cfg
=
coder.config('dll')coder.EmbeddedCodeConfig
object.
Otherwise, it creates a coder.CodeConfig
object.
creates
a code generation configuration object for C/C++ executable generation.
If the Embedded Coder product is installed, it creates a cfg
= coder.config('exe')coder.EmbeddedCodeConfig
object.
Otherwise, it creates a coder.CodeConfig
object.
creates a cfg
= coder.config(output_type
,
'ecoder', false)coder.CodeConfig
object
for the specified output type even if the Embedded Coder product
is installed.
creates a cfg
= coder.config(output_type
,
'ecoder', true)coder.EmbeddedCodeConfig
object
for the specified output type even if the Embedded Coder product
is not installed. However, you cannot generate code using a coder.EmbeddedCodeConfig
object
unless an Embedded Coder license is available.
|
Specify build configuration. Default: | |||||||||||||||||||||||
|
Specify data type casting level for variables in the generated C/C++ code.
Default: | |||||||||||||||||||||||
|
Enable execution-time profiling during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution. Default: | |||||||||||||||||||||||
|
Specify a code generation template for file and function banners
in the generated code. This parameter is a handle to a This parameter is empty by default. If you do not set this parameter
to a | |||||||||||||||||||||||
|
Specify a code replacement library for the generated code.
Compatible libraries depend on these parameters:
Embedded Coder offers more libraries and the ability to create and use custom code replacement libraries. MATLAB® Coder™ generates the minimal set of Before setting this parameter, verify that your compiler supports the library that you want to use. If you select a parameter value that your compiler does not support, compiler errors can occur.
Default: | |||||||||||||||||||||||
|
Specify comment style in the generated C or C++ code.
For C code generation, specify the single-line comment style only if your compiler supports it. Dependency: Default: | |||||||||||||||||||||||
|
For compile-time recursion, control the number of copies of
a function that are allowed in the generated code. To disallow recursion
in the MATLAB code, set Default: | |||||||||||||||||||||||
|
Select whether to convert Default: | |||||||||||||||||||||||
|
Specify the maximum number of instructions that the constant folder executes before stopping. In some situations, code generation requires specific instructions to be constant. If code generation is failing, increase this value. Default: | |||||||||||||||||||||||
|
Specify code to appear near the top of each C/C++ header file generated from your MATLAB algorithm code. Specify code as a character vector. Default: | |||||||||||||||||||||||
|
Specify a space-separated list of include folders to add to the include path when compiling the generated code. Specify list of include folders as a character vector. If your list includes Windows paths that contain spaces, enclose each instance in double quotes, for example: 'C:\Project "C:\Custom Files"' Default: | |||||||||||||||||||||||
|
Specify code to appear in the initialize function of the generated Default: | |||||||||||||||||||||||
|
Specify the name of a LAPACK callback class that derives from Default: | |||||||||||||||||||||||
|
Specify a space-separated list of static library files to link with the generated code. Specify list as a character vector. Default: | |||||||||||||||||||||||
|
Specify a space-separated list of source files to compile and link with the generated code. Specify list of source files as a character vector. Default: | |||||||||||||||||||||||
|
Specify code to appear near the top of the generated Default: | |||||||||||||||||||||||
|
Customize generated identifiers for EMX Array types (Embeddable mxArray types). See Settings. Default: | |||||||||||||||||||||||
|
Customize generated identifiers for EMX Array (Embeddable mxArrays) utility functions. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated local function identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated field names in global type identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated global variable identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated constant macro identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated local temporary variable identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Customize generated global type identifiers. See Settings. Default: | |||||||||||||||||||||||
|
Specify code to appear in the terminate function of the generated Default: | |||||||||||||||||||||||
|
Specify custom settings for each tool in the selected toolchain, as a cell array. Dependencies:
Start by getting the current options and values. For example: rtwdemo_sil_topmodel; set_param(gcs, 'BuildConfiguration', 'Specify') opt = get_param(gcs, 'CustomToolchainOptions') Then edit the values in These values derive from the toolchain definition file and the third-party compiler options. See Custom Toolchain Registration. Default: | |||||||||||||||||||||||
|
Specify whether to use built-in C data types or predefined types
from Set to Default: | |||||||||||||||||||||||
|
Description of the Default: | |||||||||||||||||||||||
|
Control use of dynamic memory allocation for variable-size data. By default, dynamic memory allocation is enabled for variable-size
arrays whose size (in bytes) is greater than or equal to Set this property to Dependencies:
Default: | |||||||||||||||||||||||
|
Specify the size threshold in bytes. Dependency:
Default: | |||||||||||||||||||||||
|
Specify whether MATLAB Coder must treat common visualization
functions as extrinsic functions. When this option is enabled, MATLAB Coder detects
calls to many common visualization functions, such as Default: | |||||||||||||||||||||||
|
Enable the
See memcpy Optimization. Default: | |||||||||||||||||||||||
|
If possible, enable OpenMP. Using the OpenMP library, the C/C++
code that MATLAB Coder generates for Default: | |||||||||||||||||||||||
|
Allow recursive functions in generated code. If your MATLAB code
requires run-time recursion and this parameter is Some coding standards, such as MISRA, do not allow recursion.
To increase the likelihood of generating code that is compliant with MISRA C®,
set Default: | |||||||||||||||||||||||
|
Specify whether to replace multiplications by powers of two
with signed left bitwise shifts in the generated C/C++ code. Some
coding standards, such as MISRA, do not allow bitwise operations on
signed integers. To increase the likelihood of generating MISRA C compliant
code, set this option to When this option is i <<= 3; When this option is i = i * 8; Default: | |||||||||||||||||||||||
|
Specify whether to allow signed right bitwise shifts in the
generated C/C++ code. Some coding standards, such as MISRA, do
not allow bitwise operations on signed integers. To increase the likelihood
of generating MISRA-C:2004 compliant code, set this option to When this option is i >>= 3 When this option is i = asr_s32(i, 3U); Default: | |||||||||||||||||||||||
|
Enable optimization that simplifies array indexing in loops in the generated code. When possible, for array indices in loops, this optimization replaces multiply operations with add operations. Multiply operations can be expensive. This optimization is useful when the C/C++ compiler on the target platform does not optimize the array indexing. Even when the optimization replaces the multiply operations in the generated code, it is possible that the C/C++ compiler can generate multiply instructions. Default: | |||||||||||||||||||||||
|
Enable support for variable-size arrays. Dependency:
Default: | |||||||||||||||||||||||
|
Specify whether to generate one C/C++ file for each MATLAB language
file ( Default: | |||||||||||||||||||||||
|
Generate a static code metrics report including generated file information, number of lines, and memory usage. Default: | |||||||||||||||||||||||
|
Specify code generation versus an executable or library build. Default: | |||||||||||||||||||||||
|
Generate a code replacements report that summarizes the replacements used from the selected code replacement library. The report provides a mapping between each code replacement instance and the line of MATLAB code that triggered the replacement. Default: | |||||||||||||||||||||||
|
Place comments in the generated files. Dependencies:
Default: | |||||||||||||||||||||||
|
Specify whether to generate an example C/C++ main function.
If example main generation is enabled, MATLAB Coder generates
source and header files for the main function in the The example main function declares and initializes data. It calls entry-point functions but does not use values returned from the entry-point functions. Before you use the example main files, copy them to another location and modify them to meet the requirements of your application.
Default: | |||||||||||||||||||||||
|
Specify whether to generate a makefile during the build process. Default: | |||||||||||||||||||||||
|
Default: | |||||||||||||||||||||||
|
Handle to cfg = coder.config('lib','ecoder',true); hw = coder.hardware('BeagleBone Black'); cfg.Hardware = hw; Dependencies:
| |||||||||||||||||||||||
|
Handle to If you set the Dependency: Setting | |||||||||||||||||||||||
|
Highlight potential data type issues in the code generation report. If this option is enabled, the code generation report highlights MATLAB code that results in single-precision or double-precision operations in the generated C/C++ code. If you have a Fixed-Point Designer™ license, the report also highlights expressions in the MATLAB code that result in expensive fixed-point operations in the generated code. Default: | |||||||||||||||||||||||
|
Generate a terminate function. If you set this property to Default: | |||||||||||||||||||||||
|
Specify the number of characters per indentation level. Specify an integer from 2 to 8. Default: | |||||||||||||||||||||||
|
Specify the style for the placement of braces in the generated C/C++ code.
Default: | |||||||||||||||||||||||
|
Enable the
See memset Optimization. Default: | |||||||||||||||||||||||
|
Specify the stack size limit on inlined functions. This specification determines the amount of stack space allocated for local variables of the inlined function. Specifying a limit on the stack space constrains the amount of inlining allowed. For out-of-line functions, stack space for variables local to the function is released when the function returns. However, for inlined functions, stack space remains occupied by the local variables even when the function returns. This feature is especially important for embedded processors, where stack size can be limited. Default: | |||||||||||||||||||||||
|
Specify function size for inline threshold. Unless there are conflicts with other inlining conditions, MATLAB Coder inlines functions that are smaller than this size. The function size is measured in terms of an abstract number of instructions, not actual MATLAB instructions or instructions in the target processor. You must experiment with this parameter to obtain the inlining behavior that you want. For instance, if the default setting for this parameter is leading to large functions being inlined, you can tune the parameter in steps until you are satisfied with the inlining behavior. Default: | |||||||||||||||||||||||
|
Specify the maximum size of functions after inlining. If the
size of the calling function after inlining exceeds The function size is measured in terms of an abstract number of instructions, not actual MATLAB instructions or instructions in the target processor. You must experiment with this parameter to obtain the inlining behavior that you want. For instance, if the default setting for this parameter is leading to the inlining of large functions, you can tune the parameter in steps until you are satisfied with the inlining behavior. Default: | |||||||||||||||||||||||
|
Specify whether to display a report after code generation is complete or an error occurs. Default: | |||||||||||||||||||||||
|
Include MATLAB function help text in a function banner in generated code. If not selected, MATLAB Coder treats the help text as a user comment. Dependencies:
Default: | |||||||||||||||||||||||
|
Include MATLAB source code as comments in the generated code. Dependencies:
Default: | |||||||||||||||||||||||
|
Specify maximum number of characters in generated function, type definition, and variable names. To avoid truncation of identifiers by the target C compiler, specify a value that matches the maximum identifier length of the target C compiler. This parameter does not apply to exported identifiers, such as the generated names for entry-point functions or emxArray API functions. If the length of an exported identifier exceeds the maximum identifier length of the target C compiler, the target C compiler truncates the exported identifier. Minimum is 31. Maximum is 256. Default: | |||||||||||||||||||||||
|
Specify the minimum number of bytes for the code generator to
invoke the The number of bytes is the number of array elements to copy or assign multiplied by the number of bytes required for the C/C++ data type. See memcpy Optimization and memset Optimization. Default: | |||||||||||||||||||||||
|
Generate reusable, multi-instance code that is reentrant. Default: | |||||||||||||||||||||||
|
Name of the configuration object. Default: | |||||||||||||||||||||||
|
Specify whether to generate a standalone C/C++ static library,
dynamic library, or executable. Set to Default: | |||||||||||||||||||||||
|
Specify the parenthesization level in the generated C/C++ code.
Default: | |||||||||||||||||||||||
|
Specify whether to pass structures by reference to entry-point
functions. Set to This parameter applies only to entry-point functions. If you set this parameter to Default: | |||||||||||||||||||||||
|
Specify command to customize build processing after code generation
using Default: | |||||||||||||||||||||||
|
Specify whether the declarations of external functions generated
by Default: | |||||||||||||||||||||||
|
Specify which variable names the code generator must preserve in the generated code.
Default: | |||||||||||||||||||||||
|
Specify whether to generate floating-point data and operations. Default: | |||||||||||||||||||||||
|
Enter a space-separated list of names that MATLAB Coder is not to use for naming functions or variables. Specify list as a character vector. Default: | |||||||||||||||||||||||
|
Enable run-time error detection and reporting in the generated C/C++ code. If you select this option, the generated code checks for errors such as out-of-bounds array indexing. The error reporting software uses Error messages are in English. Default: | |||||||||||||||||||||||
|
Overflows saturate to either the minimum or maximum value that the data type can represent. Otherwise, the overflow behavior depends on your target C compiler. Most C compilers wrap on overflow. This parameter applies only to MATLAB built-in integer types. It does not apply to doubles, singles, or fixed-point data types. Default: | |||||||||||||||||||||||
|
Enable debugger to observe code behavior during a software-in-the-loop (SIL) execution. The software supports the following debuggers:
Default: | |||||||||||||||||||||||
|
Specify the maximum stack usage per application in bytes. Set a limit that is lower than the available stack size. Otherwise, a run-time stack overflow can occur. The C compiler detects and reports overflows. Default: | |||||||||||||||||||||||
|
Specify whether to generate nonfinite data and operations. Default: | |||||||||||||||||||||||
|
Specify the target language. Set to Default: | |||||||||||||||||||||||
|
Specify a standard math library for the generated code. Options
include Before setting this parameter, verify that your compiler supports the library that you want to use. If you select a parameter value that your compiler does not support, compiler errors can occur. Default: | |||||||||||||||||||||||
|
Specify the toolchain to use. If you do not specify a toolchain, MATLAB Coder automatically locates an installed toolchain. Default: | |||||||||||||||||||||||
|
Display code generation progress.
Default: | |||||||||||||||||||||||
|
Specify code verification mode.
Default: |
Enter a macro that specifies the format of the generated identifier. The macro can include valid C identifier characters and a combination of the following format tokens:
Token | Description |
---|---|
$M | Code generator inserts name mangling text to avoid naming collisions. Required. |
$N | Code generator inserts name of object (global variable, global type, local function, local temporary variable, or constant macro) for which identifier is generated. Improves readability of generated code. |
$R | Code generator inserts root project name into identifier, replacing unsupported characters with the underscore (_) character. |
Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB documentation.
Generate a standalone C/C++ static library from a MATLAB function that is suitable for code generation.
Note: To generate code for this example, you must have an Embedded Coder license. |
Write a MATLAB function, coderand
,
that generates a random scalar value from the standard uniform distribution
on the open interval (0,1).
function r = coderand() %#codegen % The directive %#codegen declares that the function % is intended for code generation r = rand();
Create a code generation configuration object to generate a static library.
cfg = coder.config('lib')
coder.EmbeddedCodeConfig
object.Set the PurelyIntegerCode
parameter
to true
to enable generation of integer-only code.
cfg.PurelyIntegerCode = true;
Generate the C library files in the default folder
(codegen/lib/coderand). Use the -config
option
to specify the configuration object.
codegen -config cfg coderand
Use the coder
function to create a MATLAB Coder project.
The project provides a user interface that facilitates adding MATLAB files,
defining input parameters, and specifying build parameters.
codegen
| coder
| coder.config