Documentation Center

  • Trial Software
  • Product Updates

Automatic Data Typing Using Derived Ranges

Prerequisites for Autoscaling Using Derived Ranges

The Fixed-Point Tool uses range analysis to derive minimum and maximum values for objects in your model.

Range analysis:

Set Up the Model

To use the Fixed-Point Tool to generate data type proposals for your model based on derived minimum and maximum values only, you must first set up your model in Simulink®.

  1. Back up your model in case of error and as a baseline for testing and validation.

  2. Open your model in Simulink.

  3. Select Simulation > Normal in the Simulink menu so that the model runs in Normal mode. The Fixed-Point Tool supports only Normal mode.

  4. To autoscale using derived data, you must specify design minimum and maximum values on at least the model inputs. The range analysis tries to narrow the derived range by using all the specified design ranges in the model. The more design range information you specify, the more likely the range analysis is to succeed. As the analysis is performed, it derives new range information for the model and then attempts to use this new information together with the specified ranges to derive ranges for the remaining objects in the model. For this reason, the analysis results might depend on block priorities because these priorities determine the order in which the software analyzes the blocks.

    You specify a design range for model objects using parameters typically titled Output minimum and Output maximum. For a list of blocks that permit you to specify these values, see Blocks That Allow Signal Range Specification.

  5. Specify fixed-point data types for blocks and signals in your model. For blocks with the Data Type Assistant, use the Calculate Best-Precision Scaling button to calculate best-precision scaling automatically. For more information, see Specify Fixed-Point Data Types with the Data Type Assistant.

  6. You can choose to lock some blocks against automatic data typing by selecting the Lock output data type setting against changes by the fixed-point tools parameter. If you select the Lock output data type setting against changes by the fixed-point tools parameter, the tool does not propose data types for that object.

  7. From the Simulink Simulation menu, select Update Diagram to perform parameter range checking for all blocks in the model.

    If update diagram fails, use the failure information to fix the errors in your model. After fixing the errors, test update diagram again. If you are unable to fix the errors, restore your back-up model.

  8. If the model changed, back up the model in case of error and as a baseline for testing and validation.

  9. Create a shortcut to capture the initial fixed-point instrumentation and data type override settings. For more information, see Capture Model Settings Using the Shortcut Editor.

Prepare Model for Autoscaling Using Derived Data

First use the Fixed-Point Advisor to prepare the model for conversion to fixed point. You do this preparation only once. The Fixed-Point Advisor gives advice about model and block configuration settings to prepare for automatic conversion to fixed point using the Fixed-Point Tool. The Fixed-Point Advisor:

  • Checks the model against fixed-point guidelines.

  • Identifies unsupported blocks.

  • Removes output data type inheritance from blocks.

  • Allows you to promote simulation minimum and maximum values to design minimum and maximum values. This capability is useful if you have not specified design ranges and you have simulated the model with inputs that cover the full intended operating range. For more information, see Specify block minimum and maximum values.

  • Runs simulation range detection diagnostics. When preparing the model for automatic data typing using derived data, you can complete the preparation without setting up signal logging and creating a simulation reference run. However, creating at least one simulation run is useful for early error detection. Simulating the model helps to verify that the design minimum and maximum values specified on the model are correct and that the model conforms to modeling guidelines.

To open the Fixed-Point Advisor:

  1. From the Simulink Analysis menu, select Fixed-Point Tool.

  2. On the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem of interest.

  3. On the Fixed-point preparation for selected system pane, click Fixed-Point Advisor.

    Use the Fixed-Point Advisor to prepare the model for conversion. For more information, see Preparation for Fixed-Point Conversion.

Derive Minimum and Maximum Values

  1. On the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem of interest.

  2. On the Settings for selected system pane, set Data type override to Double.

  3. Optionally, in the Data collection pane Store results in run field, specify a run name. Specifying a unique run name avoids overwriting results from previous runs.

  4. In the Fixed-Point Tool, click Derive min/max values for selected system.

    The analysis runs and tries to derive range information for objects in the selected system.

    If the analysis successfully derives range data for the model, the Fixed-Point Tool displays the derived minimum and maximum values for the blocks in the selected system. (See View Derived Ranges in the Fixed-Point Tool.) Before proposing data types, review the results.

    If the analysis fails, examine the error messages and resolve the issues. See Resolve Range Analysis Issues.

Resolve Range Analysis Issues

The following table shows the different types of range analysis issues and the steps to resolve them.

Analysis ResultsNext StepsFor More Information

The analysis fails because the model contains blocks that it does not support. The Fixed-Point Tool generates an error.

Review the error message information and replace the unsupported blocks.

Model Compatibility with Range Analysis

The analysis cannot derive range data because the model contains conflicting design range information. The Fixed-Point Tool generates an error.

Examine the design ranges specified in the model to identify inconsistent design specifications and modify them to make them consistent.

Fixing Design Range Conflicts

The analysis cannot derive range data for an object because there is insufficient design range information specified on the model. The Fixed-Point Tool highlights the results for the object.

Examine the model to determine which design range information is missing.

Providing More Design Range Information

Proposing Data Types

