2 IIR7 Name: IIR7.ASM Type: Assembler Macro Version: 1.0 Date Entered: 15-Jul-87 Last Change: 15-Jul-87 Description: Cascaded Biquad Filters Cascaded biquad filters are typically used when the transfer function can be decomposed into a product of second order polynomials. The magnitude of the coefficients of the second order section are guaranteed to be less than 2.0 if the filter is stable and minimum phase. Since the DSP56000 scaling modes can implement 1 bit scaling directly, implementing cascaded second order sections can be done efficiently. The difference equation for a second order section is: y(n) = a(1)y(n-1) + a(2)y(n-2) + x(n) + b(1)x(n-1) + b(2)x(n-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 b(n) = filter coefficient n T = sample period When these sections are cascaded together, the z transform of the overall system is: M -1 -2 R(z) --- 1 + b[n](1)z + b[n](2)z ------- = | | ------------------------- S(z) | | -1 -2 n=1 1 - a[n](1)z - a[n](2)z Where M is the total number of sections and [n] refers to the section number. A cascaded biquad filter with M=2 is shown below. s(n) Input w[1](n) w[2](n) Output >-->(+)-----------------------(+)-(+)-----------------------(+)--> r(n) ^ | ^ ^ | ^ | 1/z | | 1/z | (+)<-a[1](1)--|--b[1](1)->(+) (+)<-a[2](1)--|--b[2](1)->(+) | 1/z | | 1/z | (+)<-a[1](2)--|--b[1](2)->(+) (+)<-a[2](2)--|--b[2](2)->(+) Cascaded Second Order Biquad Filter For the filter kernel, the input sample is in register A and the output after filtering of a section is also in register A. This allows the next filter section to be executed by putting the filter kernel inside of a DO loop. The memory map for the cascaded biquad filter is shown below. Note in particular the way that the filter states are stored. The first element is the second filter state and the second element is the first filter state. Also note the method of coefficient storage. The first element is a(2) then a(1) followed by b(2) and b(1). r0 | v ----------------------------------------- X: | | | | | |w[1](n-1)|w[1](n-2)|w[2](n-2)|w[2](n-1)| Filter States ----------------------------------------- <- section 1 ->|<- section 2 -> r4 | v ------------------------------------- Y: | a(2) | a(1) | b(2) | b(1) | Section 1 | .711/2 | -1.29/2| -.5 | 0.0 | Filter Coefficients ------------------------------------- ------------------------------------- | a(2) | a(1) | b(2) | b(1) | Section 2 | .807/2 | -1.64/2| -.5 | 0.0 | Filter Coefficients ------------------------------------- Memory Map for the Biquad Filter Since 1 bit scaling is used, all coefficients are the actual value for the filter divided by two. The symbol "nsec" refers to the number of biquad sections in the overall filter. For an example of how to use this filter see the test program IIR7T.ASM