Products & Services Industries Academia Support User Community Company

Working with the Fixed-Point Tool

Fixed-Point Tool Workflow

Fixed-Point Tool Workflow
1. Prerequisites
1.1

Open your model in Simulink and set it up for use with the Fixed-Point Tool.

2. Run the model to gather floating-point benchmark
2.1

From the Simulink Tools menu, select Fixed-Point > Fixed-Point Tool to launch the Fixed-Point Tool.

2.2

Enable signal logging for system or subsystem of interest:

  • Select the system or subsystem in the Fixed-Point Tool Model Hierarchy pane

  • Right-click to open the context menu

  • Use the Enable Signal Logging option to enable signal logging as necessary

For more information, see Signal Logging Options in the fxptdlg reference.

2.3

In the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem for which you want a scaling proposal.

2.4

Set Data type override to True doubles. The Fixed-Point Tool performs a global override of the fixed-point data types and scaling using double-precision numbers, thus avoiding quantization effects.

2.5

Set Fixed-point instrumentation mode to Minimums, maximums and overflows to log minimum value, maximum value, and overflow data for all blocks in the current system or subsystem during simulation.

2.6

Click the Fixed-Point Tool Start button to run the simulation.

    Note   You must simulate in Normal mode.

3. Propose scaling
3.1

If you do not want to use simulation data for range information, uncheck the Use simulation min/max if design min/max is not available checkbox.

3.2

If you have safety margins to apply, set Percent safety margin for design min/max and/or Percent safety margin for simulation min/max as necessary.

For more information, see Percent safety margin for simulation min/max and Percent safety margin for design min/max in the fxptdlg reference.

3.3

Click the Propose fraction lengths button .

    Note   This does not write the proposed data types to the model.

If there are conflicts in your model, the Fixed-Point Tool displays the Results Need Attention dialog box.

If you do not see this warning, there are no conflicts in your model, go to step 5.

4 . Examine results to resolve conflicts
4.1

Click OK on the Results Need Attention dialog box to close the dialog.

4.2

Use the Show option on the Fixed-Point Tool toolbar to filter the results to show Conflicts with proposed data types.

The Fixed-Point Tool alerts you to potential scaling issues for each result by displaying a block icon annotated with red, yellow, and green symbols.

4.3

The proposed scaling will introduce data type errors if applied to this object. You must inspect this result and fix the problem in the Simulink model.

To review the error and correct the problem:

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

  • Click the Show autoscale information for selected result button to open the Autoscale Information dialog box

  • Use the advice provided in the Needs Attention section of the Autoscale Information dialog box to resolve the conflict by fixing the problem in the Simulink model

4.4

The proposed scaling poses potential issues for this object. You should review this proposal.

Review the Autoscale Information for the warnings and correct the problem if necessary.

4.5

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.

4.6

Click the Propose fraction lengths button to generate a scaling proposal.

4.7

Use the Show option on the Fixed-Point Tool toolbar to filter the results to show All results.

5. Apply scaling
5.1

Examine each result. For more information about a particular result, select the result then click the Show autoscale information for selected result button . The Autoscale Information dialog box appears.

5.2

If you do not want to accept the proposal for a result, uncheck the Accept checkbox in the Fixed-Point Tool Contents pane for that result.

5.3

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

    Note   If you have not fixed all the warnings in the model, the Fixed-Point Tool displays the Apply Fraction Length Warning dialog box.

6. Store Reference Run
6.1

Click the Exchange Active and Reference Results button to store the ideal doubles-based simulation in the reference group. This prevents the tool from overwriting results that you want to retain.

7. Verify new settings
7.1

In the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem for which you want a proposal.

7.2

Change Data type override to Use local settings. This option enables each of the model's subsystems to use its locally specified data type settings.

7.3

Verify that Fixed-point instrumentation mode is set to Minimums, maximums and overflows.

7.4

Click the Fixed-Point Tool Start button to run the simulation.

7.5

Compare the ideal results stored in the reference run with the fixed-point results in the active run:

  • In the Contents pane, select a result that has logged signal data. These results are annotated with the icon.

  • Click the Time Series Difference (A-R) Plot to view the difference between the active and reference runs for the selected result

Prerequisites for Using the Fixed-Point Tool

