[GITLAB] - UPGRADE TO v12 on Wednesday the 18th of December at 11.30AM

dlsch_demodulation.c 243 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
#include "PHY/extern.h"
34
#include "SCHED/defs.h"
35 36
#include "defs.h"
#include "extern.h"
37
#include "PHY/sse_intrin.h"
38
#include "T.h"
39 40 41 42

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

46 47 48 49 50 51
/* 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;

52 53
//#define DEBUG_HARQ

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

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

Bilel's avatar
Bilel committed
60

61 62

// [MCS][i_mod (0,1,2) = (2,4,6)]
63
unsigned char offset_mumimo_llr_drange_fix=0;
64
//inferference-free case
65
unsigned char interf_unaw_shift_tm4_mcs[29]={5, 3, 4, 3, 3, 2, 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
66
                                             1, 1, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 0} ;
67
unsigned char interf_unaw_shift_tm1_mcs[29]={5, 5, 4, 3, 3, 3, 2, 2, 4, 4, 2, 3, 3, 3, 1, 1,
68
                                             0, 1, 1, 2, 5, 4, 4, 6, 5, 1, 0, 5, 6} ; // mcs 21, 26, 28 seem to be errorneous
69

70 71 72
/*
//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
73 74
{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
75
*/
76 77 78 79 80 81 82 83
 /*
 //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
 */
84
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}};
85 86


87
extern void print_shorts(char *s,int16_t *x);
88

89

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

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

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

113
  unsigned char aatx,aarx;
114

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

119
  uint8_t beamforming_mode;
120
  uint32_t *rballoc;
121

122 123
  int32_t **rxdataF_comp_ptr;
  int32_t **dl_ch_mag_ptr;
124 125
  int32_t codeword_TB0 = -1;
  int32_t codeword_TB1 = -1;
126 127


128

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

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

144
  case PDSCH:
Bilel's avatar
Bilel committed
145
    pdsch_vars = ue->pdsch_vars[subframe&0x1];
Bilel's avatar
Bilel committed
146
    dlsch = ue->dlsch[subframe&0x1][eNB_id];
147
    //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
Bilel's avatar
Bilel committed
148 149 150 151 152
    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);

153 154 155 156 157 158
    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];
159 160 161
#ifdef DEBUG_HARQ
      printf("[DEMOD] I am assuming both TBs are active\n");
#endif
162
    }
163 164 165 166 167 168
     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;
169 170 171
#ifdef DEBUG_HARQ
      printf("[DEMOD] I am assuming only TB0 is active\n");
#endif
172
    }
173 174 175
     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
176 177
      dlsch0_harq  = dlsch[1]->harq_processes[harq_pid];
      dlsch1_harq  = NULL;
178
      codeword_TB0 = -1;
179
#ifdef DEBUG_HARQ
180
      printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", dlsch0_harq->codeword);
181
#endif
182
    }
183 184 185 186
    else {
      LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
      return(-1);
    }
187
    beamforming_mode  = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
188 189 190
    break;

  default:
Cedric Roux's avatar
Cedric Roux committed
191
    LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
192 193 194
    return(-1);
    break;
  }
195 196 197 198
#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
199

200 201
  DevAssert(dlsch0_harq);
  round = dlsch0_harq->round;
202
  //printf("round = %d\n", round);
203

204
  if (eNB_id > 2) {
jiangx's avatar
jiangx committed
205
    LOG_W(PHY,"dlsch_demodulation.c: Illegal eNB_id %d\n",eNB_id);
206 207
    return(-1);
  }
208

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

214
  if (!dlsch[0]) {
jiangx's avatar
jiangx committed
215
    LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n");
216 217 218
    return(-1);
  }

219 220
  if (!pdsch_vars) {
    LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n");
221 222
    return(-1);
  }
223

224
  if (!frame_parms) {
225
    LOG_W(PHY,"dlsch_demodulation.c: Null frame_parms\n");
226 227
    return(-1);
  }
228

229 230 231 232 233
  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;
234

235

236
  if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
237 238 239
    LOG_E(PHY,"This transmission mode is not yet supported!\n");
    return(-1);
  }
240 241


