Fixed-Point Tool
Convert a floating-point model to a fixed-point model
Open the Fixed-Point Tool
Simulink Toolstrip: On the Apps tab, under Code Generation, click the app icon.
MATLAB command prompt: Enter
fxptdlg
('system_name')
, where'system_name'
is the name of the model or system you want to convert, specified as a string.
Examples
Related Examples
Parameters
System Under Design (SUD)
— System or subsystem to analyze or convert
current system (default)
System or subsystem to analyze or convert to fixed-point. You can select individual subsystems in your model one at a time to facilitate debugging by isolating the source of numerical issues, or you can choose the top-level model.
For more information on converting systems containing particular modeling constructs, see:
Range Collection Mode
— How the tool collects ranges for objects in your system
Simulation ranges (default) | Derived ranges | Simulation with derived ranges
How the tool collects ranges for objects in your system, specified as one of the following:
Simulation ranges — Collect ranges through simulation. To collect and merge the ranges of multiple simulation runs, specify Simulation Inputs. Data type proposals are as good as the test bench provided.
Derived ranges — Collect ranges through a static analysis that derives the ranges, also known as range analysis or derived range analysis. Ranges collected using this option are based only on design ranges specified on the model. This option typically delivers more conservative data type proposals. For more information, see How Range Analysis Works.
Simulation with derived ranges — Collect ranges through simulation and derived range analysis and combine the results. Proposed data types are based on the union of simulation and derived ranges. This option provides the most comprehensive range information.
For more information, see Choosing a Range Collection Method.
Simulation Inputs
— Inputs for simulations
Use default model inputs
(default) | Simulink.SimulationInput
object
Inputs for simulations, specified as a Simulink.SimulationInput
object.
If you choose the Range Collection Mode to be
Simulation ranges or Simulation with derived
ranges, you can choose to specify additional simulation inputs to improve
the accuracy of the collected ranges and data type proposals. During the range
collection simulation, the Fixed-Point Tool captures the minimum and
maximum values from each specified simulation scenario. If the
Simulink.SimulationInput
object that you select contains more than
one simulation scenario, the Fixed-Point Tool proposes data types based on
the merged ranges from all simulation scenarios.
A comprehensive set of input signals that exercise the full range of your design will result in more accurate data type proposals for your system. For an example, see Propose Data Types For Merged Simulation Ranges.
Signal Tolerances
— Tolerances for signals in your model that have signal logging enabled
absolute tolerance | relative tolerance | time tolerance
To determine if the numerical behavior of a new fixed-point implementation is acceptable, you can define tolerances for individual signals in your model that have logging enabled. You can specify any of the following types of tolerances:
Absolute Tolerance — Absolute value of the maximum acceptable difference between the original signal and the signal in the converted design.
Relative Tolerance — Maximum relative difference, specified as a percentage, between the original output and the output of the new design. For example, a value of
1e-2
indicates a maximum difference of one percent between the original values and the signal values of the converted design.Time Tolerance (seconds) — Time interval in which the maximum and minimum values define the upper and lower values to compare against.
In the Optimized Fixed-Point Conversion workflow, you must specify at least one behavioral constraint in order to optimize data types. Signal tolerances are one type of behavioral constraint that you can specify.
In the Iterative Fixed-Point Conversion workflow, signal tolerances are not required to propose data types, but are required for the tool to determine whether the embedded run is within tolerance.
In the Range Collection workflow, signal tolerances are not required to collect ranges, but are required for the tool to determine whether the ranges collected are within tolerance.
For more information, see Specify Behavioral Constraints and Tolerance Computation.
Collect Ranges
— Collect ranges
Use current settings
(default) | Double precision
| Single precision
| Scaled double precision
Collect ranges for objects in your model using:
Use current settings
— Use the current data type override set on the model.Double precision
— Override data types in the model with doubles.Single precision
— Override data types in the model with singles.Scaled double precision
— Override data types in the model with scaled doubles.
Ranges collected depend on the Range Collection Mode and any Simulation Inputs specified.
For more information, see Fixed-Point Instrumentation and Data Type Override and Use Custom Data Type Override Settings for Range Collection.
Settings
— Data typing options
Allowable Wordlengths
| Max Iterations
| Propose
| Propose signedness
| Verify using
| ...
Data typing options available in the Settings menu depend on the workflow chosen.
Optimized Fixed-Point Conversion Workflow Options
Option | Description |
---|---|
Allowable Wordlengths |
Word lengths that
can be used in your optimized system under design. The final result of the
optimization uses word lengths in the intersection of the
|
Max Iterations |
Maximum number of iterations to perform, specified as a scalar integer. The optimization process iterates through different solutions until it finds an ideal solution, reaches the maximum number of iterations, or reaches another stopping criteria. |
Max Time (sec) |
Maximum amount of time for the optimization to run, specified in seconds as a scalar number. The optimization runs until it reaches the time specified, an ideal solution, or another stopping criteria. |
Patience (iterations) |
Maximum number of iterations where no new best solution is found, specified as a scalar integer. The optimization continues as long as the algorithm continues to find new best solutions. |
Safety Margin (%) |
A safety margin, specified as a positive scalar value, indicating the percentage increase in the bounds of the collected range. The safety margin is applied to the union of all collected ranges. |
Objective Function | Objective function to use during the optimization search. The optimization algorithm seeks to minimize an objective function while meeting the specified behavioral constraints.
Note To use |
Perform Neighborhood Search |
Whether to perform a neighborhood search for the optimized solution. Disabling this option can increase the speed of the optimization process, but also increases the chances of finding a less ideal solution. |
Use Parallel |
Whether to run iterations of the optimization in parallel. Running the iterations in parallel requires a Parallel Computing Toolbox™ license. If you do not have a Parallel Computing Toolbox license, or if you do no enable this option, the iterations run in serial. |
Iterative Fixed-Point Conversion Workflow Options
Option | Description |
---|---|
Propose | Whether to propose fraction lengths or word lengths for objects in the system under design.
|
Propose signedness |
Whether to use the collected range information to propose signedness. |
Safety margin for simulation min/max
(%) |
Specify a safety margin to apply to collected simulation ranges. The Fixed-Point Tool will add the specified amount to the collected ranges and base proposals on this larger range. |
Convert double/single/half types |
Whether to generate data type proposals for objects that currently specify a double, single, or half-precision data type. |
Convert inherited types |
Whether to generate data type proposals for results that currently specify an inherited data type. |
Default word length |
Default word
length to use for data type proposals, specified as a scalar integer. This
setting is enabled only when the |
Default fraction length |
Default fraction
length to use for data type proposals, specified as a scalar integer. This
setting is enabled only when the |
Range Collection Workflow Options
Option | Description |
---|---|
Verify using | Data type override settings to use for embedded simulation.
|
Limitations
Some blocks do not support fixed-point data types and can result in an error during fixed-point conversion. See Blocks That Do Not Support Fixed-Point Data Types.
Some modeling constructs may cause data type propagation issues. See Models That Might Cause Data Type Propagation Errors.
If your model contains a MATLAB Function block, use only supported modeling constructs for successful conversion. See MATLAB Language Features Supported for Automated Fixed-Point Conversion.
Tips
For best practices and recommendations, see Best Practices for Fixed-Point Conversion Workflow.
To customize views in the Fixed-Point Tool, see Control Views in the Fixed-Point Tool.
For help troubleshooting the optimization workflow, see Data Type Optimization Not Successful.
Version History
Introduced before R2006a