From 59c4ddef2454b801859349248ec2dfa00eaa0ed4 Mon Sep 17 00:00:00 2001 From: Raymond Knopp <raymond.knopp@eurecom.fr> Date: Mon, 1 Oct 2018 02:30:29 +0200 Subject: [PATCH] completed most of code generation tool for polar decoder integrated into "polartest" --- .../CODING/nrPolar_tools/nr_polar_decoder.c | 203 ++++++++++-------- .../nrPolar_tools/nr_polar_decoding_tools.c | 155 +++++++------ .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 4 +- 3 files changed, 186 insertions(+), 176 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index e1b248b27e..24d3a8d404 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -30,7 +30,6 @@ #include "PHY/TOOLS/time_meas.h" - int8_t polar_decoder( double *input, uint8_t *output, @@ -294,6 +293,92 @@ int8_t polar_decoder( } +#define decoder_int8_A(sorted_dlist,currentListSize,polarParams) {for (int i = 0; i < currentListSize; i++) { \ + for (int k = 0; k < (polarParams->n+1); k++) { \ + memcpy((void*)&sorted_dlist[i+currentListSize]->bit[k][0],\ + (void*)&sorted_dlist[i]->bit[k][0],\ + sizeof(uint8_t)*polarParams->N);\ + memcpy((void*)&sorted_dlist[i+currentListSize]->llr[k][0],\ + (void*)&sorted_dlist[i]->llr[k][0],\ + sizeof(int16_t)*polarParams->N);}}} + +#define decoder_int8_B(sorted_dlist,currentListSize) {for (int i = 0; i < currentListSize; i++) {sorted_dlist[i]->bit[0][currentBit]=0;sorted_dlist[i+currentListSize]->bit[0][currentBit]=1;}} + +void inline decoder_int8_C(decoder_list_int8_t *sorted_dlist[], + t_nrPolar_params *polarParams, + int currentBit, + int currentListSize, + int listSize) { + + int32_t pathMetric[2*listSize]; + decoder_list_int8_t *temp_dlist[2*listSize]; + + int listIndex[2*listSize]; + int listIndex2[2*listSize]; + + for (int i = 0; i < currentListSize; i++) { + listIndex[i]=i; + pathMetric[i] = sorted_dlist[i]->pathMetric; + } + nr_sort_asc_int16_1D_array_ind(pathMetric, listIndex, currentListSize); + for (int i=0;i<currentListSize;i++) { + listIndex2[listIndex[i]] = i; + } + + // copy the llr/bit arrays that are needed + for (int i = 0; i < listSize; i++) { + // printf("listIndex[%d] %d\n",i,listIndex[i]); + if ((listIndex2[i+listSize]<listSize) && (listIndex2[i]<listSize)) { // both '0' and '1' path metrics are to be kept + // do memcpy of LLR and Bit arrays + + for (int k = 0; k < (polarParams->n+1); k++) { + + memcpy((void*)&sorted_dlist[i+listSize]->bit[k][0], + (void*)&sorted_dlist[i]->bit[k][0], + sizeof(uint8_t)*polarParams->N); + memcpy((void*)&sorted_dlist[i+listSize]->llr[k][0], + (void*)&sorted_dlist[i]->llr[k][0], + sizeof(int16_t)*polarParams->N); + } + sorted_dlist[i]->bit[0][currentBit]=0; + sorted_dlist[i+listSize]->bit[0][currentBit]=1; + } + else if (listIndex2[i+listSize]<listSize) { // only '1' path metric is to be kept + // just change the current bit from '0' to '1' + + for (int k = 0; k < (polarParams->n+1); k++) { + memcpy((void*)&sorted_dlist[i+listSize]->bit[k][0], + (void*)&sorted_dlist[i]->bit[k][0], + sizeof(uint8_t)*polarParams->N); + memcpy((void*)&sorted_dlist[i+listSize]->llr[k][0], + (void*)&sorted_dlist[i]->llr[k][0], + sizeof(int16_t)*polarParams->N); + } + sorted_dlist[i+listSize]->bit[0][currentBit]=1; + + /* + decoder_list_t *tmp = sorted_dlist[i+listSize]; + sorted_dlist[i+listSize] = sorted_dlist[i]; + sorted_dlist[i+listSize]->pathMetric = tmp->pathMetric; + sorted_dlist[i+listSize]->bit[0][currentBit]=1; + memcpy((void*)&sorted_dlist[i+listSize]->crcChecksum[0], + (void*)&tmp->crcChecksum[0], + 24*sizeof(uint8_t));*/ + + } + } + + + + for (int i = 0; i < 2*listSize; i++) { + temp_dlist[i] = sorted_dlist[i]; + } + for (int i = 0; i < 2*listSize; i++) { + // printf("i %d => %d\n",i,listIndex[i]); + sorted_dlist[i] = temp_dlist[listIndex[i]]; + } +} + int8_t polar_decoder_int8(int16_t *input, uint8_t *output, t_nrPolar_params *polarParams, @@ -380,12 +465,9 @@ int8_t polar_decoder_int8(int16_t *input, uint8_t currentListSize=1; decoder_list_int8_t *sorted_dlist[2*listSize]; - decoder_list_int8_t *temp_dlist[2*listSize]; - int listIndex[2*listSize]; - int32_t pathMetric[2*listSize]; - + for (uint8_t i = 0; i < 2*listSize; i++) sorted_dlist[i] = &dlist[i]; - + for (uint16_t currentBit=0; currentBit<polarParams->N; currentBit++){ // printf("***************** BIT %d (currentListSize %d, information_bit_pattern %d)\n", // currentBit,currentListSize,polarParams->information_bit_pattern[currentBit]); @@ -402,110 +484,45 @@ int8_t polar_decoder_int8(int16_t *input, stop_meas(path_metric); start_meas(sorting); - - // for (int i=0;i<currentListSize;i++) { - // printf("sorted_dlist[%d] pathmetric %d\n",i,sorted_dlist[i]->pathMetric); - // } + if (currentListSize <= listSize/2) { // until listsize is full we need to copy bit and LLR arrays to new entries // below we only copy the ones we need to keep for sure + decoder_int8_A(sorted_dlist,currentListSize,polarParams); +#ifdef SHOWCOMP + printf("decoder_int8_A(sorted_dlist,%d,polarParams);\n",currentListSize); +#endif + } + decoder_int8_B(sorted_dlist,currentListSize); +#ifdef SHOWCOMP + printf("decoder_int8_B(sorted_dlist,%d);\n",currentListSize); +#endif - for (int i = 0; i < currentListSize; i++) { - for (int k = 0; k < (polarParams->n+1); k++) { - - memcpy((void*)&sorted_dlist[i+currentListSize]->bit[k][0], - (void*)&sorted_dlist[i]->bit[k][0], - sizeof(uint8_t)*polarParams->N); - memcpy((void*)&sorted_dlist[i+currentListSize]->llr[k][0], - (void*)&sorted_dlist[i]->llr[k][0], - sizeof(int16_t)*polarParams->N); - } - } - } - - for (int i = 0; i < currentListSize; i++) { - sorted_dlist[i]->bit[0][currentBit]=0; - sorted_dlist[i+currentListSize]->bit[0][currentBit]=1; - } bitUpdated[currentBit][0]=1; + updateCrcChecksum2_int8(sorted_dlist,extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); currentListSize*=2; //Keep only the best "listSize" number of entries. if (currentListSize > listSize) { - int listIndex2[listSize]; - - for (int i = 0; i < currentListSize; i++) { - listIndex[i]=i; - pathMetric[i] = sorted_dlist[i]->pathMetric; - } - nr_sort_asc_int16_1D_array_ind(pathMetric, listIndex, currentListSize); - for (int i=0;i<currentListSize;i++) { - listIndex2[listIndex[i]] = i; - } - - // copy the llr/bit arrays that are needed - for (int i = 0; i < listSize; i++) { - // printf("listIndex[%d] %d\n",i,listIndex[i]); - if ((listIndex2[i+listSize]<listSize) && (listIndex2[i]<listSize)) { // both '0' and '1' path metrics are to be kept - // do memcpy of LLR and Bit arrays - - for (int k = 0; k < (polarParams->n+1); k++) { - - memcpy((void*)&sorted_dlist[i+listSize]->bit[k][0], - (void*)&sorted_dlist[i]->bit[k][0], - sizeof(uint8_t)*polarParams->N); - memcpy((void*)&sorted_dlist[i+listSize]->llr[k][0], - (void*)&sorted_dlist[i]->llr[k][0], - sizeof(int16_t)*polarParams->N); - } - sorted_dlist[i]->bit[0][currentBit]=0; - sorted_dlist[i+listSize]->bit[0][currentBit]=1; - } - else if (listIndex2[i+listSize]<listSize) { // only '1' path metric is to be kept - // just change the current bit from '0' to '1' - - for (int k = 0; k < (polarParams->n+1); k++) { - memcpy((void*)&sorted_dlist[i+listSize]->bit[k][0], - (void*)&sorted_dlist[i]->bit[k][0], - sizeof(uint8_t)*polarParams->N); - memcpy((void*)&sorted_dlist[i+listSize]->llr[k][0], - (void*)&sorted_dlist[i]->llr[k][0], - sizeof(int16_t)*polarParams->N); - } - sorted_dlist[i+listSize]->bit[0][currentBit]=1; - - /* - decoder_list_t *tmp = sorted_dlist[i+listSize]; - sorted_dlist[i+listSize] = sorted_dlist[i]; - sorted_dlist[i+listSize]->pathMetric = tmp->pathMetric; - sorted_dlist[i+listSize]->bit[0][currentBit]=1; - memcpy((void*)&sorted_dlist[i+listSize]->crcChecksum[0], - (void*)&tmp->crcChecksum[0], - 24*sizeof(uint8_t));*/ - - } - } - + + decoder_int8_C(sorted_dlist, + polarParams, + currentBit, + currentListSize, + listSize); currentListSize = listSize; - - for (int i = 0; i < 2*listSize; i++) { - temp_dlist[i] = sorted_dlist[i]; - } - for (int i = 0; i < 2*listSize; i++) { - // printf("i %d => %d\n",i,listIndex[i]); - sorted_dlist[i] = temp_dlist[listIndex[i]]; - } } - stop_meas(sorting); + stop_meas(sorting); + nonFrozenBit++; - } + } - } + } + - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { // printf("list index %d :",i); 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 6cc67965fb..206dfb955f 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -32,9 +32,6 @@ inline void computeLLR(double llr[1+nmax][Nmax], uint16_t row, uint16_t col, double absA,absB; -#ifdef SHOWCOMP - printf("computeLLR (%d,%d,%d)\n",row,col,offset); -#endif a = llr[col + 1][row]; b = llr[col+1][row + offset]; @@ -60,7 +57,7 @@ inline void computeLLR_int8(int16_t llr[1+nmax][Nmax], uint16_t row, uint16_t co int16_t minabs; #ifdef SHOWCOMP - printf("computeLLR_int8 (%d,%d,%d)\n",row,col,offset); + printf("computeLLR_int8(llr,%d,%d,%d);\n",row,col,offset); #endif a = llr[col + 1][row]; b = llr[col+1][row + offset]; @@ -87,13 +84,7 @@ void updateLLR(decoder_list_t **dlist,uint8_t **llrU, uint8_t **bitU, if (llrU[row-offset][col+1]==0) updateLLR(dlist, llrU, bitU, listSize, (row-offset), (col+1), xlen, ylen, approximation); if (llrU[row][col+1]==0) updateLLR(dlist, llrU, bitU, listSize, row, (col+1), xlen, ylen, approximation); for (uint8_t i=0; i<listSize; i++) { -#ifdef SHOWCOMP - printf("updatingLLR (%d,%d,%d) (bit %d,%d,%d, llr0 %d,%d,%d, llr1 %d,%d,%d \n",row,col,i, - row-offset,col,i,row-offset,col+1,i,row,col+1,i); -#endif dlist[i]->llr[col][row] = (pow((-1),dlist[i]->bit[col][row-offset])*dlist[i]->llr[col+1][row-offset]) + dlist[i]->llr[col+1][row]; - // printf("updating dlist[%d]->llr[%d][%d] => %f (%f,%f) offset %d\n",i,col,row,32*dlist[i]->llr[col][row], - // (pow((-1),dlist[i]->bit[col][row-offset])*32*dlist[i]->llr[col+1][row-offset]),32*dlist[i]->llr[col+1][row],offset); } } else { if (llrU[row][col+1]==0) updateLLR(dlist, llrU, bitU, listSize, row, (col+1), xlen, ylen, approximation); @@ -104,6 +95,9 @@ void updateLLR(decoder_list_t **dlist,uint8_t **llrU, uint8_t **bitU, llrU[row][col]=1; } +#define updateLLR_int8_A(dlist,i,col,row,offset) if (dlist[(i)]->bit[(col)][(row)-(offset)]==0) dlist[(i)]->llr[(col)][(row)] = dlist[(i)]->llr[(col)+1][(row)-(offset)] + dlist[(i)]->llr[(col)+1][(row)]; else dlist[(i)]->llr[(col)][(row)] = -dlist[(i)]->llr[(col)+1][(row)-(offset)] + dlist[(i)]->llr[(col)+1][(row)]; + + void updateLLR_int8(decoder_list_int8_t **dlist,uint8_t **llrU, uint8_t **bitU, uint8_t listSize, uint16_t row, uint16_t col, uint16_t xlen, uint8_t ylen) { uint16_t offset = (xlen/(1<<(ylen-col-1))); @@ -111,18 +105,19 @@ void updateLLR_int8(decoder_list_int8_t **dlist,uint8_t **llrU, uint8_t **bitU, if (bitU[row-offset][col]==0) updateBit_int8(dlist, bitU, listSize, (row-offset), col, xlen, ylen); if (llrU[row-offset][col+1]==0) updateLLR_int8(dlist, llrU, bitU, listSize, (row-offset), (col+1), xlen, ylen); if (llrU[row][col+1]==0) updateLLR_int8(dlist, llrU, bitU, listSize, row, (col+1), xlen, ylen); + + for (uint8_t i=0; i<listSize; i++) { #ifdef SHOWCOMP - printf("updatingLLR_int8 (%d,%d,%d) (bit %d,%d,%d, llr0 %d,%d,%d, llr1 %d,%d,%d \n",row,col,i, - row-offset,col,i,row-offset,col+1,i,row,col+1,i); + printf("updateLLR_int8_A(dlist,%d,%d,%d,%d);\n",i,row,col,offset); #endif + updateLLR_int8_A(dlist,i,col,row,offset); + /* if (dlist[i]->bit[col][row-offset]==0) dlist[i]->llr[col][row] = dlist[i]->llr[col+1][row-offset] + dlist[i]->llr[col+1][row]; else - dlist[i]->llr[col][row] = -dlist[i]->llr[col+1][row-offset] + dlist[i]->llr[col+1][row]; - // printf("updating dlist[%d]->llr[%d][%d] => %d (%d,%d) offset %d\n",i,col,row,dlist[i]->llr[col][row], - // (dlist[i]->bit[col][row-offset]==0 ? 1 : -1)*dlist[i]->llr[col+1][row-offset],dlist[i]->llr[col+1][row], offset); - } + dlist[i]->llr[col][row] = -dlist[i]->llr[col+1][row-offset] + dlist[i]->llr[col+1][row];*/ + } } else { if (llrU[row][col+1]==0) updateLLR_int8(dlist, llrU, bitU, listSize, row, (col+1), xlen, ylen); if (llrU[row+offset][col+1]==0) updateLLR_int8(dlist, llrU, bitU, listSize, (row+offset), (col+1), xlen, ylen); @@ -140,25 +135,19 @@ void updateBit(decoder_list_t **dlist, uint8_t **bitU, uint8_t listSize, uint16_ if (( (row) % (2*offset) ) >= offset ) { if (bitU[row][col-1]==0) updateBit(dlist, bitU, listSize, row, (col-1), xlen, ylen); dlist[i]->bit[col][row] = dlist[i]->bit[col-1][row]; -#ifdef SHOWCOMP - printf("updating bit (%d,%d,%d) from (%d,%d,%d)\n", - row,col,i,row,col-1,i); -#endif } else { if (bitU[row][col-1]==0) updateBit(dlist, bitU, listSize, row, (col-1), xlen, ylen); if (bitU[row+offset][col-1]==0) updateBit(dlist, bitU, listSize, (row+offset), (col-1), xlen, ylen); dlist[i]->bit[col][row] = ( (dlist[i]->bit[col-1][row]+dlist[i]->bit[col-1][row+offset]) % 2); - // printf("updating dlist[%d]->bit[%d][%d] => %d\n",i,col,row,dlist[i]->bit[col][row]); -#ifdef SHOWCOMP - printf("updating bit (%d,%d,%d) from (%d,%d,%d)+(%d,%d,%d)\n", - row,col,i,row,col-1,i,row+offset,col-1,i); -#endif } } bitU[row][col]=1; } +#define updateBit_int8_A(dlist,i,col,row) dlist[(i)]->bit[(col)][(row)] = dlist[(i)]->bit[(col)-1][(row)] +#define updateBit_int8_B(dlist,i,col,row,offset) dlist[(i)]->bit[(col)][(row)] = dlist[(i)]->bit[(col)-1][(row)]^dlist[(i)]->bit[(col)-1][(row)+(offset)] + void updateBit_int8(decoder_list_int8_t **dlist, uint8_t **bitU, uint8_t listSize, uint16_t row, uint16_t col, uint16_t xlen, uint8_t ylen) { uint16_t offset = ( xlen/(pow(2,(ylen-col))) ); @@ -166,71 +155,66 @@ void updateBit_int8(decoder_list_int8_t **dlist, uint8_t **bitU, uint8_t listSiz for (uint8_t i=0; i<listSize; i++) { if (( (row) % (2*offset) ) >= offset ) { if (bitU[row][col-1]==0) updateBit_int8(dlist, bitU, listSize, row, (col-1), xlen, ylen); - dlist[i]->bit[col][row] = dlist[i]->bit[col-1][row]; + // dlist[i]->bit[col][row] = dlist[i]->bit[col-1][row]; #ifdef SHOWCOMP - printf("updating bit (%d,%d,%d) from (%d,%d,%d)\n", - row,col,i,row,col-1,i); + printf("updateBit_int8_A(dlist,%d,%d,%d);\n",i,col,row); #endif + updateBit_int8_A(dlist,i,col,row); + } else { if (bitU[row][col-1]==0) updateBit_int8(dlist, bitU, listSize, row, (col-1), xlen, ylen); if (bitU[row+offset][col-1]==0) updateBit_int8(dlist, bitU, listSize, (row+offset), (col-1), xlen, ylen); - dlist[i]->bit[col][row] = dlist[i]->bit[col-1][row]^dlist[i]->bit[col-1][row+offset]; + // dlist[i]->bit[col][row] = dlist[i]->bit[col-1][row]^dlist[i]->bit[col-1][row+offset]; // printf("updating dlist[%d]->bit[%d][%d] => %d\n",i,col,row,dlist[i]->bit[col][row]); #ifdef SHOWCOMP - printf("updating bit (%d,%d,%d) from (%d,%d,%d)+(%d,%d,%d)\n", - row,col,i,row,col-1,i,row+offset,col-1,i); + printf("updateBit_int8_B(dlist,%d,%d,%d,%d);\n",i,col,row,offset); #endif + updateBit_int8_B(dlist,i,col,row,offset); } } bitU[row][col]=1; } - + void updatePathMetric(decoder_list_t **dlist,uint8_t listSize, uint8_t bitValue, - uint16_t row, uint8_t approximation) { - -#ifdef SHOWCOMP - printf("updating path_metric from Frozen bit (%d,%d) \n", - row,0); -#endif - - if (approximation) { //eq. (12) - for (uint8_t i=0; i<listSize; i++) { - if ((2*bitValue) != ( 1 - copysign(1.0,dlist[i]->llr[0][row]) )) dlist[i]->pathMetric += fabs(dlist[i]->llr[0][row]); - // printf("updatepathmetric : llr %f pathMetric %f (bitValue %d)\n",32*dlist[i]->llr[0][row],32*dlist[i]->pathMetric,bitValue); - } - } else { //eq. (11b) - int8_t multiplier = (2*bitValue) - 1; - for (uint8_t i=0; i<listSize; i++) { + uint16_t row, uint8_t approximation) { + + if (approximation) { //eq. (12) + for (uint8_t i=0; i<listSize; i++) { + if ((2*bitValue) != ( 1 - copysign(1.0,dlist[i]->llr[0][row]) )) dlist[i]->pathMetric += fabs(dlist[i]->llr[0][row]); + } + } else { //eq. (11b) + int8_t multiplier = (2*bitValue) - 1; + for (uint8_t i=0; i<listSize; i++) { dlist[i]->pathMetric += log ( 1 + exp(multiplier*dlist[i]->llr[0][row]) ) ; - // printf("updatepathmetric : llr %f pathMetric %f\n",32*dlist[i]->llr[0][row],32*dlist[i]->pathMetric); } - } - + } + } - + +#define updatePathMetric0_int8_A(dlist,i,row,mask,absllr) { mask=dlist[i]->llr[0][row]>>15;if(mask!=0){absllr=(dlist[i]->llr[0][row]+mask)^mask;dlist[i]->pathMetric+=absllr;}} void updatePathMetric0_int8(decoder_list_int8_t **dlist,uint8_t listSize, uint16_t row) { + int16_t mask,absllr; + for (uint8_t i=0; i<listSize; i++) { + + updatePathMetric0_int8_A(dlist,i,row,mask,absllr); #ifdef SHOWCOMP - printf("updating path_metric from Frozen bit (%d,%d) \n", - row,0); + printf("updatePathMetric0_int8_A(dlist,i,%d,%d);\n",listSize,row); #endif - int16_t mask; - for (uint8_t i=0; i<listSize; i++) { - // if ((2*bitValue) != ( 1 - copysign(1.0,dlist[i]->llr[0][row]) )) dlist[i]->pathMetric += fabs(dlist[i]->llr[0][row]); - // equiv: if ((llr>0 && bitValue==1) || (llr<0 && bitValue==0) ... - // equiv: (llr>>7 + bitValue) != 0, in opposite case (llr>8 + bitValue) = -1 or 1 - + + /* mask = dlist[i]->llr[0][row]>>15; if (mask != 0) { int16_t absllr = (dlist[i]->llr[0][row]+mask)^mask; dlist[i]->pathMetric += absllr; - } - // printf("updatepathmetric : llr %d, pathMetric %d (bitValue %d)\n",dlist[i]->llr[0][row],dlist[i]->pathMetric); - } + }*/ + + + } } @@ -241,10 +225,6 @@ void updatePathMetric2(decoder_list_t **dlist, uint8_t listSize, uint16_t row, u for (i=0;i<listSize;i++) dlist[i+listSize]->pathMetric = dlist[i]->pathMetric; decoder_list_t **dlist2 = &dlist[listSize]; -#ifdef SHOWCOMP - printf("updating path_metric from information bit (%d,%d) \n", - row,0); -#endif if (appr) { //eq. (12) for (i = 0; i < listSize; i++) { // bitValue=0 @@ -263,22 +243,23 @@ void updatePathMetric2(decoder_list_t **dlist, uint8_t listSize, uint16_t row, u } } +#define updatePathMetric2_int8_A(dlist,i,listSize,row) {dlist[i+listSize]->pathMetric = dlist[i]->pathMetric;if (dlist[i]->llr[0][row]<0) dlist[i]->pathMetric-=dlist[i]->llr[0][row];else dlist[i+listSize]->pathMetric += dlist[i]->llr[0][row];} + + void updatePathMetric2_int8(decoder_list_int8_t **dlist, uint8_t listSize, uint16_t row) { int i; - for (i=0;i<listSize;i++) dlist[i+listSize]->pathMetric = dlist[i]->pathMetric; - decoder_list_int8_t **dlist2 = &dlist[listSize]; + for (i = 0; i < listSize; i++) { #ifdef SHOWCOMP - printf("updating path_metric from information bit (%d,%d) \n", - row,0); + printf("updatePathMetric2_int8_A(dlist,%d,%d,%d);\n", + i,listSize,row); #endif - for (i = 0; i < listSize; i++) { - // bitValue=0 - if (dlist[i]->llr[0][row]<0) dlist[i]->pathMetric -= dlist[i]->llr[0][row]; - // bitValue=1 - else dlist2[i]->pathMetric += dlist[i]->llr[0][row]; + updatePathMetric2_int8_A(dlist,i,listSize,row); + // dlist[i+listSize]->pathMetric = dlist[i]->pathMetric; + //if (dlist[i]->llr[0][row]<0) dlist[i]->pathMetric -= dlist[i]->llr[0][row]; + //else dlist[i+listSize]->pathMetric += dlist[i]->llr[0][row]; } } @@ -301,20 +282,32 @@ void updateCrcChecksum2(decoder_list_t **dlist, uint8_t **crcGen, } } +#define updateCrcChecksum_int8_A(dlist,i,crcGen,i2,len) {for (uint8_t j = 0; j < len; j++) dlist[i]->crcChecksum[j] = (dlist[i]->crcChecksum[j]^crcGen[i2][j]);} + void updateCrcChecksum_int8(decoder_list_int8_t **dlist, uint8_t **crcGen, uint8_t listSize, uint32_t i2, uint8_t len) { for (uint8_t i = 0; i < listSize; i++) { - for (uint8_t j = 0; j < len; j++) { - dlist[i]->crcChecksum[j] = ( (dlist[i]->crcChecksum[j] + crcGen[i2][j]) % 2 ); - } +#ifdef SHOWCOMP + printf("updateCrcChecksum_int8_A(dlist,%d,crcGen,%d,%d);\n",i,i2,len); +#endif + updateCrcChecksum_int8_A(dlist,i,crcGen,i2,len); + // for (uint8_t j = 0; j < len; j++) { + // dlist[i]->crcChecksum[j] = ( (dlist[i]->crcChecksum[j] + crcGen[i2][j]) % 2 ); + // } } } +#define updateCrcChecksum2_int8_A(dlist,i,listSize,crcGen,i2,len) {for (uint8_t j = 0; j < len; j++) dlist[i+listSize]->crcChecksum[j]=dlist[i]->crcChecksum[j]^crcGen[i2][j];} + void updateCrcChecksum2_int8(decoder_list_int8_t **dlist, uint8_t **crcGen, uint8_t listSize, uint32_t i2, uint8_t len) { for (uint8_t i = 0; i < listSize; i++) { - for (uint8_t j = 0; j < len; j++) { - dlist[i+listSize]->crcChecksum[j] = ( (dlist[i]->crcChecksum[j] + crcGen[i2][j]) % 2 ); - } +#ifdef SHOWCOMP + printf("updateCrcChecksum2_int8_A(dlist,%d,%d,crcGen,%d,%d);\n",i,listSize,i2,len); +#endif + updateCrcChecksum2_int8_A(dlist,i,listSize,crcGen,i2,len); + // for (uint8_t j = 0; j < len; j++) { + // dlist[i+listSize]->crcChecksum[j] = ( (dlist[i]->crcChecksum[j] + crcGen[i2][j]) % 2 ); + // } } } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 43142864cb..c9339e308d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -147,8 +147,8 @@ typedef struct decoder_list_s { typedef struct decoder_list_int8_s { - uint8_t bit[1+nmax][Nmax]; - int16_t llr[1+nmax][Nmax]; + uint8_t bit[1+nmax][Nmax] __attribute__((aligned(32))); + int16_t llr[1+nmax][Nmax]__attribute__((aligned(32))); uint8_t crcChecksum[24]; int32_t pathMetric; -- 2.26.2