242
  if ((dlsch0_harq->mimo_mode==LARGE_CDD) || ((dlsch0_harq->mimo_mode>=DUALSTREAM_UNIFORM_PRECODING1) && (dlsch0_harq->mimo_mode<=DUALSTREAM_PUSCH_PRECODING)))  {
243
    DevAssert(dlsch1_harq);
244 245 246 247 248
    if (eNB_id!=eNB_id_i) {
      LOG_E(PHY,"TM3/TM4 requires to set eNB_id==eNB_id_i!\n");
      return(-1);
    }
  }
249 250 251
#ifdef DEBUG_HARQ
  printf("Demod  dlsch0_harq->pmi_alloc %d\n",  dlsch0_harq->pmi_alloc);
#endif
252

Xiwen JIANG's avatar
Xiwen JIANG committed
253
  if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) {
254
#ifdef DEBUG_DLSCH_MOD
255
    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]);
256
#endif
257

258 259
    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],
260 261
                                   pdsch_vars[eNB_id]->rxdataF_ext,
                                   pdsch_vars[eNB_id]->dl_ch_estimates_ext,
262
                                   dlsch0_harq->pmi_alloc,
263
                                   pdsch_vars[eNB_id]->pmi_ext,
264
                                   rballoc,
265 266
                                   symbol,
                                   subframe,
267
                                   ue->high_speed_flag,
268
                                   frame_parms,
269
                                   dlsch0_harq->mimo_mode);
Gabriel's avatar
Gabriel committed
270 271
#ifdef DEBUG_DLSCH_MOD
      printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
272
       for (rb=0;rb<nb_rb;rb++)
273
          printf("%d",pdsch_vars[eNB_id]->pmi_ext[rb]);
Gabriel's avatar
Gabriel committed
274 275
       printf("\n");
#endif
276

277
   if (rx_type >= rx_IC_single_stream) {
278
      if (eNB_id_i<ue->n_connected_eNB) // we are in TM5
279
      nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
280
                                       common_vars->common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id_i],
281 282
                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
283
                                       dlsch0_harq->pmi_alloc,
284
                                       pdsch_vars[eNB_id_i]->pmi_ext,
285
                                       rballoc,
286 287
                                       symbol,
                                       subframe,
288
                                       ue->high_speed_flag,
289
                                       frame_parms,
290
                                       dlsch0_harq->mimo_mode);
291
      else
292 293
        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],
294 295
                                       pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
296
                                       dlsch0_harq->pmi_alloc,
297
                                       pdsch_vars[eNB_id_i]->pmi_ext,
298
                                       rballoc,
299 300
                                       symbol,
                                       subframe,
301
                                       ue->high_speed_flag,
302
                                       frame_parms,
303
                                       dlsch0_harq->mimo_mode);
304
    }
305
  } else if (beamforming_mode==0) { //else if nb_antennas_ports_eNB==1 && beamforming_mode == 0
306 307
    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],
308 309
                                     pdsch_vars[eNB_id]->rxdataF_ext,
                                     pdsch_vars[eNB_id]->dl_ch_estimates_ext,
310
                                     dlsch0_harq->pmi_alloc,
311
                                     pdsch_vars[eNB_id]->pmi_ext,
312
                                     rballoc,
313 314
                                     symbol,
                                     subframe,
315
                                     ue->high_speed_flag,
316
                                     frame_parms);
317

Elena Lukashova's avatar
Elena Lukashova committed
318
   if (rx_type==rx_IC_single_stream) {
319
     if (eNB_id_i<ue->n_connected_eNB)
320 321
        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],
322
                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
323
                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
324
                                         dlsch0_harq->pmi_alloc,
325
                                         pdsch_vars[eNB_id_i]->pmi_ext,
326
                                         rballoc,
327 328
                                         symbol,
                                         subframe,
329
                                         ue->high_speed_flag,
330
                                         frame_parms);
331
      else
332 333
        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],
334
                                         pdsch_vars[eNB_id_i]->rxdataF_ext,
335
                                         pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
336
                                         dlsch0_harq->pmi_alloc,
337
                                         pdsch_vars[eNB_id_i]->pmi_ext,
338
                                         rballoc,
339 340
                                         symbol,
                                         subframe,
341
                                         ue->high_speed_flag,
