|On this page…|
The API for user-written fixed-point S-functions provides support for a variety of Simulink® and Fixed-Point Designer™ data types, including
Built-in Simulink data types
Fixed-point Simulink data types, such as
Data types resulting from a data type override with Scaled double, such as
For more information, see Fixed-Point Data Type and Scaling Notation.
The API treats integers as fixed-point numbers with trivial scaling. In [Slope Bias] representation, fixed-point numbers are represented as
real-world value = (slope × integer) + bias.
In the trivial case, slope = 1 and bias = 0.
In terms of binary-point-only scaling, the binary point is to the right of the least significant bit for trivial scaling, meaning that the fraction length is zero:
real-world value = integer × 2-fraction length = integer × 20.
In either case, trivial scaling means that the real-world value is equal to the stored integer value:
real-world value = integer.
All integers, including Simulink built-in integers such as uint8, are treated as fixed-point numbers with trivial scaling by this API. However, Simulink built-in integers are different in that their use does not cause a Fixed-Point Designer software license to be checked out.
The Fixed-Point Tool enables you to perform various data type overrides on fixed-point signals in your simulations. This API can handle signals whose data types have been overridden in this way:
A signal that has been overridden with Single is treated as a Simulink built-in single.
A signal that has been overridden with Double is treated as a Simulink built-in double.
A signal that has been overridden with Scaled double is treated as being of data type ScaledDouble.
ScaledDouble signals are a hybrid between floating-point and fixed-point signals, in that they are stored as doubles with the scaling, sign, and word length information retained. The value is stored as a floating-point double, but as with a fixed-point number, the distinction between the stored integer value and the real-world value remains. The scaling information is applied to the stored integer double to obtain the real-world value. By storing the value in a double, overflow and precision issues are almost always eliminated. Refer to any individual API function reference page at the end of this appendix to learn how that function treats ScaledDouble signals.