slot_fep_ul.c 4.56 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 27
#include "defs.h"
//#define DEBUG_FEP

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

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

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

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

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

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

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

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

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

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

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

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

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

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

102
  for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
103
    rx_offset = slot_offset +nb_prefix_samples0;
104 105
    if (l==0) {

106 107 108 109
      dft( (int16_t *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][rx_offset],
           (int16_t *)&eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
           1
         );
110
    } else {
111
      
112
      rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l;
113
      /* should never happen for eNB
114 115 116 117 118 119
      if(rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
      {
        memcpy((void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][frame_length_samples],
               (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][0],
               frame_parms->ofdm_symbol_size*sizeof(int));
      }
120
      */
121

122 123
      // check for 256-bit alignment of input buffer and do DFT directly, else do via intermediate buffer
      if( (rx_offset & 15) != 0){
124
        memcpy((void *)&tmp_dft_in,
125 126
	       (void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][(rx_offset % frame_length_samples)],
	       frame_parms->ofdm_symbol_size*sizeof(int));
127 128 129 130 131 132 133 134 135 136 137
        dft( (short *) tmp_dft_in,
             (short*)  &eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
             1
           );
      }
      else{
      dft( (short *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][rx_offset],
           (short*)&eNB_common_vars->rxdataF[eNB_id][aa][frame_parms->ofdm_symbol_size*symbol],
           1
         );
      }
138 139 140 141
    }
  }

#ifdef DEBUG_FEP
142
  LOG_D(PHY,"slot_fep: done\n");
143 144 145
#endif
  return(0);
}