Main Content

Best Practices for Fixed-Point Conversion Workflow

Using the Fixed-Point Tool, you can prepare a model or subsystem for conversion from floating-point to an equivalent fixed-point representation. The following are modeling best practices for converting a model to fixed point.

Enable Signal Logging

To compare the behavior before and after conversion, enable signal logging for signals of interest in the system under design.

You can specify absolute, relative, and time tolerances for signals in your model that have signal logging enabled. After you simulate with embedded types, the Workflow Browser displays whether the embedded run meets the specified signal tolerances compared to the baseline run created during range collection. You can view the comparison plots in the Simulation Data Inspector.

Back Up Your Simulink Model

Before using the Fixed-Point Tool, back up your Simulink® model and associated workspace variables. Backing up your model can provide a baseline for testing and validation.

The Fixed-Point Tool automatically creates a back up of your original model during the Prepare stage of the conversion. To restore your model to this state, click the Restore Original Model button.

Convert Individual Subsystems

Convert individual subsystems in your model one at a time. This practice facilitates debugging by isolating the source of fixed-point issues.

Do Not Use “Save as” on Referenced Models and MATLAB Function blocks

During the fixed-point conversion process using the Fixed-Point Tool, do not use the “Save as” option to save referenced models or MATLAB® Function blocks with a different name. If you do, you might lose existing results for the original model.

Use Lock Output Data Type Setting

You can prevent the Fixed-Point Tool from replacing the current data type. Use the Lock output data type setting against changes by the fixed-point tools parameter that is available on many blocks. The default setting allows for 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.

    Explicitly specify the output data type of the block and select Lock output data type setting against changes by the fixed-point tools.

  • You are debugging a model and know that a particular block accepts only certain input signal data types.

    Explicitly specify the output data type of upstream blocks and select Lock output data type setting against changes by the fixed-point tools.

Save Simulink Signal Objects

If your model contains Simulink signal objects and you accept proposed data types, the Fixed-Point Tool automatically applies the changes to the signal objects. However, the Fixed-Point Tool does not automatically save changes that it makes to Simulink signal objects. To preserve changes, before closing your model, save the Simulink signal objects in your workspace and model.

Do Not Use clear all

clear all is not supported by fixed-point conversion workflows. Do not use clear all in initialization functions (InitFcn), or at the MATLAB Command Window when using the Fixed-Point Tool.

Related Examples

More About