From d89602c8afa72a71afb19cd390a143e3a7b44cf1 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 23 Aug 2018 11:16:20 +0200 Subject: [PATCH] UE adding polar decoder --- .../CODING/nrPolar_tools/nr_polar_decoder.c | 4 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- openair1/PHY/INIT/nr_init_ue.c | 9 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 96 +++++++------------ openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 14 ++- openair1/PHY/defs_nr_UE.h | 1 + targets/RT/USER/nr-ue.c | 4 +- 7 files changed, 55 insertions(+), 75 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index f8969f790a..51a0328d7e 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -40,7 +40,7 @@ int8_t polar_decoder( double *input, - uint32_t *out, + uint8_t *out, t_nrPolar_paramsPtr polarParams, uint8_t listSize, uint8_t pathMetricAppr) @@ -274,7 +274,7 @@ int8_t polar_decoder( /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + //nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index e44b4632dd..fdf34398fa 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -112,7 +112,7 @@ void polar_encoder_dci(uint32_t *in, uint16_t n_RNTI); int8_t polar_decoder(double *input, - uint32_t *output, + uint8_t *output, t_nrPolar_paramsPtr polarParams, uint8_t listSize, uint8_t pathMetricAppr); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index bcbbb968d7..806350e2a9 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -933,8 +933,9 @@ void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { }*/ -void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms) +void phy_init_nr_top(PHY_VARS_NR_UE *ue) { + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; crcTableInit(); @@ -960,7 +961,11 @@ void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms) generate_ul_reference_signal_sequences(SHRT_MAX); // Polar encoder init for PBCH - nr_polar_init(&frame_parms->pbch_polar_params, 1); + //nr_polar_init(&frame_parms->pbch_polar_params, 1); + nr_polar_init(&ue->nrPolar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL); //lte_sync_time_init(frame_parms); diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index acc4be1a14..2ee0f6dc26 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -36,6 +36,7 @@ #endif //#include "PHY/defs.h" #include "PHY/defs_nr_UE.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" //#include "PHY/extern.h" //#include "SCHED/defs.h" //#include "SIMULATION/TOOLS/defs.h" // for taus @@ -3719,67 +3720,34 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, void dci_decoding(uint8_t DCI_LENGTH, uint8_t aggregation_level, - int8_t *e, + t_nrPolar_paramsPtr currentPtr, + double *e, uint8_t *decoded_output) { + + int8_t decoderState=0; - uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; - int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; - - uint16_t RCC; - - uint16_t D=(DCI_LENGTH+16+64); - uint16_t coded_bits; #ifdef DEBUG_DCI_DECODING int32_t i; #endif - if (aggregation_level>3) { + if (aggregation_level>16) { LOG_I(PHY," dci.c: dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); return; } - coded_bits = 72 * (1<>3)); - -#ifdef DEBUG_DCI_DECODING - printf("Before Viterbi\n"); - - for (i=0; i<16+DCI_LENGTH; i++) - printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - //debug_printf("Doing DCI Viterbi \n"); - phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); - //debug_printf("Done DCI Viterbi \n"); + + decoderState = polar_decoder(e, + decoded_output, + currentPtr, + 8, + 0); + } @@ -3954,7 +3922,8 @@ void nr_dci_decoding_procedure0(int s, NR_DCI_ALLOC_t *dci_alloc, //x int16_t eNB_id, //x uint8_t current_thread_id, //x - NR_DL_FRAME_PARMS *frame_parms, //x + NR_DL_FRAME_PARMS *frame_parms, + t_nrPolar_paramsPtr *nrPolar_params, //x uint8_t mi, uint16_t crc_scrambled_values[13], //x uint8_t L, @@ -3974,6 +3943,7 @@ void nr_dci_decoding_procedure0(int s, int L2 = (1 << L); unsigned int Yk, nb_candidates = 0, i, m; unsigned int CCEmap_cand; + double *polar_input = malloc (sizeof(double) * 108*L); // A[p], p is the current active CORESET uint16_t A[3]={39827,39829,39839}; @@ -4171,7 +4141,12 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif - dci_decoding(sizeof_bits, L, &pdcch_vars[eNB_id]->e_rx[CCEind * 72], &dci_decoded_output[current_thread_id][0]); + //&pdcch_vars[eNB_id]->e_rx[CCEind * 54] + + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); + + dci_decoding(sizeof_bits, L, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); /* for (i=0;i<3+(sizeof_bits>>3);i++) printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]); @@ -5124,6 +5099,7 @@ uint8_t nr_dci_decoding_procedure(int s, NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); // we need to initialize this values as crc is going to be compared with them uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; @@ -5223,7 +5199,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<2)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5241,7 +5217,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<3)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5259,7 +5235,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<4)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5285,7 +5261,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 1. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 0, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5298,7 +5274,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 2. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 1, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5311,7 +5287,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 4. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5324,7 +5300,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 8. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 3, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5337,7 +5313,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 16. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5403,7 +5379,7 @@ uint8_t nr_dci_decoding_procedure(int s, /* * To be removed until here */ - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 0, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5431,7 +5407,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 1, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5448,7 +5424,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5465,7 +5441,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5482,7 +5458,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index e526d0c5cf..59646eda41 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -535,15 +535,17 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, unsigned short idx_demod =0; int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; + double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); - /*double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. - for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN;*/ + for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; int subframe_rx = proc->subframe_rx; + + printf("ue->current_thread_id[subframe_rx] %d subframe_rx %d\n",ue->current_thread_id[subframe_rx], subframe_rx); pbch_e_rx = &nr_ue_pbch_vars->llr[0]; @@ -651,7 +653,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, //#endif //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, pathMetricAppr); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(&ue->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); + decoderState = polar_decoder(demod_pbch_e, pbch_a_b, currentPtr, decoderListSize, pathMetricAppr); printf("polar decoder state %d\n", decoderState); if(decoderState == -1) return(decoderState); @@ -715,8 +718,3 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, return 0; } - - - - - diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4654564a26..45c61a372b 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1085,6 +1085,7 @@ typedef struct { uint32_t dmrs_pbch_bitmap_nr[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE]; #endif + t_nrPolar_paramsPtr nrPolar_params; /// PBCH DMRS sequence uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 85c7df1923..bfd6088e92 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -696,8 +696,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { UE->ul_indication.slot = 0; // to be fill UE->ul_indication.frame = 0; // to be fill // [TODO] mapping right after NR initial sync - //UE->ul_indication.frame = ; - //UE->ul_indication.slot = ; + UE->ul_indication.frame = proc->frame_rx; + UE->ul_indication.slot = proc->nr_tti_rx; UE->if_inst->ul_indication(&UE->ul_indication); }