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

improving code structure

parent 3980842f
......@@ -59,6 +59,8 @@ int ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag);
////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -145,15 +145,17 @@ 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 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
//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
//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;
//int32_t **ul_ch_estimates=pusch_vars->drs_ch_estimates[eNB_id];
......@@ -164,9 +166,10 @@ int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
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)));
......@@ -223,12 +226,9 @@ int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
printf(" re_chest_av = %d im_chest_av = %d ",ul_ch2[k<<1],ul_ch2[1+(k<<1)]);
}
printf("\n");*/
}
}
}
return(0);
}
......@@ -275,6 +275,8 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
unsigned char l,
unsigned char Ns,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag)
{
......@@ -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){
if (0<=I_sc && I_sc<=11)
{
return I_sc;
}
if (12<=I_sc && I_sc<=15){
} else if (12<=I_sc && I_sc<=15) {
return 3*(I_sc-12);
}
if (16<=I_sc && I_sc<=17){
} else if (16<=I_sc && I_sc<=17) {
return 6*(I_sc-16);
}
if (I_sc==18){
} 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
......@@ -34,24 +34,17 @@
//#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,
......@@ -408,6 +426,8 @@ int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB *eNB,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t UE_id,
uint32_t I_sc,
uint8_t Nsc_RU,
int16_t *llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB *eNB,
......@@ -479,6 +499,10 @@ int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
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,
......
......@@ -561,7 +561,25 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
//printf("frame %d in demod NPUSCH = \n",frame);
/////////////////////////////////////////////////// NPUSH DEMOD ////////////////////////////////////
// LTE_eNB_COMMON *common_vars = &eNB->common_vars;
LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[0];
NB_IoT_eNB_NULSCH_t **ulsch_NB_IoT = &eNB->ulsch_NB_IoT;//[0][0];
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0,//eNB_id, // this is the effective sector id
0,//UE_id,
ulsch_NB_IoT,
1,//npusch_format, // 1, 2
22,//UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
1,//subcarrier_spacing, // 0 (3.75 KHz) or 1 (15 KHz)
65522,//rnti_tmp, //= 65522
proc->subframe_dscr_msg3,//subframerx,//scrambling_subframe_msg3, // first received subframe
proc->frame_dscr_msg3,//framerx,// scrambling_frame_msg3, // first received frame
16,//nb_slot, // total number of occupied slots
11, // I_sc
1, // Nsc_RU
2, // Mcs
88); // A = TBS
/* LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[0];
//NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_eNB_NULSCH_t **ulsch_NB_IoT = &eNB->ulsch_NB_IoT;//[0][0];
int l; //i;
......@@ -583,8 +601,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
// ulsch[UE_id]->harq_process->first_rb,
22, //ulsch[UE_id]->harq_process->UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
1, //ulsch_NB_IoT[0]->harq_process->N_sc_RU, // number of subcarriers in UL //////////////// high level parameter
(uint8_t)proc->subframe_delay,//subframe,// ulsch[UE_id]->harq_process->I_sc, // subcarrier indication field
nb_rb,
I_sc,//subframe,// ulsch[UE_id]->harq_process->I_sc, // subcarrier indication field
l%(fp->symbols_per_tti/2),
l/(fp->symbols_per_tti/2),
fp);
......@@ -594,6 +611,10 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
l%(fp->symbols_per_tti/2), //symbol within slot
l/(fp->symbols_per_tti/2),
proc->counter_msg3,
pilot_pos1,
pilot_pos2,
I_sc,
Qm,
fp);
}
......@@ -618,23 +639,14 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
rotate_single_carrier_NB_IoT(eNB,
fp,
pusch_vars->rxdataF_comp[0],
0, // UE ID
UE_id, // UE ID
l,
proc->counter_msg3,
2); // Qm
I_sc,
Qm); // Qm
}
proc->subframe_delay++;
if(proc->subframe_delay==10) ///&& frame == ????
{
proc->subframe_delay=0;
}
proc->subframe_delay++;
///////// IDFT inverse precoding is done over the whole subframe of 14 - 2 (pilots) symbols
//lte_idft_NB_IoT(fp,
// (uint32_t*)pusch_vars->rxdataF_ext[0][0],
......@@ -654,16 +666,19 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
pusch_vars->rxdataF_comp[0],
pusch_vars->llr,
l,
0, // UE ID
UE_id, // UE ID
I_sc,
Nsc_RU, // uint8_t Nsc_RU=1
&llrp[ii*2]); //// !!! Pensez à créer un buffer de longueur 8 subframes
ii++;
}
/*printf("\n");
for (l=0;l<24;l++){
printf(" llr = %d ",pusch_vars->llr[(8-proc->counter_msg3)*24+l]);
}*/
// printf("\n");
// for (l=0;l<24;l++){
// printf(" llr = %d ",pusch_vars->llr[(8-proc->counter_msg3)*24+l]);
// }
*/
/*
/////////////////////////////////////////////////// NPUSH DECOD ////////////////////////////////////
if(proc->counter_msg3==1)
{
......@@ -691,20 +706,6 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
uint32_t rnti_tmp= 65522; // true rnti should be used
uint8_t reset;
/*int16_t *Rx_buffer;
FILE *fich = fopen("xyzabc.txt","w");
Rx_buffer = &ulsch_llr[0]; // get the whole frame
memcpy(&buffer_npusch[0],&Rx_buffer[0],2*2*8*12);
int pp;
for (pp=0;pp<2*8*12;pp++)
{
fprintf(fich," %d ",buffer_npusch[pp]);
}
fclose(fich);
exit(0); */
// NB-IoT ///////////////////////////////////////////////
// x1 is set in lte_gold_generic
// x2 should not reinitialized each subframe
......@@ -792,10 +793,10 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
}
break;
}
printf("\n \n");
/*for (j=0;j<140;j++){
printf(" y = %d ",y[j]);
}*/
// printf("\n \n");
// for (j=0;j<140;j++){
// printf(" y = %d ",y[j]);
// }
// CQI and Data bits
j = 0;
j2 = 0;
......@@ -812,10 +813,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
ep[7] = yp[7];
}
/*printf("\n \n");
for (j=0;j<140;j++){
printf(" e = %d ",ulsch_harq->e[j]);
}*/
// Do ULSCH Decoding for data portion
......@@ -906,19 +904,13 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
}
r_offset += E;
/*printf("\n \n");
for (j=0;j<140;j++){
printf(" w = %d ",ulsch_harq->w[r][j]);
}*/
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
ulsch_harq->w[r]);
/*printf("\n \n");
for (j=0;j<140;j++){
printf(" d = %d ",ulsch_harq->d[r][96+j]);
}*/
if (ulsch_harq->C == 1)
{
......@@ -984,17 +976,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
printf("pdu[2] = %d \n",ulsch_harq->b[8]);
printf("pdu[3] = %d \n",ulsch_harq->b[9]);
/*uint8_t xo = 128;
int m =0;
for(m=0; m<6;m++)
{
if((ulsch_harq->b[2+m]<<7) == 128)
{
msg3[m]= (ulsch_harq->b[3+m]>>1) ^ xo;
} else {
msg3[m]= (ulsch_harq->b[3+m]>>1);
}
}*/
int m =0;
for(m=0; m<6;m++)
{
......@@ -1007,7 +989,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
proc->flag_DCI_msg4 =1 ;
proc->counter_DCI_msg4=4;
} // NPUSH decode end
} // NPUSH decode end */
proc->counter_msg3--;
}
......@@ -1086,7 +1068,7 @@ if(proc->flag_msg4 == 1 && proc->counter_msg4 > 0)
dlsch_encoding_rar_NB_IoT(tab_rar,
rar,
2, ///// number_of_subframes_required
1, ///// number_of_subframes_required
236,
1); //////////// G*2 // option =2 for msg4
......@@ -1215,16 +1197,16 @@ if(proc->flag_DCI_msg4 ==1 && proc->counter_DCI_msg4>0)
uint8_t agr_level = 2;
// uint8_t dci_number=1;
uint8_t tab_a[3];
/* tab_a[0]= 128;
tab_a[0]= 128;
tab_a[1]= 66;
tab_a[2]= 4;
*/
// TBS =120
tab_a[0]= 129;
/* tab_a[0]= 129;
tab_a[1]= 130;
tab_a[2]= 2;
*/
/* // TBS =144
tab_a[0]= 128;
......
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