nr_dl_channel_estimation.c 44.6 KB
Newer Older
Hongzhi Wang's avatar
Hongzhi Wang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

Raymond Knopp's avatar
Raymond Knopp committed
22

Hongzhi Wang's avatar
Hongzhi Wang committed
23
#include <string.h>
Hongzhi Wang's avatar
Hongzhi Wang committed
24
#include "SCHED_NR_UE/defs.h"
25
#include "nr_estimation.h"
Raymond Knopp's avatar
Raymond Knopp committed
26
#include "PHY/NR_REFSIG/refsig_defs_ue.h"
27
#include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
Hongzhi Wang's avatar
Hongzhi Wang committed
28
#include "filt16a_32.h"
29

hongzhi wang's avatar
hongzhi wang committed
30
//#define DEBUG_PDSCH
Guy De Souza's avatar
Guy De Souza committed
31
//#define DEBUG_PDCCH
Hongzhi Wang's avatar
Hongzhi Wang committed
32

Raymond Knopp's avatar
Raymond Knopp committed
33

34
int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
yilmazt's avatar
yilmazt committed
35 36 37 38 39
                             uint8_t eNB_offset,
                             unsigned char Ns,
                             unsigned char symbol,
                             int dmrss,
                             NR_UE_SSB *current_ssb)
40 41 42 43 44 45 46
{
  int pilot[200] __attribute__((aligned(16)));
  unsigned char aarx;
  unsigned short k;
  unsigned int pilot_cnt;
  int16_t ch[2],*pil,*rxF;
  int symbol_offset;
47

48 49 50 51

  uint8_t nushift;
  uint8_t ssb_index=current_ssb->i_ssb;
  uint8_t n_hf=current_ssb->n_hf;
52
  int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
53 54 55 56 57 58

  nushift =  ue->frame_parms.Nid_cell%4;
  ue->frame_parms.nushift = nushift;
  unsigned int  ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
  if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;

59 60 61
  AssertFatal(dmrss >= 0 && dmrss < 3,
	      "symbol %d is illegal for PBCH DM-RS \n",
	      dmrss);
62 63 64 65 66 67 68

  symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;


  k = nushift;

#ifdef DEBUG_CH
69
  printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ue->frame_parms.ofdm_symbol_size,
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
         ue->frame_parms.Ncp,Ns,k, symbol);
#endif

  // generate pilot
  nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);

  int re_offset = ssb_offset;
  for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {

    pil   = (int16_t *)&pilot[0];
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

#ifdef DEBUG_CH
    printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
    printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
    printf("rxF addr %p\n", rxF);
#endif
    //if ((ue->frame_parms.N_RB_DL&1)==0) {

    // Treat first 2 pilots specially (left edge)
    ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
    ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

    current_ssb->c_re +=ch[0];
    current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
    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[0],ch[1],pil[0],pil[1]);
#endif

    pil+=2;
102
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];


    ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
    ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

    current_ssb->c_re +=ch[0];
    current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
    printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif

    pil+=2;
117
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
118 119 120 121 122 123 124 125 126 127
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

    current_ssb->c_re +=ch[0];
    current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
    printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif

    pil+=2;
128
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
129 130 131 132 133 134 135 136 137 138
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

    for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) {

      //	if (pilot_cnt == 30)
      //	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];

      // in 2nd symbol, skip middle  REs (48 with DMRS,  144 for SSS, and another 48 with DMRS) 
      if (dmrss == 1 && pilot_cnt == 12) {
	pilot_cnt=48;
139
	re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size;
140 141 142 143 144 145 146 147 148
	rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
      }
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
      
      current_ssb->c_re +=ch[0];
      current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
149
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
150 151 152
#endif

      pil+=2;
153
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
154 155 156 157 158 159 160 161 162 163
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
        
  
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

      current_ssb->c_re +=ch[0];
      current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
164
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
165 166
#endif
      pil+=2;
167
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
168 169 170 171 172 173 174 175 176 177
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
        

      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

      current_ssb->c_re +=ch[0];
      current_ssb->c_im +=ch[1];

#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
178
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
179 180 181
#endif

      pil+=2;
182
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
183 184 185 186 187 188 189 190 191 192 193
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

    }


    //}

  }
  return(0);
}

