From 88d5bf42f8aa309010109b48e6d043aaf8885ca8 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 13 Oct 2018 16:05:43 +0200 Subject: [PATCH] 16-bit llr decoder integrated --- openair1/PHY/CODING/TESTBENCH/polartest.c | 39 ++++++++++++------- .../CODING/nrPolar_tools/nr_polar_decoder.c | 6 +-- .../nrPolar_tools/nr_polar_decoding_tools.c | 16 ++++++-- openair1/PHY/CODING/nr_polar_init.c | 3 ++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 9f3ddf97a8..f412be1271 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -151,7 +151,9 @@ int main(int argc, char *argv[]) { uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength); double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input double *channelOutput = malloc (sizeof(double) * coderLength); //add noise - + int16_t *channelOutput_int16; + if (decoder_int16 == 1) channelOutput_int16 = (int16_t*)malloc (sizeof(int16_t) * coderLength); + t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); @@ -323,13 +325,6 @@ int main(int argc, char *argv[]) { /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ -/* - if (decoder_int16==1) { - if (channelOutput[i] > 15) channelOutput_int8[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int8[i] = -128; - else channelOutput_int8[i] = (int16_t) (8*channelOutput[i]); - } -*/ //Bit-to-byte: nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); @@ -341,6 +336,15 @@ int main(int argc, char *argv[]) { modulatedInput[i]=(-1)/sqrt(2); channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); + + + if (decoder_int16==1) { + if (channelOutput[i] > 15) channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; + else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); + } + + } start_meas(&timeDecoder); @@ -350,12 +354,19 @@ int main(int argc, char *argv[]) { NR_POLAR_DECODER_LISTSIZE, aPrioriArray, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); + if (decoder_int16==0) + decoderState = polar_decoder_aPriori(channelOutput, + estimatedOutput, + currentPtr, + NR_POLAR_DECODER_LISTSIZE, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + aPrioriArray); + else + decoderState = polar_decoder_int16(channelOutput_int16, + estimatedOutput, + currentPtr); + + stop_meas(&timeDecoder); /*printf("testInput: [0]->0x%08x\n", testInput[0]); printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 8353d0f21e..f1b72ae897 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -1039,7 +1039,7 @@ int8_t polar_decoder_dci(double *input, int8_t polar_decoder_int16(int16_t *input, - uint8_t *output, + uint8_t *out, t_nrPolar_params *polarParams) { @@ -1069,9 +1069,9 @@ int8_t polar_decoder_int16(int16_t *input, nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); //Remove the CRC (รข) - for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_B[j]; - + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 5f019146f3..2891a3399b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -34,6 +34,7 @@ #include "PHY/sse_intrin.h" #include "PHY/impl_defs_top.h" +//#define DEBUG_NEW_IMPL void updateLLR(double ***llr, uint8_t **llrU, @@ -266,7 +267,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { for (int i=0;iNv;i++) printf("i%d (frozen %d): alpha_v[i] = %d\n",i,1-pp->information_bit_pattern[node->first_leaf_index+i],alpha_v[i]); #endif - + if (node->left->all_frozen == 0) { @@ -275,7 +276,8 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { if (avx2mod == 0) { __m256i a256,b256,absa256,absb256,minabs256; int avx2len = node->Nv/2/16; - + + // printf("avx2len %d\n",avx2len); for (int i=0;iNv/2)]); + */ } } else if (avx2mod == 8) { @@ -315,6 +324,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { absb=(b+maskb)^maskb; minabs = absaNv == 2) { // apply hard decision on left node @@ -368,7 +378,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { betar[0] = (alpha_r[0]>0) ? -1 : 1; pp->nr_polar_U[node->first_leaf_index+1] = (1+betar[0])>>1; #ifdef DEBUG_NEW_IMPL - printf("Setting bit %d to %d (LLR %d frozen_mask %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0],frozen_mask); + printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]); #endif } } diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 87da29c48e..e238c7b84f 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -147,6 +147,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, free(J); + build_decoder_tree(newPolarInitNode); + printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes); + } else { AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); } -- GitLab