Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Vlsi DSP Fir Final

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 73

Finite Impulse Response (FIR) Filters

Learning Objectives
Introduction to the theory behind FIR
filters:
Properties (including aliasing).
Coefficient calculation.
Structure selection.
Introduction
Amongst all the obvious advantages that digital
filters offer, the FIR filter can guarantee linear
phase characteristics.
Neither analogue or IIR filters can achieve this.
FIR filters can be designed for arbitrary frequency
response.
There are many commercially available software
packages for filter design. However, without
basic theoretical knowledge of the FIR filter, it
will be difficult to use them.
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

x[n] represents the filter input,


bk represents the filter coefficients,
y[n] represents the filter output,
N is the number of filter coefficients
(order of the filter).
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k FIR equation
k 0

-1 -1 -1 -1
x(n) z z z z

b0 b1 b2 bN-1
x x x x

+ + + y(n)

Filter structure
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

If the signal x[n] is replaced by an impulse


[n] then:
N 1
yn bk n k
k 0

y0 b0 0 b1 1 bk N
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

If the signal x[n] is replaced by an impulse


[n] then:
N 1
yn bk n k
k 0

yn b0 n b1 n 1 bk n N
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

If the signal x[n] is replaced by an impulse


[n] then:
N 1
yn bk n k
k 0

1 for n k
n k
0 for n k
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

Finally:
b0 h0
b1 h1

bk hk
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn k
k 0

With: bk hk

The coefficients of a filter are the same as


the impulse response samples of the filter.
Frequency Response of an FIR Filter
By taking the z-transform of h[n], H(z):
N 1
H z hnz n
n 0

Replacing z by ej in order to find the


frequency response leads to:


N 1
H z z e j H e j hne jn
n 0
Frequency Response of an FIR Filter
Since e-j2k = 1 then:
N 1 N 1
H z z e 2 hne jn 2 hne jn
n 0 n 0

Therefore:


H e j 2 k H e j
FIR filters have a periodic frequency
response and the period is 2.
Frequency Response of an FIR Filter
Frequency response: H e j 2 k H e j

x[n] FIR y[n]


x[n]

y[n]
Freq

Freq
Fs/2 Fs/2
Frequency Response of an FIR Filter
Solution: Use an anti-aliasing filter.
x[n]
x(t) ADC FIR y[n]
Analogue Anti-
Aliasing
x(t)

y[n]
Freq Freq
Fs/2 Fs/2
Phase Linearity of an FIR Filter
A causal FIR filter whose impulse response is
symmetrical is guaranteed to have a linear phase
response.
h(n) h(n)
N = 2n + 2 N = 2n + 1

n n
0 1 n n+1 2n 2n+1 0 1 n-1 n n+1 2n-1 2n

Even symmetry Odd symmetry



Phase Linearity of an FIR Filter
A causal FIR filter whose impulse response is symmetrical (ie h[n] = h[N-1-
n] for n = 0, 1, , N-1) is guaranteed to have a linear phase response.

N 1
Condition Phase k Phase Property Filter Type
2

hn hN n 1 Odd Symmetry Type 1


k Linear phase
Positive Symmetry Even Symmetry Type 2
Design Procedure

To fully design and implement a filter five steps are required:


(1) Filter specification.
(2) Coefficient calculation.
(3) Structure selection.
(4) Simulation (optional).
(5) Implementation.
Filter Specification - Step 1
|H(f)| pass-band stop-band

fc : cut-off frequency fs/2 f(norm)


(a)

|H(f)| pass-band transition band stop-band |H(f)|


(dB) (linear)
p 1 p

0 1
1 p

pass-band
-3
ripple

stop-band
ripple
s s

fs/2 f(norm)
fsb : stop-band frequency
fc : cut-off frequency
fpb : pass-band frequency
(b)
Coefficient Calculation - Step 2

There are several different methods available,


the most popular are:
Window method.
Frequency sampling.
Parks-McClellan.
We will consider first the window method.
Window Method
First stage of this method is to calculate the
coefficients of the ideal filter.
This is calculated as follows:
Determine the form of the frequency response.
Then as the frequency response is periodic ,
calculate h(n) using inverse Fourier method
Filter Design Procedure

Determine the form of H(ej) .


Calculate h(n) using

1