Francesco Mani's avatar
Francesco Mani committed
194

Hongzhi Wang's avatar
Hongzhi Wang committed
195
int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
yilmazt's avatar
yilmazt committed
196 197 198 199 200 201
                               uint8_t eNB_offset,
                               unsigned char Ns,
                               unsigned char symbol,
                               int dmrss,
                               uint8_t ssb_index,
                               uint8_t n_hf)
Hongzhi Wang's avatar
Hongzhi Wang committed
202
{
Raymond Knopp's avatar
Raymond Knopp committed
203
  int pilot[200] __attribute__((aligned(16)));
Hongzhi Wang's avatar
Hongzhi Wang committed
204
  unsigned char aarx,p;
Hongzhi Wang's avatar
Hongzhi Wang committed
205
  unsigned short k;
hongzhi wang's avatar
hongzhi wang committed
206
  unsigned int pilot_cnt;
hongzhi wang's avatar
hongzhi wang committed
207
  int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr;
Hongzhi Wang's avatar
Hongzhi Wang committed
208
  int ch_offset,symbol_offset;
laurent's avatar
laurent committed
209
  //int slot_pbch;
Hongzhi Wang's avatar
Hongzhi Wang committed
210

hongzhi wang's avatar
hongzhi wang committed
211
  //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
Hongzhi Wang's avatar
Hongzhi Wang committed
212

Francesco Mani's avatar
Francesco Mani committed
213
  uint8_t nushift;
214
  int **dl_ch_estimates  =ue->pbch_vars[eNB_offset]->dl_ch_estimates;
215
  int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
Hongzhi Wang's avatar
Hongzhi Wang committed
216

hongzhi wang's avatar
hongzhi wang committed
217
  nushift =  ue->frame_parms.Nid_cell%4;
hongzhi wang's avatar
hongzhi wang committed
218
  ue->frame_parms.nushift = nushift;
Raymond Knopp's avatar
Raymond Knopp committed
219 220 221
  unsigned int  ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
  if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;

Hongzhi Wang's avatar
Hongzhi Wang committed
222 223 224 225 226
  if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
    ch_offset     = ue->frame_parms.ofdm_symbol_size ;
  else
    ch_offset     = ue->frame_parms.ofdm_symbol_size*symbol;

227 228 229
  AssertFatal(dmrss >= 0 && dmrss < 3,
	      "symbol %d is illegal for PBCH DM-RS \n",
	      dmrss);
Raymond Knopp's avatar
Raymond Knopp committed
230

Hongzhi Wang's avatar
Hongzhi Wang committed
231 232
  symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;

Raymond Knopp's avatar
Raymond Knopp committed
233

Hongzhi Wang's avatar
Hongzhi Wang committed
234 235 236
  k = nushift;

#ifdef DEBUG_CH
Francesco Mani's avatar
Francesco Mani committed
237
  printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size,
238
         ue->frame_parms.Ncp,Ns,k, symbol);
Hongzhi Wang's avatar
Hongzhi Wang committed
239 240 241 242
#endif

  switch (k) {
  case 0:
Raymond Knopp's avatar
Raymond Knopp committed
243 244 245 246
    fl = filt16a_l0;
    fm = filt16a_m0;
    fr = filt16a_r0;
    break;
Hongzhi Wang's avatar
Hongzhi Wang committed
247 248

  case 1:
Raymond Knopp's avatar
Raymond Knopp committed
249 250 251 252
    fl = filt16a_l1;
    fm = filt16a_m1;
    fr = filt16a_r1;
    break;
Hongzhi Wang's avatar
Hongzhi Wang committed
253 254

  case 2:
Raymond Knopp's avatar
Raymond Knopp committed
255 256 257 258
    fl = filt16a_l2;
    fm = filt16a_m2;
    fr = filt16a_r2;
    break;
Hongzhi Wang's avatar
Hongzhi Wang committed
259 260

  case 3:
Raymond Knopp's avatar
Raymond Knopp committed
261 262 263 264
    fl = filt16a_l3;
    fm = filt16a_m3;
    fr = filt16a_r3;
    break;
Hongzhi Wang's avatar
Hongzhi Wang committed
265 266 267 268 269 270 271 272

  default:
    msg("pbch_channel_estimation: k=%d -> ERROR\n",k);
    return(-1);
    break;
  }

  // generate pilot