342
                                         frame_parms);
343
    }
344
  } else if (beamforming_mode==7) { //else if beamforming_mode == 7
345
    nb_rb = dlsch_extract_rbs_TM7(common_vars->common_vars_rx_data_per_thread[subframe&0x1].rxdataF,
346 347 348
                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates,
                                  pdsch_vars[eNB_id]->rxdataF_ext,
                                  pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
349
                                  rballoc,
350 351
                                  symbol,
                                  subframe,
352
                                  ue->high_speed_flag,
353
                                  frame_parms);
354

355
  } else if(beamforming_mode>7) {
356
    LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
357
  }
358

Bilel's avatar
Bilel committed
359
  //printf("nb_rb = %d, eNB_id %d\n",nb_rb,eNB_id);
360
  if (nb_rb==0) {
361
    LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n");
362 363
    return(-1);
  }
364

Elena Lukashova's avatar
Elena Lukashova committed
365

366
#ifdef DEBUG_PHY
367
  LOG_D(PHY,"[DLSCH] nb_rb %d log2_maxh = %d (%d,%d)\n",nb_rb,pdsch_vars[eNB_id]->log2_maxh,avg[0],avgs);
368
  LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
369 370
#endif

371
  aatx = frame_parms->nb_antenna_ports_eNB;
Elena Lukashova's avatar
Elena Lukashova committed
372 373
  aarx = frame_parms->nb_antennas_rx;

374
  dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
375 376 377 378
                      frame_parms,
                      dlsch,
                      symbol,
                      nb_rb);
379

380 381 382 383 384 385
  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
  {
386
    dlsch_scale_channel(pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
387
                        frame_parms,
388
                        dlsch,
389 390
                        symbol,
                        nb_rb);
391
  }
392

393
  if (first_symbol_flag==1) {
394 395 396
    if (beamforming_mode==0){
      if (dlsch0_harq->mimo_mode<LARGE_CDD) {
        dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
397 398 399 400
                           frame_parms,
                           avg,
                           symbol,
                           nb_rb);
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
        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
421
      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],
422
              avg_1[0], rx_type, rx_standard, dlsch_demod_shift);
423
        if (rx_type>rx_standard) {
424 425
          avg_0[0] = (log2_approx(avg_0[0])/2) -13 + dlsch_demod_shift;// + 2 ;//+ 4;
          avg_1[0] = (log2_approx(avg_1[0])/2) -13 + dlsch_demod_shift;// + 2 ;//+ 4;
426 427
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
428
         // printf("dlsch_demod_shift  %d\n", dlsch_demod_shift);
429 430
         }
          else {
431 432
          avg_0[0] = (log2_approx(avg_0[0])/2) - 13 + dlsch_demod_shift;
          avg_1[0] = (log2_approx(avg_1[0])/2) - 13 + dlsch_demod_shift;
433 434 435 436 437 438 439 440 441 442 443 444 445
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
        }
      }
      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);
446

447 448
        }
        else if (dlsch0_harq->dl_power_off==1) { //TM6
449

450 451 452 453 454
          dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                   frame_parms,
                                   avg,
                                   symbol,
                                   nb_rb);
455

456 457 458 459
          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]);
460

461 462
          pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
          pdsch_vars[eNB_id]->log2_maxh++;
463

464
        }
465
      }
466

467 468 469 470 471 472 473
    }
    else if (beamforming_mode==7)
       dlsch_channel_level_TM7(pdsch_vars[eNB_id]->dl_bf_ch_estimates_ext,
                              frame_parms,
                              avg,
                              symbol,
                              nb_rb);
Gabriel's avatar
Gabriel committed
474
#ifdef UE_DEBUG_TRACE
Gabriel's avatar
Gabriel committed
475
    LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
Gabriel's avatar
Gabriel committed
476
            frame%1024,subframe, pdsch_vars[eNB_id]->log2_maxh,
Bilel's avatar
Bilel committed
477 478 479
                                                 pdsch_vars[eNB_id]->log2_maxh0,
                                                 pdsch_vars[eNB_id]->log2_maxh1,
                                                 avg[0],avgs);
Gabriel's avatar
Gabriel committed
480
    //LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
481 482
#endif
  }
483

