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
/* 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;
Cedric Roux's avatar
Cedric Roux committed
51
int16_t interf_unaw_shift = 13;
52

53 54
//#define DEBUG_HARQ

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

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

Bilel's avatar
Bilel committed
61

62 63

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

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


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

90

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

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

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

114
  unsigned char aatx,aarx;
115

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

120
  uint8_t beamforming_mode;
121
  uint32_t *rballoc;
122

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


129

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

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

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

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

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

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

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

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

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

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

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

236

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


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

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

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

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

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

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

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

Elena Lukashova's avatar
Elena Lukashova committed
366

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

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

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

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

394
  if (first_symbol_flag==1) {
395 396 397
    if (beamforming_mode==0){
      if (dlsch0_harq->mimo_mode<LARGE_CDD) {
        dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
398 399 400 401
                           frame_parms,
                           avg,
                           symbol,
                           nb_rb);
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
        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);

Cedric Roux's avatar
Cedric Roux committed
422
      LOG_D(PHY,"Channel Level TM34  avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, dlsch_demod_shift %d \n", avg_0[0],
423
              avg_1[0], rx_type, rx_standard, dlsch_demod_shift);
424
        if (rx_type>rx_standard) {
Cedric Roux's avatar
Cedric Roux committed
425 426
          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;
427 428
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
429
         // printf("dlsch_demod_shift  %d\n", dlsch_demod_shift);
430 431
         }
          else {
Cedric Roux's avatar
Cedric Roux committed
432 433
          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;
434
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
Cedric Roux's avatar
Cedric Roux committed
435
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
436 437 438 439 440 441 442 443 444 445 446 447
        }
      }
      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);
448

449 450
        }
        else if (dlsch0_harq->dl_power_off==1) { //TM6
451

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

458 459 460 461
          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]);
462

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

466
        }
467
      }
468

469 470 471 472 473 474 475
    }
    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
476
#ifdef UE_DEBUG_TRACE
Gabriel's avatar
Gabriel committed
477
    LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
Gabriel's avatar
Gabriel committed
478
            frame%1024,subframe, pdsch_vars[eNB_id]->log2_maxh,
Bilel's avatar
Bilel committed
479 480 481
                                                 pdsch_vars[eNB_id]->log2_maxh0,
                                                 pdsch_vars[eNB_id]->log2_maxh1,
                                                 avg[0],avgs);
Gabriel's avatar
Gabriel committed
482
    //LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
483 484
#endif
  }
485

486 487 488 489 490 491 492
#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
493

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

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

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

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

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


    } 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
686 687
  }

688 689 690 691
// MRC


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

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

Gabriel's avatar
Gabriel committed
757 758
  //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);

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

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