Raymond Knopp's avatar
Raymond Knopp committed
273
  nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);
Hongzhi Wang's avatar
Hongzhi Wang committed
274

Raymond Knopp's avatar
Raymond Knopp committed
275
  int re_offset = ssb_offset;
Hongzhi Wang's avatar
Hongzhi Wang committed
276 277
  for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {

Raymond Knopp's avatar
Raymond Knopp committed
278 279 280
    pil   = (int16_t *)&pilot[0];
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
    dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
Francesco Mani's avatar
Francesco Mani committed
281

Hongzhi Wang's avatar
Hongzhi Wang committed
282 283 284 285 286
    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
      multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         1,ue->frame_parms.ofdm_symbol_size);
287
#ifdef DEBUG_CH
Raymond Knopp's avatar
Raymond Knopp committed
288
    printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
Hongzhi Wang's avatar
Hongzhi Wang committed
289
    printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
hongzhi wang's avatar
hongzhi wang committed
290 291
    printf("rxF addr %p\n", rxF);
    printf("dl_ch addr %p\n",dl_ch);
292
#endif
hongzhi wang's avatar
hongzhi wang committed
293
    //if ((ue->frame_parms.N_RB_DL&1)==0) {
Hongzhi Wang's avatar
Hongzhi Wang committed
294

Raymond Knopp's avatar
Raymond Knopp committed
295 296 297
    // Treat first 2 pilots specially (left edge)
    ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
    ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
Francesco Mani's avatar
Francesco Mani committed
298

Raymond Knopp's avatar
Raymond Knopp committed
299 300 301 302 303 304 305 306 307
#ifdef DEBUG_CH
    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[0],ch[1],pil[0],pil[1]);
#endif
    multadd_real_vector_complex_scalar(fl,
				       ch,
				       dl_ch,
				       16);
    pil+=2;
308
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
309 310 311 312 313 314 315
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

    //for (int i= 0; i<8; i++)
    //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));

    ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
    ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
Francesco Mani's avatar
Francesco Mani committed
316 317


Raymond Knopp's avatar
Raymond Knopp committed
318 319 320 321 322 323 324 325
#ifdef DEBUG_CH
    printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif
    multadd_real_vector_complex_scalar(fm,
				       ch,
				       dl_ch,
				       16);
    pil+=2;
326
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
327 328
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];

329 330 331
    ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
    ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

Raymond Knopp's avatar
Raymond Knopp committed
332 333 334 335 336 337 338 339 340
#ifdef DEBUG_CH
    printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif

    multadd_real_vector_complex_scalar(fr,
				       ch,
				       dl_ch,
				       16);
    pil+=2;
341
    re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
