www.kxcad.net Home > CAE Software Index > MATLAB Index >
Reduce execution time by collapsing or removing groups of blocks.
Default: On
Simulink searches for and reduces the following block patterns:
Accumulators — A group consisting of a Constant block, a Sum block, and feedback through a Unit Delay block.
Redundant type conversions — Unnecessary type conversion blocks, such as an int type conversion block with an input and output of type int.
Dead code — Blocks or signals in an unused code path.
Fast-to-slow Rate Transition block in a single-tasking system — Rate Transition blocks with an input frequency faster than its output frequency.
Simulink does not search for block patterns that can be optimized. Simulation and generated code are not optimized.
When you select Block reduction, Simulink collapses certain groups of blocks into a single, more efficient block, or removes them entirely. This results in faster execution during model simulation and in generated code.
Block reduction does not change the appearance of the source model.
Tunable parameters do not prevent a block from being reduced by dead code elimination.
Once block reduction takes place, Simulink does not display the sorted order for blocks that have been removed.
Block reduction is only intended to remove the generated code that represents execution of a block. Other supporting data, such as definitions for sample time and data types might remain in the generated code.
Accumulators. Simulink recognizes the block diagram shown in the following figure as an accumulator:

An accumulator construct is recognized anywhere across a block diagram, or within subsystems at lower levels.
With the Block reduction option enabled, Simulink creates a synthesized block, Sum_synth_accum. The synthesized block replaces the previous block diagram, resulting in a simple increment calculation.
Dead Code Elimination. Any blocks or signals in an unused code path are eliminated from generated code.
The following conditions need to be met for a block to be considered part of an unused code path:
All signal paths for the block end with a block that does not execute. Examples of blocks that do not execute include Terminator blocks, disabled Assertion blocks, S-Function blocks configured for block reduction, and To Workspace blocks for which MAT-file logging is disabled for code generation.
No signal paths for the block include global signal storage downstream from the block.
Tunable parameters do not prevent a block from being reduced by dead code elimination.
Consider the signal paths in the following block diagram.

If you check Block reduction, Real-Time Workshop responds to each signal path as follows:
| For Signal Path... | Real-Time Workshop... |
|---|---|
| In1 to Out1 | Always generates code because dead code elimination conditions are not met. |
| In2 to Terminator | Never generates code because dead code elimination conditions are met. |
| In3 to Scope | Generates code if MAT-file logging is enabled and eliminates code if MAT-file logging is disabled. |
| Parameter: BlockReduction |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'on' |
| Application | Setting |
|---|---|
| Debugging | Off |
| Traceability | Off |
| Efficiency | On |
| Safety precaution | No impact |