484 485 486 487 488 489 490
#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
491

492 493
// Now channel compensation
  if (dlsch0_harq->mimo_mode<LARGE_CDD) {
494 495 496 497 498 499
    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,
500 501 502
                               frame_parms,
                               symbol,
                               first_symbol_flag,
Elena Lukashova's avatar
Elena Lukashova committed
503
                               dlsch0_harq->Qm,
504
                               nb_rb,
505
                               pdsch_vars[eNB_id]->log2_maxh,
506
                               measurements); // log2_maxh+I0_shift
507
 /*if (symbol == 5) {
508
     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);
509
 } */
510
    if ((rx_type==rx_IC_single_stream) &&
511
        (eNB_id_i<ue->n_connected_eNB)) {
512
         dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
513 514 515 516 517
                                 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,
518 519 520 521 522
                                 frame_parms,
                                 symbol,
                                 first_symbol_flag,
                                 i_mod,
                                 nb_rb,
523
                                 pdsch_vars[eNB_id]->log2_maxh,
524
                                 measurements); // log2_maxh+I0_shift
525 526
#ifdef DEBUG_PHY
      if (symbol == 5) {
527
        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);
528
        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);
529
      }
530
#endif
531

532
      dlsch_dual_stream_correlation(frame_parms,
533 534
                                    symbol,
                                    nb_rb,
535 536
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
537
                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
538
                                    pdsch_vars[eNB_id]->log2_maxh);
539
    }
540 541
  } else if ((dlsch0_harq->mimo_mode == LARGE_CDD) || ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){
542
      dlsch_channel_compensation_TM34(frame_parms,
543
                                     pdsch_vars[eNB_id],
544
                                     measurements,
545 546 547
                                     eNB_id,
                                     symbol,
                                     dlsch0_harq->Qm,
Elena Lukashova's avatar
Elena Lukashova committed
548
                                     dlsch1_harq->Qm,
549 550 551
                                     harq_pid,
                                     dlsch0_harq->round,
                                     dlsch0_harq->mimo_mode,
552
                                     nb_rb,
553
                                     pdsch_vars[eNB_id]->log2_maxh0,
554
                                     pdsch_vars[eNB_id]->log2_maxh1);
555
  /*   if (symbol == 5) {
556 557 558 559
     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
560
        } */
561
      // compute correlation between signal and interference channels (rho12 and rho21)
562
        dlsch_dual_stream_correlation(frame_parms, // this is doing h11'*h12 and h21'*h22
563 564
                                    symbol,
                                    nb_rb,
565 566
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
567 568 569
                                    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] );
570
      //to be optimized (just take complex conjugate)
571
      dlsch_dual_stream_correlation(frame_parms, // this is doing h12'*h11 and h22'*h21
572 573
                                    symbol,
                                    nb_rb,
574
                                    &(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
575
                                    pdsch_vars[eNB_id]->dl_ch_estimates_ext,
576 577
                                    pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                    pdsch_vars[eNB_id]->log2_maxh1);
578
    //  printf("rho stream2 =%d\n",&pdsch_vars[eNB_id]->dl_ch_rho2_ext );
579
      //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh);
580
  /*     if (symbol == 5) {
581 582 583 584
     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
585
        } */
586

587 588 589
    } 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,
590 591 592 593 594
                                      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,
595
                                      frame_parms,
596
                                      measurements,
597 598
                                      eNB_id,
                                      symbol,
599
                                      dlsch0_harq->Qm,
600
                                      nb_rb,
601
                                      pdsch_vars[eNB_id]->log2_maxh,
602
                                      dlsch0_harq->dl_power_off);
603

604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
        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
619
       //  if (rb==0)
620
        //    printf("pmi %d, pmi_i %d\n",pdsch_vars[eNB_id]->pmi_ext[rb],pdsch_vars[eNB_id_i]->pmi_ext[rb]);
621
      }
622 623 624 625 626 627
      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,
628
                                      frame_parms,
629
                                      measurements,
630 631 632 633
                                      eNB_id_i,
                                      symbol,
                                      i_mod,
                                      nb_rb,
634
                                      pdsch_vars[eNB_id]->log2_maxh,
635
                                      dlsch0_harq->dl_power_off);
