{ TESTAFA.ASM is a testing shell for the Adaptive Filtering Algorithms, such as the various Least Mean Squares (LMS) algorithms and the Recursive Least Squares (RLS) algorithm. This file has to be edited to conform with the algorithm employed. *********************************************************************** * This program generates a moving average sequence of real samples, * * and employs the adaptive filter for System Identification based on * * a transversal FIR filter structure. The generating plant is * * described by the following difference equation: * * y(n)= x(n-1)-0.5x(n-2)-x(n-3) * * where the plant impulse response is 0, 1, -0.5, -1, 0, 0, ... . * * The filter is allowed five weight coefficients. The input data * * sequence is a pseudonoise process with a period of 20. * * This program is also used to test adaptive filters based on both * * symmetric transversal FIR and lattice FIR structures. The output * * filter error signal is stored in a data buffer named [flt_err] * * for comparison. * * Place * s in this file with the corresponding code * *********************************************************************** Written by : Wassim G. Najm, Analog Devices, DSP division, April 2 1991 } #define SAMPLES ** { ** = 200 for RLS and 1000 for various LMS } .EXTERN ***_init, ***_alg; { *** = lms, llms, nlms, selms, sdlms, sslms, } { sylms, latlms, rls . } .SEGMENT/DM dm_data; .VAR flt_err[SAMPLES]; .VAR input_data[20]= 0.038, -0.901, 0.01, -0.125, -1.275, 0.877, -0.881, 0.930, 1.233, -1.022, 1.522, -0.170, 1.489, -1.469, 1.068, -0.258, 0.989, -2.891, -0.841, -0.355; .GLOBAL flt_err; .ENDSEG; .SEGMENT/PM pm_data; .VAR plant_hn[3]= -1.0, -0.5, 1.0; .ENDSEG; .SEGMENT/PM rst_svc; dmwait=0x21; pmwait=0x21; jump begin; .ENDSEG; .SEGMENT/PM pm_code; begin: b6=flt_err; l6=0; b7=input_data; l7=20; b15=plant_hn; l15=3; m15=1; m7=1; m6=-3; call ***_init; { *** = algorithm codenames listed above } lcntr=SAMPLES, do adapt_filter until lce; {generate data through the plant} f0=dm(i7,m7), f4=pm(i15,m15); {f0= x(n-3), f4= -1.0} f8=f0*f4, f0=dm(i7,m7), f4=pm(i15,m15); {f8= -x(n-3), f0= x(n-2), f4= -0.5} f12=f0*f4, f0=dm(i7,m7), f4=pm(i15,m15); {f12= -0.5x(n-2), f0= x(n-1), f4= 1.0} f12=f0*f4, f8=f8+f12, f0=dm(i7,m7); {f12= x(n-1), f8= -x(n-3)-0.5x(n-2), f0= x(n)= u(n)} f*=f8+f12, modify(i7,m6); { f*= y(n)= d(n), i7 -> x(n-3) of next iteration} { f*= f1 for lms, nlms, llms, selms, sdlms, sslms,sylms} { f*= f9 for latlms and RLS} call ***_alg; { *** = algorithm codenames listed above } dm(i6,m7)=f*; { store filter error} { f*= f6 for lms, llms, nlms, sdlms, sylms, latlms} { f*= f1 for selms, sslms, rls } nop; adapt_filter: nop; idle; .ENDSEG;