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

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

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

45
extern int16_t dlsch_demod_shift;
46 47
//#define DEBUG_HARQ

48 49 50
//#undef LOG_D
//#define LOG_D LOG_I

51
//#define DEBUG_PHY 1
52
//#define DEBUG_DLSCH_DEMOD 1
53

54
int avg[4];
55 56
int avg_0[2];
int avg_1[2];
57 58

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

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


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

88

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

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

Elena Lukashova's avatar
Elena Lukashova committed
108

109
  unsigned char aatx,aarx;
110

111
  unsigned short nb_rb = 0, round;
112
  int avgs, rb;
113
  LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
Elena Lukashova's avatar
Elena Lukashova committed
114

115
  uint8_t beamforming_mode;
116
  uint32_t *rballoc;
117

118 119
  int32_t **rxdataF_comp_ptr;
  int32_t **dl_ch_mag_ptr;
120 121 122 123
  int32_t codeword_TB0;
  int32_t codeword_TB1;


124

125 126
  switch (type) {
  case SI_PDSCH:
127
    pdsch_vars = &ue->pdsch_vars_SI[eNB_id];
128 129
    dlsch = &ue->dlsch_SI[eNB_id];
    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
130
    beamforming_mode  = 0;
131
    break;
132

133
  case RA_PDSCH:
134
    pdsch_vars = &ue->pdsch_vars_ra[eNB_id];
135 136
    dlsch = &ue->dlsch_ra[eNB_id];
    dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
137
    beamforming_mode  = 0;
138
    break;
139

140
  case PDSCH:
141
    pdsch_vars = &ue->pdsch_vars[subframe&0x1][eNB_id];
Bilel's avatar
Bilel committed
142 143 144 145 146 147
    dlsch = ue->dlsch[subframe&0x1][eNB_id];
    LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d,  harq status %d.%d \n",
                   frame,subframe,symbol,harq_pid,
                   dlsch[0]->harq_processes[harq_pid]->status,
                   dlsch[1]->harq_processes[harq_pid]->status);

148 149 150 151 152 153
    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];
154
    }
155 156 157 158 159 160
     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;
161
    }
162 163 164
     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
165 166
      dlsch0_harq  = dlsch[1]->harq_processes[harq_pid];
      dlsch1_harq  = NULL;
167
      codeword_TB0 = -1;
168
    }
169 170 171 172
    else {
      LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: no active DLSCH\n",ue->proc.proc_rxtx[0].frame_rx,subframe);
      return(-1);
    }
173
    beamforming_mode  = ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id];
174 175 176
    break;

  default:
Cedric Roux's avatar
Cedric Roux committed
177
    LOG_E(PHY,"[UE][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",ue->proc.proc_rxtx[0].frame_rx,subframe,type);
178 179 180
    return(-1);
    break;
  }
181 182 183 184
#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
185

186 187
  DevAssert(dlsch0_harq);
  round = dlsch0_harq->round;
188

189
  if (eNB_id > 2) {
jiangx's avatar
jiangx committed
190
    LOG_W(PHY,"dlsch_demodulation.c: Illegal eNB_id %d\n",eNB_id);
191 192
    return(-1);
  }
193

194 195
  if (!common_vars) {
    LOG_W(PHY,"dlsch_demodulation.c: Null common_vars\n");
196 197 198
    return(-1);
  }

199
  if (!dlsch[0]) {
jiangx's avatar
jiangx committed
200
    LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n");
201 202 203
    return(-1);
  }

204 205
  if (!pdsch_vars) {
    LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n");
206 207
    return(-1);
  }
208

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

214 215 216 217 218
  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;
219

220

221
  if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
222 223 224
    LOG_E(PHY,"This transmission mode is not yet supported!\n");
    return(-1);
  }
225 226 227



228 229 230 231 232 233 234 235
  if ((dlsch0_harq->mimo_mode==LARGE_CDD) || ((dlsch0_harq->mimo_mode>=DUALSTREAM_UNIFORM_PRECODING1) && (dlsch0_harq->mimo_mode<=DUALSTREAM_PUSCH_PRECODING)))  {
    DevAssert(dlsch1_harq);
    if (eNB_id!=eNB_id_i) {
      LOG_E(PHY,"TM3/TM4 requires to set eNB_id==eNB_id_i!\n");
      return(-1);
    }
  }

Xiwen JIANG's avatar
Xiwen JIANG committed
236
  if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) {
237
#ifdef DEBUG_DLSCH_MOD
238
    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]);
239
#endif
240

241 242
    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],
