dlsch_demodulation.c 241 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * 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
 */
21 22 23

/*! \file PHY/LTE_TRANSPORT/dlsch_demodulation.c
 * \brief Top-level routines for demodulating the PDSCH physical channel from 36-211, V8.6 2009-03
24
 * \author R. Knopp, F. Kaltenberger,A. Bhamri, S. Aubert, X. Xiang
25
 * \date 2011
26
 * \version 0.1
27 28 29 30 31
 * \company Eurecom
 * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr,sebastien.aubert@eurecom.fr
 * \note
 * \warning
 */
32
//#include "PHY/defs.h"
33 34 35
#include "PHY/extern.h"
#include "defs.h"
#include "extern.h"
36
#include "PHY/sse_intrin.h"
37
#include "T.h"
38 39 40 41

#ifndef USER_MODE
#define NOCYGWIN_STATIC static
#else
42
#define NOCYGWIN_STATIC
43 44
#endif

45 46 47 48 49 50
/* dynamic shift for LLR computation for TM3/4
 * set as command line argument, see lte-softmodem.c
 * default value: 0
 */
int16_t dlsch_demod_shift = 0;

51 52
//#define DEBUG_HARQ

53 54 55
//#undef LOG_D
//#define LOG_D LOG_I

56
//#define DEBUG_PHY 1
57
//#define DEBUG_DLSCH_DEMOD 1
58

Bilel's avatar
Bilel committed
59

60 61

// [MCS][i_mod (0,1,2) = (2,4,6)]
62
unsigned char offset_mumimo_llr_drange_fix=0;
Elena Lukashova's avatar
Elena Lukashova committed
63 64 65
uint8_t interf_unaw_shift0=0;
uint8_t interf_unaw_shift1=0;
uint8_t interf_unaw_shift=0;
66
//inferference-free case
67
unsigned char interf_unaw_shift_tm4_mcs[29]={5, 3, 4, 3, 3, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
68
                                             1, 1, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 0} ;
69
unsigned char interf_unaw_shift_tm1_mcs[29]={5, 5, 4, 3, 3, 3, 2, 2, 4, 4, 2, 3, 3, 3, 1, 1,
70
                                             0, 1, 1, 2, 5, 4, 4, 6, 5, 1, 0, 5, 6} ; // mcs 21, 26, 28 seem to be errorneous
71

72 73 74
/*
//original values from sebastion + same hand tuning
unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{6,6,6},{6,6,6},{6,6,6},{5,5,5},{4,4,4},{1,2,4}, // QPSK
75 76
{5,5,4},{5,5,5},{5,5,5},{3,3,3},{2,2,2},{2,2,2},{2,2,2}, // 16-QAM
{2,2,1},{3,3,3},{3,3,3},{3,3,1},{2,2,2},{2,2,2},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}; //64-QAM
77
*/
78 79 80 81 82 83 84 85
 /*
 //first optimization try
 unsigned char offset_mumimo_llr_drange[29][3]={{7, 8, 7},{6, 6, 7},{6, 6, 7},{6, 6, 6},{5, 6, 6},{5, 5, 6},{5, 5, 6},{4, 5, 4},{4, 3, 4},{3, 2, 2},{6, 5, 5},{5, 4, 4},{5, 5, 4},{3, 3, 2},{2, 2, 1},{2, 1, 1},{2, 2, 2},{3, 3, 3},{3, 3, 2},{3, 3, 2},{3, 2, 1},{2, 2, 2},{2, 2, 2},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
 */
 //second optimization try
 /*
   unsigned char offset_mumimo_llr_drange[29][3]={{5, 8, 7},{4, 6, 8},{3, 6, 7},{7, 7, 6},{4, 7, 8},{4, 7, 4},{6, 6, 6},{3, 6, 6},{3, 6, 6},{1, 3, 4},{1, 1, 0},{3, 3, 2},{3, 4, 1},{4, 0, 1},{4, 2, 2},{3, 1, 2},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};  w
 */
86
unsigned char offset_mumimo_llr_drange[29][3]= {{0, 6, 5},{0, 4, 5},{0, 4, 5},{0, 5, 4},{0, 5, 6},{0, 5, 3},{0, 4, 4},{0, 4, 4},{0, 3, 3},{0, 1, 2},{1, 1, 0},{1, 3, 2},{3, 4, 1},{2, 0, 0},{2, 2, 2},{1, 1, 1},{2, 1, 0},{2, 1, 1},{1, 0, 1},{1, 0, 1},{0, 0, 0},{1, 0, 0},{0, 0, 0},{0, 1, 0},{1, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0},{0, 0, 0}};
87 88


89
extern void print_shorts(char *s,int16_t *x);
90

91

