Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Real-Time Workshop Checks

Real-Time Workshop Overview

Use Real-Time Workshop Model Advisor checks to configure your model for code generation.

See Also

Check solver for code generation

Check model solver and sample time configuration settings.

Description

Incorrect configuration settings can stop the Real-Time Workshop software from generating code. Underspecifying sample times can lead to undesired results. Avoid generating code that might corrupt data or produce unpredictable behavior.

Results and Recommended Actions

ConditionRecommended Action
The solver type is set incorrectly for model level code generation.Set Configuration Parameters > Solver >
  • Type to Fixed-step

  • Solver to Discrete (no continuous states)

Multitasking diagnostic options are not set to error.Set Configuration Parameters > Diagnostics >

Tips

You do not have to modify the solver settings to generate code from a subsystem. The Real-Time Workshop Embedded Coder build process automatically changes Solver type to fixed-step when you select Real-Time Workshop > Build Subsystem or Real-Time Workshop > Generate S-Function from the subsystem context menu.

See Also

Identify questionable blocks within the specified system

Identify blocks not supported by code generation or not recommended for deployment.

Description

The code generator creates code only for the blocks that it supports. Some blocks are not recommended for production code deployment.

Results and Recommended Actions

ConditionRecommended Action
A block is not supported by the Real-Time Workshop software.Remove the specified block from the model or replace the block with the recommended block.
A block is not recommended for production code deployment.Remove the specified block from the model or replace the block with the recommended block.
Check for Gain blocks whose value equals 1.Replace Gain blocks with Signal Conversion blocks.

See Also

Block Support Considerations

Check for model reference configuration mismatch

Identify referenced model configuration parameter settings that do not match the top model configuration parameter settings.

Description

The code generator cannot create code for top models that contain referenced models with different, incompatible configuration parameter settings.

Results and Recommended Actions

ConditionRecommended Action
The top model and the referenced model have inconsistent configuration parameter settings. Modify the specified Configuration Parameters settings.

See Also

Model Referencing Configuration Parameter Requirements

Check the hardware implementation

Identify inconsistent or underspecified hardware implementation settings

Description

The Simulink and Real-Time Workshop software require two sets of target specifications. The first set describes the final intended production target. The second set describes the currently selected target. If the configurations do not match, the code generator creates extra code to emulate the behavior of the production target. Inconsistencies or underspecification of hardware attributes can lead to nonoptimal results.

Results and Recommended Actions

ConditionRecommended Action
Your system target file is grt.tlc.Use an ERT-based target to generate final production code.
Hardware implementation parameters are not set to recommended values.Specify the following Configuration Parameters > Hardware Implementation parameters to the recommended values:
  • Number of bits

  • Byte ordering

  • Signed integer division rounding

Hardware implementation Embedded Hardware settings do not match Emulation Hardware settings.Select the Configuration Parameters > Hardware Implementation > None check box and configure the Emulation hardware settings.
The target hardware has not been configured.Specify the parameters in the Emulation hardware box in the Configuration Parameters > Hardware Implementationpane.

Limitations

A Real-Time Workshop Embedded Coder license is required to use an ERT-based target.

See Also

Making GRT-Based Targets ERT-Compatible

Identify questionable software environment specifications

Identify questionable software environment settings.

Description

Results and Recommended Actions

ConditionRecommended Action
The maximum identifier length does not conform with industry standards for C. Set the Configuration Parameters > Real-Time Workshop > Symbols > Maximum identifier length parameter to 31 characters.
Real-Time Workshop Interface parameters are not set to recommended values.Set the following Configuration Parameters > Real-Time Workshop > Interface parameters to the recommended values:
  • Support: continuous time

  • Support: non-finite numbers

  • Support: non-inlined S-functions

Real-Time Workshop Symbols parameters are not set to recommended values.Set the Configuration Parameters > Real-Time Workshop > Symbols > Generate scalar inlined parameters as parameter to Literals.
Support: variable-size signals is selected. This might lead to inefficient code.If you do not intend to support variable-sized signals, clear the Real-Time Workshop > Interface > Support: variable-size signals check box in the Configuration Parameters dialog box.
The model contains Stateflow charts with weak Simulink I/O data type specifications.Select the Stateflow chart property Use Strong Data Typing with Simulink I/O. You might need to adjust the data types in your model after selecting the property.

Limitations

A Stateflow license is required when using Stateflow charts.

See Also

Strong Data Typing with Simulink I/O

Identify questionable code instrumentation (data I/O)

Identify questionable code instrumentation.

Description