j ) jn
h( n) H ( e e d
2

Use an appropriate number of points, then shift to h(n)


to design a causal system
Low pass filter design
Recall that for the FIR filter
k ; c
H ( )
0 ; c

k L
y ( n) h( n) x ( n k )
k 0

1
H (e )e jn d
j
where h(n)
2
c
1 1
ke d d
jn jn
ke
2
2 c

k e jn c e jn c
{ }
n 2j
k
sin( n c ) n 0, 1,2,...
n
Example
Assume that c=/4, and that k=1, then the
values of h(n) are tabulated below
n=[-10:10] h(-10) = 0.0318 0.0250 -0.0000
-0.0322 -0.0531
y=0.25*sinc(n/4)
-0.0450 0.0000 0.0750
0.1592 0.2251
0.2500 0.2251 0.1592 0.0750
0.0000
-0.0450 -0.0531 -0.0322 -
0.0000 0.0250
h(10)=0.0318
Impulse response plot
> stem (n, y)
Windowed Fourier Series
To get an FIR filter the IIR sequence needs to be
truncated. This is done by multiplying by a window
function, w(n), of compact support, to give

hT (n) w(n)h(n)
If the window that produces the least squared error in the
magnitude response is sought it can be shown that
1 ; n M
w(n)
0 ; n M
So that the causal Type-I FIR impulse response
is
c
hc (n) sinc( c (n M )) ; n 0,1,...,2 M

2. Windowing effects: window types

Rectangular: WnR 1,n 0,1,...M 1

1 2 n 2 2 n
Hanning: W 1 cos
N
sin ,n 0,1,...M 1
M 1 M 1
n
2

2 n
Hamming: WnM 0.54 0.46 cos ,n 0,1,...M 1
M 1

2 n 4 n
Blackman: W 0.42 0.5cos
B
0.08cos ,n 0,1,...M 1
M 1 M 1
n
Example Frequency Responses with
Different Windows
Each window is slightly different in the time domain.
Frequency Responses with Different
Windowed truncationWindows
of a filter ideal frequency response.

Each window type has different properties.


Stop band attenuation for Blackman is highest but Blackman has long
transition width.
Window Method
Window Method
Second stage of this method is to select a window function based on the
passband or attenuation specifications, then determine the filter length based on
the required width of the transition band.

Normalised Transition Stopband Attenuation


Window Type Passband Ripple(dB)
Width (f(Hz)) (dB)

0.9
Rectangular 0.7416 21
N

3 .1
Hanning 0.0546 44
N

3.3
Hamming 0.0194 53
N

5.5
Blackman 0.0017 74
N
2.93
4.54
N 0.0274 50
Kaiser 5.71
8.96
N 0.000275 90
Summary
f = Normalised transition width
f = Transition width/Sampling Frequency

Window Method
The third stage is to calculate the set of truncated or windowed impulse
response coefficients, h[n]:

N 1 N 1
n for N odd
hn hd nW n for 2 2
N
n
N for N even
2 2

2n
Where: W n 0.54 0.46 cos
N
for 66 n 66
2n
0.54 0.46 cos
133
2. Windowing effects: window types
Adjustable windows:
Kaiser window:

2 n
2

I0 1 1
M 1
WnK ,n 0,1,...M 1
I0
2
x 2 m
Where: I 0 ( x) 1
m 1
m !

For Kaiser Window


7.95
N
14.36
A = -20 log() is the stop-band attenuation
= min(p , s)
Amplitude Specification Example
A low- pass digital filter is required for a physiological noise reduction.
The filter should meet the following specifications:
Pass-band edge frequency 1.5 kHz
Transition width 0.5 kHz
Stop-band attenuation > 50 dB
Sampling frequency 8 kHz
Solution
Transition width = 0.5 K
From the table we can see that Hamming, Blackman, Kaiser
windows will satisfy stop-band attenuation
Hamming window: N 3.3/( f) = 3.3/(0.0625) = 52.8
Choose N = 53
2. Windowing effects
We can view the truncation of the infinite impulse response of an ideal filter as
windowing. In frequency domain, this operation is equivalent to convolution of
a frequency response of the window function with the frequency response of
an ideal filter.
ht ,n hd ,n wn

1.2
|Ht()|
W R: 1
|W()|
0.8 |Hd()|
Gibbs phenomenon
0.6
(comes from truncated
Fourier series) 0.4

0.2
Ripples of equal magnitude in PB and SB
0
Transition band another window artifact
-0.2
-1 -0.5 0 0.5 1
/
Frequency Sampling Structures
Frequency Sampling Method

The frequency sampling method allows to


design recursive and nonrecursive FIR filters
for both standard frequency selective and
filters with arbitrary frequency response.
DFT Review

If x(n) is a real sequence of duration N then


Re[X(k)] = Re[X(N-k)]
Im[X(k) = -Im[X(N-k)]
Non recursive frequency sampling
filters :
The problem of FIR filter design is to find a
finitelength impulse response h(n) that
corresponds to desired frequency response.
In this method h (n) can be determined by
uniformly sampling, the desired frequency
response Hd () at the N points and finding its
inverse DFT of the frequency samples as
shown in the Figure 4.
Frequency Sampling Method

Basic Idea :
Given the ideal low-pass
filter H(ej), choose the
filter length M and then
sample H(ej), at M
equi-spaced frequencies
between 0 and 2. The
actual response H(ej), is
the interpolation of the
Figure 4
samples of H(k)
Frequency Sampling Method
j 2k / M H (0) for k 0
H (k ) H (e ) *
H ( M k ) k 1. ..., M - 1

2k j
Thus H(k) is given by H (k ) H ( )e
M

M 1 2k M - 1
( )( ) k 0,..., 2
2 M

( M 1)( 2 )( M k ), k M 1 1,..., M 1
2 M 2
Example
Design a low-pass filter using frequency sampling method with p =
0.2 , s = 0.3 and As ( attenuation in stop band ) = 50 dB

Solution:

Choosing M = 20, so the we have a frequency sample at p = 0.2 of k= 2


p = 0.2 = (2/20) x 2 ( so k = 2)
s = 0.3 = (2/20) x 3 ( so k = 3)

The magnitude of the DFT coefficients are have even symmetric X(k) = X(M-k)
Thus H(k) (magnitude) = [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1] (15 zeros)
Phase = =
2
9.5 k 9.5k k 0,1,...9
20
9.5 (20 - k), k 10, 11,...19

h(n)= IDFT(H(k))
Frequency Sampling Filters

Frequency sampling filters are based on


specification of a set of samples of the desired
frequency response at N uniformly spaced
points around the unit circle. The set of
frequencies that have been used until this
point is determined by the relation.
Recursive Frequency Sampling Filter
In recursive frequency sampling method the DFT samples H (k) for
an FIR sequence can be regarded as samples of the filters z
transform, evaluated at N points equally spaced around the unit
circle
The frequency response is given by
H = 1
=0
and it follow also
that
2
= = 1

=0 2/

( samples of the frequency response at the


sampled point are equal to DFT values)
The DFT can be evaluated from the Z transform as

H(k)

H(k)
Specifying Frequency Response
Implementation
High-Pass , Band-pass and Band-
stop design
High Pass FIR Filter
High Pass FIR Filter
High pass filter can be achieved by
High-Pass , Band-pass and Band- stop design

By comparing the magnitude response of an ideal lowpass


filter and high pass filter, we observe that = - a (a = c )
Conclusion: Shift the low-pass filter frequency response by
, we obtain the high filter frequency response.

H HP (e j ) H LP (e j ( )

j
H HP (e ) h
n
LP (n)(e jn( )

h
n
LP (n)(e jn ( )
)(e jn ( n )
) h
n
LP (n)(e jn( ) )( 1) n

LP
h (
n
n )( e jn ( )
)( 1) n


h
n
HP (n)(e jn( ) )

Thus h HP (n) hLP (n)( 1) n


Example

Design a high pass filter which has a pass-band for the frequencies greater
than 10 kHz, with a sampling frequency set at 50 KHz. Assume the pass-
band gain frequency is unity.
Digital Cut off frequency = c = wT = 2 (10k)(1/50k)=0.4
The corresponding lowpass cuffoff frequency = - 0.4 = 0.6
hLp = (1/n )sin (0.6 n)
hHP = (-1)n (1/n )sin (0.6 n)
Bandpass Filter Design
Band Pass FIR Filter Design
Frequency Transformation

Lowpass Fiter
k
hLP (n) sin( n c ), n 0, 1, 2,.., I
n
HighPass Filter Trasnformation
h HP (n) (-1)n hLP (n)
BandPass Filter Transformation
h BP (n) [2 cos(n o )]hLP (n) where
u l
u l 2 c , 0
2
Bandstop
h BS (0) K - h BP (0)
h BS (n) - h BP (n), n 0, 1, 2,.., I
u l
u l 2 c , 0
2
Example 2

Design a band-pass filter which has a pass-band gain of 1 in the


interval from 10 kHz to 15 kHz with a system sampling frequency
of 50 kHz. Determine the general expression for the filter weights
Solution:

2 (10) 4 2 (10) 4 x1.5


l 4
0.4 u 4
0.6
5(10) 5(10)
l
c u 0.1 o 0.5
2
1
hLP (n) sin 0.1n
n
1
hBP (n) 2 cos(0.5n) sin 0.1n
n
Realisation Structure Selection - Step 3
Direct form structure for an FIR filter:
N 1
H z bk z k
k 0

Y z H z X z yn b0 xn b1 xn 1 .... bN 1 xn N 1

-1 -1 -1
x(n) z z z

b b b b
0 1 2 N-1

+ + + y(n)
Realisation Structure Selection - Step 3
Direct form structure for an FIR filter:
N 1
H z bk z k
k 0

Linear phase structures:


N
1


2
N even: H z bk z k z N k 1
k 0

N 1
N 1

2
N Odd: H z bk z k z N k 1 b N 1 z 2

k 0 2
Realization Structure Selection - Step 3
(a) N even. z
-1
z
-1
z
-1
z
-1
z
-1

b0
+

(b) N odd. +
b1

b2
+

+ +

b N/2-1
+ +
y(n)
(a)

x(n) -1 -1 -1 -1 -1 -1
z z z z z z
b0
+
b1
+ +
b2
+ +
b(N-1)/2

b(N-3)/2
+ +

y(n) +

(b)
Realisation Structure Selection - Step 3
Direct form structure for an FIR filter:
N 1
H z bk z k
k 0

Cascade structures:
N 1
H z bk z k b0 b1 z 1 b2 z 2 ... bN 1 z N 1
k 0

b b b
b0 1 1 z 1 2 z 2 ... N 1 z N 1
b0 b0 b0


M
b0 1 bk ,1 z 1 bk , 2 z 2
k 1
Realisation Structure Selection - Step 3
Direct form structure for an FIR filter:
N 1
H z bk z k
k 0

Cascade structures:

x(n) b0 y(n)
+ + +

z -1 z -1 z -1
b 1,1 b 2,1 b M,1
+ + +
z -1 z -1 z -1
b 1,2 b 2,2 b M,2
63

Preliminary considerations

M 1
FIR filter: H ( z ) hk z k (11.2.1)
k 0

transfer function unit-pulse response


M 1

M 1 k
b z k

H ( z ) hk z k k 0
;a0 1 (11.2.2)
k 0 a0
Here M-1 is the filter order.
M is the number of filters coefficients. Assuming that M is odd:

H ( z ) h0 h1 z 1 h2 z 2 ... hM 2 z ( M 2) hM 1 z ( M 1)
M 1 M 3
M 1 M 1 M 1
2
2 k k
z hM 1 hk z 2
hk z 2 (11.2.3)
2 k 0 M 1

k
2
64

Preliminary considerations

For an FIR filter to have a linear phase:

hk hM* 1 k (11.3.1)

That means an even symmetry of the coefficients.


M 1
M 3
M 1
M 3
M 1
k

k

2 2
H ( z) z 2
hM 1 hk z 2
hM 1 k z 2
2 k 0 k 0


M 1 M 1
M 3
2 M 1 k
2
k
z hM 1 hk z 2
hM 1 k z 2
(11.3.2)
2
k 0

Remember: FIR filters are always stable (no poles other than at the origin)!
65

Preliminary considerations

Since the filter is stable:

M 1 M 3
M 1 M 1
j k
j
h j k

2

M21
H (e j ) e 2
h e jhk
e 2
e jhk
e 2

k


k 0

M 1 M 3

j
h 2
2
M 1
e 2
M21
k 0
hk cos
2

k

hk

(11.4.1)


Rc (e j )
Here Rc (e j ) is a real function of frequency.
As a result of symmetry:
M 1
H e e Rc e j
j
j 2 (11.4.2)
66

Preliminary considerations

Therefore: M 1
if Rc e j 0

H e j 2
(11.5.1)
M 1 if R e j 0
2
c

Generalized linear phase

We can use Rc e to design ANY amplitude of frequency response: LPF,


j

HPF, BPF,

When Rc e changes sign, the phase undergoes an abrupt change of 180


j 0

In M is even: M 2
2
M 1
Rc (e ) 2
j
hk cos k hk (11.5.2)
k 0 2
67

Preliminary considerations

An FIR filter will also have a linear phase in the case of odd symmetry of
filter coefficients (antisymmetric impulse response), i.e.:
hk hM* 1k (11.6.1)

It can be shown that


M 3
2
M 1
Rs (e j ) 2 hk sin k hk ;M isodd (11.6.2)
k 0 2
M 2
2
M 1
Rs (e j ) 2 hk sin k hk ;M iseven (11.6.3)
k 0 2
Therefore: M 1
j
H e j e 2
jRs e j (11.6.4)

H jdifferentiator (11.6.5)

H j sign Hilberttransformer (11.6.6)


68

Preliminary considerations

Thus: M 1
if Rs e j 0

H e j 2 2
(11.7.1)
3 M 1 if R e j 0
2 2
s

Generalized linear phase

Summarizing, a unit-pulse response of a GLP FIR filter must satisfy:


hk hM* 1 k (11.7.2)

M 1
H ( z ) hk z k (11.7.3)
k 0

M 1 Rc e j LPF , HPF , BPF , BSF ,...


j
H e j e 2
(11.7.4)

jR
s e j
differentiators,Hilberttransformers
We only need to specify (M-1)/2 (odd M) or M/2 unique coefficients (even M).
69

Preliminary considerations

Combining (11.7.2) and (11.7.3), we arrive at:


M 1 M 1 M 1
H ( z ) hk z k
h *
M 1 k z k
m M 1 k hm* z m( M 1)
k 0 k 0 m0
M 1
z ( M 1)
m
h* m
z z ( M 1)
H *
1 z *
(11.8.1)
m 0
1 1 j
hasazeroatz z0 re j
hasazeroat z *
e
z0 r
1

Example: if M = 5: 0.5

Imaginary Part
H ( z ) h0 h1 z 1 h2 z 2 h3 z 3 h4 z 4 0
4

-0.5
Has two pairs of reciprocal zeros.
-1
firls(4,[0 0.25],[1 0]); -1 -0.5 0 0.5 1
Real Part
70

Location of Zeros for Symmetric Cases


For type I and II we have
hn hM 1 n

z

H z z ( M 1) H z 1
So if z0 is a zero 1/z0 is also a zero of the system
If h[n] is real and z0 is a zero , then z0* is also a zero
So for real and symmetric h[n] zeros come in sets of four
Special cases where zeros come in pairs
If a zero is on the unit circle reciprocal is equal to conjugate
If a zero is real conjugate is equal to itself
Special cases where a zero come by itself
If z=1 both the reciprocal and conjugate is itself
Particular importance of z=-1

H 1 1 H 1
M 1

If M is even implies that


H
Cannot design high-pass filter 1 symmetric
with 0 FIR filter and M is
even
70
No issues with M is odd
71

Location of Zeros for Antisymmetric Cases

For type III and IV we have


hn hM 1 n

z

H z z ( M 1) H z 1
All properties of symmetric systems holds
Particular importance of both z=+1 and z=-1

f z=1 H1 H1 H1 0

Independent from M: odd or even


If z=-1
H 1 1 H 1
M

If M is odd implies that H 1 0 71


72

Preliminary considerations
There are four types of real GLP FIR filters:

Type I: Type II:


symmetric hn, symmetric hn,
odd M even M
(number of
coefficients)
even order.

Type III: Type IV:


antisymmetric antisymmetric
hn, odd M hn, even M

indicate structural zeros


73

Preliminary considerations

As a result of structural zeros

Type II FIR HPF would have a zero at - specs will be violated!


Type III FIR HPF would have a zero at - specs will be violated!
Type IV FIR LPF would have a zero at 0 - specs will be violated!

If something like tis happens, increase or decrease the FIR order to change
the type of your filter.

We need to be careful with selection of filter orders!

You might also like