243 244
                                   pdsch_vars[eNB_id]->rxdataF_ext,
                                   pdsch_vars[eNB_id]->dl_ch_estimates_ext,
245
                                   dlsch0_harq->pmi_alloc,
246
                                   pdsch_vars[eNB_id]->pmi_ext,
247
                                   rballoc,
248 249
                                   symbol,
                                   subframe,
250
                                   ue->high_speed_flag,
251
                                   frame_parms,
252
                                   dlsch0_harq->mimo_mode);
253
//#ifdef DEBUG_DLSCH_MOD
254 255
    /*   printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
       for (rb=0;rb<nb_rb;rb++)
256
          printf("%d",pdsch_vars[eNB_id]->pmi_ext[rb]);
257
       printf("\n");*/
258
//#endif
259

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

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

338
  } else if(beamforming_mode>7) {
339
    LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
340
  }
341

Bilel's avatar
Bilel committed
342
  //printf("nb_rb = %d, eNB_id %d\n",nb_rb,eNB_id);
343
  if (nb_rb==0) {
344
    LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n");
345 346
    return(-1);
  }
347

Elena Lukashova's avatar
Elena Lukashova committed
348

349
#ifdef DEBUG_PHY
350 351
  LOG_D(PHY,"[DLSCH] log2_maxh = %d (%d,%d)\n",pdsch_vars[eNB_id]->log2_maxh,avg[0],avgs);
  LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
352 353
#endif

354
  aatx = frame_parms->nb_antenna_ports_eNB;
Elena Lukashova's avatar
Elena Lukashova committed
355 356
  aarx = frame_parms->nb_antennas_rx;

357
  dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
358 359 360 361
                      frame_parms,
                      dlsch,
                      symbol,
                      nb_rb);
362

363 364 365 366 367 368
  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
  {
369
    dlsch_scale_channel(pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
370
                        frame_parms,
371
                        dlsch,
372 373
                        symbol,
                        nb_rb);
374
  }
375

376
  if (first_symbol_flag==1) {
377 378 379
    if (beamforming_mode==0){
      if (dlsch0_harq->mimo_mode<LARGE_CDD) {
        dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
380 381 382 383
                           frame_parms,
                           avg,
                           symbol,
                           nb_rb);
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
        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
404 405
      LOG_D(PHY,"Channel Level TM34  avg_0 %d, avg_1 %d, rx_type %d, rx_standard %d, interf_unaw_shift %d \n", avg_0[0],
              avg_1[0], rx_type, rx_standard, interf_unaw_shift);
406
        if (rx_type>rx_standard) {
407 408
          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;
409 410
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
Bilel's avatar
Bilel committed
411 412
          //printf("TM4 I-A log2_maxh0 = %d\n", pdsch_vars[eNB_id]->log2_maxh0);
          //printf("TM4 I-A log2_maxh1 = %d\n", pdsch_vars[eNB_id]->log2_maxh1);
413 414 415 416 417 418
         }
          else {
          avg_0[0] = (log2_approx(avg_0[0])/2) - 13 + interf_unaw_shift;
          avg_1[0] = (log2_approx(avg_1[0])/2) - 13 + interf_unaw_shift;
          pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg_0[0],0);
          pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg_1[0],0);
Bilel's avatar
Bilel committed
419 420
          //printf("TM4 I-UA log2_maxh0 = %d\n", pdsch_vars[eNB_id]->log2_maxh0);
          //printf("TM4 I-UA log2_maxh1 = %d\n", pdsch_vars[eNB_id]->log2_maxh1);
421 422 423 424 425 426 427 428 429 430 431 432
        }
      }
      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);
433

434 435
        }
        else if (dlsch0_harq->dl_power_off==1) { //TM6
436

437 438 439 440 441
          dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                   frame_parms,
                                   avg,
                                   symbol,
                                   nb_rb);
442

443 444 445 446
          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]);
447

448 449
          pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + 1;
          pdsch_vars[eNB_id]->log2_maxh++;
450

451
        }
452
      }
453

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

470 471 472 473 474 475 476
#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
477

478 479
// Now channel compensation
  if (dlsch0_harq->mimo_mode<LARGE_CDD) {
480 481 482 483 484 485
    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,
486 487 488
                               frame_parms,
                               symbol,
                               first_symbol_flag,
Elena Lukashova's avatar
Elena Lukashova committed
489
                               dlsch0_harq->Qm,
490
                               nb_rb,
491
                               pdsch_vars[eNB_id]->log2_maxh,
492
                               measurements); // log2_maxh+I0_shift
493
 /*if (symbol == 5) {
494
     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);
495
 } */