Results and Recommended Actions

ConditionRecommended Action
Interface parameters are not set to recommended values.Set the Configuration Parameters > Real-Time Workshop > Interface parameters to the recommended values.
Blocks generate assertion code.Set the Configuration Parameters > Diagnostics > Data Validity > Model Verification block enabling parameter to Disable All on a block-by-block basis or globally.
Block output signals have one or more test points and the Ignore test point signals check box is cleared in the Real-Time Workshop pane of the Configuration Parameters dialog box .

Remove test points from the specified block output signals. For each signal, in the Signal Properties dialog box, clear the Test point check box.

Alternatively, if the model is using an ERT-based system target file, select the Ignore test point signals check box in the Real-Time Workshop pane of the Configuration Parameters dialog box to ignore test points during code generation.

Check for blocks that have constraints on tunable parameters

Identify blocks with constraints on tunable parameters.

Description

Lookup Table and Lookup Table (2-D) blocks have strict constraints when they are tunable. If you violate lookup table block restrictions, the generated code produces wrong answers.

Results and Recommended Actions

ConditionRecommended Action
Lookup Table blocks have tunable parameters.When tuning parameters during simulation or when running the generated code, you must:
  • Preserve monotonicity of the setting for the Vector of input values parameter.

  • Preserve the number and location of zero values that you specify for Vector of input values and Vector of output values parameters if you specify multiple zero values for the Vector of input values parameter.

Lookup Table (2-D) blocks have tunable parameters.When tuning parameters during simulation or when running the generated code, you must:
  • Preserve monotonicity of the setting for the Row index input values and Column index of input values parameters.

  • Preserve the number and location of zero values that you specify for Row index input values, Column index of input values, and Vector of output values parameters if you specify multiple zero values for the Row index input values or Column index of input values parameters.

See Also

Lookup Table block

Identify questionable subsystem settings

Identify questionable subsystem block settings.

Description

Subsystem blocks implemented as void/void functions in the generated code use global memory to store the subsystem I/O.

Results and Recommended Actions

ConditionRecommended Action
Subsystem blocks have the Subsystem Parameters > Real-Time Workshop system code option set to Function.Set the Subsystem Parameters > Real-Time Workshop system code parameter to Auto.

See Also

Subsystem block

Disable signal logging

Disables unnecessary signal logging.

Description

Disabling unnecessary signal logging avoids declaring extra signal memory in generated code.

Analysis Results and Recommended Actions

ConditionsRecommended Action
Signals are logged.Disable signal logging on all signals.

Action Results

Clicking Modify All disables signal logging on all logged signals.

Identify blocks that generate expensive saturation and rounding code

Check for blocks that generate expensive saturation or rounding code.

Description

Results and Recommended Actions

ConditionRecommended Action
Blocks generate expensive saturation code.Check each block to ensure that your application requires setting Function Block Parameters > Signal Attributes > Saturate on integer overflow. Otherwise, clear the Saturate on integer overflow parameter to ensure the most efficient implementation of the block in the generated code.
Generated code is inefficient.Set the Function Block Parameters > Integer rounding mode parameter to the recommended value.

Check sample times and tasking mode

Set up the sample time and tasking mode for your system.

Description

Incorrect tasking mode can result in inefficient code execution or incorrect generated code.

Results and Recommended Actions

ConditionRecommended Action
The model represents a multirate system but is not configured for multitasking.Set the Configuration Parameters > Solver > Tasking mode for periodic sample times parameter as recommended.
The model is configured for multitasking, but multitasking is not appropriate for the target hardware.Set the Configuration Parameters > Solver > Tasking mode for periodic sample times parameter to SingleTasking, or change the Configuration Parameters > Hardware Implementation settings.

See Also

Single-Tasking and Multitasking Execution Modes

Identify questionable fixed-point operations

Identify fixed-point operations that can lead to nonoptimal results.

Description

The following operations can lead to nonoptimal results:

Results and Recommended Actions

