Digital biquad Filter

Source: Internet
Author: User
Tags bit set
Direct form 1

The most straightforward implementation is the direct form 1, which has the following difference equation:

Or, if normalized:

Here the, and coefficients determine zeros, and, determine the position of the Poles.

Flow Graph of biquad filter in direct form 1:

Direct form 2

The direct form 1 implementation requires four delay registers. An equivalent circuit is the direct form 2 Implementation, which requires only two delay registers:

The direct form 2 implementation is called the canonical form, because it uses the minimal amount of delays, adders and multipliers, yielding in the same transfer function as the direct form 1 implementation. the Difference Equations for df2 are:

Where

 

// ASM example

//////////////////////////////////////// /////////////////////
////
// Process the audio stream //
////
//////////////////////////////////////// /////////////////////

# Include <def21262.h>
# Define sections 3/* Number of second-order sections (biquads )*/

. Section/PM seg_pmco;
. Global _ cascaded_iir_filter_simd;
. Extern inbuf;
. Extern outbuf;
. Extern delaybuf;
. Extern coefficients;


_ Cascaded_iir_filter_simd:

/*************************************** **************************************
The algorithm:

IIR Second Order sections-the cannonic Second-Order Section implemented
"Direct Form II" biquads. Note that the SIMD architecture of the 2126x sharc
Family enables the two parallel execution units to filter the left and right
Channel simultaneously. All register moves and memory reads implicitly apply
To the shadow processing element (Pey) as well as the primary computational
Unit (PEX ).
**************************************** *************************************

Given the most General Biquadratic (Second Order Rational polynomial)

B0 + B1 '* Z ^-1 + B2' * Z ^-2
H (z) = --------------------------,
A0 + A1 '* Z ^-1 + A2' * Z ^-2

We may factor out the gain of the transfer function,

B0 (b1 '/A0) * Z ^-1 + (B2'/A0) * Z ^-2
H (z) = ----*-------------------------------
A0 (A1 '/B0) * Z ^-1 + (A2'/B0) * Z ^-2

And normalize the coefficients, such that

A1 * Z ^-1 + A2 * Z ^-2
H (z) = *-------------------
B1 * Z ^-1 + B2 * Z ^-2

Where a = gain = b1 '/A0

A1 = A1 '/B0, a2 = a2'/B0, b1 = b1 '/A0, b2 = b2'/A0

This leaves only four true filter coefficients. The gain values from
All of the sections may be combined into a single channel gain applied
Apart from the inner computational loop. With the simplified coefficients,
The cannonic direct Form II may be written as a pair of difference
Equations:

W [N] = x [N] + A1 * W [n-1] + A2 * W [N-2]
Y [N] = W [N] + B1 * W [n-1] + B2 * W [N-2]

Which leads to the following pseudo code:

Read (X [N])
F12 = 0, f2 = W [n-1], read (A1)
--- Loop --------------------------------------------------------------------
F12 = A1 * W [n-1], F8 = F8 + F12, F3 = W [N-2], read (A2)
F12 = a2 * W [N-2], F8 = x [N] + A1 * W [N-2], W [n-1]-> W [N-2] ', read (B1)
F12 = b1 * W [N-2], W [N] = x [N] + A1 * W [N-2] + A2 * W [n-1], f2 = W [n-1], read (B2)
F12 = b2 * W [n-1], F8 = W [N] + B1 * W [N-2], W [N]-> W [n-1] ', read (A1)
-----------------------------------------------------------------------------
Y [N] = F8 + F12

**************************************** **********************************/

/* Subroutine that implements the pseudo code above */

Cascaded_biquad:
Bit Set mode1 cbufen | peyen; // enable SIMD Mode

B0 = delaybuf;
B1 = b0;
B3 = inbuf;
B4 = outbuf;
B9 = coefficients;
R0 = sections;

F8 = DM (I3, M1); // read inbuf
R12 = R12 XOR R12, f2 = DM (I0, M1), F4 = PM (i8, M8 );
Lcntr = r0, do quads until lce;
F12 = F2 * F4, F8 = F8 + F12, F3 = DM (I0, M1), F4 = PM (i8, M8 );
F12 = F3 * F4, F8 = F8 + F12, DM (I1, M1) = F3, F4 = PM (i8, M8 );
F12 = F2 * F4, F8 = F8 + F12, f2 = DM (I0, M1), F4 = PM (i8, M8 );
QUADS: F12 = F3 * F4, F8 = F8 + F12, DM (I1, M1) = F8, F4 = PM (i8, M8 );

F8 = F8 + F12;
RTS (db );
DM (I4, M1) = F8;
Bit CLR mode1 cbufen | peyen; // disable SIMD Mode

_ Cascaded_iir_filter_simd.end:


//--------------------------------------------

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.