diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 225990133e..a2413d75b9 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -251,12 +251,14 @@ void nr_polar_interleaving_pattern(uint16_t K, void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N, - uint16_t *J, + int16_t *Q_PC_N, + const uint16_t *J, const uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E, - uint8_t n_PC); + uint8_t n_PC, + uint8_t n_pc_wm); void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index 75ae8805ab..91e4ef3158 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -138,14 +138,16 @@ void nr_polar_channel_interleaver_pattern(uint16_t *cip, void nr_polar_info_bit_pattern(uint8_t *ibp, - int16_t *Q_I_N, - int16_t *Q_F_N, - uint16_t *J, - const uint16_t *Q_0_Nminus1, - uint16_t K, - uint16_t N, - uint16_t E, - uint8_t n_PC) + int16_t *Q_I_N, + int16_t *Q_F_N, + int16_t *Q_PC_N, + const uint16_t *J, + const uint16_t *Q_0_Nminus1, + uint16_t K, + uint16_t N, + uint16_t E, + uint8_t n_PC, + uint8_t n_pc_wm) { int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final int16_t *Q_Itmp_N = malloc(sizeof(int16_t) * (N + 1)); // array index assigned a value. @@ -159,44 +161,44 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, uint16_t limit, ind; if (E < N) { - if ((K / (double) E) <= (7.0 / 16)) { //puncturing + if ((K / (double)E) <= (7.0 / 16)) { // puncturing for (int n = 0; n <= N - E - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = J[n]; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; } - if ((E / (double) N) >= (3.0 / 4)) { - limit = ceil((double) (3 * N - 2 * E) / 4); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } + if ((E / (double)N) >= (3.0 / 4)) { + limit = ceil((double)(3 * N - 2 * E) / 4); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } } else { - limit = ceil((double) (9 * N - 4 * E) / 16); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } + limit = ceil((double)(9 * N - 4 * E) / 16); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } } - } else { //shortening + } else { // shortening for (int n = E; n <= N - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = J[n]; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; } } } - //Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N + // Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N for (int n = 0; n <= N - 1; n++) { flag = 1; for (int m = 0; m <= Q_Ftmp_N[N]; m++) { if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { - flag = 0; - break; + flag = 0; + break; } } if (flag) { @@ -205,19 +207,26 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, } } - //Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N + // Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N for (int n = 0; n <= (K + n_PC) - 1; n++) { ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); Q_I_N[n] = Q_Itmp_N[ind]; } - //Q_F_N = Q_0_N-1 \ Q_I_N + if (n_PC > 0) { + AssertFatal(n_pc_wm == 0, "Q_PC_N computation for n_pc_wm = %i is not implemented yet!\n", n_pc_wm); + for (int n = 0; n < n_PC - n_pc_wm; n++) { + Q_PC_N[n] = Q_I_N[n]; + } + } + + // Q_F_N = Q_0_N-1 \ Q_I_N for (int n = 0; n <= N - 1; n++) { flag = 1; for (int m = 0; m <= (K + n_PC) - 1; m++) { if (Q_0_Nminus1[n] == Q_I_N[m]) { - flag = 0; - break; + flag = 0; + break; } } if (flag) { @@ -226,14 +235,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, } } - //Information Bit Pattern + // Information Bit Pattern for (int n = 0; n <= N - 1; n++) { ibp[n] = 0; for (int m = 0; m <= (K + n_PC) - 1; m++) { if (n == Q_I_N[m]) { - ibp[n] = 1; - break; + ibp[n] = 1; + break; } } } diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 4a88417a13..ea01177c58 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -244,12 +244,15 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern, newPolarInitNode->Q_I_N, newPolarInitNode->Q_F_N, + newPolarInitNode->Q_PC_N, J, newPolarInitNode->Q_0_Nminus1, newPolarInitNode->K, newPolarInitNode->N, newPolarInitNode->encoderLength, - newPolarInitNode->n_pc); + newPolarInitNode->n_pc, + newPolarInitNode->n_pc_wm); + // sort the Q_I_N array in ascending order (first K positions) qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp); newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);