From 0ef58f685acfe855272a3ac0776b699288ac1ffb Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 7 Jun 2017 11:20:51 +0200 Subject: [PATCH 1/5] proper checking for detection of PDCCH/PDSCH, fix of error counters --- openair1/SIMULATION/LTE_PHY/dlsim.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 873edc8343..b152b89ef1 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -1396,6 +1396,7 @@ int main(int argc, char **argv) int DLSCH_RB_ALLOC = 0; int log_level = LOG_ERR; + int dci_received; #if defined(__arm__) FILE *proc_fd = NULL; @@ -2330,10 +2331,10 @@ int main(int argc, char **argv) //if (trials%100==0) eNB2UE[0]->first_run = 1; + UE->dlsch[subframe&0x1][eNB_id][0]->harq_ack[subframe].ack = 0; + UE->dlsch[subframe&0x1][eNB_id][1]->harq_ack[subframe].ack = 0; - UE->dlsch_errors[0] = 1; - - while ((round < num_rounds) && (UE->dlsch_errors[0] > 0)) { + while ((round < num_rounds) && (UE->dlsch[subframe&0x1][eNB_id][0]->harq_ack[subframe].ack == 0)) { // printf("Trial %d, round %d\n",trials,round); round_trials[round]++; @@ -2509,7 +2510,7 @@ int main(int argc, char **argv) UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[subframe&1]; proc->subframe_rx = subframe; UE->UE_mode[0] = PUSCH; - UE->dlsch_errors[0] = 0; + // first symbol has to be done separately in one-shot mode slot_fep(UE, 0, @@ -2550,12 +2551,15 @@ int main(int argc, char **argv) } } + dci_received = UE->pdcch_vars[proc->subframe_rx & 0x1][eNB_id]->dci_received; + phy_procedures_UE_RX(UE,proc,0,0,dci_flag,normal_txrx,no_relay,NULL); - if (UE->dlsch[subframe&0x1][0][0]->active == 0) { + dci_received = dci_received - UE->pdcch_vars[proc->subframe_rx & 0x1][eNB_id]->dci_received; + + if (dci_flag && (dci_received == 0)) { //printf("DCI not received\n"); dci_errors[round]++; - UE->dlsch_errors[0] = 1; /* write_output("pdcchF0_ext.m","pdcchF_ext", UE->pdcch_vars[eNB_id]->rxdataF_ext[0],2*3*UE->frame_parms.ofdm_symbol_size,1,1); @@ -2626,7 +2630,7 @@ int main(int argc, char **argv) - if (UE->dlsch_errors[0] == 0) { + if (UE->dlsch[subframe&0x1][eNB_id][0]->harq_ack[subframe].ack == 1) { avg_iter += UE->dlsch[subframe&0x1][eNB_id][0]->last_iteration_cnt; iter_trials++; @@ -2906,15 +2910,15 @@ int main(int argc, char **argv) errs2[0], round_trials[0], errs[1], - round_trials[0], + round_trials[1], errs[2], - round_trials[0], + round_trials[2], errs[3], - round_trials[0], + round_trials[3], (double)errs[0]/(round_trials[0]), - (double)errs[1]/(round_trials[0]), - (double)errs[2]/(round_trials[0]), - (double)errs[3]/(round_trials[0]), + (double)errs[1]/(round_trials[1]), + (double)errs[2]/(round_trials[2]), + (double)errs[3]/(round_trials[3]), dci_errors[0]+dci_errors[1]+dci_errors[2]+dci_errors[3], round_trials[0]+round_trials[1]+round_trials[2]+round_trials[3], (double)(dci_errors[0]+dci_errors[1]+dci_errors[2]+dci_errors[3])/(round_trials[0]+round_trials[1]+round_trials[2]+round_trials[3]), From 9eb6d6a4ec9cd41958fb429c028434c6b33306fa Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 7 Jun 2017 11:22:47 +0200 Subject: [PATCH 2/5] fixing handling of ndi/first_tx in dci. commenting out corner case of missed ACK, this needs to be done better --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 108 +++++++++++++++---------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 59d16c7a39..e4dbdfe17a 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -5214,28 +5214,38 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, rnti,harq_pid,pdlsch0_harq->DCINdi); } - // DCI has been toggled or this is the first transmission - if (ndi1!=pdlsch0_harq->DCINdi) + // NDI has been toggled or this is the first transmission + if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) { pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 1; - pdlsch0_harq->status = ACTIVE; - } - - if( ((ndi1 == pdlsch0_harq->DCINdi) && (pdlsch0_harq->round == 0)) || - ((rv1 != 0) && (pdlsch0_harq->round == 0)) - ) - { - LOG_D(PHY,"skip pdsch decoding and report ack\n"); - // skip pdsch decoding and report ack - pdlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - pdlsch0_harq->first_tx = 0; + pdlsch0_harq->status = ACTIVE; + } + /* + else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if (pdlsch0_harq->round == 0) + //packet was actually decoded in previous transmission (ACK was missed by eNB) + //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. + { + LOG_D(PHY,"skip pdsch decoding and report ack\n"); + // skip pdsch decoding and report ack + pdlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; + + pdlsch0_harq->first_tx = 0; + } + else //normal retransmission + { + // nothing to do + } + } + */ } pdlsch0_harq->DCINdi = ndi1; @@ -5815,18 +5825,22 @@ void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); dlsch0_harq->first_tx = 0; } - }else{ - if(dlsch0_harq->round == 0) { -#if 0 - // skip pdsch decoding and report ack - dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; -#endif - } } + else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { + if(dlsch0_harq->round == 0) { +#if 0 + // skip pdsch decoding and report ack + dlsch0_harq->status = SCH_IDLE; + pdlsch0->active = 0; + pdlsch0->harq_ack[subframe].ack = 1; + pdlsch0->harq_ack[subframe].harq_id = harq_pid; + pdlsch0->harq_ack[subframe].send_harq_status = 1; +#endif + } + } + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest // PDCCH for the same trasport block using Imcs in [0 .. 28] @@ -5858,19 +5872,22 @@ void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); dlsch1_harq->first_tx = 0; } - }else{ -#if 0 - if(dlsch1_harq->round == 0) { - // skip pdsch decoding and report ack - dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - pdlsch1->harq_ack[subframe].ack = 1; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->harq_ack[subframe].send_harq_status = 1; - } -#endif } - + else if (rv1 != 0 ) + //NDI has not been toggled but rv was increased by eNB: retransmission + { +#if 0 + if(dlsch1_harq->round == 0) { + // skip pdsch decoding and report ack + dlsch1_harq->status = SCH_IDLE; + pdlsch1->active = 0; + pdlsch1->harq_ack[subframe].ack = 1; + pdlsch1->harq_ack[subframe].harq_id = harq_pid; + pdlsch1->harq_ack[subframe].send_harq_status = 1; + } +#endif + } + // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest // PDCCH for the same trasport block using Imcs in [0 .. 28] if(dlsch1_harq->mcs <= 28) @@ -6344,11 +6361,15 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0_harq->mimo_mode = SISO; - if (dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) { + if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || + (dlsch0_harq->first_tx==1)) { dlsch0_harq->round = 0; + dlsch0_harq->first_tx = 0; dlsch0_harq->status = ACTIVE; - } else if (dlsch0_harq->status == SCH_IDLE) { // we got an Ndi = 0 for a previously decoded process, + } + /* + else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, // this happens if either another harq process in the same // is NAK or an ACK was not received @@ -6358,6 +6379,7 @@ int generate_ue_dlsch_params_from_dci(int frame, dlsch0->active = 0; return(0); } + */ dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; From 804a9a0630531422a821f5da0f41867d0b977c39 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 7 Jun 2017 16:16:33 +0200 Subject: [PATCH 3/5] fixing leftover issues from previous commit --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index e4dbdfe17a..4e169028bc 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -5202,7 +5202,6 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) { pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 1; pdlsch0_harq->status = ACTIVE; } else //CRNTI @@ -5222,30 +5221,29 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, pdlsch0_harq->status = ACTIVE; } - /* + else if (rv1 != 0 ) //NDI has not been toggled but rv was increased by eNB: retransmission { - if (pdlsch0_harq->round == 0) + if (pdlsch0_harq->status == SCH_IDLE) //packet was actually decoded in previous transmission (ACK was missed by eNB) //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. { LOG_D(PHY,"skip pdsch decoding and report ack\n"); // skip pdsch decoding and report ack - pdlsch0_harq->status = SCH_IDLE; + //pdlsch0_harq->status = SCH_IDLE; pdlsch0->active = 0; pdlsch0->harq_ack[subframe].ack = 1; pdlsch0->harq_ack[subframe].harq_id = harq_pid; pdlsch0->harq_ack[subframe].send_harq_status = 1; - pdlsch0_harq->first_tx = 0; + //pdlsch0_harq->first_tx = 0; } else //normal retransmission { - // nothing to do + // nothing special to do } } - */ } pdlsch0_harq->DCINdi = ndi1; @@ -5829,15 +5827,13 @@ void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, else if (rv1 != 0 ) //NDI has not been toggled but rv was increased by eNB: retransmission { - if(dlsch0_harq->round == 0) { -#if 0 + if(dlsch0_harq->status == SCH_IDLE) { // skip pdsch decoding and report ack - dlsch0_harq->status = SCH_IDLE; + //dlsch0_harq->status = SCH_IDLE; pdlsch0->active = 0; pdlsch0->harq_ack[subframe].ack = 1; pdlsch0->harq_ack[subframe].harq_id = harq_pid; pdlsch0->harq_ack[subframe].send_harq_status = 1; -#endif } } @@ -5876,16 +5872,14 @@ void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, else if (rv1 != 0 ) //NDI has not been toggled but rv was increased by eNB: retransmission { -#if 0 - if(dlsch1_harq->round == 0) { + if(dlsch1_harq->status == SCH_IDLE) { // skip pdsch decoding and report ack - dlsch1_harq->status = SCH_IDLE; + //dlsch1_harq->status = SCH_IDLE; pdlsch1->active = 0; pdlsch1->harq_ack[subframe].ack = 1; pdlsch1->harq_ack[subframe].harq_id = harq_pid; pdlsch1->harq_ack[subframe].send_harq_status = 1; } -#endif } // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest From 3c56a7edc5aec64d7735e1a6256a5493429d04ba Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 7 Jun 2017 18:11:44 +0200 Subject: [PATCH 4/5] a new proposal for the dlsch_channel_level function --- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index 1450209c26..e6d2ec301f 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -3377,7 +3377,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, short rb; unsigned char aatx,aarx,nre=12,symbol_mod; - __m128i *dl_ch128, avg128D, coeff128; + __m128i *dl_ch128, avg128D; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -3388,11 +3388,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, else nre=12; - double one_over_nb_re = 0.0; - one_over_nb_re = 1/((double)(nb_rb*nre)); - int16_t one_over_nb_re_q1_15 = (int16_t)(one_over_nb_re * (double)(1<<15) ); - coeff128 = _mm_set_epi16(one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15, - one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15,one_over_nb_re_q1_15); + //nb_rb*nre = y * 2^x + int16_t x = log2_approx(nb_rb*nre)-1; + //int16_t one_over_y_q15 = (int16_t)((1<<((int32_t)x+15))/((int32_t)nb_rb*(int32_t)nre)); + float y = (float)(nb_rb*nre)/(float)(1<nb_antenna_ports_eNB; aatx++) for (aarx=0; aarxnb_antennas_rx; aarx++) { @@ -3405,14 +3406,18 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, for (rb=0;rbNcp-1)))&&(frame_parms->mode1_flag==0)) { dl_ch128+=2; } else { - avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15))); + avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[2],dl_ch128[2]),x)); + //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15))); dl_ch128+=3; } /* @@ -3424,11 +3429,12 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, */ } - avg[(aatx<<1)+aarx] =(((int32_t*)&avg128D)[0] + - ((int32_t*)&avg128D)[1] + - ((int32_t*)&avg128D)[2] + - ((int32_t*)&avg128D)[3]); - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] + + ((int32_t*)&avg128D)[1] + + ((int32_t*)&avg128D)[2] + + ((int32_t*)&avg128D)[3]); + avg[(aatx<<1)+aarx] = (int32_t) ((float) avg[(aatx<<1)+aarx]/y); + printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); } _mm_empty(); From 9542e8a8f9aa8c033e110b26fb719d6ebb123fab Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 8 Jun 2017 09:22:30 +0200 Subject: [PATCH 5/5] alternative version of dlsch_channel_level not needing floating point --- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 11 ++++------ openair1/PHY/TOOLS/defs.h | 3 +++ openair1/PHY/TOOLS/log2_approx.c | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index e6d2ec301f..f5281beffc 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -3389,11 +3389,9 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, nre=12; //nb_rb*nre = y * 2^x - int16_t x = log2_approx(nb_rb*nre)-1; - //int16_t one_over_y_q15 = (int16_t)((1<<((int32_t)x+15))/((int32_t)nb_rb*(int32_t)nre)); - float y = (float)(nb_rb*nre)/(float)(1<nb_antenna_ports_eNB; aatx++) for (aarx=0; aarxnb_antennas_rx; aarx++) { @@ -3432,8 +3430,7 @@ void dlsch_channel_level(int **dl_ch_estimates_ext, avg[(aatx<<1)+aarx] = (((int32_t*)&avg128D)[0] + ((int32_t*)&avg128D)[1] + ((int32_t*)&avg128D)[2] + - ((int32_t*)&avg128D)[3]); - avg[(aatx<<1)+aarx] = (int32_t) ((float) avg[(aatx<<1)+aarx]/y); + ((int32_t*)&avg128D)[3])/y; printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); } diff --git a/openair1/PHY/TOOLS/defs.h b/openair1/PHY/TOOLS/defs.h index 542b8edba5..a90a8b718c 100644 --- a/openair1/PHY/TOOLS/defs.h +++ b/openair1/PHY/TOOLS/defs.h @@ -338,6 +338,9 @@ uint8_t log2_approx64(unsigned long long int x); int16_t invSqrt(int16_t x); uint32_t angle(struct complex16 perrror); +/// computes the number of factors 2 in x +unsigned char factor2(unsigned int x); + /*!\fn int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot, uint32_t last_pilot, int32_t ignore_prefix); Compensate the phase rotation of the RF. WARNING: This function is currently unused. It has not been tested! diff --git a/openair1/PHY/TOOLS/log2_approx.c b/openair1/PHY/TOOLS/log2_approx.c index 0317a97d2f..bd4d5d04ab 100644 --- a/openair1/PHY/TOOLS/log2_approx.c +++ b/openair1/PHY/TOOLS/log2_approx.c @@ -37,6 +37,26 @@ unsigned char log2_approx(unsigned int x) return(l2); } +unsigned char factor2(unsigned int x) +{ + + int i; + unsigned char l2; + + l2=0; + + for (i=0; i<31; i++) + if ((x&(1<