From 4e50e36ede4793fe1898a2c8cda129d5f035be68 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 17 May 2020 10:43:15 +0200 Subject: [PATCH] intermediate commit, pucch2 RX with polar still not complete --- openair1/PHY/CODING/TESTBENCH/polartest.c | 4 +- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 376 ++++++++++++++-------- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 25 +- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- 4 files changed, 245 insertions(+), 162 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index a07111a986..3df5b28983 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -121,9 +121,9 @@ int main(int argc, char *argv[]) crcTableInit(); if (polarMessageType == 0) { //PBCH - aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; + aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; } else if (polarMessageType == 1) { //DCI - coderLength = 108*aggregation_level; + coderLength = 108*aggregation_level; } else if (polarMessageType == 2) { //UCI //pucch2 parameters, 1 symbol, aggregation_level = NPRB AssertFatal(aggregation_level>2,"For UCI formats, aggregation (N_RB) should be > 2\n"); diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 62ced5af9d..a822302c06 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -50,7 +50,7 @@ #include "T.h" -//#define DEBUG_NR_PUCCH_RX 1 +#define DEBUG_NR_PUCCH_RX 1 int get_pucch0_cs_lut_index(PHY_VARS_gNB *gNB,nfapi_nr_pucch_pdu_t* pucch_pdu) { @@ -871,6 +871,8 @@ __m256i *pucch2_lut[9]={pucch2_3bit, pucch2_10bit, pucch2_11bit}; +__m64 pucch2_polar_8bit[256*2]; + void init_pucch2_luts() { uint32_t out; @@ -879,7 +881,9 @@ void init_pucch2_luts() { for (int b=3;b<12;b++) { for (uint16_t i=0;i<(1< 0 ? -1 : 1; @@ -948,6 +952,26 @@ void init_pucch2_luts() { *lut_ip1 = _mm256_insert_epi16(*lut_ip1,bit,15); } } + for (uint16_t i=0;i<256;i++) { + __m64 *lut_i=&pucch2_polar_8bit[i<<1]; + __m64 *lut_ip1=&pucch2_polar_8bit[1+(i<<1)]; + bit = (out&0x1) > 0 ? -1 : 1; + *lut_i = _mm_insert_pi16(*lut_i,bit,0); + bit = (out&0x2) > 0 ? -1 : 1; + *lut_ip1 = _mm_insert_pi16(*lut_ip1,bit,0); + bit = (out&0x4) > 0 ? -1 : 1; + *lut_i = _mm_insert_pi16(*lut_i,bit,1); + bit = (out&0x8) > 0 ? -1 : 1; + *lut_ip1 = _mm_insert_pi16(*lut_ip1,bit,1); + bit = (out&0x10) > 0 ? -1 : 1; + *lut_i = _mm_insert_pi16(*lut_i,bit,2); + bit = (out&0x20) > 0 ? -1 : 1; + *lut_ip1 = _mm_insert_pi16(*lut_ip1,bit,2); + bit = (out&0x40) > 0 ? -1 : 1; + *lut_i = _mm_insert_pi16(*lut_i,bit,3); + bit = (out&0x80) > 0 ? -1 : 1; + *lut_ip1 = _mm_insert_pi16(*lut_ip1,bit,3); + } } @@ -983,6 +1007,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, int16_t r_im_ext2[Prx2][8*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); int16_t rd_re_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); int16_t rd_im_ext[Prx2][4*pucch_pdu->nr_of_symbols*pucch_pdu->prb_size] __attribute__((aligned(32))); + int16_t *r_re_ext_p,*r_im_ext_p,*rd_re_ext_p,*rd_im_ext_p; int16_t *rp[Prx2]; __m64 dmrs_re,dmrs_im; @@ -1003,66 +1028,71 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, // 24 PRBs contains 48x16-bit, so 6x8x16-bit for (int prb=0;prbprb_size;prb+=2) { for (int aa=0;aa (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext[aa][i],rd_im_ext[aa],i); + for (int i=0;i<8;i++) printf("Ant %d PRB %d dmrs[%d] -> (%d,%d)\n",aa,prb+(i>>2),i,rd_re_ext_p[i],rd_im_ext_p[i],i); #endif + rp[aa]+=48; } // aa } // prb @@ -1076,7 +1106,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #endif s = lte_gold_generic(&x1, &x2, 1); - for (int group=0;group>=5; corr32_im[group][aa]>>=5; #ifdef DEBUG_NR_PUCCH_RX @@ -1144,7 +1178,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, #endif } //aa - if ((group&3) == 3) s = lte_gold_generic(&x1, &x2, 0); + if ((group&1) == 1) s = lte_gold_generic(&x1, &x2, 0); } // group } else { // 2 symbol case @@ -1262,23 +1296,106 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, s = lte_gold_generic(&x1, &x2, 0); } AssertFatal(pucch_pdu->bit_len_csi_part1 + pucch_pdu->bit_len_csi_part2 == 0,"no csi for now\n"); - AssertFatal((pucch_pdu->bit_len_harq+pucch_pdu->sr_flag > 2 ) && (pucch_pdu->bit_len_harq+pucch_pdu->sr_flag < 12),"illegal length (%d,%d)\n",pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); + AssertFatal((pucch_pdu->bit_len_harq+pucch_pdu->sr_flag > 2 ) && (pucch_pdu->bit_len_harq+pucch_pdu->sr_flag < 65),"illegal length (%d,%d)\n",pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); int nb_bit = pucch_pdu->bit_len_harq+pucch_pdu->sr_flag; - __m256i *rp_re[Prx2]; - __m256i *rp2_re[Prx2]; - __m256i *rp_im[Prx2]; - __m256i *rp2_im[Prx2]; - for (int aa=0;aa>1], + ((int16_t*)&pucch2_lut[nb_bit-3][cw<<1])[1+(i>>1)]); + } + printf("\n"); +#endif + // do complex correlation + for (int aa=0;aa corr) { + corr = corr_tmp; + cw_ML=cw; + } + } + uint8_t corr_dB = dB_fixed64((uint64_t)corr); + LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); + uci_pdu->harq.harq_bit_len = pucch_pdu->bit_len_harq; + + + int harq_bytes=pucch_pdu->bit_len_harq>>3; + if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; + uci_pdu->harq.harq_payload = (nfapi_nr_harq_t*)malloc(harq_bytes); + uci_pdu->harq.harq_crc = 2; + for (int i=0;iharq.harq_payload[i] = cw_ML & 255; + cw_ML>>=8; + } + + if (pucch_pdu->sr_flag == 1) { + uci_pdu->sr.sr_bit_len = 1; + uci_pdu->sr.sr_payload = malloc(1); + uci_pdu->sr.sr_payload[0] = cw_ML; + } + } + else { // polar coded case + __m64 *rp_re[Prx2]; + __m64 *rp2_re[Prx2]; + __m64 *rp_im[Prx2]; + __m64 *rp2_im[Prx2]; + for (int aa=0;aa corr) { - corr = corr_tmp; - cw_ML=cw; - } + } - uint8_t corr_dB = dB_fixed64((uint64_t)corr); - LOG_D(PHY,"cw_ML %d, metric %d dB\n",cw_ML,corr_dB); - uci_pdu->harq.harq_bit_len = pucch_pdu->bit_len_harq; + // non-coherent LLR computation on groups of 4 REs (half-PRBs) + for (in half_prb=0;half_prb<(2*pucch_pdu->prb_size);half_prb++) { + for (int cw=0;cw<256;cw++) { + for (int aa=0;aabit_len_harq>>3; - if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; - uci_pdu->harq.harq_payload = (nfapi_nr_harq_t*)malloc(harq_bytes); - uci_pdu->harq.harq_crc = 2; - for (int i=0;iharq.harq_payload[i] = cw_ML & 255; - cw_ML>>=8; + + LOG_D(PHY,"pucch2 half_prb %d cw %d aa %d: (%d,%d)+(%d,%d) = (%d,%d)\n",half_prb,cw,aa, + corr32_re[half_prb>>2][aa],corr32_im[half_prb>>2][aa], + ((int16_t*)(&prod_re[aa]))[0], + ((int16_t*)(&prod_im[aa]))[0], + corr32_re[half_prb>>2][aa]+((int16_t*)(&prod_re[aa]))[0], + corr32_im[half_prb>>2][aa]+((int16_t*)(&prod_im[aa]))[0]); + + corr_re = ( corr32_re[half_prb>>2][aa]+((int16_t*)(&prod_re[aa]))[0]); + corr_im = ( corr32_im[half_prb>>2][aa]+((int16_t*)(&prod_im[aa]))[0]); + corr_tmp += corr_re*corr_re + corr_im*corr_im; + } + int64_t corr_tmp = corr_re*corr_re + corr_im*corr_im; } - - if (pucch_pdu->sr_flag == 1) { - uci_pdu->sr.sr_bit_len = 1; - uci_pdu->sr.sr_payload = malloc(1); - uci_pdu->sr.sr_payload[0] = cw_ML; + AssertFatal(1==0,"stopping here\n"); } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 2a08d54c5a..5b7734865b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -908,24 +908,13 @@ void nr_uci_encoding(uint64_t payload, // CRC bits are not attached, and coding small block lengths (subclause 5.3.3) b[0] = encodeSmallBlock((uint16_t*)&payload,A); } else if (A>=12) { - AssertFatal(1==0,"Polar encoding not supported yet for UCI\n"); - // procedure in subclause 6.3.1.2.1 (UCI encoded by Polar code -> subclause 6.3.1.3.1) - /*if ((A>=360 && E>=1088)||(A>=1013)) { - I_seg = 1; - } else { - I_seg = 0; - }*/ - - /*if (A>=20) { - // parity bits (subclause 5.2.1) computed by setting L=11 and using generator polynomial gCRC11(D) (subclause 5.1) - L=11; - } else if (A<=19) { - // parity bits (subclause 5.2.1) computed by setting L=6 and using generator polynomial gCRC6(D) (subclause 5.1) - L=6; - }*/ - - // code block segmentation and CRC attachment is performed according to subclause 5.2.1 - // polar coding subclause 5.3.1 + AssertFatal(A<65,"Polar encoding not supported yet for UCI with more than 64 bits\n"); + t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_UCI_PUCCH_MESSAGE_TYPE, + A, + nrofPRB, + 1, + NULL); + polar_encoder_fast(&payload, b, 0,0,currentPtr); } } diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index d36f42f6c6..aefec7bed3 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -336,7 +336,7 @@ int main(int argc, char **argv) } AssertFatal(((format < 2)&&(nr_bit<3)&&(actual_payload<4)) || - ((format == 2)&&(nr_bit>2)&&(nr_bit<12)),"illegal combination format %d, nr_bit %d\n", + ((format == 2)&&(nr_bit>2)&&(nr_bit<65)),"illegal combination format %d, nr_bit %d\n", format,nr_bit); actual_payload &= ((1<