Main Content

Data Type Conversion Overview

Within digital hardware, numbers are represented as either fixed-point or floating-point data types. For both these data types, word sizes are fixed at a set number of bits. Fixed-point representation often offers advantages in terms of the power consumption, size, memory usage, speed, and cost of the final product. However, the dynamic range of fixed-point values is much smaller than floating-point values with equivalent word sizes. Therefore, in order to avoid overflow or unreasonable quantization errors, fixed-point values must be scaled.

The following summarizes the process of converting data types in a system from floating point to fixed point. After converting data types in your model to an embedded-efficient representation, you can further optimize your design for your intended hardware, generate code and then deploy code onto your target.

  1. Identify system requirements.

  2. Model ideal system.

  3. Convert data types of system to data types that are efficient on target hardware.

  4. Verify numeric behavior of the converted system.

  5. Verify performance of the converted system. Optimize performance of the system based on target hardware.

  6. Generate code.

  7. Deploy code onto hardware.

Methods for Converting a System to Fixed Point

The Fixed-Point Designer™ software provides three methods for automatically specifying fixed-point data types for a system in your model. The following table summarizes the methods available for converting a floating-point system to fixed-point data types.

MethodDescription
Fixed-Point Tool

The Fixed-Point Tool is a user interface that automates specifying fixed-point data types in a model.

  • Iterative Fixed-Point Conversion workflow — The tool collects range data for model objects. Based on these values, the tool proposes fixed-point data types that maximize precision and cover the range. You can then review the data type proposals and apply them selectively to objects in your model.

  • Optimized Fixed-Point Conversion — If you know your system behavior tolerances, you can use fxpopt in the Fixed-Point Tool to find the optimal data types for your system which minimize total bit-width (sum of word lengths) of the system while staying within specified tolerances.

For an example, see Convert Floating-Point Model to Fixed Point.

DataTypeWorkflow.Converter

The DataTypeWorkflow.Converter object and its associated object functions are a command-line alternative to the Fixed-Point Tool. These functions offer the same functionality as the Fixed-Point Tool.

For an example, see Convert a Model to Fixed Point Using the Command Line.

fxpopt

If you know your system behavior tolerances, then the command-line fxpopt function can find the optimal data types for your system which minimize total bit-width (sum of word lengths) of the system while staying within specified tolerances.

For an example, see Optimize Fixed-Point Data Types for a System

After converting a system to fixed point, verify that the behavior of the fixed-point system meets your requirements. For more information, see Verify New Settings.

Optimize performance of the system based on target hardware. For example, replace trigonometric functions with equivalent CORDIC implementations, or use the Lookup Table Optimizer app to replace parts of your model with an embedded-efficient lookup table implementation.

Related Topics