dlsch_demodulation.c 180 KB
Newer Older
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3
    Copyright(c) 1999 - 2014 Eurecom
4

ghaddab's avatar
ghaddab committed
5
6
7
8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9
10


ghaddab's avatar
ghaddab committed
11
12
13
14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

ghaddab's avatar
ghaddab committed
16
    You should have received a copy of the GNU General Public License
17
18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19
   see <http://www.gnu.org/licenses/>.
20
21

  Contact Information
ghaddab's avatar
ghaddab committed
22
23
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27

28
*******************************************************************************/
29
30
31
32
33

/*! \file PHY/LTE_TRANSPORT/dlsch_demodulation.c
 * \brief Top-level routines for demodulating the PDSCH physical channel from 36-211, V8.6 2009-03
 * \author R. Knopp, F. Kaltenberger,A. Bhamri, S. Aubert
 * \date 2011
34
 * \version 0.1
35
36
37
38
39
40
41
42
43
44
 * \company Eurecom
 * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr,ankit.bhamri@eurecom.fr,sebastien.aubert@eurecom.fr
 * \note
 * \warning
 */

#include "PHY/defs.h"
#include "PHY/extern.h"
#include "defs.h"
#include "extern.h"
45
#include "PHY/sse_intrin.h"
46
47
48
49
50


#ifndef USER_MODE
#define NOCYGWIN_STATIC static
#else
51
#define NOCYGWIN_STATIC
52
53
#endif

Elena Lukashova's avatar
Elena Lukashova committed
54
55
56
//#undef LOG_D
//#define LOG_D LOG_I

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

knopp's avatar
knopp committed
60
int avg[4]; 
61
62

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

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


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

92

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

105
106
107
108
109
110
  LTE_UE_COMMON *lte_ue_common_vars  = &phy_vars_ue->lte_ue_common_vars;
  LTE_UE_PDSCH **lte_ue_pdsch_vars;
  LTE_DL_FRAME_PARMS *frame_parms    = &phy_vars_ue->lte_frame_parms;
  PHY_MEASUREMENTS *phy_measurements = &phy_vars_ue->PHY_measurements;
  LTE_UE_DLSCH_t   **dlsch_ue;

Elena Lukashova's avatar
Elena Lukashova committed
111

112
  unsigned char aatx,aarx;    
113
  unsigned short nb_rb, round;
114
  int avgs, rb;  
Elena Lukashova's avatar
Elena Lukashova committed
115
116

 LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
117
  uint32_t *rballoc;
118

119
120
121
  int32_t **rxdataF_comp_ptr;
  int32_t **dl_ch_mag_ptr;

Elena Lukashova's avatar
Elena Lukashova committed
122
123
  
  
124
125
126
127
  switch (type) {
  case SI_PDSCH:
    lte_ue_pdsch_vars = &phy_vars_ue->lte_ue_pdsch_vars_SI[eNB_id];
    dlsch_ue          = &phy_vars_ue->dlsch_ue_SI[eNB_id];
128
    dlsch0_harq       = dlsch_ue[0]->harq_processes[harq_pid];
129
    break;
130

131
132
133
  case RA_PDSCH:
    lte_ue_pdsch_vars = &phy_vars_ue->lte_ue_pdsch_vars_ra[eNB_id];
    dlsch_ue          = &phy_vars_ue->dlsch_ue_ra[eNB_id];
134
    dlsch0_harq       = dlsch_ue[0]->harq_processes[harq_pid];
135
    break;
136

137
138
139
  case PDSCH:
    lte_ue_pdsch_vars = &phy_vars_ue->lte_ue_pdsch_vars[eNB_id];
    dlsch_ue          = phy_vars_ue->dlsch_ue[eNB_id];
140
141
    dlsch0_harq       = dlsch_ue[0]->harq_processes[harq_pid];
    dlsch1_harq       = dlsch_ue[1]->harq_processes[harq_pid];
142
143
144
    break;

  default:
145
    LOG_E(PHY,"[UE %d][FATAL] Frame %d subframe %d: Unknown PDSCH format %d\n",phy_vars_ue->frame_rx,subframe,type);
146
147
148
    return(-1);
    break;
  }
149

150
151
  DevAssert(dlsch0_harq);
  round = dlsch0_harq->round;
152

153
  if (eNB_id > 2) {
jiangx's avatar
jiangx committed
154
    LOG_W(PHY,"dlsch_demodulation.c: Illegal eNB_id %d\n",eNB_id);
155
156
    return(-1);
  }
157

158
  if (!lte_ue_common_vars) {
jiangx's avatar
jiangx committed
159
    LOG_W(PHY,"dlsch_demodulation.c: Null lte_ue_common_vars\n");
160
161
162
163
    return(-1);
  }

  if (!dlsch_ue[0]) {
jiangx's avatar
jiangx committed
164
    LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n");
165
166
167
168
    return(-1);
  }

  if (!lte_ue_pdsch_vars) {
jiangx's avatar
jiangx committed
169
    LOG_W(PHY,"dlsch_demodulation.c: Null lte_ue_pdsch_vars pointer\n");
170
171
    return(-1);
  }
172

173
  if (!frame_parms) {
jiangx's avatar
jiangx committed
174
    LOG_W(PHY,"dlsch_demodulation.c: Null lte_frame_parms\n");
175
176
    return(-1);
  }
177
178
179
180
181
182
  
  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;
183

Elena Lukashova's avatar
Elena Lukashova committed
184
  if (dlsch0_harq->mimo_mode>DUALSTREAM_PUSCH_PRECODING) {
185
186
187
    LOG_E(PHY,"This transmission mode is not yet supported!\n");
    return(-1);
  }
Elena Lukashova's avatar
Elena Lukashova committed
188
189
190
  
  
  
191
192
193
194
195
196
197
198
199
200
  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);
    }
  }

  //printf("rx_pdsch: harq_pid=%d, round=%d\n",harq_pid,round);

201
202
  if (frame_parms->nb_antennas_tx_eNB>1) {
    nb_rb = dlsch_extract_rbs_dual(lte_ue_common_vars->rxdataF,
203
204
205
206
207
                                   lte_ue_common_vars->dl_ch_estimates[eNB_id],
                                   lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
                                   lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                   dlsch0_harq->pmi_alloc,
                                   lte_ue_pdsch_vars[eNB_id]->pmi_ext,
208
                                   rballoc,
209
210
211
                                   symbol,
                                   subframe,
                                   phy_vars_ue->high_speed_flag,
Elena Lukashova's avatar
Elena Lukashova committed
212
213
                                   frame_parms,
				   dlsch0_harq->mimo_mode);
214
//#ifdef DEBUG_DLSCH_MOD
215
216
217
218
    /*   printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc);
       for (rb=0;rb<nb_rb;rb++)
	  printf("%d",lte_ue_pdsch_vars[eNB_id]->pmi_ext[rb]);
       printf("\n");*/
219
//#endif
220

Elena Lukashova's avatar
Elena Lukashova committed
221
   if (rx_type==rx_IC_single_stream) {
222
      if (eNB_id_i<phy_vars_ue->n_connected_eNB) // we are in TM5
Elena Lukashova's avatar
Elena Lukashova committed
223
       nb_rb = dlsch_extract_rbs_dual(lte_ue_common_vars->rxdataF,
224
225
226
227
228
                                       lte_ue_common_vars->dl_ch_estimates[eNB_id_i],
                                       lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                       dlsch0_harq->pmi_alloc,
                                       lte_ue_pdsch_vars[eNB_id_i]->pmi_ext,
229
                                       rballoc,
230
231
232
                                       symbol,
                                       subframe,
                                       phy_vars_ue->high_speed_flag,
Elena Lukashova's avatar
Elena Lukashova committed
233
234
                                       frame_parms,
				       dlsch0_harq->mimo_mode);
Elena Lukashova's avatar
Elena Lukashova committed
235
236
     else 
       nb_rb = dlsch_extract_rbs_dual(lte_ue_common_vars->rxdataF,
237
238
239
240
241
                                       lte_ue_common_vars->dl_ch_estimates[eNB_id],
                                       lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
                                       lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                       dlsch0_harq->pmi_alloc,
                                       lte_ue_pdsch_vars[eNB_id_i]->pmi_ext,
242
                                       rballoc,
243
244
245
                                       symbol,
                                       subframe,
                                       phy_vars_ue->high_speed_flag,
Elena Lukashova's avatar
Elena Lukashova committed
246
247
                                       frame_parms,
				       dlsch0_harq->mimo_mode);
248
249
    }
  } // if n_tx>1
250
  else {
251
    nb_rb = dlsch_extract_rbs_single(lte_ue_common_vars->rxdataF,
252
253
254
255
256
                                     lte_ue_common_vars->dl_ch_estimates[eNB_id],
                                     lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
                                     lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                     dlsch0_harq->pmi_alloc,
                                     lte_ue_pdsch_vars[eNB_id]->pmi_ext,
257
                                     rballoc,
258
259
260
261
                                     symbol,
                                     subframe,
                                     phy_vars_ue->high_speed_flag,
                                     frame_parms);
Elena Lukashova's avatar
Elena Lukashova committed
262
263
   if (rx_type==rx_IC_single_stream) {
     if (eNB_id_i<phy_vars_ue->n_connected_eNB)
264
265
266
267
268
269
        nb_rb = dlsch_extract_rbs_single(lte_ue_common_vars->rxdataF,
                                         lte_ue_common_vars->dl_ch_estimates[eNB_id_i],
                                         lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
                                         lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,    
                                         dlsch0_harq->pmi_alloc,
                                         lte_ue_pdsch_vars[eNB_id_i]->pmi_ext,
270
                                         rballoc,
271
272
273
274
                                         symbol,
                                         subframe,
                                         phy_vars_ue->high_speed_flag,
                                         frame_parms);
Elena Lukashova's avatar
Elena Lukashova committed
275

276
      else 
277
278
279
280
281
282
        nb_rb = dlsch_extract_rbs_single(lte_ue_common_vars->rxdataF,
                                         lte_ue_common_vars->dl_ch_estimates[eNB_id],
                                         lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
                                         lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,    
                                         dlsch0_harq->pmi_alloc,
                                         lte_ue_pdsch_vars[eNB_id_i]->pmi_ext,
283
                                         rballoc,
284
285
286
287
                                         symbol,
                                         subframe,
                                         phy_vars_ue->high_speed_flag,
                                         frame_parms);
288
289
    }
  } //else n_tx>1
290
291

  //  printf("nb_rb = %d, eNB_id %d\n",nb_rb,eNB_id);
292
  if (nb_rb==0) {
293
    LOG_D(PHY,"dlsch_demodulation.c: nb_rb=0\n");
294
295
    return(-1);
  }
296

knopp's avatar
   
knopp committed
297
  /*
298
299
  // DL power control: Scaling of Channel estimates for PDSCH
  dlsch_scale_channel(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
300
301
302
303
  frame_parms,
  dlsch_ue,
  symbol,
  nb_rb);
knopp's avatar
   
knopp committed
304
  */
305
306
  if (first_symbol_flag==1) {
    dlsch_channel_level(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
307
308
309
310
                        frame_parms,
                        avg,
                        symbol,
                        nb_rb);
311
#ifdef DEBUG_PHY
jiangx's avatar
jiangx committed
312
    LOG_D(PHY,"[DLSCH] avg[0] %d\n",avg[0]);
313
#endif
314

315
316
317
318
    // the channel gain should be the effective gain of precoding + channel
    // however lets be more conservative and set maxh = nb_tx*nb_rx*max(h_i)
    // in case of precoding we add an additional factor of two for the precoding gain
    avgs = 0;
319

320
321
    for (aatx=0;aatx<frame_parms->nb_antennas_tx_eNB;aatx++)
      for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
322
323
        avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
    //  avgs = cmax(avgs,avg[(aarx<<1)+aatx]);
324

325
326
   lte_ue_pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2) + interf_unaw_shift_tm1_mcs[dlsch0_harq->mcs];
  // printf(" TM1 shift = %d\n",interf_unaw_shift_tm1_mcs[dlsch0_harq->mcs]); 
327
328
    // + log2_approx(frame_parms->nb_antennas_tx_eNB-1) //-1 because log2_approx counts the number of bits
    //      + log2_approx(frame_parms->nb_antennas_rx-1);
329

330
    if ((dlsch0_harq->mimo_mode>=UNIFORM_PRECODING11) &&
331
332
        (dlsch0_harq->mimo_mode< DUALSTREAM_UNIFORM_PRECODING1) &&
        (dlsch0_harq->dl_power_off==1)) // we are in TM 6
333
334
      lte_ue_pdsch_vars[eNB_id]->log2_maxh++;

335
336
    //printf("log2_maxh =%d\n",lte_ue_pdsch_vars[eNB_id]->log2_maxh);
    
337
    // this version here applies the factor .5 also to the extra terms. however, it does not work so well as the one above
338
    /* K = Nb_rx         in TM1
339
340
341
342
       Nb_tx*Nb_rx   in TM2,4,5
       Nb_tx^2*Nb_rx in TM6 */
    /*
      K = frame_parms->nb_antennas_rx*frame_parms->nb_antennas_tx_eNB; //that also covers TM1 since Nb_tx=1
343
344
345
      if ((dlsch0_harq->mimo_mode>=UNIFORM_PRECODING11) &&
      (dlsch0_harq->mimo_mode< DUALSTREAM_UNIFORM_PRECODING1) &&
      (dlsch0_harq->dl_power_off==1)) // we are in TM 6
346
347
348
349
350
351
      K *= frame_parms->nb_antennas_tx_eNB;

      lte_ue_pdsch_vars[eNB_id]->log2_maxh = (log2_approx(K*avgs)/2);
    */

#ifdef DEBUG_PHY
jiangx's avatar
jiangx committed
352
353
    LOG_D(PHY,"[DLSCH] log2_maxh = %d (%d,%d)\n",lte_ue_pdsch_vars[eNB_id]->log2_maxh,avg[0],avgs);
    LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
354
355
#endif
  }
356

357
358
359
  aatx = frame_parms->nb_antennas_tx_eNB;
  aarx = frame_parms->nb_antennas_rx;

360
  if (dlsch0_harq->mimo_mode<LARGE_CDD) {// SISO or ALAMOUTI
361
    
Elena Lukashova's avatar
Elena Lukashova committed
362
    	dlsch_channel_compensation(lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
363
364
365
366
367
368
369
370
                               lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                               lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
                               lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0,
                               lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
                               (aatx>1) ? lte_ue_pdsch_vars[eNB_id]->rho : NULL,
                               frame_parms,
                               symbol,
                               first_symbol_flag,
Elena Lukashova's avatar
Elena Lukashova committed
371
                               dlsch0_harq->Qm,
372
373
374
375
376
377
378
379
380
                               nb_rb,
                               lte_ue_pdsch_vars[eNB_id]->log2_maxh,
                               phy_measurements); // log2_maxh+I0_shift
 /*
 if (symbol == 5) {
     write_output("rxF_comp_d.m","rxF_c_d",&lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
 } */
    if ((rx_type==rx_IC_single_stream) && 
        (eNB_id_i<phy_vars_ue->n_connected_eNB)) {
Elena Lukashova's avatar
Elena Lukashova committed
381
382
         
	 dlsch_channel_compensation(lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
383
384
385
386
387
388
389
390
391
392
393
394
                                 lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                 lte_ue_pdsch_vars[eNB_id_i]->dl_ch_mag0,
                                 lte_ue_pdsch_vars[eNB_id_i]->dl_ch_magb0,
                                 lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0,
                                 (aatx>1) ? lte_ue_pdsch_vars[eNB_id_i]->rho : NULL,
                                 frame_parms,
                                 symbol,
                                 first_symbol_flag,
                                 i_mod,
                                 nb_rb,
                                 lte_ue_pdsch_vars[eNB_id]->log2_maxh,
                                 phy_measurements); // log2_maxh+I0_shift
395
#ifdef DEBUG_PHY
396

397
      if (symbol == 5) {
398
        write_output("rxF_comp_d.m","rxF_c_d",&lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
399

400
        write_output("rxF_comp_i.m","rxF_c_i",&lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);     
401
402
      }
#endif 
Elena Lukashova's avatar
Elena Lukashova committed
403
     // compute correlation between signal and interference channels
404
      dlsch_dual_stream_correlation(frame_parms,
405
406
407
408
409
410
                                    symbol,
                                    nb_rb,
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                                    lte_ue_pdsch_vars[eNB_id]->log2_maxh);
411
    }
412
    
413
  }
414
415
416
  else if ((dlsch0_harq->mimo_mode == LARGE_CDD) || 
           ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) && 
            (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
417
    //   LOG_I(PHY,"Running PDSCH RX for TM3\n");
418
	      
419
    if (frame_parms->nb_antennas_tx_eNB == 2) {
420
421
422
       
	 
	 // scaling interfering channel (following for TM56)
423
	dlsch_scale_channel(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
424
425
426
			    frame_parms,
			    dlsch_ue,
			    symbol,
427
			    nb_rb);
428
429
	
	        
430
      if (first_symbol_flag==1) {
431
432
        // effective channel of desired user is always stronger than interfering eff. channel
        dlsch_channel_level_TM34(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext, 
Elena Lukashova's avatar
Elena Lukashova committed
433
434
                                 frame_parms,
				 lte_ue_pdsch_vars[eNB_id]->pmi_ext,
Elena Lukashova's avatar
Elena Lukashova committed
435
436
437
                                 avg,
				 symbol,
				 nb_rb,
438
439
                                 dlsch0_harq->mimo_mode);
	    
Elena Lukashova's avatar
Elena Lukashova committed
440
	
441
	if (rx_type>rx_standard) {
442
443
444
445
446
447
448
449
450
451
452
453
	// !!!!! Right now in testing mode for -gS channel ONLY. We investigate if any
	// additional gain/penalty needs to be introduced in comparison with I-UA receiver
	// by comparing performances if run with -u2 and -u0.
	// this is valid only if same mcs are used. We calibrate for mcs 4. Best shift value is 3. 
	// MCS-dependent LUT will be introduced. 
	avg[0] = (log2_approx(avg[0])/2) - 13 + interf_unaw_shift;
	lte_ue_pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg[0],0);
	lte_ue_pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg[0],0); 
	
	//avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(dlsch1_harq->Qm>>1)-1];  
	//lte_ue_pdsch_vars[eNB_id]->log2_maxh0 = (log2_approx(avg[0])/2) +interf_unaw_shift_tm4_mcs[dlsch0_harq->mcs];//+offset_mumimo_llr_drange[dlsch0_harq->mcs][(get_Qm(dlsch1_harq->mcs)>>1)-1]; 
	//lte_ue_pdsch_vars[eNB_id]->log2_maxh1 = (log2_approx(avg[0])/2) +interf_unaw_shift_tm4_mcs[dlsch1_harq->mcs];//+offset_mumimo_llr_drange[dlsch1_harq->mcs][(get_Qm(dlsch0_harq->mcs)>>1)-1];
454
455
456
457
458
	//printf("TM4 I-A shift layer1 = %d\n",interf_unaw_shift_tm4_mcs[dlsch0_harq->mcs]);
	//printf("TM4 I-A shift layer2 = %d\n",interf_unaw_shift_tm4_mcs[dlsch1_harq->mcs] );
       
	
	  
459
	}
460
	else
461
462
463
	// to avoid tails in SNR/BLER curves. -13 is needed to make shift a positive number. 
	// this is valid only if same mcs are used. We calibrate for mcs 4. Best shift value is 3.
	// MCS-dependent LUT will be introduced.
464
	avg[0] = (log2_approx(avg[0])/2) - 13 + interf_unaw_shift;
Elena Lukashova's avatar
Elena Lukashova committed
465
466
	lte_ue_pdsch_vars[eNB_id]->log2_maxh0 = cmax(avg[0],0);
	lte_ue_pdsch_vars[eNB_id]->log2_maxh1 = cmax(avg[0],0);
Elena Lukashova's avatar
Elena Lukashova committed
467
	//printf("TM4 I-UA shift = %d\n",interf_unaw_shift); 
468
469
	//lte_ue_pdsch_vars[eNB_id]->log2_maxh0 = (log2_approx(avg[0])/2) +interf_unaw_shift_tm4_mcs[dlsch0_harq->mcs]; 
	//lte_ue_pdsch_vars[eNB_id]->log2_maxh1 = (log2_approx(avg[0])/2) +interf_unaw_shift_tm4_mcs[dlsch1_harq->mcs];
470
	//printf("TM4 I-UA shift layer1 = %d\n",interf_unaw_shift_tm4_mcs[dlsch0_harq->mcs]); 
471
	//printf("TM4 I-UA shift layer2 = %d\n",interf_unaw_shift_tm4_mcs[dlsch1_harq->mcs]);
472
473
474
475
476
477
478
      }
    
      dlsch_channel_compensation_TM34(frame_parms, 
                                     lte_ue_pdsch_vars[eNB_id],
                                     phy_measurements, 
                                     eNB_id, 
                                     symbol, 
Elena Lukashova's avatar
Elena Lukashova committed
479
480
                                     dlsch0_harq->Qm, 
                                     dlsch1_harq->Qm,
481
482
483
484
                                     harq_pid,
                                     dlsch0_harq->round,
                                     dlsch0_harq->mimo_mode,
                                     nb_rb, 
485
486
                                     lte_ue_pdsch_vars[eNB_id]->log2_maxh0,
				     lte_ue_pdsch_vars[eNB_id]->log2_maxh1); 
Elena Lukashova's avatar
Elena Lukashova committed
487
   	/*   
488
489
490
491
492
493
494
495
       if (symbol == 5) {
   
     write_output("rxF_comp_d00.m","rxF_c_d00",&lte_ue_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",&lte_ue_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",&lte_ue_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",&lte_ue_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

   
Elena Lukashova's avatar
Elena Lukashova committed
496
	}*/
497
      // compute correlation between signal and interference channels (rho12 and rho21)
Elena Lukashova's avatar
Elena Lukashova committed
498
499
      
	dlsch_dual_stream_correlation(frame_parms,
500
501
502
503
504
                                    symbol,
                                    nb_rb,
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                    &(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
505
			   	    lte_ue_pdsch_vars[eNB_id]->log2_maxh0);
506
507

      //to be optimized (just take complex conjugate)
Elena Lukashova's avatar
Elena Lukashova committed
508

509
      dlsch_dual_stream_correlation(frame_parms,
510
511
512
513
                                    symbol,
                                    nb_rb,
                                    &(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]),
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
514
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_rho2_ext,
515
				    lte_ue_pdsch_vars[eNB_id]->log2_maxh1);
516
517
      //printf("TM3 log2_maxh : %d\n",lte_ue_pdsch_vars[eNB_id]->log2_maxh);

Elena Lukashova's avatar
Elena Lukashova committed
518
   }
