From b307044345b7d84153c18af43e6bad2ab151fd18 Mon Sep 17 00:00:00 2001 From: Roberto Louro Magueta Date: Wed, 8 Mar 2023 15:41:18 +0000 Subject: [PATCH] Decode PUCCH2 for polarParams->N = 64 --- .../CODING/nrPolar_tools/nr_polar_encoder.c | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 4cba3fe078..ad77a61a02 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -342,7 +342,8 @@ void build_polar_tables(t_nrPolar_params *polarParams) { } } - AssertFatal(polarParams->N==512 || polarParams->N==256 || polarParams->N==128,"N = %d, not done yet\n",polarParams->N); + AssertFatal(polarParams->N == 512 || polarParams->N == 256 || polarParams->N == 128 || polarParams->N == 64, "N = %d, not done yet\n", polarParams->N); + // build G bit vectors for information bit positions and convert the bit as bytes tables in nr_polar_kronecker_power_matrices.c to 64 bit packed vectors. // keep only rows of G which correspond to information/crc bits polarParams->G_N_tab = (uint64_t **)calloc((polarParams->K + polarParams->n_pc),sizeof(int64_t *)); @@ -410,19 +411,34 @@ void build_polar_tables(t_nrPolar_params *polarParams) { firstingroup_in,firstingroup_in+ccnt, firstingroup_out,firstingroup_out+ccnt); #endif - AssertFatal(mingroupsize==4 || mingroupsize==8 || mingroupsize==16,"mingroupsize %d, needs to be handled\n",mingroupsize); - polarParams->groupsize=mingroupsize; - int shift=3; - if (mingroupsize == 16) shift=4; - else if (mingroupsize == 4) shift=2; + polarParams->groupsize = mingroupsize; + + int shift = 0; + switch (mingroupsize) { + case 2: + shift = 1; + break; + case 4: + shift = 2; + break; + case 8: + shift = 3; + break; + case 16: + shift = 4; + break; + default: + AssertFatal(1 == 0, "mingroupsize = %i is not supported\n", mingroupsize); + break; + } + + polarParams->rm_tab = (int *)malloc(sizeof(int) * (polarParams->encoderLength >> shift)); - polarParams->rm_tab=(int *)malloc(sizeof(int)*polarParams->encoderLength/mingroupsize); // rerun again to create groups - int tcnt=0; - - for (int outpos=0; outposencoderLength; outpos+=mingroupsize,tcnt++) - polarParams->rm_tab[tcnt] = polarParams->rate_matching_pattern[outpos]>>shift; + int tcnt = 0; + for (int outpos = 0; outpos < polarParams->encoderLength; outpos += mingroupsize, tcnt++) + polarParams->rm_tab[tcnt] = polarParams->rate_matching_pattern[outpos] >> shift; } void polar_encoder_fast(uint64_t *A, @@ -699,6 +715,11 @@ void polar_encoder_fast(uint64_t *A, #endif } } + } else if (polarParams->N == 64) { + for (int i = 0; i < ((len > 63) ? 64 : len); i++) { + Cprime_i = -((Cprime[0] >> i) & 1); + D[0] ^= (Cprime_i & polarParams->G_N_tab[off + i][0]); + } } memset((void*)out,0,polarParams->encoderLength>>3); polar_rate_matching(polarParams,(void *)D, out);