Documentation

Automatic Data Typing Using Derived Ranges

The Fixed-Point Tool automates the task of specifying fixed-point data types in a Simulink® model. This process is also known as autoscaling. The tool collects range data for model objects, either from design minimum and maximum values that objects specify explicitly, from logged minimum and maximum values that occur during simulation, or from minimum and maximum values derived using range analysis. Based on these values, the tool proposes fixed-point data types that maximize precision and cover the range.

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 works only for compatible models. For more information, see Model Compatibility with 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 as a baseline for testing and validation.

  2. Open your model in Simulink.

  3. In the model, select Simulation > Mode > Normal 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 such as Output minimum and Output maximum. For a list of blocks in which you can specify these values, see Blocks That Allow Signal Range Specification.

  5. 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 this parameter, the tool does not propose data types for the block.

  6. Update the diagram to perform parameter range checking for all blocks in the model.

    If updating the diagram fails, use the error messages to fix the errors in your model. After fixing the errors, update the diagram again. If you cannot fix the errors, restore your backup model.

  7. If the model changed, back up the model again.

Select System Under Design

  1. In your model, select Analysis > Fixed-Point Tool.

  2. Under System Under Design, specify the system or subsystem you want to convert. To continue with the conversion on the current system, click Continue. Otherwise, click Change and select the system.

Optionally, 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.

You can also use the Fixed-Point Advisor to identify unsupported blocks in your model and prepare the model for conversion. For more information, see Preparation for Fixed-Point Conversion.

Derive Minimum and Maximum Values

  1. Under Range collection, specify a run name in the Run name field. Specify a unique run name to avoid overwriting results from previous runs.

  2. Specify if you want to derive ranges for the selected system under design, or for the whole model in the Derive ranges for field. Click Derive ranges.

    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

The Fixed-Point Tool proposes a data type for all objects whose Lock output data type setting against changes by the fixed-point tools parameter is cleared.

When proposing data types, the Fixed-Point Tool uses these types of range data for model objects:

  • Design minimum or maximum values — You specify a design range for model objects using parameters such as Output minimum and Output maximum. For a list of blocks for which you can specify these values, see Blocks That Allow Signal Range Specification.

  • Simulation minimum or maximum values — When simulating a system with instrumentation enabled, 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 Fixed-point instrumentation mode.

  • 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 on the blocks to derive range information for signals in your model. For more information, see Derive Ranges.

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

When proposing types use Parameter SettingFixed-Point Tool Action
All collected ranges

The Fixed-Point Tool uses design ranges in addition to derived and simulation ranges to propose data types.

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

Design and simulation ranges

The Fixed-Point Tool uses the design ranges in conjunction with collected simulation ranges to propose data types. Design ranges take precedence over simulation ranges.

The Safety margin for simulation min/max (%) parameter specifies a range that differs from that defined by the simulation range.

Design and derived ranges

The Fixed-Point Tool uses the design ranges in conjunction with derived ranges to propose data types. Design ranges take precedence over design ranges.

Propose Data Types

Under Automatic data typing, configure the proposal settings and generate proposals. When the Fixed-Point Tool proposes data types, it does not modify your model.

  1. Select the Signedness check box to have the Fixed-Point Tool propose signedness.

    When this box is selected, the Fixed-Point Tool proposes signedness based on range information.

  2. Select the type of length to propose.

    • When you select Word length, the Fixed-Point Tool uses range information and the specified Default fraction length value to propose word lengths for the objects in your model.

    • When you select Fraction length, the Fixed-Point Tool uses the range information and the specified Default word length value to propose best-precision fraction lengths for the objects in your model.

  3. Specify whether to propose new data types for objects that use inherited and floating-point output data types by selecting the corresponding check boxes.

  4. Specify the default word length or default fraction length to use for proposals.

  5. Select the type of ranges for the Fixed-Point Tool to use for proposals from the When proposing types use menu.

  6. To generate proposals, click the Propose data types button .

Examine Results to Resolve Conflicts

You can examine each proposal using the Result Details tab, which displays the rationale for the proposed data types. This tab also describes potential issues or errors, and suggests methods for resolving them. To view the details, on the Contents pane, select an object that has a proposed data type. Then select the Result Details tab in the right-most pane of the Fixed-Point Tool.

The Result Details tab provides this information about the proposed data types.

Proposed Data Type Summary

The summary describes a proposal in terms of how it differs from the currently specified data type of the object. For cases when the Fixed-Point Tool does not propose data types, this section provides a rationale. For example, the data type might be locked against changes by the fixed-point tools.

This section of the Result Details tab also informs you if the selected object must use 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 use the same data type. Similarly, blocks that are connected by the same element of a virtual bus must use the same data type.

In the tab, click the link to highlight the objects that share data types in the model. To clear this highlighting, right-click in the model and select Remove Highlighting.

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

Some Simulink blocks accept only certain data types on some ports. This section of the Result Details tab also informs you when a block that connects to the selected object has data type constraints that affect the proposed data type of the selected object.

The Proposed Data Type Summary section of the Result Details tab provides a table with the proposed data type information.

ItemDescription

ProposedDT

Data type that the Fixed-Point Tool proposes for this object and the minimum and maximum values that the proposed data type can represent

SpecifiedDT

Data type that an object specifies

Needs Attention

Lists potential issues and errors associated with data type proposals and describes the issues and suggests methods for resolving them.

Indicates a warning message

Indicates an error message

Range Information

Provides a table with model object attributes that influence the data type proposal.

ItemDescription

Design

Design maximum and minimum values that an object specifies, e.g., its Output maximum and Output minimum parameters

Simulation

Maximum and minimum values that occur during simulation

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 has an option that requires all of its inputs to have the same data type. As a result, the table might also list attributes of other model objects that affect the proposal for the selected object. In such cases, the table displays these types of shared values:

  • Initial Values

    Some model objects have parameters that allow you to specify the initial values of their signals. For example, the Constant block has 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. With data type dependencies, the tool determines how initial values impact the proposals for neighboring objects.

  • Model-Required Parameters

    Some model objects require you to specify 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 parameter value required by the model impacts the proposals for neighboring objects.

Examine the Results and Resolve Conflicts

  1. On the Fixed-Point Tool toolbar, select Show > Conflicts with proposed data types.

    The Fixed-Point Tool lists the data type proposals on the Contents pane under the ProposedDT column. Potential issues for each object appear coded by color in the list.

    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. Select the result with the error, right-click, and select Highlight in Editor from the context menu to identify the conflict. Use the information in the Needs Attention section of the Result Details tab to resolve the conflict.

  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 Simulate model button to rerun the simulation.

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

  5. Click Propose data types to generate a proposal.

  6. On the Fixed-Point Tool toolbar, select 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 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 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 current data type of the object.

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 is locked against automatic data typing.

  1. Examine each result. For more information about a particular result, select the result and then click the Result Details tab.

  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 data types 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

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

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

More About

Was this topic helpful?