2 IIR5 Name: IIR5.ASM Type: Assembler Macro Version: 1.0 Date Entered: 15-Jul-87 Last Change: 15-Jul-87 Description: Second Order Direct Canonic Filter with Scaling This macro implements a second order filter with a minimum of delay elements. The scaling mode of the DSP56000/1 is used to directly implement coefficients with a magnitude less than two. The difference equation relating the output to the input is: y(n) =2 [a(1)y(n-1) + a(2)y(n-2) + x(n) + b(1)x(n-1) + b(2)x(n-2)] --- --- --- --- --- 2 2 2 2 2 with z transform: -1 -2 Y(z) 1 + b(1)z + b(2)z ------- = ---------------------- X(z) -1 -2 1 - a(1)z - a(2)z where: x(n) = input sample at time nT y(n) = output of the filter at time nT a(n) = filter coefficient n (magnitude less than two) b(n) = filter coefficient n (magnitude less than two) T = sample period In this example, it is assumed that b(0)=1. A network to implement this filter is shown below. Input w(n) x(n) >----(+)--------------------------(+)-----> y(n) ^ | ^ Output | a(1) 1/z b(1) | (+)<-- 0.8/2 -----|---- 0.4/2 -->(+) ^ v ^ | a(2) 1/z b(2) | (+)<-- -0.3/2 ----|--- -0.6/2 -->(+) The coefficients in the example are arbitrary. For the above filter, the memory map for the filter states and the coefficients is shown below. r0 | v ------------------- X: | | | |2*w(n-1)|2*w(n-2)| Filter States ------------------- ------------------------------------- Y: | a(1) | a(2) | b(1) | b(2) | | .8/2 | -.3/2 | .4/2 | -.6/2 | Filter Coefficients ------------------------------------- ^ | r4 m0=3 (mod 4) Note that the coefficients for the filter are stored divided by two. When the filter states are saved, they are scaled up by two. Since the coefficients are scaled down by two, the scale factors cancel when the filter states are multiplied by the coefficients. The address register r0 is initialized pointing to the first filter state and r4 is initialized pointing to the filter coefficients. Modulo register m0 is set to -1 to provide linear arithmetic. Modulo register m4 is set to 3 providing modulo 4 arithmetic. For an example of how to use this filter see the test program IIR5T.ASM