Unless you select an object's Lock output data type setting against changes by the fixed-point tools parameter or the data types are using inheritance rules, the Fixed-Point Tool proposes data types for model objects that specify fixed-point data types. You set up the tool to either propose fraction lengths for specified word lengths or to propose word lengths for specified fraction lengths. For more information, see Propose Fraction Lengths and Propose Word Lengths.

When generating data type proposals, the Fixed-Point Tool collects the following types of range data for model objects:

  • Design minimum or maximum values — You specify a design range for model objects using parameters typically titled Output minimum and Output maximum. For a list of blocks that permit you to specify these values, see Blocks That Allow Signal Range Specification.

  • Simulation minimum or maximum values — When simulating a system whose Fixed-point instrumentation mode parameter specifies Minimums, maximums and overflows, the Fixed-Point Tool logs the minimum and maximum values generated by model objects. For more information about the Fixed-point instrumentation mode parameter, see fxptdlg.

  • Derived minimum or maximum values — When deriving minimum and maximum values for a selected system, the Fixed-Point Tool uses the design minimum and maximum values that you specify for the model to derive range information for signals in your model. For more information, see Derive Ranges.

    For models that contain floating-point operations, range analysis might report a range that is slightly larger than expected due to rounding errors in the analysis. Automatic data typing bases its proposal on this slightly larger derived range. To avoid this issue, use the safety margin for design and derived min/max.

The Fixed-Point Tool uses available range data to calculate data type proposals according to the following rules:

  • Design minimum and maximum values take precedence over the simulation and derived range.

    The Safety margin for design and derived min/max (%) parameter specifies a range that differs from that defined by the design range. For example, a value of 20 specifies that a range of at least 20 percent larger is desired. A value of -10 specifies that a range of up to 10 percent smaller is acceptable. If this parameter is not visible in the Automatic data typing for selected system pane, click the Configure link.

    For more information, see Safety margin for design and derived min/max (%) in the fxptdlg reference.

  • The tool observes the derived range only when the Derived min/max option is selected. Otherwise, the tool ignores the derived range.

    The Safety margin for design and derived min/max (%) parameter specifies a range that differs from that defined by the derived range. For more information, see Percent safety margin for design and derived min/max in the fxptdlg reference.

  • The tool observes the simulation range only when the Simulation min/max option is selected. Otherwise, the tool ignores the simulation range.

    The Safety margin for simulation min/max (%) parameter specifies a range that differs from that defined by the simulation range. For more information, see Safety margin for simulation min/max (%) in the fxptdlg reference.

Propose Data Types

  1. On the Automatic data typing for selected system Settings pane, select either Propose fraction lengths for specified word lengths or Propose word lengths for specified fraction lengths, as applicable.

    If these options are not visible, use the Configure link to display them.

  2. If you have a safety margin to apply, set Safety margin for design and derived min/max (%). For example, enter 10 for a 10% safety margin.

  3. Click the Propose fraction lengths or Propose word lengths button to generate a proposal, .

      Note:   When the Fixed-Point Tool proposes data types, it does not alter your model.

    If there are conflicts in your model, the Fixed-Point Tool displays the Result Details dialog box.

    If you do not see this warning, there are no conflicts in your model, go to Apply Proposed Data Types.

Examine Results to Resolve Conflicts

You can examine each data type proposal using the Result Details dialog box, which displays the rationale underlying the proposal. Also, this dialog box describes potential issues or errors, and provides methods for resolving them. To open the dialog box:

  1. On the Contents pane, select an object that has proposed data types.

  2. Click the Show details for selected result button .

The Result Details dialog box provides the following information about the proposed data type, as appropriate.

Summary

Details about which run the result is in and the current data type specified for the selected object.

Proposed Data Type Summary

Describes a data type proposal in terms of how it differs from the object's current data type. For cases when the Fixed-Point Tool does not propose data types, provides a rationale. For example, the data type might be locked against changes by the fixed-point tool.

Needs Attention

Lists potential issues and errors associated with data type proposals. Describes the issues and suggests methods for resolving them. The dialog box uses the following icons to differentiate warnings from errors.

Indicates a warning message.

Indicates an error message.

Shared Data Type Summary

This section of the dialog box informs you that the selected object must share the same data type as other objects in the model because of data type propagation rules. For example, the inputs to a Merge block must have the same data type. Therefore, the outputs of blocks that connect to these inputs must share the same data type.

**The Shared Data Type Summary also reports all source blocks that drive the same element of a bus object. **

The dialog box provides a hyperlink that you can click to highlight the objects that share data types in the model. To clear this highlighting, from the model View menu, select Remove Highlighting.

The Fixed-Point Tool allocates an identification tag to objects that must share the same data type. The tool displays this identification tag in the DTGroup column for the object. To display only the objects that must share data types, from the Fixed-Point Tool main toolbar, select the Show option.

Constrained Data Type Summary

Some Simulink blocks accept only certain data types on some ports. This section of the dialog box informs you when a block that connects to the selected object has data type constraints that impact the proposed data type of the selected object. The dialog box lists the blocks that have data type constraints, provides details of the constrained data types, and links to the blocks in the model.

