Download presentation
Presentation is loading. Please wait.
Published byRhoda Weaver Modified over 9 years ago
1
EE 445S Real-Time Digital Signal Processing Lab Fall 2011 Lab #3.1 Digital Filters Debarati Kundu (With the help of Mr. Eric Wilbur, TI)
2
2 Outline Discrete-Time Convolution FIR Filter Design Convolution Using Circular Buffer FIR Filter Implementation FIR Filter Block Processing Code Optimization
3
3 Discrete-Time Convolution Represented by the following equation Filter implementations will use the second version (hold h[n] in place and flip-and-slide x[n] about h[n]) Z-transform of convolution
4
4 Discrete-Time Sinusoidal Response Input two-sided complex sinusoid: x[n] = e j n LTI system has impulse response h[n] Output y[n] = x[n] * h[n] H( ) is frequency response of the LTI system Filters are stable, so H( ) = H[z] | z=exp(j ) Multiplying by H( ) = A( ) e j ( ) causes change in magnitude by A( ) and change in phase by ( ) H()H()
5
5 FIR Filters Design & Implementation An FIR filter does discrete-time convolution z -1 indicates delay elements and hence we need a buffer We shall implement FIR filters using circular buffers
6
6 FIR Filters Design & Implementation Implementation Use the Filter Design & Analysis Tool (fdatool) to get the co- efficient. Specifications are given in the task list Use convolve function (explained in subsequent slides) to implement FIR filter given coefficients from fdatool.
7
7 Convolution Using Circular Buffer Always choose the size of circular buffer to be larger than N. Make sure that the size of the circular buffer is a power of 2.
8
8 Convolution Using Circular Buffer main() { int x_index = 0; float y, xcirc[N]; --- /*--------------------------------------------*/ /* circularly increment newest (No %)*/ ++newest; if(newest == N) newest = 0; /*-------------------------------------------*/ /* Put new sample in delay line. */ xcirc[newest] = newsample; /*-------------------------------------------*/ /* Do convolution sum */ Go on to the next column y = 0; x_index = newest for (k = 0; k < No_of_coeff; k++) { y += h[k]*xcirc[x_index]; /*-------------------------------------*/ /* circularly decrement x_index */ --x_index; if(x_index == -1) x_index = N-1; /*-------------------------------------*/ }... }
9
9 Block Processing using Ping-Pong Buffer This lab uses a double-buffered (PING/PONG) channel-sorted (L/R) buffering scheme. A FIR algorithm requires “history” to be preserved over calls to the algorithm. FIR_process() must first copy the history, then process the data. data rcvPingL.hist rcvPingL.data hist data hist rcvPongL.hist rcvPongL.data PING PONG Processing of the last data blk (PONG) starts from the top of hist down thru data for DATA_SIZE items. This leaves the last ORDER-1 data items NOT processed. Therefore, user must copy the history of the last processed buffer (PONG) to the new buffer (PING), then filter. Repeat the process…
10
TSKHWI isrAudio rcvBufs ADC DAC McASP SR12 SR11 isrAudio xmtBufs FIR or COPY AIC3106 Audio Codec SEM_post() LED PRD1PRD2 CLK 100ms500ms SW8
11
Code Optimization count i = 1 Y = coeff i * x i A typical goal of any system’s algorithm is to meet real-time You might also want to approach or achieve “CPU Min” in order to maximize #channels processed The minimum # cycles the algorithm takes based on architectural limits (e.g. data size, #loads, math operations req’d) Goals : CPU Min (the “limit”): Often, meeting real-time only requires setting a few compiler options However, achieving “CPU Min” often requires extensive knowledge of the architecture (harder, requires more time) Real-time vs. CPU Min
12
12 “Debug” vs “Optimized” Benchmarks for (j = 0; j < nr; j++) { sum = 0; for (i = 0; i < nh; i++) sum += x[i + j] * h[i]; r[j] = sum >> 15; } Debug – get your code LOGICALLY correct first (no optimization) “Opt” – increase performance using compiler options (easier) “CPU Min” – it depends. Could require extensive time OptimizationMachine Cycles Debug (no opt, –g)817K “Release” (-o3, no -g)18K CPU Min6650
13
Provides the best “debug” environment with full symbolic support, no “code motion”, easy to single step Code is NOT optimized – i.e. very poor performance Create test vectors on FUNCTION boundaries (use same vectors as Opt Env) “Debug” (–g, NO opt): Get Code Logically Correct Higher levels of optimization results in code motion – functions become “black boxes” (hence the use of FXN vectors) Optimizer can find “errors” in your code (use volatile ) Highly optimized code (can reach “CPU Min” w/some algos) Each level of optimization increases optimizer’s “scope”… “Release” (–o3, –g ): Increase Performance
14
Levels of Optimization FILE1.C { } {... } {... } FILE2.C -o0, -o1 -o2 -o3-pm -o3 LOCAL single block FUNCTION Across blocks FILE Across functions PROGRAM Across files {... }
15
DSPLIB Optimized DSP Function Library for C programmers using C62x/C67x and C64x devices These routines are typically used in computationally intensive real-time applications where optimal execution speed is critical. By using these routines, you can achieve execution speeds considerably faster than equivalent code written in standard ANSI C language. And these ready-to-use functions can significantly shorten your development time. The DSP library features: C-callable Hand-coded assembly-optimized Tested against C model and existing run-time-support functions Adaptive filteringMath DSP_firlms2DSP_dotp_sqr CorrelationDSP_dotprod DSP_autocorDSP_maxval FFTDSP_maxidx DSP_bitrev_cplxDSP_minval DSP_radix 2DSP_mul32 DSP_r4fftDSP_neg32 DSP_fftDSP_recip16 DSP_fft16x16rDSP_vecsumsq DSP_fft16x16tDSP_w_vec DSP_fft16x32Matrix DSP_fft32x32DSP_mat_mul DSP_fft32x32sDSP_mat_trans DSP_ifft16x32Miscellaneous DSP_ifft32x32DSP_bexp Filters & convolutionDSP_blk_eswap16 DSP_fir_cplxDSP_blk_eswap32 DSP_fir_genDSP_blk_eswap64 DSP_fir_r4DSP_blk_move DSP_fir_r8DSP_fltoq15 DSP_fir_symDSP_minerror DSP_iirDSP_q15tofl
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.