Fixed-Point Instrumentation and Data Type Override
The conversion of a model from floating point to fixed point requires configuring fixed-point instrumentation and data type overrides. However, leaving these settings on after the conversion can lead to unexpected results.
The Fixed-Point Tool automatically enables fixed-point instrumentation when you click the Collect Ranges button in the tool. By default, the Fixed-Point Tool uses the current data type override set on the model. You can also choose to override data types with doubles, singles, or scaled doubles. When the simulation or derivation is complete, the tool automatically disables the instrumentation and removes the data type override, if data type override was selected in the tool. When you click the Simulate with Embedded Types button, the tool enables instrumentation during the simulation. Data type override settings on the model are not affected.
Control Instrumentation Settings
The fixed-point instrumentation mode controls which objects log minimum, maximum, and overflow data during simulation. Instrumentation is required to collect simulation ranges using the Fixed-Point Tool. These ranges are used to propose data types for the model. When you are not actively converting your model to fixed point, disable the fixed-point instrumentation to restore the maximum simulation speed to your model.
To enable instrumentation outside of the Fixed-Point Tool, at the command
line set the MinMaxOverflowLogging
parameter to
MinMaxAndOverflow
or
OverflowOnly
.
set_param('MyModel','MinMaxOverflowLogging','MinMaxAndOverflow')
Instrumentation requires a Fixed-Point Designer™ license. To disable instrumentation on a model, set the parameter to
ForceOff
or
UseLocalSettings
.
set_param('MyModel','MinMaxOverflowLogging','UseLocalSettings')
Control Data Type Override
Use data type override to simulate your model using double, single, or scaled double data types. If you do not have Fixed-Point Designer, you can still configure data type override settings to simulate a model that specifies fixed-point data types. Using this setting, the software temporarily overrides data types with floating-point data types during simulation.
set_param('MyModel','DataTypeOverride','Double')
To observe the true behavior of your model, set the data type override parameter to
UseLocalSettings
or
Off
.
set_param('MyModel','DataTypeOverride','Off')
Instrumentation Settings and Data Type Override for a Model Reference Hierarchy
When you simulate a model that contains referenced models, the data type override and fixed-point instrumentation settings for the top-level model do not control the settings for the referenced models. You must specify these settings separately for the referenced model. If the settings are inconsistent, for example, if you set the top-level model data type override setting to double and the referenced model to use local settings and the referenced model uses fixed-point data types, data type propagation issues might occur.
When you change the fixed-point instrumentation and data type override settings for any instance of a referenced model, the settings change on all instances of the model and on the referenced model itself.
Data Type Override Limitations
For these blocks, data type override is not supported.
Stateflow® Chart blocks that use MATLAB® as the action language
State Transition Table blocks that use MATLAB as the action language
Truth Table blocks that use MATLAB as the action language
Test Sequence block
MATLAB Function block
MATLAB Discrete-Event System block
Requirements Table block