To determine if the numerical behavior of a new fixed-point implementation is acceptable, define constraints by setting signal tolerances, by using one or more model verification blocks, or both.
In the Optimized Fixed-Point Conversion
workflow of the
Fixed-Point Tool, or when using fxpopt
at the
command line, you must specify at least one behavioral constraint. Data types are optimized to
meet all specified constraints.
In the Iterative Fixed-Point Conversion
workflow of the
Fixed-Point Tool, or when using DataTypeWorkflow.Converter
at the command
line, you can specify behavioral constraints to verify the numerical behavior of the model
with embedded types. After simulating with embedded types, the Workflow
Browser indicates whether the embedded run meets the specified signal tolerances
compared to the range collection run. For more information, see Verify New Settings.
You can specify tolerances for signals in your model that have signal logging enabled. To enable signal logging,
In the Simulink® Editor, select one or more signals.
In the Signal tab of the Simulink Editor, click Log Signals.
In the Fixed-Point Tool, specify individual signal tolerances in the table under
Signal Tolerances. The table contains all signals in the model with
signal logging enabled. If you log additional signals after opening the Fixed-Point Tool,
click Refresh Signals to update the Signal
Tolerances table. At the command line, specify tolerances using the
addTolerance
method.
You can specify any of the following types of tolerances:
Abs Tol — Absolute value of the maximum acceptable difference between the original signal and the signal in the converted design.
Rel Tol — Maximum relative difference, specified as a
percentage, between the original signal and the signal in the converted design. For
example, a value of 1e-2
indicates a maximum relative difference of
one percent.
Time Tol (seconds) — Time interval, in which the maximum and minimum values define the upper and lower values to compare against.
You can define a tolerance band using any combination of absolute, relative, and time tolerance values. When you specify the tolerance for your signal using multiple types of tolerances, the overall tolerance band is computed by selecting the most lenient tolerance result for each data point. For more information about how tolerances are computed, see Tolerance Computation.
You can use enabled Model Verification blocks to specify constraints on the behavior of your system. For examples of data type optimization using model verification blocks, see Optimize Data Types Using Multiple Simulation Scenarios and Image Denoising Using Fixed-Point Quantized Restricted Boltzmann Machine Algorithm.
Optimize Fixed-Point Data Types for a System