Main Content

Autoscaling Data Objects Using the Fixed-Point Tool

The Fixed-Point Tool generates a data type proposal for data objects based on ranges collected through simulation, derived range analysis, and design ranges specified on model objects. The Fixed-Point Tool also takes into consideration any data type constraints imposed by the model objects.

These types of data objects are supported for conversion using the Fixed-Point Tool.

The following sections describe how the tool collects the ranges and analyzes constraints.

Collecting Ranges for Data Objects

The objects in your model that use the same data object to specify its type must all share the same data type. The Fixed-Point Tool collects the ranges for all objects in your model. Objects that must share the same data type are placed in a data type group. The Fixed-Point Tool generates a data type proposal for the group based on the union of the ranges of all model objects in the group.

Collecting Ranges for Parameter Objects

Whenever possible, it is a best practice to specify design range information on the parameter object. When the data type of the parameter object is set to auto, the Fixed-Point Tool follows the same rules as when proposing for inherited data types. The Fixed-Point Tool determines the ranges to use for the data type proposal for a parameter object by taking the union of the parameter value, the parameter design ranges, and the design ranges of client blocks.

Data Type Constraints in Data Objects

Some objects in a shared data type group may contain constraints on the data types they can accept. For example, some blocks can accept only signed data types.

Autoscaling Parameter Objects

The Fixed-Point Tool is not able to detect when a parameter object must be integer only, such as when using a parameter object as a variable for dimensions, variant control, or a Boolean value. In these cases, you must clear the Accept box in the Fixed-Point Tool proposal stage before applying data types to your model.

Autoscaling Breakpoint Objects

Breakpoint data must always be strictly monotonically increasing. Although a breakpoint data set may be strictly monotonic in double format, due to saturation and quantization, it might not be after conversion to a fixed-point data type. The Fixed-Point Tool accounts for this behavior and proposes a data type large enough to satisfy the monotonicity constraint after conversion. In some cases, the data type is very large in order to satisfy the constraint. In this case, consider editing your breakpoint data such that it can be represented efficiently in fixed point.

Autoscale a Model Using Data Objects for Data Type Definitions

The following model uses several different types of data objects, including Simulink.Bus, Simulink.NumericType, Simulink.LookupTable, and Simulink.Breakpoint objects for data type definition. Use the Fixed-Point Tool to convert the floating-point model, including the data objects used in the model, to fixed point.

Open the ex_data_objects Model

open_system('ex_data_objects')

Use the Fixed-Point Tool to Autoscale the Model

  1. From the Simulink® Apps tab, select Fixed-Point Tool.

  2. In the Fixed-Point Tool, under New workflow, select Iterative Fixed-Point Conversion.

  3. In the Fixed-Point Tool, under System Under Design (SUD), select Target Embedded System as the system you want to convert.

  4. Under Range Collection Mode, select Simulation ranges.

  5. Click the Prepare button. The Fixed-Point Tool checks the system under design for compatibility with the conversion process and reports any issues found in the model.

    When model objects within the system under design share a data type with objects outside of the system under design, data type propagation issues can occur after conversion to fixed point. For this reason, during the preparation stage of the conversion, the Fixed-Point Tool inserts Data Type Conversion blocks at the outputs of the system under design.

    In this example, the tool is not able to automatically insert a Data Type Conversion block at the ex_data_objects/Throttle port because the port uses a bus signal. You can ignore this warning in this case because there are already Data Type Conversion blocks isolating this port inside the Throttle subsystem.

  6. Expand the Collect Ranges button arrow and select Double Precision. Click the Collect Ranges button to start the simulation. The Fixed-Point Tool stores collected range information in a run titled BaselineRun.

  7. In the Convert section, click the Propose Data Types button .

    The Fixed-Point Tool detects data objects in the model and proposes a data type that satisfies the constraints of the data object. You can view all data objects used in a model by selecting Data Objects in the Model Hierarchy pane.

  8. To learn more about a particular result, select the data object in the Results spreadsheet. The Result Details pane provides more details about the proposal, and gives a link to highlight all blocks in your model using a particular data object.

    The tool displays the proposed data types for all results in the Proposed DT column of the Results spreadsheet.

  9. To view the data type group that a result belongs to, add the DT Group column to the spreadsheet. Right-click any existing column header. Select DT Group in the menu.

    To sort by the DT Group column, click the column header. You can now see results that must share the same data type next to each other.

  10. Click the Apply Data Types button to write the proposed data types to the model.

    The Fixed-Point Tool applies the data type proposals to the data objects at their definition. In this example, the data objects are defined in the base workspace. View the details of a particular data object by entering the name of the data object at the MATLAB® command line.

    errorDT
      NumericType with properties:
    
          DataTypeMode: 'Fixed-point: binary point scaling'
            Signedness: 'Signed'
            WordLength: 16
        FractionLength: 11
               IsAlias: 1
             DataScope: 'Auto'
            HeaderFile: ''
           Description: ''

Related Topics