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
00047 #include "dsp.h"
00048
00049 #if defined(FORCE_ALL_GENERICS) || \
00050 defined(FORCE_GENERIC_FILT32_NLMS) || \
00051 !defined(TARGET_SPECIFIC_FILT32_NLMS)
00052
00053 #include "filt_nlms.h"
00054
00055 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)
00056 {
00057 int i;
00058 static S64 normalization = 0;
00059 S64 temp;
00060
00061 x[0] = new_x;
00062
00063 temp = 0;
00064
00065 for(i=0; i<size; i+=4)
00066 {
00067 temp += (((S64) w[i])*((S64) x[i]));
00068 temp += (((S64) w[i+1])*((S64) x[i+1]));
00069 temp += (((S64) w[i+2])*((S64) x[i+2]));
00070 temp += (((S64) w[i+3])*((S64) x[i+3]));
00071 }
00072 *y = temp >> (DSP32_QB);
00073
00074
00075 *e = d - *y;
00076
00077
00078 normalization += ((((S64) new_x)*((S64) new_x))) >> (DSP32_QB);
00079
00080 #if !(DSP_OPTIMIZATION & DSP_OPTI_ACCURACY)
00081 temp = (((S64) *e) << DSP32_QB)/normalization;
00082
00083 if (temp > ((S64) 0x7FFFFFFF))
00084 temp = (S64) 0x7FFFFFFF;
00085 else if (temp < -((S64) 0x80000000))
00086 temp = -((S64) 0x80000000);
00087 #endif
00088
00089 if (!normalization)
00090 normalization = 1;
00091
00092
00093 for(i=0; i<size; i+=4)
00094 {
00095 #if (DSP_OPTIMIZATION & DSP_OPTI_ACCURACY)
00096 w[i] += (((((S64) *e)*((S64) x[i])))/normalization) >> (DSP_NLMS_MU - 1);
00097 w[i+1] += (((((S64) *e)*((S64) x[i+1])))/normalization) >> (DSP_NLMS_MU - 1);
00098 w[i+2] += (((((S64) *e)*((S64) x[i+2])))/normalization) >> (DSP_NLMS_MU - 1);
00099 w[i+3] += (((((S64) *e)*((S64) x[i+3])))/normalization) >> (DSP_NLMS_MU - 1);
00100 #else
00101 w[i] += ((temp*((S64) x[i])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00102 w[i+1] += ((temp*((S64) x[i+1])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00103 w[i+2] += ((temp*((S64) x[i+2])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00104 w[i+3] += ((temp*((S64) x[i+3])) >> (DSP_NLMS_MU - 1 + DSP32_QB));
00105 #endif
00106 }
00107
00108
00109 normalization -= ((((S64) x[size-1])*((S64) x[size-1]))) >> (DSP32_QB);
00110
00111
00112 for(i=size-1; i>0; i-=4)
00113 {
00114 x[i] = x[i-1];
00115 x[i-1] = x[i-2];
00116 x[i-2] = x[i-3];
00117 x[i-3] = x[i-4];
00118 }
00119 }
00120
00121 #endif