Transcript Linearity

EE345S Real-Time Digital Signal Processing Lab
Spring 2006
Finite Impulse Response Filters
Prof. Brian L. Evans
Dept. of Electrical and Computer Engineering
The University of Texas at Austin
Lecture 5
http://courses.utexas.edu/
Discrete-Time Impulse Signal
• Let d[k] be a discrete-time impulse function, a.k.a.
Kronecker delta function:
1 k  0
d k   
0 k  0
• Impulse response is response of discrete-time LTI
system to discrete impulse function
d[k]
1 h[k]
Example: delay by one sample
• Finite impulse response filter
z
h[k ]  d [k  1]
Non-zero extent of impulse response is finite
Can be in continuous time or discrete time
Also called tapped delay line (see slides 3-13, 3-19, 5-3)
5-2
Discrete-time Tapped Delay Line
• Impulse response h[k] of finite extent k = 0,…, M-1
M 1
y[k ]   h[m] x[k  m]
Discrete-time
convolution
m 0
• Block diagram (finite impulse response filter)
x[k-1]
x[k]
h[0]
z-1
z-1
…
z-1
h[1]
h[2]
…
h[M-1]
S
Applications of continuoustime tapped delay lines?
y[k]
5-3
Discrete-time Convolution Derivation
• Output y[k] for input x[k]
yk   T xk 
 

yk   T   xmd k  m
m

• Any signal can be decomposed
into sum of discrete impulses
yk  
• Apply linear properties
yk  
• Apply shift-invariance
• Apply change of variables
yk  

 xmT d k  m
m  

 xm hk  m
m  

 hm xk  m
m  
h[k]
Averaging filter
impulse response
1
2
y[k] = h[0] x[k] + h[1] x[k-1]
0
1
2
3
k
= ( x[k] + x[k-1] ) / 2
5-4
Comparison to Continuous Time
• Continuous-time convolution of x(t) and h(t)


yt   xt  ht    x  ht    d   h  xt    d


For each t, compute different (possibly) infinite integral
• In discrete-time, replace integral with summation
yk  


m  
m  
 xm hk  m   hm xk  m
For each k, compute different (possibly) infinite summation
• LTI system
From impulse response and input, one can determine output
Impulse response uniquely characterizes LTI system
5-5
Convolution Demos
• Johns Hopkins University Demonstrations
http://www.jhu.edu/~signals (http://www.jhu.edu/~signals)
Convolution applet to animate convolution of simple signals
and hand-sketched signals
Convolving two rectangular pulses of same width gives
triangle with width of twice the width of rectangular pulses
(also see Appendix E for intermediate calculations)
x(t)
*
1
0
Ts
t
h(t)
1
0
Ts
y(t)
=
Ts
t
Ts
2Ts
5-6
t
Linear Time-Invariant Systems
• Complex exponentials zk have yk   hk  f k   hk  z k

a special property when they
  hmz k  m
m  
are input into LTI systems

k
 z  h[m]z  m
• Output will be same complex
m  
exponential weighted by H(z)
 z k H ( z)
• When we specialize the z-domain to frequency
domain, magnitude of H(z) will control which
frequencies are attenuated or passed
• H(z) is also known as the transfer function
5-7
Linear Time-Invariant Systems
• The Fundamental Theorem of Linear Systems
If a complex sinusoid were input into an LTI system, then
the output would be a complex sinusoid of the same
frequency that has been scaled by the frequency
response of the LTI system at that frequency
Scaling may attenuate the signal and shift it in phase
Example in continuous time: see handout F
Example in discrete time. Let x[k] = e j W k,
y[k ] 

e
m  
j W k m 
h[m]  e
jWk

jWm
jWk
h
[
m
]
e

e
H W