342 343 344 345 346 347 348 349 350 351 352
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
    dl_ch+=24;

    for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) {

      //	if (pilot_cnt == 30)
      //	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];

      // in 2nd symbol, skip middle  REs (48 with DMRS,  144 for SSS, and another 48 with DMRS) 
      if (dmrss == 1 && pilot_cnt == 12) {
	pilot_cnt=48;
353
	re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
354 355 356
	rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
	dl_ch += 288;
      }
Hongzhi Wang's avatar
Hongzhi Wang committed
357 358
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
Francesco Mani's avatar
Francesco Mani committed
359

360
#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
361
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
362
#endif
Hongzhi Wang's avatar
Hongzhi Wang committed
363
      multadd_real_vector_complex_scalar(fl,
Raymond Knopp's avatar
Raymond Knopp committed
364 365 366 367
					 ch,
					 dl_ch,
					 16);

hongzhi wang's avatar
hongzhi wang committed
368
      //for (int i= 0; i<8; i++)
Raymond Knopp's avatar
Raymond Knopp committed
369
      //            printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));
Hongzhi Wang's avatar
Hongzhi Wang committed
370

Raymond Knopp's avatar
Raymond Knopp committed
371
      pil+=2;
372
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
373 374 375
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
        
  
Hongzhi Wang's avatar
Hongzhi Wang committed
376 377
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
Francesco Mani's avatar
Francesco Mani committed
378

Hongzhi Wang's avatar
Hongzhi Wang committed
379
#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
380
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
Hongzhi Wang's avatar
Hongzhi Wang committed
381 382
#endif
      multadd_real_vector_complex_scalar(fm,
Raymond Knopp's avatar
Raymond Knopp committed
383 384 385
					 ch,
					 dl_ch,
					 16);
Hongzhi Wang's avatar
Hongzhi Wang committed
386
      pil+=2;
387
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
388 389
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
        
Hongzhi Wang's avatar
Hongzhi Wang committed
390 391 392 393

      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

hongzhi wang's avatar
hongzhi wang committed
394
#ifdef DEBUG_CH
yilmazt's avatar
yilmazt committed
395
      printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
hongzhi wang's avatar
hongzhi wang committed
396
#endif
Hongzhi Wang's avatar
Hongzhi Wang committed
397 398

      multadd_real_vector_complex_scalar(fr,
Raymond Knopp's avatar
Raymond Knopp committed
399 400 401
					 ch,
					 dl_ch,
					 16);
Hongzhi Wang's avatar
Hongzhi Wang committed
402
      pil+=2;
403
      re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
Raymond Knopp's avatar
Raymond Knopp committed
404
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
405
      dl_ch+=24;
Hongzhi Wang's avatar
Hongzhi Wang committed
406

Raymond Knopp's avatar
Raymond Knopp committed
407
    }
Hongzhi Wang's avatar
Hongzhi Wang committed
408

frtabu's avatar
frtabu committed
409
    idft_size_idx_t idftsizeidx;
Hongzhi Wang's avatar
Hongzhi Wang committed
410 411 412

    switch (ue->frame_parms.ofdm_symbol_size) {
    case 128:
frtabu's avatar
frtabu committed
413
      idftsizeidx = IDFT_128;
Hongzhi Wang's avatar
Hongzhi Wang committed
414 415 416
      break;

    case 256:
frtabu's avatar
frtabu committed
417
      idftsizeidx = IDFT_256;
Hongzhi Wang's avatar
Hongzhi Wang committed
418 419 420
      break;

    case 512:
frtabu's avatar
frtabu committed
421
      idftsizeidx = IDFT_512;
Hongzhi Wang's avatar
Hongzhi Wang committed
422 423 424
      break;

    case 1024:
frtabu's avatar
frtabu committed
425
      idftsizeidx = IDFT_1024;
Hongzhi Wang's avatar
Hongzhi Wang committed
426 427 428
      break;

    case 1536:
frtabu's avatar
frtabu committed
429
      idftsizeidx = IDFT_1536;
Hongzhi Wang's avatar
Hongzhi Wang committed
430 431 432
      break;

    case 2048:
frtabu's avatar
frtabu committed
433
      idftsizeidx = IDFT_2048;
Hongzhi Wang's avatar
Hongzhi Wang committed
434 435 436
      break;

    case 3072:
frtabu's avatar
frtabu committed
437
      idftsizeidx = IDFT_3072;
Hongzhi Wang's avatar
Hongzhi Wang committed
438 439 440
      break;

    case 4096:
frtabu's avatar
frtabu committed
441
      idftsizeidx = IDFT_4096;
Hongzhi Wang's avatar
Hongzhi Wang committed
442 443 444 445 446 447 448
      break;

    default:
      printf("unsupported ofdm symbol size \n");
      assert(0);
    }

449
    if( dmrss == 2) // update time statistics for last PBCH symbol
Hongzhi Wang's avatar
Hongzhi Wang committed
450 451 452
    {
        // do ifft of channel estimate
        for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++)
453
            for (p=0; p<ue->frame_parms.nb_antenna_ports_gNB; p++) {
Hongzhi Wang's avatar
Hongzhi Wang committed
454 455
                if (ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx])
                {
Hongzhi Wang's avatar
Hongzhi Wang committed
456
  		LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, ue->current_thread_id[Ns], symbol, ch_offset);
