Main Content

Generate scalar inlined parameters as

Express scalar inlined parameter values in the generated code as literals or macros

Model Configuration Pane: Code Generation / Identifiers

Description

Control expression of scalar inlined parameter values in the generated code. Block parameters appear inlined in the generated code when you set Configuration Parameters > Optimization > Default parameter behavior to Inlined.

Dependencies

This parameter:

  • Appears only for ERT-based targets.

  • Requires Embedded Coder® when generating code.

Settings

Literals (default) | Macros
Literals

Generates scalar inlined parameters as numeric constants.

Macros

Generates scalar inlined parameters as variables with #define macros. This setting makes generated code more readable.

Examples

expand all

When you generate efficient code by inlining the numeric values of block parameters (with the configuration parameter Default parameter behavior), you can configure scalar parameters to appear as macros instead of literal numbers. Each macro has a unique name that is based on the name of the corresponding block parameter.

Open the example model sldemo_fuelsys_dd_controller.

sldemo_fuelsys_dd_controller

The model uses these configuration parameter settings:

  • Default parameter behavior set to Inlined.

  • System target file set to ert.tlc.

Set the configuration parameter Generate scalar inlined parameters as to Macros.

set_param('sldemo_fuelsys_dd_controller','InlinedPrmAccess','Macros')

Generate code from the model.

slbuild('sldemo_fuelsys_dd_controller')
### Starting build procedure for: sldemo_fuelsys_dd_controller
### Successful completion of code generation for: sldemo_fuelsys_dd_controller

Build Summary

Top model targets:

Model                         Build Reason                                         Status           Build Duration
==================================================================================================================
sldemo_fuelsys_dd_controller  Information cache folder or artifacts were missing.  Code generated.  0h 0m 39.053s 

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 44.655s

The header file sldemo_fuelsys_dd_controller_private.h defines several macros that represent inlined (nontunable) block parameters. For example, the macros rtCP_DiscreteFilter_NumCoe_EL_0 and rtCP_DiscreteFilter_NumCoe_EL_1 represent floating-point constants.

file = fullfile('sldemo_fuelsys_dd_controller_ert_rtw',...
    'sldemo_fuelsys_dd_controller_private.h');
coder.example.extractLines(file,'#define rtCP_DiscreteFilter_NumCoe_EL_0',...
    'rtCP_DiscreteFilter_NumCoe_EL_1',1,1)
#define rtCP_DiscreteFilter_NumCoe_EL_0 (8.7696F)
#define rtCP_DiscreteFilter_NumCoe_EL_1 (-8.5104F)

The comments above the macro definitions indicate that the code generated for a Discrete Filter block uses the macros.

coder.example.extractLines(file,'Computed Parameter: DiscreteFilter_NumCoef',...
    'Referenced by: ''<S12>/Discrete Filter''',1,1)
/* Computed Parameter: DiscreteFilter_NumCoef
 * Referenced by: '<S12>/Discrete Filter'

Click the hyperlink to navigate to the block in the model.

Tips

  • If you configure a block parameter to use the storage class Define, the generated code uses variables with #define macros to represent the parameter, and the storage class setting overrides Generate scalar inlined parameter as.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityMacros
EfficiencyLiterals
Safety precautionNo impact

Programmatic Use

Parameter: InlinedPrmAccess
Type: character vector
Value: Literals | Macros
Default: Literals

Version History

Introduced before R2006a