92
int rx_pdsch(PHY_VARS_UE *ue,
93 94
             PDSCH_t type,
             unsigned char eNB_id,
95
             unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
96
             uint32_t frame,
97
             uint8_t subframe,
98 99
             unsigned char symbol,
             unsigned char first_symbol_flag,
100
             RX_type_t rx_type,
101
             unsigned char i_mod,
102 103 104
             unsigned char harq_pid)
{

105 106 107
  LTE_UE_COMMON *common_vars  = &ue->common_vars;
  LTE_UE_PDSCH **pdsch_vars;
  LTE_DL_FRAME_PARMS *frame_parms    = &ue->frame_parms;
108
  PHY_MEASUREMENTS *measurements = &ue->measurements;
109
  LTE_UE_DLSCH_t   **dlsch;
110

Bilel's avatar
Bilel committed
111 112 113
  int avg[4];
  int avg_0[2];
  int avg_1[2];
Elena Lukashova's avatar
Elena Lukashova committed
114

115
  unsigned char aatx,aarx;
116

117
  unsigned short nb_rb = 0, round;
118
  int avgs, rb;
119
  LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
Elena Lukashova's avatar
Elena Lukashova committed
120

121
  uint8_t beamforming_mode;
122
  uint32_t *rballoc;
123

124 125
  int32_t **rxdataF_comp_ptr;
  int32_t **dl_ch_mag_ptr;
126 127 128 129
  int32_t codeword_TB0;
  int32_t codeword_TB1;


130

131 132
  switch (type) {
  case SI_PDSCH:
133
    pdsch_vars = &ue->pdsch_vars_SI[eNB_id];
134 135
    dlsch = &ue->dlsch_SI[eNB_id];
    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
136
    beamforming_mode  = 0;
137
    break;
138

139
  case RA_PDSCH:
140
    pdsch_vars = &ue->pdsch_vars_ra[eNB_id];
141 142
    dlsch = &ue->dlsch_ra[eNB_id];
    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
143
    beamforming_mode  = 0;
144
    break;
145

146
  case PDSCH:
Bilel's avatar
Bilel committed
147
    pdsch_vars = ue->pdsch_vars[subframe&0x1];
Bilel's avatar
Bilel committed
148 149 150 151 152 153
    dlsch = ue->dlsch[subframe&0x1][eNB_id];
    LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d,  harq status %d.%d \n",
                   frame,subframe,symbol,harq_pid,
                   dlsch[0]->harq_processes[harq_pid]->status,
                   dlsch[1]->harq_processes[harq_pid]->status);

154 155 156 157 158 159
    if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
        (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE)){
      codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
      codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
      dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid];
      dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid];
160
    }
161 162 163 164 165 166
     else if ((dlsch[0]->harq_processes[harq_pid]->status == ACTIVE) &&
              (dlsch[1]->harq_processes[harq_pid]->status != ACTIVE) ) {
      codeword_TB0 = dlsch[0]->harq_processes[harq_pid]->codeword;
      dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
      dlsch1_harq = NULL;
      codeword_TB1 = -1;
167
    }
168 169 170
     else if ((dlsch[0]->harq_processes[harq_pid]->status != ACTIVE) &&
              (dlsch[1]->harq_processes[harq_pid]->status == ACTIVE) ){
      codeword_TB1 = dlsch[1]->harq_processes[harq_pid]->codeword;
Bilel's avatar
Bilel committed
171 172
      dlsch0_harq  = dlsch[1]->harq_processes[harq_pid];
      dlsch1_harq  = NULL;
173
      codeword_TB0 = -1;
174
    }
175 176 177 178
    else {
      LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
      return(-1);
    }
179
    beamforming_mode  = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
180 181 182
    break;

  default:
Cedric Roux's avatar
Cedric Roux committed
183
    LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
184 185 186
    return(-1);
    break;
  }
187 188 189 190
#ifdef DEBUG_HARQ
  printf("[DEMOD] MIMO mode = %d\n", dlsch0_harq->mimo_mode);
  printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1);
#endif
191

192 193
  DevAssert(dlsch0_harq);
  round = dlsch0_harq->round;
194

195
  if (eNB_id > 2) {
jiangx's avatar
jiangx committed
196
    LOG_W(PHY,"dlsch_demodulation.c: Illegal eNB_id %d\n",eNB_id);
197 198
    return(-1);
  }
199

200 201
  if (!common_vars) {
    LOG_W(PHY,"dlsch_demodulation.c: Null common_vars\n");
202 203 204
    return(-1);
  }

205
  if (!dlsch[0]) {
jiangx's avatar
jiangx committed
206
    LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n");
207 208 209
    return(-1);
  }

210 211
  if (!pdsch_vars) {
    LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n");
212 213
    return(-1);
  }
214

215
  if (!frame_parms) {
216
    LOG_W(PHY,"dlsch_demodulation.c: Null frame_parms\n");
217 218
    return(-1);
  }
219

220 221 222 223 224
  if (((frame_parms->Ncp == NORMAL) && (symbol>=7)) ||
      ((frame_parms->Ncp == EXTENDED) && (symbol>=6)))
    rballoc = dlsch0_harq->rb_alloc_odd;
  else
    rballoc = dlsch0_harq->rb_alloc_even;
225

226

227
  if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
228 229 230
    LOG_E(PHY,"This transmission mode is not yet supported!\n");
    return(-1);
  }
231 232 233



234 235 236 237 238 239 240 241
  if ((dlsch0_harq->mimo_mode==LARGE_CDD) || ((dlsch0_harq->mimo_mode>=DUALSTREAM_UNIFORM_PRECODING1) && (dlsch0_harq->mimo_mode<=DUALSTREAM_PUSCH_PRECODING)))  {
    DevAssert(dlsch1_harq);
    if (eNB_id!=eNB_id_i) {
      LOG_E(PHY,"TM3/TM4 requires to set eNB_id==eNB_id_i!\n");
      return(-1);
    }
  }

