Commit 10c62314 authored by Matthieu Kanj's avatar Matthieu Kanj

improving code structure

parent 3980842f
......@@ -53,13 +53,15 @@ int NB_IoT_est_timing_advance_pusch(PHY_VARS_eNB_NB_IoT* phy_vars_eNB,module_id_
////////// Vincent: NB-IoT specific adapted function for channel estimation ////////////////////
int ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t UE_id,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t cooperation_flag);
eNB_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t UE_id,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag);
////////////////////////////////////////////////////////////////////////////////////////////////
int16_t lte_ul_freq_offset_estimation_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
......
......@@ -141,49 +141,52 @@ void rotate_channel_sc_tmp_NB_IoT(int16_t *estimated_channel,
int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3,
LTE_DL_FRAME_PARMS *frame_parms)
int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3, /// should be replaced by the number of the received part of UL data
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint32_t I_sc,
uint8_t Qm,
LTE_DL_FRAME_PARMS *frame_parms)
{
int pilot_pos1 = 3, pilot_pos2 = 10; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
uint16_t ul_sc_start; // subcarrier start index into UL RB
uint8_t Qm = 2; // needed to rotate the estimated channel
uint32_t u; //for group hopping
uint32_t I_sc = 11;
int symbol_offset;
uint16_t aa,k,n;
//int pilot_pos1 = 3, pilot_pos2 = 10; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
uint16_t ul_sc_start; // subcarrier start index into UL RB
//uint8_t Qm = 2; // needed to rotate the estimated channel
uint32_t u; //for group hopping
int symbol_offset;
uint16_t aa,k,n;
//int32_t **ul_ch_estimates=pusch_vars->drs_ch_estimates[eNB_id];
int16_t *received_data, *estimated_channel, *pilot_sig; // pointers to
int16_t *received_data, *estimated_channel, *pilot_sig; // pointers to
unsigned int index_Nsc_RU=0;
uint8_t symbol; //symbol within subframe
int16_t average_channel[24]; // average channel over a RB and 2 slots
int32_t *p_average_channel = (int32_t *)&average_channel;
int16_t *ul_ch1, *ul_ch2;
uint8_t symbol; //symbol within subframe
int16_t average_channel[24]; // average channel over a RB and 2 slots
int32_t *p_average_channel = (int32_t *)&average_channel;
int16_t *ul_ch1, *ul_ch2;
u=0; //Ncell_ID%16;
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
u= frame_parms->Nid_cell % 16; //Ncell_ID%16;
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB // I_sc = 11 for testing
symbol = l + 7*(Ns&1);
if (l == pilot_pos1)
{
symbol_offset = frame_parms->N_RB_UL*12*(l+(7*(Ns&1)));
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++)
{
received_data = (int16_t *)&rxdataF_ext[aa][symbol_offset];
estimated_channel = (int16_t *)&ul_ch_estimates[aa][symbol_offset];
pilot_sig = &ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][24 + 24*((8-counter_msg3)*2+Ns)-(ul_sc_start<<1)]; // pilot values depends on the slots
received_data = (int16_t *)&rxdataF_ext[aa][symbol_offset];
estimated_channel = (int16_t *)&ul_ch_estimates[aa][symbol_offset];
pilot_sig = &ul_ref_sigs_rx_NB_IoT[u][index_Nsc_RU][24 + 24*((8-counter_msg3)*2+Ns)-(ul_sc_start<<1)]; // pilot values depends on the slots
for (k=0;k<12;k++)
{
for (k=0;k<12;k++)
{
// Multiplication by the complex conjugate of the pilot
estimated_channel[k<<1] = (int16_t)(((int32_t)received_data[k<<1]*(int32_t)pilot_sig[k<<1] +
(int32_t)received_data[(k<<1)+1]*(int32_t)pilot_sig[(k<<1)+1])>>15); //real part of estimated channel
estimated_channel[(k<<1)+1] = (int16_t)(((int32_t)received_data[(k<<1)+1]*(int32_t)pilot_sig[k<<1] -
(int32_t)received_data[k<<1]*(int32_t)pilot_sig[(k<<1)+1])>>15); //imaginary part of estimated channel
}
}
rotate_channel_sc_tmp_NB_IoT(estimated_channel,symbol,Qm,counter_msg3);
//printf("\n");
......@@ -206,39 +209,36 @@ int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
// Then, an average over 2 pilot symbols is performed to increase the SNR
// This part may be improved
for (k=0;k<12;k++)
{
{
average_channel[k<<1] = (int16_t)(((int32_t)ul_ch1[k<<1] + (int32_t)ul_ch2[k<<1])/2);
average_channel[1+(k<<1)] = (int16_t)(((int32_t)ul_ch1[1+(k<<1)] + (int32_t)ul_ch2[1+(k<<1)])/2);
}
for (n=0; n<frame_parms->symbols_per_tti; n++)
{
{
for (k=0;k<12;k++)
{
{
ul_ch_estimates[aa][frame_parms->N_RB_UL*12*n + k] = p_average_channel[k];
}
}
/*for (k=11;k<12;k++)
{
printf(" re_chest_av = %d im_chest_av = %d ",ul_ch2[k<<1],ul_ch2[1+(k<<1)]);
}
printf("\n");*/
}
}
/*for (k=11;k<12;k++)
{
printf(" re_chest_av = %d im_chest_av = %d ",ul_ch2[k<<1],ul_ch2[1+(k<<1)]);
}
printf("\n");*/
}
}
}
return(0);
}
int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **rxdataF_comp,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms)
int32_t **rxdataF_comp,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms)
{
int symbol_offset;
uint16_t aa,k;
......@@ -249,12 +249,12 @@ int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
{
received_data = (int16_t *)&rxdataF_ext[aa][symbol_offset];
estimated_channel = (int16_t *)&ul_ch_estimates[aa][symbol_offset];
equal_data = (int16_t *)&rxdataF_comp[aa][symbol_offset];
equal_data = (int16_t *)&rxdataF_comp[aa][symbol_offset];
for (k=0;k<12;k++)
{
{
// Multiplication by the complex conjugate of the channel
//printf("\nkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk %d",k);
//printf("\nkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk %d",k);
equal_data[k<<1] = (int16_t)(((int32_t)received_data[k<<1]*(int32_t)estimated_channel[k<<1] +
(int32_t)received_data[(k<<1)+1]*(int32_t)estimated_channel[(k<<1)+1])>>15); //real part of estimated channel
equal_data[(k<<1)+1] = (int16_t)(((int32_t)received_data[(k<<1)+1]*(int32_t)estimated_channel[k<<1] -
......@@ -268,14 +268,16 @@ int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
/////////////////////////////////////////////////////////////////////////////
int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t UE_id,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t cooperation_flag)
int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t UE_id,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag)
{
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
......@@ -300,7 +302,7 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
int pilot_pos1_3_75k = 4, pilot_pos2_3_75k = 11; // holds for npusch format 1, and 3.75 kHz subcarrier bandwidth
int pilot_pos_format2_3_75k[6] = {0,1,2,7,8,9}; // holds for npusch format 2, and 3.75 kHz subcarrier bandwidth
int pilot_pos1, pilot_pos2; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
//int pilot_pos1, pilot_pos2; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
int *pilot_pos_format2; // holds for npusch format 2, and 15 kHz subcarrier bandwidth
int16_t *ul_ch1=NULL, *ul_ch2=NULL, *ul_ch3=NULL, *ul_ch4=NULL, *ul_ch5=NULL, *ul_ch6=NULL;
int16_t average_channel[24]; // average channel over a RB and 2 slots
......
......@@ -21,7 +21,7 @@
/*! \file PHY/LTE_TRANSPORT/lte_mcs_NB_IoT.c
* \brief Some support routines for subcarrier start into UL RB for ULSCH
* \author V. Savaux
* \author V. Savaux, M. KANJ
* \date 2017
* \version 0.1
* \company b<>com
......@@ -38,23 +38,29 @@
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc)
{
if (0<=I_sc && I_sc<=11){
return I_sc;
}
if (12<=I_sc && I_sc<=15){
if (0<=I_sc && I_sc<=11)
{
return I_sc;
} else if (12<=I_sc && I_sc<=15) {
return 3*(I_sc-12);
}
if (16<=I_sc && I_sc<=17){
return 6*(I_sc-16);
}
if (I_sc==18){
} else if (16<=I_sc && I_sc<=17) {
return 6*(I_sc-16);
} else if (I_sc==18){
return 0;
}
if (I_sc>18){
return -1;
} else if (I_sc>18 || I_sc<0){
return -1; /// error msg is needed for this case
} else {
return -1; // this was added to remove warning since it is not a void function
return -1; /// error msg is needed for this case
}
}
......
......@@ -21,7 +21,7 @@
/*! \file PHY/LTE_TRANSPORT/lte_mcs_NB_IoT.c
* \brief Some support routines for MCS computations
* \author V. Savaux
* \author V. Savaux , M. KANJ
* \date 2017
* \version 0.1
* \company b<>com
......@@ -33,25 +33,18 @@
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
// 36213 Section 16.5.1.2, Table
unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU)
{
// N_sc_RU = 1, 3, 6, 12
if (N_sc_RU)
if (N_sc_RU > 1)
return(2);
else
else // case N_sc_RU = 1 , see table 16.5.1.2-1 , TS 36213
if (I_MCS<2)
return(1);
else
return(2);
// if (I_MCS < 11)
// return(2);
// else if (I_MCS < 21)
// return(4);
// else
// return(6);
}
......@@ -326,13 +326,30 @@ void rx_ulsch_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
NB_IoT_eNB_NULSCH_t **ulsch,
uint8_t cooperation_flag);
void rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t eNB_id, // this is the effective sector id
uint8_t UE_id,
NB_IoT_eNB_NULSCH_t **ulsch,
uint8_t npusch_format, // 1, 2
uint16_t UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
uint8_t subcarrier_spacing, // 0 (3.75 KHz) or 1 (15 KHz)
uint32_t rnti_tmp, //= 65522
uint8_t scrambling_subframe_msg3,
uint32_t scrambling_frame_msg3,
uint16_t nb_slot, // total number of occupied slots
uint16_t I_sc,
uint16_t Nsc_RU,
uint16_t Mcs,
unsigned int A);
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
// uint32_t first_rb,
uint16_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block !!! may be defined twice : in frame_parms and in NB_IoT_UL_eNB_HARQ_t
uint8_t N_sc_RU, // number of subcarriers in UL
uint8_t subframe,// uint32_t I_sc, // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t nb_rb,
uint8_t l,
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms);
......@@ -386,6 +403,7 @@ void rotate_single_carrier_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t UE_id,
uint8_t symbol,
uint8_t counter_msg3,
uint32_t I_sc,
uint8_t Qm);
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB *eNB,
......@@ -407,7 +425,9 @@ int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB *eNB,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t UE_id,
uint8_t UE_id,
uint32_t I_sc,
uint8_t Nsc_RU,
int16_t *llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB *eNB,
......@@ -474,17 +494,21 @@ int dlsch_qpsk_llr_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
/// Vincent: temporary functions
int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3,
LTE_DL_FRAME_PARMS *frame_parms);
int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint32_t I_sc,
uint8_t Qm,
LTE_DL_FRAME_PARMS *frame_parms);
void rotate_channel_sc_tmp_NB_IoT(int16_t *estimated_channel,
uint8_t l,
uint8_t Qm,
uint8_t counter_msg3);
uint8_t l,
uint8_t Qm,
uint8_t counter_msg3);
int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **rxdataF_comp,
......
This diff is collapsed.
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