Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1...

7
1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker delta function: Impulse response h[k]: response of a discrete-time LTI system to a discrete impulse function Finite impulse response filter Non-zero extent of impulse response is finite Can be in continuous time or discrete time Also called a tapped delay line [] = = 0 0 0 1 k k k δ 2 [] [] [] [ ][ ] [ ][ ] -∞ = -∞ = - = - = * = m m m k x m h m k h m x k h k x k y Discrete-time Convolution By linear and time-invariant properties, linear convolution For each value of k, compute a different (possibly) infinite summation for y[k] y[k] = h[0] x[k] + h[1] x[k-1] = ( x[k] + x[k-1] ) / 2 k h[k] 2 1 Averaging filter impulse response

Transcript of Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1...

Page 1: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

1

1

Discrete-Time Impulse Signal Let δδδδ[k] be a discrete-time impulse function,

a.k.a. the Kronecker delta function:

Impulse response h[k]: response of a discrete-time LTI system to a discrete impulse function

Finite impulse response filter Non-zero extent of impulse response is finite Can be in continuous time or discrete time Also called a tapped delay line

[ ]

≠=

=00

01

k

kkδ

2

[ ] [ ] [ ] [ ] [ ] [ ] [ ]∞

−∞=

−∞=−=−=∗=

mm

mkxmhmkhmxkhkxky

Discrete-time Convolution By linear and time-invariant properties, linear

convolution

For each value of k, compute a different (possibly) infinite summation for y[k]

y[k] = h[0] x[k] + h[1] x[k-1]

= ( x[k] + x[k-1] ) / 2k

h[k]

2

1

Averaging filter impulse response

Page 2: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

2

3

Comparison to Continuous Time

Continuous-time convolution of x(t) and h(t)

For each value of t, we compute a different (possibly) infinite integral.

Discrete-time definition is the continuous-time definition with the integral replaced by summation

LTI system If we know the impulse response and the input,

we can determine the output Impulse response uniquely characterizes an LTI

system

( ) ( ) ( ) ( ) ( ) ( ) ( )∞

∞−

∞−−=−=∗= λλλλλλ dtxhdthxthtxty

4

Convolution Demos Johns Hopkins University Demonstrations

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 a triangle whose width is twice the width of the rectangular pulses

Page 3: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

3

5

Linear Time-Invariant Systems The Fundamental Theorem of Linear Systems

If one inputs a complex sinusoid into an LTI system, then the output will 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 discrete time. Let x[k] = e j Ω k,

H(Ω) is the discrete-time Fourier transform of h[k] and is also called the frequency response

( )

( )

( )Ω=== Ω

Ω

−∞=

Ω−Ω∞

−∞=

−Ω Heemhemheky kj

H

m

mjkj

m

mkj ][][][

6

Frequency Response For continuous-time systems, response to

complex sinusoid is

For discrete-time systems, response to complex sinusoid is

( )( ) ( ) ( )( )ωω

ωωω

ωω

cos cos

jj

kjjkj

eHkeHk

eeHe

∠+→

( )( ) ( ) ( )( )Ω∠+ΩΩ→Ω

Ω→ ΩΩ

jHtjHt

ejHe tjtj

cos cos

frequency response

frequency response

Page 4: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

4

7

Example: Ideal Delay Continuous Time

Delay by T seconds

Impulse response

Frequency response

Discrete TimeDelay by 1 sample

Impulse response

Frequency response

( ) )( Ttxty −=

Tx(t) y(t)

( ) )( Ttth −= δ

( )( )( ) TH

HeH Tj

1 ||

Ω−=Ω∠=Ω

=Ω Ω−

]1[][ −= kxky

1−zx[k] y[k]

]1[][ −= kkh δ

( )( )( ) ωωω

ω ω

1 ||

−=∠=

= −

HH

eH j

8

Example: Lowpass Filter System response to complex exponential e j ΩΩΩΩt

for all possible frequencies ΩΩΩΩ where ΩΩΩΩ=2ππππf :

Passes low frequencies, a.k.a. lowpass filter FIR filters are only realizable LTI filters that can

have linear phase over all frequencies

Ω

∠|H(Ω)|

Ω

|H(Ω)|

Ωp Ωs−Ωs −Ωp

passband

stopband stopbandLinearphase

THd

ddelay =Ω∠

Ω−=Ω )()(

Page 5: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

5

9

Mandrill Demo (DSP First) Five-tap averaging FIR filter with input x[k] and

output y[k]

Lowpass filter (smooth/blur input signal) Impulse response is 1/5, 1/5, 1/5, 1/5, 1/5

First-order difference FIR filter Highpass filter (sharpens input

signal) Impulse response is 1, -1

[ ] ]4[5

1]3[

5

1]2[

5

1]1[

5

1][

5

1 −+−+−+−+= kxkxkxkxkxky

[ ] ]1[][ −−= kxkxky k

h[k]

1

First-order difference impulse response

1−

10

Mandrill Demo (DSP First) From lowpass filter to highpass filter

original → blurry → sharpened

From highpass to lowpass filter original → sharpened → blurry

Frequencies that are zeroed out (e.g. DC) can never be recovered

Order of two LTI systems in cascade can be switched under the assumption that the computations are performed in exact precision

Page 6: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

6

11

Finite Impulse Response Filters Duration of impulse response h[k] is finite,

i.e. non-zero for k = 0, 1, … N-1:

Output depends on current input and previous N-1 inputs Summation to compute y[k] reduces to a vector dot product

between N input samples in the vector

and N nonzero values of the impulse response in vector

What instruction set/architecture features would you add to accelerate FIR filtering?

[ ] [ ] [ ] [ ] [ ] [ ] [ ]−

=

−∞=

−=−=∗=1

0

N

mm

mkxmhmkxmhkhkxky

)]1([ ..., ],1[ ],[ −−− Nkxkxkx

]1[ ..., ],1[ ],0[ −Nhhh

12

=−=

1

0

][ ][ ][N

m

mkxmhky

Discrete-time Tapped Delay Line Assuming that h[k] has finite duration from

k =0,…,N-1

Block diagram of an implementation (finite impulse response digital filter)

z-1 z-1 z-1…

x[k]

Σ y[k]

h[0] h[1] h[2] h[N-1]

Page 7: Discrete-Time Impulse Signaltorlak/courses/DSProject/lectures/lectureFIRDSP.pdf · 1 1 Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker

7

13

FIR Implementation: Circular Buffer Shifting the elements in the entire array is

inefficient

Better approach is to use circular buffers and updating address index

0

1

4

1

2

323

Time index n-1 n

address index

0

1

0

1 4

1

3

2

4

1

23

22

3

3

Time index n-1 naddress index

14

DSP Hardware for Circular Buffer DSPs have hardware support to implement circular

buffers even more efficiently Let N be number of coefficients and then, N is

circular buffer block size BK is a block size register Beginning address of the circular buffer array is a

multiple of the smallest power of 2 strictly greater than the filter length N.

LAST+1

0XXXX

XXXX

XXXX

0…………0

L………….L

LSBs of BK

AR

31 K-1 0Beginning address

Value of register, BK

Data memory