To use the Fixed-Point Tool to generate scaling proposals for your model, you must first set up your model in Simulink.

  1. Open your model in Simulink.

  2. Select Simulation > Normal in the Simulink menu to ensure the model runs in Normal mode.

      Note   The Fixed-Point Tool supports only Normal mode.

  3. If you are using design minimum and maximum range information, add this information to blocks.

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

  4. 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 Specifying Fixed-Point Data Types with the Data Type Assistant.

      Note   If you have a floating-point model, use the Fixed-Point Advisor to facilitate converting your model to an equivalent fixed-point representation. To learn more about the Fixed-Point Advisor, see Fixed-Point Advisor.

  5. You can choose to lock some blocks against autoscaling by selecting the Lock output data type setting against changes by the fixed-point tools parameter. If an object's Lock output data type setting against changes by the fixed-point tools parameter is selected, the tool does not propose scaling for that object.

  6. Select Update Diagram from the Simulink Edit menu to perform parameter range checking for all blocks in the model.

Running the Model to Gather a Floating-Point Benchmark

You first run the model with a global override of the fixed-point data types using double-precision numbers to avoid quantization effects. This provides a floating-point benchmark that represents the ideal output. The Simulink software logs the signal logging results to the MATLAB workspace. The Fixed-Point Tool displays the simulation results including minimum and maximum values that occur during the run.

To Gather a Floating-Point Benchmark

  1. Launch Fixed-Point Tool.

    From the Simulink Tools menu, select Fixed-Point > Fixed-Point Tool.

  2. Enable signal logging for the system or subsystem of interest. Using the Fixed-Point Tool you can enable signal logging for multiple signals simultaneously. For more information, see Signal Logging Options in the fxptdlg Reference.

    To enable signal logging:

    1. Select the system or subsystem in the Fixed-Point Tool Model Hierarchy pane.

    2. Right-click to open the context menu.

    3. Use the Enable Signal Logging option to enable signal logging, as necessary.

    The Contents pane of the Fixed-Point Tool displays an antenna icon next to items that have signal logging enabled.

      Note   You can only plot results for signals that have signal logging enabled.

  3. In the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem for which you want a proposal.

  4. Set Data type override to True doubles to perform a global override of the fixed-point data types and scaling using double-precision numbers, thus avoiding quantization effects.

  5. Set Fixed-point instrumentation mode to Minimums, maximums and overflows to log minimum value, maximum value, and overflow data for all blocks in the current system or subsystem during simulation.

  6. Click the Fixed-Point Tool Start button to run the simulation.

      Note   You must simulate in Normal mode.

Proposing Scaling

The Fixed-Point Tool generates scaling proposals for model objects that specify fixed-point data types unless an object's Lock output data type setting against changes by the fixed-point tools parameter is selected.

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

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

To Propose Scaling

  1. To use design min/max information only, uncheck the Use simulation min/max if design min/max is not available checkbox, otherwise leave it checked.

  2. If you have safety margins to apply:

    1. Enter Percent safety margin for design min/max, if applicable. For example, enter 10 for a 10% safety margin.

    2. Enter Percent safety margin for simulation min/max, if applicable. For example, enter 10 for a 10% safety margin.

  3. Click the Propose fraction lengths button .

      Note   The Fixed-Point Tool does not alter your model when it proposes scaling.

    If there are conflicts in your model, the Fixed-Point Tool displays the Results Need Attention dialog box.

    If you do not see this warning, there are no conflicts in your model, go to Applying Scaling.

Examining Results to Resolve Conflicts

You can examine each scaling proposal using the Autoscale Information dialog, which displays the rationale underlying the proposed scaling. Also, this dialog describes potential issues or errors, and it suggests methods for resolving them. To open the dialog:

  1. In the Contents pane, select an object that has proposed scaling.

  2. Click the Show autoscale Information for selected result button .

    The dialog appears.

The sections that follow describe the information that the dialog displays.

Proposed Data Type Summary

This section describes a scaling proposal in terms of how it differs from the object's current data type. For cases when the Fixed-Point Tool does not propose scaling, this section provides an explanation.

Needs Attention

This section lists potential issues and errors associated with scaling proposals. It displays the following icons to differentiate warnings from errors.

Indicates a warning message.

Indicates an error message.

Not only does this section describe such issues, but also it suggests methods for resolving them.

Shared Data Type Summary

