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.
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.
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 in your model one at a time. This practice facilitates debugging by isolating the source of fixed-point issues.
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.
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.
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.