<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="new19">
  <name>FIR Filter Structures</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2003/07/11 16:30:37 GMT-5</md:created>
  <md:revised>2004/10/10 16:15:07.591 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="kclarks">
      <md:firstname>Kyle</md:firstname>
      
      <md:surname>Clarkson</md:surname>
      <md:email>kclarks@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>FIR</md:keyword>
    <md:keyword>structures</md:keyword>
    <md:keyword>implementation</md:keyword>
  </md:keywordlist>

  <md:abstract>The direct-form and transpose-form structures are most commonly used to implement FIR filters.  For certain special filters, recursive implementations require less computation.  Lattice and cascade structures are occasionally also used.</md:abstract>
</metadata>

  <content>
    <para id="delete_me">
      Consider causal FIR filters:
      <m:math>
	<m:apply>
	  <m:eq/>
	  <m:apply>
	    <m:ci type="fn">y</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	  <m:apply>
	    <m:sum/>
	    <m:bvar>
	      <m:ci>k</m:ci>
	    </m:bvar>
	    <m:uplimit>
	      <m:apply>
		<m:minus/>
		<m:ci>M</m:ci>
		<m:cn>1</m:cn>
	      </m:apply>
	    </m:uplimit>
	    <m:lowlimit>
	      <m:cn>0</m:cn>
	    </m:lowlimit>
	    <m:apply>
	      <m:times/>
	      <m:apply>
		<m:ci type="fn">h</m:ci>
		<m:ci>k</m:ci>
	      </m:apply>
	      <m:apply>
		<m:ci type="fn">x</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:ci>n</m:ci>
		  <m:ci>k</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:apply>
      </m:math>; this can be realized using the following structure
      
      <figure id="figure1">
	<media type="image/png" src="fig1FIRFilterStruct.png"/>
      </figure>
     
      or in a different notation
       
      <figure id="figure2">
	<media type="image/png" src="fig2FIRFilterStruct.png"/>
      </figure>
      <figure id="subfigures3" orient="vertical">
	<subfigure>
	  <media type="image/png" src="subfig3aFIRFilterStruct.png"/>
	</subfigure>
	<subfigure>
	  <media type="image/png" src="subfig3bFIRFilterStruct.png"/>
	</subfigure>
	<subfigure>
	  <media type="image/png" src="subfig3cFIRFilterStruct.png"/>
	</subfigure>  
      </figure>
      
      This is called the <term>direct-form FIR filter structure</term>.
    </para>
    <para id="para2">
      There are no closed loops (no feedback) in this structure, so it
      is called a <term>non-recursive structure</term>. Since any FIR
      filter can be implemented using the direct-form, non-recursive
      structure, it is always possible to implement an FIR filter
      non-recursively. However, it is also possible to implement an
      FIR filter <emphasis>recursively</emphasis>, and for some
      special sets of FIR filter coefficients this is much more
      efficient.
	
    </para>

    <example id="ex1">
      <para id="para3">
	<m:math display="block">
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">y</m:ci>
	      <m:ci>n</m:ci>
	    </m:apply>
	    <m:apply>
	      <m:sum/>
	      <m:bvar>
		<m:ci>k</m:ci>
	      </m:bvar>
	      <m:uplimit>
		<m:apply>
		  <m:minus/>
		  <m:ci>M</m:ci>
		  <m:cn>1</m:cn>
		</m:apply>
	      </m:uplimit>
	      <m:lowlimit>
		<m:cn>0</m:cn>
	      </m:lowlimit>
	      <m:apply>
		<m:ci type="fn">x</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:ci>n</m:ci>
		  <m:ci>k</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>
	where
	<m:math display="block">
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">h</m:ci>
	      <m:ci>k</m:ci>
	    </m:apply>
	    <m:set>
	      <m:cn>0</m:cn>
	      <m:cn>0</m:cn>
	      <m:cn>
		<m:munder>
		  <m:mn>1</m:mn>
		  <m:munder>
		    <m:mo>⌃︀</m:mo>
		    <m:mrow>
		      <m:mi>k</m:mi>
		      <m:mo>=</m:mo>
		      <m:mn>0</m:mn>
		    </m:mrow>
		  </m:munder>
		</m:munder>
	      </m:cn>
	      <m:cn>1</m:cn>
	      <m:ci>…</m:ci>
	      <m:cn>1</m:cn>
	      <m:cn>
		<m:munder>
		  <m:mn>1</m:mn>
		  <m:munder>
		    <m:mo>⌃︀</m:mo>
		    <m:mrow>
		      <m:mi>k</m:mi>
		      <m:mo>=</m:mo>
		      <m:mi>M</m:mi>
		      <m:mo>-</m:mo>
		      <m:mn>1</m:mn>
		    </m:mrow>
		  </m:munder>
		</m:munder>
	      </m:cn>
	      <m:cn>0</m:cn>
	      <m:cn>0</m:cn>
	      <m:cn>0</m:cn>
	      <m:ci>…</m:ci>
	    </m:set>
	  </m:apply>
	</m:math>
	But note that 
	<m:math display="block">
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">y</m:ci>
	      <m:ci>n</m:ci>
	    </m:apply>
	    <m:apply>
	      <m:plus/>
	      <m:apply>
		<m:ci type="fn">y</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:ci>n</m:ci>
		  <m:cn>1</m:cn>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:minus/>
		<m:apply>
		  <m:ci type="fn">x</m:ci>
		  <m:ci>n</m:ci>
		</m:apply>
		<m:apply>
		  <m:ci type="fn">x</m:ci>
		  <m:apply>
		    <m:minus/>
		    <m:ci>n</m:ci>
		    <m:ci>M</m:ci>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>
	This can be implemented as
	
	<figure id="figure3">
	  <media type="image/png" src="fig4FIRFilterStruct.png"/>
	</figure>

	Instead of costing 
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci>M</m:ci>
	    <m:cn>1</m:cn>
	  </m:apply>
	</m:math> adds/output point, this comb filter costs only two
	adds/output.
      </para>
      
    </example>
    <exercise id="exer1">
      <problem>
	<para id="para5">
	  Is this stable, and if not, how can it be made so?
	</para>
      </problem>
    </exercise>
    <para id="para6">
      IIR filters must be implemented with a
      <emphasis>recursive</emphasis> structure, since that's the
      only way a finite number of elements can generate an
      infinite-length impulse response in a linear, time-invariant (LTI)
      system. Recursive structures have the advantages of being
      able to implement IIR systems, and sometimes greater
      computational efficiency, but the disadvantages of
      possible instability, limit cycles, and other deletorious
      effects that we will study shortly.
    </para>
    
    <section id="sect1">
      <name>Transpose-form FIR filter structures</name>
      <para id="para7">
	The <term>flow-graph-reversal theorem</term> says that if one
	changes the directions of all the arrows, and inputs at the
	output and takes the output from the input of a reversed
	flow-graph, the new system has an identical input-output
	relationship to the original flow-graph.
      </para>
      
      <figure id="figure4">
	<name>Direct-form FIR structure</name>
	<media type="image/png" src="fig2FIRFilterStruct.png"/>
      </figure>
      
     
      <figure id="figure5">
	<name>reverse = transpose-form FIR filter structure</name>
	<media type="image/png" src="fig5FIRFilterStruct.png"/>
      </figure>
      
      
      <figure id="figure6">
	<name>or redrawn</name>
	<media type="image/png" src="fig6FIRFilterStruct.png"/>
      </figure>
      
      <section id="sect2">
	<name>Cascade structures</name>
	<para id="para8">
	  The z-transform of an FIR filter can be factored into a
	  cascade of short-length filters
	  <m:math display="block">
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:plus/>
		<m:ci>
		  <m:msub>
		    <m:mi>b</m:mi>
		    <m:mn>0</m:mn>
		  </m:msub>
		</m:ci>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>b</m:mi>
		      <m:mn>1</m:mn>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:inverse/>
		    <m:ci>z</m:ci>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>b</m:mi>
		      <m:mn>2</m:mn>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:power/>
		    <m:ci>z</m:ci>
		    <m:cn>-3</m:cn>
		  </m:apply>
		</m:apply>
		<m:ci>…</m:ci>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>b</m:mi>
		      <m:mi>m</m:mi>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:power/>
		    <m:ci>z</m:ci>
		    <m:apply>
		      <m:minus/>
		      <m:ci>m</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:times/>
		<m:ci>
		  <m:msub>
		    <m:mi>b</m:mi>
		    <m:mn>0</m:mn>
		  </m:msub>
		</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:ci>
		      <m:msub>
			<m:mi>z</m:mi>
			<m:mn>1</m:mn>
		      </m:msub>
		    </m:ci>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:ci>
		      <m:msub>
			<m:mi>z</m:mi>
			<m:mn>2</m:mn>
		      </m:msub>
		    </m:ci>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:ci>…</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:ci>
		      <m:msub>
			<m:mi>z</m:mi>
			<m:mi>m</m:mi>
		      </m:msub>
		    </m:ci>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	  where the
	  <m:math>
	    <m:ci>
	      <m:msub>
		<m:mi>z</m:mi>
		<m:mi>i</m:mi>
	      </m:msub>
	    </m:ci>
	  </m:math> are the zeros of this polynomial. Since the
	  coefficients of the polynomial are usually real, the roots
	  are usually complex-conjugate pairs, so we generally combine
	  <m:math>
	    <m:apply>
	      <m:times/>
	      <m:apply>
		<m:minus/>
		<m:cn>1</m:cn>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>z</m:mi>
		      <m:mi>i</m:mi>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:inverse/>
		    <m:ci>z</m:ci>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:minus/>
		<m:cn>1</m:cn>
		<m:apply>
		  <m:times/>
		  <m:apply>
		    <m:conjugate/>
		    <m:ci>
		      <m:msub>
			<m:mi>z</m:mi>
			<m:mi>i</m:mi>
		      </m:msub>
		    </m:ci>
		  </m:apply>
		  <m:apply>
		    <m:inverse/>
		    <m:ci>z</m:ci>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	  into one quadratic (length-2) section with
	  <emphasis>real</emphasis> coefficients
	  <m:math display="block">
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:times/>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:ci>
		      <m:msub>
			<m:mi>z</m:mi>
			<m:mi>i</m:mi>
		      </m:msub>
		    </m:ci>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:apply>
		      <m:conjugate/>
		      <m:ci>
			<m:msub>
			  <m:mi>z</m:mi>
			  <m:mi>i</m:mi>
			</m:msub>
		      </m:ci>
		    </m:apply>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:plus/>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:times/>
		    <m:cn>2</m:cn>
		    <m:apply>
		      <m:real/>
		      <m:ci>
			<m:msub>
			  <m:mi>z</m:mi>
			  <m:mi>i</m:mi>
			</m:msub>
		      </m:ci>
		    </m:apply>
		    <m:apply>
		      <m:inverse/>
		      <m:ci>z</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:times/>
		  <m:apply>
		    <m:power/>
		    <m:apply>
		      <m:abs/>
		      <m:ci>
			<m:msub>
			  <m:mi>z</m:mi>
			  <m:mi>i</m:mi>
			</m:msub>
		      </m:ci>
		    </m:apply>
		    <m:cn>2</m:cn>
		  </m:apply>
		  <m:apply>
		    <m:power/>
		    <m:ci>z</m:ci>
		    <m:cn>-2</m:cn>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:ci type="fn">
		  <m:msub>
		    <m:mi>H</m:mi>
		    <m:mi>i</m:mi>
		  </m:msub>
		</m:ci>
		<m:ci>z</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>
	  The overall filter can then be implemented in a
	  <term>cascade</term> structure.
	  
	  <figure id="figure7">
	    <media type="image/png" src="fig7FIRFilterStruct.png"/>
	  </figure>
	  This is occasionally done in FIR filter implementation
	  when one or more of the short-length filters can be
	  implemented efficiently.
	</para>
      </section>
      <section id="section4">
	<name>Lattice Structure</name>
	<para id="para10">
	  It is also possible to implement FIR filters in a lattice
	  structure: this is sometimes used in adaptive filtering
	  
	  <figure id="figure8">
	    <media type="image/png" src="fig8FIRFilterStruct.png"/>
	  </figure>
	  
	</para>
      </section>
    </section>
	  

  </content>
  
</document>