636 637
#ifdef DEBUG_PHY
      if (symbol==5) {
638
        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);
639
       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);
640
      }
641
#endif
642 643 644
      dlsch_dual_stream_correlation(frame_parms,
                                    symbol,
                                    nb_rb,
645 646 647 648
                                    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);
649
    }  else if (dlsch0_harq->dl_power_off==1)  {
650 651 652 653 654 655
      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,
656
                                      frame_parms,
657
                                      measurements,
658 659
                                      eNB_id,
                                      symbol,
660
                                      dlsch0_harq->Qm,
661
                                      nb_rb,
662
                                      pdsch_vars[eNB_id]->log2_maxh,
663
                                      1);
Elena Lukashova's avatar
Elena Lukashova committed
664

665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
      }


    } 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
684 685
  }

686 687 688 689
// MRC


   if (frame_parms->nb_antennas_rx > 1) {
690
    if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
691
        ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
692
         (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
Xiwen JIANG's avatar
Xiwen JIANG committed
693
      if (frame_parms->nb_antenna_ports_eNB == 2) {
694
        dlsch_detection_mrc_TM34(frame_parms,
695
                                 pdsch_vars[eNB_id],
696
                                 harq_pid,
697
                                 dlsch0_harq->round,
698 699 700
                                 symbol,
                                 nb_rb,
                                 1);
701
    /*   if (symbol == 5) {
702 703
     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
704
        } */
705
      }
706
    } else {
707
      dlsch_detection_mrc(frame_parms,
708 709 710
                          pdsch_vars[eNB_id]->rxdataF_comp0,
                          pdsch_vars[eNB_id_i]->rxdataF_comp0,
                          pdsch_vars[eNB_id]->rho,
711
                          pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
712 713 714 715
                          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,
716 717
                          symbol,
                          nb_rb,
718
                          rx_type==rx_IC_single_stream);
719 720 721 722 723
    }
  }
  //  printf("Combining");
  if ((dlsch0_harq->mimo_mode == SISO) ||
      ((dlsch0_harq->mimo_mode >= UNIFORM_PRECODING11) &&
724 725
       (dlsch0_harq->mimo_mode <= PUSCH_PRECODING0)) ||
       (dlsch0_harq->mimo_mode == TM7)) {
726 727
    /*
      dlsch_siso(frame_parms,
728 729
      pdsch_vars[eNB_id]->rxdataF_comp,
      pdsch_vars[eNB_id_i]->rxdataF_comp,
730 731 732 733 734
      symbol,
      nb_rb);
    */
  } else if (dlsch0_harq->mimo_mode == ALAMOUTI) {
    dlsch_alamouti(frame_parms,
735 736 737
                   pdsch_vars[eNB_id]->rxdataF_comp0,
                   pdsch_vars[eNB_id]->dl_ch_mag0,
                   pdsch_vars[eNB_id]->dl_ch_magb0,
738 739
                   symbol,
                   nb_rb);
740 741
  }

742
  //    printf("LLR");
743 744
  if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
      ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
745
       (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))  {
746
    rxdataF_comp_ptr = pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round];
747
    dl_ch_mag_ptr = pdsch_vars[eNB_id]->dl_ch_mag1[harq_pid][round];
748 749
  }
  else {
750 751
    rxdataF_comp_ptr = pdsch_vars[eNB_id_i]->rxdataF_comp0;
    dl_ch_mag_ptr = pdsch_vars[eNB_id_i]->dl_ch_mag0;
752
    //i_mod should have been passed as a parameter
753
  }
754

Gabriel's avatar
Gabriel committed
755 756
  //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol);

757
  switch (dlsch0_harq->Qm) {
758
  case 2 :
759
    if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
760
        dlsch_qpsk_llr(frame_parms,
761 762
                       pdsch_vars[eNB_id]->rxdataF_comp0,
                       pdsch_vars[eNB_id]->llr[0],
763 764 765
                       symbol,
                       first_symbol_flag,
                       nb_rb,
766
                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
767
                       pdsch_vars[eNB_id]->llr128,
768
                       beamforming_mode);
769 770 771 772 773 774 775 776 777 778 779 780

    } else if (codeword_TB0 == -1){

        dlsch_qpsk_llr(frame_parms,
                       pdsch_vars[eNB_id]->rxdataF_comp0,
                       pdsch_vars[eNB_id]->llr[1],
                       symbol,
                       first_symbol_flag,
                       nb_rb,
                       adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
                       pdsch_vars[eNB_id]->llr128_2ndstream,
                       beamforming_mode);
781
    }
