pss.c 3.65 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

ghaddab's avatar
ghaddab committed
28
 *******************************************************************************/
29 30 31 32 33 34 35 36 37 38 39 40 41 42

/*! \file PHY/LTE_TRANSPORT/pss.c
* \brief Top-level routines for generating primary synchronization signal (PSS) V8.6 2009-03
* \author F. Kaltenberger, O. Tonelli, R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it,knopp@eurecom.fr
* \note
* \warning
*/
/* file: pss.c
   purpose: generate the primary synchronization signals of LTE
   author: florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it
43
   date: 21.10.2009
44 45 46 47 48 49
*/

//#include "defs.h"
#include "PHY/defs.h"
#include "PHY/extern.h"

50
int generate_pss(int32_t **txdataF,
51 52 53 54 55
                 short amp,
                 LTE_DL_FRAME_PARMS *frame_parms,
                 unsigned short symbol,
                 unsigned short slot_offset)
{
56 57

  unsigned int Nsymb;
Raymond Knopp's avatar
 
Raymond Knopp committed
58
  unsigned short k,m,aa,a;
59
  uint8_t Nid2;
60
  short *primary_sync;
Raymond Knopp's avatar
 
Raymond Knopp committed
61

62 63 64 65 66 67 68

  Nid2 = frame_parms->Nid_cell % 3;

  switch (Nid2) {
  case 0:
    primary_sync = primary_synch0;
    break;
69

70 71 72
  case 1:
    primary_sync = primary_synch1;
    break;
73

74 75 76
  case 2:
    primary_sync = primary_synch2;
    break;
77

78 79 80 81 82
  default:
    msg("[PSS] eNb_id has to be 0,1,2\n");
    return(-1);
  }

83
  a = (frame_parms->nb_antenna_ports_eNB == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15)>>15;
84 85
  //printf("[PSS] amp=%d, a=%d\n",amp,a);

Raymond Knopp's avatar
 
Raymond Knopp committed
86
  Nsymb = (frame_parms->Ncp==NORMAL)?14:12;
87

88
  for (aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) {
89
    //  aa = 0;
90

91
    // The PSS occupies the inner 6 RBs, which start at
Raymond Knopp's avatar
 
Raymond Knopp committed
92 93 94
    k = frame_parms->ofdm_symbol_size-3*12+5;

    //printf("[PSS] k = %d\n",k);
95
    for (m=5; m<67; m++) {
Raymond Knopp's avatar
 
Raymond Knopp committed
96
      ((short*)txdataF[aa])[2*(slot_offset*Nsymb/2*frame_parms->ofdm_symbol_size +
97 98
                               symbol*frame_parms->ofdm_symbol_size + k)] =
                                 (a * primary_sync[2*m]) >> 15;
Raymond Knopp's avatar
 
Raymond Knopp committed
99
      ((short*)txdataF[aa])[2*(slot_offset*Nsymb/2*frame_parms->ofdm_symbol_size +
100 101
                               symbol*frame_parms->ofdm_symbol_size + k) + 1] =
                                 (a * primary_sync[2*m+1]) >> 15;
Raymond Knopp's avatar
 
Raymond Knopp committed
102 103 104 105

      k+=1;

      if (k >= frame_parms->ofdm_symbol_size) {
106 107
        k++; //skip DC
        k-=frame_parms->ofdm_symbol_size;
Raymond Knopp's avatar
 
Raymond Knopp committed
108 109
      }

110 111
    }
  }
112

113 114
  return(0);
}
115 116 117 118

int generate_pss_emul(PHY_VARS_eNB *phy_vars_eNb,uint8_t sect_id)
{

119
  msg("[PHY] EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id);
Raymond Knopp's avatar
 
Raymond Knopp committed
120
  eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id;
121 122
  return(0);
}