Documentation

Preparation for Fixed-Point Conversion

Introduction

Using the Fixed-Point Advisor, you can prepare a model for conversion from a floating-point model or subsystem to an equivalent fixed-point representation. After preparing the model for conversion, use theFixed-Point Toolto obtain initial fixed-point data types and then refine these data types.

Best Practices

Use a Known Working Model

Before using the Fixed-Point Advisor, verify thatupdate diagramsucceeds for your model. To update diagram, pressCtrl+D. Ifupdate diagramfails, before you start converting your model, fix the failure in your model.

Back Up Your Model

Back up your Simulink®model first.

This practice provides you with a back up 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. Using 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. For more information, seeStart time(Simulink) andStop time(Simulink) in theSimulink Reference.

Make Small Changes to Your Model

做一些小的改变您的模型,这样您就可以dentify where errors are accidentally introduced.

Isolate the System Under Conversion

If you encounter data type propagation issues with a particular subsystem, isolate this subsystem by placingData Type Conversionblocks on the inputs and outputs of the system. TheData Type Conversionblock converts an input signal of any Simulink software data type to the data type and scaling you specify for itsOutput data typeparameter. 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 isolate withData Type Conversionblocks with blocks that do support fixed-point data types.

Use Lock Output Data Type Setting

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

  • You already know the fixed-point data types that you want to use for a particular block.

    For example, the block is modeling a real-world component. Set up the block to allow for known hardware limitations, such as restricting outputs to integer values.

    Specify the output data type of the block explicitly and selectLock output data type setting against changes by the fixed-point tools.

  • 你调试模型和知道particular block accepts only certain data types.

    Specify the output data type of upstream blocks explicitly and selectLock output data type setting against changes by the fixed-point tools.

Save万博1manbetxSignal Objects

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, before closing the model, save the Simulink signal objects in your workspace and model before closing the model.

Save Restore Point

Before making changes to your model that might cause subsequent update diagram failure, consider saving a restore point. For example, before applying proposed data types in task 3.1. For more information, seeSave a Restore Point.

Run the Fixed-Point Advisor

  1. Open a model.

  2. Start the Fixed-Point Advisor by:

    • Typefpcadvisor('model_name/subsystem_name')at the MATLAB®command line

    • Open the Fixed-Point Tool by selectingAnalysis>Data Type Design>Fixed-Point Tool. UnderSystem under design, select the system that you want to convert to fixed-point. UnderFixed-point preparation, clickFixed-Point Advisor.

  3. In the Fixed-Point Advisor window, on the left pane, select the Fixed-Point Advisor folder.

  4. Run the advisor by:

    • SelectingRun Allfrom the Run menu.

    • Right-clicking the Fixed-Point Advisor folder and selectingRun Allfrom 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 anInput Parameter. Then continue running to failure by right-clicking the task and selectingContinuefrom the context menu. If the task fails for a different reason, fix the task as described inFix a Task Failure.

    If your model contains referenced models, the Fixed-Point Advisor provides results for each referenced model instance.

Fix a Task Failure

Tasks fail when there is a step for you to take to convert your model from floating-point to fixed-point. The Fixed-Point Advisor provides guidance on how to fix the issues.

You can fix a failure using three different methods:

  • Follow the instructions in the Analysis Result box. Use this method to fix failures individually. SeeManually Fixing Failures.

  • Use the Action box. Use this method to automatically fix all failures. See自动修复失败s.

  • Use the Model Advisor Results Explorer. Use this method to batch fix failures. SeeBatch Fixing Failures

Note

A warning result is meant for your information. You can choose to fix the reported issue or move on to the next task.

Manually Fixing Failures

All checks have aResultpane that describes the recommended actions to manually fix failures.

To manually fix warnings or failures within a task:

  1. Optionally, save a restore point so you can undo the changes that you make. For more information, seeSave a Restore Point.

  2. UnderResult, review the recommended actions. Use the information to make changes to your model.

  3. To verify that the task now passes, underAnalysis, clickRun This Task.

自动修复失败s

You can automatically fix failures using theActionbox. TheActionbox applies all of the recommended actions listed in theResultbox.

Caution

Prior to automatically fixing failures, review theAnalysis Resultbox to ensure that you want to apply all of the recommended actions.

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

  1. Optionally, save a restore point so you can undo the changes that you make. For more information, seeSave a Restore Point.

  2. In theActionbox, clickModify All.

    TheAction Resultbox displays a table of changes.

  3. To verify that the task now passes, in theAnalysisbox, clickRun 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. Optionally, save a restore point so you can undo the changes that you make. For more information, seeSave a Restore Point.

  2. In theAnalysisbox, clickExplore Result.

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

  4. When you finish making changes, in the Fixed-Point Advisor window, clickRun This Taskto see if the changes you made result in the task passing. Continue fixing failures and rerunning the task until the task passes.

Restore Points

The Fixed-Point Advisor provides a model and data restore point capability for reverting changes that you made in response to advice from the Fixed-Point Advisor. A restore point is a snapshot in time of the model, base workspace, and Fixed-Point Advisor.

Caution

A restore point saves only the current working model, base workspace variables, and Fixed-Point Advisor tree. It does not save other items, such as libraries and referenced submodels.

To learn how to save a restore point, seeSave a Restore Point.

To learn how to load a restore point, seeLoad a Restore Point.

Save a Restore Point

When to Save a Restore Point

Consider saving a restore point:

  • Before applying changes to your model that might cause update diagram failure.

  • Before attempting to fix failures.

How to Save a Restore Point

You can save a restore point and give it a name and optional description, or allow the Fixed Point Advisor to automatically name the restore point for you.

To save a restore point with a name and optional description:

  1. From the main menu, selectFile>Save Restore Point As.

  2. In theSave Model and Data Restore Pointdialog box, in theNamefield, enter a name for the restore point.

  3. In theDescriptionfield, you can optionally add a description to help you identify the restore point.

  4. ClickSave.

    The Fixed Point Advisor saves a restore point of the current model, base workspace, and Fixed Point Advisor status.

Note

To quickly save a restore point, go toFile>Save Restore Point. The Fixed Advisor saves a restore point with the nameautosaven.nis the sequential number of the restore point. If you use this method, you cannot change the name of, or add a description to, the restore point.

Load a Restore Point

When to Load a Restore Point

Load a restore point when:

  • A task fails and you cannot continue the conversion. In this case, load a restore point saved earlier in the run to avoid rerunning all the previous tasks.

  • You want to revert changes you made in response to advice from the Fixed-Point Advisor.

How to Load a Restore Point

To load a restore point:

  1. Go toFile>Load Restore Point.

  2. In theLoad Model and Data Restore Pointdialog box, select the restore point that you want.

  3. ClickLoad.

    The Model Advisor issues a warning that the restoration will overwrite the current model and workspace.

  4. ClickLoadto load the restore point that you selected.

    The Fixed Point Advisor reverts the model, base workspace, and Fixed Point Advisor status.

Was this topic helpful?