782
      else if (rx_type >= rx_IC_single_stream) {
Elena Lukashova's avatar
Elena Lukashova committed
783
        if (dlsch1_harq->Qm == 2) {
784
          dlsch_qpsk_qpsk_llr(frame_parms,
785
                              pdsch_vars[eNB_id]->rxdataF_comp0,
786
                              rxdataF_comp_ptr,
787 788
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
789
                              symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
790
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
791
                              pdsch_vars[eNB_id]->llr128);
792 793 794
          if (rx_type==rx_IC_dual_stream) {
            dlsch_qpsk_qpsk_llr(frame_parms,
                                rxdataF_comp_ptr,
795 796 797
                                pdsch_vars[eNB_id]->rxdataF_comp0,
                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                pdsch_vars[eNB_id]->llr[1],
798
                                symbol,first_symbol_flag,nb_rb,
799
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
800
                                pdsch_vars[eNB_id]->llr128_2ndstream);
801 802
          }
        }
803
        else if (dlsch1_harq->Qm == 4) {
804
          dlsch_qpsk_16qam_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_16qam_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,4,subframe,symbol),
822
                                 pdsch_vars[eNB_id]->llr128_2ndstream);
823 824 825 826
          }
        }
        else {
          dlsch_qpsk_64qam_llr(frame_parms,
827
                               pdsch_vars[eNB_id]->rxdataF_comp0,
828 829
                               rxdataF_comp_ptr,//i
                               dl_ch_mag_ptr,//i
830 831
                               pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                               pdsch_vars[eNB_id]->llr[0],
832
                               symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
833
                               adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol),
834
                               pdsch_vars[eNB_id]->llr128);
835 836 837
          if (rx_type==rx_IC_dual_stream) {
            dlsch_64qam_qpsk_llr(frame_parms,
                                 rxdataF_comp_ptr,
838
                                 pdsch_vars[eNB_id]->rxdataF_comp0,//i
839
                                 dl_ch_mag_ptr,
840 841
                                 pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                 pdsch_vars[eNB_id]->llr[1],
842
                                 symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
843
                                 adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
844
                                 pdsch_vars[eNB_id]->llr128_2ndstream);
845
          }
846
        }
847
      }
848 849
    break;
  case 4 :
850
    if ((rx_type==rx_standard ) || (codeword_TB1 == -1)) {
851
      dlsch_16qam_llr(frame_parms,
852 853 854
                      pdsch_vars[eNB_id]->rxdataF_comp0,
                      pdsch_vars[eNB_id]->llr[0],
                      pdsch_vars[eNB_id]->dl_ch_mag0,
855
                      symbol,first_symbol_flag,nb_rb,
856
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
857 858
                      pdsch_vars[eNB_id]->llr128,
                      beamforming_mode);
859 860 861 862 863 864 865 866 867
    } else if (codeword_TB0 == -1){
      dlsch_16qam_llr(frame_parms,
                      pdsch_vars[eNB_id]->rxdataF_comp0,
                      pdsch_vars[eNB_id]->llr[1],
                      pdsch_vars[eNB_id]->dl_ch_mag0,
                      symbol,first_symbol_flag,nb_rb,
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
                      pdsch_vars[eNB_id]->llr128_2ndstream,
                      beamforming_mode);
868
    }
869
    else if (rx_type >= rx_IC_single_stream) {
Elena Lukashova's avatar
Elena Lukashova committed
870
      if (dlsch1_harq->Qm == 2) {
871
        dlsch_16qam_qpsk_llr(frame_parms,
872
                             pdsch_vars[eNB_id]->rxdataF_comp0,
873
                             rxdataF_comp_ptr,//i
874 875 876
                             pdsch_vars[eNB_id]->dl_ch_mag0,
                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                             pdsch_vars[eNB_id]->llr[0],
877
                             symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
878
                             adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
879
                             pdsch_vars[eNB_id]->llr128);
880 881 882
        if (rx_type==rx_IC_dual_stream) {
          dlsch_qpsk_16qam_llr(frame_parms,
                               rxdataF_comp_ptr,
883 884 885 886
                               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],
887
                               symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
888
                               adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
889
                               pdsch_vars[eNB_id]->llr128_2ndstream);
890
        }
891
      }