m  
H(W)
H(W) is discrete-time Fourier transform of h[k]
H(W) is also called the frequency response
5-8
Frequency Response
• For continuous-time systems, response to complex
sinusoid is
e j W t  H  jW e j W t
frequency response
cosW t   H  jW cosW t  H  jW
• For discrete-time systems, z-k = (r e j w)–k = r-k e – j w k
and the response is
z k  H ( z) z k
• For discrete-time systems, response to complex
sinusoid is
e j w k  H e j w  e j w k
frequency response
 

 
cosw k   H e j w cos w k  H e j w
5-9
Example: Ideal Delay
• Continuous Time
Delay by T seconds
x(t)
T
y(t)
yt   x(t  T )
• Discrete Time
Delay by 1 sample
x[k]
z
1
y[k]
y[k ]  x[k  1]
Impulse response
ht   d (t  T )
Impulse response
h[k ]  d [k  1]
Frequency response
Frequency response
H w   e j w
H W  e j W T
| H W |  1
| H w  |  1
H W   W T
H w    w
5 - 10
Frequency Response
• System response to complex sinusoid e j W t for all
possible frequencies W where W = 2 p f :
|H(W)|
|H(W)|
stopband
stopband
Ws Wp
Wp Ws
passband
W
Linear
phase
W
d
delay (W)  
H (W)  T
dW
• Above: passes low frequencies, a.k.a. lowpass filter
• FIR filters are only realizable LTI filters that can
have linear phase over all frequencies
• Not all FIR filters exhibit linear phase
5 - 11
Linear Time-Invariant Systems
• Any linear time-invariant system (LTI) system,
whether continuous-time or discrete-time, can be
uniquely characterized by its
Impulse response: response of system to an impulse OR
Frequency response: response of system to a complex
sinusoid (e j W t or e j w k) for all possible frequencies OR
Transfer function: general transform of impulse response
(Laplace transform for continuous-time systems and ztransform for discrete-time systems)
• Given one, we can find other two if they exist
Give an impulse response that has a Laplace transform but
not a Fourier transform? What about the other way?
5 - 12
Mandrill Demo (DSP First)
• Five-tap discrete-time averaging FIR filter with
input x[k] and output y[k]
yk  
1
1
1
1
1
x[k ]  x[k  1]  x[k  2]  x[k  3]  x[k  4]
5
5
5
5
5
Lowpass filter (smooth/blur input signal)
Impulse response is {1/5, 1/5, 1/5, 1/5, 1/5}
• First-order difference FIR filter
yk   x[k ]  x[k 1]
Highpass filter (sharpens
input signal)
Impulse response is {1, -1}
h[k]
First-order difference
impulse response
1
k
1
5 - 13
Mandrill Demo (DSP First)
• DSP First demos: http://users.ece.gatech.edu/~dspfirst
• From lowpass filter to highpass filter
original image  blurred image  sharpened/blurred image
• From highpass to lowpass filter
original image  sharpened image  blurred/sharpened image
• Frequencies that are zeroed out can never be
recovered (e.g. DC is zeroed out by highpass filter)
• Order of two LTI systems in cascade can be
switched under the assumption that computations
are performed in exact precision
5 - 14
Mandrill Demo (DSP First)
• Precision
– Input is represented as eight-bit numbers [0,255] per image
pixel (i.e. fewer than three decimal digits of accuracy)
– Filter coeffients represented by one decimal digit each
– Intermediate computations (filtering) in double-precision
floating-point arithmetic (15-16 decimal digits of accuracy)
– Output is represented as eight-bit number [-128, 127]
(i.e. fewer than three decimal digits)
• No output precision was harmed in the making of
this demo 
5 - 15
Finite Impulse Response Filters
• Duration of impulse response h[k] is finite, i.e. zerovalued for k outside interval [0, M-1]:
yk   xk  hk  

M 1
m  
m 0
 hm xk  m   hm xk  m
– Output depends on current input and previous M-1 inputs
– Summation to compute y[k] reduces to a vector dot product
between M input samples in the vector
 x[k ], x[k 1], ..., x[k  (M 1)] 
and M values of the impulse response in vector
 h[0], h[1], ..., h[M 1] 
• What instruction set architecture features would you
add to accelerate FIR filtering?
5 - 16
Symmetric FIR Filters
• Impulse response often symmetric about midpoint
– Phase of frequency response is linear (slides 5-9 to 5-11)
– Example: three-tap FIR filter (M = 3) with h[0] = h[2]
yk   h[0] x[k ]  h[1] x[k  1]  h[2] x[k  2]
 h[0]x[k ]  x[k  2]  h[1] x[k  1]
