Generate scalar inlined parameters as

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.

Category: Code Generation > Identifiers

Settings

Default: Literals

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.

Dependencies

This parameter:

  • Appears only for ERT-based targets.

  • Requires Embedded Coder® when generating code.

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityMacros
EfficiencyNo impact
Safety precautionNo impact

Improve Code Readability by Generating Block Parameter Values as Macros

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.

rtwbuild('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 built:

Model                         Action          Rebuild Reason                                    
================================================================================================
sldemo_fuelsys_dd_controller  Code generated  Code generation information file does not exist.  

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

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');
rtwdemodbtype(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.

rtwdemodbtype(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.

Related Topics