This section notifies you when data type requirements associated with other model objects impact the data type of the selected object. In this case, the dialog provides a hyperlink that you can click to highlight those items in the model. To eliminate such highlighting, from the model's View menu, select Remove Highlighting.

Data Type Details

This section provides a table that lists a model object's attributes that influence its scaling proposal.

ItemDescription

Currently Specified Data Type

Data type that an object currently specifies.

Proposed Data Type

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

Proposed Representable Maximum

Maximum value that results from the proposed data type.

Design Maximum

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

Simulation Maximum

Maximum value that occurs during simulation.

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 results from the proposed data type.

The 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 scaling, 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 table might also list attributes of other model objects that impact the scaling proposal for the selected object. In such cases, the table displays the following types of shared values:

To Examine the Results and Resolve Conflicts

  1. Click OK on the Results Need Attention dialog box to close the dialog.

  2. Use the Show option on the Fixed-Point Tool toolbar to filter the results to show Conflicts with proposed data types.

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

    The proposed scaling poses no issues for this object.

    The proposed scaling poses potential issues for this object.

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

  3. Review and fix each error.

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

    2. Click the Show autoscale information for selected result button to open the Autoscale Information dialog box

    3. Use the advice provided in the Needs Attention section of the Autoscale Information dialog box to resolve the conflict by fixing the problem in the Simulink model

  4. Review the Autoscale Information for the warnings and correct the problem if necessary.

  5. 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.

  6. Click the Propose fraction lengths button to generate a scaling proposal.

  7. Use the Show option on the Fixed-Point Tool toolbar to filter the results to show All results.

Applying Scaling

After reviewing the scaling proposals, you are ready to apply the scaling to your model. The Fixed-Point Tool allows you to apply its scaling proposals selectively to objects in your model. Use the Accept check box in the Contents pane to specify the scaling 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 scaling to this object. By default, the tool selects the Accept check box when a scaling proposal differs from the object's current scaling.

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

No scaling proposal exists for this object. This occurs, for example, when the object specifies a data type inheritance rule or has its scaling locked.

To Apply Scaling

  1. Examine each result. For more information about a particular result, select the result and then click the Show autoscale information for selected result button .

    The Autoscale Information dialog box appears.

  2. If you do not want to accept the proposal for a result, uncheck the Accept checkbox in the Fixed-Point Tool Contents pane for that result. For more information, see fxptdlg

      Tip   The Fixed-Point Tool enables you to customize its scaling proposals before applying them to your model. To do so, in the Contents pane, click a ProposedDT cell and edit the data type expression. See documentation for the fixdt function for information about specifying fixed-point data types.

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

      Note   If you have not fixed all the warnings in the model, the Fixed-Point Tool displays the Apply Fraction Length Warning dialog box.

Storing Reference Run

You can use the Exchange Active and Reference Results button to swap the results that the Fixed-Point Tool stores as an active run with those that it stores as a reference run. This prevents the tool from overwriting results that you want to retain.

To Store the Reference Run

Click the Exchange Active and Reference Results button to store the ideal doubles-based simulation in the reference group.

The simulation results corresponding to True doubles override are now stored as a reference run.

Verifying New Settings

After applying scaling to your model, you simulate the model using the fixed-point data types that you applied. The Fixed-Point Tool displays in its Contents pane information about blocks that logged fixed-point data. The SimDT (simulation data type) column for the active run shows that the blocks used fixed-point data types with the new scaling.

To Verify the New Settings

  1. In the Fixed-Point Tool Model Hierarchy pane, select the system or subsystem for which you want a proposal.

  2. Change Data type override to Use local settings. This option enables each of the model's subsystems to use its locally specified data type settings.

  3. Verify that Fixed-point instrumentation mode is set to Minimums, maximums and overflows.

  4. Click the Fixed-Point Tool Start button to run the simulation.

  5. Compare the ideal results stored in the reference run with the fixed-point results in the active run:

    1. In the Contents pane, select a result that has logged signal data. These results are annotated with the icon.

    2. Click the Time Series Difference (A-R) Plot to view the difference between the active and reference runs for the selected result.

Automatic Scaling of Simulink Signal Objects

Fixed-Point Tool can propose new scaling for Simulink signal objects in the base or model workspace. If you accept the proposed scaling, the Fixed-Point Tool will apply the new scaling to the Simulink signal objects automatically.

  


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