Example - Conversions and Arithmetic Operations
This example uses the FixPt FIR block to illustrate when parameters are converted from a double to a fixed-point number, when the input data type is converted to the output data type, and when the rules for addition and subtraction, and multiplication are applied. For details about conversions and operations, refer to Parameter and Signal Conversions and Rules for Arithmetic Operations.
If a block can perform all four arithmetic operations, such as the FixPt FIR block, then the rules for multiplication and division are applied first.
Suppose you configure the FixPt FIR block for two outputs (SIMO mode) where the first output is given by
and the second output is given by
Additionally, the initial values of u(k - 1) and u(k - 2) are given by 0.8 and 1.1, respectively and all inputs, parameters, and outputs have radix point-only scaling.
To configure the FixPt FIR block for this situation, you must specify the FIR coefficient parameter as [13 11 -7; 6 -5 0] and the Initial condition parameter as[0.8 1.1] as shown below in the dialog box below.
Parameter conversions and block operations are given below in the order in which they are carried out by the FixPt FIR block.
The FIR coefficients parameter is converted from doubles to the Parameter data type offline using round-to-nearest and saturation.
The Initial condition parameter is converted from doubles to the input data type offline using round-to-nearest and saturation.
The coefficients and inputs are multiplied together for the initial time step for both outputs.
For y1(0), the operations 13 · u(0), 11 · 0.8, and -7 · 1.1 are performed, while for y2(0), the operations 6 · u(0) and -5 · 0.8 are performed.
The results of these operations are then converted to the Output data type using the specified rounding and overflow modes.
The sum is carried out for y1(0) and y2(0). Note that the rules for addition and subtraction are satisfied since the coefficients and inputs are already converted to the Output data type.
Steps 2 and 3 are repeated for subsequent time steps.