496
    if ((rx_type==rx_IC_single_stream) &&
497
        (eNB_id_i<ue->n_connected_eNB)) {
498
         dlsch_channel_compensation(pdsch_vars[eNB_id_i]->rxdataF_ext,
499 500 501 502 503
                                 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,
504 505 506 507 508
                                 frame_parms,
                                 symbol,
                                 first_symbol_flag,
                                 i_mod,
                                 nb_rb,
509
                                 pdsch_vars[eNB_id]->log2_maxh,
510
                                 measurements); // log2_maxh+I0_shift
511 512
#ifdef DEBUG_PHY
      if (symbol == 5) {
513
        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);
514
        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);
515
      }
516
#endif
517

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

573 574 575
    } 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,
576 577 578 579 580
                                      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,
581
                                      frame_parms,
582
                                      measurements,
583 584
                                      eNB_id,
                                      symbol,
585
                                      dlsch0_harq->Qm,
586
                                      nb_rb,
587
                                      pdsch_vars[eNB_id]->log2_maxh,
588
                                      dlsch0_harq->dl_power_off);
589

590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
        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
605
       //  if (rb==0)
606
        //    printf("pmi %d, pmi_i %d\n",pdsch_vars[eNB_id]->pmi_ext[rb],pdsch_vars[eNB_id_i]->pmi_ext[rb]);
607
      }
608 609 610 611 612 613
      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,
614
                                      frame_parms,
615
                                      measurements,
616 617 618 619
                                      eNB_id_i,
                                      symbol,
                                      i_mod,
                                      nb_rb,
620
                                      pdsch_vars[eNB_id]->log2_maxh,
621
                                      dlsch0_harq->dl_power_off);
622 623
#ifdef DEBUG_PHY
      if (symbol==5) {
624
        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);
625
       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);
626
      }
627
#endif
628 629 630
      dlsch_dual_stream_correlation(frame_parms,
                                    symbol,
                                    nb_rb,
631 632 633 634
                                    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);
635
    }  else if (dlsch0_harq->dl_power_off==1)  {
636 637 638 639 640 641
      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,
642
                                      frame_parms,
643
                                      measurements,
644 645
                                      eNB_id,
                                      symbol,
646
                                      dlsch0_harq->Qm,
647
                                      nb_rb,
648
                                      pdsch_vars[eNB_id]->log2_maxh,
649
                                      1);
Elena Lukashova's avatar
Elena Lukashova committed
650

651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
      }


    } 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
670 671
  }

672 673 674 675
// MRC


   if (frame_parms->nb_antennas_rx > 1) {
676
    if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
677
        ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) &&
678
         (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
Xiwen JIANG's avatar
Xiwen JIANG committed
679
      if (frame_parms->nb_antenna_ports_eNB == 2) {
680
        dlsch_detection_mrc_TM34(frame_parms,
681
                                 pdsch_vars[eNB_id],
682
                                 harq_pid,
683
                                 dlsch0_harq->round,
684 685 686
                                 symbol,
                                 nb_rb,
                                 1);
687
    /*   if (symbol == 5) {
688 689
     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
690
        } */
691
      }
692
    } else {
693
      dlsch_detection_mrc(frame_parms,
694 695 696
                          pdsch_vars[eNB_id]->rxdataF_comp0,
                          pdsch_vars[eNB_id_i]->rxdataF_comp0,
                          pdsch_vars[eNB_id]->rho,
697
                          pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
698 699 700 701
                          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,
702 703
                          symbol,
                          nb_rb,
704
                          rx_type==rx_IC_single_stream);
705 706 707 708 709
    }
  }
  //  printf("Combining");
  if ((dlsch0_harq->mimo_mode == SISO) ||
      ((dlsch0_harq->mimo_mode >= UNIFORM_PRECODING11) &&
710 711
       (dlsch0_harq->mimo_mode <= PUSCH_PRECODING0)) ||
       (dlsch0_harq->mimo_mode == TM7)) {
712 713
    /*
      dlsch_siso(frame_parms,
714 715
      pdsch_vars[eNB_id]->rxdataF_comp,
      pdsch_vars[eNB_id_i]->rxdataF_comp,
716 717 718 719 720
      symbol,
      nb_rb);
    */
  } else if (dlsch0_harq->mimo_mode == ALAMOUTI) {
    dlsch_alamouti(frame_parms,
721 722 723
                   pdsch_vars[eNB_id]->rxdataF_comp0,
                   pdsch_vars[eNB_id]->dl_ch_mag0,
                   pdsch_vars[eNB_id]->dl_ch_magb0,
724 725
                   symbol,
                   nb_rb);
726 727
  }

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

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