2 IIR6 Name: IIR6.ASM Type: Assembler Macro Version: 1.0 Date Entered: 15-Jul-87 Last Change: 15-Jul-87 Description: Arbitrary Order Direct Canonic Filter This macro implements a direct form filter with a minimum number of delay elements using looped code to allow a filter of arbitrary order. Input w(n) x(n) >----(+)--------------------------(+)-----> Output ^ | ^ y(n) | a(1) 1/z b(1) | (+)<-- 0.8 -----|---- 0.1 -->(+) ^ v ^ | a(2) 1/z b(2) | (+)<-- -0.7 ----|---- 0.2 -->(+) ^ v ^ | a(3) 1/z b(3) | (+)<-- 0.6 ----|---- 0.3 -->(+) ^ v ^ | a(4) 1/z b(4) | (+)<-- -0.5 ----|---- 0.4 -->(+) ^ v ^ | a(5) 1/z b(5) | (+)<-- 0.4 ----|---- 0.5 -->(+) Direct Form Canonic Filter 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) + b(1)x(n-1) + b(2)x(n-2) + ... + b(r)x(n-r) with z transform: -1 -2 -r Y(z) 1 + b(1)z + b(2)z + ... + b(r)z ------- = -------------------------------------- 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) b(n) = filter coefficient n (magnitude less than one) T = sample period r = order of filter This filter can be described in terms of its "order" where the order of the filter refers to the highest power of z in the polynomial describing the system. In this example, the filter is a 5th order filter. The memory map for this filter is shown below. r0 m0=order (=5, mod 6) | v ------------------------------------------- X: | | | | | | | Filter States |w(n) |w(n-1)|w(n-2)|w(n-3)|w(n-4)|w(n-5)| ------------------------------------------- r4 m4=2*order-1 (=9, mod 10) | v ------------------------------------ Y: | a(1)| a(2) | a(3) | a(4) | a(5) | | .8 | -.7 | .6 | -.5 | .4 | ------------------------------------ ------------------------------------ | b(1)| b(2) | b(3) | b(4) | b(5) | | .1 | .2 | .3 | .4 | .5 | ------------------------------------ Memory Map for the Direct Form Canonic Filter For an example of how to use this filter see the test program IIR6T.ASM