• Implementation savings
– Reduce number of multiplications from M to M/2 for evenlength and to (M+1)/2 for odd-length impulse responses
– Reduce storage of impulse response by same amount
– TI TMS320C54 DSP has an accelerator instructor FIRS to
compute h[0] ( x[k] + x[k-2] ) in one instruction cycle
– On most DSPs, no accelerator instruction is available 5 - 17
Filter Design
• Specify a desired
piecewise constant
magnitude response
• Lowpass filter example
w  [0, wp], mag  [1-dp, 1]
w  [ws, p], mag  [0, ds]
Transition band unspecified
• Symmetric FIR filter
design methods
Windowing
Least squares
Remez (Parks-McClellan)
Lowpass Filter Example
Desired Magnitude Response
1
forbidden
1dp
forbidden
Achtung!
forbidden
ds
w
wp
Passband
ws
p
Transition Stopband
band
dp passband ripple
ds stopband ripple
Red region
is forbidden
5 - 18
Importance of Linear phase
• Speech signals
• Linear phase crucial
Use phase differences to
Audio
locate a speaker
Images
Once locked onto a speaker,
Communication systems
our ears are relatively
• Linear phase response
insensitive to phase
Need FIR filters
distortion in speech from
that speaker (underlies
Realizable IIR filters
speech compression
cannot achieve linear
systems, e.g. digital cell
phase response over all
phones)
frequencies
5 - 19
Z-transform Definition
• For discrete-time systems, z-transforms play same
role as Laplace transforms do for continuous-time
systems
Bilateral Forward z-transform
H ( z) 


k  
hk  z k
Bilateral Inverse z-transform
h[k ] 
1
2 p j R
H ( z ) z  k 1dz
Inverse transform requires contour integration over closed
contour (region) R
Contour integration covered in a Complex Analysis course
• Compute forward and inverse transforms using
transform pairs and properties
5 - 20
Common Z-transform Pairs
• h[k] = d[k]
H z  

 d k  z
• h[k] = ak u[k]
k
k  
0
  d k  z
k
1
k 0
Region of convergence: entire
z-plane
• h[k] = d[k-1]
H z  

d k 1 z
k  
k
1
  d k  1 z k  z 1
k 1
Region of convergence: entire
z-plane
h[n-1]  z-1 H(z)
H z  

 a uk  z
k
k
k  


a
  a k z k    
k 0
k 0  z 
1
a

if
1
a
z
1
z
k
Region of convergence:
|z| > |a|
|z| > |a| is the complement
of a disk
5 - 21
Region of Convergence
• Region of the complex zplane for which forward ztransform converges
• Four possibilities (z=0 is a
special case that may or
may not be included)
Im{z}
Entire
plane
Im{z}
Disk
Re{z}
Re{z}
Im{z}
Complement
of a disk
Im{z}
Re{z}
Intersection
of a disk and
complement
of a disk
Re{z}
5 - 22
Stability
• Rule #1: For a causal sequence, poles are inside the
unit circle (applies to z-transform functions that
are ratios of two polynomials) OR
• Rule #2: Unit circle is in the region of convergence.
(For continuous-time signal, imaginary axis would
be in region of convergence of Laplace transform.)
Z
1
• Example: a k uk 
for z  a
1  a z 1
Stable if |a| < 1 by rule #1 or equivalently
Stable if |a| < 1 by rule #2 because |z|>|a| and |a|<1
5 - 23
Transfer Function
• Transfer function is z-transform of impulse
response; e.g. for FIR filter with M taps (slide 5-3)

M 1
k
H ( z )   hk  z   hk  z k  h[0]  h[1] z 1  ...  h[ M  1] z ( M 1)
k  
k 0
Region of convergence is entire z-plane
FIR filters are always stable
• Substitute z = e j w into transfer function to obtain
frequency response
Valid when unit circle is in region of convergence (i.e. for
stable systems according to rule #2 on last slide)
M 1
H (e )  H ( z ) | z e jw   hk  e  j w k  h[0]  h[1] e  j w  ...  h[ M  1] e ( M 1) j w
jw
k 0
5 - 24