00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include "dsp.h"
00047
00048 #if !defined(FORCE_ALL_GENERICS) && \
00049 !defined(FORCE_GENERIC_FILT32_NLMS) && \
00050 defined(TARGET_SPECIFIC_FILT32_NLMS)
00051
00052 #include "filt_nlms.h"
00053
00054 void dsp32_filt_nlms(dsp32_t *x, dsp32_t *w, int size, dsp32_t new_x, dsp32_t d, dsp32_t *y, dsp32_t *e)
00055 {
00056 int i = 0;
00057 static S64 normalization = 0;
00058 #if !(DSP_OPTIMIZATION & DSP_OPTI_ACCURACY)
00059 S64 temp = 0;
00060 #endif
00061
00062 x[0] = new_x;
00063
00064 dsp32_filt_nlms_fir(x, w, size, y, i);
00065
00066
00067 *e = d - *y;
00068
00069
00070 normalization += ((((S64) new_x)*((S64) new_x))) >> (DSP32_QB);
00071
00072 #if !(DSP_OPTIMIZATION & DSP_OPTI_ACCURACY)
00073 temp = (((S64) *e) << DSP32_QB)/normalization;
00074
00075 if (temp > ((S64) 0x7FFFFFFF))
00076 temp = (S64) 0x7FFFFFFF;
00077 else if (temp < -((S64) 0x80000000))
00078 temp = -((S64) 0x80000000);
00079 #endif
00080
00081 if (!normalization)
00082 normalization = 1;
00083
00084
00085 for(i=1; i<size-1; i+=4)
00086 {
00087 #if (DSP_OPTIMIZATION & DSP_OPTI_ACCURACY)
00088 w[i] += (((((S64) *e)*((S64) x[i])))/normalization) >> (DSP_NLMS_MU - 1);
00089 w[i+1] += (((((S64) *e)*((S64) x[i+1])))/normalization) >> (DSP_NLMS_MU - 1);
00090 w[i+2] += (((((S64) *e)*((S64) x[i+2])))/normalization) >> (DSP_NLMS_MU - 1);
00091 w[i+3] += (((((S64) *e)*((S64) x[i+3])))/normalization) >> (DSP_NLMS_MU - 1);
00092 #else
00093 w[i] += ((temp*((S64) x[i])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00094 w[i+1] += ((temp*((S64) x[i+1])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00095 w[i+2] += ((temp*((S64) x[i+2])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00096 w[i+3] += ((temp*((S64) x[i+3])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00097 #endif
00098 }
00099
00100
00101 normalization -= ((((S64) x[size-1])*((S64) x[size-1]))) >> (DSP32_QB);
00102
00103
00104 for(i=size-1; i>0; i-=4)
00105 {
00106 x[i] = x[i-1];
00107 x[i-1] = x[i-2];
00108 x[i-2] = x[i-3];
00109 x[i-3] = x[i-4];
00110 }
00111 }
00112
00113 #endif
00114