diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 9f3ddf97a8b04f3e90c709c36918a46dd6c4db49..f412be12714a9e90e5a3a117d45d9e441d2dd155 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 8353d0f21ed9696756eb31b38bb14c54f071ef79..f1b72ae897125607d897af90fde67e043bbe2e0d 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 5f019146f35f98b2c84916a4ed9005a84ce2af61..2891a3399b0401103baf719beb0d975bdb18b175 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 87da29c48ed7a576e565c06b3824b094e5ec44ec..e238c7b84f3c911671529dd37a73f5bd2bc7397d 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"); }