ConditionRecommended Action
Integer division generated code is large.Set the Configuration Parameters > Hardware Implementation > Signed integer division rounds to parameter to the recommended value.
Protection code generated as part of the division operation is redundant.Verify that your model cannot cause exceptions in division operations and then remove redundant protection code by setting the Configuration Parameters > Optimization > Remove code that protects against division arithmetic exceptions parameter.
Generated code is inefficient.Set the Function Block Parameters > Integer rounding mode parameter to the recommended value.
Lookup Table vector of input values is not evenly spaced.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
Lookup Table vector of input values is not evenly spaced when quantized, but it is very close to being evenly spaced.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_evenspace_cleanup.
Lookup Table vector of input values is evenly spaced, but the spacing is not a power of 2.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
For a Prelookup or Lookup Table (n-D) block, Index search method is Evenly spaced points. Breakpoint data does not have power of 2 spacing.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. Otherwise, in the block parameter dialog box, specify a different Index search method to avoid the computation-intensive division operation.
Lookup Table (n-D) breakpoint data is not evenly spaced and Index search method is not Evenly spaced points.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing and then set Index search method to Evenly spaced points.
Lookup Table (n-D) breakpoint data is evenly spaced and Index search method is Evenly spaced points. But the spacing is not a power of 2.If breakpoint data is nontunable, adjust the data to have even, power of 2 spacing. See fixpt_look1_func_approx.
Lookup Table (n-D) breakpoint data is evenly spaced, but the spacing is not a power of 2. Also, Index search method is not Evenly spaced points.Set Index search method to Evenly spaced points. Also, if the data is nontunable, consider an even, power of 2 spacing.
Lookup Table (n-D) breakpoint data is evenly spaced, and the spacing is a power of 2. But the Index search method is not Evenly spaced points.Set Index search method to Evenly spaced points.
Blocks require cumbersome multiplication. Restrict multiplication operations:
  • So the product integer size is no larger than the target integer size.

  • To the recommended size.

Blocks multiply signals with nonzero bias.Insert a Data Type Conversion block before and after the block containing the multiplication operation.
Product blocks are multiplying signals with mismatched slope adjustment factors.Change the scaling of the output so that its slope adjustment factor is the product of the input slope adjustment factor.
Product blocks are multiplying signals with mismatched slope adjustment factors. The net slope correction uses multiplication followed by shifts, which is inefficient for some target hardware.Select Use integer division to handle net slopes that are reciprocals of integers if the net slope is the reciprocal of an integer and division is more efficient than multiplication and shifts on the target hardware.

Product blocks are configured to do multiple division operations.Multiply all the denominator terms together, and then do a single division using cascading Product blocks.
Product blocks are configured to do many multiplication or division operations.Split the operations across several blocks, with each block performing one multiplication or one division operation.
Product blocks are configured with a divide operation for the first input and a multiply operation for the second input. Reverse the inputs so the multiply operation occurs first and the division operation occurs second.
An input with an invariant constant value is used as the denominator in an online division operation. Change the operation to multiplication, and replace the invariant input by its reciprocal.
The data type range of the inputs of Sum blocks exceeds the data type range of the output, which can cause overflow or saturation.

Change the output and accumulator data types so the range equals or exceeds all input ranges.

For example, if the model has two inputs:

  • int8 (–128 to 127)

  • uint8 (0 to 255)

The data type range of the output and accumulator must equal or exceed –128 to 255. A int16 (–32768 to 32767) data type meets this condition.

A Sum block has an input with a slope adjustment factor that does not equal the slope adjustment factor of the output.Change the data types so the inputs, outputs, and accumulator have the same slope adjustment factor.
The net sum of the Sum block input biases does not equal the bias of the output. Change the bias of the output scaling, making the net bias adjustment zero.
The inputs of the Relational Operator block have different data types.
  • Change the data type and scaling of the invariant input to match other inputs.

  • Insert Data Type Conversion blocks before the Relational Operator block to convert both inputs to a common data type.

The inputs of the Relational Operator block have different slope adjustment factor.Change the scaling of either input.
The input and output of the MinMax block have different data types.Change the data type of the input or output.
The input of the MinMax block has a different slope adjustment factor than the output. Change the scaling of the input or the output.
The initial condition of the Discrete-Time Integrator block is used to initialize both the state and the output. Set the Function Block Parameters > Use initial condition as initial and reset value for parameter to State only (most efficient).

Limitations

A Simulink Fixed Point license is required to generate fixed-point code.

See Also

Check model configuration settings against code generation objectives

Check the configuration parameter settings for the model against the code generation objectives.

Description

Each parameter in the Configuration Parameters dialog box might have different recommended settings for code generation based on your objectives. This check helps you identify the recommended setting for each parameter so that you can achieve optimized code based on your objective.

Analysis Results and Recommended Actions

ConditionRecommended Action
Parameters are set to values other than the value recommended for the specified objectives.Set the parameters to the recommended values.

    Note   A change to one parameter value can impact other parameters. Successfully passing the check might take multiple iterations.

Action Results

Clicking Modify Parameters changes the parameter values to the recommended values.

See Also

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS