📄 filtering.c
字号:
/* Alessandro Nordio 01/02/04 Linus Gasser 02/10/24*/#include "spc.h"#include "filtering.h"#include "midamble.h"#include "debugging.h"#define DBG_LVL 4/** * @short build matched filter */int matched_filter_build(midamble_t *m, estimation_vars_t *est, unsigned int midamble_index ) { // pointer to the channel estimates mmx_t *channel; // pointers to the real and imaginary parts of the matched filter. short *yr,*yi; // counters int i; unsigned short shift; channel = &est->estimates[ (m->max_channels-midamble_index-1) * m->shift * DAQ_SAMPLES_PER_CHIP]; shift = 0; yr = est->matched_filter_Re; yi = est->matched_filter_Im; for( i=0; i<est->estimation_length; i++ ) { *yr++ = channel[i].w[0]; *yi++ = channel[i].w[1]; } emms(); return(0);}/** * @short matched filtering */int matched_filtering( mmx_t *x, mmx_t *h1, mmx_t *h2, SYMBOL_COMPLEX *y, unsigned int length, unsigned int downsample_factor, unsigned int n_y ) { int n,l; // loop counter indices mmx_t *h1tmp,*h2tmp,*xtmp, tmp, inv_complex = {0xffffffff00000000ULL}; downsample_factor = downsample_factor>>2; // downsample in chips length = length>>2; for( n=0; n<n_y; n++ ) { pxor_r2r(mm6,mm6); // result R pxor_r2r(mm7,mm7); // result I pxor_r2r(mm3,mm3); // clear mm3 for(l=0;l<length;l+=4) { xtmp = &x[l]; h1tmp = &h1[l]; h2tmp = &h2[l]; movq_m2r(xtmp[0],mm0); pmaddwd_r2r(mm3,mm4); movq_m2r(h2tmp[0],mm1); pmaddwd_r2r(mm3,mm5); movq_m2r(h1tmp[0],mm2); paddd_r2r(mm4,mm6); paddd_r2r(mm5,mm7); movq_m2r(xtmp[1],mm3); pmaddwd_r2r(mm0,mm1); movq_m2r(h2tmp[1],mm4); pmaddwd_r2r(mm0,mm2); movq_m2r(h1tmp[1],mm5); paddd_r2r(mm1,mm6); paddd_r2r(mm2,mm7); movq_m2r(xtmp[2],mm0); pmaddwd_r2r(mm3,mm4); movq_m2r(h2tmp[2],mm1); pmaddwd_r2r(mm3,mm5); movq_m2r(h1tmp[2],mm2); paddd_r2r(mm4,mm6); paddd_r2r(mm5,mm7); movq_m2r(xtmp[3],mm3); pmaddwd_r2r(mm0,mm1); movq_m2r(h2tmp[3],mm4); pmaddwd_r2r(mm0,mm2); movq_m2r(h1tmp[3],mm5); paddd_r2r(mm1,mm6); paddd_r2r(mm2,mm7); } pmaddwd_r2r(mm3,mm4); pmaddwd_r2r(mm3,mm5); paddd_r2r(mm4,mm6); paddd_r2r(mm5,mm7); // make a copy of mm7 movq_r2r(mm7,mm5); punpckhdq_r2r(mm6,mm7); punpckldq_r2r(mm6,mm5); // add t10 t11 to mm6 paddd_r2r(mm5,mm7); // Aww, ugly. Somewhere a negative sign sneeks in for the complex-part. // I think it's in the definition of the midamble. But... pxor_m2r( inv_complex, mm7 ); movq_r2m(mm7, tmp); y->real = tmp.d[0] / ( 1 << 12 ); y->imag = tmp.d[1] / ( 1 << 12 ); y++; x += downsample_factor; } emms(); return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -