Commit 72f01769 authored by Matthieu Kanj's avatar Matthieu Kanj

msg2 & msg3 functions

parent b07dc0f8
......@@ -1680,7 +1680,7 @@ void phy_init_lte_top_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms)
//generate_16qam_table();
// generate_RIV_tables();
// init_unscrambling_lut();
init_unscrambling_lut_NB_IoT();
// init_scrambling_lut();
//set_taus_seed(1328);
......
......@@ -50,24 +50,15 @@ 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);
int lte_ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
module_id_t eNB_id,
module_id_t UE_id,
uint8_t l,
uint8_t Ns,
uint8_t cooperation_flag);
////////// Vincent: NB-IoT specific adapted function for channel estimation ////////////////////
int ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
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);
////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -75,7 +66,7 @@ int16_t lte_ul_freq_offset_estimation_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *ul_ch_estimates,
uint16_t nb_rb);
void freq_equalization_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
void freq_equalization_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int **rxdataF_comp,
int **ul_ch_mag,
int **ul_ch_mag_b,
......
......@@ -282,7 +282,7 @@ int16_t inv_ch_NB_IoT[256*8] = {512,512,512,512,512,512,512,512,
2,2,2,2,2,2,2,2,
};
void freq_equalization_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
void freq_equalization_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
......
......@@ -93,17 +93,18 @@ void rotate_channel_single_carrier_NB_IoT(int16_t *estimated_channel,unsigned ch
}
int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
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)
{
NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
LTE_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
int32_t **ul_ch_estimates=pusch_vars->drs_ch_estimates[eNB_id];
//int32_t **ul_ch_estimates_time= pusch_vars->drs_ch_estimates_time[eNB_id];
//int32_t **ul_ch_estimates_0= pusch_vars->drs_ch_estimates_0[eNB_id];
......@@ -150,7 +151,7 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
////// NB-IoT specific ///////////////////////////////////////////////////////////////////////////////////////
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t I_sc = 11; /// eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint16_t ul_sc_start; // subcarrier start index into UL RB
// 36.211, Section 10.1.4.1.2, Table 10.1.4.1.2-3
......@@ -180,7 +181,7 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int16_t *p_alpha_re, *p_alpha_im; // pointers to tables alpha above;
uint8_t threetnecyclicshift=0, sixtonecyclichift=0; // NB-IoT: to be defined from higher layer, see 36.211 Section 10.1.4.1.2
uint8_t actual_cyclicshift;
uint8_t Nsc_RU = eNB->ulsch[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
//uint8_t Nsc_RU = eNB->ulsch_NB_IoT[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
unsigned int index_Nsc_RU=4; // Vincent: index_Nsc_RU 0,1,2,3 ---> number of sc 1,3,6,12
int16_t *received_data, *estimated_channel, *pilot_sig; // pointers to
uint8_t npusch_format = 1; // NB-IoT: format 1 (data), or 2: ack. Should be defined in higher layer
......@@ -200,7 +201,7 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
///////////////////////////////////////////////////////////////////////////////////////
switch (Nsc_RU){
switch (N_sc_RU){
case 1:
index_Nsc_RU = 0;
break;
......@@ -229,7 +230,8 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
}
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
u=frame_parms->npusch_config_common.ul_ReferenceSignalsNPUSCH.grouphop[n_s][index_Nsc_RU]; // Vincent: may be adapted for Nsc_RU, see 36.211, Section 10.1.4.1.3
//u=frame_parms->npusch_config_common.ul_ReferenceSignalsNPUSCH.grouphop[n_s][index_Nsc_RU]; // Vincent: may be adapted for Nsc_RU, see 36.211, Section 10.1.4.1.3
u=Ncell_ID%16;
switch (npusch_format){
case 1:
if (l == pilot_pos1) { // NB-IoT: no extended CP
......@@ -254,41 +256,41 @@ int32_t ul_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
(int32_t)received_data[k<<1]*(int32_t)pilot_sig[(k<<1)+1])>>15); //imaginary part of estimated channel
}
if (Nsc_RU == 1){ // rotate the estimated channel by pi/2 or pi/4, due to mapping b2c
Qm = get_Qm_ul_NB_IoT(eNB->ulsch[UE_id]->harq_process->mcs,Nsc_RU);
if (N_sc_RU == 1){ // rotate the estimated channel by pi/2 or pi/4, due to mapping b2c
Qm = get_Qm_ul_NB_IoT(2,N_sc_RU); ////eNB->ulsch_NB_IoT[UE_id]->harq_process->mcs,N_sc_RU);
rotate_channel_single_carrier_NB_IoT(estimated_channel,l,Qm);
}
if(Nsc_RU != 1 && Nsc_RU != 12) {
if(N_sc_RU != 1 && N_sc_RU != 12) {
// Compensating for the phase shift introduced at the transmitter
// In NB-IoT NPUSCH format 1, phase alpha is zero when 1 and 12 subcarriers are allocated
// else (still format 1), alpha is defined in 36.211, Table 10.1.4.1.2-3
if (Nsc_RU == 3){
if (N_sc_RU == 3){
p_alpha_re = alpha3_re;
p_alpha_im = alpha3_im;
actual_cyclicshift = threetnecyclicshift;
}else if (Nsc_RU == 6){
actual_cyclicshift = threetnecyclicshift; //// should be defined in higher layer
}else if (N_sc_RU == 6){
p_alpha_re = alpha6_re;
p_alpha_im = alpha6_im;
actual_cyclicshift = sixtonecyclichift;
actual_cyclicshift = sixtonecyclichift; //// should be defined in higher layer
}else{
msg("lte_ul_channel_estimation_NB-IoT: wrong Nsc_RU value, Nsc_RU=%d\n",Nsc_RU);
msg("lte_ul_channel_estimation_NB-IoT: wrong N_sc_RU value, N_sc_RU=%d\n",N_sc_RU);
return(-1);
}
for(i=symbol_offset+ul_sc_start; i<symbol_offset+ul_sc_start+Nsc_RU; i++) {
for(i=symbol_offset+ul_sc_start; i<symbol_offset+ul_sc_start+N_sc_RU; i++) {
ul_ch_estimates_re = ((int16_t*) ul_ch_estimates[aa])[i<<1];
ul_ch_estimates_im = ((int16_t*) ul_ch_estimates[aa])[(i<<1)+1];
// ((int16_t*) ul_ch_estimates[aa])[i<<1] = (i%2 == 1? 1:-1) * ul_ch_estimates_re;
((int16_t*) ul_ch_estimates[aa])[i<<1] =
(int16_t) (((int32_t) (p_alpha_re[actual_cyclicshift*Nsc_RU+i]) * (int32_t) (ul_ch_estimates_re) +
(int32_t) (p_alpha_im[actual_cyclicshift*Nsc_RU+i]) * (int32_t) (ul_ch_estimates_im))>>15);
(int16_t) (((int32_t) (p_alpha_re[actual_cyclicshift*N_sc_RU+i]) * (int32_t) (ul_ch_estimates_re) +
(int32_t) (p_alpha_im[actual_cyclicshift*N_sc_RU+i]) * (int32_t) (ul_ch_estimates_im))>>15);
//((int16_t*) ul_ch_estimates[aa])[(i<<1)+1] = (i%2 == 1? 1:-1) * ul_ch_estimates_im;
((int16_t*) ul_ch_estimates[aa])[(i<<1)+1] =
(int16_t) (((int32_t) (p_alpha_re[actual_cyclicshift*Nsc_RU+i]) * (int32_t) (ul_ch_estimates_im) -
(int32_t) (p_alpha_im[actual_cyclicshift*Nsc_RU+i]) * (int32_t) (ul_ch_estimates_re))>>15);
(int16_t) (((int32_t) (p_alpha_re[actual_cyclicshift*N_sc_RU+i]) * (int32_t) (ul_ch_estimates_im) -
(int32_t) (p_alpha_im[actual_cyclicshift*N_sc_RU+i]) * (int32_t) (ul_ch_estimates_re))>>15);
}
......
......@@ -378,7 +378,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
}
uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe)
uint8_t subframe2harq_pid_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
/*
......@@ -392,7 +392,7 @@ uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t fra
uint8_t ret = 255;
if (frame_parms->frame_type == FDD_NB_IoT) {
if (frame_parms->frame_type == FDD) {
ret = (((frame<<1)+subframe)&7);
} else {
......
......@@ -176,7 +176,7 @@ if(option ==1)
npbch_a[i] = a[i];
}
} else {
for (int i=0; i<33; i++)
for (int i=0; i<6; i++)
{
npbch_a[i] = a[i];
}
......
......@@ -103,7 +103,7 @@ int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_UE_PDSCH **pdsch_vars;
NB_IoT_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
PHY_MEASUREMENTS_NB_IoT *measurements = &ue->measurements;
NB_IoT_UE_DLSCH_t **dlsch;
/////////////////////////////////////////////////////////////////NB_IoT_UE_DLSCH_t **dlsch;
int avg[4];
// int avg_0[2];
......@@ -111,7 +111,7 @@ int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
unsigned char aatx,aarx;
unsigned short nb_rb = 0 , round;
unsigned short nb_rb = 0; ////////// round;
int avgs /*,rb*/;
NB_IoT_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0;
......@@ -142,7 +142,7 @@ int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
// case PDSCH:
pdsch_vars = ue->pdsch_vars[subframe&0x1];
dlsch = ue->dlsch[subframe&0x1][eNB_id];
////////////////////////////////////////////////////////// dlsch = ue->dlsch[subframe&0x1][eNB_id];
//printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status);
// LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n",
// frame,subframe,symbol,harq_pid,
......@@ -196,8 +196,8 @@ int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
// printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1);
// #endif
DevAssert(dlsch0_harq);
round = dlsch0_harq->round;
//////////////////////DevAssert(dlsch0_harq);
///////////////////////////////////////// round = dlsch0_harq->round;
//printf("round = %d\n", round);
// if (eNB_id > 2) {
......
......@@ -206,6 +206,7 @@ void init_unscrambling_lut() {
}
}
void init_scrambling_lut() {
uint32_t s;
......
......@@ -45,6 +45,7 @@
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/impl_defs_lte.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "openair1/PHY/extern_NB_IoT.h"
void dlsch_sib_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_DL_eNB_SIB_t *dlsch,
......@@ -104,3 +105,16 @@ void dlsch_sib_scrambling_rar_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
}
}
void init_unscrambling_lut_NB_IoT() {
uint32_t s;
int i=0,j;
for (s=0;s<=65535;s++) {
for (j=0;j<16;j++) {
unscrambling_lut_NB_IoT[i++] = (int16_t)((((s>>j)&1)<<1)-1);
}
}
}
......@@ -35,7 +35,7 @@
//#define DEBUG_GROUPHOP 1
void generate_grouphop_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms)
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms)
{
uint8_t ns;
......
......@@ -301,7 +301,7 @@ err
uint16_t subcarrier_estimation(int16_t *input_buffer){
uint16_t estimated_sc;
uint16_t estimated_sc=0;
int16_t *s_n_re, *s_n_im;
uint16_t k,m,n;
int64_t max_correl_sc_m = 0;
......@@ -364,7 +364,8 @@ p_output_buffer=output_buffer;
void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx){
int n,k;
int n;
//int k;
//float f_s_RB22 = 1807.5;
//float f_s = 7680;
//int16_t *signal_compensed_re, *signal_compensed_im;
......@@ -407,17 +408,17 @@ void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t
uint32_t RX_NPRACH_NB_IoT(PHY_VARS_eNB *eNB, int frame){
uint32_t estimated_TA_coarse=0;
uint32_t estimated_TA;
int16_t *Rx_sub_sampled_buffer_128,*Rx_sub_sampled_buffer_16;
//uint32_t estimated_TA_coarse=0;
//uint32_t estimated_TA;
int16_t *Rx_sub_sampled_buffer_128; // *Rx_sub_sampled_buffer_16;
uint16_t sub_sampling_rate; //NB-IoT: to be defined somewhere
uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx; // NB-IoT: length of input buffer, to be defined somewhere
uint32_t FRAME_LENGTH_COMPLEX_SUB_SAMPLES; // Length of buffer after sub-sampling
uint32_t *length_ouput; // Length of buffer after sub-sampling
uint8_t coarse=1; // flag that indicate the level of TA estimation
// uint8_t coarse=1; // flag that indicate the level of TA estimation
int16_t *Rx_buffer;
//int16_t *filtered_buffer;
int n;
//int n;
//// 1. Coarse TA estimation using sub sampling rate = 128, i.e. fs = 240 kHz
......@@ -453,7 +454,7 @@ uint32_t RX_NPRACH_NB_IoT(PHY_VARS_eNB *eNB, int frame){
// 2. Fine TA estimation using sub sampling rate = 16, i.e. fs = 1.92 MHz
// Sub-sampling stage /============================================================/
/*sub_sampling_rate = FRAME_LENGTH_COMPLEX_SAMPLESx/(2400*8);
//// sub_sampling_rate = FRAME_LENGTH_COMPLEX_SAMPLESx/(2400*8);
Rx_sub_sampled_buffer_16 = sub_sampling_NB_IoT(filtered_buffer,FRAME_LENGTH_COMPLEX_SAMPLESx,length_ouput, sub_sampling_rate);
......@@ -465,7 +466,7 @@ uint32_t RX_NPRACH_NB_IoT(PHY_VARS_eNB *eNB, int frame){
sub_sampling_rate,
FRAME_LENGTH_COMPLEX_SUB_SAMPLES,
estimated_TA_coarse,
coarse); */
coarse); //
// Needs to be stored in a variable in PHY_VARS_eNB_NB_IoT structure
//for (n=0;n<FRAME_LENGTH_COMPLEX_SAMPLESx;n++){
......
......@@ -26,7 +26,7 @@ void generate_pilots_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms;
uint16_t subframe = Ntti;
uint32_t tti,tti_offset,slot_offset,Nsymb,samples_per_symbol;
uint32_t tti_offset,slot_offset,Nsymb,samples_per_symbol; // tti,
uint8_t first_pilot,second_pilot;
unsigned short RB_IoT_ID = RB_ID;
Nsymb = 14;
......
......@@ -37,6 +37,7 @@
//#include <math.h>
//NPSS
void init_unscrambling_lut_NB_IoT(void);
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
......@@ -196,8 +197,8 @@ 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_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
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,
......@@ -212,10 +213,10 @@ NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(//unsigned char Kmimo,
NB_IoT_DL_FRAME_PARMS* frame_parms);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
// NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
uint8_t subframe2harq_pid_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213.
......@@ -313,8 +314,8 @@ int dlsch_encoding_rar_NB_IoT(unsigned char *a,
unsigned int G,
uint8_t option);
/////////////////////////////////////////////////////////////////
void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
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,
......@@ -323,13 +324,31 @@ void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
// uint32_t first_rb,
// uint32_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
uint16_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
uint8_t N_sc_RU, // number of subcarriers in UL
// uint32_t I_sc, // subcarrier indication field
uint32_t nb_rb,
uint8_t l,
uint8_t Ns,
NB_IoT_DL_FRAME_PARMS *frame_parms);
LTE_DL_FRAME_PARMS *frame_parms);
void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint16_t nb_rb);
void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates_ext,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
int32_t **rxdataF_comp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t Qm,
uint16_t nb_rb,
uint8_t output_shift);
void lte_idft_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH);
void extract_CQI_NB_IoT(void *o,UCI_format_NB_IoT_t uci_format,NB_IoT_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode);
......@@ -352,41 +371,41 @@ void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t
//*****************Vincent part for ULSCH demodulation ******************//
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc);
void generate_grouphop_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void 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 Qm);
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol);
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t ulsch_bpsk_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 uint8_t,
int16_t **llrp);
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t 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,
int16_t **llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void rotate_bpsk_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol);
......@@ -447,6 +466,12 @@ int dlsch_qpsk_llr_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int16_t **llr32p,
uint8_t beamforming_mode);
////////////////////////////NB-IoT testing ///////////////////////////////
void clean_eNb_ulsch_NB_IoT(NB_IoT_eNB_NULSCH_t *ulsch);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
//************************************************************//
......
......@@ -64,6 +64,181 @@
*/
#include "UTIL/LOG/vcd_signal_dumper.h"
//#define DEBUG_ULSCH_DECODING
/////////////////////////////////////////////////// NB-IoT testing ////////////////////////////////////////
void free_eNB_ulsch_NB_IoT(NB_IoT_eNB_NULSCH_t *ulsch)
{
int r;
if (ulsch) {
if (ulsch->harq_process) {
if (ulsch->harq_process->b) {
free16(ulsch->harq_process->b,MAX_ULSCH_PAYLOAD_BYTES);
ulsch->harq_process->b = NULL;
}
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
free16(ulsch->harq_process->c[r],((r==0)?8:0) + 768);
ulsch->harq_process->c[r] = NULL;
}
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++)
if (ulsch->harq_process->d[r]) {
free16(ulsch->harq_process->d[r],((3*8*6144)+12+96)*sizeof(short));
ulsch->harq_process->d[r] = NULL;
}
free16(ulsch->harq_process,sizeof(NB_IoT_UL_eNB_HARQ_t));
ulsch->harq_process = NULL;
}
free16(ulsch,sizeof(NB_IoT_eNB_NULSCH_t));
ulsch = NULL;
}
}
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag)
{
NB_IoT_eNB_NULSCH_t *ulsch;
uint8_t exit_flag = 0,r;
unsigned char bw_scaling =1;
switch (N_RB_UL) {
case 6:
bw_scaling =16;
break;
case 25:
bw_scaling =4;
break;
case 50:
bw_scaling =2;
break;
default:
bw_scaling =1;
break;
}
ulsch = (NB_IoT_eNB_NULSCH_t *)malloc16(sizeof(NB_IoT_eNB_NULSCH_t));
if (ulsch) {
memset(ulsch,0,sizeof(NB_IoT_eNB_NULSCH_t));
ulsch->max_turbo_iterations = max_turbo_iterations;
ulsch->Mlimit = 4;
// printf("new_ue_ulsch: Harq process %d\n",i);
ulsch->harq_process = (NB_IoT_UL_eNB_HARQ_t *)malloc16(sizeof(NB_IoT_UL_eNB_HARQ_t));
if (ulsch->harq_process) {
memset(ulsch->harq_process,0,sizeof(NB_IoT_UL_eNB_HARQ_t));
ulsch->harq_process->b = (uint8_t*)malloc16(MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
if (ulsch->harq_process->b)
memset(ulsch->harq_process->b,0,MAX_ULSCH_PAYLOAD_BYTES/bw_scaling);
else
exit_flag=3;
if (abstraction_flag==0) {
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS/bw_scaling; r++) {
ulsch->harq_process->c[r] = (uint8_t*)malloc16(((r==0)?8:0) + 3+768);
if (ulsch->harq_process->c[r])
memset(ulsch->harq_process->c[r],0,((r==0)?8:0) + 3+768);
else
exit_flag=2;
ulsch->harq_process->d[r] = (short*)malloc16(((3*8*6144)+12+96)*sizeof(short));
if (ulsch->harq_process->d[r])
memset(ulsch->harq_process->d[r],0,((3*8*6144)+12+96)*sizeof(short));
else
exit_flag=2;
}
ulsch->harq_process->subframe_scheduling_flag = 0;
}
} else {
exit_flag=1;
}
if (exit_flag==0)
return(ulsch);
}
LOG_E(PHY,"new_ue_ulsch: exit_flag = %d\n",exit_flag);
free_eNB_ulsch_NB_IoT(ulsch);
return(NULL);
}
void clean_eNb_ulsch_NB_IoT(NB_IoT_eNB_NULSCH_t *ulsch)
{
unsigned char i;
//ulsch = (LTE_eNB_ULSCH_t *)malloc16(sizeof(LTE_eNB_ULSCH_t));
if (ulsch) {
ulsch->rnti = 0;
if (ulsch->harq_process) {
// ulsch->harq_processes[i]->Ndi = 0;
ulsch->harq_process->status = 0;
ulsch->harq_process->subframe_scheduling_flag = 0;
//ulsch->harq_processes[i]->phich_active = 0; //this will be done later after transmission of PHICH
ulsch->harq_process->phich_ACK = 0;
ulsch->harq_process->round = 0;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch)
{
......@@ -746,14 +921,14 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr
// NB_IoT: functions in ulsch_decoding_data_NB_IoT must be defined
int ulsch_decoding_data_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,int UE_id,int harq_pid,int llr8_flag) {
int ulsch_decoding_data_NB_IoT(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
unsigned int r,r_offset=0,Kr,Kr_bytes,iind;
uint8_t crc_type;
int offset = 0;
int ret = 1;
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)];
NB_IoT_eNB_NULSCH_t *ulsch = eNB->ulsch[UE_id];
NB_IoT_eNB_NULSCH_t *ulsch = eNB->ulsch_NB_IoT[UE_id];
// NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_process[harq_pid];
NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_process;
//int Q_m = get_Qm_ul(ulsch_harq->mcs);
......@@ -768,13 +943,13 @@ int ulsch_decoding_data_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,int UE_id,int harq_pid,i
uint8_t,
uint8_t,
uint8_t,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *,
time_stats_t_NB_IoT *);
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *);
if (llr8_flag == 0)
tc = phy_threegpplte_turbo_decoder16;
......@@ -943,8 +1118,8 @@ static inline unsigned int lte_gold_unscram_NB_IoT(unsigned int *x1, unsigned in
}
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
......@@ -953,8 +1128,8 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
int16_t *ulsch_llr = eNB->pusch_vars[UE_id]->llr;
NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_eNB_NULSCH_t *ulsch = eNB->ulsch[UE_id];
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_eNB_NULSCH_t *ulsch = eNB->ulsch_NB_IoT[UE_id];
NB_IoT_UL_eNB_HARQ_t *ulsch_harq;
uint8_t harq_pid;
......
......@@ -21,11 +21,11 @@
/*! \file PHY/LTE_TRANSPORT/ulsch_demodulation.c
* \brief Top-level routines for demodulating the PUSCH physical channel from 36.211 V8.6 2009-03
* \author R. Knopp
* \date 2011
* \authors V. Savaux, M. Kanj
* \date 2018
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, ankit.bhamri@eurecom.fr
* \company b<>com
* \email: vincent.savaux@b-com.com , matthieu.kanj@b-com.com
* \note
* \warning
*/
......@@ -48,7 +48,7 @@ static short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0};
static short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1};
#ifndef OFDMA_ULSCH
void lte_idft_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH)
void lte_idft_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH)
{
#if defined(__x86_64__) || defined(__i386__)
__m128i idft_in128[3][1200],idft_out128[3][1200];
......@@ -440,8 +440,8 @@ void lte_idft_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Ms
#endif
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
......@@ -450,7 +450,7 @@ int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
{
int16_t *rxF;
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t I_sc = eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint16_t ul_sc_start; // subcarrier start index into UL RB
// int i;
......@@ -504,8 +504,8 @@ int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
// }
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t 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,
......@@ -515,9 +515,9 @@ int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int32_t *rxF;
int32_t **llrp32 = (int32_t **)llrp;
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t I_sc = eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint16_t ul_sc_start; // subcarrier start index into UL RB
uint8_t Nsc_RU = eNB->ulsch[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
uint8_t Nsc_RU = eNB->ulsch_NB_IoT[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
int i;
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
......@@ -537,7 +537,7 @@ int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
}
void ulsch_detection_mrc_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
void ulsch_detection_mrc_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
......@@ -604,13 +604,13 @@ void ulsch_detection_mrc_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
// uint32_t first_rb,
// uint32_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
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
// 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,
NB_IoT_DL_FRAME_PARMS *frame_parms)
LTE_DL_FRAME_PARMS *frame_parms)
{
uint16_t nb_rb1;
// uint16_t nb_rb2;
......@@ -619,10 +619,10 @@ void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
//uint8_t symbol = l+Ns*frame_parms->symbols_per_tti/2;
uint8_t symbol = l+(7*(Ns&1)); ///symbol within sub-frame
// uint16_t ul_sc_start; // subcarrier start index into UL RB
unsigned short UL_RB_ID_NB_IoT;
//unsigned short UL_RB_ID_NB_IoT;
// ul_sc_start = get_UL_sc_start_NB_IoT(I_sc);
UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID;
//UL_RB_ID_NB_IoT = frame_parms->NB_IoT_RB_ID;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
......@@ -682,7 +682,7 @@ void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
int32_t **rxdataF_comp,
NB_IoT_DL_FRAME_PARMS *frame_parms,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t Qm,
uint16_t nb_rb,
......@@ -1308,15 +1308,15 @@ void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
// #endif
// }
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol)
{
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint8_t Nsc_RU = eNB->ulsch[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
uint32_t I_sc = 11;//eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint8_t Nsc_RU = 1;//eNB->ulsch[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
uint16_t ul_sc_start; // subcarrier start index into UL RB
int32_t *rxdataF_comp32;
uint8_t m; // index of subcarrier
......@@ -1324,27 +1324,32 @@ void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ul_sc_start = get_UL_sc_start_NB_IoT(I_sc); // NB-IoT: get the used subcarrier in RB
rxdataF_comp32 = (int32_t *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12];
if (Nsc_RU != 12){
for (m=0;m<12;m++){ // 12 is the number of subcarriers per RB
if (m == ul_sc_start){
m = m + Nsc_RU; // skip non-zeros subcarriers
}
rxdataF_comp32[m] = 0;
for (m=0;m<12;m++)
{ // 12 is the number of subcarriers per RB
if (m == ul_sc_start)
{
m = m + Nsc_RU; // skip non-zeros subcarriers
}
if(m<12)
{
rxdataF_comp32[m] = 0;
}
}
}
}
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void 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 Qm)
{
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t I_sc = eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint16_t ul_sc_start; // subcarrier start index into UL RB
int16_t pi_2_re[2] = {32767 , 0};
int16_t pi_2_im[2] = {0 , 32768};
......@@ -1374,14 +1379,14 @@ void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
}
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_FRAME_PARMS *frame_parms,
void rotate_bpsk_NB_IoT(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t UE_id,
uint8_t symbol)
{
uint32_t I_sc = eNB->ulsch[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint32_t I_sc = eNB->ulsch_NB_IoT[UE_id]->harq_process->I_sc; // NB_IoT: subcarrier indication field: must be defined in higher layer
uint16_t ul_sc_start; // subcarrier start index into UL RB
int16_t m_pi_4_re = 25735; // cos(pi/4)
int16_t m_pi_4_im = 25736; // sin(pi/4)
......@@ -1485,7 +1490,7 @@ int32x4_t avg128U;
#endif
void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
NB_IoT_DL_FRAME_PARMS *frame_parms,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint16_t nb_rb)
{
......@@ -1550,17 +1555,17 @@ void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
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_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
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;
NB_IoT_eNB_COMMON *common_vars = &eNB->common_vars;
NB_IoT_eNB_PUSCH *pusch_vars = eNB->pusch_vars[UE_id];
NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
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;
......@@ -1576,7 +1581,7 @@ void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
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[UE_id]->harq_process->N_sc_RU; // Vincent: number of sc 1,3,6,12
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
......@@ -1612,7 +1617,7 @@ void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ulsch_extract_rbs_single_NB_IoT(common_vars->rxdataF[eNB_id],
pusch_vars->rxdataF_ext[eNB_id],
// ulsch[UE_id]->harq_process->first_rb,
//ulsch[UE_id]->harq_process->UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block
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
// ulsch[UE_id]->harq_process->I_sc, // subcarrier indication field
ulsch[UE_id]->harq_process->nb_rb,
......@@ -1632,6 +1637,7 @@ void rx_ulsch_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
UE_id,
l%(frame_parms->symbols_per_tti/2),
l/(frame_parms->symbols_per_tti/2),
1,
cooperation_flag);
}
......
......@@ -515,6 +515,8 @@ NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX];
NB_IoT_eNB_NDLSCH_t ndlsch_SIB;
NB_IoT_eNB_NDLSCH_t ndlsch_rar;
NB_IoT_eNB_NPDCCH_temp_t npdcch_tmp;
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT[NUMBER_OF_UE_MAX+1];
////////////// For IF Module /////////////////////////////
IF_Module_NB_IoT_t *if_inst;
......
......@@ -155,6 +155,7 @@ static inline void* malloc16_clear( size_t size )
#else
typedef enum {normal_txrx_NB_IoT=0,rx_calib_ue_NB_IoT=1,rx_calib_ue_med_NB_IoT=2,rx_calib_ue_byp_NB_IoT=3,debug_prach_NB_IoT=4,no_L2_connect_NB_IoT=5,calib_prach_tx_NB_IoT=6,rx_dump_frame_NB_IoT=7,loop_through_memory_NB_IoT=8} runmode_NB_IoT_t;
#endif
/*
enum transmission_access_mode {
NO_ACCESS=0,
......
......@@ -86,7 +86,12 @@ typedef struct {
int next_subframe_tx_DCI;
uint32_t sheduling_info_rar;
uint8_t flag_scrambling;
uint8_t flag_scrambling;
uint8_t flag_msg3;
uint8_t counter_msg3;
uint32_t frame_msg3;
uint8_t remaining_dci;
uint8_t remaining_rar;
......
......@@ -35,6 +35,11 @@
#include "types.h"
////////////////// NB-IoT testing //////////////////
//#include "impl_defs_lte_NB_IoT.h"
///////////////////////////////////////////////////
//#include "defs.h"
#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10
......@@ -63,6 +68,53 @@ typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t;
typedef enum {LOCALIZED=0,DISTRIBUTED=1} vrb_t;
////////////////////////////////////////// NB-IoT testing ///////////////////////////////////////////////////////////////
typedef struct{
/// The base sequence of DMRS sequence in a cell for 3 tones transmission; see TS 36.211 [21, 10.1.4.1.2]. If absent, it is given by NB-IoT CellID mod 12. Value 12 is not used.
uint16_t threeTone_BaseSequence;
/// Define 3 cyclic shifts for the 3-tone case, see TS 36.211 [21, 10.1.4.1.2].
uint16_t threeTone_CyclicShift;
/// The base sequence of DMRS sequence in a cell for 6 tones transmission; see TS 36.211 [21, 10.1.4.1.2]. If absent, it is given by NB-IoT CellID mod 14. Value 14 is not used.
uint16_t sixTone_BaseSequence;
/// Define 4 cyclic shifts for the 6-tone case, see TS 36.211 [21, 10.1.4.1.2].
uint16_t sixTone_CyclicShift;
/// The base sequence of DMRS sequence in a cell for 12 tones transmission; see TS 36.211 [21, 10.1.4.1.2]. If absent, it is given by NB-IoT CellID mod 30. Value 30 is not used.
uint16_t twelveTone_BaseSequence;
}DMRS_CONFIGx_t;
/// UL-ReferenceSignalsNPUSCH from 36.331 RRC spec
typedef struct {
/// Parameter: Group-hopping-enabled, see TS 36.211 (5.5.1.3). \vr{[0..1]}
uint8_t groupHoppingEnabled;
/// , see TS 36.211 (5.5.1.3). \vr{[0..29]}
uint8_t groupAssignmentNPUSCH;
/// Parameter: cyclicShift, see TS 36.211 (Table 5.5.2.1.1-2). \vr{[0..7]}
uint8_t cyclicShift;
/// nPRS for cyclic shift of DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification.
uint8_t nPRS[20];
/// group hopping sequence for DMRS, 36.211, Section 10.1.4.1.3. Second index corresponds to the four possible subcarrier configurations
uint8_t grouphop[20][4];
/// sequence hopping sequence for DRS \note not part of offical UL-ReferenceSignalsPUSCH ASN1 specification.
uint8_t seqhop[20];
} UL_REFERENCE_SIGNALS_NPUSCHx_t;
/// PUSCH-ConfigCommon from 36.331 RRC spec.
typedef struct {
/// Number of repetitions for ACK/NACK HARQ response to NPDSCH containing Msg4 per NPRACH resource, see TS 36.213 [23, 16.4.2].
uint8_t ack_NACK_NumRepetitions_Msg4[3];
/// SRS SubframeConfiguration. See TS 36.211 [21, table 5.5.3.3-1]. Value sc0 corresponds to value 0, sc1 to value 1 and so on.
uint8_t srs_SubframeConfig;
/// Parameter: \f$N^{HO}_{RB}\f$, see TS 36.211 (5.3.4). \vr{[0..98]}
DMRS_CONFIGx_t dmrs_Config;
/// Ref signals configuration
UL_REFERENCE_SIGNALS_NPUSCHx_t ul_ReferenceSignalsNPUSCH;
} NPUSCH_CONFIG_COMMONx;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Enumeration for parameter PHICH-Duration \ref PHICH_CONFIG_COMMON::phich_duration.
typedef enum {
normal=0,
......@@ -587,6 +639,11 @@ typedef struct {
struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA];
////////////////////////// NB-IoT testing //////////////////////////////
uint8_t subcarrier_spacing;
NPUSCH_CONFIG_COMMONx npusch_config_common;
/////////////////////////////////////////////////////////////////////
} LTE_DL_FRAME_PARMS;
......
......@@ -469,7 +469,7 @@ typedef struct {
/// Ref signals configuration
UL_REFERENCE_SIGNALS_NPUSCH_t ul_ReferenceSignalsNPUSCH;
} NPUSCH_CONFIG_COMMON;
} NPUSCH_CONFIG_COMMON;
typedef struct{
......
......@@ -36,6 +36,10 @@
#include "SCHED/defs.h"
#include "SCHED/extern.h"
///////// NB-IoT testing /////////////////////
#include "PHY/extern_NB_IoT.h"
//#include "PHY/defs_NB_IoT.h"
/////////////////////////////////////////////
#include "PHY/LTE_TRANSPORT/if4_tools.h"
#include "PHY/LTE_TRANSPORT/if5_tools.h"
#include "openair1/SCHED/defs_NB_IoT.h"
......@@ -44,6 +48,11 @@
#include "SCHED/phy_procedures_emos.h"
#endif
////// NB-IoT testing /////////////
#include "PHY/CODING/extern.h"
#include "PHY/LTE_ESTIMATION/defs_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
////////////////////////////////////
//#define DEBUG_PHY_PROC (Already defined in cmake)
//#define DEBUG_ULSCH
......@@ -114,6 +123,35 @@ extern uint8_t smbv_frame_cnt;
extern int rx_sig_fifo;
#endif
static inline unsigned int lte_gold_unscram_NB_IoT(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline));
static inline unsigned int lte_gold_unscram_NB_IoT(unsigned int *x1, unsigned int *x2, unsigned char reset)
{
int n;
if (reset) {
*x1 = 1+ (1<<31);
*x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31);
// skip first 50 double words (1600 bits)
// printf("n=0 : x1 %x, x2 %x\n",x1,x2);
for (n=1; n<50; n++) {
*x1 = (*x1>>1) ^ (*x1>>4);
*x1 = *x1 ^ (*x1<<31) ^ (*x1<<28);
*x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4);
*x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28);
}
}
*x1 = (*x1>>1) ^ (*x1>>4);
*x1 = *x1 ^ (*x1<<31) ^ (*x1<<28);
*x2 = (*x2>>1) ^ (*x2>>2) ^ (*x2>>3) ^ (*x2>>4);
*x2 = *x2 ^ (*x2<<31) ^ (*x2<<30) ^ (*x2<<29) ^ (*x2<<28);
return(*x1^*x2);
// printf("n=%d : c %x\n",n,x1^x2);
}
uint8_t is_SR_subframe(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t UE_id)
{
......@@ -492,13 +530,443 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
int **txdataF = eNB->common_vars.txdataF[0];
uint8_t *pbch_pdu=&eNB->pbch_pdu[0];
//////////////////////////////////////////////////////// to uncomment for LTE, uint8_t *pbch_pdu=&eNB->pbch_pdu[0];
int subframe = proc->subframe_tx;
int frame = proc->frame_tx;
//int With_NSSS=0;
// NB-IoT synchro signals
//int With_NSSS=0;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////// RX NPUSH //////////////////////////////////////
/*
if(subframe>0 && proc->flag_msg3==1 && frame==proc->frame_msg3 && proc->counter_msg3>0) ///&& frame == ????
{
/////////////////////////////////////////////////// NPUSH DEMOD ////////////////////////////////////
// LTE_eNB_COMMON *common_vars = &eNB->common_vars;
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;
int32_t avgU[2];
int32_t avgs;
uint8_t log2_maxh = 0;
uint8_t pilot_pos1 = 3, pilot_pos2 = 10; // holds for npusch format 1, and 15 kHz subcarrier bandwidth
int16_t *llrp;
uint8_t nb_rb=1; //ulsch_NB_IoT[0]->harq_process->nb_rb, //////////////// high level parameter
//buffer_npusch = common_vars->rxdataF[0];
for (l=0; l<fp->symbols_per_tti; l++)
{
ulsch_extract_rbs_single_NB_IoT(eNB->common_vars.rxdataF[0],
pusch_vars->rxdataF_ext[0],
// 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
// ulsch[UE_id]->harq_process->I_sc, // subcarrier indication field
nb_rb,
l%(fp->symbols_per_tti/2),
l/(fp->symbols_per_tti/2),
fp);
ul_channel_estimation_NB_IoT(eNB,proc,
0,
0,
l%(fp->symbols_per_tti/2),
l/(fp->symbols_per_tti/2),
1, // N_sc_RU
0);
}
for (i=0; i<fp->nb_antennas_rx; i++)
{
pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[0][i], 12);
}
ulsch_channel_level_NB_IoT(pusch_vars->drs_ch_estimates[0],
fp,
avgU,
nb_rb);
avgs = 0;
for (i=0; i<fp->nb_antennas_rx; i++)
{
avgs = cmax(avgs,avgU[(i<<1)]);
}
log2_maxh = (log2_approx(avgs)/2)+ log2_approx(fp->nb_antennas_rx-1)+4;
for (l=0; l<fp->symbols_per_tti; l++) {
if (l==pilot_pos1 || l==pilot_pos2) // skip pilots
{
l++;
}
ulsch_channel_compensation_NB_IoT(pusch_vars->rxdataF_ext[0],
pusch_vars->drs_ch_estimates[0],
pusch_vars->ul_ch_mag[0],
pusch_vars->ul_ch_magb[0],
pusch_vars->rxdataF_comp[0],
fp,
l,
2, //Qm
nb_rb,
log2_maxh); // log2_maxh+I0_shift
freq_equalization_NB_IoT(fp,
pusch_vars->rxdataF_comp[0],
pusch_vars->ul_ch_mag[0],
pusch_vars->ul_ch_magb[0],
l,
12, //NscRU: keep 12, even if the actual number of sc is not 12
2); // Qm
fill_rbs_zeros_NB_IoT(eNB,
fp,
pusch_vars->rxdataF_comp[0],
0, // UE ID
l);
}
///////// IDFT inverse precoding is done over the whole subframe of 14 - 2 (pilots) symbols
lte_idft_NB_IoT(fp,
(uint32_t*)pusch_vars->rxdataF_comp[0][0],
12); // IDFT size
llrp = (int16_t*)&pusch_vars->llr[0];
for (l=0; l<fp->symbols_per_tti; l++)
{
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,
fp,
pusch_vars->rxdataF_comp[0],
0, // UE ID
l,
2); // Qm
ulsch_qpsk_llr_NB_IoT(eNB,
fp,
pusch_vars->rxdataF_comp[0],
pusch_vars->llr,
l,
0, // UE ID
&llrp); //// !!! Pensez à créer un buffer de longueur 8 subframes
}
/////////////////////////////////////////////////// NPUSH DECOD ////////////////////////////////////
if(proc->counter_msg3==1)
{
int16_t *ulsch_llr = eNB->pusch_vars[0]->llr; //UE_id=0
//NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
//NB_IoT_eNB_NULSCH_t *ulsch = eNB->ulsch[0];
NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT[0]->harq_process;
//uint8_t harq_pid;
unsigned int A;
uint8_t Q_m;
unsigned int i2,j,j2;
int iprime;
//unsigned int ret = 0;
int r,Kr;
unsigned int sumKr=0;
unsigned int G,H,Hprime,Hpp,Cmux,Rmux_prime; // Q_CQI,Q_RI=0
uint32_t x1, x2, s=0;
int16_t c;
int16_t y[6*14*1200] __attribute__((aligned(32)));
uint8_t ytag[14*1200];
int16_t cseq[6*14*1200];
uint32_t subframe = 1; // first subframe of Msg3 received // required for scrambling
uint32_t rnti_tmp= 65522; // true rnti should be used
// NB-IoT ///////////////////////////////////////////////
// x1 is set in lte_gold_generic
// x2 should not reinitialized each subframe
// x2 should be reinitialized according to 36.211 Sections 10.1.3.1 and 10.1.3.6
x2 = (rnti_tmp<<14) + ((uint32_t)subframe<<9) + ((proc->frame_msg3%2)<<13) + fp->Nid_cell; //this is c_init in 36.211 Sec 10.1.3.1
//ulsch_harq = ulsch[0]->harq_process;
A = 88; // ulsch_harq->TBS;
Q_m = get_Qm_ul_NB_IoT(2,1); ///// ulsch_harq->mcs,ulsch_harq->N_sc_RU
G = (1 * Q_m) * 6 * 16; // Vincent : see 36.212, Section 5.1.4.1.2
//G = ulsch_harq->N_sc_RU * Q_m) * ulsch_harq->Nsymb_UL * ulsch_harq->Nslot_UL; (= number of RE * 2 - pilots)
if (ulsch_harq->round == 0)
{
// This is a new packet, so compute quantities regarding segmentation
ulsch_harq->B = A+24;
lte_segmentation_NB_IoT(NULL,
NULL,
ulsch_harq->B,
&ulsch_harq->C,
&ulsch_harq->Cplus,
&ulsch_harq->Cminus,
&ulsch_harq->Kplus,
&ulsch_harq->Kminus,
&ulsch_harq->F);
// CLEAR LLR's HERE for first packet in process
}
sumKr = 0;
for (r=0; r<ulsch_harq->C; r++)
{
if (r<ulsch_harq->Cminus)
{
Kr = ulsch_harq->Kminus;
}else{
Kr = ulsch_harq->Kplus;
}
sumKr += Kr;
}
ulsch_harq->G = G;
H = G ;
Hprime = H/Q_m;
// Demultiplexing/Deinterleaving of PUSCH/ACK/RI/CQI
Hpp = Hprime;
// Cmux = (ulsch_harq->Nsymb_UL-1)*ulsch_harq->Nslot_UL; // see definition in 36.212, Section 6.3.2, but not consistent with definition
// of RU in 36.211, Section 10.1.2.3. Maybe prefer the following:
Cmux = 6*16; //////////////(ulsch_harq->Nsymb_UL)*ulsch_harq->Nslot_UL;
Rmux_prime = Hpp/Cmux;
// Clear "tag" interleaving matrix to allow for CQI/DATA identification
memset(ytag,0,Cmux*Rmux_prime);
i = 0;
memset(y,LTE_NULL_NB_IoT,Q_m*Hpp);
// 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;
for (i=0; i<((Hpp*Q_m)>>5); i++)
{
#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)];
s>>=16;
((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut_NB_IoT)[(s&65535)<<1];
((__m128i*)cseq)[i2++] = ((__m128i*)unscrambling_lut_NB_IoT)[1+((s&65535)<<1)];
#else
((__m256i*)cseq)[i2++] = ((__m256i*)unscrambling_lut_NB_IoT)[s&65535];
((__m256i*)cseq)[i2++] = ((__m256i*)unscrambling_lut_NB_IoT)[(s>>16)&65535];
#endif
#elif defined(__arm__)
((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut_NB_IoT)[(s&65535)<<1];
((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut_NB_IoT)[1+((s&65535)<<1)];
s>>=16;
((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut_NB_IoT)[(s&65535)<<1];
((int16x8_t*)cseq)[i2++] = ((int16x8_t*)unscrambling_lut_NB_IoT)[1+((s&65535)<<1)];
#endif
s = lte_gold_unscram_NB_IoT(&x1, &x2, 0);
}
i = 0;
switch (Q_m)
{
case 1:
for (j=0; j<Cmux; j++)
{
y[j] = cseq[j]*ulsch_llr[j];
}
break;
case 2:
for (j=0; j<Cmux; j++)
{
i2 = j<<1;
for (r=0; r<Rmux_prime; r++)
{
c = cseq[i];
// printf("ulsch %d: %d * ",i,c);
y[i2++] = c*ulsch_llr[i++];
// printf("%d\n",ulsch_llr[i-1]);
c = cseq[i];
// printf("ulsch %d: %d * ",i,c);
y[i2] = c*ulsch_llr[i++];
// printf("%d\n",ulsch_llr[i-1]);
i2 = (i2+(Cmux<<1)-1);
}
}
break;
}
// CQI and Data bits
j = 0;
j2 = 0;
int16_t *yp,*ep;
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];
ep[1] = yp[1];
ep[2] = yp[2];
ep[3] = yp[3];
ep[4] = yp[4];
ep[5] = yp[5];
ep[6] = yp[6];
ep[7] = yp[7];
}
// Do ULSCH Decoding for data portion
// uint8_t llr8_flag=0; // ? to be verified
// ret = eNB->td(eNB,0,harq_pid,llr8_flag);
r=0;
Kr=0;
unsigned int r_offset=0,Kr_bytes,iind;
uint8_t crc_type;
int offset = 0;
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)];
//NB_IoT_UL_eNB_HARQ_t *ulsch_harq = ulsch_NB_IoT[0]->harq_process; ///
int ret = 1;
unsigned int E;
uint8_t (*tc)(int16_t *y,
uint8_t *,
uint16_t,
uint16_t,
uint16_t,
uint8_t,
uint8_t,
uint8_t,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *);
tc = phy_threegpplte_turbo_decoder16;
for (r=0; r<ulsch_harq->C; r++)
{
// Get Turbo interleaver parameters
if (r<ulsch_harq->Cminus)
{
Kr = ulsch_harq->Kminus;
} else{
Kr = ulsch_harq->Kplus;
}
Kr_bytes = Kr>>3;
if (Kr_bytes<=64)
{
iind = (Kr_bytes-5);
} else if (Kr_bytes <=128) {
iind = 59 + ((Kr_bytes-64)>>1);
} else if (Kr_bytes <= 256) {
iind = 91 + ((Kr_bytes-128)>>2);
} else if (Kr_bytes <= 768) {
iind = 123 + ((Kr_bytes-256)>>3);
} else {
LOG_E(PHY,"ulsch_decoding: Illegal codeword size %d!!!\n",Kr_bytes);
//return(-1);
}
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
(uint8_t*)&dummy_w[r][0],
(r==0) ? ulsch_harq->F : 0);
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
G,
ulsch_harq->w[r],
(uint8_t*) &dummy_w[r][0],
ulsch_harq->e+r_offset,
ulsch_harq->C,
1, //////////////////////////////// not used
0, //Uplink
1,
1,//ulsch_harq->rvidx,
(ulsch_harq->round==0)?1:0, // clear
2,//get_Qm_ul(ulsch_harq->mcs),
1,
r,
&E)==-1)
{
LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n");
//return(-1);
}
r_offset += E;
sub_block_deinterleaving_turbo(4+Kr,
&ulsch_harq->d[r][96],
ulsch_harq->w[r]);
if (ulsch_harq->C == 1)
{
crc_type = CRC24_A;
}else{
crc_type = CRC24_B;
}
ret = tc(&ulsch_harq->d[r][96],
ulsch_harq->c[r],
Kr,
f1f2mat_old[iind*2],
f1f2mat_old[(iind*2)+1],
ulsch_NB_IoT[0]->max_turbo_iterations, //MAX_TURBO_ITERATIONS,
crc_type,
(r==0) ? ulsch_harq->F : 0,
&eNB->ulsch_tc_init_stats,
&eNB->ulsch_tc_alpha_stats,
&eNB->ulsch_tc_beta_stats,
&eNB->ulsch_tc_gamma_stats,
&eNB->ulsch_tc_ext_stats,
&eNB->ulsch_tc_intl1_stats,
&eNB->ulsch_tc_intl2_stats);
if (ret != (1+ulsch_NB_IoT[0]->max_turbo_iterations))
{
if (r<ulsch_harq->Cminus)
{
Kr = ulsch_harq->Kminus;
} else {
Kr = ulsch_harq->Kplus;
Kr_bytes = Kr>>3;
}
if (r==0)
{
memcpy(ulsch_harq->b,
&ulsch_harq->c[0][(ulsch_harq->F>>3)],
Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
} else {
memcpy(ulsch_harq->b+offset,
ulsch_harq->c[r],
Kr_bytes - ((ulsch_harq->C>1)?3:0));
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
}
} else {
break;
}
} // r loop end
printf("pdu[0] = %d",ulsch_harq->b[0]);
printf("pdu[1] = %d",ulsch_harq->b[1]);
printf("pdu[2] = %d",ulsch_harq->b[2]);
printf("pdu[3] = %d",ulsch_harq->b[3]);
//printf("pdu[4] = %d",ulsch_harq->b[4]);
} // NPUSH decode end
proc->counter_msg3--;
}
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
common_signal_procedures_NB_IoT(eNB,proc);
/////////////////// NB-IoT broadcast channel //////////////////////////
......@@ -517,7 +985,10 @@ RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[eNB->Mod_id].common_chan
proc->sheduling_info_rar =1;
proc->rar_to_transmit =0;
proc->SP =0;
proc->flag_scrambling =0;
proc->flag_msg3=0;
proc->frame_msg3=0;
proc->counter_msg3=0;
proc->flag_scrambling =0;
//printf("detection ok in TX !!!!!!!!!!!!!!!!!");
//RA_template[0].generate_rar = 0;
//RA_template[0].RA_active = FALSE;
......@@ -534,7 +1005,7 @@ proc->flag_scrambling =0;
if(((10*frame +subframe) % 8)==2 && subframe != 0 && subframe != 4 && subframe != 6 && proc->SP !=1)
{
printf("\n xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxframe %d, subframe %dxxxxxxxxxxxxxxxxxxxxxxxxxxxx", frame, subframe);
proc->SP =1;
proc->SP =1;
NB_IoT_eNB_NPDCCH_temp_t *npdcch_struct = &eNB->npdcch_tmp;
......@@ -547,17 +1018,17 @@ proc->flag_scrambling =0;
uint16_t npdcch_D = 16 + 23;
uint16_t npdcch_E = 236;
uint8_t agr_level = 2;
uint8_t dci_number=1;
// uint8_t dci_number=1;
uint8_t tab_a[3];
tab_a[0]= 128;
tab_a[1]= 66;
tab_a[2]= 4;
int RB_ID_IoT=22 ;
// int RB_ID_IoT=22 ;
bzero(npdcch_struct->npdcch_e[0],npdcch_E);
memset(npdcch_struct->npdcch_d[0],LTE_NULL_NB_IoT,96);
ccode_encode_NB_IoT (numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
ccode_encode_NB_IoT(numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
RCC = sub_block_interleaving_cc_NB_IoT(npdcch_D,npdcch_struct->npdcch_d[0]+96,npdcch_struct->npdcch_w[0]);
lte_rate_matching_cc_NB_IoT(RCC,npdcch_E,npdcch_struct->npdcch_w[0],npdcch_struct->npdcch_e[0]);
......@@ -581,17 +1052,17 @@ proc->flag_scrambling =0;
uint16_t npdcch_D = 16 + 23;
uint16_t npdcch_E = 236;
uint8_t agr_level = 2;
uint8_t dci_number=1;
//uint8_t dci_number=1;
uint8_t tab_a[3];
tab_a[0]= 128;
tab_a[1]= 66;
tab_a[2]= 4;
int RB_ID_IoT=22 ;
// int RB_ID_IoT=22 ;
bzero(npdcch_struct->npdcch_e[0],npdcch_E);
memset(npdcch_struct->npdcch_d[0],LTE_NULL_NB_IoT,96);
ccode_encode_NB_IoT (numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
ccode_encode_NB_IoT(numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
RCC = sub_block_interleaving_cc_NB_IoT(npdcch_D,npdcch_struct->npdcch_d[0]+96,npdcch_struct->npdcch_w[0]);
lte_rate_matching_cc_NB_IoT(RCC,npdcch_E,npdcch_struct->npdcch_w[0],npdcch_struct->npdcch_e[0]);
......@@ -691,17 +1162,17 @@ proc->flag_scrambling =0;
uint16_t npdcch_D = 16 + 23;
uint16_t npdcch_E = 236;
uint8_t agr_level = 2;
uint8_t dci_number=1;
// uint8_t dci_number=1;
uint8_t tab_a[3];
tab_a[0]= 128;
tab_a[1]= 66;
tab_a[2]= 4;
int RB_ID_IoT=22 ;
// int RB_ID_IoT=22 ;
bzero(npdcch_struct->npdcch_e[0],npdcch_E);
memset(npdcch_struct->npdcch_d[0],LTE_NULL_NB_IoT,96);
ccode_encode_NB_IoT (numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
ccode_encode_NB_IoT(numbits,2,tab_a,npdcch_struct->npdcch_d[0]+96,RA_template[0].RA_rnti);
RCC = sub_block_interleaving_cc_NB_IoT(npdcch_D,npdcch_struct->npdcch_d[0]+96,npdcch_struct->npdcch_w[0]);
lte_rate_matching_cc_NB_IoT(RCC,npdcch_E,npdcch_struct->npdcch_w[0],npdcch_struct->npdcch_e[0]);
......@@ -827,8 +1298,8 @@ if(subframe !=5 && subframe !=0)
// printf("xxxxx index verif %d XXXXXX",RA_template[0].preamble_index);
tab_rar[0]=64 + RA_template[0].preamble_index;
tab_rar[1]=0;
tab_rar[2]=8;
tab_rar[3]=3;
tab_rar[2]=9;
tab_rar[3]=99;
tab_rar[4]=64;
tab_rar[5]=255; // 16
tab_rar[6]=242; // 5*/
......@@ -883,6 +1354,12 @@ if(subframe !=5 && subframe !=0)
proc->remaining_rar--;
proc->next_subframe_tx =subframe+2;
if(proc->remaining_rar == 0)
{
proc->flag_msg3 =1;
proc->frame_msg3=frame+1;
proc->counter_msg3 = 8;
}
}
} else {
......@@ -924,6 +1401,12 @@ if(subframe !=5 && subframe !=0)
proc->remaining_rar--;
proc->next_subframe_tx =subframe+1;
if(proc->remaining_rar == 0)
{
proc->flag_msg3 =1;
proc->frame_msg3=frame+1;
proc->counter_msg3 = 8;
}
}
}
......@@ -1633,16 +2116,16 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
int frame=proc->frame_tx;
int subframe=proc->subframe_tx;
// uint16_t input_buffer_length;
uint32_t i,j,aa;
uint32_t i,aa; //j;
uint8_t harq_pid;
DCI_PDU *DCI_pdu;
DCI_PDU DCI_pdu_tmp;
int8_t UE_id=0;
uint8_t num_pdcch_symbols=0;
// uint8_t num_pdcch_symbols=0;
uint8_t ul_subframe;
uint32_t ul_frame;
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
DCI_ALLOC_t *dci_alloc=(DCI_ALLOC_t *)NULL;
// DCI_ALLOC_t *dci_alloc=(DCI_ALLOC_t *)NULL;
int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1;
......@@ -2460,15 +2943,15 @@ void get_n1_pucch_eNB(PHY_VARS_eNB *eNB,
void prach_procedures(PHY_VARS_eNB *eNB) {
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// uint16_t preamble_energy_list[64],preamble_delay_list[64];
// uint16_t preamble_max,preamble_energy_max;
uint16_t preamble_max=0;
uint16_t i;
int8_t UE_id;
// uint16_t preamble_max=0;
// uint16_t i;
// int8_t UE_id;
int subframe = eNB->proc.subframe_prach;
int frame = eNB->proc.frame_prach;
uint8_t CC_id = eNB->CC_id;
// uint8_t CC_id = eNB->CC_id;
uint32_t detection=0;
......@@ -3311,7 +3794,7 @@ void eNB_fep_rru_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc_rxtx) {
void do_prach(PHY_VARS_eNB *eNB,int frame,int subframe) {
eNB_proc_t *proc = &eNB->proc;
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
if(frame%2==0 && subframe==9)
{
......@@ -3360,7 +3843,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
const int subframe = proc->subframe_rx;
const int frame = proc->frame_rx;
int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1);
// int offset = (eNB->single_thread_flag==1) ? 0 : (subframe&1);
/// VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB+offset, proc->frame_rx );
/// VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB+offset, proc->subframe_rx );
......
......@@ -1519,10 +1519,10 @@ void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint32_t nprach_procedures_NB_IoT(PHY_VARS_eNB *eNB) {
uint32_t estimated_TA;
int subframe,frame,frame_mod;
int frame,frame_mod; // subframe,
subframe = eNB->proc.subframe_prach;
// subframe = eNB->proc.subframe_prach;
frame = eNB->proc.frame_prach;
//printf("frame = %i \n sf = %i\n",frame,subframe);
......
......@@ -1016,7 +1016,7 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
for (i=0; i<NB_RA_PROC_MAX; i++) {
if (RA_template[i].RA_active==FALSE &&
RA_template[i].wait_ack_Msg4 == 0) {
int loop = 0;
// int loop = 0;
RA_template[i].RA_active=TRUE;
RA_template[i].generate_rar=1;
RA_template[i].generate_Msg4=0;
......@@ -1029,12 +1029,12 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
RA_template[i].rnti = taus();
loop++;
} while (loop != 100 &&
/* TODO: this is not correct, the rnti may be in use without
* being in the MAC yet. To be refined.
*/
/* !(find_UE_id(module_idP, RA_template[i].rnti) == -1 &&
/* 1024 and 60000 arbirarily chosen, not coming from standard */
/* RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
// TODO: this is not correct, the rnti may be in use without
// being in the MAC yet. To be refined.
//
/// !(find_UE_id(module_idP, RA_template[i].rnti) == -1 &&
// 1024 and 60000 arbirarily chosen, not coming from standard //
// RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
if (loop == 100) {
printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
......
......@@ -6,7 +6,7 @@
// Sched_INFO as a input for the scheduler
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
int i=0;
// int i=0;
uint32_t abs_subframe;
//UE_TEMPLATE_NB_IoT *UE_info;
......
......@@ -1282,6 +1282,8 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
frame_parms[CC_id]->nushift = 0;
frame_parms[CC_id]->subcarrier_spacing = 1;
frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth;
frame_parms[CC_id]->phich_config_common.phich_duration = normal;
// UL RS Config
......
......@@ -87,7 +87,9 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n", i);
PHY_vars_eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,frame_parms->N_RB_UL, abstraction_flag);
//////////////// NB-IoT testing ////////////////////////////
PHY_vars_eNB->ulsch_NB_IoT[1+i] = new_eNB_ulsch_NB_IoT(MAX_TURBO_ITERATIONS,frame_parms->N_RB_UL, abstraction_flag);
//////////////////////////////////////////////////////////////
if (!PHY_vars_eNB->ulsch[1+i]) {
LOG_E(PHY,"Can't get eNB ulsch structures\n");
exit(-1);
......@@ -121,11 +123,18 @@ PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms,
// ULSCH for RA
PHY_vars_eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, frame_parms->N_RB_UL, abstraction_flag);
//////////////// NB-IoT testing ////////////////////////////
PHY_vars_eNB->ulsch_NB_IoT[0] = new_eNB_ulsch_NB_IoT(MAX_TURBO_ITERATIONS, frame_parms->N_RB_UL, abstraction_flag);
////////////////////////////////////////////////////////////
if (!PHY_vars_eNB->ulsch[0]) {
LOG_E(PHY,"Can't get eNB ulsch structures\n");
exit(-1);
}
if (!PHY_vars_eNB->ulsch_NB_IoT[0]) {
LOG_E(PHY,"Can't get eNB ulsch structures\n");
exit(-1);
}
PHY_vars_eNB->dlsch_SI = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL, abstraction_flag, frame_parms);
LOG_D(PHY,"eNB %d : SI %p\n",eNB_id,PHY_vars_eNB->dlsch_SI);
PHY_vars_eNB->dlsch_ra = new_eNB_dlsch(1,8,NSOFT,frame_parms->N_RB_DL, abstraction_flag, frame_parms);
......
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