Vlsi DSP Fir Final
Vlsi DSP Fir Final
Vlsi DSP Fir Final
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
-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
y0 b0 0 b1 1 bk N
Properties of an FIR Filter
Filter coefficients:
N 1
yn bk xn 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
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
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
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
N 1
Condition Phase k Phase Property Filter Type
2
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
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
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.
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 !
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
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:
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
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
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( ) )
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
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
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
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
hk hM* 1 k (11.3.1)
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
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
HPF, BPF,
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)
H jdifferentiator (11.6.5)
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
M 1
H ( z ) hk z k (11.7.3)
k 0
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
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
H 1 1 H 1
M 1
f z=1 H1 H1 H1 0
Preliminary considerations
There are four types of real GLP FIR filters:
Preliminary considerations
If something like tis happens, increase or decrease the FIR order to change
the type of your filter.