Commit d6b7b6b9 authored by rmagueta's avatar rmagueta

Q_PC_N computation for n_pc_wm = 0

parent 98ed514c
...@@ -251,12 +251,14 @@ void nr_polar_interleaving_pattern(uint16_t K, ...@@ -251,12 +251,14 @@ void nr_polar_interleaving_pattern(uint16_t K,
void nr_polar_info_bit_pattern(uint8_t *ibp, void nr_polar_info_bit_pattern(uint8_t *ibp,
int16_t *Q_I_N, int16_t *Q_I_N,
int16_t *Q_F_N, int16_t *Q_F_N,
uint16_t *J, int16_t *Q_PC_N,
const uint16_t *J,
const uint16_t *Q_0_Nminus1, const uint16_t *Q_0_Nminus1,
uint16_t K, uint16_t K,
uint16_t N, uint16_t N,
uint16_t E, 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, void nr_polar_info_bit_extraction(uint8_t *input,
uint8_t *output, uint8_t *output,
......
...@@ -138,14 +138,16 @@ void nr_polar_channel_interleaver_pattern(uint16_t *cip, ...@@ -138,14 +138,16 @@ void nr_polar_channel_interleaver_pattern(uint16_t *cip,
void nr_polar_info_bit_pattern(uint8_t *ibp, void nr_polar_info_bit_pattern(uint8_t *ibp,
int16_t *Q_I_N, int16_t *Q_I_N,
int16_t *Q_F_N, int16_t *Q_F_N,
uint16_t *J, int16_t *Q_PC_N,
const uint16_t *Q_0_Nminus1, const uint16_t *J,
uint16_t K, const uint16_t *Q_0_Nminus1,
uint16_t N, uint16_t K,
uint16_t E, uint16_t N,
uint8_t n_PC) 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_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. 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, ...@@ -159,44 +161,44 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
uint16_t limit, ind; uint16_t limit, ind;
if (E < N) { 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++) { for (int n = 0; n <= N - E - 1; n++) {
ind = Q_Ftmp_N[N] + 1; ind = Q_Ftmp_N[N] + 1;
Q_Ftmp_N[ind] = J[n]; Q_Ftmp_N[ind] = J[n];
Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1;
} }
if ((E / (double) N) >= (3.0 / 4)) { if ((E / (double)N) >= (3.0 / 4)) {
limit = ceil((double) (3 * N - 2 * E) / 4); limit = ceil((double)(3 * N - 2 * E) / 4);
for (int n = 0; n <= limit - 1; n++) { for (int n = 0; n <= limit - 1; n++) {
ind = Q_Ftmp_N[N] + 1; ind = Q_Ftmp_N[N] + 1;
Q_Ftmp_N[ind] = n; Q_Ftmp_N[ind] = n;
Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1;
} }
} else { } else {
limit = ceil((double) (9 * N - 4 * E) / 16); limit = ceil((double)(9 * N - 4 * E) / 16);
for (int n = 0; n <= limit - 1; n++) { for (int n = 0; n <= limit - 1; n++) {
ind = Q_Ftmp_N[N] + 1; ind = Q_Ftmp_N[N] + 1;
Q_Ftmp_N[ind] = n; Q_Ftmp_N[ind] = n;
Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1;
} }
} }
} else { //shortening } else { // shortening
for (int n = E; n <= N - 1; n++) { for (int n = E; n <= N - 1; n++) {
ind = Q_Ftmp_N[N] + 1; ind = Q_Ftmp_N[N] + 1;
Q_Ftmp_N[ind] = J[n]; Q_Ftmp_N[ind] = J[n];
Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; 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++) { for (int n = 0; n <= N - 1; n++) {
flag = 1; flag = 1;
for (int m = 0; m <= Q_Ftmp_N[N]; m++) { for (int m = 0; m <= Q_Ftmp_N[N]; m++) {
if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) {
flag = 0; flag = 0;
break; break;
} }
} }
if (flag) { if (flag) {
...@@ -205,19 +207,26 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -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++) { for (int n = 0; n <= (K + n_PC) - 1; n++) {
ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1);
Q_I_N[n] = Q_Itmp_N[ind]; 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++) { for (int n = 0; n <= N - 1; n++) {
flag = 1; flag = 1;
for (int m = 0; m <= (K + n_PC) - 1; m++) { for (int m = 0; m <= (K + n_PC) - 1; m++) {
if (Q_0_Nminus1[n] == Q_I_N[m]) { if (Q_0_Nminus1[n] == Q_I_N[m]) {
flag = 0; flag = 0;
break; break;
} }
} }
if (flag) { if (flag) {
...@@ -226,14 +235,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -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++) { for (int n = 0; n <= N - 1; n++) {
ibp[n] = 0; ibp[n] = 0;
for (int m = 0; m <= (K + n_PC) - 1; m++) { for (int m = 0; m <= (K + n_PC) - 1; m++) {
if (n == Q_I_N[m]) { if (n == Q_I_N[m]) {
ibp[n] = 1; ibp[n] = 1;
break; break;
} }
} }
} }
......
...@@ -244,12 +244,15 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui ...@@ -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, nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern,
newPolarInitNode->Q_I_N, newPolarInitNode->Q_I_N,
newPolarInitNode->Q_F_N, newPolarInitNode->Q_F_N,
newPolarInitNode->Q_PC_N,
J, J,
newPolarInitNode->Q_0_Nminus1, newPolarInitNode->Q_0_Nminus1,
newPolarInitNode->K, newPolarInitNode->K,
newPolarInitNode->N, newPolarInitNode->N,
newPolarInitNode->encoderLength, newPolarInitNode->encoderLength,
newPolarInitNode->n_pc); newPolarInitNode->n_pc,
newPolarInitNode->n_pc_wm);
// sort the Q_I_N array in ascending order (first K positions) // sort the Q_I_N array in ascending order (first K positions)
qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp); qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp);
newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment