npss_NB_IoT.c 2.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/***********************************************************************

**********************************************************************/
/*! \file PHY/LTE_TRANSPORT/npss_NB_IoT.c
* \Generation of Narrowband Primary Synchronisation Signal(NPSS) for NB-IoT,	 TS 36-212, V13.4.0 2017-02
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/

15
//#include "PHY/defs.h"
16
#include "PHY/defs_nb_iot.h"
17
#include "PHY/extern.h"
18
#include "PHY/LTE_REFSIG/primary_synch_NB_IoT.h"
19 20 21

int generate_npss_NB_IoT(int32_t **txdataF,
						short amp,
22
						NB_IoT_DL_FRAME_PARMS *frame_parms,
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
						unsigned short symbol_offset,				// symbol_offset should equal to 3 for NB-IoT 
						unsigned short slot_offset,
						unsigned short RB_IoT_ID)					// new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
{
   unsigned short c,aa,a,s;
   unsigned short slot_id;
   short *primary_sync;
   unsigned short NB_IoT_start; 			// Index of the first RE in the RB dedicated for NB-IoT
   unsigned short bandwidth_even_odd;

   slot_id = slot_offset;  							// The id(0..19) of the slot including the NPSS signal // For NB-IoT, slod_id should be 10 (SF5)
   primary_sync = primary_synch_NB_IoT;     		// primary_synch_NB_IoT[264] of primary_synch_NB_IoT.h

   // Signal amplitude
   a = (frame_parms->nb_antennas_tx == 1) ? amp: (amp*ONE_OVER_SQRT2_Q15)>>15;

   // Testing if the total number of RBs is even or odd (i.e. Identification of the bandwidth: 1.4, 3, 5, 10, ... MHz)
   bandwidth_even_odd = frame_parms->N_RB_DL % 2;  		// 0 for even, 1 for odd

   for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
	
		if(RB_IoT_ID < (frame_parms->N_RB_DL/2))
		{
46
			NB_IoT_start = frame_parms->ofdm_symbol_size - 12*(frame_parms->N_RB_DL/2) - (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
47
		} else {
48
			NB_IoT_start = (bandwidth_even_odd*6) + 12*(RB_IoT_ID%(int)(ceil(frame_parms->N_RB_DL/(float)2)));
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
		}
		// For the In-band or Stand-alone case the REs of NPSS signal have the same positions
		for (s=0; s<11; s++ )   				// loop on OFDM symbols
		{	
			for (c=0; c<12; c++) {   			// loop on NB-IoT carriers
			
				((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )] =
			
										(a * primary_sync[2*c + (2*12*s)]) >> 15;
										
				((short*)txdataF[aa])[2*( (slot_id*7*frame_parms->ofdm_symbol_size) + ((symbol_offset+s)*frame_parms->ofdm_symbol_size) + NB_IoT_start + c )+1] =
			
										(a * primary_sync[2*c + (2*12*s) + 1]) >> 15;
			}
		}
	}

  return(0);
}

/* (for LTE)
70
int generate_pss_emul(PHY_VARS_eNB_NB_IoT *phy_vars_eNb,uint8_t sect_id)
71 72 73 74 75 76 77
{

  msg("[PHY] EMUL eNB generate_pss_emul eNB %d, sect_id %d\n",phy_vars_eNb->Mod_id,sect_id);
  eNB_transport_info[phy_vars_eNb->Mod_id][phy_vars_eNb->CC_id].cntl.pss=sect_id;
  return(0);
}
*/