slot_fep_ul.c 4.16 KB
Newer Older
1 2 3 4 5
/*
 * 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
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 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
 */

22
#include "PHY/defs_eNB.h"
23 24
//#include "PHY/phy_extern.h"
//#include "modulation_eNB.h"
25 26
//#define DEBUG_FEP

27 28


29
int slot_fep_ul(RU_t *ru,
30 31 32 33
                unsigned char l,
                unsigned char Ns,
                int no_prefix)
{
34 35 36 37
#ifdef DEBUG_FEP
  char fname[40], vname[40];
#endif
  unsigned char aa;
38
  RU_COMMON *common=&ru->common;
39
  LTE_DL_FRAME_PARMS *fp = ru->frame_parms;
40 41 42
  unsigned char symbol = l+((7-fp->Ncp)*(Ns&1)); ///symbol within sub-frame
  unsigned int nb_prefix_samples = (no_prefix ? 0 : fp->nb_prefix_samples);
  unsigned int nb_prefix_samples0 = (no_prefix ? 0 : fp->nb_prefix_samples0);
43
  //  unsigned int subframe_offset;
44 45
  unsigned int slot_offset;

46

frtabu's avatar
frtabu committed
47
  dft_size_idx_t dftsize;
48

49
  int tmp_dft_in[2048] __attribute__ ((aligned (32)));  // This is for misalignment issues for 6 and 15 PRBs
50
  unsigned int frame_length_samples = fp->samples_per_tti * 10;
51 52
  unsigned int rx_offset;

53
  switch (fp->ofdm_symbol_size) {
54
  case 128:
frtabu's avatar
frtabu committed
55
    dftsize = DFT_128;
56
    break;
57

58
  case 256:
frtabu's avatar
frtabu committed
59
    dftsize = DFT_256;
60
    break;
61

62
  case 512:
frtabu's avatar
frtabu committed
63
    dftsize = DFT_512;
64
    break;
65

66
  case 1024:
frtabu's avatar
frtabu committed
67
    dftsize = DFT_1024;
68
    break;
69

70
  case 1536:
frtabu's avatar
frtabu committed
71
    dftsize = DFT_1536;
72 73 74
    break;

  case 2048:
frtabu's avatar
frtabu committed
75
    dftsize = DFT_2048;
76
    break;
77

78
  default:
frtabu's avatar
frtabu committed
79
    dftsize = DFT_512;
80 81 82 83 84
    break;
  }

  if (no_prefix) {
    //    subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1);
85
    slot_offset = fp->ofdm_symbol_size * (fp->symbols_per_tti>>1) * (Ns&1);
86
  } else {
87
    //    subframe_offset = frame_parms->samples_per_tti * (Ns>>1);
88
    slot_offset = (fp->samples_per_tti>>1) * (Ns&1);
89 90
  }

91 92
  if (l<0 || l>=7-fp->Ncp) {
    LOG_E(PHY,"slot_fep: l must be between 0 and %d\n",7-fp->Ncp);
93 94
    return(-1);
  }
95

96
  if (Ns<0 || Ns>=20) {
97
    LOG_E(PHY,"slot_fep: Ns must be between 0 and 19\n");
98 99 100 101
    return(-1);
  }

#ifdef DEBUG_FEP
102
  LOG_D(PHY,"slot_fep: Ns %d offset %d, symbol %d, nb_prefix_samples %d\n",Ns,slot_offset,symbol, nb_prefix_samples);
103 104
#endif

105
  for (aa=0; aa<ru->nb_rx; aa++) {
106
    rx_offset = slot_offset +nb_prefix_samples0;
107
    if (l==0) {
108 109 110 111
#ifdef DEBUG_FEP
      LOG_D(PHY,"slot_fep: symbol 0 %d dB\n",
	    dB_fixed(signal_energy(&common->rxdata_7_5kHz[aa][rx_offset],fp->ofdm_symbol_size)));
#endif
frtabu's avatar
frtabu committed
112
      dft( dftsize,(int16_t *)&common->rxdata_7_5kHz[aa][rx_offset],
113
           (int16_t *)&common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
114 115
           1
         );
116
    } else {
117
      
118
      rx_offset += (fp->ofdm_symbol_size+nb_prefix_samples)*l;
119 120
      // check for 256-bit alignment of input buffer and do DFT directly, else do via intermediate buffer
      if( (rx_offset & 15) != 0){
121
        memcpy((void *)&tmp_dft_in,
122
	       (void *)&common->rxdata_7_5kHz[aa][(rx_offset % frame_length_samples)],
123
	       fp->ofdm_symbol_size*sizeof(int));
frtabu's avatar
frtabu committed
124
        dft( dftsize,(short *) tmp_dft_in,
125
             (short*)  &common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
126 127 128 129
             1
           );
      }
      else{
frtabu's avatar
frtabu committed
130
      dft( dftsize,(short *)&common->rxdata_7_5kHz[aa][rx_offset],
131
           (short*)&common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
132 133 134
           1
         );
      }
135 136 137 138
    }
  }

#ifdef DEBUG_FEP
139
  //  LOG_D(PHY,"slot_fep: done\n");
140 141 142
#endif
  return(0);
}