slot_fep_ul.c 4.65 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Copyright(c) 1999 - 2014 Eurecom

    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.


    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.

    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 20 21 22 23
   see <http://www.gnu.org/licenses/>.

  Contact Information
  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
ghaddab's avatar
ghaddab committed
27 28

 *******************************************************************************/
29
#include "PHY/defs.h"
30
#include "PHY/extern.h"
31 32 33 34
#include "defs.h"
//#define DEBUG_FEP

int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms,
35 36 37 38 39 40
                LTE_eNB_COMMON *eNB_common_vars,
                unsigned char l,
                unsigned char Ns,
                unsigned char eNB_id,
                int no_prefix)
{
41 42 43 44 45 46 47
#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);
48
  //  unsigned int subframe_offset;
49 50 51 52
  unsigned int slot_offset;

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

53 54 55 56
  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;

57 58
  switch (frame_parms->ofdm_symbol_size) {
  case 128:
59 60
    dft = dft128;
    break;
61

62
  case 256:
63 64
    dft = dft256;
    break;
65

66
  case 512:
67 68
    dft = dft512;
    break;
69

70
  case 1024:
71 72
    dft = dft1024;
    break;
73

74 75 76 77 78
  case 1536:
    dft = dft1536;
    break;

  case 2048:
79 80
    dft = dft2048;
    break;
81

82 83 84 85 86 87 88 89
  default:
    dft = dft512;
    break;
  }

  if (no_prefix) {
    //    subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1);
    slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_tti>>1) * (Ns%2);
90
  } else {
91 92 93 94 95
    //    subframe_offset = frame_parms->samples_per_tti * (Ns>>1);
    slot_offset = (frame_parms->samples_per_tti>>1) * (Ns%2);
  }

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

100
  if (Ns<0 || Ns>=20) {
101
    LOG_E(PHY,"slot_fep: Ns must be between 0 and 19\n");
102 103 104 105
    return(-1);
  }

#ifdef DEBUG_FEP
106
  LOG_D(PHY,"slot_fep: Ns %d offset %d, symbol %d, nb_prefix_samples %d\n",Ns,slot_offset,symbol, nb_prefix_samples);
107 108
#endif

109
  for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
110
    rx_offset = slot_offset +nb_prefix_samples0;
111 112
    if (l==0) {

113 114 115 116
      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
         );
117
    } else {
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
      rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l;
      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));
      }

      if( (rx_offset & 7) != 0){
        memcpy((void *)&tmp_dft_in,
        		(void *)&eNB_common_vars->rxdata_7_5kHz[eNB_id][aa][(rx_offset % frame_length_samples)],
				frame_parms->ofdm_symbol_size*sizeof(int));
        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
         );
      }
141 142 143 144
    }
  }

#ifdef DEBUG_FEP
145
  LOG_D(PHY,"slot_fep: done\n");
146 147 148
#endif
  return(0);
}