519
      else {
Elena Lukashova's avatar
Elena Lukashova committed
520
     LOG_E(PHY, "only 2 tx antennas supported for TM3\n");
521
      return(-1);
522
523
    }
  }
524
  else if (dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) {// single-layer precoding (TM5, TM6)
Elena Lukashova's avatar
Elena Lukashova committed
525
   //    printf("Channel compensation for precoding\n");
526
    if ((rx_type==rx_IC_single_stream) && (eNB_id_i==phy_vars_ue->n_connected_eNB)) {  // TM5 two-user
527
528
529

      // Scale the channel estimates for interfering stream

530
      dlsch_scale_channel(lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
531
532
533
534
                          frame_parms,
                          dlsch_ue,
                          symbol,
                          nb_rb);     
535
536
537

      /* compute new log2_maxh for effective channel */
      if (first_symbol_flag==1) {
Elena Lukashova's avatar
Elena Lukashova committed
538

539
        // effective channel of desired user is always stronger than interfering eff. channel
Elena Lukashova's avatar
Elena Lukashova committed
540
541
542
543
544
545
       dlsch_channel_level_TM56(lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
				frame_parms,
				lte_ue_pdsch_vars[eNB_id]->pmi_ext,
				avg,
				symbol,
				nb_rb);
546

547
548
        //    LOG_D(PHY,"llr_offset = %d\n",offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1]);
        avg[0] = log2_approx(avg[0]) - 13 + offset_mumimo_llr_drange[dlsch0_harq->mcs][(i_mod>>1)-1];
549

550
551
        lte_ue_pdsch_vars[eNB_id]->log2_maxh = cmax(avg[0],0);
        //printf("log1_maxh =%d\n",lte_ue_pdsch_vars[eNB_id]->log2_maxh);
552
553
554
555
556
557
558
559
560
561
562
563
      }

      dlsch_channel_compensation_TM56(lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0,
                                      lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
                                      lte_ue_pdsch_vars[eNB_id]->pmi_ext,
                                      frame_parms,
                                      phy_measurements,
                                      eNB_id,
                                      symbol,
564
                                      dlsch0_harq->Qm,
565
566
                                      nb_rb,
                                      lte_ue_pdsch_vars[eNB_id]->log2_maxh,
567
                                      dlsch0_harq->dl_power_off);
568
569
570
571

      // if interference source is MU interference, assume opposite precoder was used at eNB

      // calculate opposite PMI
572
      for (rb=0; rb<nb_rb; rb++) {
Elena Lukashova's avatar
Elena Lukashova committed
573

574
575
576
577
        switch(lte_ue_pdsch_vars[eNB_id]->pmi_ext[rb]) {
        case 0:
          lte_ue_pdsch_vars[eNB_id_i]->pmi_ext[rb]=1;
          break;
Elena Lukashova's avatar
Elena Lukashova committed
578
       case 1:
579
580
          lte_ue_pdsch_vars[eNB_id_i]->pmi_ext[rb]=0;
          break;
Elena Lukashova's avatar
Elena Lukashova committed
581
       case 2:
582
583
584
585
586
587
          lte_ue_pdsch_vars[eNB_id_i]->pmi_ext[rb]=3;
          break;
        case 3:
          lte_ue_pdsch_vars[eNB_id_i]->pmi_ext[rb]=2;
          break;
        }
588

Elena Lukashova's avatar
Elena Lukashova committed
589
       //  if (rb==0)
590
591
        //    printf("pmi %d, pmi_i %d\n",lte_ue_pdsch_vars[eNB_id]->pmi_ext[rb],lte_ue_pdsch_vars[eNB_id_i]->pmi_ext[rb]);

592
593
      }

594
595
596
597
598
599
600
601
602
603
604
605
606
      dlsch_channel_compensation_TM56(lte_ue_pdsch_vars[eNB_id_i]->rxdataF_ext,
                                      lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext,
                                      lte_ue_pdsch_vars[eNB_id_i]->dl_ch_mag0,
                                      lte_ue_pdsch_vars[eNB_id_i]->dl_ch_magb0,
                                      lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0,
                                      lte_ue_pdsch_vars[eNB_id_i]->pmi_ext,
                                      frame_parms,
                                      phy_measurements,
                                      eNB_id_i,
                                      symbol,
                                      i_mod,
                                      nb_rb,
                                      lte_ue_pdsch_vars[eNB_id]->log2_maxh,
607
                                      dlsch0_harq->dl_power_off);
608

Elena Lukashova's avatar
Elena Lukashova committed
609

610
#ifdef DEBUG_PHY
611

612
      if (symbol==5) {
613
        write_output("rxF_comp_d.m","rxF_c_d",&lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
Elena Lukashova's avatar
Elena Lukashova committed
614
       write_output("rxF_comp_i.m","rxF_c_i",&lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
615
      }
616
#endif
617
      dlsch_dual_stream_correlation(frame_parms, 
618
619
620
621
622
623
                                    symbol, 
                                    nb_rb, 
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext, 
                                    lte_ue_pdsch_vars[eNB_id_i]->dl_ch_estimates_ext, 
                                    lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], 
                                    lte_ue_pdsch_vars[eNB_id]->log2_maxh);
624

625
    } else {
626
      dlsch_channel_compensation_TM56(lte_ue_pdsch_vars[eNB_id]->rxdataF_ext,
627
628
629
630
631
632
633
634
635
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_estimates_ext,
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
                                      lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0,
                                      lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
                                      lte_ue_pdsch_vars[eNB_id]->pmi_ext,
                                      frame_parms,
                                      phy_measurements,
                                      eNB_id,
                                      symbol,
636
                                      dlsch0_harq->Qm,
637
638
639
                                      nb_rb,
                                      lte_ue_pdsch_vars[eNB_id]->log2_maxh,
                                      1);
Elena Lukashova's avatar
Elena Lukashova committed
640

641
642
643
644
    }
  }

  //  printf("MRC\n");
645
  if (frame_parms->nb_antennas_rx > 1) {
646
647
648
    if ((dlsch0_harq->mimo_mode == LARGE_CDD) ||
        ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) && 
         (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING))){  // TM3 or TM4
649
      if (frame_parms->nb_antennas_tx_eNB == 2) {
Elena Lukashova's avatar
Elena Lukashova committed
650

651
652
653
654
655
656
657
	dlsch_detection_mrc_TM34(frame_parms, 
                                 lte_ue_pdsch_vars[eNB_id],
				 harq_pid,
                                 dlsch0_harq->round,
				 symbol,
				 nb_rb,
				 1);
658
      }
659
660
    } else {

661
      dlsch_detection_mrc(frame_parms,
662
663
664
665
666
667
668
669
670
671
672
                          lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
                          lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0,
                          lte_ue_pdsch_vars[eNB_id]->rho,
                          lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
                          lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
                          lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0,
                          lte_ue_pdsch_vars[eNB_id_i]->dl_ch_mag0,
                          lte_ue_pdsch_vars[eNB_id_i]->dl_ch_magb0,
                          symbol,
                          nb_rb,
                          rx_type==rx_IC_single_stream); 
673
674
    }
  }