Xiwen JIANG's avatar
Xiwen JIANG committed
242
  if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) {
243
#ifdef DEBUG_DLSCH_MOD
244
    LOG_I(PHY,"dlsch: using pmi %x (%p), rb_alloc %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0],dlsch0_harq->rb_alloc_even[0]);
245
#endif
246

247 248
    nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
                                   common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id],
249 250
                                   pdsch_vars[eNB_id]->rxdataF_ext,
                                   pdsch_vars[eNB_id]->dl_ch_estimates_ext,
251
                                   dlsch0_harq->pmi_alloc,
252
                                   pdsch_vars[eNB_id]->pmi_ext,
253
                                   rballoc,
254 255
                                   symbol,
                                   subframe,
256
                                   ue->high_speed_flag,
257
                                   frame_parms,
258
                                   dlsch0_harq->mimo_mode);
259
//#ifdef DEBUG_DLSCH_MOD
260 261
    /*   printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
       for (rb=0;rb<nb_rb;rb++)
262
          printf("%d",pdsch_vars[eNB_id]->pmi_ext[rb]);
263
       printf("\n");*/
264
//#endif
265

266
   if (rx_type >= rx_IC_single_stream) {
267
      if (eNB_id_i<ue->n_connected_eNB) // we are in TM5
268
      nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
269
                                       common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id_i],
270 271
                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
272
                                       dlsch0_harq->pmi_alloc,
273
                                       pdsch_vars[eNB_id_i]->pmi_ext,
274
                                       rballoc,
275 276
                                       symbol,
                                       subframe,
277
                                       ue->high_speed_flag,
278
                                       frame_parms,
279
                                       dlsch0_harq->mimo_mode);
280
      else
281 282
        nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
                                       common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id],
283 284
                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
285
                                       dlsch0_harq->pmi_alloc,
286
                                       pdsch_vars[eNB_id_i]->pmi_ext,
287
                                       rballoc,
288 289
                                       symbol,
                                       subframe,
290
                                       ue->high_speed_flag,
291
                                       frame_parms,
292
                                       dlsch0_harq->mimo_mode);
293
    }
294
  } else if (beamforming_mode==0) { //else if nb_antennas_ports_eNB==1 && beamforming_mode == 0
295 296
    nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
                                     common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id],
297 298
                                     pdsch_vars[eNB_id]->rxdataF_ext,
                                     pdsch_vars[eNB_id]->dl_ch_estimates_ext,
299
                                     dlsch0_harq->pmi_alloc,
300
                                     pdsch_vars[eNB_id]->pmi_ext,
301
                                     rballoc,
302 303
                                     symbol,
                                     subframe,
304
                                     ue->high_speed_flag,
305
                                     frame_parms);
306

Elena Lukashova's avatar
Elena Lukashova committed
307
   if (rx_type==rx_IC_single_stream) {
308
     if (eNB_id_i<ue->n_connected_eNB)
309 310
        nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
                                         common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id_i],
311
                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
312
                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
313
                                         dlsch0_harq->pmi_alloc,
314
                                         pdsch_vars[eNB_id_i]->pmi_ext,
315
                                         rballoc,
316 317
                                         symbol,
                                         subframe,
318
                                         ue->high_speed_flag,
319
                                         frame_parms);
320
      else
321 322
        nb_rb = dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
                                         common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id],
323
                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
324
                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
325
                                         dlsch0_harq->pmi_alloc,
326
                                         pdsch_vars[eNB_id_i]->pmi_ext,
327
                                         rballoc,
328 329
                                         symbol,
                                         subframe,
330
                                         ue->high_speed_flag,
331
                                         frame_parms);
332
    }
333
  } else if (beamforming_mode==7) { //else if beamforming_mode == 7
334
    nb_rb = dlsch_extract_rbs_TM7(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
335 336 337
                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates,
                                  pdsch_vars[eNB_id]->rxdataF_ext,
                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
338
                                  rballoc,
339 340
                                  symbol,
                                  subframe,
341
                                  ue->high_speed_flag,
342
                                  frame_parms);
343

344
  } else if(beamforming_mode>7) {
345
    LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
346
  }
347

Bilel's avatar
Bilel committed
348
  //printf("nb_rb = %d, eNB_id %d\n",nb_rb,eNB_id);
349
  if (nb_rb==0) {
350
    LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n");
351 352
    return(-1);
  }
353

Elena Lukashova's avatar
Elena Lukashova committed
354

355
#ifdef DEBUG_PHY
356 357
  LOG_D(PHY,"[DLSCH] log2_maxh = %d (%d,%d)\n",pdsch_vars[eNB_id]->log2_maxh,avg[0],avgs);
  LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
358 359
#endif

360
  aatx = frame_parms->nb_antenna_ports_eNB;
Elena Lukashova's avatar
Elena Lukashova committed
361 362
  aarx = frame_parms->nb_antennas_rx;

363
  dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
364 365 366 367
                      frame_parms,
                      dlsch,
                      symbol,
                      nb_rb);
368

369 370 371 372 373 374
  if ((dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) &&
      (rx_type==rx_IC_single_stream) &&
      (eNB_id_i==ue->n_connected_eNB) &&
      (dlsch0_harq->dl_power_off==0)
     )  // TM5 two-user
  {
375
    dlsch_scale_channel(pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
376
                        frame_parms,
377
                        dlsch,
378 379
                        symbol,
                        nb_rb);
380
  }
