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;
......
......@@ -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{
......
This diff is collapsed.
......@@ -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