Discrete-Time Impulse Signal Let δ[k] be a discrete-time impulse function, a.k.a. the Kronecker delta function: δ [k ] = 1 k =0 0 k≠0 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 1 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 ] = x[k ]∗ h[k ] = ∞ 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] k = ( x[k] + x[k-1] ) / 2 2 1 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 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 3 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 4 2 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, y[ k ] = ∞ e j Ω (k −m ) h[m] = e jΩk m = −∞ ∞ h[m] e − j Ω m = e j Ω k H (Ω ) m = −∞ H (Ω ) H(Ω) is the discrete-time Fourier transform of h[k] and is also called the frequency response 5 Frequency Response For continuous-time systems, response to complex sinusoid is frequency response e j Ω t → H ( jΩ ) e j Ω t cos(Ω t ) → H ( jΩ ) cos(Ω t + ∠H ( jΩ )) For discrete-time systems, response to complex sinusoid is ( ) H (e ) cos(ω k + ∠H (e )) e jω k → H e jω e jω k frequency response cos(ω k ) → jω jω 6 3 Example: Ideal Delay Continuous Time Discrete Time Delay by T seconds Delay by 1 sample x(t) y(t) T x[k] y (t ) = x(t − T ) z −1 y[k] y[ k ] = x[k − 1] Impulse response Impulse response h(t ) = δ (t − T ) h[ k ] = δ [ k − 1] Frequency response Frequency response H (Ω ) = e | H (Ω ) | = 1 ∠H (Ω ) = − Ω T H (ω ) = e − j ω | H (ω ) | = 1 ∠H (ω ) = − ω − jΩT 7 Example: Lowpass Filter System response to complex exponential e j Ωt for all possible frequencies Ω where Ω=2π πf : ∠|H(Ω)| |H(Ω)| stopband Linear phase stopband −Ωs −Ωp Ωp Ωs passband Ω Ω delay (Ω ) = − d ∠H (Ω) = T dΩ Passes low frequencies, a.k.a. lowpass filter FIR filters are only realizable LTI filters that can have linear phase over all frequencies 8 4 Mandrill Demo (DSP First) Five-tap 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 Highpass filter (sharpens input h[k] signal) 1 Impulse response is {1, -1} y[k ] = x[k ] − x[ k − 1] First-order difference impulse response k −1 9 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 10 5 Finite Impulse Response Filters Duration of impulse response h[k] is finite, i.e. non-zero for k =∞ 0, 1, … N-1: N −1 y[k ] = x[k ]∗ h[k ] = h[m ] x[k − m] = h[m] x[k − m ] m = −∞ m =0 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 { x[k ], x[k − 1], ..., x[k − ( N − 1)] } and N nonzero values of the impulse response in vector { h[0], h[1], ..., h[ N − 1] } What instruction set/architecture features would you add to accelerate FIR filtering? 11 Discrete-time Tapped Delay Line Assuming that h[k] has finite duration from k =0,…,N-1 y[k ] = N −1 h[ m] x[ k − m] m= 0 Block diagram of an implementation (finite impulse response digital filter) x[k] h[0] z-1 z-1 … h[1] h[2] … h[N-1] Σ z-1 y[k] 12 6 FIR Implementation: Circular Buffer Shifting the elements in the entire array is inefficient Time index n-1 n 0 1 1 2 3 2 3 address index 4 Better approach is to use circular buffers and updating address index Time index 0 3 1 2 n-1 n address index 4 0 1 4 3 1 2 3 1 2 2 3 13 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. Data memory 31 Beginning address Value of register, BK AR K-1 XXXX 0…………0 XXXX L………….L XXXX LSBs of BK 0 0 LAST+1 14 7