frtabu's avatar
frtabu committed
457 458
  		idft(idftsizeidx,
  			 (int16_t*) &ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx][ch_offset],
Hongzhi Wang's avatar
Hongzhi Wang committed
459 460 461 462
  		     (int16_t*) ue->pbch_vars[eNB_offset]->dl_ch_estimates_time[(p<<1)+aarx],1);
                }
            }
    }
Hongzhi Wang's avatar
Hongzhi Wang committed
463

hongzhi wang's avatar
hongzhi wang committed
464
    //}
Hongzhi Wang's avatar
Hongzhi Wang committed
465 466 467 468 469

  }
  return(0);
}

470
int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
yilmazt's avatar
yilmazt committed
471 472 473 474 475
                                uint8_t eNB_offset,
                                unsigned char Ns,
                                unsigned char symbol,
                                unsigned short coreset_start_subcarrier,
                                unsigned short nb_rb_coreset)
476
{
477

Hongzhi Wang's avatar
Hongzhi Wang committed
478
  unsigned char aarx;
479 480 481 482 483 484 485
  unsigned short k;
  unsigned int pilot_cnt;
  int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr;
  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];

486
  int **dl_ch_estimates  =ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
487
  int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
488 489 490 491 492 493 494 495 496


  if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
    ch_offset     = ue->frame_parms.ofdm_symbol_size ;
  else
    ch_offset     = ue->frame_parms.ofdm_symbol_size*symbol;

  symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;

497
  k = coreset_start_subcarrier;
498

hongzhi wang's avatar
hongzhi wang committed
499
#ifdef DEBUG_PDCCH
500 501
  printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size,
         ue->frame_parms.Ncp,Ns,k, symbol);
502 503 504 505 506 507
#endif

  fl = filt16a_l1;
  fm = filt16a_m1;
  fr = filt16a_r1;

508

509 510
  // generate pilot
  int pilot[nb_rb_coreset * 3] __attribute__((aligned(16))); 
Florian Kaltenberger's avatar
Florian Kaltenberger committed
511
  nr_pdcch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdcch[eNB_offset][Ns][symbol], &pilot[0],2000,nb_rb_coreset);
512 513 514 515


  for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {

Raymond Knopp's avatar
Raymond Knopp committed
516
    pil   = (int16_t *)&pilot[0];
517
    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];
Raymond Knopp's avatar
Raymond Knopp committed
518
    dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
519 520 521 522 523 524

    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
      multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         1,ue->frame_parms.ofdm_symbol_size);
hongzhi wang's avatar
hongzhi wang committed
525
#ifdef DEBUG_PDCCH
Raymond Knopp's avatar
Raymond Knopp committed
526
    printf("pdcch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
527 528 529 530
    printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
    printf("rxF addr %p\n", rxF);

    printf("dl_ch addr %p\n",dl_ch);
531
#endif
532
    //    if ((ue->frame_parms.N_RB_DL&1)==0) {
533 534 535
      // Treat first 2 pilots specially (left edge)
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
536
#ifdef DEBUG_PDCCH
537 538 539 540 541 542 543 544 545 546 547 548 549 550
      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[0],ch[1],pil[0],pil[1]);
#endif
      multadd_real_vector_complex_scalar(fl,
                                         ch,
                                         dl_ch,
                                         16);
      pil+=2;
      rxF+=8;
      //for (int i= 0; i<8; i++)
      //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));

      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
551
#ifdef DEBUG_PDCCH
552 553 554 555 556 557 558 559 560 561 562 563
      printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif
      multadd_real_vector_complex_scalar(fm,
                                         ch,
                                         dl_ch,
                                         16);
      pil+=2;
      rxF+=8;

      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

hongzhi wang's avatar
hongzhi wang committed
564
#ifdef DEBUG_PDCCH
565 566 567 568 569 570 571
      printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif

      multadd_real_vector_complex_scalar(fr,
                                         ch,
                                         dl_ch,
                                         16);
hongzhi wang's avatar
hongzhi wang committed
572
                                         
hongzhi wang's avatar
hongzhi wang committed
573
#ifdef DEBUG_PDCCH       
hongzhi wang's avatar
hongzhi wang committed
574
      for (int m =0; m<12; m++)