Elena Lukashova's avatar
Elena Lukashova committed
892
      else if (dlsch1_harq->Qm == 4) {
893
        dlsch_16qam_16qam_llr(frame_parms,
894
                              pdsch_vars[eNB_id]->rxdataF_comp0,
895
                              rxdataF_comp_ptr,//i
896
                              pdsch_vars[eNB_id]->dl_ch_mag0,
897
                              dl_ch_mag_ptr,//i
898 899
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
900 901
                              symbol,first_symbol_flag,nb_rb,
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
902
                              pdsch_vars[eNB_id]->llr128);
903 904 905
        if (rx_type==rx_IC_dual_stream) {
          dlsch_16qam_16qam_llr(frame_parms,
                                rxdataF_comp_ptr,
906
                                pdsch_vars[eNB_id]->rxdataF_comp0,//i
907
                                dl_ch_mag_ptr,
908 909 910
                                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],
911 912
                                symbol,first_symbol_flag,nb_rb,
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
913
                                pdsch_vars[eNB_id]->llr128_2ndstream);
914
        }
915 916
      }
      else {
917
        dlsch_16qam_64qam_llr(frame_parms,
918
                              pdsch_vars[eNB_id]->rxdataF_comp0,
919
                              rxdataF_comp_ptr,//i
920
                              pdsch_vars[eNB_id]->dl_ch_mag0,
921
                              dl_ch_mag_ptr,//i
922 923
                              pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                              pdsch_vars[eNB_id]->llr[0],
924 925
                              symbol,first_symbol_flag,nb_rb,
                              adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,subframe,symbol),
926
                              pdsch_vars[eNB_id]->llr128);
927 928 929
        if (rx_type==rx_IC_dual_stream) {
          dlsch_64qam_16qam_llr(frame_parms,
                                rxdataF_comp_ptr,
930
                                pdsch_vars[eNB_id]->rxdataF_comp0,
931
                                dl_ch_mag_ptr,
932 933 934
                                pdsch_vars[eNB_id]->dl_ch_mag0,
                                pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                pdsch_vars[eNB_id]->llr[1],
935 936
                                symbol,first_symbol_flag,nb_rb,
                                adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
937
                                pdsch_vars[eNB_id]->llr128_2ndstream);
938
        }
939 940 941 942
      }
    }
    break;
  case 6 :
943
    if ((rx_type==rx_standard) || (codeword_TB1 == -1))  {
944
      dlsch_64qam_llr(frame_parms,
945 946 947 948
                      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,
949
                      symbol,first_symbol_flag,nb_rb,
950
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
951 952
                      pdsch_vars[eNB_id]->llr128,
                      beamforming_mode);
953 954 955 956 957 958 959 960 961 962
    } else if (codeword_TB0 == -1){
      dlsch_64qam_llr(frame_parms,
                      pdsch_vars[eNB_id]->rxdataF_comp0,
                      pdsch_vars[eNB_id]->llr[1],
                      pdsch_vars[eNB_id]->dl_ch_mag0,
                      pdsch_vars[eNB_id]->dl_ch_magb0,
                      symbol,first_symbol_flag,nb_rb,
                      adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol),
                      pdsch_vars[eNB_id]->llr128_2ndstream,
                      beamforming_mode);
963
    }
964
    else if (rx_type >= rx_IC_single_stream) {
965
      if (dlsch1_harq->Qm == 2) {
966
        dlsch_64qam_qpsk_llr(frame_parms,
967
                             pdsch_vars[eNB_id]->rxdataF_comp0,
968
                             rxdataF_comp_ptr,//i
969 970 971
                             pdsch_vars[eNB_id]->dl_ch_mag0,
                             pdsch_vars[eNB_id]->dl_ch_rho2_ext,
                             pdsch_vars[eNB_id]->llr[0],