Data Type Details

Provides a table that lists a model object attributes that influence its data type proposal.

ItemDescription

Currently Specified Data Type

Data type that an object specifies.

Proposed Data Type

Data type that the Fixed-Point Tool proposes for this object.

Proposed Representable Maximum

Maximum value that the proposed data type can represent.

Design Maximum

Design maximum value that an object specifies using, e.g., its Output maximum parameter.

Simulation Maximum

Maximum value that occurs during simulation.

Derived Maximum

Maximum value that the Fixed-Point Tool derives for this signal from design ranges.

Intermediate Maximum

Intermediate maximum value reached by the object based on design ranges.

Intermediate Minimum

Intermediate minimum value reached by the object based on design ranges.

Derived Minimum

Minimum value that the Fixed-Point Tool derives for this signal from design ranges.

Simulation Minimum

Minimum value that occurs during simulation.

Design Minimum

Design minimum value that an object specifies using, e.g., its Output minimum parameter.

Proposed Representable Minimum

Minimum value that the proposed data type can represent.

The dialog box table also includes a column titled Percent Proposed Representable. This column indicates the percentage of the proposed representable range that each value covers. Overflows occur when values lie outside this range.

Shared Values.  When proposing data types, the Fixed-Point Tool attempts to satisfy data type requirements that model objects impose on one another. For example, the Sum block provides an option that requires all of its inputs to have the same data type. Consequently, the dialog box table might also list attributes of other model objects that impact the data type proposal for the selected object. In such cases, the table displays the following types of shared values:

  • Initial Values

    Some model objects provide parameters that allow you to specify the initial values of their signals. For example, the Constant block includes a Constant value parameter that initializes the block output signal. The Fixed-Point Tool uses initial values to propose data types for model objects whose design and simulation ranges are unavailable. When data type dependencies exist, the tool considers how initial values impact the proposals for neighboring objects.

  • Model-Required Parameters

    Some model objects require the specification of numeric parameters to compute the value of their outputs. For example, the Table data parameter of an n-D Lookup Table block specifies values that the block requires to perform a lookup operation and generate output. When proposing data types, the Fixed-Point Tool considers how this "model-required" parameter value impacts the proposals for neighboring objects.

To Examine the Results and Resolve Conflicts

  1. On the Fixed-Point Tool toolbar, use the Show option to filter the results to show Conflicts with proposed data types.

    The Fixed-Point Tool lists its data type proposals on the Contents pane under the ProposedDT column. The tool alerts you to potential issues for each object in the list by displaying a green, yellow, or red icon.

    The proposed data type poses no issues for this object.

    The proposed data type poses potential issues for this object.

    The proposed data type will introduce data type errors if applied to this object.

  2. Review and fix each error.

    1. Select the error, right-click, and from the context menu, select Highlight Block In Model to identify which block has a conflict.

    2. Click the Show details for selected result button to open the Result Details dialog box.

    3. Use the information provided in the Needs Attention section of the Result Details dialog box to resolve the conflict by fixing the problem in the Simulink model.

  3. Review the Result Details for the warnings and correct the problem if necessary.

  4. You have changed the Simulink model, so the benchmark data is not up to date. Click the Fixed-Point Tool Start button to rerun the simulation.

    The Fixed-Point Tool warns you that you have not applied proposals. Click the Ignore and Simulate button to continue.

  5. Click the Propose fraction lengths or Propose word lengths button to generate a data type proposal, .

  6. On the Fixed-Point Tool toolbar, use the Show option to filter the results to show All results.

Apply Proposed Data Types

After reviewing the data type proposals, apply the proposed data types to your model. The Fixed-Point Tool allows you to apply its data type proposals selectively to objects in your model. On the Contents pane, use the Accept check box to specify the proposals that you want to assign to model objects. The check box indicates the status of a proposal:

The Fixed-Point Tool will apply the proposed data type to this object. By default, the tool selects the Accept check box when a proposal differs from the object's current data type.

The Fixed-Point Tool will ignore the proposed data type and leave the current data type intact for this object.

No proposal exists for this object, for example, when the object specifies a data type inheritance rule or is locked against automatic data typing.

  1. Examine each result. For more information about a particular result, select the result and then click the Show details for selected result button to open the Result Details dialog box.

  2. If you do not want to accept the proposal for a result, on the Fixed-Point Tool Contents pane, clear the Accept check box for that result.

    Before applying proposals to your model, the Fixed-Point Tool enables you to customize them. On the Contents pane, click a ProposedDT cell and edit the data type expression. For information about specifying fixed-point data types, see fixdt.

  3. Click the Apply accepted fraction lengths or Apply accepted word lengths button to write the proposed data types to the model.

    If you have not fixed all the warnings in the model, the Fixed-Point Tool displays a warning dialog box.

Update Diagram

From the model's Simulation menu, select Update Diagram.

After applying the data types to the model, update diagram to check for data type propagation issues.

If update diagram fails, use the failure information to fix the errors in your model. After fixing the errors, test update diagram again. If you are unable to fix the errors, restore your backed up model.

Was this topic helpful?