Raymond Knopp's avatar
Raymond Knopp committed
575
	printf("data :  dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]);
hongzhi wang's avatar
hongzhi wang committed
576
#endif      
577 578 579
      pil+=2;
      rxF+=8;
      dl_ch+=24;
580
      k+=12;
hongzhi wang's avatar
hongzhi wang committed
581 582
      
      
583

584
      for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt+=3) {
585

586
        if (k >= ue->frame_parms.ofdm_symbol_size){
Raymond Knopp's avatar
Raymond Knopp committed
587
	  k-=ue->frame_parms.ofdm_symbol_size;
588
	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];}
589 590 591

        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
592
#ifdef DEBUG_PDCCH
yilmazt's avatar
yilmazt committed
593
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
594 595 596 597 598 599 600 601 602 603 604 605
#endif
        multadd_real_vector_complex_scalar(fl,
                                           ch,
                                           dl_ch,
                                           16);

        //for (int i= 0; i<8; i++)
        //            printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));

        pil+=2;
        rxF+=8;

Hongzhi Wang's avatar
Hongzhi Wang committed
606 607
        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
608
#ifdef DEBUG_PDCCH
yilmazt's avatar
yilmazt committed
609
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
Hongzhi Wang's avatar
Hongzhi Wang committed
610 611 612 613 614 615 616 617 618 619 620
#endif
        multadd_real_vector_complex_scalar(fm,
                                           ch,
                                           dl_ch,
                                           16);
        pil+=2;
        rxF+=8;

        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);

hongzhi wang's avatar
hongzhi wang committed
621
#ifdef DEBUG_PDCCH
622
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
hongzhi wang's avatar
hongzhi wang committed
623
#endif
Hongzhi Wang's avatar
Hongzhi Wang committed
624 625 626 627 628 629 630

        multadd_real_vector_complex_scalar(fr,
                                           ch,
                                           dl_ch,
                                           16);
        pil+=2;
        rxF+=8;
hongzhi wang's avatar
hongzhi wang committed
631
        dl_ch+=24;
632
        k+=12;
Hongzhi Wang's avatar
Hongzhi Wang committed
633 634 635 636

      }


637
      //}
Hongzhi Wang's avatar
Hongzhi Wang committed
638 639 640 641 642 643

  }

  return(0);
}

644
int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
yilmazt's avatar
yilmazt committed
645 646 647 648 649 650
                                uint8_t eNB_offset,
                                unsigned char Ns,
                                unsigned short p,
                                unsigned char symbol,
                                unsigned short bwp_start_subcarrier,
                                unsigned short nb_rb_pdsch)
651
{
652
  int pilot[3280] __attribute__((aligned(16)));
653 654 655
  unsigned char aarx;
  unsigned short k;
  unsigned int pilot_cnt;
656 657
  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;
658 659 660 661 662
  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];

  uint8_t nushift;
663
  int **dl_ch_estimates  =ue->pdsch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
664
  int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
665 666 667 668 669 670 671 672 673

  if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
    ch_offset     = ue->frame_parms.ofdm_symbol_size ;
  else
    ch_offset     = ue->frame_parms.ofdm_symbol_size*symbol;

  symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;

  k = bwp_start_subcarrier;
hongzhi wang's avatar
hongzhi wang committed
674
  int re_offset = k;
675 676

#ifdef DEBUG_CH
677 678
  printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size,
         ue->frame_parms.Ncp,Ns,k, symbol);
679 680
#endif

681
  // generate pilot for gNB port number 1000+p
682
  uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12;
683 684 685 686 687
  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){
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
    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;
    }
727
  } else {//pdsch_dmrs_type2
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
    nushift = delta;
    ue->frame_parms.nushift = nushift;
    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;
    }
766
  }
767 768

  for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
769
    pil   = (int16_t *)&pilot[rb_offset*((config_type==pdsch_dmrs_type1) ? 6:4)];
770
    k     = k % ue->frame_parms.ofdm_symbol_size;
771 772 773
    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];
774 775 776 777 778 779

    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
      multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
                                         1,ue->frame_parms.ofdm_symbol_size);