675

676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
  //  printf("Combining");
  if ((dlsch0_harq->mimo_mode == SISO) ||
      ((dlsch0_harq->mimo_mode >= UNIFORM_PRECODING11) &&
       (dlsch0_harq->mimo_mode <= PUSCH_PRECODING0))) {

    /*
      dlsch_siso(frame_parms,
      lte_ue_pdsch_vars[eNB_id]->rxdataF_comp,
      lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp,
      symbol,
      nb_rb);
    */
  } else if (dlsch0_harq->mimo_mode == ALAMOUTI) {

    dlsch_alamouti(frame_parms,
691
692
693
694
695
                   lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0,
                   lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0,
                   lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0,
                   symbol,
                   nb_rb);
Elena Lukashova's avatar
Elena Lukashova committed
696
        
697
  } 
698
          
699
700
701
702
703
704
  //    printf("LLR");
  if ((dlsch0_harq->mimo_mode == LARGE_CDD) || 
      ((dlsch0_harq->mimo_mode >=DUALSTREAM_UNIFORM_PRECODING1) && 
       (dlsch0_harq->mimo_mode <=DUALSTREAM_PUSCH_PRECODING)))  {
    rxdataF_comp_ptr = lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[harq_pid][round];
    dl_ch_mag_ptr = lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1;
705
706
  }
  else {
707
708
709
    rxdataF_comp_ptr = lte_ue_pdsch_vars[eNB_id_i]->rxdataF_comp0;
    dl_ch_mag_ptr = lte_ue_pdsch_vars[eNB_id_i]->dl_ch_mag0;
    //i_mod should have been passed as a parameter
710
  }
