slot_fep_ul.c 4.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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
 */

22
#include "PHY/defs.h"
23
#include "PHY/extern.h"
24 25 26
#include "defs.h"
//#define DEBUG_FEP

27
int slot_fep_ul(RU_t *ru,
28 29 30 31
                unsigned char l,
                unsigned char Ns,
                int no_prefix)
{
32 33 34 35
#ifdef DEBUG_FEP
  char fname[40], vname[40];
#endif
  unsigned char aa;
36 37 38 39 40
  RU_COMMON *common=&ru->common;
  LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
  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);
41
  //  unsigned int subframe_offset;
42 43
  unsigned int slot_offset;

44

45 46
  void (*dft)(int16_t *,int16_t *, int);

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

51
  switch (fp->ofdm_symbol_size) {
52
  case 128:
53 54
    dft = dft128;
    break;
55

56
  case 256:
57 58
    dft = dft256;
    break;
59

60
  case 512:
61 62
    dft = dft512;
    break;
63

64
  case 1024:
65 66
    dft = dft1024;
    break;
67

68 69 70 71 72
  case 1536:
    dft = dft1536;
    break;

  case 2048:
73 74
    dft = dft2048;
    break;
75

76 77 78 79 80 81 82
  default:
    dft = dft512;
    break;
  }

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

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

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

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

103
  for (aa=0; aa<ru->nb_rx; aa++) {
104
    rx_offset = slot_offset +nb_prefix_samples0;
105
    if (l==0) {
106 107 108 109
#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
110
      dft( (int16_t *)&common->rxdata_7_5kHz[aa][rx_offset],
111
           (int16_t *)&common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
112 113
           1
         );
114
    } else {
115
      
116
      rx_offset += (fp->ofdm_symbol_size+nb_prefix_samples)*l;
117 118
      // check for 256-bit alignment of input buffer and do DFT directly, else do via intermediate buffer
      if( (rx_offset & 15) != 0){
119
        memcpy((void *)&tmp_dft_in,
120
	       (void *)&common->rxdata_7_5kHz[aa][(rx_offset % frame_length_samples)],
121
	       fp->ofdm_symbol_size*sizeof(int));
122
        dft( (short *) tmp_dft_in,
123
             (short*)  &common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
124 125 126 127
             1
           );
      }
      else{
128
      dft( (short *)&common->rxdata_7_5kHz[aa][rx_offset],
129
           (short*)&common->rxdataF[aa][fp->ofdm_symbol_size*symbol],
130 131 132
           1
         );
      }
133 134 135 136
    }
  }

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