plc coder: optimization -凯发k8网页登录

main content

plc coder: optimization

optimization overview

select the code generation optimization settings.

see also

generate structured text from the model window

default parameter behavior

transform numeric block parameters into constant inlined values in the generated code. this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

description

transform numeric block parameters into constant inlined values in the generated code.

category: optimization

settings

default: tunable for grt targets | inlined for ert targets

inlined

set default parameter behavior to inlined to reduce global ram usage and increase efficiency of the generated code. the code does not allocate memory to represent numeric block parameters such as the gain parameter of a gain block. instead, the code inlines the literal numeric values of these block parameters.

tunable

set default parameter behavior to tunable to enable tunability of numeric block parameters in the generated code. the code represents numeric block parameters and variables that use the storage class auto, including numeric matlab® variables, as tunable fields of a global parameters structure.

tips

  • whether you set default parameter behavior to inlined or to tunable, create parameter data objects to preserve tunability for block parameters. for more information, see (simulink coder).

  • when you switch from a system target file that is not ert-based to one that is ert-based, default parameter behavior sets to inlined by default. however, you can change the setting of default parameter behavior later.

  • when a top model uses referenced models, or if a model is referenced by another model:

    • all referenced models must set default parameter behavior to inlined if the top model has default parameter behavior set to inlined.

    • the top model can specify default parameter behavior as tunable or inlined.

  • if your model contains an block, you can suppress code generation for the branch connected to the sim port if you set default parameter behavior to inlined and the branch does not contain external signals.

command-line information

parameter:plc_plcenablevarreuse
type: string
value: 'on' | 'off'
default: 'on'

see also

generate structured text from the model window

signal storage reuse

reuse signal memory. this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: on

on

reuses memory buffers allocated to store block input and output signals, reducing the memory requirement of your real-time program.

off

allocates a separate memory buffer for each block's outputs. this allocation makes block outputs global and unique, which in many cases significantly increases ram and rom usage.

tips

  • this option applies only to signals with storage class auto.

  • signal storage reuse can occur among only signals that have the same data type.

  • clearing this option can substantially increase the amount of memory required to simulate large models.

  • clear this option if you want to:

    • debug a c-mex s-function.

    • use a or a block with the floating display option selected to inspect signals in a model that you are debugging.

  • if you select signal storage reuse and attempt to use a floating scope or floating display block to display a signal whose buffer has been reused, an error dialog box opens.

command-line information

parameter:plc_plcenablevarreuse
type: string
value: 'on' | 'off'
default: 'on'

see also

generate structured text from the model window

remove code from floating-point to integer conversions that wraps out-of-range values

enable code removal for efficient casts. this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: on

on

removes code from floating-point to integer conversions.

off

does not remove code from floating-point to integer conversions.

tips

use this parameter to optimize code generation.

command-line information

parameter: plc_plcenableefficientcast
type: string
value: 'on' | 'off'
default: 'on'

see also

generate structured text from the model window

generate reusable code

using this option, you can generate better reusable code for reusable subsystems. for instance, if your model contains multiple instances of the same subsystem and some instances have constant inputs, by default, the generated code contains separate function blocks for each instance. if you select this option, the software does not consider whether the inputs to the subsystem are constant and generates one function block for the multiple instances.

this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: off

on

generates better reusable code for reusable subsystems.

off

reverts to its default behavior. instead of a single reusable function block, the software generates separate function blocks for individual instances of a reusable subsystem because of certain differences in their inputs.

tips

  • if you find multiple function blocks in your generated code for multiple instances of the same subsystem, select this option. the software performs better identification of whether two instances of a subsystem are actually the same and whether it can combine the multiple blocks into one reusable function block.

  • if different instances of a subsystem have different values of a block parameter, you cannot generate reusable code. clear this option or use the same block parameter for all instances.

  • despite selecting this option, if you do not see reusable code for different instances of a subsystem, you can determine the reason. to determine if two reusable subsystems are identical, the code generator internally uses a checksum value. you can compare the checksum values for two instances of a subsystem and investigate why they are not identical.

    to get the checksum values for the two instances that you expect to be identical, use the function . if the checksum values are different, investigate the checksum details to see why the values are not identical.

command-line information

parameter:plc_generatereusablecode
type: string
value: 'on' | 'off'
default: 'off'

see also

inline named constants

using this option, you can control inlining of global named constants. by default, the generated code contains named ssmethodtype constants for internal states or other simulink® semantics. if you select this option, the software replaces the named constants with its integer value.

this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: off

on

inlines named constants.

off

reverts to its default behavior and uses named constants in the generated code.

command-line information

parameter:plc_inlinenamedconstant
type: string
value: 'on' | 'off'
default: 'off'

see also

reuse matlab function block variables

you can use this option to enable reuse of matlab function block variables in the generated code.

this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: off

on

generates code that reuses matlab function block variables where appropriate.

off

reverts to its default behavior and does not reuse variables in the generated code.

command-line information

parameter:plc_reusemlfcnvariable
type: string
value: 'on' | 'off'
default: 'off'

see also

fold temporary variable using function block instance output variable

use this to optimize the code for the output variables of function blocks generated from reusable simulink subsystems, stateflow® charts, or matlab function blocks by removing temporary variable assignments that are not required. this option is available on the plc code generation> optimization pane in the configuration parameters dialog box.

settings

default: off

on

generates optimized code for output variables of function blocks by folding temporary variables into a single expression.

off

the generated code for function block instance output variables uses temporary variable assignments.

command-line information

parameter:plc_foldfbcalloutputvar
type: string
value: 'on' | 'off'
default: 'off'

limitations

this option is not supported for the rockwell automation® studio 5000 and the omron sysmac® studio target ides.

loop unrolling threshold

specify the minimum signal or parameter width for which a for loop is generated. this option is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: 5

specify the array size at which the code generator begins to use a for loop instead of separate assignment statements to assign values to the elements of a signal or parameter array.

when the loops are perfectly nested loops, the code generator uses a for loop if the product of the loop counts for all loops in the perfect loop nest is greater than or equal to this threshold.

command-line information

parameter: plc_rollthreshold
type: string
value: any valid value
default: '5'

see also

generate structured text from the model window

remove unused ssmethod fb call arguments

enable this parameter to generate less complex, more readable code by removing unused arguments in function block calls from ssmethod calls. this parameter is available on the plc code generation > optimization pane in the configuration parameters dialog box.

settings

default: off

on

generate readable, less complex code by removing unused arguments in function block calls from ssmethod calls in the generated code.

off

do not remove unused arguments in function block calls.

command-line information

parameter:plc_removeunusedssmethodcallarguments
type: string
value: 'on' | 'off'
default: 'off'

limitations

before you enable this option, ensure that the target ide supports the removal of unused arguments in function block calls from ssmethod calls.

网站地图