hongzhi wang's avatar
hongzhi wang committed
780
#ifdef DEBUG_PDSCH
Raymond Knopp's avatar
Raymond Knopp committed
781
    printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
782
    printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
hongzhi wang's avatar
hongzhi wang committed
783
    printf("rxF addr %p p %d\n", rxF,p);
hongzhi wang's avatar
hongzhi wang committed
784
    printf("dl_ch addr %p nushift %d\n",dl_ch,nushift);
785
#endif
786 787

    if (config_type == pdsch_dmrs_type1) {
788 789 790 791

      // Treat first 2 pilots specially (left edge)
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
792
#ifdef DEBUG_PDSCH
793 794
      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[0],ch[1],pil[0],pil[1]);
hongzhi wang's avatar
hongzhi wang committed
795
      printf("data 0 : rxF - > (%d,%d) addr %p  ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]);
796 797 798 799 800 801
#endif
      multadd_real_vector_complex_scalar(fl,
                                         ch,
                                         dl_ch,
                                         8);
      pil+=2;
802
      re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
803
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
804 805 806 807 808
      //for (int i= 0; i<8; i++)
      //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));

      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
809
#ifdef DEBUG_PDSCH
810 811 812 813 814 815 816
      printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif
      multadd_real_vector_complex_scalar(fml,
                                         ch,
                                         dl_ch,
                                         8);
      pil+=2;
817
      re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
818
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
819
      //printf("dl_ch addr %p\n",dl_ch);
hongzhi wang's avatar
hongzhi wang committed
820 821 822
      
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
823
#ifdef DEBUG_PDSCH
hongzhi wang's avatar
hongzhi wang committed
824
      printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
hongzhi wang's avatar
hongzhi wang committed
825
#endif
hongzhi wang's avatar
hongzhi wang committed
826 827 828 829
      multadd_real_vector_complex_scalar(fmm,
                                         ch,
                                         dl_ch,
                                         8);
hongzhi wang's avatar
hongzhi wang committed
830 831 832 833
                                         
      //for (int i= 0; i<16; i++)
      //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
      
hongzhi wang's avatar
hongzhi wang committed
834
      pil+=2;
835
      re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
836
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
837
      dl_ch+=8;
838

hongzhi wang's avatar
hongzhi wang committed
839
      for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pdsch-3); pilot_cnt+=2) {
hongzhi wang's avatar
hongzhi wang committed
840 841
    	//if ((pilot_cnt%6)==0)
    		//dl_ch+=4;
hongzhi wang's avatar
hongzhi wang committed
842
		//printf("re_offset %d\n",re_offset);
843 844 845

        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
846
#ifdef DEBUG_PDSCH
yilmazt's avatar
yilmazt committed
847
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
848 849 850 851 852 853 854
#endif
        multadd_real_vector_complex_scalar(fm,
                                           ch,
                                           dl_ch,
                                           8);

        pil+=2;
855
        re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
856
        rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
857
      
858 859
        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
860
#ifdef DEBUG_PDSCH
yilmazt's avatar
yilmazt committed
861
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
862
#endif
hongzhi wang's avatar
hongzhi wang committed
863
        multadd_real_vector_complex_scalar(fmm,
864 865 866 867
                                           ch,
                                           dl_ch,
                                           8);
        pil+=2;
868
        re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
869
        rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
870
        dl_ch+=8;
871 872

      }
hongzhi wang's avatar
hongzhi wang committed
873
      
874
      // Treat first 2 pilots specially (right edge)
875
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
hongzhi wang's avatar
hongzhi wang committed
876
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
877
#ifdef DEBUG_PDSCH
yilmazt's avatar
yilmazt committed
878
	printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
hongzhi wang's avatar
hongzhi wang committed
879 880
#endif
      multadd_real_vector_complex_scalar(fm,
hongzhi wang's avatar
hongzhi wang committed
881 882 883
                                         ch,
                                         dl_ch,
                                         8);
hongzhi wang's avatar
hongzhi wang committed
884 885 886 887
                                         
      //for (int i= 0; i<8; i++)
      //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));

hongzhi wang's avatar
hongzhi wang committed
888
      pil+=2;
