2 IIR3 Name: IIR3.ASM Type: Assembler Macro Version: 1.0 Date Entered: 15-Jul-87 Last Change: 15-Jul-87 Description: Direct Form Arbitrary Order All Pole Filter To implement a direct form all pole filter with an arbitrary number of coefficients, looped code is used. An example of an all pole IIR filter (N=5) is shown in below. Input >----------(+)------------------------> Output x(n) ^ | y(n) | a(1) 1/z (+)<-- 0.8 -----| ^ | | a(2) 1/z (+)<-- -0.7 ----| ^ | | a(3) 1/z (+)<-- 0.6 ----| ^ | | a(4) 1/z (+)<-- -0.5 ----| ^ | | a(5) 1/z (+)<-- 0.4 ----| Direct Form All Pole IIR Filter The values for the coefficients are arbitrary. This filter is described by the difference equation: y(n)= x(n) + a(1)y(n-1) + a(2)y(n-2) + ... + a(r)y(n-r) with z transform: Y(z) 1 ------- = -------------------------------------- X(z) -1 -2 -r 1 - a(1)z - a(2)z ... - a(r)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 one) T = sample period r = number of coefficients This filter is efficiently implemented by using modulo addressing and multiple address pointers, similar to the IIR1 macro. For the above filter, the memory map for the filter coefficients and state variables (past output samples is shown below. r0 m0=ncoef-1 (=4, mod 5) | v ------------------------------------ X: |y(n) |y(n-1)|y(n-2)|y(n-3)|y(n-4)| Filter States ------------------------------------ ------------------------------------ Y: | a(1)| a(2) | a(3) | a(4) | a(5) | | .8 | -.7 | .6 | -.5 | .4 | ------------------------------------ ^ | r4 m4=ncoef-1 (=4, mod 5) Memory Map for the Direct Form Canonic Filter For an example of how to use this filter, see the test program IIR3T.ASM