Commit 798c839b authored by Matthieu Kanj's avatar Matthieu Kanj

NPUSCH update

parent debb2cca
......@@ -51,7 +51,7 @@ void lte_sync_timefreq_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int band,unsigned int DL_fr
int NB_IoT_est_timing_advance_pusch(PHY_VARS_eNB_NB_IoT* phy_vars_eNB,module_id_t UE_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,
......@@ -61,7 +61,7 @@ int ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t N_sc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint8_t cooperation_flag);
uint8_t cooperation_flag); */
////////////////////////////////////////////////////////////////////////////////////////////////
int16_t lte_ul_freq_offset_estimation_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
......
......@@ -404,7 +404,7 @@ 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,
......@@ -731,7 +731,7 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB *eNB,
}
*/
......
......@@ -36,17 +36,42 @@
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"
unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU)
uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag)
{
// N_sc_RU = 1, 3, 6, 12
if (N_sc_RU > 1)
return(2);
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 (Msg3_flag == 1) /////////////////////////// case of Msg3
{
if(I_mcs > 0)
{
return 2;
} else if (I_mcs == 0 && I_sc <12) {
return 1;
} else { ////// I_mcs == 0 && I_sc >11
return 2;
}
} else { /////////////////////// case of other NPUSCH config
if(N_sc_RU == 1)
{
if(I_mcs <2)
{
return 1;
} else {
return 2;
}
} else { /////////////// N_sc_RU > 1
return 2;
}
}
}
......
......@@ -237,13 +237,13 @@ uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
/*unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
*/
// NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
......@@ -255,7 +255,6 @@ uint8_t subframe2harq_pid_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,
@param I_MCS */
//uint8_t get_Qm_ul_NB_IoT(uint8_t I_MCS);
unsigned char get_Qm_ul_NB_IoT(unsigned char I_MCS, uint8_t N_sc_RU);
/** \fn dlsch_encoding(PHY_VARS_eNB *eNB,
uint8_t *input_buffer,
......@@ -351,13 +350,7 @@ int32_t dlsch_encoding_NB_IoT(unsigned char *a,
unsigned int G); // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
/////////////////////////////////////////////////////////////////
void rx_ulsch_NB_IoT(PHY_VARS_eNB *phy_vars_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 cooperation_flag);
uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB *eNB,
......@@ -378,7 +371,8 @@ uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB *eNB,
unsigned int A,
uint16_t counter_msg,
uint8_t subframerx,
uint8_t rvdx);
uint8_t rvdx,
uint8_t msg3_flag);
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
......@@ -426,6 +420,13 @@ int16_t* sub_sampling_NB_IoT(int16_t *input_buffer, uint32_t length_input, uint3
void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx);
//************************************************************//
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag);
uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag);
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc);
uint16_t get_UL_sc_index_start_NB_IoT(uint8_t subcarrier_spacing, uint16_t I_sc, uint8_t npush_format);
......@@ -438,6 +439,10 @@ uint8_t get_numb_UL_sc_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t
uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrier_indcation, uint8_t UL_format);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
......
......@@ -1117,7 +1117,7 @@ static inline unsigned int lte_gold_unscram_NB_IoT(unsigned int *x1, unsigned in
}
/*
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
......@@ -1183,9 +1183,9 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0);
return 1+ulsch->max_turbo_iterations;
}
*/
/* ----------------------- Segmentation */
/*
// nb_rb = ulsch_harq->nb_rb; // nb_rb set but not used ??
//nb_rb = 1; // nb_rb set but not used ??
A = ulsch_harq->TBS;
......@@ -1248,7 +1248,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
//mac_xface_NB_IoT->macphy_exit("ulsch_decoding.c: FATAL sumKr is 0!");
return(-1);
}
*/
// No control information in NB-IoT
// Compute Q_ri
// Qprime = ulsch_harq->O_RI*ulsch_harq->Msc_initial*ulsch_harq->Nsymb_initial * ulsch->beta_offset_ri_times8;
......@@ -1313,7 +1313,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
// #endif
// G = G - Q_RI - Q_CQI;
ulsch_harq->G = G;
/* ulsch_harq->G = G;
if ((int)G < 0) {
LOG_E(PHY,"FATAL: ulsch_decoding.c G < 0 (%d) : Q_RI %d, Q_CQI %d\n",G,Q_RI,Q_CQI);
......@@ -1343,15 +1343,15 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
// read in buffer and unscramble llrs for everything but placeholder bits
// llrs stored per symbol correspond to columns of interleaving matrix
s = lte_gold_unscram_NB_IoT(&x1, &x2, 1);
i2 = 0;
i2 = 0;*/
for (i=0; i<((Hpp*Q_m)>>5); i++) {
// for (i=0; i<((Hpp*Q_m)>>5); i++) {
/*
for (j=0; j<32; j++) {
cseq[i2++] = (int16_t)((((s>>j)&1)<<1)-1);
}
*/
#if defined(__x86_64__) || defined(__i386__)
/* #if defined(__x86_64__) || defined(__i386__)
#ifndef __AVX2__
((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut_NB_IoT)[(s&65535)<<1];
((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut_NB_IoT)[1+((s&65535)<<1)];
......@@ -1372,7 +1372,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
s = lte_gold_unscram_NB_IoT(&x1, &x2, 0);
}
*/
// printf("after unscrambling c[%d] = %p\n",0,ulsch_harq->c[0]);
// if (frame_parms->Ncp == 0)
......@@ -1429,7 +1429,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
// #endif
// j=(j+3)&3;
// }
/*
i = 0;
switch (Q_m) {
......@@ -1459,7 +1459,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
}
break;
*/
// case 4:
// for (j=0; j<Cmux; j++) {
......@@ -1508,14 +1508,14 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
// }
// break;
}
// }
// if (i!=(H+Q_RI))
if (i!=(H))
LOG_D(PHY,"ulsch_decoding.c: Error in input buffer length (j %d, H+Q_RI %d)\n",i,H+Q_RI);
// if (i!=(H))
// LOG_D(PHY,"ulsch_decoding.c: Error in input buffer length (j %d, H+Q_RI %d)\n",i,H+Q_RI);
// HARQ-ACK Bits (LLRs are nulled in overwritten bits after copying HARQ-ACK LLR)
......@@ -1629,8 +1629,8 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
// printf("after RI2 c[%d] = %p\n",0,ulsch_harq->c[0]);
// CQI and Data bits
j = 0;
j2 = 0;
// j = 0;
// j2 = 0;
// r=0;
// if (Q_RI>0) {
......@@ -1726,9 +1726,9 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
*((int16x8_t *)&ulsch_harq->e[iprime]) = *((int16x8_t *)&y[j2]);
#endif
*/
int16_t *yp,*ep;
// int16_t *yp,*ep;
for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0];
/* for (iprime=0,yp=&y[j2],ep=&ulsch_harq->e[0];
iprime<G;
iprime+=8,j2+=8,ep+=8,yp+=8) {
ep[0] = yp[0];
......@@ -1741,7 +1741,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
ep[7] = yp[7];
}
*/
//stop_meas_NB_IoT(&eNB->ulsch_demultiplexing_stats);
......@@ -1878,7 +1878,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
*/
// Do ULSCH Decoding for data portion
/*
ret = eNB->td(eNB,UE_id,harq_pid,llr8_flag);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0);
......@@ -1886,7 +1886,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
return(ret);
}
*/
/*
#ifdef PHY_ABSTRACTION
......
......@@ -1609,443 +1609,6 @@ void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
#endif
}
int32_t avgU[2];
int32_t avgU_0[2],avgU_1[2]; // For the Distributed Alamouti Scheme
void rx_ulsch_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 cooperation_flag)
{
// flagMag = 0;
LTE_eNB_COMMON *common_vars = &eNB->common_vars;
LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
uint32_t l,i;
int32_t avgs;
uint8_t log2_maxh = 0,aarx;
// int32_t avgs_0,avgs_1;
// uint32_t log2_maxh_0 = 0,log2_maxh_1 = 0;
uint8_t harq_pid;
uint8_t Qm;
///uint16_t rx_power_correction;
int16_t *llrp;
int subframe = proc->subframe_rx;
uint8_t npusch_format = 1; // NB-IoT: format 1 (data), or 2: ack. Should be defined in higher layer
uint8_t Nsc_RU = eNB->ulsch_NB_IoT[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
uint8_t subcarrier_spacing = frame_parms->subcarrier_spacing; // 15 kHz or 3.75 kHz
int pilot_pos1_15k = 3, pilot_pos2_15k = 10; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
int pilot_pos_format2_15k[2] = {2,9}; // holds for npusch format 2, and 15 kHz subcarrier bandwidth
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[2] = {0,7}; // 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_pos_format2; // holds for npusch format 2, and 15 kHz subcarrier bandwidth
harq_pid = subframe2harq_pid_NB_IoT(frame_parms,proc->frame_rx,subframe);
Qm = get_Qm_ul_NB_IoT(ulsch[UE_id]->harq_process->mcs,Nsc_RU);
///rx_power_correction = 1;
if (ulsch[UE_id]->harq_process->nb_rb == 0) {
LOG_E(PHY,"PUSCH (%d/%x) nb_rb=0!\n", harq_pid,ulsch[UE_id]->rnti);
return;
}
if (subcarrier_spacing){
pilot_pos_format2 = pilot_pos_format2_15k;
pilot_pos1 = pilot_pos1_15k;
pilot_pos2 = pilot_pos2_15k;
}else{
pilot_pos_format2 = pilot_pos_format2_3_75k;
pilot_pos1 = pilot_pos1_3_75k;
pilot_pos2 = pilot_pos2_3_75k;
}
for (l=0; l<frame_parms->symbols_per_tti; l++) {
ulsch_extract_rbs_single_NB_IoT(common_vars->rxdataF[eNB_id],
pusch_vars->rxdataF_ext[eNB_id],
// 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
ulsch[UE_id]->harq_process->N_sc_RU, // number of subcarriers in UL
0,// ulsch[UE_id]->harq_process->I_sc, // subcarrier indication field
l%(frame_parms->symbols_per_tti/2),
l/(frame_parms->symbols_per_tti/2),
frame_parms);
// lte_ul_channel_estimation_NB_IoT(eNB,proc,
// eNB_id,
// UE_id,
// l%(frame_parms->symbols_per_tti/2),
// l/(frame_parms->symbols_per_tti/2),
// cooperation_flag);
ul_channel_estimation_NB_IoT(eNB,proc,
eNB_id,
UE_id,
l%(frame_parms->symbols_per_tti/2),
l/(frame_parms->symbols_per_tti/2),
1,
0,
0,
cooperation_flag);
/* 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); */
}
// if(cooperation_flag == 2) {
// for (i=0; i<frame_parms->nb_antennas_rx; i++) {
// pusch_vars->ulsch_power_0[i] = signal_energy(pusch_vars->drs_ch_estimates_0[eNB_id][i],
// ulsch[UE_id]->harq_process->nb_rb*12)*rx_power_correction;
// pusch_vars->ulsch_power_1[i] = signal_energy(pusch_vars->drs_ch_estimates_1[eNB_id][i],
// ulsch[UE_id]->harq_process->nb_rb*12)*rx_power_correction;
// }
// } else {
for (i=0; i<frame_parms->nb_antennas_rx; i++) {
/*
pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[eNB_id][i],
ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction;
*/
//////////////////////// NB_IoT: maybe, should be defined for NB-IoT
// pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[eNB_id][i],
// ulsch[UE_id]->harq_process->nb_rb*12);
pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[eNB_id][i], 12);
// #ifdef LOCALIZATION
// pusch_vars->subcarrier_power = (int32_t *)malloc(ulsch[UE_id]->harq_process->nb_rb*12*sizeof(int32_t));
// pusch_vars->active_subcarrier = subcarrier_energy(pusch_vars->drs_ch_estimates[eNB_id][i],
// ulsch[UE_id]->harq_process->nb_rb*12, pusch_vars->subcarrier_power, rx_power_correction);
// #endif
}
// }
//write_output("rxdataF_ext.m","rxF_ext",pusch_vars->rxdataF_ext[eNB_id][0],300*(frame_parms->symbols_per_tti-ulsch[UE_id]->srs_active),1,1);
//write_output("ulsch_chest.m","drs_est",pusch_vars->drs_ch_estimates[eNB_id][0],300*(frame_parms->symbols_per_tti-ulsch[UE_id]->srs_active),1,1);
// if(cooperation_flag == 2) {
// ulsch_channel_level_NB_IoT(pusch_vars->drs_ch_estimates_0[eNB_id],
// frame_parms,
// avgU_0,
// ulsch[UE_id]->harq_process->nb_rb);
// // printf("[ULSCH] avg_0[0] %d\n",avgU_0[0]);
// avgs_0 = 0;
// for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
// avgs_0 = cmax(avgs_0,avgU_0[(aarx<<1)]);
// log2_maxh_0 = (log2_approx(avgs_0)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+3;
// #ifdef DEBUG_ULSCH
// printf("[ULSCH] log2_maxh_0 = %d (%d,%d)\n",log2_maxh_0,avgU_0[0],avgs_0);
// #endif
// ulsch_channel_level_NB_IoT(pusch_vars->drs_ch_estimates_1[eNB_id],
// frame_parms,
// avgU_1,
// ulsch[UE_id]->harq_process->nb_rb);
// // printf("[ULSCH] avg_1[0] %d\n",avgU_1[0]);
// avgs_1 = 0;
// for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
// avgs_1 = cmax(avgs_1,avgU_1[(aarx<<1)]);
// log2_maxh_1 = (log2_approx(avgs_1)/2) + log2_approx(frame_parms->nb_antennas_rx-1)+3;
// #ifdef DEBUG_ULSCH
// printf("[ULSCH] log2_maxh_1 = %d (%d,%d)\n",log2_maxh_1,avgU_1[0],avgs_1);
// #endif
// log2_maxh = max(log2_maxh_0,log2_maxh_1);
// } else {
ulsch_channel_level_NB_IoT(pusch_vars->drs_ch_estimates[eNB_id],
frame_parms,
avgU,
ulsch[UE_id]->harq_process->nb_rb);
// printf("[ULSCH] avg[0] %d\n",avgU[0]);
avgs = 0;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
avgs = cmax(avgs,avgU[(aarx<<1)]);
// log2_maxh = 4+(log2_approx(avgs)/2);
log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4;
#ifdef DEBUG_ULSCH
printf("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs);
#endif
//}
for (l=0; l<frame_parms->symbols_per_tti; l++) {
if (npusch_format == 1){
if (l==pilot_pos1 || l==pilot_pos2) // skip pilots
{
l++;
}
}
if (npusch_format == 2){
if (l == pilot_pos_format2[0] || l == pilot_pos_format2[1]) // skip 3 pilots
{
l = l + 3;
}
}
// if(cooperation_flag == 2) {
// ulsch_channel_compensation_alamouti_NB_IoT(
// pusch_vars->rxdataF_ext[eNB_id],
// pusch_vars->drs_ch_estimates_0[eNB_id],
// pusch_vars->drs_ch_estimates_1[eNB_id],
// pusch_vars->ul_ch_mag_0[eNB_id],
// pusch_vars->ul_ch_magb_0[eNB_id],
// pusch_vars->ul_ch_mag_1[eNB_id],
// pusch_vars->ul_ch_magb_1[eNB_id],
// pusch_vars->rxdataF_comp_0[eNB_id],
// pusch_vars->rxdataF_comp_1[eNB_id],
// frame_parms,
// l,
// Qm,
// ulsch[UE_id]->harq_process->nb_rb,
// log2_maxh);
// ulsch_alamouti_NB_IoT(frame_parms,
// pusch_vars->rxdataF_comp[eNB_id],
// pusch_vars->rxdataF_comp_0[eNB_id],
// pusch_vars->rxdataF_comp_1[eNB_id],
// pusch_vars->ul_ch_mag[eNB_id],
// pusch_vars->ul_ch_magb[eNB_id],
// pusch_vars->ul_ch_mag_0[eNB_id],
// pusch_vars->ul_ch_magb_0[eNB_id],
// pusch_vars->ul_ch_mag_1[eNB_id],
// pusch_vars->ul_ch_magb_1[eNB_id],
// l,
// ulsch[UE_id]->harq_process->nb_rb);
// } else {
ulsch_channel_compensation_NB_IoT(
pusch_vars->rxdataF_ext[eNB_id],
pusch_vars->drs_ch_estimates[eNB_id],
pusch_vars->ul_ch_mag[eNB_id],
pusch_vars->ul_ch_magb[eNB_id],
pusch_vars->rxdataF_comp[eNB_id],
frame_parms,
l,
Qm,
ulsch[UE_id]->harq_process->nb_rb,
log2_maxh); // log2_maxh+I0_shift
// }
//eren
/* if(flagMag == 0){
//writing for the first time
write_output(namepointer_log2,"xxx",log2_maxh,1,1,12);
write_output(namepointer_chMag,"xxx",pusch_vars->ul_ch_mag[eNB_id][0],300,1,11);
//namepointer_chMag = NULL;
flagMag=1;
}*/
if (frame_parms->nb_antennas_rx > 1)
ulsch_detection_mrc_NB_IoT(frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->ul_ch_mag[eNB_id],
pusch_vars->ul_ch_magb[eNB_id],
l,
ulsch[UE_id]->harq_process->nb_rb);
// #ifndef OFDMA_ULSCH
// if ((eNB->measurements->n0_power_dB[0]+3)<pusch_vars->ulsch_power[0]) {
// freq_equalization_NB_IoT(frame_parms,
// pusch_vars->rxdataF_comp[eNB_id],
// pusch_vars->ul_ch_mag[eNB_id],
// pusch_vars->ul_ch_magb[eNB_id],
// l,
// ulsch[UE_id]->harq_process->nb_rb*12,
// Qm);
freq_equalization_NB_IoT(frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->ul_ch_mag[eNB_id],
pusch_vars->ul_ch_magb[eNB_id],
l,
12,
Qm);
// }
// #endif
// this function is added in to fill the RB resource elements with zeros
// before processing the IFDT, in order to avoid absurd values
fill_rbs_zeros_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
UE_id,
l);
}
// #ifndef OFDMA_ULSCH
//#ifdef DEBUG_ULSCH
// Inverse-Transform equalized outputs
// printf("Doing IDFTs\n");
// lte_idft_NB_IoT(frame_parms,
// (uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0],
// ulsch[UE_id]->harq_process->nb_rb*12);
// lte_idft_NB_IoT(frame_parms,
// (uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0],
// ulsch[UE_id]->harq_process->12);
lte_idft_NB_IoT(frame_parms,
(uint32_t*)pusch_vars->rxdataF_comp[eNB_id][0],
12);
// printf("Done\n");
//#endif //DEBUG_ULSCH
// #endif
llrp = (int16_t*)&pusch_vars->llr[0];
T(T_ENB_PHY_PUSCH_IQ, T_INT(eNB_id), T_INT(UE_id), T_INT(proc->frame_rx),
T_INT(subframe), T_INT(ulsch[UE_id]->harq_process->nb_rb),
T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_tti),
T_BUFFER(pusch_vars->rxdataF_comp[eNB_id][0],
2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2));
for (l=0; l<frame_parms->symbols_per_tti; l++) {
// if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))|| // skip pilots
// ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) {
// l++;
// }
if (npusch_format == 1){
if (l==pilot_pos1 || l==pilot_pos2) // skip pilots
{
l++;
}
// In case of 1 subcarrier: BPSK and QPSK should be rotated by pi/2 and pi/4, respectively
if (Nsc_RU == 1){
rotate_single_carrier_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
UE_id,
l,
1,
0,
Qm,
0);
/* rotate_single_carrier_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol,
uint8_t counter_msg3,
uint32_t I_sc,
uint8_t Qm); */
}
}
if (npusch_format == 2){
if (l == pilot_pos_format2[0] || l == pilot_pos_format2[1]) // skip 3 pilots
{
l = l + 3;
}
// In case of 1 subcarrier: BPSK and QPSK must be rotated by pi/2 and pi/4, respectively
rotate_single_carrier_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
UE_id,
l,
1,
0,
Qm,
0);
}
switch (Qm) {
case 1:
// In case of BPSK, apply a phase rotation of pi/4 before llr, see 36.211, Table 7.1.1-1
rotate_bpsk_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
UE_id,
l);
// BPSK always corresponds to single-carrier
ulsch_bpsk_llr_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->llr,
l,
UE_id,
&llrp);
break;
case 2:
ulsch_qpsk_llr_NB_IoT(eNB,
frame_parms,
pusch_vars->rxdataF_comp[eNB_id],
pusch_vars->llr,
l,
UE_id,
0,
0,
&llrp);
/* ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t UE_id,
uint32_t I_sc,
uint8_t Nsc_RU,
int16_t *llrp);*/
break;
default:
#ifdef DEBUG_ULSCH
printf("ulsch_demodulation.c (rx_ulsch): Unknown Qm!!!!\n");
#endif //DEBUG_ULSCH
break;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// generalization of RX procedures //////////////////////////////////////////
......@@ -2054,25 +1617,25 @@ int32_t llr_msg5[16];
int32_t y_msg5[16];
uint8_t 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, // first received subframe
uint32_t scrambling_frame_msg3, // first received frame
uint16_t nb_slot, // total number of occupied slots
uint16_t I_sc,
uint16_t Nsc_RU, // to remove and create function Nsc_RU = f(I_sc)
uint16_t Mcs,
unsigned int A, // A = TBS
uint16_t counter_msg,
uint8_t subframerx,
uint8_t rvdx)
//uint8_t option) // data (0) or control (1)
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, // first received subframe
uint32_t scrambling_frame_msg3, // first received frame
uint16_t nb_slot, // total number of occupied slots
uint16_t I_sc,
uint16_t Nsc_RU, // to remove and create function Nsc_RU = f(I_sc)
uint16_t Mcs,
unsigned int A, // A = TBS
uint16_t counter_msg,
uint8_t subframerx,
uint8_t rvdx,
uint8_t msg3_flag) // data (0) or control (1)
{
//LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
......@@ -2106,7 +1669,8 @@ uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB *eNB,
//uint8_t I_sc = ulsch[UE_id]->harq_process->I_sc;
// Qm = get_Qm_ul_NB_IoT(ulsch[UE_id]->harq_process->mcs,Nsc_RU); // I_msc is in the UL grant
Qm = get_Qm_ul_NB_IoT(Mcs,Nsc_RU);
Qm = get_Qm_UL_NB_IoT( Mcs,Nsc_RU,I_sc,msg3_flag);
switch(npusch_format + subcarrier_spacing*2)
{
......
......@@ -534,7 +534,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
proc->frame_dscr_msg5 = framerx;
proc->subframe_dscr_msg5 = subframerx;
}
/*
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0,//eNB_id, // this is the effective sector id
......@@ -554,7 +554,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
proc->counter_msg5,
subframerx, //current_rx_subframe,
0); // data (0) or control (1)
*/
proc->subframe_msg5++;
......@@ -581,7 +581,7 @@ 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;
/*
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0,//eNB_id, // this is the effective sector id
......@@ -601,7 +601,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
proc->counter_msg3,
subframerx,
0); // data (0) or control (1)
*/
proc->counter_msg3--;
}
......
......@@ -1616,7 +1616,6 @@ void npusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t data_or_c
nulsch->flag_scramble = 0;
}
/*
// UE has ULSCH scheduling
for (int rb=0; rb<=ulsch_harq->nb_rb; rb++)
......@@ -1632,6 +1631,8 @@ void npusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t data_or_c
ulsch_harq->V_UL_DAI,
ulsch_harq->nb_rb>20 ? 1 : 0);*/
// fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti);
uint16_t N_slots = get_UL_slots_per_RU_NB_IoT(nulsch_harq->subcarrier_spacing, nulsch_harq->subcarrier_indication, nulsch->npusch_format)*get_UL_N_ru_NB_IoT(nulsch_harq->mcs,nulsch_harq->resource_assignment,nulsch->Msg3_flag);
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0, // this is the effective sector id
......@@ -1643,19 +1644,18 @@ void npusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t data_or_c
nulsch->rnti, //= 65522
nulsch->Msg3_subframe, // first received subframe
nulsch->Msg3_frame, // first received frame
get_UL_slots_per_RU_NB_IoT(nulsch_harq->subcarrier_spacing, nulsch_harq->subcarrier_indication, nulsch->npusch_format)*get_UL_N_ru_NB_IoT(nulsch_harq->mcs,nulsch_harq->resource_assignment,nulsch->Msg3_flag), // total number of occupied slots = get_nb_slot_per_RU * NB_of_RU
N_slots, // total number of occupied slots = get_nb_slot_per_RU * NB_of_RU
get_UL_sc_index_start_NB_IoT(nulsch_harq->subcarrier_spacing,nulsch_harq->subcarrier_indication,nulsch->npusch_format),
1,
2,
get_UL_N_ru_NB_IoT(nulsch_harq->mcs,nulsch_harq->resource_assignment,nulsch->Msg3_flag), // N_RU
nulsch_harq->mcs, // I_mcs
nulsch_harq->TBS, // A = TBS
proc->counter_msg3, // this represents the number of Subframe after encoding the msg3 // proc->counter_msg3
N_slots/2, ///proc->counter_msg3, // this represents the number of Subframe after encoding the msg3 // proc->counter_msg3
subframerx,
0);
0,
nulsch->Msg3_flag);
}
} // for UE loop
}
\ No newline at end of file
......@@ -971,6 +971,31 @@ void maintain_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t
}
}
//// get I_TBS for any NPUSCH config
uint8_t I_TBS_index_single_tone[11]= {0,2,1,3,4,5,6,7,8,9,10};
uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag)
{
if(Msg3_flag == 1)
{
return I_mcs;
} else {
if(N_sc_RU == 1)
{
return I_TBS_index_single_tone[I_mcs];
} else {
return I_mcs;
}
}
}
/*Get MCS index*/
uint32_t get_I_mcs(int CE_level)
{
......
......@@ -291,8 +291,10 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
//contidition should be added to select either the UL_TBS_Table or t UL_TBS_table_msg3
//(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.size = UL_TBS_Table[((DCIFormatN0_t *)DCI_pdu)->mcs][((DCIFormatN0_t *)DCI_pdu)->ResAssign];
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.size = UL_TBS_Table_msg3[((DCIFormatN0_t *)DCI_pdu)->mcs]; // for the case of MSG3
//(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.size = UL_TBS_Table[get_UL_I_TBS_from_MCS_NB_IoT(((DCIFormatN0_t *)DCI_pdu)->mcs, get_N_RU(), 0)][((DCIFormatN0_t *)DCI_pdu)->ResAssign];
// get_UL_I_TBS_from_MCS_NB_IoT() to be used to get the I_TBS for any NPUSCH format
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.size = UL_TBS_Table_msg3[get_UL_I_TBS_from_MCS_NB_IoT(((DCIFormatN0_t *)DCI_pdu)->mcs, 0, 1)]; // for the case of MSG3
//LOG_D(MAC,"test\n");
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.rnti = schedule_result_list_UL->rnti; //TODO : check if it is the right rnti // get from msg2
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.subcarrier_indication = ((DCIFormatN0_t *)DCI_pdu)->scind;
......@@ -302,7 +304,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.repetition_number = ((DCIFormatN0_t *)DCI_pdu)->RepNum;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.new_data_indication = ((DCIFormatN0_t *)DCI_pdu)->ndi;
}else if(schedule_result_list_UL->npusch_format == 1){
} else if(schedule_result_list_UL->npusch_format == 1){
DCI_pdu = schedule_result_list_UL->DCI_pdu;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.nulsch_format = 1;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.rnti = schedule_result_list_UL->rnti;
......
......@@ -186,6 +186,11 @@ uint32_t get_I_mcs(int CE_level);
uint32_t get_max_tbs(uint32_t I_tbs);
uint32_t get_tbs(uint32_t data_size, uint32_t I_tbs, uint32_t *I_sf);
uint32_t get_num_sf(uint32_t I_sf);
//////
uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag);
//////
uint32_t get_scheduling_delay(uint32_t I_delay, uint32_t R_max);
uint32_t get_HARQ_delay(int subcarrier_spacing, uint32_t HARQ_delay_index);
//void generate_scheduling_result_DL(uint32_t DCI_subframe, uint32_t NPDSCH_subframe, uint32_t HARQ_subframe, DCIFormatN1_t *DCI, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
......
......@@ -60,7 +60,7 @@ const uint32_t mapped_mcs[3][8]={{1,5,9,10,3,7,11,12},
//TBS table for NPUSCH transmission TS 36.213 v14.2 table Table 16.5.1.2-2:
const int UL_TBS_Table[14][8]=
{
{16,2,56,88,120,152,208,256},
{16,32,56,88,120,152,208,256},
{24,56,88,144,176,208,256,344},
{32,72,144,176,208,256,328,424},
{40,104,176,208,256,328,440,568},
......
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