889
      re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
890
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
891
             
892 893
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
894
#ifdef DEBUG_PDSCH
895
      printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
yilmazt's avatar
yilmazt committed
896
      printf("pilot %u: rxF - > (%d,%d) addr %p  ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
897 898 899 900 901
#endif
      multadd_real_vector_complex_scalar(fmr,
                                         ch,
                                         dl_ch,
                                         8);
hongzhi wang's avatar
hongzhi wang committed
902
                                         
903
      pil+=2;
904
      re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
hongzhi wang's avatar
hongzhi wang committed
905
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
hongzhi wang's avatar
hongzhi wang committed
906 907
      dl_ch+=8;
      
908 909
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
hongzhi wang's avatar
hongzhi wang committed
910
#ifdef DEBUG_PDSCH
yilmazt's avatar
yilmazt committed
911
      printf("pilot %u: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
912 913 914 915 916
#endif
      multadd_real_vector_complex_scalar(fr,
                                         ch,
                                         dl_ch,
                                         8);
917 918
    
    // check if PRB crosses DC and improve estimates around DC
Sakthivel Velumani's avatar
Sakthivel Velumani committed
919
    if ((bwp_start_subcarrier < ue->frame_parms.ofdm_symbol_size) && (bwp_start_subcarrier+nb_rb_pdsch*12 >= ue->frame_parms.ofdm_symbol_size)) {
920 921 922 923
      dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
      uint16_t idxDC = 2*(ue->frame_parms.ofdm_symbol_size - bwp_start_subcarrier);
      uint16_t idxPil = idxDC/2;
      re_offset = k;
924
      pil = (int16_t *)&pilot[rb_offset*((config_type==pdsch_dmrs_type1) ? 6:4)];
925 926 927
      pil += (idxPil-2);
      dl_ch += (idxDC-4);
      dl_ch = memset(dl_ch, 0, sizeof(int16_t)*10);
928
      re_offset = (re_offset+idxDC/2-2) % ue->frame_parms.ofdm_symbol_size;
929 930 931
      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
932
      
933 934
      // for proper allignment of SIMD vectors
      if((ue->frame_parms.N_RB_DL&1)==0) {
935
        
936
        multadd_real_vector_complex_scalar(fdcl,
937 938 939 940 941
                                           ch,
                                           dl_ch-4,
                                           8);
        
        pil += 4;
942
        re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
943 944 945 946
        rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
        
947
        multadd_real_vector_complex_scalar(fdcr,
948 949 950 951 952
                                           ch,
                                           dl_ch-4,
                                           8);
      } else {

953
        multadd_real_vector_complex_scalar(fdclh,
954 955 956 957 958
                                           ch,
                                           dl_ch,
                                           8);
        
        pil += 4;
959
        re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
960 961 962 963
        rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
        
964
        multadd_real_vector_complex_scalar(fdcrh,
965 966 967
                                           ch,
                                           dl_ch,
                                           8);
968
      }
969
    }
970 971
    } else { //pdsch_dmrs_type2  |dmrs_r,dmrs_l,0,0,0,0,dmrs_r,dmrs_l,0,0,0,0|

972 973 974
      // 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);
975

976
#ifdef DEBUG_PDSCH
977 978
      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]);
979 980
#endif

981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
      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);
1038 1039

#ifdef DEBUG_PDSCH
1040
        printf("pilot %u : 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]);
1041 1042
#endif

1043 1044 1045 1046 1047
        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);
1048

1049 1050
        ch[0] = (ch_l[0]+ch_r[0])>>1;
        ch[1] = (ch_l[1]+ch_r[1])>>1;
1051 1052

#ifdef DEBUG_PDSCH
1053
        printf("pilot %u : 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]);
1054 1055
#endif

1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082
        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);
1083 1084

#ifdef DEBUG_PDSCH
1085
        printf("pilot %u : 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]);
1086 1087
#endif

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
        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);
        }
      }
1181
    }
1182

1183
#ifdef DEBUG_PDSCH
1184 1185 1186 1187 1188 1189 1190
    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);
    }
1191 1192
#endif
  }
1193 1194
  return(0);
}