381

382
  if (first_symbol_flag==1) {
383 384 385
    if (beamforming_mode==0){
      if (dlsch0_harq->mimo_mode<LARGE_CDD) {
        dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
386 387 388 389
                           frame_parms,
                           avg,
                           symbol,
                           nb_rb);
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
        avgs = 0;
        for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++)
          for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
            avgs = cmax(avgs,avg[(aatx<<1)+aarx]);

        pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+1;
     }
     else if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
           ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))
     {
      dlsch_channel_level_TM34(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                 frame_parms,
                                 pdsch_vars[eNB_id]->pmi_ext,
                                 avg_0,
                                 avg_1,
                                 symbol,
                                 nb_rb,
                                 dlsch0_harq->mimo_mode);

Bilel's avatar
Bilel committed
410 411
      LOG_D(PHY,"Channel Level TM34  avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, interf_unaw_shift %d \n", avg_0[0],
              avg_1[0], rx_type, rx_standard, interf_unaw_shift);
412
        if (rx_type>rx_standard) {
413 414
          avg_0[0] = (log2_approx(avg_0[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
          avg_1[0] = (log2_approx(avg_1[0])/2) + dlsch_demod_shift;// + 2 ;//+ 4;
415 416
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
Bilel's avatar
Bilel committed
417 418
          //printf("TM4 I-A log2_maxh0 = %d\n", pdsch_vars[eNB_id]->log2_maxh0);
          //printf("TM4 I-A log2_maxh1 = %d\n", pdsch_vars[eNB_id]->log2_maxh1);
419 420 421 422 423 424
         }
          else {
          avg_0[0] = (log2_approx(avg_0[0])/2) - 13 + interf_unaw_shift;
          avg_1[0] = (log2_approx(avg_1[0])/2) - 13 + interf_unaw_shift;
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
Bilel's avatar
Bilel committed
425 426
          //printf("TM4 I-UA log2_maxh0 = %d\n", pdsch_vars[eNB_id]->log2_maxh0);
          //printf("TM4 I-UA log2_maxh1 = %d\n", pdsch_vars[eNB_id]->log2_maxh1);
427 428 429 430 431 432 433 434 435 436 437 438
        }
      }
      else if (dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) {// single-layer precoding (TM5, TM6)
        if ((rx_type==rx_IC_single_stream) && (eNB_id_i==ue->n_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
            dlsch_channel_level_TM56(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                frame_parms,
                                pdsch_vars[eNB_id]->pmi_ext,
                                avg,
                                symbol,
                                nb_rb);
            avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1];
            pdsch_vars[eNB_id]->log2_maxh = cmax(avg[0],0);
439

440 441
        }
        else if (dlsch0_harq->dl_power_off==1) { //TM6
442

443 444 445 446 447
          dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                   frame_parms,
                                   avg,
                                   symbol,
                                   nb_rb);
448

449 450 451 452
          avgs = 0;
          for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++)
            for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
              avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
453

454 455
          pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
          pdsch_vars[eNB_id]->log2_maxh++;
456

457
        }
458
      }
459

460 461 462 463 464 465 466
    }
    else if (beamforming_mode==7)
       dlsch_channel_level_TM7(pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
                              frame_parms,
                              avg,
                              symbol,
                              nb_rb);
467
#ifdef DEBUG_PHY
Bilel's avatar
Bilel committed
468 469 470 471 472
    LOG_I(PHY,"[DLSCH] log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",pdsch_vars[eNB_id]->log2_maxh,
                                                 pdsch_vars[eNB_id]->log2_maxh0,
                                                 pdsch_vars[eNB_id]->log2_maxh1,
                                                 avg[0],avgs);
    LOG_I(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
473 474
#endif
  }
475

476 477 478 479 480 481 482
#if T_TRACER
    if (type == PDSCH)
    {
      T(T_UE_PHY_PDSCH_ENERGY, T_INT(eNB_id),  T_INT(0), T_INT(frame%1024), T_INT(subframe),
                               T_INT(avg[0]), T_INT(avg[1]),    T_INT(avg[2]),             T_INT(avg[3]));
    }
#endif
483

484 485
// Now channel compensation
  if (dlsch0_harq->mimo_mode<LARGE_CDD) {
486 487 488 489 490 491
    dlsch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext,
                               pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                               pdsch_vars[eNB_id]->dl_ch_mag0,
                               pdsch_vars[eNB_id]->dl_ch_magb0,
                               pdsch_vars[eNB_id]->rxdataF_comp0,
                               (aatx>1) ? pdsch_vars[eNB_id]->rho : NULL,
492 493 494
                               frame_parms,
                               symbol,
                               first_symbol_flag,
Elena Lukashova's avatar
Elena Lukashova committed
495
                               dlsch0_harq->Qm,
496
                               nb_rb,
497
                               pdsch_vars[eNB_id]->log2_maxh,
498
                               measurements); // log2_maxh+I0_shift
499
 /*if (symbol == 5) {
500
     write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
501
 } */
502
    if ((rx_type==rx_IC_single_stream) &&
503
        (eNB_id_i<ue->n_connected_eNB)) {
504
         dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
505 506 507 508 509
                                 pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                 pdsch_vars[eNB_id_i]->dl_ch_mag0,
                                 pdsch_vars[eNB_id_i]->dl_ch_magb0,
                                 pdsch_vars[eNB_id_i]->rxdataF_comp0,
                                 (aatx>1) ? pdsch_vars[eNB_id_i]->rho : NULL,
510 511 512 513 514
                                 frame_parms,
                                 symbol,
                                 first_symbol_flag,
                                 i_mod,
                                 nb_rb,
515
                                 pdsch_vars[eNB_id]->log2_maxh,
516
                                 measurements); // log2_maxh+I0_shift
517 518
#ifdef DEBUG_PHY
      if (symbol == 5) {
519
        write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
520
        write_output("rxF_comp_i.m","rxF_c_i",&pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
521
      }
522
#endif
523

524
      dlsch_dual_stream_correlation(frame_parms,
525 526
                                    symbol,
                                    nb_rb,
527 528
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
529
                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
530
                                    pdsch_vars[eNB_id]->log2_maxh);
531
    }
532 533
  } else if ((dlsch0_harq->mimo_mode == LARGE_CDD) || ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){
534
      dlsch_channel_compensation_TM34(frame_parms,
535
                                     pdsch_vars[eNB_id],
536
                                     measurements,
537 538 539
                                     eNB_id,
                                     symbol,
                                     dlsch0_harq->Qm,
Elena Lukashova's avatar
Elena Lukashova committed
540
                                     dlsch1_harq->Qm,
541 542 543
                                     harq_pid,
                                     dlsch0_harq->round,
                                     dlsch0_harq->mimo_mode,
544
                                     nb_rb,
545
                                     pdsch_vars[eNB_id]->log2_maxh0,
546
                                     pdsch_vars[eNB_id]->log2_maxh1);
547
  /*   if (symbol == 5) {
548 549 550 551
     write_output("rxF_comp_d00.m","rxF_c_d00",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
     write_output("rxF_comp_d01.m","rxF_c_d01",&pdsch_vars[eNB_id]->rxdataF_comp0[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
     write_output("rxF_comp_d10.m","rxF_c_d10",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
     write_output("rxF_comp_d11.m","rxF_c_d11",&pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
552
        } */
553
      // compute correlation between signal and interference channels (rho12 and rho21)
554
        dlsch_dual_stream_correlation(frame_parms, // this is doing h11'*h12 and h21'*h22
555 556
                                    symbol,
                                    nb_rb,
557 558
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
559 560 561
                                    pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                                    pdsch_vars[eNB_id]->log2_maxh0);
        //printf("rho stream1 =%d\n", &pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round] );
562
      //to be optimized (just take complex conjugate)
563
      dlsch_dual_stream_correlation(frame_parms, // this is doing h12'*h11 and h22'*h21
564 565
                                    symbol,
                                    nb_rb,
566
                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
567
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
568 569
                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                    pdsch_vars[eNB_id]->log2_maxh1);
570
    //  printf("rho stream2 =%d\n",&pdsch_vars[eNB_id]->dl_ch_rho2_ext );
571
      //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh);
572
  /*     if (symbol == 5) {
573 574 575 576
     write_output("rho0_0.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
     write_output("rho2_0.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
     write_output("rho0_1.m.m","rho0_1",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
     write_output("rho2_1.m","rho2_1",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[1][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be QAM
577
        } */
578

579 580 581
    } else if (dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) {// single-layer precoding (TM5, TM6)
        if ((rx_type==rx_IC_single_stream) && (eNB_id_i==ue->n_connected_eNB) && (dlsch0_harq->dl_power_off==0)) {
          dlsch_channel_compensation_TM56(pdsch_vars[eNB_id]->rxdataF_ext,
582 583 584 585 586
                                      pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                      pdsch_vars[eNB_id]->dl_ch_mag0,
                                      pdsch_vars[eNB_id]->dl_ch_magb0,
                                      pdsch_vars[eNB_id]->rxdataF_comp0,
                                      pdsch_vars[eNB_id]->pmi_ext,
587
                                      frame_parms,
588
                                      measurements,
589 590
                                      eNB_id,
                                      symbol,
591
                                      dlsch0_harq->Qm,
592
                                      nb_rb,
593
                                      pdsch_vars[eNB_id]->log2_maxh,
594
                                      dlsch0_harq->dl_power_off);
595

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
        for (rb=0; rb<nb_rb; rb++) {
          switch(pdsch_vars[eNB_id]->pmi_ext[rb]) {
          case 0:
            pdsch_vars[eNB_id_i]->pmi_ext[rb]=1;
            break;
         case 1:
            pdsch_vars[eNB_id_i]->pmi_ext[rb]=0;
            break;
         case 2:
            pdsch_vars[eNB_id_i]->pmi_ext[rb]=3;
            break;
          case 3:
            pdsch_vars[eNB_id_i]->pmi_ext[rb]=2;
            break;
          }
Elena Lukashova's avatar
Elena Lukashova committed
611
       //  if (rb==0)
612
        //    printf("pmi %d, pmi_i %d\n",pdsch_vars[eNB_id]->pmi_ext[rb],pdsch_vars[eNB_id_i]->pmi_ext[rb]);
613
      }
614 615 616 617 618 619
      dlsch_channel_compensation_TM56(pdsch_vars[eNB_id_i]->rxdataF_ext,
                                      pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                      pdsch_vars[eNB_id_i]->dl_ch_mag0,
                                      pdsch_vars[eNB_id_i]->dl_ch_magb0,
                                      pdsch_vars[eNB_id_i]->rxdataF_comp0,
                                      pdsch_vars[eNB_id_i]->pmi_ext,
620
                                      frame_parms,
621
                                      measurements,
622 623 624 625
                                      eNB_id_i,
                                      symbol,
                                      i_mod,
                                      nb_rb,
626
                                      pdsch_vars[eNB_id]->log2_maxh,
627
                                      dlsch0_harq->dl_power_off);
628 629
#ifdef DEBUG_PHY
      if (symbol==5) {
630
        write_output("rxF_comp_d.m","rxF_c_d",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
631
       write_output("rxF_comp_i.m","rxF_c_i",&pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
632
      }
633
#endif
634 635 636
      dlsch_dual_stream_correlation(frame_parms,
                                    symbol,
                                    nb_rb,
637 638 639 640
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                    pdsch_vars[eNB_id]->log2_maxh);
641
    }  else if (dlsch0_harq->dl_power_off==1)  {
642 643 644 645 646 647
      dlsch_channel_compensation_TM56(pdsch_vars[eNB_id]->rxdataF_ext,
                                      pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                      pdsch_vars[eNB_id]->dl_ch_mag0,
                                      pdsch_vars[eNB_id]->dl_ch_magb0,
                                      pdsch_vars[eNB_id]->rxdataF_comp0,
                                      pdsch_vars[eNB_id]->pmi_ext,
648
                                      frame_parms,
649
                                      measurements,
650 651
                                      eNB_id,
                                      symbol,
652
                                      dlsch0_harq->Qm,
653
                                      nb_rb,
654
                                      pdsch_vars[eNB_id]->log2_maxh,
655
                                      1);
Elena Lukashova's avatar
Elena Lukashova committed
656

657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
      }


    } else if (dlsch0_harq->mimo_mode==TM7) { //TM7

      dlsch_channel_compensation(pdsch_vars[eNB_id]->rxdataF_ext,
                                 pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
                                 pdsch_vars[eNB_id]->dl_ch_mag0,
                                 pdsch_vars[eNB_id]->dl_ch_magb0,
                                 pdsch_vars[eNB_id]->rxdataF_comp0,
                                 (aatx>1) ? pdsch_vars[eNB_id]->rho : NULL,
                                 frame_parms,
                                 symbol,
                                 first_symbol_flag,
                                 get_Qm(dlsch0_harq->mcs),
                                 nb_rb,
                                 //9,
                                 pdsch_vars[eNB_id]->log2_maxh,
                                 measurements); // log2_maxh+I0_shift
676 677
  }

678 679 680 681
// MRC


   if (frame_parms->nb_antennas_rx > 1) {
682
    if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
683
        ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
684
         (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
Xiwen JIANG's avatar
Xiwen JIANG committed
685
      if (frame_parms->nb_antenna_ports_eNB == 2) {
686
        dlsch_detection_mrc_TM34(frame_parms,
687
                                 pdsch_vars[eNB_id],
688
                                 harq_pid,
689
                                 dlsch0_harq->round,
690 691 692
                                 symbol,
                                 nb_rb,
                                 1);
693
    /*   if (symbol == 5) {
694 695
     write_output("rho0_mrc.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM
     write_output("rho2_mrc.m","rho2_0",&pdsch_vars[eNB_id]->dl_ch_rho2_ext[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);//should be almost 0
696
        } */
697
      }
698
    } else {
699
      dlsch_detection_mrc(frame_parms,
700 701 702
                          pdsch_vars[eNB_id]->rxdataF_comp0,
                          pdsch_vars[eNB_id_i]->rxdataF_comp0,
                          pdsch_vars[eNB_id]->rho,
703
                          pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
704 705 706 707
                          pdsch_vars[eNB_id]->dl_ch_mag0,
                          pdsch_vars[eNB_id]->dl_ch_magb0,
                          pdsch_vars[eNB_id_i]->dl_ch_mag0,
                          pdsch_vars[eNB_id_i]->dl_ch_magb0,
708 709
                          symbol,
                          nb_rb,
710
                          rx_type==rx_IC_single_stream);
711 712 713 714 715
    }
  }
  //  printf("Combining");
  if ((dlsch0_harq->mimo_mode == SISO) ||
      ((dlsch0_harq->mimo_mode >= UNIFORM_PRECODING11) &&
716 717
       (dlsch0_harq->mimo_mode <= PUSCH_PRECODING0)) ||
       (dlsch0_harq->mimo_mode == TM7)) {
718 719
    /*
      dlsch_siso(frame_parms,
720 721
      pdsch_vars[eNB_id]->rxdataF_comp,
      pdsch_vars[eNB_id_i]->rxdataF_comp,
722 723 724 725 726
      symbol,
      nb_rb);
    */
  } else if (dlsch0_harq->mimo_mode == ALAMOUTI) {
    dlsch_alamouti(frame_parms,
727 728 729
                   pdsch_vars[eNB_id]->rxdataF_comp0,
                   pdsch_vars[eNB_id]->dl_ch_mag0,
                   pdsch_vars[eNB_id]->dl_ch_magb0,
730 731
                   symbol,
                   nb_rb);
732 733
  }

734
  //    printf("LLR");
735 736
  if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
      ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
737
       (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))  {
738
    rxdataF_comp_ptr = pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round];
739
    dl_ch_mag_ptr = pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round];
