Main Content

Conversions and Arithmetic Operations

This example uses theDiscrete FIR Filter当参数块来说明rs 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, subtraction, and multiplication are applied.

Note

If a block can perform all four arithmetic operations, then the rules for multiplication and division are applied first. TheDiscrete FIR Filterblock is an example of this.

Suppose you configure theDiscrete FIR Filterblock for two outputs, where the first output is given by

y 1 ( k ) = 13 u ( k ) + 11 u ( k 1 ) 7 u ( k 2 ) ,

and the second output is given by

y 2 ( k ) = 6 u ( k ) 5 u ( k 1 ) .

Additionally, the initial values ofu(k–1)andu(k–2)are given by 0.8 and 1.1, respectively, and all inputs, parameters, and outputs have binary-point-only scaling.

To configure theDiscrete FIR Filterblock for this situation, on theMainpane of its dialog box, you must specify theCoefficientsparameter as[13 11 -7; 6 -5 0]and theInitial statesparameter as[0.8 1.1],如下所示。

Similarly, configure the options on theData Typespane of the block dialog box to appear as follows:

TheDiscrete FIR Filterblock performs parameter conversions and block operations in the following order:

  1. TheCoefficientsparameter is converted offline from doubles to theCoefficientsdata type using round-to-nearest and saturation.

    TheInitial statesparameter is converted offline from doubles to the input data type using round-to-nearest and saturation.

  2. The coefficients and inputs are multiplied together for the initial time step for both outputs. Fory1(0), the operations13·u(0),11·0.8, and–7·1.1are performed, while fory2(0), the operationsu(0)and–5·0.8are performed.

    The results of these operations are stored asProduct output.

  3. The sum is carried out inAccumulator. The final summation result is then converted toOutput.

  4. Steps 2 and 3 repeat for subsequent time steps.

See Also

Related Topics