Main Content

使用自定义数据类型ride Settings for Range Collection

This example shows how to specify custom data type override settings to use during the range collection step in the Fixed-Point Tool.

By default, the Fixed-Point Tool honors the data types and any data type override specified on the model. You can use the Fixed-Point Tool to override data types in your model with doubles, singles, or scaled doubles. To specify custom data type overrides for elements within your model, use theset_paramfunction.

Load a Simple Model

Open thefxp_custom_dtomodel. The model consists of three subsystems. Update the diagram (Ctrl+D) to display the data types currently set on the model.

open_system('fxp_custom_dto')

The original model uses the double-precision data type for each of the three subsystems within the model.

Override Data Types for a Subsystem

To override the data types inSubsystem AandSubsystem Cwith singles, use theset_paramfunction:

set_param('fxp_custom_dto/Subsystem A','DataTypeOverride','Single'); set_param('fxp_custom_dto/Subsystem C','DataTypeOverride','Single');

Update the diagram and inspect the model to confirm that the data type override has been applied.

Collect Ranges Using the Fixed-Point Tool

In theAppstab of thefxp_custom_dtomodel, selectFixed-Point Tool.

In the Fixed-Point Tool, selectNew > Range Collection. UnderSystem Under Design (SUD), selectfxp_custom_dto. UnderRange Collection Mode, selectSimulation Ranges.

UnderCollect Ranges, selectUse current settings. ClickCollect Ranges.

The Fixed-Point Tool collects ranges via simulation using the current data type override applied to your model. In this example, the data types ofSubsystem AandSubsystem Care overrode with singles, andSubsystem Bremains in double precision.

Verify Data Type Override Settings

To verify that the custom data type override settings specified using theset_paramfunction were applied to the model during the range collection run, inspect theResultsspreadsheet in the Fixed-Point Tool.

编译后的数据类型(CompiledDT) column forBaselineRunshows thatSubsystem AandSubsystem Cused thesingledata type, while the rest of the model was simulation using thedoubledata type.

Data Type Override for a Model Reference Hierarchy

When you simulate a model that contains referenced models, the data type override settings for the top-level model do not control the settings for the referenced models. You must specify these settings separately for referenced models, and if the settings must be consistent. 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, then data type propagation issues might occur.

When you change the 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.

See Also

|