740 741
  }
  else {
742 743
    rxdataF_comp_ptr = pdsch_vars[eNB_id_i]->rxdataF_comp0;
    dl_ch_mag_ptr = pdsch_vars[eNB_id_i]->dl_ch_mag0;
744
    //i_mod should have been passed as a parameter
745
  }
746

747
  switch (dlsch0_harq->Qm) {
748
  case 2 :
749
    if ((rx_type==rx_standard) || (codeword_TB0 == -1) || (codeword_TB1 == -1)) {
750
        dlsch_qpsk_llr(frame_parms,
751 752
                       pdsch_vars[eNB_id]->rxdataF_comp0,
                       pdsch_vars[eNB_id]->llr[0],
753 754 755
                       symbol,
                       first_symbol_flag,
                       nb_rb,
756
                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
757
                       pdsch_vars[eNB_id]->llr128,
758
                       beamforming_mode);
759
    }
760
      else if (rx_type >= rx_IC_single_stream) {
Elena Lukashova's avatar
Elena Lukashova committed
761
        if (dlsch1_harq->Qm == 2) {
762
          dlsch_qpsk_qpsk_llr(frame_parms,
763
                              pdsch_vars[eNB_id]->rxdataF_comp0,
764
                              rxdataF_comp_ptr,
765 766
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
767
                              symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
768
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
769
                              pdsch_vars[eNB_id]->llr128);
770 771 772
          if (rx_type==rx_IC_dual_stream) {
            dlsch_qpsk_qpsk_llr(frame_parms,
                                rxdataF_comp_ptr,
773 774 775
                                pdsch_vars[eNB_id]->rxdataF_comp0,
                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                pdsch_vars[eNB_id]->llr[1],
776
                                symbol,first_symbol_flag,nb_rb,
777
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
778
                                pdsch_vars[eNB_id]->llr128_2ndstream);
779 780
          }
        }
781
        else if (dlsch1_harq->Qm == 4) {
782
          dlsch_qpsk_16qam_llr(frame_parms,
783
                               pdsch_vars[eNB_id]->rxdataF_comp0,
784 785
                               rxdataF_comp_ptr,//i
                               dl_ch_mag_ptr,//i
786 787
                               pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                               pdsch_vars[eNB_id]->llr[0],
788
                               symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
789
                               adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
790
                               pdsch_vars[eNB_id]->llr128);
791 792 793
          if (rx_type==rx_IC_dual_stream) {
            dlsch_16qam_qpsk_llr(frame_parms,
                                 rxdataF_comp_ptr,
794
                                 pdsch_vars[eNB_id]->rxdataF_comp0,//i
795
                                 dl_ch_mag_ptr,
796 797
                                 pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                 pdsch_vars[eNB_id]->llr[1],
798
                                 symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
799
                                 adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
800
                                 pdsch_vars[eNB_id]->llr128_2ndstream);
801 802 803 804
          }
        }
        else {
          dlsch_qpsk_64qam_llr(frame_parms,
805
                               pdsch_vars[eNB_id]->rxdataF_comp0,
806 807
                               rxdataF_comp_ptr,//i
                               dl_ch_mag_ptr,//i
808 809
                               pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                               pdsch_vars[eNB_id]->llr[0],
810
                               symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
811
                               adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
812
                               pdsch_vars[eNB_id]->llr128);
813 814 815
          if (rx_type==rx_IC_dual_stream) {
            dlsch_64qam_qpsk_llr(frame_parms,
                                 rxdataF_comp_ptr,
816
                                 pdsch_vars[eNB_id]->rxdataF_comp0,//i
817
                                 dl_ch_mag_ptr,
818 819
                                 pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                 pdsch_vars[eNB_id]->llr[1],
820
                                 symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
821
                                 adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
822
                                 pdsch_vars[eNB_id]->llr128_2ndstream);
823
          }
824
        }
825
      }
826 827
    break;
  case 4 :
828
    if ((rx_type==rx_standard ) || (codeword_TB0 == -1) || (codeword_TB1 == -1)) {
829
      dlsch_16qam_llr(frame_parms,
830 831 832
                      pdsch_vars[eNB_id]->rxdataF_comp0,
                      pdsch_vars[eNB_id]->llr[0],
                      pdsch_vars[eNB_id]->dl_ch_mag0,
833
                      symbol,first_symbol_flag,nb_rb,
834
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
835 836
                      pdsch_vars[eNB_id]->llr128,
                      beamforming_mode);
837
    }
838
    else if (rx_type >= rx_IC_single_stream) {
Elena Lukashova's avatar
Elena Lukashova committed
839
      if (dlsch1_harq->Qm == 2) {
840
        dlsch_16qam_qpsk_llr(frame_parms,
841
                             pdsch_vars[eNB_id]->rxdataF_comp0,
842
                             rxdataF_comp_ptr,//i
843 844 845
                             pdsch_vars[eNB_id]->dl_ch_mag0,
                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                             pdsch_vars[eNB_id]->llr[0],
846
                             symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
847
                             adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
848
                             pdsch_vars[eNB_id]->llr128);
849 850 851
        if (rx_type==rx_IC_dual_stream) {
          dlsch_qpsk_16qam_llr(frame_parms,
                               rxdataF_comp_ptr,
852 853 854 855
                               pdsch_vars[eNB_id]->rxdataF_comp0,//i
                               pdsch_vars[eNB_id]->dl_ch_mag0,//i
                               pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                               pdsch_vars[eNB_id]->llr[1],
856
                               symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
857
                               adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
858
                               pdsch_vars[eNB_id]->llr128_2ndstream);
859
        }
860
      }
Elena Lukashova's avatar
Elena Lukashova committed
861
      else if (dlsch1_harq->Qm == 4) {
862
        dlsch_16qam_16qam_llr(frame_parms,
863
                              pdsch_vars[eNB_id]->rxdataF_comp0,
864
                              rxdataF_comp_ptr,//i
865
                              pdsch_vars[eNB_id]->dl_ch_mag0,
866
                              dl_ch_mag_ptr,//i
867 868
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
869 870
                              symbol,first_symbol_flag,nb_rb,
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
871
                              pdsch_vars[eNB_id]->llr128);
872 873 874
        if (rx_type==rx_IC_dual_stream) {
          dlsch_16qam_16qam_llr(frame_parms,
                                rxdataF_comp_ptr,
875
                                pdsch_vars[eNB_id]->rxdataF_comp0,//i
876
                                dl_ch_mag_ptr,
877 878 879
                                pdsch_vars[eNB_id]->dl_ch_mag0,//i
                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                pdsch_vars[eNB_id]->llr[1],
880 881
                                symbol,first_symbol_flag,nb_rb,
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
882
                                pdsch_vars[eNB_id]->llr128_2ndstream);
883
        }
884 885
      }
      else {
886
        dlsch_16qam_64qam_llr(frame_parms,
887
                              pdsch_vars[eNB_id]->rxdataF_comp0,
888
                              rxdataF_comp_ptr,//i
889
                              pdsch_vars[eNB_id]->dl_ch_mag0,
890
                              dl_ch_mag_ptr,//i
891 892
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
893 894
                              symbol,first_symbol_flag,nb_rb,
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
895
                              pdsch_vars[eNB_id]->llr128);
896 897 898
        if (rx_type==rx_IC_dual_stream) {
          dlsch_64qam_16qam_llr(frame_parms,
                                rxdataF_comp_ptr,
899
                                pdsch_vars[eNB_id]->rxdataF_comp0,
900
                                dl_ch_mag_ptr,
901 902 903
                                pdsch_vars[eNB_id]->dl_ch_mag0,
                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                pdsch_vars[eNB_id]->llr[1],
904 905
                                symbol,first_symbol_flag,nb_rb,
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
906
                                pdsch_vars[eNB_id]->llr128_2ndstream);
907
        }
908 909 910 911
      }
    }
    break;
  case 6 :
912
    if ((rx_type==rx_standard) || (codeword_TB0 == -1) || (codeword_TB1 == -1))  {
913
      dlsch_64qam_llr(frame_parms,
914 915 916 917
                      pdsch_vars[eNB_id]->rxdataF_comp0,
                      pdsch_vars[eNB_id]->llr[0],
                      pdsch_vars[eNB_id]->dl_ch_mag0,
                      pdsch_vars[eNB_id]->dl_ch_magb0,
918
                      symbol,first_symbol_flag,nb_rb,
919
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
920 921
                      pdsch_vars[eNB_id]->llr128,
                      beamforming_mode);
922
    }
923
    else if (rx_type >= rx_IC_single_stream) {
924
      if (dlsch1_harq->Qm == 2) {
925
        dlsch_64qam_qpsk_llr(frame_parms,
926
                             pdsch_vars[eNB_id]->rxdataF_comp0,
927
                             rxdataF_comp_ptr,//i
928 929 930
                             pdsch_vars[eNB_id]->dl_ch_mag0,
                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                             pdsch_vars[eNB_id]->llr[0],
931 932
                             symbol,first_symbol_flag,nb_rb,
                             adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
933
                             pdsch_vars[eNB_id]->llr128);
934 935 936
        if (rx_type==rx_IC_dual_stream) {
          dlsch_qpsk_64qam_llr(frame_parms,
                               rxdataF_comp_ptr,
937 938 939 940
                               pdsch_vars[eNB_id]->rxdataF_comp0,//i
                               pdsch_vars[eNB_id]->dl_ch_mag0,
                               pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                               pdsch_vars[eNB_id]->llr[1],
941 942
                               symbol,first_symbol_flag,nb_rb,
                               adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
943
                               pdsch_vars[eNB_id]->llr128_2ndstream);
944
        }
945
      }
Elena Lukashova's avatar
Elena Lukashova committed
946
      else if (dlsch1_harq->Qm == 4) {
947
        dlsch_64qam_16qam_llr(frame_parms,
948
                              pdsch_vars[eNB_id]->rxdataF_comp0,
949
                              rxdataF_comp_ptr,//i
950
                              pdsch_vars[eNB_id]->dl_ch_mag0,
951
                              dl_ch_mag_ptr,//i
952 953
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
954 955
                              symbol,first_symbol_flag,nb_rb,
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
956
                              pdsch_vars[eNB_id]->llr128);
957 958 959
        if (rx_type==rx_IC_dual_stream) {
          dlsch_16qam_64qam_llr(frame_parms,
                                rxdataF_comp_ptr,