Commit 3b0c26d9 authored by Matthieu Kanj's avatar Matthieu Kanj

Merge branch 'develop-nb-iot' of...

Merge branch 'develop-nb-iot' of https://gitlab.eurecom.fr/oai/openairinterface5g into develop-nb-iot
parents 5a13a7d4 4c3b80b1
......@@ -4071,7 +4071,7 @@ unsigned short dlsch_extract_rbs_single_NB_IoT(int **rxdataF,
int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
unsigned short UL_RB_ID_NB_IoT; // index of the NB-IoT RB
uint8_t id_offset; // offset of pilot position in symbols: 0,1,2
unsigned short NB_IoT_start,bandwidth_even_odd; // Index of the first RE in the RB dedicated for NB-IoT, bandwidth_even_odd = 0 even 1 odd
unsigned char symbol_mod,crs_pilots=0,j=0,poffset=0;
unsigned char nrs_pilots=0,nrs_offset=0; // nrs_pilots: flag of presence of pilot, nrs_offset: offset from first subcarrier
......@@ -4110,117 +4110,117 @@ unsigned short dlsch_extract_rbs_single_NB_IoT(int **rxdataF,
rxF_ext = &rxdataF_ext[aarx][symbol*(frame_parms->N_RB_DL*12)];
bandwidth_even_odd = frame_parms->N_RB_DL % 2; // 0 for even, 1 for odd
// if ((frame_parms->N_RB_DL&1) == 0) // even number of RBs
if(UL_RB_ID_NB_IoT <= (frame_parms->N_RB_DL>>1))
{ // RB in first half (below DC)
NB_IoT_start = UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset;
} else { // RB in the second half (above DC): DC is taken into account
NB_IoT_start = 1 + bandwidth_even_odd*6 + 6*(2*UL_RB_ID_NB_IoT - (frame_parms->N_RB_DL+bandwidth_even_odd));
}
for (rb=0;rb<1;rb++) {
for (rb=0;rb<1;rb++) {
// if (rb < 32)
rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
// else if (rb < 64)
// rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
// else if (rb < 96)
// rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
// else if (rb < 100)
// rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
// else
// rb_alloc_ind = 0;
if (rb_alloc_ind == 1)
nb_rb++;
// if (rb==(frame_parms->N_RB_DL>>1)) {
if (UL_RB_ID_NB_IoT <= (frame_parms->N_RB_DL>>1)) { // NB-IoT RB is in the first half
rxF = &rxdataF[aarx][(UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset + (symbol*(frame_parms->ofdm_symbol_size)))];
}// For second half of RBs skip DC carrier
else{ // NB-IoT RB is in the second half
rxF = &rxdataF[aarx][(1 + 6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_DL) + (symbol*(frame_parms->ofdm_symbol_size)))];
//dl_ch0++;
}
// if (rb < 32)
rb_alloc_ind = (rb_alloc[0]>>rb) & 1;
// else if (rb < 64)
// rb_alloc_ind = (rb_alloc[1]>>(rb-32)) & 1;
// else if (rb < 96)
// rb_alloc_ind = (rb_alloc[2]>>(rb-64)) & 1;
// else if (rb < 100)
// rb_alloc_ind = (rb_alloc[3]>>(rb-96)) & 1;
// else
// rb_alloc_ind = 0;
// // PBCH
// if (subframe==0) {
// rb_alloc_ind = 0;
// }
if (rb_alloc_ind == 1)
nb_rb++;
rxF = &rxdataF[aarx][NB_IoT_start + (symbol*(frame_parms->ofdm_symbol_size))];
//NSSS subframe
if (subframe==9 && frame%2==0) {
rb_alloc_ind = 0;
}
//NPSS subframe
if (subframe==5) {
rb_alloc_ind = 0;
}
// // PBCH
// if (subframe==0) {
// rb_alloc_ind = 0;
// }
// if ((frame_parms->frame_type == TDD) &&
// (subframe==6)) { //TDD Subframe 6
// if ((rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
// rb_alloc_ind = 0;
// }
// }
if (rb_alloc_ind==1) { // If subframe not including NPSS, NSSS
*pmi_ext = (pmi>>((rb>>2)<<1))&3;
memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
/*
printf("rb %d\n",rb);
for (i=0;i<12;i++)
printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
printf("\n");
*/
if (crs_pilots==0 && nrs_pilots==0) {
for (i=0; i<12; i++) {
rxF_ext[i]=rxF[i];
/*
printf("%d : (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),
((short*)&rxF[i])[0],((short*)&rxF[i])[1]);*/
}
//NSSS subframe
if (subframe==9 && frame%2==0) {
rb_alloc_ind = 0;
}
dl_ch0_ext+=12;
rxF_ext+=12;
}
else if (crs_pilots==1 && nrs_pilots==0) {
j=0;
//NPSS subframe
if (subframe==5) {
rb_alloc_ind = 0;
}
for (i=0; i<12; i++) {
if ((i!=(frame_parms->nushift+poffset)) &&
(i!=((frame_parms->nushift+poffset+6)%12))) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j++]=dl_ch0[i];
// if ((frame_parms->frame_type == TDD) &&
// (subframe==6)) { //TDD Subframe 6
// if ((rb>=((frame_parms->N_RB_DL>>1)-3)) && (rb<((frame_parms->N_RB_DL>>1)+3)) && (l==pss_symb) ) {
// rb_alloc_ind = 0;
// }
// }
}
}
if (rb_alloc_ind==1) { // If subframe not including NPSS, NSSS
*pmi_ext = (pmi>>((rb>>2)<<1))&3;
memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
dl_ch0_ext+=10;
rxF_ext+=10;
/*
printf("rb %d\n",rb);
for (i=0;i<12;i++)
printf("(%d %d)",((short *)dl_ch0)[i<<1],((short*)dl_ch0)[1+(i<<1)]);
printf("\n");
*/
if (crs_pilots==0 && nrs_pilots==0) {
for (i=0; i<12; i++) {
rxF_ext[i]=rxF[i];
/*
printf("%d : (%d,%d)\n",(rxF+i-&rxdataF[aarx][( (symbol*(frame_parms->ofdm_symbol_size)))]),
((short*)&rxF[i])[0],((short*)&rxF[i])[1]);*/
}
else if (crs_pilots==0 && nrs_pilots==1) {
j=0;
for (i=0; i<12; i++) {
if ((i!=(id_offset+nrs_offset)) &&
(i!=((id_offset+nrs_offset+6)%12))) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j++]=dl_ch0[i];
dl_ch0_ext+=12;
rxF_ext+=12;
}
else if (crs_pilots==1 && nrs_pilots==0) {
j=0;
}
}
for (i=0; i<12; i++) {
if ((i!=(frame_parms->nushift+poffset)) &&
(i!=((frame_parms->nushift+poffset+6)%12))) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j++]=dl_ch0[i];
dl_ch0_ext+=10;
rxF_ext+=10;
}
}
dl_ch0_ext+=10;
rxF_ext+=10;
}
else if (crs_pilots==0 && nrs_pilots==1) {
j=0;
for (i=0; i<12; i++) {
if ((i!=(id_offset+nrs_offset)) &&
(i!=((id_offset+nrs_offset+6)%12))) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j++]=dl_ch0[i];
}
}
dl_ch0_ext+=10;
rxF_ext+=10;
}
dl_ch0+=12;
rxF+=12;
}
dl_ch0+=12;
rxF+=12;
}
// if (crs_pilots==0) {
// for (i=0; i<12; i++) {
// rxF_ext[i]=rxF[i];
......
......@@ -136,4 +136,139 @@ int generate_sss_NB_IoT(int32_t **txdataF,
return(0);
}
int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric)
{
uint8_t Nid2,q_est,u_est;
NB_IoT_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int l,k,m;
int16_t *d, *nsss_sf;
int32_t nsss_ext[2][132]; // up to 2 rx antennas ?
int32_t metric; // correlation metric
// we suppose we are in NSSS subframe, after DFT
// this could be changed in further version
for (l=0;l<11;l++){
nsss_extract_NB_IoT(ue,frame_parms,nsss_ext,l);
}
// now do the Cell ID estimation based on the precomputed sequences in PHY/LTE_TRANSPORT/nsss_NB_IoT.h
*tot_metric = -99999999;
nsss_sf = (int16_t*)&nsss_ext[0][0];
for (Nid2=0;Nid2<16;Nid2++){
switch (Nid2) {
case 0:
d = d0f0;
break;
case 1:
d = d0f1;
break;
case 2:
d = d0f2;
break;
case 3:
d = d0f3;
break;
case 4:
d = d1f0;
break;
case 5:
d = d1f1;
break;
case 6:
d = d1f2;
break;
case 7:
d = d1f3;
break;
case 8:
d = d2f0;
break;
case 9:
d = d2f1;
break;
case 10:
d = d2f2;
break;
case 11:
d = d2f3;
case 12:
d = d3f0;
break;
case 13:
d = d3f1;
break;
case 14:
d = d3f2;
break;
case 15:
d = d3f3;
break;
default:
msg("[NSSS] ERROR\n");
return(-1);
}
for (k=0;k<126;k++){ // corresponds to u in standard
metric = 0;
for (m=0;m<132;m++){ // 132 resource elements in NSSS subframe
metric += (int32_t)d[(k*126+m)<<1] * (int32_t)nsss_sf[(k*126+m)<<1] +
(int32_t)d[((k*126+m)<<1)+1] * (int32_t)nsss_sf[((k*126+m)<<1)+1]; // real part of correlation
}
if (metric > *tot_metric){
q_est = Nid2/4;
u_est = k;
ue->frame_parms.Nid_cell = q_est*126 + u_est;
}
}
}
return(0);
}
int nsss_extract_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **nsss_ext,
int l)
{
uint8_t i,aarx;
unsigned short UL_RB_ID_NB_IoT; // index of RB dedicated to NB-IoT
int32_t *nsss_rxF,*nsssF_ext;
int32_t **rxdataF;
int first_symbol_offset = 3; // NSSS starts at third symbol in subframe
UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
rxdataF = ue->common_vars.common_vars_rx_data_per_thread[0].rxdataF; // Note that
nsssF_ext = &nsss_ext[aarx][l*12];
if (UL_RB_ID_NB_IoT <= (frame_parms->N_RB_DL>>1)) { // NB-IoT RB is in the first half
nsss_rxF = &rxdataF[aarx][(UL_RB_ID_NB_IoT*12 + frame_parms->first_carrier_offset + ((l+first_symbol_offset)*(frame_parms->ofdm_symbol_size)))];
}// For second half of RBs skip DC carrier
else{ // NB-IoT RB is in the second half
nsss_rxF = &rxdataF[aarx][(1 + 6*(2*UL_RB_ID_NB_IoT - frame_parms->N_RB_DL) + ((l+first_symbol_offset)*(frame_parms->ofdm_symbol_size)))];
//dl_ch0++;
}
for (i=0; i<12; i++) {
nsssF_ext[i]=nsss_rxF[i];
}
}
return(0);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -52,7 +52,16 @@ int generate_sss_NB_IoT(int32_t **txdataF,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//*****************Vincent part for Cell ID estimation from NSSS ******************//
int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric);
int nsss_extract_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **nsss_ext,
int l);
//NRS
......
......@@ -51,7 +51,7 @@ int16_t *primary_synch2_time;
PHY_VARS_UE_NB_IoT ***PHY_vars_UE_NB_IoT_g;
PHY_VARS_eNB_NB_IoT ***PHY_vars_eNB_NB_IoT_g;
PHY_VARS_RN_NB_IoT **PHY_vars_RN_NB_IoT_g;
NB_IoT_DL_FRAME_PARMS *lte_frame_parms_g;
//NB_IoT_DL_FRAME_PARMS *lte_frame_parms_g;
#else
PHY_VARS_UE_NB_IoT * PHY_vars_UE_NB_IoT_g[MAX_UE][MAX_NUM_CCs]={NULL};
PHY_vars_eNB_NB_IoT * PHY_vars_eNB_NB_IoT_g[MAX_eNB_NB_IoT][MAX_NUM_CCs]={NULL};
......
......@@ -10,7 +10,7 @@
//#include "PHY/extern.h"
#include "PHY/extern_NB_IoT.h"
//#include "PHY/vars.h"
#include "PHY/vars_NB_IoT.h"
#include "PHY/INIT/defs_NB_IoT.h"
......
......@@ -56,6 +56,8 @@
/////////////////////////////NB-IoT Parameters here////////////////////////////////////////
#include "PHY/vars_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment