Commit 97a9dfd8 authored by Khodr Saaifan's avatar Khodr Saaifan

UE: implement pdsch channel estimation for dmrs_config type2

parent 1de69e8e
......@@ -185,3 +185,57 @@ short filt8_rr1[8] = {
short filt8_rr2[8] = {
-4096,-8192,-12288,-16384,0,0,0,0};
short filt8_l2[8] = {
0,0,13107,9830,6554,3277,0,0};
short filt8_r2[8] = {
0,0,3277,6554,9830,13107,0,0};
short filt8_m2[8] = {
0,0,0,0,13107,9830,6554,3277};
short filt8_mm2[8]= {
0,0,0,0,3277,6554,9830,13107};
short filt8_rl2[8] = {
19661,22938,26214,29491,0,0,0,0};
short filt8_rm2[8] = {
-3277,-6554,-9830,-13107,0,0,0,0};//-3277,-6554,-9830,-13107
short filt8_l3[8] = {
22938,19661,0,0,13107,9830,6554,3277};
short filt8_r3[8] = {
-7537,-4260,0,0,3277,6554,9830,13107};//-6554,-3277
short filt8_rl3[8] = {
0,0,19661,22938,0,0,0,0};
short filt8_rr3[8] = {
0,0,-4260,-7537,0,0,0,0};//-3277,-6554
short filt8_dcrl1[8] = {
14895,13405,11916,10426,8937,7447,5958,4468};
short filt8_dcrh1[8] = {
2979,1489,0,0,0,0,0,0};
short filt8_dcll1[8] = {
13405,14895,0,0,0,0,0,0};
short filt8_dclh1[8] = {
1489,2979,4468,5958,7447,8937,10426,11916};
short filt8_dcrl2[8] = {
0,0,0,0,14895,13405,11916,10426};
short filt8_dcrh2[8] = {
8937,7447,5958,4468,2979,1489,0,0,};
short filt8_dcll2[8] = {
7447,8937,10426,11916,13405,14895,0,0};
short filt8_dclh2[8] = {
0,0,0,0,1489,2979,4468,5958};
......@@ -133,4 +133,40 @@ extern short filt8_rr1[8];
extern short filt8_rr2[8];
extern short filt8_rm2[8];
extern short filt8_rl2[8];
extern short filt8_l2[8];
extern short filt8_r2[8];
extern short filt8_m2[8];
extern short filt8_mm2[8];
extern short filt8_l3[8];
extern short filt8_r3[8];
extern short filt8_rr3[8];
extern short filt8_rl3[8];
extern short filt8_dcrl1[8];
extern short filt8_dcrh1[8];
extern short filt8_dcll1[8];
extern short filt8_dclh1[8];
extern short filt8_dcrl2[8];
extern short filt8_dcrh2[8];
extern short filt8_dcll2[8];
extern short filt8_dclh2[8];
#endif
\ No newline at end of file
......@@ -24,6 +24,7 @@
#include "SCHED_NR_UE/defs.h"
#include "nr_estimation.h"
#include "PHY/NR_REFSIG/refsig_defs_ue.h"
#include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
#include "filt16a_32.h"
//#define DEBUG_PDSCH
......@@ -652,8 +653,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
unsigned char aarx;
unsigned short k;
unsigned int pilot_cnt;
int16_t ch[2],*pil,*rxF,*dl_ch;
int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh;
int16_t ch_l[2],ch_r[2],ch[2],*pil,*rxF,*dl_ch;
int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh, *frl, *frr;
int ch_offset,symbol_offset;
//uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
......@@ -662,9 +663,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
int **dl_ch_estimates =ue->pdsch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
nushift = (p>>1)&1;
ue->frame_parms.nushift = nushift;
if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
ch_offset = ue->frame_parms.ofdm_symbol_size ;
else
......@@ -680,51 +678,101 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
ue->frame_parms.Ncp,Ns,k, symbol);
#endif
switch (nushift) {
case 0:
fl = filt8_l0;
fm = filt8_m0;
fr = filt8_r0;
fmm = filt8_mm0;
fml = filt8_m0;
fmr = filt8_mr0;
fdcl = filt8_dcl0;
fdcr = filt8_dcr0;
fdclh = filt8_dcl0_h;
fdcrh = filt8_dcr0_h;
break;
case 1:
fl = filt8_l1;
fm = filt8_m1;
fr = filt8_r1;
fmm = filt8_mm1;
fml = filt8_ml1;
fmr = filt8_m1;
fdcl = filt8_dcl1;
fdcr = filt8_dcr1;
fdclh = filt8_dcl1_h;
fdcrh = filt8_dcr1_h;
break;
default:
msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift);
return(-1);
break;
}
// generate pilot
// generate pilot for gNB port number 1000+p
uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12;
int config_type = ue->dmrs_DownlinkConfig.pdsch_dmrs_type;
nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000,0,nb_rb_pdsch+rb_offset);
uint8_t config_type = ue->dmrs_DownlinkConfig.pdsch_dmrs_type;
int8_t delta = get_delta(p, config_type);
nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000+p,0,nb_rb_pdsch+rb_offset);
if (config_type == pdsch_dmrs_type1){
nushift = (p>>1)&1;
ue->frame_parms.nushift = nushift;
switch (delta) {
case 0://port 0,1
fl = filt8_l0;//left interpolation Filter for DMRS config. 1
fm = filt8_m0;//left middle interpolation Filter
fr = filt8_r0;//right interpolation Filter
fmm = filt8_mm0;;//middle middle interpolation Filter
fml = filt8_m0;//left middle interpolation Filter
fmr = filt8_mr0;//middle right interpolation Filter
fdcl = filt8_dcl0;//left DC interpolation Filter (even RB)
fdcr = filt8_dcr0;//right DC interpolation Filter (even RB)
fdclh = filt8_dcl0_h;//left DC interpolation Filter (odd RB)
fdcrh = filt8_dcr0_h;//right DC interpolation Filter (odd RB)
frl = NULL;
frr = NULL;
break;
case 1://port2,3
fl = filt8_l1;
fm = filt8_m1;
fr = filt8_r1;
fmm = filt8_mm1;
fml = filt8_ml1;
fmr = filt8_m1;
fdcl = filt8_dcl1;
fdcr = filt8_dcr1;
fdclh = filt8_dcl1_h;
fdcrh = filt8_dcr1_h;
frl = NULL;
frr = NULL;
break;
default:
msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift);
return(-1);
break;
}
} else {//pdsch_dmrs_type2
nushift = delta;
ue->frame_parms.nushift = nushift>>1;//SFN:fixMe IT MUST BE WITHOUT >>1
switch (delta) {
case 0://port 0,1
fl = filt8_l2;//left interpolation Filter should be fml
fr = filt8_r2;//right interpolation Filter should be fmr
fm = filt8_l2;
fmm = filt8_r2;
fml = filt8_ml2;
fmr = filt8_mr2;
frl = filt8_rl2;
frr = filt8_rm2;
fdcl = filt8_dcl1;
fdcr = filt8_dcr1;
fdclh = filt8_dcl1_h;
fdcrh = filt8_dcr1_h;
break;
case 2://port2,3
fl = filt8_l3;
fm = filt8_m2;
fr = filt8_r3;
fmm = filt8_mm2;
fml = filt8_l2;
fmr = filt8_r2;
frl = filt8_rl3;
frr = filt8_rr3;
fdcl = NULL;
fdcr = NULL;
fdclh = NULL;
fdcrh = NULL;
break;
default:
msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift);
return(-1);
break;
}
}
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[rb_offset*((config_type==pdsch_dmrs_type1) ? 6:4)];
k = k % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
re_offset = k;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+re_offset+nushift)];
dl_ch = (int16_t *)&dl_ch_estimates[p*ue->frame_parms.nb_antennas_rx+aarx][ch_offset];
memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha
......@@ -737,7 +785,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
printf("rxF addr %p p %d\n", rxF,p);
printf("dl_ch addr %p nushift %d\n",dl_ch,nushift);
#endif
//if ((ue->frame_parms.N_RB_DL&1)==0) {
if (config_type == pdsch_dmrs_type1) {
// Treat first 2 pilots specially (left edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
......@@ -867,7 +916,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
ch,
dl_ch,
8);
//}
// check if PRB crosses DC and improve estimates around DC
if ((bwp_start_subcarrier < ue->frame_parms.ofdm_symbol_size) && (bwp_start_subcarrier+nb_rb_pdsch*12 >= ue->frame_parms.ofdm_symbol_size)) {
......@@ -920,20 +968,229 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
dl_ch,
8);
}
}
} else { //pdsch_dmrs_type2 |dmrs_r,dmrs_l,0,0,0,0,dmrs_r,dmrs_l,0,0,0,0|
// Treat first 4 pilots specially (left edge)
ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pdsch*12/8); idxP++) {
for(uint8_t idxI=0; idxI<16; idxI+=2) {
printf("%d\t%d\t",dl_ch[idxP*16+idxI],dl_ch[idxP*16+idxI+1]);
}
printf("%d\n",idxP);
printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch_l[0],ch_l[1],pil[0],pil[1]);
#endif
pil+=2;
re_offset = (re_offset+1) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
ch[0] = (ch_l[0]+ch_r[0])>>1;
ch[1] = (ch_l[1]+ch_r[1])>>1;
dl_ch[(0+2*nushift)] = ch[0];
dl_ch[(1+2*nushift)] = ch[1];
dl_ch[2+2*nushift] = ch[0];
dl_ch[3+2*nushift] = ch[1];
multadd_real_vector_complex_scalar(fl,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+5) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
pil+=2;
re_offset = (re_offset+1) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
ch[0] = (ch_l[0]+ch_r[0])>>1;
ch[1] = (ch_l[1]+ch_r[1])>>1;
multadd_real_vector_complex_scalar(fr,
ch,
dl_ch,
8);
dl_ch+=12;
dl_ch[0+2*nushift] = ch[0];
dl_ch[1+2*nushift] = ch[1];
dl_ch[2+2*nushift] = ch[0];
dl_ch[3+2*nushift] = ch[1];
dl_ch+=4;
for (pilot_cnt=4; pilot_cnt<4*nb_rb_pdsch; pilot_cnt+=4) {
multadd_real_vector_complex_scalar(fml,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+5) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch_l[0],ch_l[1],pil[0],pil[1]);
#endif
pil+=2;
re_offset = (re_offset+1) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
ch[0] = (ch_l[0]+ch_r[0])>>1;
ch[1] = (ch_l[1]+ch_r[1])>>1;
#ifdef DEBUG_PDSCH
printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch_r[0],ch_r[1],pil[0],pil[1]);
#endif
multadd_real_vector_complex_scalar(fmr,
ch,
dl_ch,
8);
dl_ch+=8;
dl_ch[0+2*nushift] = ch[0];
dl_ch[1+2*nushift] = ch[1];
dl_ch[2+2*nushift] = ch[0];
dl_ch[3+2*nushift] = ch[1];
multadd_real_vector_complex_scalar(fm,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+5) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_l[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_l[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
pil+=2;
re_offset = (re_offset+1) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch_r[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch_r[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch_r[0],ch_r[1],pil[0],pil[1]);
#endif
ch[0] = (ch_l[0]+ch_r[0])>>1;
ch[1] = (ch_l[1]+ch_r[1])>>1;
multadd_real_vector_complex_scalar(fmm,
ch,
dl_ch,
8);
dl_ch+=12;
dl_ch[0+2*nushift] = ch[0];
dl_ch[1+2*nushift] = ch[1];
dl_ch[2+2*nushift] = ch[0];
dl_ch[3+2*nushift] = ch[1];
dl_ch+=4;
}
// Treat last 2 pilots specially (right edge)
// dl_ch-2+nushift<<1
multadd_real_vector_complex_scalar(frl,
dl_ch-2+2*nushift,
dl_ch,
8);
multadd_real_vector_complex_scalar(frr,
dl_ch-14+2*nushift,/*14*/
dl_ch,
8);
// check if PRB crosses DC and improve estimates around DC
if ((bwp_start_subcarrier < ue->frame_parms.ofdm_symbol_size) && (bwp_start_subcarrier+nb_rb_pdsch*12 >= ue->frame_parms.ofdm_symbol_size) && (p<2)) {
dl_ch = (int16_t *)&dl_ch_estimates[p*ue->frame_parms.nb_antennas_rx+aarx][ch_offset];
uint16_t idxDC = 2*(ue->frame_parms.ofdm_symbol_size - bwp_start_subcarrier);
dl_ch += (idxDC-8);
dl_ch = memset(dl_ch, 0, sizeof(int16_t)*20);
dl_ch -= 2;
ch_r[0] = dl_ch[0];
ch_r[1]= dl_ch[1] ;
dl_ch += 22;
ch_l[0] = dl_ch[0];
ch_l[1]= dl_ch[1] ;
// for proper allignment of SIMD vectors
if((ue->frame_parms.N_RB_DL&1)==0) {
dl_ch -= 20;
//Interpolate fdcrl1 with ch_r
multadd_real_vector_complex_scalar(filt8_dcrl1,
ch_r,
dl_ch,
8);
//Interpolate fdclh1 with ch_l
multadd_real_vector_complex_scalar(filt8_dclh1,
ch_l,
dl_ch,
8);
dl_ch += 16;
//Interpolate fdcrh1 with ch_r
multadd_real_vector_complex_scalar(filt8_dcrh1,
ch_r,
dl_ch,
8);
//Interpolate fdcll1 with ch_l
multadd_real_vector_complex_scalar(filt8_dcll1,
ch_l,
dl_ch,
8);
} else {
dl_ch -= 28;
//Interpolate fdcrl1 with ch_r
multadd_real_vector_complex_scalar(filt8_dcrl2,
ch_r,
dl_ch,
8);
//Interpolate fdclh1 with ch_l
multadd_real_vector_complex_scalar(filt8_dclh2,
ch_l,
dl_ch,
8);
dl_ch += 16;
//Interpolate fdcrh1 with ch_r
multadd_real_vector_complex_scalar(filt8_dcrh2,
ch_r,
dl_ch,
8);
//Interpolate fdcll1 with ch_l
multadd_real_vector_complex_scalar(filt8_dcll2,
ch_l,
dl_ch,
8);
}
}
}
#endif
}
#ifdef DEBUG_PDSCH
dl_ch = (int16_t *)&dl_ch_estimates[p*ue->frame_parms.nb_antennas_rx+aarx][ch_offset];
for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pdsch*12/8); idxP++) {
for(uint8_t idxI=0; idxI<16; idxI+=2) {
printf("%d\t%d\t",dl_ch[idxP*16+idxI],dl_ch[idxP*16+idxI+1]);
}
printf("%d\n",idxP);
}
#endif
}
return(0);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment