Products & Services Solutions Academia Support User Community Company

Working with the Fixed-Point Advisor

Introduction to the Fixed-Point Advisor

The Fixed-Point Advisor provides a set of tasks to help you convert a floating-point model or subsystem to an equivalent fixed-point representation. You can use the Fixed-Point Advisor to prepare a model for conversion and obtain an initial scaling to use as the starting point for refinement and exploration inside the Fixed-Point Tool.

Best Practices for Using the Fixed-Point Advisor

Start with a Known Working Model

Check that update diagram succeeds for your model before using the Fixed-Point Advisor. (To update diagram, press Ctrl+D.) If update diagram fails, fix the failure in your model before you start converting your model.

Back Up Your Model

Always back up your Simulink model before using the Fixed-Point Advisor.

This practice provides a fallback in case of error and a baseline for testing and validation.

Convert Small Models

The Fixed-Point Advisor is intended to assist in converting small models. Larger models can result in long processing times.

Convert Subsystems

Convert subsystems within your model, rather than the entire model. This practice saves time and unnecessary conversions.

Specify Short Simulation Run Times

Specifying small simulation run times reduces task processing times. You can change the simulation run time in the Configuration Parameters dialog box. See Start time and Stop time in the Simulink Reference for more information.

Make Small Changes to Your Model

Make small changes to your model so that you can identify where errors are introduced accidentally.

Isolate the System Under Conversion

If you encounter data type propagation issues with a particular subsystem, isolate this subsystem by placing Data Type Conversion blocks on the inputs and outputs of the system. The Data Type Conversion block converts an input signal of any Simulink software data type to the data type and scaling you specify for its Output data type parameter. This practice enables you to continue converting the rest of your model.

The ultimate goal is to replace all blocks that do not support fixed-point data types. You must eventually replace blocks that you isolated with Data Type Conversion blocks with blocks that do support fixed-point data types.

Use Lock Output Data Type Setting When Necessary

You can prevent the Fixed-Point Advisor replacing the current data type. Use the Lock output data type setting against changes by the fixed-point tools parameter available on many blocks. The default setting allows replacement. Use this setting when:

Save Simulink Signal Objects Before Closing Your Model

The Fixed-Point Advisor proposes data types for Simulink signal objects in your model. However, it does not automatically save Simulink signal objects. To preserve changes, save the Simulink signal objects in your workspace and model before closing the model.

Models That Might Cause Data Type Propagation Errors

The Fixed-Point Advisor is not aware of all potential scaling issues and might propose data types that cause subsequent data propagation errors. To ensure that you can recover your original data type settings, back up your model before using the Fixed-Point Advisor. For more information about backing up your model and other best practices for using the Fixed-Point Advisor, see Best Practices for Using the Fixed-Point Advisor.

The following models are likely to cause data type propagation issues:

Model Uses...Fixed-Point Advisor BehaviorData Type Propagation Issue
BusesNot aware of the minimum, maximum, data type, and initial value information for bus objects and does not include them in autoscaling.Fixed-Point Advisor might propose data types that are inconsistent with the data types for the bus object.
Simulink parameter objectsDoes not consider any data type information for Simulink parameter objects.Fixed-Point Advisor might propose data types that are inconsistent with the data types for the parameter object.
User-defined S-functionsNot aware of the operation of user-defined S-functions.
  • The user-defined S-function only accepts certain input data types. The Fixed-Point Advisor is not aware of this requirement and proposes a different data type upstream of the S-function. Update diagram fails on the model due to data type mismatch errors.

  • The user-defined S-function specifies certain output data types. The Fixed-Point Advisor is not aware of this requirement and does not use it when autoscaling. Therefore it might propose data types that are inconsistent with the data types for the S-function.

User-defined masked subsystemsHas no knowledge of the masked subsystem workspace and therefore cannot take this into account when autoscaling. Fixed-Point Advisor might propose data types that are inconsistent with the requirements of the masked subsystem, particularly if the subsystem uses mask initialization. The proposed data types might cause data type mismatch errors or overflows.
Linked subsystemsDoes not include linked subsystems when converting your model.Data type mismatch errors might occur at the linked subsystem boundaries.
Embedded MATLAB Function blocksDoes not propose data types for Embedded MATLAB Function blocks.Fixed-Point Advisor might propose data types that are inconsistent with the requirements of the Embedded MATLAB Function blocks. The proposed data types might cause data type mismatch errors or overflows.
Model referenceDoes not propose data types for referenced models.Data type propagation errors might occur at the referenced model's boundaries.
Blocks whose output is always floating-point for floating-point inputs regardless of their output data type setting. For example, Discrete Filter block and many Signal Processing Blockset blocks.Might not propose data types for these blocks as they do not allow you to set the output data type to double or single.Date type propagation errors might occur because the Fixed-Advisor Advisor is unable to lock down the output data type of these blocks.

Running the Fixed-Point Advisor

  1. Open a model.

  2. Start the Fixed-Point Advisor by:

    • Typing fpcadvisor('model_name/subsystem_name') at the MATLAB command line

    • Selecting a subsystem and then selecting Fixed-Point > Fixed-Point Advisor from the Tools menu

    • Right-clicking a subsystem block and then selecting Fixed-Point > Fixed-Point Advisor from the subsystem context menu

    The Fixed-Point Advisor window opens.

  3. Select the Fixed-Point Advisor folder in the Task Hierarchy pane.

  4. Run the advisor by:

    • Selecting Run to Failure from the Run menu

    • Right-clicking the Fixed-Point Advisor folder and selecting Run to Failure from the folder context menu

    The Fixed-Point Advisor runs the tasks in order until a task fails. A waitbar is displayed while each task runs.

  5. Review the results. If a task fails because input parameters are not specified, select an Input Parameter. Then continue running to failure by right-clicking the task and selecting Continue from the context menu. If the task fails for a different reason, fix the task as described in Fixing a Task Failure.

Fixing a Task Failure

Tasks fail when there is a step for you to take to convert your model from floating-point to fixed-point. For more information on why a specific task fails, see the Fixed-Point Advisor Reference.

You can fix a failure using three different methods:

Automatically Fixing Failures

You can automatically fix failures using the Action box. The action box applies all of the recommended actions listed in the Analysis Result box.

Automatically fix all failures within a task using the following steps:

  1. In the Action box, click Modify All.

    The Action Result box displays a table of changes.

  2. To verify that the task now passes, in the Analysis box, click Run This Task.

Batch Fixing Failures

If a task fails and you want to explore the results and make batch changes, use the following steps.

  1. In the Analysis box, click Explore Result.

    The Model Advisor Result Explorer dialog box opens.

  2. Use the Model Advisor Result Explorer to modify block parameters.

  3. When you have finished making changes, in the Fixed-Point Advisor window, click Run This Task to see if the changes you made results in the task passing. Continue fixing failures and rerunning the task until the task passes.

  


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