711

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

955
    }
Elena Lukashova's avatar
Elena Lukashova committed
956

957
    break;
958
959
960
961
962
963
964
965
966
967
968
969
970
  default:
    LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
    return(-1);
    break;
  }

  switch (get_Qm(dlsch1_harq->mcs)) {
  case 2 : 
    if (rx_type==rx_standard) {
        dlsch_qpsk_llr(frame_parms,
                       rxdataF_comp_ptr,
                       lte_ue_pdsch_vars[eNB_id]->llr[1],
                       symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
971
                       adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,subframe,symbol),
972
                       lte_ue_pdsch_vars[eNB_id]->llr128_2ndstream);
973
    }
974
975
976
977
978
979
980
981
    break;
  case 4:
    if (rx_type==rx_standard) {
      dlsch_16qam_llr(frame_parms,
                      rxdataF_comp_ptr,
                      lte_ue_pdsch_vars[eNB_id]->llr[1],
                      lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
                      symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
982
                      adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,subframe,symbol),
983
                      lte_ue_pdsch_vars[eNB_id]->llr128_2ndstream);
984
    }
985

986
    break;
987

988
  case 6 :
989
    if (rx_type==rx_standard) {
990
      dlsch_64qam_llr(frame_parms,
991
992
993
994
995
                      rxdataF_comp_ptr,
                      lte_ue_pdsch_vars[eNB_id]->llr[1],
                      lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1,
                      lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1,
                      symbol,first_symbol_flag,nb_rb,
Elena Lukashova's avatar
Elena Lukashova committed
996
                      adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol),
997
                      lte_ue_pdsch_vars[eNB_id]->llr128_2ndstream);
Elena Lukashova's avatar
Elena Lukashova committed
998
999
  }

1000
    break;
For faster browsing, not all history is shown. View entire blame