2 FIR Name: FIR.ASM Type: Assembler Macro Version: 1.0 Date Entered: 15-Jul-87 Last Change: 15-Jul-87 Description: Direct Form FIR Filter Assembler Macro This macro implements a direct form FIR filter with an arbitrary number of coefficient taps. The difference equation for a four tap filter is shown below: y(n)= b(0)x(n) + b(1)x(n-1) + b(2)x(n-1) + b(3)x(n-3) with z transform: Y(z) -1 -2 -3 ----- = b(0) + b(1)z + b(2)z + b(3)z X(z) where: x(n) = input sample at time nT y(n) = output sample at time nT T = sampling period b(n) = filter impulse response at time nT This difference equation can be implemented with the discrete time filter structure shown: Input x(n) >-----------1/z---------1/z---------1/z------- | | | | 0.1 0.3 -0.1 0.2 b(0) \ b(1) | b(2) | b(3) / \ \___ ___/ / \ \ / / ----------->(+)<-------------- |-----------------> y(n) Output The coefficients in the example are arbitrary. For the above filter, the memory map for the filter states (past input samples) and coefficients (b) are shown below. r0 m0=ntaps-1 (=3, mod 4) | v --------------------------------------- X: | New | Old | Old | Old | Filter States | x(n) | x(n-1) | x(n-2) | x(n-3) | --------------------------------------- --------------------------------------- Y: | b(0) | b(1) | b(2) | b(3) | Filter Coefficients | .1 | .3 | -.1 | .2 | --------------------------------------- ^ | r4 m4=ntaps-1 (=3, mod 4) Memory Map for the FIR Filter For an example of how to use the filter macro, see the test program FIRT.ASM.