From 2960d27a47dbec13fedf667101bcbfc0ac8b14d5 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Fri, 10 May 2019 15:37:20 +0200 Subject: [PATCH 01/32] enabling PUSCH UE side in RT --- executables/nr-ue.c | 7 ++++--- executables/nr-uesoftmodem.c | 1 + openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index de972d28f6..3127deeda7 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -421,7 +421,7 @@ void UE_processing(void *arg) { processSlotRX(UE, proc); //printf(">>> mac ended\n"); // Prepare the future Tx data -#if 0 +/* #ifndef NO_RAT_NR if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT) @@ -429,11 +429,12 @@ void UE_processing(void *arg) { if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) #endif +*/ if (UE->mode != loop_through_memory) - phy_procedures_nrUE_TX(UE,proc,0,0,UE->mode,no_relay); + phy_procedures_nrUE_TX(UE,proc,0,0); //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); -#endif + #if 0 if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 9a4a0cdf70..b78913e1bd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -777,6 +777,7 @@ int main( int argc, char **argv ) { PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset; #if defined(OAI_USRP) || defined(OAI_ADRV9371_ZC706) PHY_vars_UE_g[0][CC_id]->hw_timing_advance = timing_advance; + PHY_vars_UE_g[0][CC_id]->timing_advance = timing_advance; #else PHY_vars_UE_g[0][CC_id]->hw_timing_advance = 160; #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 2b59f93160..3de108863e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -384,11 +384,18 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, int tx_offset, ap; int32_t **txdata; int32_t **txdataF; + int timing_advance; /////////////////////////IFFT/////////////////////// /////////// - tx_offset = slot*frame_parms->samples_per_slot; +#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) + timing_advance = UE->timing_advance; +#else + timing_advance = 0; +#endif + + tx_offset = slot*frame_parms->samples_per_slot - timing_advance; txdata = UE->common_vars.txdata; txdataF = UE->common_vars.txdataF; From 376fc1eca375acfc99b6cd7e65d74691ef405281 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 17 Jun 2019 13:34:50 +0200 Subject: [PATCH 02/32] Consolidate header files for nr_phy_scope --- executables/nr-softmodem.h | 4 ---- openair1/PHY/TOOLS/nr_phy_scope.c | 1 + openair1/PHY/TOOLS/nr_phy_scope.h | 11 ++++++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index 50e0c5469f..6016f1e363 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -46,10 +46,6 @@ } -typedef struct { - int *argc; - char **argv; -} scopeParms_t; extern int T_port; extern int T_nowait; diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 3a962e4931..af895ba556 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -23,6 +23,7 @@ #include #include "nr_phy_scope.h" +#include "executables/nr-softmodem-common.h" #define TPUT_WINDOW_LENGTH 100 int otg_enabled; diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h index 37331b511d..770006d234 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.h +++ b/openair1/PHY/TOOLS/nr_phy_scope.h @@ -29,7 +29,6 @@ #include #include "common/ran_context.h" #include -#include #include #include "PHY/defs_gNB.h" //#include "PHY/defs_nrUE.h" @@ -67,6 +66,11 @@ typedef struct { FL_OBJECT * button_0; } FD_phy_scope_nrue; +typedef struct { + int *argc; + char **argv; +} scopeParms_t; + extern unsigned char scope_enb_num_ue; FD_phy_scope_gnb * create_phy_scope_gnb( void ); FD_phy_scope_nrue * create_phy_scope_nrue( void ); @@ -82,5 +86,10 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form, int eNB_id, int UE_id, uint8_t subframe); + + +void startScope(scopeParms_t * p); + + extern RAN_CONTEXT_t RC; #endif From df65d8e3232ef29792025eedd1cf4d5f52f2b433 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 15 May 2019 12:30:20 +0200 Subject: [PATCH 03/32] Restrict UL transmission to NR_UPLINK_SLOT --- executables/nr-ue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 3127deeda7..85ebbc0057 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -430,9 +430,15 @@ void UE_processing(void *arg) { (UE->frame_parms.frame_type == FDD) ) #endif */ + if (proc->nr_tti_tx == NR_UPLINK_SLOT){ + + LOG_D(PHY, "[UE_processing] Slot = %d\n", proc->nr_tti_tx); + if (UE->mode != loop_through_memory) phy_procedures_nrUE_TX(UE,proc,0,0); + } + //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); #if 0 From 031e424e46eb4b58ff67ea56e9d8f78706ef152e Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 15 May 2019 12:39:26 +0200 Subject: [PATCH 04/32] Adding Frame tx to LOG_D for debugging --- executables/nr-ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 85ebbc0057..93f29d4080 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -432,7 +432,7 @@ void UE_processing(void *arg) { */ if (proc->nr_tti_tx == NR_UPLINK_SLOT){ - LOG_D(PHY, "[UE_processing] Slot = %d\n", proc->nr_tti_tx); + LOG_D(PHY, "[UE_processing] Frame = %d, Slot = %d\n", proc->frame_tx, proc->nr_tti_tx); if (UE->mode != loop_through_memory) phy_procedures_nrUE_TX(UE,proc,0,0); From 2b81a1bf4815e3be8538c5b71dff9411205ce40a Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 15 May 2019 14:42:25 +0200 Subject: [PATCH 05/32] using LOG_I instead of LOG_D in RT PUSCH UE side --- executables/nr-ue.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 93f29d4080..41d048ccf7 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -432,7 +432,7 @@ void UE_processing(void *arg) { */ if (proc->nr_tti_tx == NR_UPLINK_SLOT){ - LOG_D(PHY, "[UE_processing] Frame = %d, Slot = %d\n", proc->frame_tx, proc->nr_tti_tx); + LOG_I(PHY, "[UE_processing] Frame = %d, Slot = %d\n", proc->frame_tx, proc->nr_tti_tx); if (UE->mode != loop_through_memory) phy_procedures_nrUE_TX(UE,proc,0,0); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9a0e82fa60..674df8b451 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2478,7 +2478,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); - LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); + LOG_I(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); #if UE_TIMING_TRACE start_meas(&ue->phy_proc_tx); @@ -2546,7 +2546,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, } */ - LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); + LOG_I(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE From ad37254217920258be2a0e7e6d797357548475b1 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Wed, 15 May 2019 18:34:50 +0200 Subject: [PATCH 06/32] adding PUSCH procedures to gNB side in RT with some logs - removed gNB RT from "ru_procedures.c" to "nr_ru_procedures" - added a new thread "nr_feprx_thread" - added some functionalities for fep for rx in "nr_ru_procedures.c" --- executables/nr-gnb.c | 21 +-- executables/nr-ru.c | 43 +++--- openair1/PHY/INIT/nr_init.c | 21 +++ openair1/PHY/NR_TRANSPORT/nr_ulsch.h | 3 +- openair1/SCHED_NR/nr_ru_procedures.c | 176 +++++++++++++++++++++- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 19 +-- openair1/SCHED_NR/sched_nr.h | 8 +- openair1/SIMULATION/NR_PHY/ulsim.c | 9 +- 8 files changed, 247 insertions(+), 53 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 2f1759b438..8d64e10705 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -184,17 +184,18 @@ static inline int rxtx(PHY_VARS_gNB *gNB,int frame_rx, int slot_rx, int frame_tx // **************************************** // Common RX procedures subframe n T(T_GNB_PHY_DL_TICK, T_INT(gNB->Mod_id), T_INT(frame_tx), T_INT(slot_tx)); - /* - // if this is IF5 or 3GPP_gNB - if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { - wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); - } +/* + // if this is IF5 or 3GPP_gNB + if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) { + wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx); + } + + // UE-specific RX processing for subframe n + if (nfapi_mode == 0 || nfapi_mode == 1) */ { + nfapi_nr_ul_config_ulsch_pdu_rel15_t *ulsch_pdu_rel15 = &gNB->ulsch[1][0]->harq_processes[0]->ulsch_pdu.ulsch_pdu_rel15; + phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx, ulsch_pdu_rel15->start_symbol, ulsch_pdu_rel15->start_symbol + ulsch_pdu_rel15->number_symbols); + } - // UE-specific RX processing for subframe n - if (nfapi_mode == 0 || nfapi_mode == 1) { - phy_procedures_gNB_uespec_RX(gNB, proc, no_relay ); - } - */ pthread_mutex_lock(&gNB->UL_INFO_mutex); gNB->UL_INFO.frame = frame_rx; gNB->UL_INFO.slot = slot_rx; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 9cc1aa0351..c26eb6d253 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1354,6 +1354,8 @@ static void *ru_thread( void *param ) { char filename[40],threadname[40]; int print_frame = 8; int i = 0; + int aa; + // set default return value ru_thread_status = 0; // set default return value @@ -1472,6 +1474,15 @@ static void *ru_thread( void *param ) { // do RX front-end processing (frequency-shift, dft) if needed if (ru->feprx) ru->feprx(ru,proc->tti_rx); + LOG_I(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); + LOG_I(PHY,"gNB proc: frame_rx = %d, slot_rx = %d\n", RC.gNB[0][0]->proc.frame_rx, RC.gNB[0][0]->proc.slot_rx); + LOG_I(PHY,"Copying rxdataF from RU to gNB\n"); + + for (aa=0;aanb_rx;aa++) + memcpy((void*)RC.gNB[0][0]->common_vars.rxdataF[aa], + (void*)&ru->common.rxdataF[aa][proc->tti_rx*fp->symbols_per_tti*fp->ofdm_symbol_size], + fp->symbols_per_tti*fp->ofdm_symbol_size*sizeof(int32_t)); + // At this point, all information for subframe has been received on FH interface // wakeup all gNB processes waiting for this RU @@ -1620,14 +1631,6 @@ int stop_rf(RU_t *ru) { return 0; } -extern void fep_full(RU_t *ru,int slot); -extern void ru_fep_full_2thread(RU_t *ru,int slot); -extern void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); -extern void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx); -extern void feptx_prec(RU_t *ru, int frame_tx,int tti_tx); -extern void init_fep_thread(RU_t *ru); -extern void nr_init_feptx_thread(RU_t *ru); - void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; @@ -1692,7 +1695,7 @@ void init_RU_proc(RU_t *ru) { } if (get_thread_worker_conf() == WORKER_ENABLE) { - if (ru->feprx) init_fep_thread(ru); + if (ru->feprx) nr_init_feprx_thread(ru); if (ru->feptx_ofdm) nr_init_feptx_thread(ru); } @@ -1985,8 +1988,8 @@ void set_function_spec_param(RU_t *ru) { ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception ru->fh_south_out = tx_rf; // send output to RF ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft only (no precoding in RRU) + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft only (no precoding in RRU) ru->feptx_prec = NULL; ru->nr_start_if = nr_start_if; // need to start the if interface for if4p5 ru->ifdevice.host_type = RRU_HOST; @@ -2007,8 +2010,8 @@ void set_function_spec_param(RU_t *ru) { malloc_IF4p5_buffer(ru); } else if (ru->function == gNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; // RX DFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft and precoding + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // RX DFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // this is fep with idft and precoding ru->feptx_prec = NULL; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north @@ -2037,13 +2040,13 @@ void set_function_spec_param(RU_t *ru) { case REMOTE_IF5: // the remote unit is IF5 RRU ru->do_prach = 0; - ru->feprx = fep_full; // this is frequency-shift + DFTs - ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // need to do transmit Precoding + IDFTs - ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception - ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission - ru->fh_south_asynch_in = NULL; // no asynchronous UL - ru->start_rf = NULL; // no local RF + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_fep_full_2thread : nr_fep_full; // this is frequency-shift + DFTs + ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_thread_worker_conf() == WORKER_ENABLE) ? nr_feptx_ofdm_2thread : nr_feptx_ofdm; // need to do transmit Precoding + IDFTs + ru->fh_south_in = fh_if5_south_in; // synchronous IF5 reception + ru->fh_south_out = fh_if5_south_out; // synchronous IF5 transmission + ru->fh_south_asynch_in = NULL; // no asynchronous UL + ru->start_rf = NULL; // no local RF ru->stop_rf = NULL; ru->nr_start_if = nr_start_if; // need to start if interface for IF5 ru->ifdevice.host_type = RAU_HOST; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 7fdd6fba43..e09e2bef72 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -38,6 +38,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "SCHED_NR/fapi_nr_l1.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "nfapi_nr_interface.h" /* extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); @@ -485,6 +486,26 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { LOG_E(PHY,"Can't get gNB ulsch structures\n"); exit(-1); } + + LOG_I(PHY,"Initializing nFAPI for ULSCH, UE %d\n",i); + // [hna] added here for RT implementation + uint8_t harq_pid = 0; + nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[i+1][j]->harq_processes[harq_pid]->ulsch_pdu; + + // --------- setting rel15_ul parameters ---------- + rel15_ul->rnti = 0x1234; + rel15_ul->ulsch_pdu_rel15.start_rb = 30; + rel15_ul->ulsch_pdu_rel15.number_rbs = 50; + rel15_ul->ulsch_pdu_rel15.start_symbol = 2; + rel15_ul->ulsch_pdu_rel15.number_symbols = 12; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = 6; + rel15_ul->ulsch_pdu_rel15.length_dmrs = 1; + rel15_ul->ulsch_pdu_rel15.Qm = 2; + rel15_ul->ulsch_pdu_rel15.mcs = 9; + rel15_ul->ulsch_pdu_rel15.rv = 0; + rel15_ul->ulsch_pdu_rel15.n_layers = 1; + /////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 11521563e4..4942ffe2f4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -75,7 +75,8 @@ void nr_ulsch_unscrambling(int16_t* llr, void nr_ulsch_procedures(PHY_VARS_gNB *gNB, - gNB_L1_rxtx_proc_t *proc, + int frame_rx, + int slot_rx, int UE_id, uint8_t harq_pid); diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 544a8ef1dd..c10144c072 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -34,7 +34,7 @@ #include "PHY/phy_extern.h" #include "sched_nr.h" #include "PHY/MODULATION/modulation_common.h" - +#include "PHY/MODULATION/nr_modulation.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" @@ -248,3 +248,177 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) { dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); } + + +void nr_fep0(RU_t *ru, int first_half) { + + uint8_t start_symbol, end_symbol, l, aa; + RU_proc_t *proc = &ru->proc; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + if(first_half == 1) { + start_symbol = 0; + end_symbol = NR_SYMBOLS_PER_SLOT/2; + } else { + start_symbol = NR_SYMBOLS_PER_SLOT/2; + end_symbol = NR_SYMBOLS_PER_SLOT; + } + + LOG_I(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d\n", proc->tti_rx, first_half, start_symbol, end_symbol); + // printf("fep0: slot %d\n",slot); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 1); + + // remove_7_5_kHz(ru,(slot&1)+(proc->tti_rx<<1)); + for (l = start_symbol; l < end_symbol; l++) { + for (aa = 0; aa < fp->nb_antennas_rx; aa++) { + nr_slot_fep_ul(fp, + ru->common.rxdata[aa], + ru->common.rxdataF[aa], + l, + proc->tti_rx, + 0, + 0); + } + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 0); +} + + +static void *nr_feprx_thread(void *param) { + + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = &ru->proc; + + + while (!oai_exit) { + + if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"NR feprx thread")<0) break; + + if (oai_exit) break; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 1 ); + + nr_fep0(ru, 0); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 0 ); + + if (release_thread(&proc->mutex_fep,&proc->instance_cnt_fep,"nr_feprx thread")<0) break; + + if (pthread_cond_signal(&proc->cond_fep) != 0) { + printf("[gNB] ERROR pthread_cond_signal for nr_feprx thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return NULL; + } + } + + return NULL; +} + + +void nr_init_feprx_thread(RU_t *ru) { + + RU_proc_t *proc = &ru->proc; + + proc->instance_cnt_fep = -1; + + pthread_mutex_init( &proc->mutex_fep, NULL); + pthread_cond_init( &proc->cond_fep, NULL); + + threadCreate(&proc->pthread_fep, nr_feprx_thread, (void*)ru, "feprx", -1, OAI_PRIORITY_RT); +} + + +void nr_fep_full_2thread(RU_t *ru, int slot) { + + RU_proc_t *proc = &ru->proc; + + struct timespec wait; + + // NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + // if ((fp->frame_type == TDD) && + // (subframe_select(fp,proc->tti_rx) != SF_UL)) return; + + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + start_meas(&ru->ofdm_demod_stats); + + if (pthread_mutex_timedlock(&proc->mutex_fep,&wait) != 0) { + printf("[RU] ERROR pthread_mutex_lock for nr_feprx thread (IC %d)\n", proc->instance_cnt_fep); + exit_fun( "error locking mutex_fep" ); + return; + } + + if (proc->instance_cnt_fep==0) { + printf("[RU] FEP thread busy\n"); + exit_fun("FEP thread busy"); + pthread_mutex_unlock( &proc->mutex_fep ); + return; + } + + ++proc->instance_cnt_fep; + + + if (pthread_cond_signal(&proc->cond_fep) != 0) { + printf("[RU] ERROR pthread_cond_signal for nr_feprx thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + //start_meas(&ru->ofdm_demod_wakeup_stats); + + pthread_mutex_unlock( &proc->mutex_fep ); + + // call second slot in this symbol + nr_fep0(ru, 1); + + start_meas(&ru->ofdm_demod_wait_stats); + wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"nr_feprx thread"); + stop_meas(&ru->ofdm_demod_wait_stats); + if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.p_time>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->tti_rx); + } + + stop_meas(&ru->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); +} + + + +void nr_fep_full(RU_t *ru, int slot) { + + RU_proc_t *proc = &ru->proc; + int l, aa; + NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; + + // if ((fp->frame_type == TDD) && + // (subframe_select(fp,proc->tti_rx) != SF_UL)) return; + + start_meas(&ru->ofdm_demod_stats); + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); + + // remove_7_5_kHz(ru,proc->tti_rx<<1); + // remove_7_5_kHz(ru,1+(proc->tti_rx<<1)); + + for (l = 0; l < fp->symbols_per_tti; l++) { + for (aa = 0; aa < fp->nb_antennas_rx; aa++) { + nr_slot_fep_ul(fp, + ru->common.rxdata[aa], + ru->common.rxdataF[aa], + l, + proc->tti_rx, + 0, + 0); + } + } + + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); + stop_meas(&ru->ofdm_demod_stats); + + +} diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index cb6cb7900e..df8a1c8084 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -210,10 +210,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, } -void nr_ulsch_procedures(PHY_VARS_gNB *gNB, - gNB_L1_rxtx_proc_t *proc, - int UE_id, - uint8_t harq_pid) +void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id, uint8_t harq_pid) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->ulsch_pdu; @@ -249,9 +246,9 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, UE_id, gNB->pusch_vars[UE_id]->llr, frame_parms, - proc->frame_rx, + frame_rx, nfapi_ulsch_pdu_rel15->number_symbols, - proc->slot_rx, + slot_rx, harq_pid, 0); @@ -261,7 +258,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, } -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { +void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { uint8_t symbol; unsigned char aa; @@ -273,7 +270,7 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { gNB->common_vars.rxdata[aa], gNB->common_vars.rxdataF[aa], symbol, - proc->slot_rx, + slot_rx, 0, 0); } @@ -282,7 +279,7 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc) { } -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, uint8_t symbol_start, uint8_t symbol_end) { +void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t symbol_start, uint8_t symbol_end) { uint8_t UE_id; uint8_t symbol; @@ -293,11 +290,11 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, u for(symbol = symbol_start; symbol < symbol_end; symbol++) { - nr_rx_pusch(gNB, UE_id, proc->frame_rx, proc->slot_rx, symbol, harq_pid); + nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid); } - nr_ulsch_procedures(gNB, proc, UE_id, harq_pid); + nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid); } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index b6b4b6ca1c..a8d4aa272f 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -37,14 +37,16 @@ nr_slot_t nr_slot_select (nfapi_nr_config_request_t *cfg, unsigned char slot); void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp); void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx, int slot_tx, int do_meas); -void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc); -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, uint8_t symbol_start, uint8_t symbol_end); +void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); +void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t symbol_start, uint8_t symbol_end); void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot); void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx); void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols); void nr_init_feptx_thread(RU_t *ru); -void fep_full(RU_t *ru,int slot); +void nr_init_feprx_thread(RU_t *ru); +void nr_fep_full(RU_t *ru, int slot); +void nr_fep_full_2thread(RU_t *ru, int slot); void feptx_prec(RU_t *ru,int frame_tx,int tti_tx); int nr_phy_init_RU(RU_t *ru); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index d71bea59f0..ac268fa1e3 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -326,10 +326,6 @@ int main(int argc, char **argv) RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0][0]; //gNB_config = &gNB->gNB_config; - gNB_L1_rxtx_proc_t gNB_proc; - - gNB_proc.frame_rx = frame; - gNB_proc.slot_rx = slot; UE_proc.nr_tti_tx = slot; UE_proc.frame_tx = frame; @@ -486,16 +482,15 @@ int main(int argc, char **argv) for (i=0; inb_antennas_rx; ap++) { - // [hna] doesn't work with noise in case of mod_order = 6 ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); } } - phy_procedures_gNB_common_RX(gNB, &gNB_proc); + phy_procedures_gNB_common_RX(gNB, frame, slot); - phy_procedures_gNB_uespec_RX(gNB, &gNB_proc, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); + phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); //---------------------------------------------------------- From 3a8bf560da6de1977410a111cd8cd26782ae5118 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 27 May 2019 18:31:20 +0200 Subject: [PATCH 07/32] channel estimation, compensation, etc .. Added the following folder: - ../openair1/PHY/NR_ESTIMATION/ Added the following file to CMakelists.txt: - ../openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c Added the following functions: - nr_pusch_dmrs_rx - nr_gold_pusch - nr_ulsch_channel_level - nr_ulsch_channel_compensation - nr_ulsch_scale_channel is commented out (I think only used for downlink) Changes from Khalid Ahmed Mahmoud Mohamed: - nr_pusch_channel_estimation is used - nr_ulsch_scale_channel is used - nr_ulsch_channel_level is used - nr_ulsch_channel_compensation is used - multiple logging options for channel and signal magnitude --- cmake_targets/CMakeLists.txt | 3 + openair1/PHY/INIT/nr_init.c | 28 +- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 265 ++++++ openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h | 51 ++ openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 55 ++ openair1/PHY/NR_REFSIG/nr_gold.c | 56 ++ openair1/PHY/NR_REFSIG/nr_refsig.h | 9 + .../PHY/NR_TRANSPORT/nr_transport_proto.h | 53 ++ .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 802 +++++++++++++++++- .../NR_TRANSPORT/nr_ulsch_llr_computation.c | 69 +- openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c | 139 +++ openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h | 143 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 2 + openair1/PHY/defs_gNB.h | 33 +- openair1/PHY/impl_defs_top.h | 1 + openair1/SIMULATION/NR_PHY/ulsim.c | 3 + 16 files changed, 1569 insertions(+), 143 deletions(-) create mode 100644 openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c create mode 100644 openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h create mode 100644 openair1/PHY/NR_UE_ESTIMATION/filt16a_32.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index befb8db1c6..9f09081a16 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1333,6 +1333,8 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c + ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c + ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c #${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c @@ -1377,6 +1379,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold_ue.c + ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index e09e2bef72..6b5acb85e4 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -208,24 +208,32 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, for (int UE_id=0; UE_idrxdataF_ext = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->rxdataF_ext2 = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->drs_ch_estimates = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->rxdataF_comp = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->ul_ch_mag = (int32_t **)malloc16( 2*sizeof(int32_t *) ); - pusch_vars[UE_id]->ul_ch_magb = (int32_t **)malloc16( 2*sizeof(int32_t *) ); + pusch_vars[UE_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rxdataF_ext2 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_estimates_time = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rxdataF_comp = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_mag0 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_magb0 = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_mag = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->ul_ch_magb = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pusch_vars[UE_id]->rho = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); - for (i=0; i<2; i++) { + for (i=0; inb_antennas_rx; i++) { // RK 2 times because of output format of FFT! // FIXME We should get rid of this pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); - pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); - pusch_vars[UE_id]->drs_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); + pusch_vars[UE_id]->ul_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_estimates_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); pusch_vars[UE_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot ); + pusch_vars[UE_id]->ul_ch_mag0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->ul_ch_magb0[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); pusch_vars[UE_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 ); + pusch_vars[UE_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) ); } pusch_vars[UE_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c new file mode 100644 index 0000000000..22062bd4d7 --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -0,0 +1,265 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + + +#include + +#include "nr_ul_estimation.h" +#include "PHY/NR_REFSIG/nr_refsig.h" +#include "PHY/NR_UE_ESTIMATION/filt16a_32.h" + +//#define DEBUG_CH + + +int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, + uint8_t gNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pusch) +{ + int pilot[1320] __attribute__((aligned(16))); + unsigned char aarx; + unsigned short k; + unsigned int pilot_cnt; + int16_t ch[2],*pil,*rxF,*ul_ch,*fl,*fm,*fr,*fml,*fmr,*fmm; + int ch_offset,symbol_offset, length_dmrs, UE_id = 0; + unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config + +#ifdef DEBUG_CH + FILE *debug_ch_est; + debug_ch_est = fopen("debug_ch_est.txt","w"); +#endif + + //uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1]; + + uint8_t nushift; + int **ul_ch_estimates = gNB->pusch_vars[UE_id]->ul_ch_estimates; + int **rxdataF = gNB->common_vars.rxdataF; + + nushift = (p>>1)&1; + gNB->frame_parms.nushift = nushift; + + ch_offset = gNB->frame_parms.ofdm_symbol_size*symbol; + + symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol; + + k = bwp_start_subcarrier; + int re_offset = k; + +/* +#ifdef DEBUG_CH + printf("PUSCH Channel Estimation : gNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", gNB_offset,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size, + gNB->frame_parms.Ncp,l,Ns,k, symbol); +#endif +*/ + switch (nushift) { + case 0: + fl = filt8_l0; + fm = filt8_m0; + fr = filt8_r0; + fmm = filt8_mm0; + fml = filt8_m0; + fmr = filt8_mr0; + break; + + case 1: + fl = filt8_l1; + fm = filt8_m1; + fr = filt8_r1; + fmm = filt8_mm1; + fml = filt8_ml1; + fmr = filt8_m1; + break; + + default: + printf("pusch_channel_estimation: nushift=%d -> ERROR\n",nushift); + return(-1); + break; + } + + + //------------------generate DMRS------------------// + + length_dmrs = 1; //to update from pusch config + + nr_gold_pusch(gNB, symbol, n_idDMRS, length_dmrs); + + nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch[gNB_offset][Ns][0], &pilot[0], 1000, 0, nb_rb_pusch); + + //------------------------------------------------// + + for (aarx=0; aarxframe_parms.nb_antennas_rx; aarx++) { + + pil = (int16_t *)&pilot[0]; + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; + ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset]; + + memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size)); + +#ifdef DEBUG_PUSCH + printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_DL); + printf("k %d, first_carrier %d\n",k,gNB->frame_parms.first_carrier_offset); + printf("rxF addr %p p %d\n", rxF,p); + printf("ul_ch addr %p nushift %d\n",ul_ch,nushift); +#endif + //if ((gNB->frame_parms.N_RB_DL&1)==0) { + + // Treat first 2 pilots specially (left edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); + printf("data 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fl, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + //for (int i= 0; i<8; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fml, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + //printf("ul_ch addr %p\n",ul_ch); + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); + +#ifdef DEBUG_PUSCH + printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmm, + ch, + ul_ch, + 8); + + //for (int i= 0; i<16; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt+=2) { + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_CH + fprintf(debug_ch_est, "pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); + //printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + ul_ch, + 8); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmm, + ch, + ul_ch, + 8); + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + } + + // Treat first 2 pilots specially (right edge) + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fm, + ch, + ul_ch, + 8); + + //for (int i= 0; i<8; i++) + //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); + printf("pilot %d: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fmr, + ch, + ul_ch, + 8); + + pil+=2; + re_offset = (re_offset+2)&(gNB->frame_parms.ofdm_symbol_size-1); + rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; + ul_ch+=8; + + ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); + ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); +#ifdef DEBUG_PUSCH + printf("pilot %d: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); +#endif + multadd_real_vector_complex_scalar(fr, + ch, + ul_ch, + 8); + //} + + } + +#ifdef DEBUG_CH + fclose(debug_ch_est); +#endif + + return(0); +} \ No newline at end of file diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h new file mode 100644 index 0000000000..7690821902 --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -0,0 +1,51 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef __NR_UL_ESTIMATION_DEFS__H__ +#define __NR_UL_ESTIMATION_DEFS__H__ + + +#include "PHY/defs_gNB.h" +/** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_ + * @{ + */ + + +/*! +\brief This function performs channel estimation including frequency interpolation +\param gNB Pointer to gNB PHY variables +\param Ns slot number (0..19) +\param p +\param symbol symbol within slot +\param bwp_start_subcarrier, first allocated subcarrier +\param nb_rb_pusch, number of allocated RBs for this UE +*/ + + int32_t nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, + uint8_t gNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pusch); + + +#endif diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index e0c17bfb75..f5c8a08864 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -36,6 +36,8 @@ #include "refsig_defs_ue.h" #include "PHY/defs_nr_UE.h" +#include "nr_refsig.h" +#include "PHY/defs_gNB.h" /*Table 7.4.1.1.2-1/2 from 38.211 */ int wf1[8][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1}}; @@ -48,6 +50,59 @@ short nr_rx_mod_table[14] = {0,0,23170,-23170,-23170,23170,23170,-23170,23170,2 short nr_rx_nmod_table[14] = {0,0,-23170,23170,23170,-23170,-23170,23170,-23170,-23170,23170,23170,23170,-23170}; +int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, + unsigned int Ns, + unsigned int *nr_gold_pusch, + int32_t *output, + unsigned short p, + unsigned char lp, + unsigned short nb_pusch_rb) +{ + int8_t w,config_type; + short *mod_table; + unsigned char idx=0; + + typedef int array_of_w[2]; + array_of_w *wf; + array_of_w *wt; + + config_type = 0; //to be updated by higher layer + + wf = (config_type==0) ? wf1 : wf2; + wt = (config_type==0) ? wt1 : wt2; + + if (config_type > 1) + LOG_E(PHY,"Bad PUSCH DMRS config type %d\n", config_type); + + if ((p>=1000) && (p<((config_type==0) ? 1008 : 1012))) { + if (gNB->frame_parms.Ncp == NORMAL) { + + for (int i=0; i>5])>>((i<<1)&0x1f))&1)<<1) ^ (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); + ((int16_t*)output)[i<<1] = mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + ((int16_t*)output)[(i<<1)+1] = mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; +#ifdef DEBUG_PUSCH + printf("nr_pusch_dmrs_rx dmrs config type %d port %d nb_pusch_rb %d\n", config_type, p, nb_pusch_rb); + printf("wf[%d] = %d wt[%d]= %d\n", i&1, wf[p-1000][i&1], lp, wt[p-1000][lp]); + printf("i %d idx %d pusch gold %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, nr_gold_pusch[(i<<1)>>5], (((nr_gold_pusch[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((nr_gold_pusch[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), ((int16_t*)output)[i<<1], ((int16_t*)output)[(i<<1)+1]); +#endif + } + } else { + LOG_E(PHY,"extended cp not supported for PUSCH DMRS yet\n"); + } + } else { + LOG_E(PHY,"Illegal p %d PUSCH DMRS port\n",p); + } + + return(0); +} + + int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, unsigned int Ns, diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 1492d7f03f..476d1d2555 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -101,3 +101,59 @@ void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) } } } + + +void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs) +{ + + unsigned char ns,l; + unsigned int n,x1,x2,x2tmp0; + int nscid; + unsigned int nid; + + /// to be updated from higher layer + //unsigned short lbar = 0; + + for (nscid=0; nscid<2; nscid++) { + if (n_idDMRS) + nid = n_idDMRS[nscid]; + else + nid = gNB->frame_parms.Nid_cell; + + //printf("gold pdsch nid %d lbar %d\n",nid,lbar); + + for (ns=0; ns<20; ns++) { + + for (l=0; l>1) ^ (x2>>2) ^ (x2>>3))<<31); + + // skip first 50 double words (1600 bits) + 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); + //printf("x1 : %x, x2 : %x\n",x1,x2); + } + + for (n=0; n<52; 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); + gNB->nr_gold_pusch[nscid][ns][l][n] = x1^x2; + // if ((ns==2)&&(l==0)) + //printf("n=%d : c %x\n",n,x1^x2); + } + + } + } + } +} \ No newline at end of file diff --git a/openair1/PHY/NR_REFSIG/nr_refsig.h b/openair1/PHY/NR_REFSIG/nr_refsig.h index cb165eed5e..e1bfa1420d 100644 --- a/openair1/PHY/NR_REFSIG/nr_refsig.h +++ b/openair1/PHY/NR_REFSIG/nr_refsig.h @@ -39,4 +39,13 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB); void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid); void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid); +void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs); + +int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB, + unsigned int Ns, + unsigned int *nr_gold_pusch, + int32_t *output, + unsigned short p, + unsigned char lp, + unsigned short nb_pusch_rb); #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 2dbef1d733..aa5d16f613 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -65,7 +65,9 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, */ void nr_ulsch_extract_rbs_single(int **rxdataF, + int **ul_ch_estimates, int **rxdataF_ext, + int **ul_ch_estimates_ext, uint32_t rxdataF_ext_offset, // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment unsigned char symbol, @@ -73,6 +75,54 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, unsigned short nb_rb_pusch, NR_DL_FRAME_PARMS *frame_parms); +void nr_ulsch_scale_channel(int32_t **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + NR_gNB_ULSCH_t **ulsch_gNB, + uint8_t symbol, + uint8_t start_symbol, + uint16_t nb_rb); + + +/** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal + @param ul_ch_estimates_ext Channel estimates in allocated RBs + @param frame_parms Pointer to frame descriptor + @param avg Pointer to average signal strength + @param pilots_flag Flag to indicate pilots in symbol + @param nb_rb Number of allocated RBs +*/ +void nr_ulsch_channel_level(int **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + int32_t *avg, + uint8_t symbol, + uint32_t len, + unsigned short nb_rb); + + +/** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation. In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation) + @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated + @param ul_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated + @param ul_ch_mag First Channel magnitudes (16QAM/64QAM) + @param ul_ch_magb Second weighted Channel magnitudes (64QAM) + @param rxdataF_comp Compensated received waveform + @param frame_parms Pointer to frame descriptor + @param symbol Symbol on which to operate + @param Qm Modulation order of allocation + @param nb_rb Number of RBs in allocation + @param output_shift Rescaling for compensated output (should be energy-normalizing) +*/ +void nr_ulsch_channel_compensation(int **rxdataF_ext, + int **ul_ch_estimates_ext, + int **ul_ch_mag, + int **ul_ch_magb, + int **rxdataF_comp, + int **rho, + NR_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + uint8_t pilots, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift); + /*! \brief This function implements the idft transform precoding in PUSCH \param z Pointer to input in frequnecy domain, and it is also the output in time domain @@ -102,6 +152,7 @@ void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp, void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol); @@ -118,6 +169,7 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol); @@ -135,6 +187,7 @@ void nr_ulsch_compute_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol, uint8_t mod_order); \ No newline at end of file diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index d70e61e358..c3e4f42e5f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -5,6 +5,13 @@ #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "PHY/defs_nr_common.h" +//#define DEBUG_CH_COMP +//#define DEBUG_RB_EXT +//#define DEBUG_CH_MAG + +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}; + void nr_idft(uint32_t *z, uint32_t Msc_PUSCH) { @@ -216,7 +223,9 @@ void nr_idft(uint32_t *z, uint32_t Msc_PUSCH) } void nr_ulsch_extract_rbs_single(int **rxdataF, + int **ul_ch_estimates, int **rxdataF_ext, + int **ul_ch_estimates_ext, uint32_t rxdataF_ext_offset, // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment unsigned char symbol, @@ -227,12 +236,22 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, unsigned short start_re, re, nb_re_pusch; unsigned char aarx, is_dmrs_symbol = 0; uint32_t rxF_ext_index = 0; + uint32_t ul_ch0_ext_index = 0; + uint32_t ul_ch0_index = 0; int16_t *rxF,*rxF_ext; + int *ul_ch0,*ul_ch0_ext; + +#ifdef DEBUG_RB_EXT + + printf("--------------------symbol = %d-----------------------\n", symbol); + printf("--------------------ch_ext_index = %d-----------------------\n", symbol*NR_NB_SC_PER_RB * nb_rb_pusch); + +#endif is_dmrs_symbol = (symbol == 2) ? 1 : 0; //to be updated from config - start_re = frame_parms->first_carrier_offset + (start_rb * NR_NB_SC_PER_RB); + start_re = (frame_parms->first_carrier_offset + (start_rb * NR_NB_SC_PER_RB))%frame_parms->ofdm_symbol_size; nb_re_pusch = NR_NB_SC_PER_RB * nb_rb_pusch; @@ -241,19 +260,712 @@ void nr_ulsch_extract_rbs_single(int **rxdataF, rxF = (int16_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; rxF_ext = (int16_t *)&rxdataF_ext[aarx][symbol * nb_re_pusch]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6 + ul_ch0 = &ul_ch_estimates[aarx][(2*(frame_parms->ofdm_symbol_size))]; // DMRS REs are only in symbol 2 (to be updated from config) + ul_ch0_ext = &ul_ch_estimates_ext[aarx][symbol*nb_re_pusch]; + for (re = 0; re < nb_re_pusch; re++) { if ( (is_dmrs_symbol && ((re&1) != 0)) || (is_dmrs_symbol == 0) ) { // [hna] (re&1) != frame_parms->nushift) assuming only dmrs type 1 and mapping type A // frame_parms->nushift should be initialized with 0 rxF_ext[rxF_ext_index] = (rxF[ ((start_re + re)*2) % (frame_parms->ofdm_symbol_size*2)]); rxF_ext[rxF_ext_index + 1] = (rxF[(((start_re + re)*2) + 1) % (frame_parms->ofdm_symbol_size*2)]); + ul_ch0_ext[ul_ch0_ext_index] = ul_ch0[ul_ch0_index]; + + #ifdef DEBUG_RB_EXT + printf("rxF_ext[%d] = %d\n", rxF_ext_index, rxF_ext[rxF_ext_index]); + printf("rxF_ext[%d] = %d\n", rxF_ext_index+1, rxF_ext[rxF_ext_index+1]); + printf("ul_ch0_ext[%d] = %d\n", 2*ul_ch0_ext_index, ((int16_t *)ul_ch0_ext)[2*ul_ch0_ext_index]); + printf("ul_ch0_ext[%d] = %d\n", 2*ul_ch0_ext_index + 1, ((int16_t *)ul_ch0_ext)[2*ul_ch0_ext_index + 1]); + #endif + rxF_ext_index = rxF_ext_index + 2; + ul_ch0_ext_index++; } + ul_ch0_index++; } } } +void nr_ulsch_scale_channel(int **ul_ch_estimates_ext, + NR_DL_FRAME_PARMS *frame_parms, + NR_gNB_ULSCH_t **ulsch_gNB, + uint8_t symbol, + uint8_t pilots, + unsigned short nb_rb) +{ +#if defined(__x86_64__)||defined(__i386__) + + short rb, ch_amp; + unsigned char aatx,aarx; + __m128i *ul_ch128, ch_amp128; + + // Determine scaling amplitude based the symbol + + ch_amp = 1024*8; //((pilots) ? (ulsch_gNB[0]->sqrt_rho_b) : (ulsch_gNB[0]->sqrt_rho_a)); + + LOG_D(PHY,"Scaling PUSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n", symbol, ch_amp, pilots, nb_rb, frame_parms->Ncp, symbol); + // printf("Scaling PUSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp); + + ch_amp128 = _mm_set1_epi16(ch_amp); // Q3.13 + + for (aatx=0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) { + for (aarx=0; aarx < frame_parms->nb_antennas_rx; aarx++) { + + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*nb_rb*NR_NB_SC_PER_RB]; + + if (pilots==1){ + nb_rb = nb_rb>>1; + } + + + for (rb=0;rb>x; + //printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x); + + for (aatx = 0; aatx < frame_parms->nb_antennas_tx; aatx++) + for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + //clear average level + avg128U = _mm_setzero_si128(); + + ul_ch128=(__m128i *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12]; + + for (rb = 0; rb < nb_rb; rb++) { + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[0], ul_ch128[0]), x)); + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[1], ul_ch128[1]), x)); + avg128U = _mm_add_epi32(avg128U, _mm_srai_epi32(_mm_madd_epi16(ul_ch128[2], ul_ch128[2]), x)); + ul_ch128+=3; + } + + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128U)[0] + + ((int32_t*)&avg128U)[1] + + ((int32_t*)&avg128U)[2] + + ((int32_t*)&avg128U)[3] ) / y; + + } + + _mm_empty(); + _m_empty(); + +#elif defined(__arm__) + + short rb; + unsigned char aatx, aarx, nre = 12, symbol_mod; + int32x4_t avg128U; + int16x4_t *ul_ch128; + + symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) + for (aarx=0; aarxnb_antennas_rx; aarx++) { + //clear average level + avg128U = vdupq_n_s32(0); + // 5 is always a symbol with no pilots for both normal and extended prefix + + ul_ch128 = (int16x4_t *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb = 0; rb < nb_rb; rb++) { + // printf("rb %d : ",rb); + // print_shorts("ch",&ul_ch128[0]); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[0], ul_ch128[0])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[1], ul_ch128[1])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[2], ul_ch128[2])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[3], ul_ch128[3])); + + if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) { + ul_ch128+=4; + } else { + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[4], ul_ch128[4])); + avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[5], ul_ch128[5])); + ul_ch128+=6; + } + + /* + if (rb==0) { + print_shorts("ul_ch128",&ul_ch128[0]); + print_shorts("ul_ch128",&ul_ch128[1]); + print_shorts("ul_ch128",&ul_ch128[2]); + } + */ + } + + if (symbol==2) //assume start symbol 2 + nre=6; + else + nre=12; + + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128U)[0] + + ((int32_t*)&avg128U)[1] + + ((int32_t*)&avg128U)[2] + + ((int32_t*)&avg128U)[3] ) / (nb_rb*nre); + } + + +#endif +} + +void nr_ulsch_channel_compensation(int **rxdataF_ext, + int **ul_ch_estimates_ext, + int **ul_ch_mag, + int **ul_ch_magb, + int **rxdataF_comp, + int **rho, + NR_DL_FRAME_PARMS *frame_parms, + unsigned char symbol, + uint8_t pilots, + unsigned char mod_order, + unsigned short nb_rb, + unsigned char output_shift) +{ + +#ifdef DEBUG_CH_COMP + int16_t *rxF, *ul_ch; + int prnt_idx; + + + rxF = (int16_t *)&rxdataF_ext[0][(symbol*nb_rb*12)]; + ul_ch = (int16_t *)&ul_ch_estimates_ext[0][symbol*nb_rb*12]; + + printf("--------------------symbol = %d, mod_order = %d, output_shift = %d-----------------------\n", symbol, mod_order, output_shift); + printf("----------------Before compansation------------------\n"); + + for (prnt_idx=0;prnt_idx<12*nb_rb*2;prnt_idx++){ + + printf("rxF[%d] = %d\n", prnt_idx, rxF[prnt_idx]); + printf("ul_ch[%d] = %d\n", prnt_idx, ul_ch[prnt_idx]); + + } + +#endif + +#ifdef DEBUG_CH_MAG + int16_t *ch_mag; + int print_idx; + + + ch_mag = (int16_t *)&ul_ch_mag[0][(symbol*nb_rb*12)]; + + printf("--------------------symbol = %d, mod_order = %d-----------------------\n", symbol, mod_order); + printf("----------------Before computation------------------\n"); + + for (print_idx=0;print_idx<50;print_idx++){ + + printf("ch_mag[%d] = %d\n", print_idx, ch_mag[print_idx]); + + } + +#endif + +#if defined(__i386) || defined(__x86_64) + + unsigned short rb; + unsigned char aatx,aarx; + __m128i *ul_ch128,*ul_ch128_2,*ul_ch_mag128,*ul_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + QAM_amp128b = _mm_setzero_si128(); + + for (aatx=0; aatxnb_antennas_tx; aatx++) { + + if (mod_order == 4) { + QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = _mm_setzero_si128(); + } else if (mod_order == 6) { + QAM_amp128 = _mm_set1_epi16(QAM64_n1); // + QAM_amp128b = _mm_set1_epi16(QAM64_n2); + } + + // printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol); + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12]; + ul_ch_mag128 = (__m128i *)&ul_ch_mag[(aatx<<1)+aarx][symbol*nb_rb*12]; + ul_ch_mag128b = (__m128i *)&ul_ch_magb[(aatx<<1)+aarx][symbol*nb_rb*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*nb_rb*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*nb_rb*12]; + + + for (rb=0; rb2) { + // get channel amplitude if not QPSK + + //print_shorts("ch:",(int16_t*)&ul_ch128[0]); + + mmtmpD0 = _mm_madd_epi16(ul_ch128[0],ul_ch128[0]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + + mmtmpD1 = _mm_madd_epi16(ul_ch128[1],ul_ch128[1]); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + + mmtmpD0 = _mm_packs_epi32(mmtmpD0,mmtmpD1); + + // store channel magnitude here in a new field of ulsch + + ul_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpD0,mmtmpD0); + ul_ch_mag128b[0] = ul_ch_mag128[0]; + ul_ch_mag128[0] = _mm_mulhi_epi16(ul_ch_mag128[0],QAM_amp128); + ul_ch_mag128[0] = _mm_slli_epi16(ul_ch_mag128[0],1); + + // print_ints("ch: = ",(int32_t*)&mmtmpD0); + // print_shorts("QAM_amp:",(int16_t*)&QAM_amp128); + // print_shorts("mag:",(int16_t*)&ul_ch_mag128[0]); + + ul_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpD0,mmtmpD0); + ul_ch_mag128b[1] = ul_ch_mag128[1]; + ul_ch_mag128[1] = _mm_mulhi_epi16(ul_ch_mag128[1],QAM_amp128); + ul_ch_mag128[1] = _mm_slli_epi16(ul_ch_mag128[1],1); + + if (pilots==0) { + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]); + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_packs_epi32(mmtmpD0,mmtmpD0); + + ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpD1,mmtmpD1); + ul_ch_mag128b[2] = ul_ch_mag128[2]; + + ul_ch_mag128[2] = _mm_mulhi_epi16(ul_ch_mag128[2],QAM_amp128); + ul_ch_mag128[2] = _mm_slli_epi16(ul_ch_mag128[2],1); + } + + ul_ch_mag128b[0] = _mm_mulhi_epi16(ul_ch_mag128b[0],QAM_amp128b); + ul_ch_mag128b[0] = _mm_slli_epi16(ul_ch_mag128b[0],1); + + + ul_ch_mag128b[1] = _mm_mulhi_epi16(ul_ch_mag128b[1],QAM_amp128b); + ul_ch_mag128b[1] = _mm_slli_epi16(ul_ch_mag128b[1],1); + + if (pilots==0) { + ul_ch_mag128b[2] = _mm_mulhi_epi16(ul_ch_mag128b[2],QAM_amp128b); + ul_ch_mag128b[2] = _mm_slli_epi16(ul_ch_mag128b[2],1); + } + } + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[0],rxdataF128[0]); + // print_ints("re",&mmtmpD0); + + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]); + // print_ints("im",&mmtmpD1); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[0]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + // print_ints("re(shift)",&mmtmpD0); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + // print_ints("im(shift)",&mmtmpD1); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + // print_ints("c0",&mmtmpD2); + // print_ints("c1",&mmtmpD3); + rxdataF_comp128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128); + // print_shorts("ch:",ul_ch128); + // print_shorts("pack:",rxdataF_comp128); + + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[1],rxdataF128[1]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[1],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[1]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[1] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+1); + // print_shorts("ch:",ul_ch128+1); + // print_shorts("pack:",rxdataF_comp128+1); + + if (pilots==0) { + // multiply by conjugated channel + mmtmpD0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); + // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) + mmtmpD1 = _mm_shufflelo_epi16(ul_ch128[2],_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1)); + mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)conjugate); + mmtmpD1 = _mm_madd_epi16(mmtmpD1,rxdataF128[2]); + // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) + mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift); + mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift); + mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1); + mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1); + + rxdataF_comp128[2] = _mm_packs_epi32(mmtmpD2,mmtmpD3); + // print_shorts("rx:",rxdataF128+2); + // print_shorts("ch:",ul_ch128+2); + // print_shorts("pack:",rxdataF_comp128+2); + + ul_ch128+=3; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=3; + rxdataF_comp128+=3; + } else { // we have a smaller PUSCH in symbols with pilots so skip last group of 4 REs and increment less + ul_ch128+=2; + ul_ch_mag128+=2; + ul_ch_mag128b+=2; + rxdataF128+=2; + rxdataF_comp128+=2; + } + + } + } + } + + if (rho) { + + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128_2 = (__m128i *)&ul_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb=0; rb=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; + + if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) { + if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size + nb_rb=1+(5*nb_rb/6); + } + else { + pilots=1; + } + } + + for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) { + if (mod_order == 4) { + QAM_amp128 = vmovq_n_s16(QAM16_n1); // 2/sqrt(10) + QAM_amp128b = vmovq_n_s16(0); + } else if (mod_order == 6) { + QAM_amp128 = vmovq_n_s16(QAM64_n1); // + QAM_amp128b = vmovq_n_s16(QAM64_n2); + } + // printf("comp: rxdataF_comp %p, symbol %d\n",rxdataF_comp[0],symbol); + + for (aarx=0; aarxnb_antennas_rx; aarx++) { + ul_ch128 = (int16x4_t*)&ul_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch_mag128 = (int16x8_t*)&ul_ch_mag[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch_mag128b = (int16x8_t*)&ul_ch_magb[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + rxdataF128 = (int16x4_t*)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + rxdataF_comp128 = (int16x4x2_t*)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_UL*12]; + + for (rb=0; rb2) { + // get channel amplitude if not QPSK + mmtmpD0 = vmull_s16(ul_ch128[0], ul_ch128[0]); + // mmtmpD0 = [ch0*ch0,ch1*ch1,ch2*ch2,ch3*ch3]; + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + // mmtmpD0 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3]>>output_shift128 on 32-bits + mmtmpD1 = vmull_s16(ul_ch128[1], ul_ch128[1]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD2 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + // mmtmpD2 = [ch0*ch0 + ch1*ch1,ch0*ch0 + ch1*ch1,ch2*ch2 + ch3*ch3,ch2*ch2 + ch3*ch3,ch4*ch4 + ch5*ch5,ch4*ch4 + ch5*ch5,ch6*ch6 + ch7*ch7,ch6*ch6 + ch7*ch7]>>output_shift128 on 16-bits + mmtmpD0 = vmull_s16(ul_ch128[2], ul_ch128[2]); + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + mmtmpD1 = vmull_s16(ul_ch128[3], ul_ch128[3]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD3 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + if (pilots==0) { + mmtmpD0 = vmull_s16(ul_ch128[4], ul_ch128[4]); + mmtmpD0 = vqshlq_s32(vqaddq_s32(mmtmpD0,vrev64q_s32(mmtmpD0)),output_shift128); + mmtmpD1 = vmull_s16(ul_ch128[5], ul_ch128[5]); + mmtmpD1 = vqshlq_s32(vqaddq_s32(mmtmpD1,vrev64q_s32(mmtmpD1)),output_shift128); + mmtmpD4 = vcombine_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + } + + ul_ch_mag128b[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128b); + ul_ch_mag128b[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128b); + ul_ch_mag128[0] = vqdmulhq_s16(mmtmpD2,QAM_amp128); + ul_ch_mag128[1] = vqdmulhq_s16(mmtmpD3,QAM_amp128); + + if (pilots==0) { + ul_ch_mag128b[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128b); + ul_ch_mag128[2] = vqdmulhq_s16(mmtmpD4,QAM_amp128); + } + } + + mmtmpD0 = vmull_s16(ul_ch128[0], rxdataF128[0]); + //mmtmpD0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] + mmtmpD1 = vmull_s16(ul_ch128[1], rxdataF128[1]); + //mmtmpD1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + //mmtmpD0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] + + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]); + //mmtmpD0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]); + //mmtmpD0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + //mmtmpD1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] + + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[0] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + mmtmpD0 = vmull_s16(ul_ch128[2], rxdataF128[2]); + mmtmpD1 = vmull_s16(ul_ch128[3], rxdataF128[3]); + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]); + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]); + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[1] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + + if (pilots==0) { + mmtmpD0 = vmull_s16(ul_ch128[4], rxdataF128[4]); + mmtmpD1 = vmull_s16(ul_ch128[5], rxdataF128[5]); + mmtmpD0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0),vget_high_s32(mmtmpD0)), + vpadd_s32(vget_low_s32(mmtmpD1),vget_high_s32(mmtmpD1))); + + mmtmpD0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]); + mmtmpD1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]); + mmtmpD1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpD0b),vget_high_s32(mmtmpD0b)), + vpadd_s32(vget_low_s32(mmtmpD1b),vget_high_s32(mmtmpD1b))); + + + mmtmpD0 = vqshlq_s32(mmtmpD0,output_shift128); + mmtmpD1 = vqshlq_s32(mmtmpD1,output_shift128); + rxdataF_comp128[2] = vzip_s16(vmovn_s32(mmtmpD0),vmovn_s32(mmtmpD1)); + + + ul_ch128+=6; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=6; + rxdataF_comp128+=3; + + } else { // we have a smaller PUSCH in symbols with pilots so skip last group of 4 REs and increment less + ul_ch128+=4; + ul_ch_mag128+=2; + ul_ch_mag128b+=2; + rxdataF128+=4; + rxdataF_comp128+=2; + } + } + } + } + + if (rho) { + for (aarx=0; aarxnb_antennas_rx; aarx++) { + rho128 = (int16x4x2_t*)&rho[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128 = (int16x4_t*)&ul_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_UL*12]; + ul_ch128_2 = (int16x4_t*)&ul_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_UL*12]; + for (rb=0; rbframe_parms; nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15; - uint32_t nb_re_pusch; - - if(symbol == rel15_ul->start_symbol) - gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0; + uint32_t nb_re_pusch, bwp_start_subcarrier; + int avgs; + int avg[4]; - if (symbol == 2) // [hna] here it is assumed that symbol 2 carries 6 DMRS REs (dmrs-type 1) + cw_idx = 0; // temp implementation + pilots = 0; + first_symbol_flag = 0; + + if(symbol == rel15_ul->start_symbol){ + gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0; + first_symbol_flag = 1; + } + + if (symbol == 2){ // [hna] here it is assumed that symbol 2 carries 6 DMRS REs (dmrs-type 1) nb_re_pusch = rel15_ul->number_rbs * 6; - else + pilots = 1; + } else { nb_re_pusch = rel15_ul->number_rbs * NR_NB_SC_PER_RB; + pilots = 0; + } + + bwp_start_subcarrier = (rel15_ul->start_rb*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; + + //---------------------------------------------------------- + //--------------------- Channel estimation --------------------- + //---------------------------------------------------------- + + if (pilots == 1) + nr_pusch_channel_estimation(gNB, + 0, + nr_tti_rx, + 0, // p + symbol, + bwp_start_subcarrier, + rel15_ul->number_rbs); //---------------------------------------------------------- //--------------------- RBs extraction --------------------- //---------------------------------------------------------- nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, + gNB->pusch_vars[UE_id]->ul_ch_estimates, gNB->pusch_vars[UE_id]->rxdataF_ext, + gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, gNB->pusch_vars[UE_id]->rxdataF_ext_offset, // rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment symbol, @@ -288,6 +1029,44 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, rel15_ul->number_rbs, frame_parms); + nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + frame_parms, + gNB->ulsch, + symbol, + pilots, + rel15_ul->number_rbs); + + if (first_symbol_flag==1) { + + nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + frame_parms, + avg, + symbol, + nb_re_pusch, + rel15_ul->number_rbs); + avgs = 0; + + for (aatx=0;aatxnb_antennas_tx;aatx++) + for (aarx=0;aarxnb_antennas_rx;aarx++) + avgs = cmax(avgs,avg[(aatx<<1)+aarx]); + + gNB->pusch_vars[UE_id]->log2_maxh = (log2_approx(avgs)/2)+1; + + } + + nr_ulsch_channel_compensation(gNB->pusch_vars[UE_id]->rxdataF_ext, + gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, + gNB->pusch_vars[UE_id]->ul_ch_mag0, + gNB->pusch_vars[UE_id]->ul_ch_magb0, + gNB->pusch_vars[UE_id]->rxdataF_comp, + (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[UE_id]->rho : NULL, + frame_parms, + symbol, + pilots, + rel15_ul->Qm, + rel15_ul->number_rbs, + gNB->pusch_vars[UE_id]->log2_maxh); + #ifdef NR_SC_FDMA nr_idft(&((uint32_t*)gNB->pusch_vars[UE_id]->rxdataF_ext[0])[symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], nb_re_pusch); #endif @@ -296,14 +1075,15 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, //-------------------- LLRs computation -------------------- //---------------------------------------------------------- - nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_ext[0][symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], - gNB->pusch_vars[UE_id]->ul_ch_mag, - gNB->pusch_vars[UE_id]->ul_ch_magb, + nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], + gNB->pusch_vars[UE_id]->ul_ch_mag0, + gNB->pusch_vars[UE_id]->ul_ch_magb0, &gNB->pusch_vars[UE_id]->llr[gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->Qm], + rel15_ul->number_rbs, nb_re_pusch, symbol, rel15_ul->Qm); - + gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset + nb_re_pusch; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c index d2d8cdd927..233ecd8de7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c @@ -30,7 +30,6 @@ * \warning */ - #include "PHY/defs_nr_common.h" #include "PHY/sse_intrin.h" #include "PHY/impl_defs_top.h" @@ -71,23 +70,20 @@ void nr_ulsch_qpsk_llr(int32_t *rxdataF_comp, void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol) { + #if defined(__x86_64__) || defined(__i386__) __m128i *rxF = (__m128i*)rxdataF_comp; - // __m128i *ch_mag; // [hna] This should be uncommented once channel estimation is implemented + __m128i *ch_mag; __m128i llr128[2]; uint32_t *llr32; - // [hna] temp_channel and one_over_sqrt_2 are for temporary use until channel estimation is implemented - // else ul_ch_mag and ul_ch_magb should be used after channel estimation has benn implemented - __m128i temp_channel; - int16_t one_over_sqrt_2 = 23170; - #elif defined(__arm__) int16x8_t *rxF = (int16x8_t*)&rxdataF_comp; - // int16x8_t *ch_mag; // [hna] This should be uncommented once channel estimation is implemented + int16x8_t *ch_mag; int16x8_t xmm0; int16_t *llr16; #endif @@ -103,21 +99,16 @@ void nr_ulsch_16qam_llr(int32_t *rxdataF_comp, llr16 = (int16_t*)ulsch_llr; #endif -// [hna] This should be uncommented once channel estimation is implemented -// ------------------------------------------------------------ -// #if defined(__x86_64__) || defined(__i386__) -// ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; -// #elif defined(__arm__) -// ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; -// #endif -// ------------------------------------------------------------ +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; +#endif len_mod4 = nb_re&3; nb_re >>= 2; // length in quad words (4 REs) nb_re += (len_mod4 == 0 ? 0 : 1); - temp_channel = _mm_set1_epi16((QAM16_n1 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); - for (i=0; i |y_R|, registers of odd index in xmm0-> |y_I| - xmm0 = _mm_subs_epi16(temp_channel,xmm0); // registers of even index in xmm0-> |y_R|-|h|^2, registers of odd index in xmm0-> |y_I|-|h|^2 + xmm0 = _mm_subs_epi16(ch_mag[i],xmm0); // registers of even index in xmm0-> |y_R|-|h|^2, registers of odd index in xmm0-> |y_I|-|h|^2 llr128[0] = _mm_unpacklo_epi32(rxF[i],xmm0); // llr128[0] contains the llrs of the 1st and 2nd REs llr128[1] = _mm_unpackhi_epi32(rxF[i],xmm0); // llr128[1] contains the llrs of the 3rd and 4th REs @@ -186,52 +177,43 @@ void nr_ulsch_64qam_llr(int32_t *rxdataF_comp, int32_t **ul_ch_mag, int32_t **ul_ch_magb, int16_t *ulsch_llr, + uint32_t nb_rb, uint32_t nb_re, uint8_t symbol) { + #if defined(__x86_64__) || defined(__i386__) __m128i *rxF = (__m128i*)rxdataF_comp; - // __m128i *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented - - // [hna] temp_channel and one_over_sqrt_2 are for temporary use until channel estimation is implemented - // else ul_ch_mag and ul_ch_magb should be used after channel estimation has been implemented - __m128i temp_channel[2]; - int16_t one_over_sqrt_2 = 23170; - + __m128i *ch_mag,*ch_magb; #elif defined(__arm__) int16x8_t *rxF = (int16x8_t*)&rxdataF_comp; - // int16x8_t *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented + int16x8_t *ch_mag,*ch_magb; // [hna] This should be uncommented once channel estimation is implemented int16x8_t xmm1,xmm2; #endif int i; unsigned char len_mod4; -// [hna] This should be uncommented once channel estimation is implemented -// ------------------------------------------------------------------------- -// #if defined(__x86_64__) || defined(__i386__) -// ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*frame_parms->N_RB_UL*12)]; -// ch_magb = (__m128i*)&ul_ch_magb[0][(symbol*frame_parms->N_RB_UL*12)]; -// #elif defined(__arm__) -// ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*frame_parms->N_RB_UL*12)]; -// ch_magb = (int16x8_t*)&ul_ch_magb[0][(symbol*frame_parms->N_RB_UL*12)]; -// #endif -// ------------------------------------------------------------------------- +#if defined(__x86_64__) || defined(__i386__) + ch_mag = (__m128i*)&ul_ch_mag[0][(symbol*nb_rb*12)]; + ch_magb = (__m128i*)&ul_ch_magb[0][(symbol*nb_rb*12)]; +#elif defined(__arm__) + ch_mag = (int16x8_t*)&ul_ch_mag[0][(symbol*nb_rb*12)]; + ch_magb = (int16x8_t*)&ul_ch_magb[0][(symbol*nb_rb*12)]; +#endif len_mod4 = nb_re&3; nb_re = nb_re>>2; // length in quad words (4 REs) nb_re += ((len_mod4 == 0) ? 0 : 1); - - temp_channel[0] = _mm_set1_epi16((QAM64_n1 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); - temp_channel[1] = _mm_set1_epi16((QAM64_n2 * one_over_sqrt_2)>>(2*15-AMP_SHIFT)); + for (i=0; isymbols_per_tti[ - int32_t **drs_ch_estimates; + int32_t **ul_ch_estimates; + /// \brief Uplink channel estimates extracted in PRBS. + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ + int32_t **ul_ch_estimates_ext; /// \brief Holds the compensated signal. /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ @@ -383,6 +387,28 @@ typedef struct { /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ int32_t **ul_ch_magb; + /// \brief Cross-correlation of two UE signals. + /// - first index: rx antenna [0..nb_antennas_rx[ + /// - second index: symbol [0..] + int32_t **rho; + /// \f$\log_2(\max|H_i|^2)\f$ + int16_t log2_maxh; + /// \brief Magnitude of Uplink Channel first layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_mag0; + /// \brief Magnitude of Uplink Channel second layer (16QAM level/First 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_mag1[8][8]; + /// \brief Magnitude of Uplink Channel, first layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_magb0; + /// \brief Magnitude of Uplink Channel second layer (2nd 64QAM level). + /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx + /// - second index: ? [0..168*N_RB_UL[ + int32_t **ul_ch_magb1[8][8]; /// measured RX power based on DRS int ulsch_power[2]; /// \brief llr values. @@ -643,6 +669,9 @@ typedef struct PHY_VARS_gNB_s { /// PDSCH DMRS sequence uint32_t ****nr_gold_pdsch_dmrs; + + /// PUSCH DMRS + uint32_t nr_gold_pusch[2][20][2][52]; /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index ee14ad36ec..88a02c45c7 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -208,6 +208,7 @@ /// First Amplitude for QAM16 (\f$ 2^{15} \times 2/\sqrt{10}\f$) #define QAM16_n1 20724 + /// Second Amplitude for QAM16 (\f$ 2^{15} \times 1/\sqrt{10}\f$) #define QAM16_n2 10362 diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index ac268fa1e3..1281675599 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -497,6 +497,8 @@ int main(int argc, char **argv) //---------------------- count errors ---------------------- //---------------------------------------------------------- + printf("available_bits = %d\n",available_bits); + for (i = 0; i < available_bits; i++) { if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || @@ -511,6 +513,7 @@ int main(int argc, char **argv) } + for (i = 0; i < TBS; i++) { estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); From ffbe17f3d74b2174c5db432131afb202925b26b4 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 17 Jun 2019 16:28:40 +0200 Subject: [PATCH 08/32] fix gNB linker error and various warnings --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/INIT/nr_init.c | 27 ++++++++++++------- .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c | 13 +++------ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 15 +++++------ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 9f09081a16..ca88d25b7e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1332,6 +1332,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sch_dmrs.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c + ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 6b5acb85e4..ebdee91d11 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -294,7 +294,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) //NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms; //nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_gNB_COMMON *const common_vars = &gNB->common_vars; - //NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars; + NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars; /*LTE_eNB_SRS *const srs_vars = gNB->srs_vars; LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars;*/ uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; @@ -330,29 +330,38 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(prach_vars->prach_ifft[0]); free_and_zero(prach_vars->rxsigF[0]); - - for (UE_id=0; UE_idrxdataF_ext[i]); free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time[i]); free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag0[i]); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb0[i]); free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]); free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]); + free_and_zero(pusch_vars[UE_id]->rho[i]); } free_and_zero(pusch_vars[UE_id]->rxdataF_ext); free_and_zero(pusch_vars[UE_id]->rxdataF_ext2); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext); + free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time); free_and_zero(pusch_vars[UE_id]->rxdataF_comp); + free_and_zero(pusch_vars[UE_id]->ul_ch_mag0); + free_and_zero(pusch_vars[UE_id]->ul_ch_magb0); free_and_zero(pusch_vars[UE_id]->ul_ch_mag); free_and_zero(pusch_vars[UE_id]->ul_ch_magb); + free_and_zero(pusch_vars[UE_id]->rho); + free_and_zero(pusch_vars[UE_id]->llr); free_and_zero(pusch_vars[UE_id]); } //UE_id - +/* for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) gNB->UE_stats_ptr[UE_id] = NULL; */ } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index c3e4f42e5f..e1b3c5cec9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -3,15 +3,13 @@ #include "nr_transport_proto.h" #include "PHY/impl_defs_top.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" +#include "PHY/NR_ESTIMATION/nr_ul_estimation.h" #include "PHY/defs_nr_common.h" //#define DEBUG_CH_COMP //#define DEBUG_RB_EXT //#define DEBUG_CH_MAG -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}; - void nr_idft(uint32_t *z, uint32_t Msc_PUSCH) { @@ -353,13 +351,11 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext, #if defined(__x86_64__)||defined(__i386__) short rb; - unsigned char aatx, aarx, nre = 12; + unsigned char aatx, aarx; __m128i *ul_ch128, avg128U; - //nb_rb*nre = y * 2^x int16_t x = factor2(len); int16_t y = (len)>>x; - //printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x); for (aatx = 0; aatx < frame_parms->nb_antennas_tx; aatx++) for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { @@ -975,14 +971,13 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, unsigned char harq_pid) { - uint8_t cw_idx, first_symbol_flag, aarx, aatx, pilots; // pilots, a flag to indicate DMRS REs in current symbol + uint8_t first_symbol_flag, aarx, aatx, pilots; // pilots, a flag to indicate DMRS REs in current symbol NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15; uint32_t nb_re_pusch, bwp_start_subcarrier; int avgs; int avg[4]; - cw_idx = 0; // temp implementation pilots = 0; first_symbol_flag = 0; @@ -1031,7 +1026,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, frame_parms, - gNB->ulsch, + gNB->ulsch[UE_id+1], symbol, pilots, rel15_ul->number_rbs); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 674df8b451..89d89cbae2 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2464,11 +2464,10 @@ void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t gNB_id, - uint8_t thread_id) + UE_nr_rxtx_proc_t *proc, + uint8_t gNB_id, + uint8_t thread_id) { - //NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; NR_UE_ULSCH_t *ulsch_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue; //int32_t ulsch_start=0; @@ -4116,10 +4115,10 @@ int is_pbch_in_slot(fapi_nr_pbch_config_t *pbch_config, int frame, int slot, int int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - uint8_t do_pdcch_flag, - runmode_t mode) + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint8_t do_pdcch_flag, + runmode_t mode) { int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; From b4c0acad9cbd7e6516f64398e403e2ddf6ed52a8 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 3 Jul 2019 14:42:04 +0200 Subject: [PATCH 09/32] fix crashes in nr_ulsch_decoding - initialize p_decParams->Z from harq_process not only in round 0 - do not set opp_enabled=1, this crashes in LDPC encoder --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 6ca2733120..1af31d77e9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -364,15 +364,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, &harq_process->Z, // [hna] Z is Zc &harq_process->F); - p_decParams->Z = harq_process->Z; - #ifdef DEBUG_ULSCH_DECODING - printf("ulsch decoding nr segmentation Z %d\n", p_decParams->Z); + printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); if (!frame%100) - printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); + printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl); #endif } + p_decParams->Z = harq_process->Z; + Coderate = (float) A /(float) G; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ @@ -436,7 +436,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); #endif - opp_enabled=1; + //opp_enabled=1; Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" Kr_bytes = Kr>>3; From 274c60f87c016328f6abd5dbd0481fef8c05bc89 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 3 Jul 2019 18:11:57 +0200 Subject: [PATCH 10/32] PUSCH running with rfsimulator --- .gitignore | 3 +- executables/nr-ru.c | 12 +- executables/nr-ue.c | 10 +- executables/nr-uesoftmodem.c | 2 + openair1/PHY/INIT/nr_parms.c | 2 + openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 170 +++++++++--------- .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c | 6 +- .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c | 1 + openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 6 +- openair1/PHY/defs_gNB.h | 2 +- openair1/SCHED_NR/nr_ru_procedures.c | 4 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 45 +++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 2 + 15 files changed, 144 insertions(+), 125 deletions(-) diff --git a/.gitignore b/.gitignore index 06a51f1b64..73e0407c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # log and exec file cmake_targets/log/ cmake_targets/*/build/ +cmake_targets/ran_build/ log/ lte_build_oai/ -targets/bin/ \ No newline at end of file +targets/bin/ diff --git a/executables/nr-ru.c b/executables/nr-ru.c index c26eb6d253..ca63123c73 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -659,6 +659,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) { ru->nb_rx); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); proc->timestamp_rx = ts-ru->ts_offset; @@ -1448,6 +1449,7 @@ static void *ru_thread( void *param ) { } // synchronization on input FH interface, acquire signals/data and block + LOG_D(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot); if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&slot); else AssertFatal(1==0, "No fronthaul interface at south port"); @@ -1474,14 +1476,12 @@ static void *ru_thread( void *param ) { // do RX front-end processing (frequency-shift, dft) if needed if (ru->feprx) ru->feprx(ru,proc->tti_rx); - LOG_I(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); - LOG_I(PHY,"gNB proc: frame_rx = %d, slot_rx = %d\n", RC.gNB[0][0]->proc.frame_rx, RC.gNB[0][0]->proc.slot_rx); - LOG_I(PHY,"Copying rxdataF from RU to gNB\n"); + LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); + LOG_D(PHY,"Copying rxdataF from RU to gNB\n"); for (aa=0;aanb_rx;aa++) memcpy((void*)RC.gNB[0][0]->common_vars.rxdataF[aa], - (void*)&ru->common.rxdataF[aa][proc->tti_rx*fp->symbols_per_tti*fp->ofdm_symbol_size], - fp->symbols_per_tti*fp->ofdm_symbol_size*sizeof(int32_t)); + (void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t)); // At this point, all information for subframe has been received on FH interface @@ -2155,7 +2155,7 @@ void init_NR_RU(char *rf_config_file) if (gNB0) { LOG_I(PHY,"Copying frame parms from gNB %d to ru %d\n",gNB0->Mod_id,ru->idx); memcpy((void *)fp,(void *)&gNB0->frame_parms,sizeof(NR_DL_FRAME_PARMS)); - memset((void *)ru->frame_parms, 0, sizeof(LTE_DL_FRAME_PARMS)); + memset((void *)ru->nr_frame_parms, 0, sizeof(NR_DL_FRAME_PARMS)); // attach all RU to all gNBs in its list/ LOG_D(PHY,"ru->num_gNB:%d gNB0->num_RU:%d\n", ru->num_gNB, gNB0->num_RU); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 41d048ccf7..4770f2dc15 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -141,8 +141,10 @@ PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, ue = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE)); memset(ue,0,sizeof(PHY_VARS_NR_UE)); memcpy(&(ue->frame_parms), frame_parms, sizeof(NR_DL_FRAME_PARMS)); + ue->Mod_id = UE_id; ue->mac_enabled = 1; + // initialize all signal buffers init_nr_ue_signal(ue,1,abstraction_flag); // intialize transport @@ -430,14 +432,12 @@ void UE_processing(void *arg) { (UE->frame_parms.frame_type == FDD) ) #endif */ - if (proc->nr_tti_tx == NR_UPLINK_SLOT){ - - LOG_I(PHY, "[UE_processing] Frame = %d, Slot = %d\n", proc->frame_tx, proc->nr_tti_tx); + //if (proc->nr_tti_tx == NR_UPLINK_SLOT){ if (UE->mode != loop_through_memory) phy_procedures_nrUE_TX(UE,proc,0,0); - } + //} //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); @@ -664,7 +664,7 @@ void *UE_thread(void *arg) { slot_nr*UE->frame_parms.samples_per_slot]; for (int i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void *)&UE->common_vars.txdata[i][curMsg->proc.nr_tti_tx*UE->frame_parms.samples_per_slot]; + txp[i] = (void *)&UE->common_vars.txdata[i][((curMsg->proc.nr_tti_rx + 2)%nb_slot_frame)*UE->frame_parms.samples_per_slot]; int readBlockSize, writeBlockSize; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index b78913e1bd..84836acf89 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -77,6 +77,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include + /* Callbacks, globals and object handlers */ extern void reset_stats( FL_OBJECT *, long ); @@ -728,6 +729,7 @@ int main( int argc, char **argv ) { PHY_vars_UE_g[0][CC_id] = init_nr_ue_vars(frame_parms[CC_id], 0,abstraction_flag); UE[CC_id] = PHY_vars_UE_g[0][CC_id]; + if (phy_test==1) UE[CC_id]->mac_enabled = 0; else diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 00b2b6a7da..ad29a95ef4 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -224,6 +224,8 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, fp->slots_per_frame = 10* fp->slots_per_subframe; fp->nb_antenna_ports_eNB = 1; // default value until overwritten by RRCConnectionReconfiguration + fp->nb_antennas_rx = 1; // default value until overwritten by RRCConnectionReconfiguration + fp->nb_antennas_tx = 1; // default value until overwritten by RRCConnectionReconfiguration fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe; diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 476d1d2555..48fcd04a0f 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -143,7 +143,7 @@ void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDM //printf("x1 : %x, x2 : %x\n",x1,x2); } - for (n=0; n<52; n++) { + for (n=0; n>1) ^ (x1>>4); x1 = x1 ^ (x1<<31) ^ (x1<<28); x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 1af31d77e9..0cb9f56ae4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -176,96 +176,96 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) unsigned char i, j; if (ulsch) { - ulsch->harq_mask = 0; - ulsch->bundling = 0; - ulsch->beta_offset_cqi_times8 = 0; - ulsch->beta_offset_ri_times8 = 0; - ulsch->beta_offset_harqack_times8 = 0; - ulsch->Msg3_active = 0; - ulsch->Msg3_flag = 0; - ulsch->Msg3_subframe = 0; - ulsch->Msg3_frame = 0; - ulsch->rnti = 0; - ulsch->rnti_type = 0; - ulsch->cyclicShift = 0; - ulsch->cooperation_flag = 0; - ulsch->Mlimit = 0; - ulsch->max_ldpc_iterations = 0; - ulsch->last_iteration_cnt = 0; - ulsch->num_active_cba_groups = 0; - for (i=0;icba_rnti[i] = 0; - for (i=0;iharq_process_id[i] = 0; + ulsch->harq_mask = 0; + ulsch->bundling = 0; + ulsch->beta_offset_cqi_times8 = 0; + ulsch->beta_offset_ri_times8 = 0; + ulsch->beta_offset_harqack_times8 = 0; + ulsch->Msg3_active = 0; + ulsch->Msg3_flag = 0; + ulsch->Msg3_subframe = 0; + ulsch->Msg3_frame = 0; + ulsch->rnti = 0; + ulsch->rnti_type = 0; + ulsch->cyclicShift = 0; + ulsch->cooperation_flag = 0; + ulsch->Mlimit = 0; + ulsch->max_ldpc_iterations = 0; + ulsch->last_iteration_cnt = 0; + ulsch->num_active_cba_groups = 0; + for (i=0;icba_rnti[i] = 0; + for (i=0;iharq_process_id[i] = 0; - for (i=0; iharq_processes[i]){ - /// Nfapi ULSCH PDU - //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; - ulsch->harq_processes[i]->frame=0; - ulsch->harq_processes[i]->subframe=0; - ulsch->harq_processes[i]->round=0; - ulsch->harq_processes[i]->TPC=0; - ulsch->harq_processes[i]->mimo_mode=0; - ulsch->harq_processes[i]->dci_alloc=0; - ulsch->harq_processes[i]->rar_alloc=0; - ulsch->harq_processes[i]->status=0; - ulsch->harq_processes[i]->subframe_scheduling_flag=0; - ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; - ulsch->harq_processes[i]->phich_active=0; - ulsch->harq_processes[i]->phich_ACK=0; - ulsch->harq_processes[i]->previous_first_rb=0; - ulsch->harq_processes[i]->handled=0; - ulsch->harq_processes[i]->delta_TF=0; + for (i=0; iharq_processes[i]){ + /// Nfapi ULSCH PDU + //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; + ulsch->harq_processes[i]->frame=0; + ulsch->harq_processes[i]->subframe=0; + ulsch->harq_processes[i]->round=0; + ulsch->harq_processes[i]->TPC=0; + ulsch->harq_processes[i]->mimo_mode=0; + ulsch->harq_processes[i]->dci_alloc=0; + ulsch->harq_processes[i]->rar_alloc=0; + ulsch->harq_processes[i]->status=0; + ulsch->harq_processes[i]->subframe_scheduling_flag=0; + ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; + ulsch->harq_processes[i]->phich_active=0; + ulsch->harq_processes[i]->phich_ACK=0; + ulsch->harq_processes[i]->previous_first_rb=0; + ulsch->harq_processes[i]->handled=0; + ulsch->harq_processes[i]->delta_TF=0; - ulsch->harq_processes[i]->TBS=0; - /// Pointer to the payload (38.212 V15.4.0 section 5.1) - //uint8_t *b; - ulsch->harq_processes[i]->B=0; - /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) - //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; - ulsch->harq_processes[i]->K=0; - ulsch->harq_processes[i]->F=0; - ulsch->harq_processes[i]->C=0; - /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) - //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; - /// LDPC processing buffer - //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; - ulsch->harq_processes[i]->Z=0; - /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) - //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; - ulsch->harq_processes[i]->E=0; + ulsch->harq_processes[i]->TBS=0; + /// Pointer to the payload (38.212 V15.4.0 section 5.1) + //uint8_t *b; + ulsch->harq_processes[i]->B=0; + /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) + //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->K=0; + ulsch->harq_processes[i]->F=0; + ulsch->harq_processes[i]->C=0; + /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) + //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC processing buffer + //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->Z=0; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + ulsch->harq_processes[i]->E=0; - ulsch->harq_processes[i]->n_DMRS=0; - ulsch->harq_processes[i]->n_DMRS2=0; - ulsch->harq_processes[i]->previous_n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS2=0; + ulsch->harq_processes[i]->previous_n_DMRS=0; - ulsch->harq_processes[i]->cqi_crc_status=0; - for (j=0;jharq_processes[i]->o[j]=0; - ulsch->harq_processes[i]->uci_format=0; - ulsch->harq_processes[i]->Or1=0; - ulsch->harq_processes[i]->Or2=0; - ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; - ulsch->harq_processes[i]->O_RI=0; - ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; - ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; - ulsch->harq_processes[i]->O_ACK=0; - ulsch->harq_processes[i]->V_UL_DAI=0; - /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) - //int8_t q[MAX_CQI_PAYLOAD]; - ulsch->harq_processes[i]->o_RCC=0; - /// coded and interleaved CQI bits - //int8_t o_w[(MAX_CQI_BITS+8)*3]; - /// coded CQI bits - //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; - for (j=0;jharq_processes[i]->q_ACK[j]=0; - for (j=0;jharq_processes[i]->q_RI[j]=0; - /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled - //uint8_t h[MAX_NUM_CHANNEL_BITS]; - /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) - //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; - } - } + ulsch->harq_processes[i]->cqi_crc_status=0; + for (j=0;jharq_processes[i]->o[j]=0; + ulsch->harq_processes[i]->uci_format=0; + ulsch->harq_processes[i]->Or1=0; + ulsch->harq_processes[i]->Or2=0; + ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; + ulsch->harq_processes[i]->O_RI=0; + ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; + ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; + ulsch->harq_processes[i]->O_ACK=0; + ulsch->harq_processes[i]->V_UL_DAI=0; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + //int8_t q[MAX_CQI_PAYLOAD]; + ulsch->harq_processes[i]->o_RCC=0; + /// coded and interleaved CQI bits + //int8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + for (j=0;jharq_processes[i]->q_ACK[j]=0; + for (j=0;jharq_processes[i]->q_RI[j]=0; + /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled + //uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + } + } } } @@ -642,7 +642,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, // harq_process->harq_ack.harq_id = harq_pid; // harq_process->harq_ack.send_harq_status = 1; // harq_process->errors[harq_process->round]++; - harq_process->round++; + //harq_process->round++; if (harq_process->round >= ulsch->Mlimit) { harq_process->status = SCH_IDLE; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 53c6615dbd..e842ca9e4d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -275,7 +275,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } #if UE_TIMING_TRACE - if(symbol > ue->frame_parms.symbols_per_tti>>1) + if(symbol > ue->frame_parms.symbols_per_slot>>1) { slot = 1; } @@ -1064,9 +1064,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, #if T_TRACER T(T_UE_PHY_PDSCH_IQ, T_INT(eNB_id), T_INT(ue->Mod_id), T_INT(frame%1024), T_INT(nr_tti_rx), T_INT(nb_rb), - T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_tti), + T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot), T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0], - 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2)); + 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2)); #endif return(0); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 5c8493c370..c56f22fd20 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -317,6 +317,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, /////////// ///////////////////////////////////////////////////////////////////////////////////// +opp_enabled=0; ///////////////////////// c---->| LDCP coding |---->d ///////////////////////// /////////// diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index ce3cd8d929..f3d9a07fea 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -240,7 +240,6 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////////////////////DMRS Modulation///////////////////////// /////////// - pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; n_dmrs = (harq_process_ul_ue->nb_rb*ulsch_ue->nb_re_dmrs); int16_t mod_dmrs[n_dmrs<<1]; @@ -250,7 +249,6 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, l0 = get_l0_ul(mapping_type, 2); nr_modulation(pusch_dmrs[l0][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - /////////// //////////////////////////////////////////////////////////////////////// @@ -339,7 +337,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_PUSCH_MAPPING - printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", + printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n", dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1], ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]); #endif @@ -370,7 +368,6 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } } } - /////////// //////////////////////////////////////////////////////////////////////// @@ -416,7 +413,6 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, frame_parms); } } - /////////// //////////////////////////////////////////////////// return 0; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index f4ea2292c1..c8b1f44f3f 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -671,7 +671,7 @@ typedef struct PHY_VARS_gNB_s { uint32_t ****nr_gold_pdsch_dmrs; /// PUSCH DMRS - uint32_t nr_gold_pusch[2][20][2][52]; + uint32_t nr_gold_pusch[2][20][2][NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD]; /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index c10144c072..3ac808fac2 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -264,7 +264,7 @@ void nr_fep0(RU_t *ru, int first_half) { end_symbol = NR_SYMBOLS_PER_SLOT; } - LOG_I(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d\n", proc->tti_rx, first_half, start_symbol, end_symbol); + LOG_D(PHY,"In fep0 for slot = %d, first_half = %d, start_symbol = %d, end_symbol = %d\n", proc->tti_rx, first_half, start_symbol, end_symbol); // printf("fep0: slot %d\n",slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+proc->tti_rx, 1); @@ -405,7 +405,7 @@ void nr_fep_full(RU_t *ru, int slot) { // remove_7_5_kHz(ru,proc->tti_rx<<1); // remove_7_5_kHz(ru,1+(proc->tti_rx<<1)); - for (l = 0; l < fp->symbols_per_tti; l++) { + for (l = 0; l < fp->symbols_per_slot; l++) { for (aa = 0; aa < fp->nb_antennas_rx; aa++) { nr_slot_fep_ul(fp, ru->common.rxdata[aa], diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index df8a1c8084..a3fa044f2f 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -286,7 +286,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, uint8_t harq_pid = 0; // [hna] Previously in LTE, the harq_pid was obtained from the subframe number (Synchronous HARQ) // In NR, this should be signaled through uplink scheduling dci (i.e, DCI 0_0, 0_1) (Asynchronous HARQ) - for (UE_id = 0; UE_id < NUMBER_OF_NR_UE_MAX; UE_id++) { + for (UE_id = 0; UE_id < 1; UE_id++) { // temporary set to 1 untill list of connected UEs is implemented for(symbol = symbol_start; symbol < symbol_end; symbol++) { diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 89d89cbae2..cf5183c075 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2483,7 +2483,6 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, start_meas(&ue->phy_proc_tx); #endif - harq_pid = 0; //temporary implementation /* @@ -2498,11 +2497,26 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, ulsch_ue->Nsymb_pusch, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); + LOG_I(PHY, "[phy_procedures_nrUE_TX] mcs = %d, nb_rb = %d \n , Nsymb_pusch = %d, nb_re_dmrs = %d, length_dmrs = %d, precod_nbr_layers = %d, TBS = %d\n", + harq_process_ul_ue->mcs, + harq_process_ul_ue->nb_rb, + ulsch_ue->Nsymb_pusch, + ulsch_ue->nb_re_dmrs, + ulsch_ue->length_dmrs, + harq_process_ul_ue->Nl, + TBS); + + //-----------------------------------------------------// // to be removed later when MAC is ready - for (i = 0; i < TBS / 8; i++) - harq_process_ul_ue->a[i] = (unsigned char) rand(); + if (harq_process_ul_ue != NULL){ + for (i = 0; i < TBS / 8; i++) + harq_process_ul_ue->a[i] = (unsigned char) rand(); + } else { + LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); + return; + } //-----------------------------------------------------// @@ -2529,6 +2543,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, &ue->frame_parms); + /* if ((ue->UE_mode[eNB_id] == PRACH) && (ue->frame_parms.prach_config_common.prach_Config_enabled==1)) { @@ -3405,7 +3420,7 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB first_symbol_flag = 0; #if UE_TIMING_TRACE uint8_t slot = 0; - if(m >= ue->frame_parms.symbols_per_tti>>1) + if(m >= ue->frame_parms.symbols_per_slot>>1) slot = 1; start_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[nr_tti_rx]][slot]); #endif @@ -3898,7 +3913,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { 0); */ // 1- perform FFT - for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + for (int l=1; lframe_parms.symbols_per_slot>>1; l++) { //if( (l != pilot0) && (l != pilot1)) { @@ -3930,7 +3945,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { } // 2- perform Channel Estimation for slot1 - for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + for (int l=1; lframe_parms.symbols_per_slot>>1; l++) { if(l == pilot1) { @@ -4018,8 +4033,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { PDSCH, ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); @@ -4033,8 +4048,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { SI_PDSCH, ue->dlsch_SI[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } @@ -4046,8 +4061,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { P_PDSCH, ue->dlsch_p[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } // do procedures for RA-RNTI @@ -4058,8 +4073,8 @@ void *UE_thread_slot1_dl_processing(void *arg) { RA_PDSCH, ue->dlsch_ra[eNB_id], NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, + (ue->frame_parms.symbols_per_slot>>1), + ue->frame_parms.symbols_per_slot-1, abstraction_flag); } @@ -4228,7 +4243,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, //set active for testing, to be removed ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 1; } - else + else ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active = 0; #if UE_TIMING_TRACE diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 3f642cac4b..96a7ba3205 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -91,6 +91,8 @@ typedef struct { uint32_t slot; /// ssb_index, if ssb is not present in current TTI, thie value set to -1 int ssb_index; + /// dci reception indication structure + fapi_nr_dci_indication_t *dci_ind; } nr_uplink_indication_t; // Downlink subframe P7 From bd392619806707de23d0b8e99b54f298f10eca8a Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Mon, 8 Jul 2019 14:59:57 +0200 Subject: [PATCH 11/32] fixing a memory leak in nr_ue_ulsch_procedures --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index f3d9a07fea..5957324659 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -161,7 +161,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned int available_bits; uint8_t mod_order, cwd_index, num_of_codewords; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; - int32_t *mod_symbols[MAX_NUM_NR_RE]; + int32_t *mod_symbols[NR_MAX_NB_CODEWORDS]; uint32_t ***pusch_dmrs; int16_t **tx_layers; int32_t **txdataF; @@ -371,6 +371,12 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////// //////////////////////////////////////////////////////////////////////// + for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { + + free(mod_symbols[cwd_index]); + + } + return 0; } From dd26598ab2db4e1e077cae881bb37584bcd3159f Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Mon, 8 Jul 2019 15:43:03 +0200 Subject: [PATCH 12/32] handle tx_offset with negative value --- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 5957324659..e7e02520d6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -401,6 +401,10 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, #endif tx_offset = slot*frame_parms->samples_per_slot - timing_advance; + + if (tx_offset < 0) + tx_offset += frame_parms->samples_per_frame; + txdata = UE->common_vars.txdata; txdataF = UE->common_vars.txdataF; From c7951965e76b7769bd49e64691e0a611451460f7 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Thu, 25 Jul 2019 15:22:47 +0200 Subject: [PATCH 13/32] TDD in rfsimulator --- executables/nr-gnb.c | 4 +++- executables/nr-ru.c | 7 ++++++- executables/nr-ue.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 8d64e10705..0a3bef3355 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -191,7 +191,9 @@ static inline int rxtx(PHY_VARS_gNB *gNB,int frame_rx, int slot_rx, int frame_tx } // UE-specific RX processing for subframe n - if (nfapi_mode == 0 || nfapi_mode == 1) */ { + if (nfapi_mode == 0 || nfapi_mode == 1) */ + + if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) { nfapi_nr_ul_config_ulsch_pdu_rel15_t *ulsch_pdu_rel15 = &gNB->ulsch[1][0]->harq_processes[0]->ulsch_pdu.ulsch_pdu_rel15; phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx, ulsch_pdu_rel15->start_symbol, ulsch_pdu_rel15->start_symbol + ulsch_pdu_rel15->number_symbols); } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index ca63123c73..368957a01f 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1474,7 +1474,12 @@ static void *ru_thread( void *param ) { if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; // do RX front-end processing (frequency-shift, dft) if needed - if (ru->feprx) ru->feprx(ru,proc->tti_rx); + + if (proc->tti_rx == NR_UPLINK_SLOT || fp->frame_type == FDD) { + + if (ru->feprx) ru->feprx(ru,proc->tti_rx); + + } LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx); LOG_D(PHY,"Copying rxdataF from RU to gNB\n"); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 4770f2dc15..29e9bb3c23 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -432,12 +432,13 @@ void UE_processing(void *arg) { (UE->frame_parms.frame_type == FDD) ) #endif */ - //if (proc->nr_tti_tx == NR_UPLINK_SLOT){ + + if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ if (UE->mode != loop_through_memory) phy_procedures_nrUE_TX(UE,proc,0,0); - //} + } //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); From dd0927dd55ed55fc7533e43970c42e7f281a6b02 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Fri, 2 Aug 2019 17:51:13 +0200 Subject: [PATCH 14/32] TDD fixes in real-time environment --- executables/nr-ru.c | 5 +- openair1/PHY/INIT/nr_init.c | 14 +- openair1/PHY/INIT/nr_parms.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_common.c | 6 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c | 38 ++- .../gnb.band78.tm1.106PRB.adrv9371zc706.conf | 288 ++++++++++++++++++ 7 files changed, 331 insertions(+), 26 deletions(-) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 368957a01f..1d6fe2c7c0 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -734,8 +734,6 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); int sf_extension = 0; - if ((SF_type == SF_DL) || - (SF_type == SF_S)) { int siglen=fp->samples_per_slot,flags=1; /* if (SF_type == SF_S) { @@ -776,7 +774,6 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); - } } @@ -1388,9 +1385,9 @@ static void *ru_thread( void *param ) { } if (ru->if_south == LOCAL_RF) { // configure RF parameters only - fill_rf_config(ru,ru->rf_config_file); nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); nr_dump_frame_parms(fp); + fill_rf_config(ru,ru->rf_config_file); nr_phy_init_RU(ru); ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); AssertFatal(ret==0,"Cannot connect to local radio\n"); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index ebdee91d11..6b04da3e15 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -19,6 +19,7 @@ * contact@openairinterface.org */ +#include "executables/nr-softmodem-common.h" #include "PHY/defs_gNB.h" #include "PHY/phy_extern.h" #include "PHY/NR_REFSIG/nr_refsig.h" @@ -31,6 +32,7 @@ #include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" #include "LAYER2/MAC/mac_extern.h" +#include "LAYER2/MAC/mac_proto.h" #include "assertions.h" #include @@ -428,23 +430,25 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) gNB_config->sch_config.ssb_periodicity.value = phy_config->cfg->sch_config.ssb_periodicity.value; if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { - gNB_config->subframe_config.duplex_mode.value = TDD; - } else { gNB_config->subframe_config.duplex_mode.value = FDD; + } else { + gNB_config->subframe_config.duplex_mode.value = TDD; } RC.gNB[Mod_id][CC_id]->mac_enabled = 1; fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); - fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_nr_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); + get_band(fp->dl_CarrierFreq, &gNB_config->nfapi_config.rf_bands.rf_band[0], &uplink_frequency_offset[CC_id][0], &fp->frame_type); + fp->ul_CarrierFreq = fp->dl_CarrierFreq + uplink_frequency_offset[CC_id][0]; fp->threequarter_fs = openair0_cfg[0].threequarter_fs; - LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u)\n", + LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u, UL freq %u)\n", Mod_id, CC_id, gNB_config->nfapi_config.rf_bands.rf_band[0], gNB_config->rf_config.dl_carrier_bandwidth.value, gNB_config->rf_config.ul_carrier_bandwidth.value, gNB_config->sch_config.physical_cell_id.value, - fp->dl_CarrierFreq ); + fp->dl_CarrierFreq, + fp->ul_CarrierFreq); nr_init_frame_parms(gNB_config, fp); diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index ad29a95ef4..7ca794c5c2 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -256,7 +256,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, { fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0]; - fp->frame_type = !(config->subframe_config.duplex_mode.value); + fp->frame_type = config->subframe_config.duplex_mode.value; fp->L_ssb = config->sch_config.ssb_scg_position_in_burst.value; return nr_init_frame_parms0(fp, config->subframe_config.numerology_index_mu.value, @@ -288,6 +288,8 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) LOG_I(PHY,"fp->samples_per_frame_wCP=%d\n",fp->samples_per_frame_wCP); LOG_I(PHY,"fp->samples_per_subframe=%d\n",fp->samples_per_subframe); LOG_I(PHY,"fp->samples_per_frame=%d\n",fp->samples_per_frame); + LOG_I(PHY,"fp->dl_CarrierFreq=%u\n",fp->dl_CarrierFreq); + LOG_I(PHY,"fp->ul_CarrierFreq=%u\n",fp->ul_CarrierFreq); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 0cb9f56ae4..bce905b4df 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -348,7 +348,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, // G = 0; // G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers); - LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); + LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); if (harq_process->round == 0) { diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index dd859852fd..c19866fc92 100755 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -35,8 +35,10 @@ nr_subframe_t nr_slot_select(nfapi_nr_config_request_t *cfg, unsigned char slot) { - if (cfg->subframe_config.duplex_mode.value == FDD) + if (cfg->subframe_config.duplex_mode.value == FDD || slot == NR_DOWNLINK_SLOT) return(SF_DL); - LOG_E(PHY,"Not developped TDD mode\n"); + else if (slot == NR_UPLINK_SLOT) + return (SF_UL); + return -1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c index 0422331fb4..7e821e6f30 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_common.c @@ -75,30 +75,42 @@ void get_band(uint32_t downlink_frequency, lte_frame_type_t *current_type) { int ind; - int64_t dl_freq_khz = downlink_frequency/1000; + uint64_t center_frequency_khz; + uint64_t center_freq_diff_khz; + uint64_t dl_freq_khz = downlink_frequency/1000; + + center_freq_diff_khz = 999999999999999999; // 2^64 + *current_band = 0; + for ( ind=0; ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); ind++) { - *current_band = nr_bandtable[ind].band; - LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); + LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", nr_bandtable[ind].band, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) { - *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; - if (*current_offset == 0) - *current_type = TDD; - else - *current_type = FDD; - LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", - downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); - break; + center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2; + + if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){ + + *current_band = nr_bandtable[ind].band; + *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000; + center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz); + + if (*current_offset == 0) + *current_type = TDD; + else + *current_type = FDD; + } } } - AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])), - "Can't find EUTRA band for frequency %d\n", downlink_frequency); + LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n", + downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset); + AssertFatal(*current_band != 0, + "Can't find EUTRA band for frequency %u\n", downlink_frequency); } uint32_t to_nrarfcn(int nr_bandP, diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf new file mode 100644 index 0000000000..5610694d7d --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf @@ -0,0 +1,288 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_gNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + DL_prefix_type = "NORMAL"; + UL_prefix_type = "NORMAL"; + eutra_band = 78; + downlink_frequency = 3510000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 106; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + MIB_subCarrierSpacingCommon = 30; + MIB_ssb_SubcarrierOffset = 0; + MIB_dmrs_TypeA_Position = 2; + pdcch_ConfigSIB1 = 0; + SIB1_frequencyOffsetSSB = "khz5"; + SIB1_ssb_PeriodicityServingCell = 5; + SIB1_ss_PBCH_BlockPower = -60; + absoluteFrequencySSB = 0; + DL_FreqBandIndicatorNR = 15; + DL_absoluteFrequencyPointA = 15; + DL_offsetToCarrier = 15; + DL_SCS_SubcarrierSpacing = "kHz30"; + DL_SCS_SpecificCarrier_k0 = 0; + DL_carrierBandwidth = 15; + DL_locationAndBandwidth = 15; + DL_BWP_SubcarrierSpacing = "kHz30"; + DL_BWP_prefix_type = "NORMAL"; + UL_FreqBandIndicatorNR = 15; + UL_absoluteFrequencyPointA = 13; + UL_additionalSpectrumEmission = 3; + UL_p_Max = -1; + UL_frequencyShift7p5khz = "TRUE"; + UL_offsetToCarrier = 10; + UL_SCS_SubcarrierSpacing = "kHz30"; + UL_SCS_SpecificCarrier_k0 = 0; + UL_carrierBandwidth = 15; + UL_locationAndBandwidth = 15; + UL_BWP_SubcarrierSpacing = "kHz30"; + UL_BWP_prefix_type = "NORMAL"; + UL_timeAlignmentTimerCommon = "infinity"; + ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_dmrs_TypeA_Position = 2; + NIA_SubcarrierSpacing = "kHz15"; + ServingCellConfigCommon_ss_PBCH_BlockPower = -60; + referenceSubcarrierSpacing = "kHz15"; + dl_UL_TransmissionPeriodicity = "ms0p5"; + nrofDownlinkSlots = 10; + nrofDownlinkSymbols = 10; + nrofUplinkSlots = 10; + nrofUplinkSymbols = 10; + rach_totalNumberOfRA_Preambles = 63; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth"; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2; + rach_groupBconfigured = "ENABLE"; + rach_ra_Msg3SizeGroupA = 56; + rach_messagePowerOffsetGroupB = "dB0"; + rach_numberOfRA_PreamblesGroupA = 32; + rach_ra_ContentionResolutionTimer = 8; + rsrp_ThresholdSSB = 64; + rsrp_ThresholdSSB_SUL = 64; + prach_RootSequenceIndex_choice = "l839"; + prach_RootSequenceIndex_l839 = 0; + prach_RootSequenceIndex_l139 = 0; + prach_msg1_SubcarrierSpacing = "kHz30"; + restrictedSetConfig = "unrestrictedSet"; + msg3_transformPrecoding = "ENABLE"; + prach_ConfigurationIndex = 10; + prach_msg1_FDM = "one"; + prach_msg1_FrequencyStart = 10; + zeroCorrelationZoneConfig = 10; + preambleReceivedTargetPower = -150; + preambleTransMax = 6; + powerRampingStep = "dB0"; + ra_ResponseWindow = 8; + groupHoppingEnabledTransformPrecoding = "ENABLE"; + msg3_DeltaPreamble = 0; + p0_NominalWithGrant = 0; + PUSCH_TimeDomainResourceAllocation_k2 = 0; + PUSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + pucch_ResourceCommon = 0; + pucch_GroupHopping = "neither"; + hoppingId = 0; + p0_nominal = -30; + PDSCH_TimeDomainResourceAllocation_k0 = 2; + PDSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + rateMatchPatternId = 0; + RateMatchPattern_patternType = "bitmaps"; + symbolsInResourceBlock = "oneSlot"; + periodicityAndPattern = 2; + RateMatchPattern_controlResourceSet = 5; + RateMatchPattern_subcarrierSpacing = "kHz30"; + RateMatchPattern_mode = "dynamic"; + controlResourceSetZero = 0; + searchSpaceZero = 0; + searchSpaceSIB1 = 10; + searchSpaceOtherSystemInformation = 10; + pagingSearchSpace = 10; + ra_SearchSpace = 10; + PDCCH_common_controlResourceSetId = 5; + PDCCH_common_ControlResourceSet_duration = 2; + PDCCH_cce_REG_MappingType = "nonInterleaved"; + PDCCH_reg_BundleSize = 3; + PDCCH_interleaverSize = 3; + PDCCH_shiftIndex = 10; + PDCCH_precoderGranularity = "sameAsREG-bundle"; + PDCCH_TCI_StateId = 32; + tci_PresentInDCI = "ENABLE"; + PDCCH_DMRS_ScramblingID = 0; + SearchSpaceId = 10; + commonSearchSpaces_controlResourceSetId = 5; + SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1"; + SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0; + SearchSpace_duration = 2; + SearchSpace_nrofCandidates_aggregationLevel1 = 0; + SearchSpace_nrofCandidates_aggregationLevel2 = 0; + SearchSpace_nrofCandidates_aggregationLevel4 = 0; + SearchSpace_nrofCandidates_aggregationLevel8 = 0; + SearchSpace_nrofCandidates_aggregationLevel16 = 0; + SearchSpace_searchSpaceType = "common"; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1; + Common_dci_Format2_3_monitoringPeriodicity = 1; + Common_dci_Format2_3_nrofPDCCH_Candidates = 1; + ue_Specific__dci_Formats = "formats0-0-And-1-0"; + RateMatchPatternLTE_CRS_carrierFreqDL = 6; + RateMatchPatternLTE_CRS_carrierBandwidthDL = 6; + RateMatchPatternLTE_CRS_nrofCRS_Ports = 1; + RateMatchPatternLTE_CRS_v_Shift = 0; + RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1; + RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; + RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame"; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8"; + + } +); + +NETWORK_CONTROLLER : +{ + FLEXRAN_ENABLED = "no"; + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; From 8df7d62e52de81501744b30746fc22271704a874 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 9 Aug 2019 15:16:18 +0200 Subject: [PATCH 15/32] fix compilation of phy simulators introduced from the usage of get_band() --- openair1/PHY/INIT/nr_init.c | 3 +-- openair1/SIMULATION/NR_PHY/dlschsim.c | 2 ++ openair1/SIMULATION/NR_PHY/dlsim.c | 2 ++ openair1/SIMULATION/NR_PHY/pbchsim.c | 2 ++ openair1/SIMULATION/NR_PHY/pucchsim.c | 2 ++ openair1/SIMULATION/NR_PHY/ulschsim.c | 18 ++++++++++++------ openair1/SIMULATION/NR_PHY/ulsim.c | 2 ++ .../NR_UE_PHY/unit_tests/src/dummy_functions.c | 2 +- 8 files changed, 24 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 6b04da3e15..e0f73c2b61 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -31,8 +31,7 @@ #include "TDD-Config.h" #include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" -#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "assertions.h" #include diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 2a6d6d04ad..272227f1cd 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -53,6 +53,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index aca129623e..11302083d9 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -60,6 +60,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode=0; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 22abbbcbc2..4b8aefc789 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -52,6 +52,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode=0; diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 9e03a06a82..ed0bee9227 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -50,6 +50,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; openair0_config_t openair0_cfg[MAX_CARDS]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode=0; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index b3f769fef0..2acf6ca903 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -52,6 +52,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; @@ -64,7 +66,7 @@ int main(int argc, char **argv) { char c; int i,sf; - double SNR, snr0 = -2.0, snr1 = 2.0; //, SNR_lin; + double SNR, snr0 = -2.0, snr1 = 2.0, SNR_lin; double snr_step = 0.1; uint8_t snr1set = 0; FILE *output_fd = NULL; @@ -83,7 +85,7 @@ int main(int argc, char **argv) //unsigned char pbch_phase = 0; int frame = 0, subframe = 0; NR_DL_FRAME_PARMS *frame_parms; - //double sigma; + double sigma; unsigned char qbits = 8; int ret; int loglvl = OAILOG_WARNING; @@ -491,11 +493,15 @@ int main(int argc, char **argv) //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); - //SNR_lin = pow(10, SNR / 10.0); - //sigma = 1.0 / sqrt(2 * SNR_lin); +#if 1 + SNR_lin = pow(10, SNR / 10.0); + sigma = 1.0 / sqrt(2 * SNR_lin); + channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, + modulated_input[i] + sigma * gaussdouble(0.0, 1.0), + qbits); +#else channel_output_fixed[i] = (short) quantize(0.01, modulated_input[i], qbits); - //channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, modulated_input[i] + sigma * gaussdouble(0.0, 1.0), qbits); - //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); +#endif //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); //Uncoded BER diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 1281675599..bb74368dfe 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -60,6 +60,8 @@ PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + double cpuf; int nfapi_mode = 0; diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c index fa243d1eb0..a93f0d48f3 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/dummy_functions.c @@ -119,7 +119,7 @@ void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync){} -uint32_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) { return(0);} +uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn) { return(0);} int32_t get_uldl_offset(int nr_bandP) { return(0);} From b10cc483514c8a081fbd8c1c5544c98c3086bca4 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 14 Aug 2019 15:05:15 +0200 Subject: [PATCH 16/32] Fix ulsim and PUSCH in rf-simulator - initialize PUSCH parameters properly --- executables/nr-ue.c | 38 +++++++++++++++++++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 30 ++++++++++++++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 1 + 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 29e9bb3c23..71c36bb74e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -355,6 +355,9 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; + uint32_t nb_rb, start_rb; + uint8_t nb_symb_sch, start_symbol, mcs, precod_nbr_layers, harq_pid, rvidx; + uint16_t n_rnti; // Process Rx data for one sub-frame if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { @@ -367,12 +370,38 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_ue_dcireq(&dcireq); //to be replaced with function pointer later scheduled_response.dl_config = &dcireq.dl_config_req; - scheduled_response.ul_config = NULL; + scheduled_response.ul_config = &dcireq.ul_config_req; scheduled_response.tx_request = NULL; scheduled_response.module_id = UE->Mod_id; scheduled_response.CC_id = 0; scheduled_response.frame = proc->frame_rx; scheduled_response.slot = proc->nr_tti_rx; + + //--------------------------Temporary configuration-----------------------------// + n_rnti = 0x1234; + nb_rb = 50; + start_rb = 30; + nb_symb_sch = 12; + start_symbol = 2; + precod_nbr_layers = 1; + mcs = 9; + harq_pid = 0; + rvidx = 0; + //------------------------------------------------------------------------------// + + scheduled_response.ul_config->sfn_slot = NR_UPLINK_SLOT; + scheduled_response.ul_config->number_pdus = 1; + scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = mcs; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = rvidx; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; + scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; nr_ue_scheduled_response(&scheduled_response); #ifdef UE_SLOT_PARALLELISATION @@ -417,6 +446,7 @@ typedef struct processingData_s { } processingData_t; void UE_processing(void *arg) { + uint8_t thread_id; processingData_t *rxtxD=(processingData_t *) arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; @@ -433,10 +463,14 @@ void UE_processing(void *arg) { #endif */ + if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ + thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx]; + + if (UE->mode != loop_through_memory) - phy_procedures_nrUE_TX(UE,proc,0,0); + phy_procedures_nrUE_TX(UE,proc,0,thread_id); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index e7e02520d6..25f415601e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -168,10 +168,12 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint16_t start_sc, start_rb; int8_t Wf[2], Wt[2], l0, l_prime[2], delta; uint16_t n_dmrs; - uint8_t dmrs_type; + uint8_t dmrs_type, length_dmrs; uint8_t mapping_type; - int ap, start_symbol, i; - int sample_offsetF; + int ap, start_symbol, Nid_cell, i; + int sample_offsetF, N_RE_prime, N_PRB_oh; + uint16_t n_rnti; + uint32_t TBS; NR_UE_ULSCH_t *ulsch_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue; @@ -179,12 +181,34 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][eNB_id]; num_of_codewords = 1; // tmp assumption + length_dmrs = 1; + n_rnti = 0x1234; + Nid_cell = 0; + N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig + + for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { ulsch_ue = UE->ulsch[thread_id][eNB_id][cwd_index]; harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; + ulsch_ue->length_dmrs = length_dmrs; + ulsch_ue->rnti = n_rnti; + ulsch_ue->Nid_cell = Nid_cell; + ulsch_ue->Nsc_pusch = harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; + ulsch_ue->Nsymb_pusch = harq_process_ul_ue->number_of_symbols; + ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; + + N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh; + + harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords; + + TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, ulsch_ue->Nsymb_pusch, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); + + harq_process_ul_ue->TBS = TBS; + + /////////////////////////ULSCH coding///////////////////////// /////////// diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 96a7ba3205..5873c84d8f 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -52,6 +52,7 @@ typedef struct { int slot; fapi_nr_dl_config_request_t dl_config_req; + fapi_nr_ul_config_request_t ul_config_req; } nr_dcireq_t; typedef struct { From b7733bae40aa361b285832f8ea024dd7b39ff07f Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Wed, 14 Aug 2019 16:02:29 +0200 Subject: [PATCH 17/32] Minor fixes - removing "Nsymb_pusch" and "Nsc_pusch" from "NR_UE_ULSCH_t" - using "number_of_symbols" from "NR_UL_UE_HARQ_t" instead - removing "generate_ue_ulsch_params" --- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 12 --- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 4 - openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 79 ++----------------- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 4 +- 4 files changed, 7 insertions(+), 92 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 155e08d477..d69b299ee1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1055,18 +1055,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, NR_DL_FRAME_PARMS* frame_parms, uint8_t harq_pid); -/*! \brief Fill up NR_UE_ULSCH_t and NR_UL_UE_HARQ_t structs - @param[in] UE, Pointer to PHY_VARS_NR_UE struct - @param[in] thread_id, thread id - @param[in] gNB_id, gNB id - @param[in] harq_pid, harq id -*/ - -int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE, - uint8_t thread_id, - int gNB_id, - unsigned char harq_pid); - /*! \brief Perform PUSCH scrambling. TS 38.211 V15.4.0 subclause 6.3.1.1 @param[in] in, Pointer to input bits @param[in] size, of input bits diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 86b551435e..376c8b90db 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -159,10 +159,6 @@ typedef struct { } NR_UL_UE_HARQ_t; typedef struct { - /// Current Number of Symbols - uint8_t Nsymb_pusch; - /// Nsc_pusch, number of allocated subcarriers for ULSCH - uint16_t Nsc_pusch; /// number of DMRS resource elements uint8_t nb_re_dmrs; /// DMRS length diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 25f415601e..5dc4fbe0c5 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -46,73 +46,6 @@ //#define DEBUG_PUSCH_MAPPING -int generate_ue_ulsch_params(PHY_VARS_NR_UE *UE, - uint8_t thread_id, - int gNB_id, - unsigned char harq_pid){ - - int N_PRB_oh, N_RE_prime, cwd_idx, length_dmrs, Nid_cell; - int nb_rb, Nsymb_pusch, first_rb, nb_codewords,mcs,rvidx; - uint16_t n_rnti; - - NR_UE_ULSCH_t *ulsch_ue; - NR_UL_UE_HARQ_t *harq_process_ul_ue; - - LOG_W(PHY,"This function should not be used. Use FAPI interfaces instead\n"); - - //--------------------------Temporary configuration-----------------------------// - length_dmrs = 1; - n_rnti = 0x1234; - Nid_cell = 0; - nb_rb = 50; - first_rb = 30; - Nsymb_pusch = 12; - nb_codewords = 1; - mcs = 9; - rvidx = 0; - //------------------------------------------------------------------------------// - - for (cwd_idx = 0; cwd_idx < nb_codewords; cwd_idx++) { - - ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_idx]; - harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - - ulsch_ue->length_dmrs = length_dmrs; - ulsch_ue->rnti = n_rnti; - ulsch_ue->Nid_cell = Nid_cell; - ulsch_ue->Nsc_pusch = nb_rb*NR_NB_SC_PER_RB; - ulsch_ue->Nsymb_pusch = Nsymb_pusch; - ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; - - - N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig - N_RE_prime = NR_NB_SC_PER_RB*Nsymb_pusch - ulsch_ue->nb_re_dmrs - N_PRB_oh; - - if (harq_process_ul_ue) { - - harq_process_ul_ue->mcs = mcs; - harq_process_ul_ue->Nl = nb_codewords; - harq_process_ul_ue->nb_rb = nb_rb; - harq_process_ul_ue->first_rb = first_rb; - harq_process_ul_ue->number_of_symbols = Nsymb_pusch; - harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb*nb_codewords; - harq_process_ul_ue->rvidx = rvidx; - harq_process_ul_ue->TBS = nr_compute_tbs(harq_process_ul_ue->mcs, - nb_rb, - Nsymb_pusch, - ulsch_ue->nb_re_dmrs, - length_dmrs, - harq_process_ul_ue->Nl); - - } - - } - - return 0; -} - - - void nr_pusch_codeword_scrambling(uint8_t *in, uint16_t size, uint32_t Nid, @@ -196,15 +129,13 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ulsch_ue->length_dmrs = length_dmrs; ulsch_ue->rnti = n_rnti; ulsch_ue->Nid_cell = Nid_cell; - ulsch_ue->Nsc_pusch = harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; - ulsch_ue->Nsymb_pusch = harq_process_ul_ue->number_of_symbols; ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords; - TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, ulsch_ue->Nsymb_pusch, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); + TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); harq_process_ul_ue->TBS = TBS; @@ -223,7 +154,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, mod_order = nr_get_Qm(harq_process_ul_ue->mcs, 1); available_bits = nr_get_G(harq_process_ul_ue->nb_rb, - ulsch_ue->Nsymb_pusch, + harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, mod_order, @@ -260,7 +191,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } - start_symbol = 14 - ulsch_ue->Nsymb_pusch; + start_symbol = 14 - harq_process_ul_ue->number_of_symbols; /////////////////////////DMRS Modulation///////////////////////// /////////// @@ -303,7 +234,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint32_t nb_re_pusch, nb_re_dmrs_per_rb; uint32_t y_offset = 0; - for (l = start_symbol; l < start_symbol + ulsch_ue->Nsymb_pusch; l++) { + for (l = start_symbol; l < start_symbol + harq_process_ul_ue->number_of_symbols; l++) { if(l == dmrs_symbol) nb_re_dmrs_per_rb = ulsch_ue->nb_re_dmrs; // [hna] ulsch_ue->nb_re_dmrs = 6 in this configuration @@ -347,7 +278,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t k_prime=0; uint16_t m=0, n=0, dmrs_idx=0, k=0; - for (l=start_symbol; lNsymb_pusch; l++) { + for (l=start_symbol; lnumber_of_symbols; l++) { k = start_sc; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index cf5183c075..fdf46681cb 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2495,12 +2495,12 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, ulsch_ue = ue->ulsch[thread_id][gNB_id][0]; // cwd_index = 0 harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, ulsch_ue->Nsymb_pusch, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); + TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); LOG_I(PHY, "[phy_procedures_nrUE_TX] mcs = %d, nb_rb = %d \n , Nsymb_pusch = %d, nb_re_dmrs = %d, length_dmrs = %d, precod_nbr_layers = %d, TBS = %d\n", harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, - ulsch_ue->Nsymb_pusch, + harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl, From ef41f62f9fdf660e90939987e2f6bce5dbfd281e Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Wed, 14 Aug 2019 17:02:11 +0200 Subject: [PATCH 18/32] optimizing nr_ue_ulsch_procedures --- openair1/PHY/MODULATION/nr_modulation.c | 97 ++++++++++++++++++++++ openair1/PHY/MODULATION/nr_modulation.h | 13 +++ openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 17 +--- 3 files changed, 113 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c index 40099f4739..3643264c87 100644 --- a/openair1/PHY/MODULATION/nr_modulation.c +++ b/openair1/PHY/MODULATION/nr_modulation.c @@ -120,6 +120,103 @@ void nr_layer_mapping(int16_t **mod_symbs, } } +void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, + uint8_t n_layers, + uint16_t n_symbs, + int16_t **tx_layers) { + + int16_t *mod_symbs; + + switch (n_layers) { + + case 1: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + for (int i=0; i>15; + tx_layers[0][(i<<1)+1] = (mod_symbs[(i<<1)+1]*AMP)>>15; + } + break; + + case 2: + case 3: + case 4: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((n_layers*i+l)<<1)+1]*AMP)>>15; + } + } + break; + + case 5: + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>1; i++) + for (int l=0; l<2; l++) { + tx_layers[l][i<<1] = (mod_symbs[((i<<1)+l)<<1]*AMP)>>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<1)+l)<<1)+1]*AMP)>>15; + } + + mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + break; + + case 6: + for (int q=0; q<2; q++){ + + mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + } + break; + + case 7: + mod_symbs = (int16_t *)ulsch_ue[1]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[((3*i+l)<<1)+1]*AMP)>>15; + } + + mod_symbs = (int16_t *)ulsch_ue[0]->d_mod; + + for (int i=0; i>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; + } + break; + + case 8: + for (int q=0; q<2; q++){ + + mod_symbs = (int16_t *)ulsch_ue[q]->d_mod; + + for (int i=0; i>2; i++) + for (int l=0; l<3; l++) { + tx_layers[l][i<<1] = (mod_symbs[((i<<2)+l)<<1]*AMP)>>15; + tx_layers[l][(i<<1)+1] = (mod_symbs[(((i<<2)+l)<<1)+1]*AMP)>>15; + } + } + break; + + default: + AssertFatal(0, "Invalid number of layers %d\n", n_layers); + } +} + void nr_dft(int32_t *z, int32_t *d, uint32_t Msc_PUSCH) { diff --git a/openair1/PHY/MODULATION/nr_modulation.h b/openair1/PHY/MODULATION/nr_modulation.h index 249a92e8e3..3b37d8e769 100644 --- a/openair1/PHY/MODULATION/nr_modulation.h +++ b/openair1/PHY/MODULATION/nr_modulation.h @@ -25,6 +25,7 @@ #include #include "PHY/defs_nr_common.h" #include "PHY/defs_gNB.h" +#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #define DMRS_MOD_ORDER 2 @@ -52,6 +53,18 @@ void nr_layer_mapping(int16_t **mod_symbs, uint16_t n_symbs, int16_t **tx_layers); +/*! \brief Perform NR layer mapping. TS 38.211 V15.4.0 subclause 7.3.1.3 + @param[in] ulsch_ue, double Pointer to NR_UE_ULSCH_t struct + @param[in] n_layers, number of layers + @param[in] n_symbs, number of modulated symbols + @param[out] tx_layers, modulated symbols for each layer +*/ + +void nr_ue_layer_mapping(NR_UE_ULSCH_t **ulsch_ue, + uint8_t n_layers, + uint16_t n_symbs, + int16_t **tx_layers); + /*! \brief This function implements the OFDM front end processor on reception (FEP) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 5dc4fbe0c5..2db023a2d2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -94,7 +94,6 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned int available_bits; uint8_t mod_order, cwd_index, num_of_codewords; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; - int32_t *mod_symbols[NR_MAX_NB_CODEWORDS]; uint32_t ***pusch_dmrs; int16_t **tx_layers; int32_t **txdataF; @@ -180,14 +179,12 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, mod_order, (int16_t *)ulsch_ue->d_mod); + // pusch_transform_precoding(ulsch_ue, frame_parms, harq_pid); /////////// //////////////////////////////////////////////////////////////////////// - mod_symbols[cwd_index] = (int32_t *)malloc16((NR_MAX_PUSCH_ENCODED_LENGTH)*sizeof(int32_t*)); - - memcpy(mod_symbols[cwd_index],ulsch_ue->d_mod,(available_bits/mod_order)*sizeof(int32_t)); } @@ -212,13 +209,10 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, tx_layers = (int16_t **)pusch_ue->txdataF_layers; - nr_layer_mapping((int16_t **)mod_symbols, + nr_ue_layer_mapping(UE->ulsch[thread_id][eNB_id], harq_process_ul_ue->Nl, available_bits/mod_order, tx_layers); - - for (uint32_t i = 0; i < 2*available_bits/mod_order; i++) - tx_layers[0][i] = (tx_layers[0][i] * AMP) >> 15; /////////// //////////////////////////////////////////////////////////////////////// @@ -323,15 +317,10 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } } } + /////////// //////////////////////////////////////////////////////////////////////// - for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { - - free(mod_symbols[cwd_index]); - - } - return 0; } From cd5a321895f8718e1e495ecdc521bc5111f4f506 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Thu, 15 Aug 2019 12:01:34 +0200 Subject: [PATCH 19/32] Fixing TDD mode using USRP x300 --- executables/nr-ru.c | 11 +++++++---- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 1d6fe2c7c0..3b79ded517 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -2103,6 +2103,7 @@ void init_NR_RU(char *rf_config_file) { int ru_id; RU_t *ru; + PHY_VARS_gNB *gNB_RC; PHY_VARS_gNB *gNB0= (PHY_VARS_gNB *)NULL; NR_DL_FRAME_PARMS *fp = (NR_DL_FRAME_PARMS *)NULL; int i; @@ -2146,6 +2147,7 @@ void init_NR_RU(char *rf_config_file) } } + gNB_RC = RC.gNB[0][0]; gNB0 = ru->gNB_list[0]; fp = ru->nr_frame_parms; LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); @@ -2154,10 +2156,11 @@ void init_NR_RU(char *rf_config_file) if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5)) AssertFatal(gNB0!=NULL,"gNB0 is null!\n"); - if (gNB0) { - LOG_I(PHY,"Copying frame parms from gNB %d to ru %d\n",gNB0->Mod_id,ru->idx); - memcpy((void *)fp,(void *)&gNB0->frame_parms,sizeof(NR_DL_FRAME_PARMS)); - memset((void *)ru->nr_frame_parms, 0, sizeof(NR_DL_FRAME_PARMS)); + if (gNB0 && gNB_RC) { + LOG_I(PHY,"Copying frame parms from gNB in RC to gNB %d in ru %d and frame_parms in ru\n",gNB0->Mod_id,ru->idx); + memset((void *)fp, 0, sizeof(NR_DL_FRAME_PARMS)); + memcpy((void *)fp,&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS)); + memcpy((void *)&gNB0->frame_parms,(void *)&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS)); // attach all RU to all gNBs in its list/ LOG_D(PHY,"ru->num_gNB:%d gNB0->num_RU:%d\n", ru->num_gNB, gNB0->num_RU); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 26f6eddf52..a11bf9d515 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -31,7 +31,7 @@ gNBs = UL_prefix_type = "NORMAL"; eutra_band = 78; downlink_frequency = 3510000000L; - uplink_frequency_offset = -120000000; + uplink_frequency_offset = 0; Nid_cell = 0; N_RB_DL = 106; nb_antenna_ports = 1; From f6470ccc9589fbd08485cbfd3938b195ccc67c2e Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Thu, 15 Aug 2019 12:18:52 +0200 Subject: [PATCH 20/32] Add macro to print CRC OK at gNB PUSCH --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index bce905b4df..e43b57321d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -50,6 +50,7 @@ //#define DEBUG_ULSCH_DECODING #define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 +#define PRINT_CRC_CHECK static uint64_t nb_total_decod =0; static uint64_t nb_error_decod =0; @@ -269,6 +270,10 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) } } +#ifdef PRINT_CRC_CHECK + static uint32_t prnt_crc_cnt = 0; +#endif + uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t UE_id, short *ulsch_llr, @@ -287,6 +292,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint8_t crc_type; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); + +#ifdef PRINT_CRC_CHECK + prnt_crc_cnt++; +#endif NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id+1][0]; @@ -584,10 +593,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, p_procTime); if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { - LOG_I(PHY, "Segment %d CRC OK\n",r); + #ifdef PRINT_CRC_CHECK + if (prnt_crc_cnt % 10 == 0) + LOG_I(PHY, "Segment %d CRC OK\n",r); + #endif ret = 2; } else { - LOG_I(PHY, "CRC NOK\n"); + #ifdef PRINT_CRC_CHECK + if (prnt_crc_cnt%10 == 0) + LOG_I(PHY, "CRC NOK\n"); + #endif ret = 1+ulsch->max_ldpc_iterations; } From 3d86e29508bc1284eb8b90740246fdab0de06be7 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 16:46:07 +0200 Subject: [PATCH 21/32] Minor fixes and edits in ulsch_decoding --- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index e43b57321d..ab497e0b12 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -333,17 +333,17 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (!ulsch_llr) { printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } if (!harq_process) { printf("ulsch_decoding.c: NULL harq_process pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } if (!frame_parms) { printf("ulsch_decoding.c: NULL frame_parms pointer\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; @@ -351,11 +351,9 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, harq_process->TBS = nr_compute_tbs(mcs, nb_rb, number_symbols, nb_re_dmrs, length_dmrs, n_layers); A = harq_process->TBS; - ret = ulsch->max_ldpc_iterations; - + ret = ulsch->max_ldpc_iterations + 1; + G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers); - // G = 0; - // G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers); LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); @@ -416,8 +414,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, //printf("coderate %f kc %d \n", Coderate, kc); - - p_decParams->numMaxIter = ulsch->max_ldpc_iterations; p_decParams->outMode= 0; @@ -439,7 +435,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (harq_process->C > MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling) { LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling); - return((1+ulsch->max_ldpc_iterations)); + return (ulsch->max_ldpc_iterations + 1); } #ifdef DEBUG_ULSCH_DECODING printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); @@ -447,7 +443,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, //opp_enabled=1; - Kr = harq_process->K; // [hna] overwrites this line "Kr = p_decParams->Z*kb" + Kr = harq_process->K; Kr_bytes = Kr>>3; K_bytes_F = Kr_bytes-(harq_process->F>>3); @@ -517,7 +513,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, stop_meas(ulsch_rate_unmatching_stats); #endif LOG_E(PHY,"ulsch_decoding.c: Problem in rate_matching\n"); - return(ulsch->max_ldpc_iterations); + return (ulsch->max_ldpc_iterations + 1); } else { #if gNB_TIMING_TRACE stop_meas(ulsch_rate_unmatching_stats); @@ -597,21 +593,20 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (prnt_crc_cnt % 10 == 0) LOG_I(PHY, "Segment %d CRC OK\n",r); #endif - ret = 2; + ret = no_iteration_ldpc; } else { #ifdef PRINT_CRC_CHECK if (prnt_crc_cnt%10 == 0) LOG_I(PHY, "CRC NOK\n"); #endif - ret = 1+ulsch->max_ldpc_iterations; + ret = ulsch->max_ldpc_iterations + 1; } - + nb_total_decod++; + if (no_iteration_ldpc > ulsch->max_ldpc_iterations){ nb_error_decod++; } - - ret=no_iteration_ldpc; for (int m=0; m < Kr>>3; m ++) { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; @@ -630,7 +625,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif } - if ((err_flag == 0) && (ret>=(1+ulsch->max_ldpc_iterations))) { + if ((err_flag == 0) && (ret >= (ulsch->max_ldpc_iterations + 1))) { // a Code segment is in error so break; LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); err_flag = 1; @@ -672,7 +667,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, } harq_process->handled = 1; - return((1+ulsch->max_ldpc_iterations)); + return (ulsch->max_ldpc_iterations + 1); } else { From 03ac9b03c89a5c66f158b31389d760225691a203 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 16:53:09 +0200 Subject: [PATCH 22/32] TBS fix at UE side + minor restructuring in "phy_procedures_nrUE_TX" - TBS calculation was performed 2 times. Once in "phy_procedures_nrUE_TX" and another in "nr_ue_ulsch_procedures". The TBS calculation was wrong in "phy_procedures_nrUE_TX" and correct in "nr_ue_ulsch_procedures". - The data generation was performed in "phy_procedures_nrUE_TX" with a wrongly calculated TBS because "ulsch_ue->nb_re_dmrs" wasn't set to a value, so the calculated TBS would be more than it should be. This doesn't create a problem in the test because the comparison between the TX and RX data is made using the correctly calculated TBS which is smaller. - Solution was to perform data generation in "nr_ue_ulsch_procedures", and remove TBS calculation in "phy_procedures_nrUE_TX" --- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 8 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 35 ++++++++------ openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 46 ++----------------- 3 files changed, 32 insertions(+), 57 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index d69b299ee1..6c14aa8b56 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1076,19 +1076,21 @@ void nr_pusch_codeword_scrambling(uint8_t *in, - transform precoding */ -uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, +void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned char harq_pid, uint8_t slot, uint8_t thread_id, - int eNB_id); + int gNB_id); /** \brief This function does IFFT for PUSCH */ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, + uint8_t harq_pid, uint8_t slot, - uint8_t Nl, + uint8_t thread_id, + uint8_t gNB_id, NR_DL_FRAME_PARMS *frame_parms); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 2db023a2d2..79a2fc9f5c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -45,7 +45,6 @@ //#define DEBUG_SCFDMA //#define DEBUG_PUSCH_MAPPING - void nr_pusch_codeword_scrambling(uint8_t *in, uint16_t size, uint32_t Nid, @@ -85,11 +84,11 @@ void nr_pusch_codeword_scrambling(uint8_t *in, } -uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, +void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, unsigned char harq_pid, uint8_t slot, uint8_t thread_id, - int eNB_id) { + int gNB_id) { unsigned int available_bits; uint8_t mod_order, cwd_index, num_of_codewords; @@ -105,12 +104,11 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, int ap, start_symbol, Nid_cell, i; int sample_offsetF, N_RE_prime, N_PRB_oh; uint16_t n_rnti; - uint32_t TBS; NR_UE_ULSCH_t *ulsch_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; - NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][eNB_id]; + NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; num_of_codewords = 1; // tmp assumption length_dmrs = 1; @@ -118,11 +116,9 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, Nid_cell = 0; N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig - - for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { - ulsch_ue = UE->ulsch[thread_id][eNB_id][cwd_index]; + ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; ulsch_ue->length_dmrs = length_dmrs; @@ -134,10 +130,20 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords; - TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); + harq_process_ul_ue->TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); - harq_process_ul_ue->TBS = TBS; + //-----------------------------------------------------// + // to be removed later when MAC is ready + if (harq_process_ul_ue != NULL){ + for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) + harq_process_ul_ue->a[i] = (unsigned char) rand(); + } else { + LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); + return; + } + + //-----------------------------------------------------// /////////////////////////ULSCH coding///////////////////////// /////////// @@ -209,7 +215,7 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, tx_layers = (int16_t **)pusch_ue->txdataF_layers; - nr_ue_layer_mapping(UE->ulsch[thread_id][eNB_id], + nr_ue_layer_mapping(UE->ulsch[thread_id][gNB_id], harq_process_ul_ue->Nl, available_bits/mod_order, tx_layers); @@ -321,19 +327,22 @@ uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////// //////////////////////////////////////////////////////////////////////// - return 0; + return; } uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, + uint8_t harq_pid, uint8_t slot, - uint8_t Nl, + uint8_t thread_id, + uint8_t gNB_id, NR_DL_FRAME_PARMS *frame_parms) { int tx_offset, ap; int32_t **txdata; int32_t **txdataF; int timing_advance; + uint8_t Nl = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->Nl; // cw 0 /////////////////////////IFFT/////////////////////// /////////// diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index fdf46681cb..dcadc3bc91 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -2468,12 +2468,9 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t thread_id) { - NR_UE_ULSCH_t *ulsch_ue; - NR_UL_UE_HARQ_t *harq_process_ul_ue; //int32_t ulsch_start=0; int slot_tx = proc->nr_tti_tx; int frame_tx = proc->frame_tx; - int harq_pid, i, TBS; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); @@ -2483,47 +2480,12 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, start_meas(&ue->phy_proc_tx); #endif - harq_pid = 0; //temporary implementation - - /* - generate_ue_ulsch_params(ue, - 0, - gNB_id, - harq_pid); - */ - - ulsch_ue = ue->ulsch[thread_id][gNB_id][0]; // cwd_index = 0 - harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; - - TBS = nr_compute_tbs( harq_process_ul_ue->mcs, harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs, ulsch_ue->length_dmrs, harq_process_ul_ue->Nl); - - LOG_I(PHY, "[phy_procedures_nrUE_TX] mcs = %d, nb_rb = %d \n , Nsymb_pusch = %d, nb_re_dmrs = %d, length_dmrs = %d, precod_nbr_layers = %d, TBS = %d\n", - harq_process_ul_ue->mcs, - harq_process_ul_ue->nb_rb, - harq_process_ul_ue->number_of_symbols, - ulsch_ue->nb_re_dmrs, - ulsch_ue->length_dmrs, - harq_process_ul_ue->Nl, - TBS); - - -//-----------------------------------------------------// - // to be removed later when MAC is ready - - if (harq_process_ul_ue != NULL){ - for (i = 0; i < TBS / 8; i++) - harq_process_ul_ue->a[i] = (unsigned char) rand(); - } else { - LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); - return; - } - -//-----------------------------------------------------// + uint8_t harq_pid = 0; //temporary implementation nr_ue_ulsch_procedures(ue, harq_pid, slot_tx, - 0, + thread_id, gNB_id); @@ -2538,8 +2500,10 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, nr_ue_pusch_common_procedures(ue, + harq_pid, slot_tx, - harq_process_ul_ue->Nl, + thread_id, + gNB_id, &ue->frame_parms); From 7c7a1e82623da4487959df68c65b1a37cf8e33ec Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 17:04:34 +0200 Subject: [PATCH 23/32] Added frame loop to ulsim --- openair1/SIMULATION/NR_PHY/ulsim.c | 265 ++++++++++++++--------------- 1 file changed, 132 insertions(+), 133 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index bb74368dfe..9d4867743e 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -95,7 +95,7 @@ int main(int argc, char **argv) SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; //unsigned char frame_type = 0; - int frame = 0; + int number_of_frames = 1; int frame_length_complex_samples; NR_DL_FRAME_PARMS *frame_parms; int loglvl = OAILOG_WARNING; @@ -190,7 +190,7 @@ int main(int argc, char **argv) break;*/ case 'n': - n_trials = atoi(optarg); + number_of_frames = atoi(optarg); break; case 's': @@ -329,9 +329,6 @@ int main(int argc, char **argv) gNB = RC.gNB[0][0]; //gNB_config = &gNB->gNB_config; - UE_proc.nr_tti_tx = slot; - UE_proc.frame_tx = frame; - frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; @@ -378,9 +375,8 @@ int main(int argc, char **argv) } } - unsigned char harq_pid = 0; - unsigned int TBS = 8424; + unsigned int TBS; unsigned int available_bits; uint8_t nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*(UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4; uint8_t length_dmrs = 1; @@ -394,170 +390,173 @@ int main(int argc, char **argv) nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch_gNB->harq_processes[harq_pid]->ulsch_pdu; NR_UE_ULSCH_t **ulsch_ue = UE->ulsch[0][0]; - - // --------- setting rel15_ul parameters for gNB -------- - rel15_ul->rnti = n_rnti; - rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; - rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; - rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; - rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; - rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; - rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; - rel15_ul->ulsch_pdu_rel15.Qm = mod_order; - rel15_ul->ulsch_pdu_rel15.mcs = Imcs; - rel15_ul->ulsch_pdu_rel15.rv = 0; - rel15_ul->ulsch_pdu_rel15.ndi = 0; - rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; - /////////////////////////////////////////////////// - - nr_scheduled_response_t scheduled_response; - fapi_nr_ul_config_request_t ul_config; - //fapi_nr_tx_request_t tx_request; - - scheduled_response.module_id = 0; - scheduled_response.CC_id = 0; - scheduled_response.frame = frame; - scheduled_response.slot = slot; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &ul_config; - scheduled_response.dl_config = NULL; - - ul_config.sfn_slot = slot; - ul_config.number_pdus = 1; - ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; - //there are plenty of other parameters that we don't seem to be using for now. e.g. - //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; - - // set FAPI parameters for UE, put them in the scheduled response and call - nr_ue_scheduled_response(&scheduled_response); - unsigned char *estimated_output_bit; unsigned char *test_input_bit; - unsigned int errors_bit = 0; + uint32_t errors_bit = 0; uint32_t errors_scrambling = 0; + uint32_t frames_in_error = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - /////////////////////////phy_procedures_nr_ue_TX/////////////////////// - /////////// + nr_scheduled_response_t scheduled_response; + fapi_nr_ul_config_request_t ul_config; - phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); + for (int frame = 0; frame < number_of_frames; frame++) { - /////////// - //////////////////////////////////////////////////// - tx_offset = slot*frame_parms->samples_per_slot; - - txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - - txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation + // printf("***********\n"); + // printf("frame = %d\n", frame); + // printf("***********\n"); + UE_proc.nr_tti_tx = slot; + UE_proc.frame_tx = frame; + // --------- setting rel15_ul parameters for gNB -------- + rel15_ul->rnti = n_rnti; + rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; + rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; + rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; + rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; + rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; + rel15_ul->ulsch_pdu_rel15.Qm = mod_order; + rel15_ul->ulsch_pdu_rel15.mcs = Imcs; + rel15_ul->ulsch_pdu_rel15.rv = 0; + rel15_ul->ulsch_pdu_rel15.ndi = 0; + rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; + /////////////////////////////////////////////////// + //fapi_nr_tx_request_t tx_request; - printf("\n"); + scheduled_response.module_id = 0; + scheduled_response.CC_id = 0; + scheduled_response.frame = frame; + scheduled_response.slot = slot; + scheduled_response.dl_config = NULL; + scheduled_response.ul_config = &ul_config; + scheduled_response.dl_config = NULL; - for (SNR = snr0; SNR < snr1; SNR += snr_step) { + ul_config.sfn_slot = slot; + ul_config.number_pdus = 1; + ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; + //there are plenty of other parameters that we don't seem to be using for now. e.g. + //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; - n_errors = 0; - n_false_positive = 0; + // set FAPI parameters for UE, put them in the scheduled response and call + nr_ue_scheduled_response(&scheduled_response); - //AWGN - sigma_dB = 10*log10(txlev_float)-SNR; - sigma = pow(10,sigma_dB/10); + /////////////////////////phy_procedures_nr_ue_TX/////////////////////// + /////////// - for (trial = 0; trial < n_trials; trial++) { + phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); - errors_scrambling = 0; - errors_bit = 0; + /////////// + //////////////////////////////////////////////////// + tx_offset = slot*frame_parms->samples_per_slot; - for (i=0; inb_antennas_rx; ap++) { - ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point - ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1])+ (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); - } - } + txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - - phy_procedures_gNB_common_RX(gNB, frame, slot); + txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation - phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); + for (SNR = snr0; SNR < snr1; SNR += snr_step) { + n_errors = 0; + n_false_positive = 0; - //---------------------------------------------------------- - //---------------------- count errors ---------------------- - //---------------------------------------------------------- + //AWGN + sigma_dB = 10*log10(txlev_float)-SNR; + sigma = pow(10,sigma_dB/10); - printf("available_bits = %d\n",available_bits); + for (trial = 0; trial < n_trials; trial++) { - for (i = 0; i < available_bits; i++) { - - if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || - ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) - { - if(errors_scrambling == 0) { - printf("\n"); - printf("First bit in error in unscrambling = %d\n",i); + errors_scrambling = 0; + errors_bit = 0; + + for (i=0; inb_antennas_rx; ap++) { + ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point + ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); } - errors_scrambling++; } - } + phy_procedures_gNB_common_RX(gNB, frame, slot); + phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); - for (i = 0; i < TBS; i++) { + //---------------------------------------------------------- + //---------------------- count errors ---------------------- + //---------------------------------------------------------- - estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments + for (i = 0; i < available_bits; i++) { - if (estimated_output_bit[i] != test_input_bit[i]) { - if(errors_bit == 0) - printf("First bit in error in decoding = %d\n",i); - errors_bit++; + if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || + ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) + { + if(errors_scrambling == 0) { + printf("\n"); + printf("First bit in error in unscrambling in frame %d = %d\n", frame, i); + } + errors_scrambling++; + } } - - } - //////////////////////////////////////////////////////////// + for (i = 0; i < TBS; i++) { - if (errors_scrambling > 0) { - if (n_trials == 1) - printf("errors_scrambling = %d (trial %d)\n", errors_scrambling, trial); - } + estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments - if (errors_bit > 0) { - n_false_positive++; - if (n_trials == 1) - printf("errors_bit = %d (trial %d)\n", errors_bit, trial); - } - printf("\n"); - } // [hna] for (trial = 0; trial < n_trials; trial++) - - printf("*****************************************\n"); - printf("SNR %f, (false positive %f)\n", SNR, - (float) n_false_positive / (float) n_trials); - printf("*****************************************\n"); - printf("\n"); + if (estimated_output_bit[i] != test_input_bit[i]) { + if(errors_bit == 0) + printf("First bit in error in decoding in frame %d = %d\n", frame, i); + errors_bit++; + } + } - if (errors_bit == 0) { - printf("PUSCH test OK\n"); - printf("\n"); - break; - } - printf("\n"); - } // [hna] for (SNR = snr0; SNR < snr1; SNR += snr_step) + //////////////////////////////////////////////////////////// + if (errors_scrambling > 0) { + if (n_trials == 1) + printf("frame %d, errors_scrambling = %d (trial %d)\n", frame, errors_scrambling, trial); + } + + if (errors_bit > 0) { + frames_in_error++; + n_false_positive++; + + if (n_trials == 1) + printf("frame %d, errors_bit = %d (trial %d)\n", frame, errors_bit, trial); + + printf("*****************************************\n"); + printf("SNR %f, (false positive %f)\n", SNR, + (float) n_false_positive / (float) n_trials); + printf("*****************************************\n"); + printf("\n"); + } + } // [hna] for (trial = 0; trial < n_trials; trial++) + + if (errors_bit == 0) + break; + } // [hna] for (SNR = snr0; SNR < snr1; SNR += snr_step) + } // frame loop + + if(frames_in_error == 0) { + printf("*************\n"); + printf("PUSCH test OK\n"); + printf("*************\n"); + } + + printf("\n"); for (i = 0; i < 2; i++) { From 3be72df3350b9e2cbcac3c7c881e23083b09a5d2 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 17:05:18 +0200 Subject: [PATCH 24/32] Set start_rb to 0 - start_rb was set to 30, and nb_rb was set to 50 with NB_RB_DL = 106. - When the DC subcarrier is included in the RB allocation, this causes errors in FFT/IFFT operations arounf the DC subcarrier - This leads to errors in unscrambling and decoding --- openair1/SIMULATION/NR_PHY/ulsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 9d4867743e..b37e494906 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -110,7 +110,7 @@ int main(int argc, char **argv) int tx_offset; double txlev_float; int32_t txlev; - int start_rb = 30; + int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) From b28d0068607f0d12de1d49c9543b02e967f382d4 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 17:11:02 +0200 Subject: [PATCH 25/32] Minor Fixes in ulsim --- openair1/SIMULATION/NR_PHY/ulsim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index b37e494906..679b5d37cf 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -338,7 +338,7 @@ int main(int argc, char **argv) crcTableInit(); - nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell, SSB_positions); + nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); phy_init_nr_gNB(gNB, 0, 0); //init_eNB_afterRU(); @@ -583,6 +583,9 @@ int main(int argc, char **argv) printf("\n"); } + free(test_input_bit); + free(estimated_output_bit); + if (output_fd) fclose(output_fd); From 675c0dff2d4537c617cdd616b4a064f898fb71b3 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Mon, 19 Aug 2019 18:32:42 +0200 Subject: [PATCH 26/32] Providing time domain channel estimates --- .../NR_ESTIMATION/nr_ul_channel_estimation.c | 76 +++++++++++++++++-- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 22062bd4d7..0382cd87aa 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -30,12 +30,12 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, - uint8_t gNB_offset, - unsigned char Ns, - unsigned short p, - unsigned char symbol, - unsigned short bwp_start_subcarrier, - unsigned short nb_rb_pusch) + uint8_t gNB_offset, + unsigned char Ns, + unsigned short p, + unsigned char symbol, + unsigned short bwp_start_subcarrier, + unsigned short nb_rb_pusch) { int pilot[1320] __attribute__((aligned(16))); unsigned char aarx; @@ -44,6 +44,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, int16_t ch[2],*pil,*rxF,*ul_ch,*fl,*fm,*fr,*fml,*fmr,*fmm; int ch_offset,symbol_offset, length_dmrs, UE_id = 0; unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config + int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(32))); + int32_t **ul_ch_estimates_time = gNB->pusch_vars[UE_id]->ul_ch_estimates_time; #ifdef DEBUG_CH FILE *debug_ch_est; @@ -253,8 +255,68 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ch, ul_ch, 8); - //} + // Convert to time domain + memset(temp_in_ifft_0,0,gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t)); + + for(int ii = 0; ii < nb_rb_pusch*12; ii++) + ((int32_t*)temp_in_ifft_0)[ii] = ul_ch_estimates[aarx][symbol_offset+ii]; + + switch (gNB->frame_parms.ofdm_symbol_size) { + case 128: + idft128((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 256: + idft256((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 512: + idft512((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 1024: + idft1024((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 1536: + idft1536((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 2048: + idft2048((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 4096: + idft4096((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + case 8192: + idft8192((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + + default: + idft512((int16_t*) temp_in_ifft_0, + (int16_t*) ul_ch_estimates_time[aarx], + 1); + break; + } } #ifdef DEBUG_CH From 17e4f0f12d5733e53de8315281e5454bde405352 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Thu, 22 Aug 2019 15:59:17 +0200 Subject: [PATCH 27/32] Reordering frame and SNR loops --- openair1/SIMULATION/NR_PHY/ulsim.c | 195 +++++++++++++++-------------- 1 file changed, 101 insertions(+), 94 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 679b5d37cf..5501ea6c2a 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -393,83 +393,87 @@ int main(int argc, char **argv) unsigned char *estimated_output_bit; unsigned char *test_input_bit; - uint32_t errors_bit = 0; + uint32_t errors_decoding = 0; uint32_t errors_scrambling = 0; - uint32_t frames_in_error = 0; + uint32_t is_frame_in_error = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); nr_scheduled_response_t scheduled_response; fapi_nr_ul_config_request_t ul_config; - - for (int frame = 0; frame < number_of_frames; frame++) { - - // printf("***********\n"); - // printf("frame = %d\n", frame); - // printf("***********\n"); - UE_proc.nr_tti_tx = slot; - UE_proc.frame_tx = frame; - - // --------- setting rel15_ul parameters for gNB -------- - rel15_ul->rnti = n_rnti; - rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; - rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; - rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; - rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; - rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; - rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; - rel15_ul->ulsch_pdu_rel15.Qm = mod_order; - rel15_ul->ulsch_pdu_rel15.mcs = Imcs; - rel15_ul->ulsch_pdu_rel15.rv = 0; - rel15_ul->ulsch_pdu_rel15.ndi = 0; - rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; - /////////////////////////////////////////////////// - - //fapi_nr_tx_request_t tx_request; - scheduled_response.module_id = 0; - scheduled_response.CC_id = 0; - scheduled_response.frame = frame; - scheduled_response.slot = slot; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &ul_config; - scheduled_response.dl_config = NULL; + printf("\n"); - ul_config.sfn_slot = slot; - ul_config.number_pdus = 1; - ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; - ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; - //there are plenty of other parameters that we don't seem to be using for now. e.g. - //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; + for (SNR = snr0; SNR < snr1; SNR += snr_step) { - // set FAPI parameters for UE, put them in the scheduled response and call - nr_ue_scheduled_response(&scheduled_response); + printf("-------------------\n"); + printf("SNR %f\n", SNR); + printf("-------------------\n"); - /////////////////////////phy_procedures_nr_ue_TX/////////////////////// - /////////// + is_frame_in_error = 0; + for (int frame = 0; frame < number_of_frames; frame++) { - phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); + UE_proc.nr_tti_tx = slot; + UE_proc.frame_tx = frame; - /////////// - //////////////////////////////////////////////////// - tx_offset = slot*frame_parms->samples_per_slot; + // --------- setting rel15_ul parameters for gNB -------- + rel15_ul->rnti = n_rnti; + rel15_ul->ulsch_pdu_rel15.start_rb = start_rb; + rel15_ul->ulsch_pdu_rel15.number_rbs = nb_rb; + rel15_ul->ulsch_pdu_rel15.start_symbol = start_symbol; + rel15_ul->ulsch_pdu_rel15.number_symbols = nb_symb_sch; + rel15_ul->ulsch_pdu_rel15.nb_re_dmrs = nb_re_dmrs; + rel15_ul->ulsch_pdu_rel15.length_dmrs = length_dmrs; + rel15_ul->ulsch_pdu_rel15.Qm = mod_order; + rel15_ul->ulsch_pdu_rel15.mcs = Imcs; + rel15_ul->ulsch_pdu_rel15.rv = 0; + rel15_ul->ulsch_pdu_rel15.ndi = 0; + rel15_ul->ulsch_pdu_rel15.n_layers = precod_nbr_layers; + /////////////////////////////////////////////////// - txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + //fapi_nr_tx_request_t tx_request; - txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation + scheduled_response.module_id = 0; + scheduled_response.CC_id = 0; + scheduled_response.frame = frame; + scheduled_response.slot = slot; + scheduled_response.dl_config = NULL; + scheduled_response.ul_config = &ul_config; + scheduled_response.dl_config = NULL; - for (SNR = snr0; SNR < snr1; SNR += snr_step) { + ul_config.sfn_slot = slot; + ul_config.number_pdus = 1; + ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = nb_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = start_rb; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = nb_symb_sch; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = start_symbol; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.mcs = Imcs; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; + ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; + //there are plenty of other parameters that we don't seem to be using for now. e.g. + //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; + + // set FAPI parameters for UE, put them in the scheduled response and call + nr_ue_scheduled_response(&scheduled_response); + + /////////////////////////phy_procedures_nr_ue_TX/////////////////////// + /////////// + + phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0); + + /////////// + //////////////////////////////////////////////////// + tx_offset = slot*frame_parms->samples_per_slot; + + txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + + txlev_float = (double)txlev/(double)AMP; // output of signal_energy is fixed point representation n_errors = 0; n_false_positive = 0; @@ -481,21 +485,29 @@ int main(int argc, char **argv) for (trial = 0; trial < n_trials; trial++) { errors_scrambling = 0; - errors_bit = 0; + errors_decoding = 0; + //---------------------------------------------------------- + //------------------------ add noise ----------------------- + //---------------------------------------------------------- for (i=0; inb_antennas_rx; ap++) { ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); } } + //////////////////////////////////////////////////////////// + //---------------------------------------------------------- + //------------------- gNB phy procedures ------------------- + //---------------------------------------------------------- phy_procedures_gNB_common_RX(gNB, frame, slot); phy_procedures_gNB_uespec_RX(gNB, frame, slot, rel15_ul->ulsch_pdu_rel15.start_symbol, rel15_ul->ulsch_pdu_rel15.start_symbol + rel15_ul->ulsch_pdu_rel15.number_symbols); + //////////////////////////////////////////////////////////// //---------------------------------------------------------- - //---------------------- count errors ---------------------- + //----------------- count and print errors ----------------- //---------------------------------------------------------- for (i = 0; i < available_bits; i++) { @@ -503,54 +515,49 @@ int main(int argc, char **argv) if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) { - if(errors_scrambling == 0) { - printf("\n"); - printf("First bit in error in unscrambling in frame %d = %d\n", frame, i); - } + if(errors_scrambling == 0) + printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i); errors_scrambling++; } } + if (errors_scrambling > 0) { + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling); + } + for (i = 0; i < TBS; i++) { estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments + test_input_bit[i] = (ulsch_ue[0]->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); if (estimated_output_bit[i] != test_input_bit[i]) { - if(errors_bit == 0) - printf("First bit in error in decoding in frame %d = %d\n", frame, i); - errors_bit++; + if(errors_decoding == 0) + printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i); + errors_decoding++; } } - //////////////////////////////////////////////////////////// - - if (errors_scrambling > 0) { - if (n_trials == 1) - printf("frame %d, errors_scrambling = %d (trial %d)\n", frame, errors_scrambling, trial); - } - - if (errors_bit > 0) { - frames_in_error++; + if (errors_decoding > 0) { + is_frame_in_error = 1; n_false_positive++; - - if (n_trials == 1) - printf("frame %d, errors_bit = %d (trial %d)\n", frame, errors_bit, trial); - - printf("*****************************************\n"); - printf("SNR %f, (false positive %f)\n", SNR, - (float) n_false_positive / (float) n_trials); - printf("*****************************************\n"); - printf("\n"); + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %d\n" "\x1B[0m", frame, trial, errors_decoding); + } else { + is_frame_in_error = 0; + break; } - } // [hna] for (trial = 0; trial < n_trials; trial++) + //////////////////////////////////////////////////////////// + } // trial loop - if (errors_bit == 0) + if (is_frame_in_error == 1) break; - } // [hna] for (SNR = snr0; SNR < snr1; SNR += snr_step) - } // frame loop + } // frame loop - if(frames_in_error == 0) { + if(is_frame_in_error == 0) + break; + } // SNR loop + + if(is_frame_in_error == 0) { + printf("\n"); printf("*************\n"); printf("PUSCH test OK\n"); printf("*************\n"); From b0f5f5f86477b5d9aee30477e6007b7cfb08a183 Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Thu, 22 Aug 2019 16:01:44 +0200 Subject: [PATCH 28/32] Adding TA estimation at gNB PHY for TA updates --- cmake_targets/CMakeLists.txt | 1 + .../PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c | 71 ++++++++++++++++ .../NR_ESTIMATION/nr_ul_channel_estimation.c | 10 +-- openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h | 1 + openair1/SCHED_NR/fapi_nr_l1.h | 3 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 81 +++++++++++++++++-- 6 files changed, 153 insertions(+), 14 deletions(-) create mode 100644 openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index ca88d25b7e..69d46bc2cd 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1336,6 +1336,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c + ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c #${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c diff --git a/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c new file mode 100644 index 0000000000..9c4d1fcc93 --- /dev/null +++ b/openair1/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c @@ -0,0 +1,71 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c +* \brief TA estimation for TA updates +* \author Ahmed Hussein +* \date 2019 +* \version 0.1 +* \company Fraunhofer IIS +* \email: ahmed.hussein@iis.fraunhofer.de +* \note +* \warning +*/ + +#include "PHY/types.h" +#include "PHY/defs_gNB.h" +#include "PHY/phy_extern.h" +#include "nr_ul_estimation.h" + +int nr_est_timing_advance_pusch(PHY_VARS_gNB* gNB, int UE_id) +{ + int temp, i, aa, max_pos = 0, max_val = 0; + short Re, Im; + uint8_t cyclic_shift = 0; + + NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; + NR_gNB_PUSCH *gNB_pusch_vars = gNB->pusch_vars[UE_id]; + int32_t **ul_ch_estimates_time = gNB_pusch_vars->ul_ch_estimates_time; + + int sync_pos = (frame_parms->ofdm_symbol_size - cyclic_shift*frame_parms->ofdm_symbol_size/12) % (frame_parms->ofdm_symbol_size); + + for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { + temp = 0; + + for (aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { + Re = ((int16_t*)ul_ch_estimates_time[aa])[(i<<1)]; + Im = ((int16_t*)ul_ch_estimates_time[aa])[1+(i<<1)]; + temp += (Re*Re/2) + (Im*Im/2); + } + + if (temp > max_val) { + max_pos = i; + max_val = temp; + } + } + + if (max_pos > frame_parms->ofdm_symbol_size/2) + max_pos = max_pos - frame_parms->ofdm_symbol_size; + + + return max_pos - sync_pos; +} + diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 0382cd87aa..0656091c78 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -44,7 +44,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, int16_t ch[2],*pil,*rxF,*ul_ch,*fl,*fm,*fr,*fml,*fmr,*fmm; int ch_offset,symbol_offset, length_dmrs, UE_id = 0; unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config - int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(32))); + int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(16))); int32_t **ul_ch_estimates_time = gNB->pusch_vars[UE_id]->ul_ch_estimates_time; #ifdef DEBUG_CH @@ -256,11 +256,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ul_ch, 8); - // Convert to time domain - memset(temp_in_ifft_0,0,gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t)); - - for(int ii = 0; ii < nb_rb_pusch*12; ii++) - ((int32_t*)temp_in_ifft_0)[ii] = ul_ch_estimates[aarx][symbol_offset+ii]; + // Convert to time domain + memset(temp_in_ifft_0, 0, gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t)); + memcpy(temp_in_ifft_0, &ul_ch_estimates[aarx][symbol_offset], nb_rb_pusch * NR_NB_SC_PER_RB * sizeof(int32_t)); switch (gNB->frame_parms.ofdm_symbol_size) { case 128: diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index 7690821902..125c166f7d 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -47,5 +47,6 @@ unsigned short bwp_start_subcarrier, unsigned short nb_rb_pusch); +int nr_est_timing_advance_pusch(PHY_VARS_gNB* phy_vars_gNB, int UE_id); #endif diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 9157ca1632..51169660bf 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -36,10 +36,13 @@ #include "nfapi_nr_interface.h" void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO); + void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, int frame, int subframe, nfapi_nr_dl_config_dci_dl_pdu *dcl_dl_pdu); + void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, uint8_t *sdu); +void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index a3fa044f2f..1689a627fc 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -26,10 +26,13 @@ #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "PHY/NR_TRANSPORT/nr_ulsch.h" +#include "PHY/NR_ESTIMATION/nr_ul_estimation.h" #include "SCHED/sched_eNB.h" +#include "sched_nr.h" #include "SCHED/sched_common_extern.h" -#include "nfapi_interface.h" -#include "SCHED/fapi_l1.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h" +#include "fapi_nr_l1.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "PHY/INIT/phy_init.h" @@ -258,6 +261,73 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id } +void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid) +{ + // -------------------- + // [hna] TO BE CLEANED + // -------------------- + + // nfapi_rx_indication_pdu_t *pdu; + + int timing_advance_update; + int sync_pos; + + // pthread_mutex_lock(&gNB->UL_INFO_mutex); + + // gNB->UL_INFO.rx_ind.sfn_sf = frame<<4| slot_rx; + // gNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; + + // pdu = &gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; + + // pdu->rx_ue_information.handle = gNB->ulsch[UE_id+1][0]->handle; + // pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; + // pdu->rx_ue_information.rnti = gNB->ulsch[UE_id+1][0]->rnti; + // pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; + // pdu->rx_indication_rel8.length = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->TBS>>3; + // pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation + // pdu->data = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b; + // estimate timing advance for MAC + sync_pos = nr_est_timing_advance_pusch(gNB, UE_id); + timing_advance_update = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check + // printf("\x1B[33m" "timing_advance_update = %d\n" "\x1B[0m", timing_advance_update); + + switch (gNB->frame_parms.N_RB_DL) { + // case 6: /* nothing to do */ break; + // case 15: timing_advance_update /= 2; break; + // case 25: timing_advance_update /= 4; break; + // case 50: timing_advance_update /= 8; break; + // case 75: timing_advance_update /= 12; break; + case 106: timing_advance_update /= 16; break; + case 217: timing_advance_update /= 32; break; + default: abort(); + } + + // put timing advance command in 0..63 range + timing_advance_update += 31; + + if (timing_advance_update < 0) timing_advance_update = 0; + if (timing_advance_update > 63) timing_advance_update = 63; + + // pdu->rx_indication_rel8.timing_advance = timing_advance_update; + + // estimate UL_CQI for MAC (from antenna port 0 only) + // int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]); + + // if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; + // else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; + // else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; + + // LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", + // harq_pid,frame,slot_rx,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, + // timing_advance_update); + + // gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; + // gNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | slot_rx; + + // pthread_mutex_unlock(&gNB->UL_INFO_mutex); +} + + void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { uint8_t symbol; @@ -287,15 +357,10 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, // In NR, this should be signaled through uplink scheduling dci (i.e, DCI 0_0, 0_1) (Asynchronous HARQ) for (UE_id = 0; UE_id < 1; UE_id++) { // temporary set to 1 untill list of connected UEs is implemented - for(symbol = symbol_start; symbol < symbol_end; symbol++) { - nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid); - } - nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid); - + nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid); // indicate SDU to MAC } - } From 61a1b1c5a82a2cb6ba70b47556c41b845f7293ff Mon Sep 17 00:00:00 2001 From: Ahmed Hussein Date: Thu, 22 Aug 2019 16:06:33 +0200 Subject: [PATCH 29/32] Adding new command line parameters --- openair1/SIMULATION/NR_PHY/ulsim.c | 125 ++++++++++++++++------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5501ea6c2a..3e1ba79f6d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) int slot = 0; FILE *output_fd = NULL; //uint8_t write_output_file = 0; - int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; + int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0; uint8_t n_tx = 1, n_rx = 1; //uint8_t transmission_mode = 1; uint16_t Nid_cell = 0; @@ -113,7 +113,6 @@ int main(int argc, char **argv) int start_rb = 0; int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault) - cpuf = get_cpu_freq_GHz(); @@ -127,8 +126,21 @@ int main(int argc, char **argv) //logInit(); randominit(0); - while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { + while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:P:R:S:")) != -1) { switch (c) { + + /*case 'd': + frame_type = 1; + break;*/ + + case 'd': + delay = atoi(optarg); + break; + + case 'f': + number_of_frames = atoi(optarg); + break; + /*case 'f': write_output_file = 1; output_fd = fopen(optarg, "w"); @@ -140,10 +152,6 @@ int main(int argc, char **argv) break;*/ - /*case 'd': - frame_type = 1; - break;*/ - case 'g': switch ((char) *optarg) { case 'A': @@ -189,8 +197,24 @@ int main(int argc, char **argv) interf2 = atoi(optarg); break;*/ + case 'l': + nb_symb_sch = atoi(optarg); + break; + + case 'm': + Imcs = atoi(optarg); + break; + case 'n': - number_of_frames = atoi(optarg); + n_trials = atoi(optarg); + break; + + case 'p': + extended_prefix_flag = 1; + break; + + case 'r': + nb_rb = atoi(optarg); break; case 's': @@ -198,16 +222,6 @@ int main(int argc, char **argv) printf("Setting SNR0 to %f\n", snr0); break; - case 'S': - snr1 = atof(optarg); - snr1set = 1; - printf("Setting SNR1 to %f\n", snr1); - break; - - case 'p': - extended_prefix_flag = 1; - break; - /* case 'r': ricean_factor = pow(10,-.1*atof(optarg)); @@ -218,6 +232,10 @@ int main(int argc, char **argv) break; */ + /*case 'x': + transmission_mode = atoi(optarg); + break;*/ + case 'y': n_tx = atoi(optarg); @@ -238,6 +256,16 @@ int main(int argc, char **argv) break; + case 'F': + input_fd = fopen(optarg, "r"); + + if (input_fd == NULL) { + printf("Problem with filename %s\n", optarg); + exit(-1); + } + + break; + case 'M': SSB_positions = atoi(optarg); break; @@ -251,56 +279,39 @@ int main(int argc, char **argv) N_RB_UL = N_RB_DL; break; - case 'F': - input_fd = fopen(optarg, "r"); - - if (input_fd == NULL) { - printf("Problem with filename %s\n", optarg); - exit(-1); - } - + case 'S': + snr1 = atof(optarg); + snr1set = 1; + printf("Setting SNR1 to %f\n", snr1); break; - case 'm': - Imcs = atoi(optarg); - break; - - case 'l': - nb_symb_sch = atoi(optarg); - break; - - case 'r': - nb_rb = atoi(optarg); - break; - - /*case 'x': - transmission_mode = atoi(optarg); - break;*/ - default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); - printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); //printf("-d Use TDD\n"); - printf("-n Number of frames to simulate\n"); - printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); - printf("-S Ending SNR, runs from SNR0 to SNR1\n"); - printf("-t Delay spread for multipath channel\n"); + printf("-d Introduce delay in terms of number of samples\n"); + printf("-f Number of frames to simulate\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); + printf("-h This message\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n"); + printf("-m MCS value\n"); + printf("-n Number of trials to simulate\n"); + printf("-p Use extended prefix mode\n"); + printf("-t Delay spread for multipath channel\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-M Multiple SSB positions in burst\n"); - printf("-N Nid_cell\n"); - printf("-R N_RB_DL\n"); - printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); + printf("-M Multiple SSB positions in burst\n"); + printf("-N Nid_cell\n"); + printf("-O oversampling factor (1,2,4,8,16)\n"); + printf("-R N_RB_DL\n"); + printf("-S Ending SNR, runs from SNR0 to SNR1\n"); exit(-1); break; } @@ -492,8 +503,8 @@ int main(int argc, char **argv) //---------------------------------------------------------- for (i=0; inb_antennas_rx; ap++) { - ((short*) gNB->common_vars.rxdata[ap])[2*i] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point - ((short*) gNB->common_vars.rxdata[ap])[2*i+1] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); + ((short*) gNB->common_vars.rxdata[ap])[(2*i) + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); // convert to fixed point + ((short*) gNB->common_vars.rxdata[ap])[2*i+1 + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)*(double)AMP); } } //////////////////////////////////////////////////////////// From 740e4c8aa12958bd2d947ef5e19dae49f660bb42 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Thu, 29 Aug 2019 16:41:54 +0200 Subject: [PATCH 30/32] Setting start_rb = 0 and mcs = 9 for PUSCH --- executables/nr-ue.c | 2 +- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 15 ++------------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 71c36bb74e..877dd18dff 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -380,7 +380,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { //--------------------------Temporary configuration-----------------------------// n_rnti = 0x1234; nb_rb = 50; - start_rb = 30; + start_rb = 0; nb_symb_sch = 12; start_symbol = 2; precod_nbr_layers = 1; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index e0f73c2b61..fff1245477 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -514,7 +514,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { // --------- setting rel15_ul parameters ---------- rel15_ul->rnti = 0x1234; - rel15_ul->ulsch_pdu_rel15.start_rb = 30; + rel15_ul->ulsch_pdu_rel15.start_rb = 0; rel15_ul->ulsch_pdu_rel15.number_rbs = 50; rel15_ul->ulsch_pdu_rel15.start_symbol = 2; rel15_ul->ulsch_pdu_rel15.number_symbols = 12; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index ab497e0b12..19ca123e50 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -270,10 +270,6 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) } } -#ifdef PRINT_CRC_CHECK - static uint32_t prnt_crc_cnt = 0; -#endif - uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t UE_id, short *ulsch_llr, @@ -293,11 +289,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t crc_type; int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); -#ifdef PRINT_CRC_CHECK - prnt_crc_cnt++; -#endif - - NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id+1][0]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &harq_process->ulsch_pdu.ulsch_pdu_rel15; @@ -590,14 +581,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { #ifdef PRINT_CRC_CHECK - if (prnt_crc_cnt % 10 == 0) - LOG_I(PHY, "Segment %d CRC OK\n",r); + LOG_I(PHY, "Segment %d CRC OK\n",r); #endif ret = no_iteration_ldpc; } else { #ifdef PRINT_CRC_CHECK - if (prnt_crc_cnt%10 == 0) - LOG_I(PHY, "CRC NOK\n"); + LOG_I(PHY, "CRC NOK\n"); #endif ret = ulsch->max_ldpc_iterations + 1; } From 7934ec451adf67728007f13728eec396ef92c579 Mon Sep 17 00:00:00 2001 From: Khalid Ahmed Date: Mon, 7 Oct 2019 18:11:06 +0200 Subject: [PATCH 31/32] In TTD mode consider ssb slot as DL slot - added nr_is_ssb_slot function --- executables/nr-ru.c | 2 +- openair1/PHY/INIT/nr_parms.c | 26 ++++++++++++++++++++ openair1/PHY/INIT/phy_init.h | 1 + openair1/SCHED_NR/phy_procedures_nr_common.c | 3 ++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 3b79ded517..4f676716fa 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -731,8 +731,8 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { int i; T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T_INT(0), T_BUFFER(&ru->common.txdata[0][slot * fp->samples_per_slot], fp->samples_per_slot * 4)); - nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); int sf_extension = 0; + //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); int siglen=fp->samples_per_slot,flags=1; /* diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 7ca794c5c2..81785872f9 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -79,6 +79,32 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_f return symbol; } +int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot) +{ + + uint8_t n_hf; + int rel_slot; + + n_hf = cfg->sch_config.half_frame_index.value; + + // if SSB periodicity is 5ms, they are transmitted in both half frames + if ( cfg->sch_config.ssb_periodicity.value == 5) { + if (slot<10) + n_hf=0; + else + n_hf=1; + } + + // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be + rel_slot = (n_hf)? (slot-10) : slot; + + if(rel_slot<10 && rel_slot>=0) + return 1; + else + return 0; + +} + int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, int mu, diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index e136e8a770..7e0500b56c 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -378,6 +378,7 @@ void phy_config_request(PHY_Config_t *phy_config); int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf); void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms); int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index); +int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot); int nr_init_frame_parms(nfapi_nr_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms); int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset); int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag); diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index c19866fc92..abc1c44ce5 100755 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -31,11 +31,12 @@ */ #include "sched_nr.h" +#include "PHY/INIT/phy_init.h" nr_subframe_t nr_slot_select(nfapi_nr_config_request_t *cfg, unsigned char slot) { - if (cfg->subframe_config.duplex_mode.value == FDD || slot == NR_DOWNLINK_SLOT) + if (cfg->subframe_config.duplex_mode.value == FDD || slot == NR_DOWNLINK_SLOT || nr_is_ssb_slot(cfg, slot) == 1) return(SF_DL); else if (slot == NR_UPLINK_SLOT) return (SF_UL); From 189e15aa8092f7f39857346b29dddc29d035c13c Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 11 Oct 2019 17:12:39 +0200 Subject: [PATCH 32/32] improved real-time performance: - gNB now only sends samples to USRP when DL slot. (should do the same for UE) - increased sf_ahead to 6 - fixed timestamp for usrp_write at UE --- executables/nr-gnb.c | 4 ++-- executables/nr-ru.c | 13 +++++++++++-- executables/nr-ue.c | 2 +- openair2/GNB_APP/gnb_config.c | 9 ++++----- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 0a3bef3355..c665cdfb8f 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -108,8 +108,8 @@ extern openair0_config_t openair0_cfg[MAX_CARDS]; extern int transmission_mode; -uint16_t sl_ahead=4; -uint16_t sf_ahead=4; +uint16_t sl_ahead=6; +uint16_t sf_ahead=6; //pthread_t main_gNB_thread; time_stats_t softmodem_stats_mt; // main thread diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 4f676716fa..af4f8b8cba 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -732,9 +732,17 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T_INT(0), T_BUFFER(&ru->common.txdata[0][slot * fp->samples_per_slot], fp->samples_per_slot * 4)); int sf_extension = 0; - //nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); + nr_subframe_t SF_type = nr_slot_select(cfg,slot%fp->slots_per_frame); + + if ((slot == 0) || + (slot == 1)) { + int siglen=fp->samples_per_slot; + int flags; + if (slot==0) + flags = 2; + else if (slot==1) + flags=3; - int siglen=fp->samples_per_slot,flags=1; /* if (SF_type == SF_S) { siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0); @@ -774,6 +782,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); + } } diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 877dd18dff..fe2fd6ca31 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -725,7 +725,7 @@ void *UE_thread(void *arg) { AssertFatal( writeBlockSize == UE->rfdevice.trx_write_func(&UE->rfdevice, timestamp+ - (2*UE->frame_parms.samples_per_slot) - + (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - openair0_cfg[0].tx_sample_advance, txp, diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 71bec1bc58..97f1839d50 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -808,11 +808,10 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { } NRRRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL; - if(N_RB_DL == 217) sf_ahead = 2; - else if(N_RB_DL == 106) sf_ahead = 4; - else sf_ahead = 4; - /*else AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n", - RC.config_file_name, i, N_RB_DL);*/ + //if(N_RB_DL == 217) sf_ahead = 2; + //else if(N_RB_DL == 106) sf_ahead = 4; + if ((N_RB_DL != 217) && (N_RB_DL != 106)) + AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n", RC.config_file_name, i, N_RB_DL); /* if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {