Commit 1465fed8 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/better-polar' into integration_2024_w21c

parents 12a1c8a8 ab2b868b
...@@ -801,7 +801,6 @@ set(PHY_POLARSRC ...@@ -801,7 +801,6 @@ set(PHY_POLARSRC
${OPENAIR1_DIR}/PHY/CODING/nr_polar_init.c ${OPENAIR1_DIR}/PHY/CODING/nr_polar_init.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_crc.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoder.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_encoder.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
......
...@@ -2217,7 +2217,6 @@ INPUT = \ ...@@ -2217,7 +2217,6 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrLDPC_encoder/ldpc_BG2_Zc352_byte_128.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrLDPC_encoder/ldpc_BG2_Zc352_byte_128.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_crc.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c \
......
...@@ -33,25 +33,25 @@ ...@@ -33,25 +33,25 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) {
uint8_t arrayInd = ceil(arraySize / 32.0); const uint arrayInd = ceil(arraySize / 32.0);
for (int i = 0; i < (arrayInd-1); i++) { for (int i = 0; i < (arrayInd - 1); i++) {
for (int j = 0; j < 32; j++) { for (int j = 0; j < 32; j++) {
out[j+(i*32)] = (in[i] >> j) & 1; out[j + (i * 32)] = (in[i] >> j) & 1;
} }
} }
for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) for (int j = 0; j < arraySize - ((arrayInd - 1) * 32); j++)
out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; out[j + ((arrayInd - 1) * 32)] = (in[(arrayInd - 1)] >> j) & 1;
} }
void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) {
uint8_t arrayInd = ceil(arraySize / 32.0); const uint arrayInd = ceil(arraySize / 32.0);
for (int i = 0; i < arrayInd; i++) { for (int i = 0; i < arrayInd; i++) {
out[i]=0; out[i] = 0;
for (int j = 31; j > 0; j--) { for (int j = 31; j > 0; j--) {
out[i]|=in[(i*32)+j]; out[i] |= in[(i * 32) + j];
out[i]<<=1; out[i] <<= 1;
} }
out[i]|=in[(i*32)]; out[i] |= in[(i * 32)];
} }
} }
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
void nr_polar_crc(uint8_t* a, uint8_t A, uint8_t P, uint8_t** G_P, uint8_t** b)
{
int i, j;
int* temp_b = (int*) malloc(sizeof(int)*P);
if (temp_b == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
printf("temp = ");
for(i=0; i<P; i++)
{
temp_b[i]=0;
for(j=0; j<A; j++)
{
temp_b[i]=temp_b[i] + a[j]*G_P[j][i];
}
temp_b[i]=temp_b[i]%2;
printf("%i ", temp_b[i]);
}
*b = (uint8_t*) malloc(sizeof(uint8_t)*(A+P));
if (*b == NULL)
{
fprintf(stderr, "malloc failed\n");
exit(-1);
}
printf("\nb = ");
for(i=0; i<A; i++)
{
(*b)[i]=a[i];
printf("%i", (*b)[i]);
}
for(i=A; i<A+P; i++)
{
(*b)[i]=temp_b[i-A];
printf("%i", (*b)[i]);
}
free(temp_b);
}
...@@ -45,9 +45,9 @@ static inline void updateBit(uint8_t listSize, ...@@ -45,9 +45,9 @@ static inline void updateBit(uint8_t listSize,
uint8_t bit[xlen][ylen][zlen], uint8_t bit[xlen][ylen][zlen],
uint8_t bitU[xlen][ylen]) uint8_t bitU[xlen][ylen])
{ {
uint16_t offset = (xlen / (pow(2, (ylen - col)))); const uint offset = (xlen / (pow(2, (ylen - col))));
for (uint8_t i = 0; i < listSize; i++) { for (uint i = 0; i < listSize; i++) {
if (((row) % (2 * offset)) >= offset) { if (((row) % (2 * offset)) >= offset) {
if (bitU[row][col - 1] == 0) if (bitU[row][col - 1] == 0)
updateBit(listSize, row, (col - 1), xlen, ylen, zlen, bit, bitU); updateBit(listSize, row, (col - 1), xlen, ylen, zlen, bit, bitU);
...@@ -89,8 +89,8 @@ void updateLLR(uint8_t listSize, ...@@ -89,8 +89,8 @@ void updateLLR(uint8_t listSize,
uint8_t bit[xlen][ylen][zlen], uint8_t bit[xlen][ylen][zlen],
uint8_t bitU[xlen][ylen]) uint8_t bitU[xlen][ylen])
{ {
uint16_t offset = (xlen / (pow(2, (ylen - col - 1)))); const uint offset = (xlen / (pow(2, (ylen - col - 1))));
for (uint8_t i = 0; i < listSize; i++) { for (uint i = 0; i < listSize; i++) {
if ((row % (2 * offset)) >= offset) { if ((row % (2 * offset)) >= offset) {
if (bitU[row - offset][col] == 0) if (bitU[row - offset][col] == 0)
updateBit(listSize, (row - offset), col, xlen, ylen, zlen, bit, bitU); updateBit(listSize, (row - offset), col, xlen, ylen, zlen, bit, bitU);
...@@ -122,10 +122,9 @@ void updatePathMetric(double *pathMetric, ...@@ -122,10 +122,9 @@ void updatePathMetric(double *pathMetric,
double llr[xlen][ylen][zlen] double llr[xlen][ylen][zlen]
) )
{ {
int8_t multiplier = (2*bitValue) - 1; const int multiplier = (2 * bitValue) - 1;
for (uint8_t i=0; i<listSize; i++) for (uint i = 0; i < listSize; i++)
pathMetric[i] += log ( 1 + exp(multiplier*llr[row][0][i]) ) ; //eq. (11b) pathMetric[i] += log(1 + exp(multiplier * llr[row][0][i])); // eq. (11b)
} }
void updatePathMetric2(double *pathMetric, void updatePathMetric2(double *pathMetric,
...@@ -139,16 +138,15 @@ void updatePathMetric2(double *pathMetric, ...@@ -139,16 +138,15 @@ void updatePathMetric2(double *pathMetric,
double tempPM[listSize]; double tempPM[listSize];
memcpy(tempPM, pathMetric, (sizeof(double) * listSize)); memcpy(tempPM, pathMetric, (sizeof(double) * listSize));
uint8_t bitValue = 0; uint bitValue = 0;
int8_t multiplier = (2 * bitValue) - 1; int multiplier = (2 * bitValue) - 1;
for (uint8_t i = 0; i < listSize; i++) for (uint i = 0; i < listSize; i++)
pathMetric[i] += log(1 + exp(multiplier * llr[row][0][i])); //eq. (11b) pathMetric[i] += log(1 + exp(multiplier * llr[row][0][i])); // eq. (11b)
bitValue = 1; bitValue = 1;
multiplier = (2 * bitValue) - 1; multiplier = (2 * bitValue) - 1;
for (uint8_t i = listSize; i < 2*listSize; i++) for (uint i = listSize; i < 2 * listSize; i++)
pathMetric[i] = tempPM[(i-listSize)] + log(1 + exp(multiplier * llr[row][0][(i-listSize)])); //eq. (11b) pathMetric[i] = tempPM[(i - listSize)] + log(1 + exp(multiplier * llr[row][0][(i - listSize)])); // eq. (11b)
} }
decoder_node_t *new_decoder_node(int first_leaf_index, int level) { decoder_node_t *new_decoder_node(int first_leaf_index, int level) {
...@@ -189,13 +187,13 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol ...@@ -189,13 +187,13 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol
for (int i=0;i<Nv;i++) { for (int i=0;i<Nv;i++) {
if (polarParams->information_bit_pattern[i+first_leaf_index]>0) { if (polarParams->information_bit_pattern[i+first_leaf_index]>0) {
all_frozen_below=0; all_frozen_below = 0;
break; break;
} }
} }
if (all_frozen_below==0) if (all_frozen_below==0)
new_node->left=add_nodes(level-1, first_leaf_index, polarParams); new_node->left = add_nodes(level - 1, first_leaf_index, polarParams);
else { else {
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("aggregating frozen bits %d ... %d at level %d (%s)\n",first_leaf_index,first_leaf_index+Nv-1,level,((first_leaf_index/Nv)&1)==0?"left":"right"); printf("aggregating frozen bits %d ... %d at level %d (%s)\n",first_leaf_index,first_leaf_index+Nv-1,level,((first_leaf_index/Nv)&1)==0?"left":"right");
...@@ -204,7 +202,7 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol ...@@ -204,7 +202,7 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol
new_node->all_frozen=1; new_node->all_frozen=1;
} }
if (all_frozen_below==0) if (all_frozen_below==0)
new_node->right=add_nodes(level-1,first_leaf_index+(Nv/2),polarParams); new_node->right = add_nodes(level - 1, first_leaf_index + (Nv / 2), polarParams);
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("new_node (%d): first_leaf_index %d, left %p, right %p\n",Nv,first_leaf_index,new_node->left,new_node->right); printf("new_node (%d): first_leaf_index %d, left %p, right %p\n",Nv,first_leaf_index,new_node->left,new_node->right);
...@@ -239,7 +237,8 @@ void build_decoder_tree(t_nrPolar_params *polarParams) ...@@ -239,7 +237,8 @@ void build_decoder_tree(t_nrPolar_params *polarParams)
#endif #endif
} }
void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) { static void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output)
{
int16_t *alpha_v=node->alpha; int16_t *alpha_v=node->alpha;
int16_t *alpha_l=node->left->alpha; int16_t *alpha_l=node->left->alpha;
int16_t *betal = node->left->beta; int16_t *betal = node->left->beta;
...@@ -248,12 +247,10 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) { ...@@ -248,12 +247,10 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) {
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("applyFtoleft %d, Nv %d (level %d,node->left (leaf %d, AF %d))\n",node->first_leaf_index,node->Nv,node->level,node->left->leaf,node->left->all_frozen); printf("applyFtoleft %d, Nv %d (level %d,node->left (leaf %d, AF %d))\n",node->first_leaf_index,node->Nv,node->level,node->left->leaf,node->left->all_frozen);
for (int i = 0; i < node->Nv; i++)
for (int i=0;i<node->Nv;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]); 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 #endif
if (node->left->all_frozen == 0) { if (node->left->all_frozen == 0) {
int avx2mod = (node->Nv/2)&15; int avx2mod = (node->Nv/2)&15;
if (avx2mod == 0) { if (avx2mod == 0) {
...@@ -307,7 +304,7 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) { ...@@ -307,7 +304,7 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) {
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("betal[0] %d (%p)\n",betal[0],&betal[0]); printf("betal[0] %d (%p)\n",betal[0],&betal[0]);
#endif #endif
pp->nr_polar_U[node->first_leaf_index] = (1+betal[0])>>1; output[node->first_leaf_index] = (1 + betal[0]) >> 1;
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index,(betal[0]+1)>>1,alpha_l[0]); printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index,(betal[0]+1)>>1,alpha_l[0]);
#endif #endif
...@@ -315,8 +312,8 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) { ...@@ -315,8 +312,8 @@ void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) {
} }
} }
void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) { static void applyGtoright(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *output)
{
int16_t *alpha_v=node->alpha; int16_t *alpha_v=node->alpha;
int16_t *alpha_r=node->right->alpha; int16_t *alpha_r=node->right->alpha;
int16_t *betal = node->left->beta; int16_t *betal = node->left->beta;
...@@ -333,9 +330,8 @@ void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -333,9 +330,8 @@ void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) {
for (int i=0;i<avx2len;i++) { for (int i=0;i<avx2len;i++) {
((simde__m256i *)alpha_r)[i] = ((simde__m256i *)alpha_r)[i] =
simde_mm256_subs_epi16(((simde__m256i *)alpha_v)[i+avx2len], simde_mm256_subs_epi16(((simde__m256i *)alpha_v)[i + avx2len],
simde_mm256_sign_epi16(((simde__m256i *)alpha_v)[i], simde_mm256_sign_epi16(((simde__m256i *)alpha_v)[i], ((simde__m256i *)betal)[i]));
((simde__m256i *)betal)[i]));
} }
} }
else if (avx2mod == 8) { else if (avx2mod == 8) {
...@@ -360,7 +356,7 @@ void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -360,7 +356,7 @@ void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) {
} }
if (node->Nv == 2) { // apply hard decision on right node if (node->Nv == 2) { // apply hard decision on right node
betar[0] = (alpha_r[0]>0) ? -1 : 1; betar[0] = (alpha_r[0]>0) ? -1 : 1;
pp->nr_polar_U[node->first_leaf_index+1] = (1+betar[0])>>1; output[node->first_leaf_index + 1] = (1 + betar[0]) >> 1;
#ifdef DEBUG_NEW_IMPL #ifdef DEBUG_NEW_IMPL
printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]); printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]);
#endif #endif
...@@ -407,18 +403,17 @@ void computeBeta(const t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -407,18 +403,17 @@ void computeBeta(const t_nrPolar_params *pp,decoder_node_t *node) {
memcpy((void*)&betav[node->Nv/2],betar,(node->Nv/2)*sizeof(int16_t)); memcpy((void*)&betav[node->Nv/2],betar,(node->Nv/2)*sizeof(int16_t));
} }
void generic_polar_decoder(const t_nrPolar_params *pp,decoder_node_t *node) { void generic_polar_decoder(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U)
{
// Apply F to left // Apply F to left
applyFtoleft(pp, node); applyFtoleft(pp, node, nr_polar_U);
// if left is not a leaf recurse down to the left // if left is not a leaf recurse down to the left
if (node->left->leaf==0) if (node->left->leaf==0)
generic_polar_decoder(pp, node->left); generic_polar_decoder(pp, node->left, nr_polar_U);
applyGtoright(pp, node); applyGtoright(pp, node, nr_polar_U);
if (node->right->leaf==0) generic_polar_decoder(pp, node->right); if (node->right->leaf == 0)
generic_polar_decoder(pp, node->right, nr_polar_U);
computeBeta(pp, node); computeBeta(pp, node);
} }
...@@ -77,7 +77,7 @@ typedef struct decoder_tree_t_s { ...@@ -77,7 +77,7 @@ typedef struct decoder_tree_t_s {
int num_nodes; int num_nodes;
} decoder_tree_t; } decoder_tree_t;
struct nrPolar_params { typedef struct nrPolar_params {
//messageType: 0=PBCH, 1=DCI, -1=UCI //messageType: 0=PBCH, 1=DCI, -1=UCI
struct nrPolar_params *nextPtr __attribute__((aligned(16))); struct nrPolar_params *nextPtr __attribute__((aligned(16)));
...@@ -99,7 +99,6 @@ struct nrPolar_params { ...@@ -99,7 +99,6 @@ struct nrPolar_params {
uint32_t crcBit; uint32_t crcBit;
uint16_t *interleaving_pattern; uint16_t *interleaving_pattern;
uint16_t *deinterleaving_pattern;
uint16_t *rate_matching_pattern; uint16_t *rate_matching_pattern;
const uint16_t *Q_0_Nminus1; const uint16_t *Q_0_Nminus1;
int16_t *Q_I_N; int16_t *Q_I_N;
...@@ -107,36 +106,18 @@ struct nrPolar_params { ...@@ -107,36 +106,18 @@ struct nrPolar_params {
int16_t *Q_PC_N; int16_t *Q_PC_N;
uint8_t *information_bit_pattern; uint8_t *information_bit_pattern;
uint8_t *parity_check_bit_pattern; uint8_t *parity_check_bit_pattern;
uint16_t *channel_interleaver_pattern;
//uint32_t crc_polynomial;
const uint8_t **crc_generator_matrix; // G_P const uint8_t **crc_generator_matrix; // G_P
const uint8_t **G_N; const uint8_t **G_N;
fourDimArray_t *G_N_tab;
int groupsize; int groupsize;
int *rm_tab; int *rm_tab;
uint64_t cprime_tab0[32][256]; uint64_t cprime_tab0[32][256];
uint64_t cprime_tab1[32][256]; uint64_t cprime_tab1[32][256];
uint64_t B_tab0[32][256]; uint64_t B_tab0[32][256];
uint64_t B_tab1[32][256]; uint64_t B_tab1[32][256];
uint8_t **extended_crc_generator_matrix; // lowercase: bits, Uppercase: Bits stored in bytes
//lowercase: bits, Uppercase: Bits stored in bytes // polar_encoder vectors
//polar_encoder vectors
uint8_t *nr_polar_crc;
uint8_t *nr_polar_aPrime;
uint8_t *nr_polar_APrime;
uint8_t *nr_polar_D;
uint8_t *nr_polar_E;
//Polar Coding vectors
uint8_t *nr_polar_A;
uint8_t *nr_polar_CPrime;
uint8_t *nr_polar_B;
uint8_t *nr_polar_U;
decoder_tree_t tree; decoder_tree_t tree;
} __attribute__ ((__packed__)); } t_nrPolar_params;
typedef struct nrPolar_params t_nrPolar_params;
void polar_encoder(uint32_t *input, void polar_encoder(uint32_t *input,
uint32_t *output, uint32_t *output,
...@@ -181,14 +162,7 @@ int8_t polar_decoder_dci(double *input, ...@@ -181,14 +162,7 @@ int8_t polar_decoder_dci(double *input,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level); uint8_t aggregation_level);
void generic_polar_decoder(const t_nrPolar_params *pp, void generic_polar_decoder(const t_nrPolar_params *pp, decoder_node_t *node, uint8_t *nr_polar_U);
decoder_node_t *node);
void applyFtoleft(const t_nrPolar_params *pp,
decoder_node_t *node);
void applyGtoright(const t_nrPolar_params *pp,
decoder_node_t *node);
void computeBeta(const t_nrPolar_params *pp, void computeBeta(const t_nrPolar_params *pp,
decoder_node_t *node); decoder_node_t *node);
...@@ -219,8 +193,6 @@ uint32_t nr_polar_output_length(uint16_t K, ...@@ -219,8 +193,6 @@ uint32_t nr_polar_output_length(uint16_t K,
uint16_t E, uint16_t E,
uint8_t n_max); uint8_t n_max);
void nr_polar_channel_interleaver_pattern(uint16_t *cip, const uint8_t I_BIL, const uint16_t E);
void nr_polar_rate_matching_pattern(uint16_t *rmp, void nr_polar_rate_matching_pattern(uint16_t *rmp,
uint16_t *J, uint16_t *J,
const uint8_t *P_i_, const uint8_t *P_i_,
...@@ -254,11 +226,11 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -254,11 +226,11 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
int16_t *Q_PC_N, int16_t *Q_PC_N,
const uint16_t *J, const uint16_t *J,
const uint16_t *Q_0_Nminus1, const uint16_t *Q_0_Nminus1,
uint16_t K, const uint16_t K,
uint16_t N, const uint16_t N,
const uint16_t E, const uint16_t E,
uint8_t n_PC, const uint8_t n_PC,
uint8_t n_pc_wm); const 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,
...@@ -309,10 +281,6 @@ void nr_sort_asc_double_1D_array_ind(double *matrix, ...@@ -309,10 +281,6 @@ void nr_sort_asc_double_1D_array_ind(double *matrix,
uint8_t *ind, uint8_t *ind,
uint8_t len); uint8_t len);
void nr_sort_asc_int16_1D_array_ind(int32_t *matrix,
int *ind,
int len);
void nr_free_double_2D_array(double **input, uint16_t xlen); void nr_free_double_2D_array(double **input, uint16_t xlen);
#ifndef __cplusplus #ifndef __cplusplus
...@@ -350,23 +318,24 @@ static inline void nr_polar_interleaver(uint8_t *input, ...@@ -350,23 +318,24 @@ static inline void nr_polar_interleaver(uint8_t *input,
uint16_t *pattern, uint16_t *pattern,
uint16_t size) uint16_t size)
{ {
for (int i=0; i<size; i++) output[i]=input[pattern[i]]; for (int i = 0; i < size; i++)
output[i] = input[pattern[i]];
} }
static inline void nr_polar_deinterleaver(uint8_t *input, static inline void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint16_t *pattern, uint16_t size)
uint8_t *output,
uint16_t *pattern,
uint16_t size)
{ {
for (int i=0; i<size; i++) output[pattern[i]]=input[i]; for (int i = 0; i < size; i++)
output[pattern[i]] = input[i];
} }
void delete_decoder_tree(t_nrPolar_params *); void delete_decoder_tree(t_nrPolar_params *);
extern pthread_mutex_t PolarListMutex; extern pthread_mutex_t PolarListMutex;
#define polarReturn \ static inline void polarReturn(t_nrPolar_params *polarParams)
pthread_mutex_lock(&PolarListMutex); \ {
polarParams->busy=false; \ pthread_mutex_lock(&PolarListMutex);
pthread_mutex_unlock(&PolarListMutex); \ polarParams->busy = false;
return pthread_mutex_unlock(&PolarListMutex);
}
#endif #endif
...@@ -33,27 +33,23 @@ ...@@ -33,27 +33,23 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){
uint8_t K_IL_max=164, k=0; uint K_IL_max = 164, k = 0;
uint8_t interleaving_pattern_table[164] = {0, 2, 4, 7, 9, 14, 19, 20, 24, 25, 26, 28, 31, 34, uint8_t interleaving_pattern_table[164] = {
42, 45, 49, 50, 51, 53, 54, 56, 58, 59, 61, 62, 65, 66, 0, 2, 4, 7, 9, 14, 19, 20, 24, 25, 26, 28, 31, 34, 42, 45, 49, 50, 51, 53, 54, 56, 58, 59,
67, 69, 70, 71, 72, 76, 77, 81, 82, 83, 87, 88, 89, 91, 61, 62, 65, 66, 67, 69, 70, 71, 72, 76, 77, 81, 82, 83, 87, 88, 89, 91, 93, 95, 98, 101, 104, 106,
93, 95, 98, 101, 104, 106, 108, 110, 111, 113, 115, 118, 119, 120, 108, 110, 111, 113, 115, 118, 119, 120, 122, 123, 126, 127, 129, 132, 134, 138, 139, 140, 1, 3, 5, 8, 10, 15,
122, 123, 126, 127, 129, 132, 134, 138, 139, 140, 1, 3, 5, 8, 21, 27, 29, 32, 35, 43, 46, 52, 55, 57, 60, 63, 68, 73, 78, 84, 90, 92, 94, 96, 99, 102, 105, 107,
10, 15, 21, 27, 29, 32, 35, 43, 46, 52, 55, 57, 60, 63, 109, 112, 114, 116, 121, 124, 128, 130, 133, 135, 141, 6, 11, 16, 22, 30, 33, 36, 44, 47, 64, 74, 79, 85,
68, 73, 78, 84, 90, 92, 94, 96, 99, 102, 105, 107, 109, 112, 97, 100, 103, 117, 125, 131, 136, 142, 12, 17, 23, 37, 48, 75, 80, 86, 137, 143, 13, 18, 38, 144, 39, 145,
114, 116, 121, 124, 128, 130, 133, 135, 141, 6, 11, 16, 22, 30, 40, 146, 41, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163};
33, 36, 44, 47, 64, 74, 79, 85, 97, 100, 103, 117, 125, 131,
136, 142, 12, 17, 23, 37, 48, 75, 80, 86, 137, 143, 13, 18,
38, 144, 39, 145, 40, 146, 41, 147, 148, 149, 150, 151, 152, 153,
154, 155, 156, 157, 158, 159, 160, 161, 162, 163};
if (I_IL == 0){ if (I_IL == 0) {
for (; k<= K-1; k++) for (; k <= K - 1; k++)
PI_k_[k] = k; PI_k_[k] = k;
} else { } else {
for (int m=0; m<= (K_IL_max-1); m++){ for (int m = 0; m <= (K_IL_max - 1); m++) {
if (interleaving_pattern_table[m] >= (K_IL_max-K)) { if (interleaving_pattern_table[m] >= (K_IL_max - K)) {
PI_k_[k] = interleaving_pattern_table[m]-(K_IL_max-K); PI_k_[k] = interleaving_pattern_table[m] - (K_IL_max - K);
k++; k++;
} }
} }
......
...@@ -38,9 +38,9 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1, ...@@ -38,9 +38,9 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1,
uint16_t row, uint16_t row,
uint16_t col) uint16_t col)
{ {
for (uint16_t i = 0; i < col; i++) { for (uint i = 0; i < col; i++) {
output[i] = 0; output[i] = 0;
for (uint16_t j = 0; j < row; j++) { for (uint j = 0; j < row; j++) {
output[i] += matrix1[j] * matrix2[j][i]; output[i] += matrix1[j] * matrix2[j][i];
} }
} }
...@@ -48,44 +48,15 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1, ...@@ -48,44 +48,15 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(const uint8_t *matrix1,
// Modified Bubble Sort. // Modified Bubble Sort.
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) { void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) {
int swaps;
double temp;
int tempInd;
for (int i = 0; i < len; i++) {
swaps = 0;
for (int j = 0; j < (len - i) - 1; j++) {
if (matrix[j] > matrix[j + 1]) {
temp = matrix[j];
matrix[j] = matrix[j + 1];
matrix[j + 1] = temp;
tempInd = ind[j];
ind[j] = ind[j + 1];
ind[j + 1] = tempInd;
swaps++;
}
}
if (swaps == 0)
break;
}
}
void nr_sort_asc_int16_1D_array_ind(int32_t *matrix, int *ind, int len) {
int swaps;
int16_t temp;
int tempInd;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
swaps = 0; int swaps = 0;
for (int j = 0; j < (len - i) - 1; j++) { for (int j = 0; j < (len - i) - 1; j++) {
if (matrix[j] > matrix[j + 1]) { if (matrix[j] > matrix[j + 1]) {
temp = matrix[j]; double temp = matrix[j];
matrix[j] = matrix[j + 1]; matrix[j] = matrix[j + 1];
matrix[j + 1] = temp; matrix[j + 1] = temp;
tempInd = ind[j]; int tempInd = ind[j];
ind[j] = ind[j + 1]; ind[j] = ind[j + 1];
ind[j + 1] = tempInd; ind[j + 1] = tempInd;
......
...@@ -232,9 +232,12 @@ uint32_t nr_polar_output_length(uint16_t K, ...@@ -232,9 +232,12 @@ uint32_t nr_polar_output_length(uint16_t K,
n_2 = ceil(log2(K/R_min)); n_2 = ceil(log2(K/R_min));
int n = n_max; int n = n_max;
if (n>n_1) n=n_1; if (n > n_1)
if (n>n_2) n=n_2; n = n_1;
if (n<n_min) n=n_min; if (n > n_2)
n = n_2;
if (n < n_min)
n = n_min;
/*printf("nr_polar_output_length: K %d, E %d, n %d (n_max %d,n_min %d, n_1 %d,n_2 %d)\n", /*printf("nr_polar_output_length: K %d, E %d, n %d (n_max %d,n_min %d, n_1 %d,n_2 %d)\n",
K,E,n,n_max,n_min,n_1,n_2); K,E,n,n_max,n_min,n_1,n_2);
...@@ -242,39 +245,6 @@ uint32_t nr_polar_output_length(uint16_t K, ...@@ -242,39 +245,6 @@ uint32_t nr_polar_output_length(uint16_t K,
return ((uint32_t) pow(2.0,n)); //=polar_code_output_length return ((uint32_t) pow(2.0,n)); //=polar_code_output_length
} }
void nr_polar_channel_interleaver_pattern(uint16_t *cip, const uint8_t I_BIL, const uint16_t E)
{
if (I_BIL == 1) {
int T = E;
while( ((T/2)*(T+1)) < E ) T++;
int16_t v[T][T];
int k = 0;
for (int i = 0; i <= T-1; i++) {
for (int j = 0; j <= (T-1)-i; j++) {
if (k<E) {
v[i][j] = k;
} else {
v[i][j] = (-1);
}
k++;
}
}
k=0;
for (int j = 0; j <= T-1; j++) {
for (int i = 0; i <= (T-1)-j; i++) {
if ( v[i][j] != (-1) ) {
cip[k]=v[i][j];
k++;
}
}
}
} else {
for (int i=0; i<=E-1; i++) cip[i]=i;
}
}
void nr_polar_info_bit_pattern(uint8_t *ibp, void nr_polar_info_bit_pattern(uint8_t *ibp,
uint8_t *pcbp, uint8_t *pcbp,
int16_t *Q_I_N, int16_t *Q_I_N,
...@@ -282,11 +252,11 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -282,11 +252,11 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
int16_t *Q_PC_N, int16_t *Q_PC_N,
const uint16_t *J, const uint16_t *J,
const uint16_t *Q_0_Nminus1, const uint16_t *Q_0_Nminus1,
uint16_t K, const uint16_t K,
uint16_t N, const uint16_t N,
const uint16_t E, const uint16_t E,
uint8_t n_PC, const uint8_t n_PC,
uint8_t n_pc_wm) const uint8_t n_pc_wm)
{ {
int Q_Ftmp_N[N + 1]; // Last element shows the final int Q_Ftmp_N[N + 1]; // Last element shows the final
int Q_Itmp_N[N + 1]; // array index assigned a value. int Q_Itmp_N[N + 1]; // array index assigned a value.
...@@ -296,8 +266,6 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -296,8 +266,6 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
Q_Itmp_N[i] = -1; Q_Itmp_N[i] = -1;
} }
int limit;
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++) {
...@@ -307,14 +275,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -307,14 +275,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
} }
if ((E / (double)N) >= (3.0 / 4)) { if ((E / (double)N) >= (3.0 / 4)) {
limit = ceil((double)(3 * N - 2 * E) / 4); int limit = ceil((double)(3 * N - 2 * E) / 4);
for (int n = 0; n <= limit - 1; n++) { for (int n = 0; n <= limit - 1; n++) {
int ind = Q_Ftmp_N[N] + 1; int 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); int limit = ceil((double)(9 * N - 4 * E) / 16);
for (int n = 0; n <= limit - 1; n++) { for (int n = 0; n <= limit - 1; n++) {
int ind = Q_Ftmp_N[N] + 1; int ind = Q_Ftmp_N[N] + 1;
Q_Ftmp_N[ind] = n; Q_Ftmp_N[ind] = n;
...@@ -332,15 +300,15 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -332,15 +300,15 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
// 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++) {
bool flag = true; const int end = Q_Ftmp_N[N];
for (int m = 0; m <= Q_Ftmp_N[N]; m++){ int m;
for (m = 0; m <= end; m++) {
AssertFatal(m < N+1, "Buffer boundary overflow"); AssertFatal(m < N+1, "Buffer boundary overflow");
if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) {
flag = false;
break; break;
} }
} }
if (flag) { if (m > end) {
Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n]; Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n];
Q_Itmp_N[N]++; Q_Itmp_N[N]++;
} }
...@@ -361,14 +329,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -361,14 +329,14 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
// Q_F_N = Q_0_N-1 \ Q_I_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++) {
bool flag = true; const int sz = (K + n_PC) - 1;
for (int m = 0; m <= (K + n_PC) - 1; m++) const int toCmp = Q_0_Nminus1[n];
if (Q_0_Nminus1[n] == Q_I_N[m]) { int m;
flag = false; for (m = 0; m <= sz; m++)
if (toCmp == Q_I_N[m])
break; break;
} if (m > sz) {
if (flag) { Q_F_N[Q_F_N[N] + 1] = toCmp;
Q_F_N[Q_F_N[N] + 1] = Q_0_Nminus1[n];
Q_F_N[N]++; Q_F_N[N]++;
} }
} }
...@@ -462,9 +430,11 @@ void nr_polar_rate_matching(double *input, ...@@ -462,9 +430,11 @@ void nr_polar_rate_matching(double *input,
} }
} else { } else {
if ( (K/(double)E) <= (7.0/16) ) { //puncturing if ( (K/(double)E) <= (7.0/16) ) { //puncturing
for (int i=0; i<=N-1; i++) output[i]=0; for (int i = 0; i <= N - 1; i++)
output[i] = 0;
} else { //shortening } else { //shortening
for (int i=0; i<=N-1; i++) output[i]=INFINITY; for (int i = 0; i <= N - 1; i++)
output[i] = INFINITY;
} }
for (int i=0; i<=E-1; i++){ for (int i=0; i<=E-1; i++){
......
...@@ -31,13 +31,13 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P ...@@ -31,13 +31,13 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P
for (int m = 0; m <= N - 1; m++) { for (int m = 0; m <= N - 1; m++) {
i = floor((32 * m) / N); i = floor((32 * m) / N);
J[m] = (P_i_[i] * (N / 32)) + (m % (N / 32)); J[m] = P_i_[i] * (N / 32)) + (m % (N / 32);
y[m] = d[J[m]]; y[m] = d[J[m]];
} }
if (E >= N) { // repetition if (E >= N) { // repetition
for (int k = 0; k <= E - 1; k++) { for (int k = 0; k <= E - 1; k++) {
ind = (k % N); ind = k % N;
rmp[k] = y[ind]; rmp[k] = y[ind];
} }
} else { } else {
...@@ -55,43 +55,23 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P ...@@ -55,43 +55,23 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P
void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){
if (E >= N) { // repetition
if (E>=N) { //repetition for (int i = 0; i <= N - 1; i++)
for (int i=0; i<=N-1; i++) output[i]=0; output[i] = 0;
for (int i=0; i<=E-1; i++){ for (int i = 0; i <= E - 1; i++) {
output[rmp[i]]+=input[i]; output[rmp[i]] += input[i];
}
} else {
if ( (K/(double)E) <= (7.0/16) ) { //puncturing
for (int i=0; i<=N-1; i++) output[i]=0;
} else { //shortening
for (int i=0; i<=N-1; i++) output[i]=INFINITY;
}
for (int i=0; i<=E-1; i++){
output[rmp[i]]=input[i];
}
}
}
void nr_polar_rate_matching_int8(int16_t *input, int16_t *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){
if (E>=N) { //repetition
for (int i=0; i<=N-1; i++) output[i]=0;
for (int i=0; i<=E-1; i++){
output[rmp[i]]+=input[i];
} }
} else { } else {
if ( (K/(double)E) <= (7.0/16) ) { //puncturing if ((K / (double)E) <= (7.0 / 16)) { // puncturing
for (int i=0; i<=N-1; i++) output[i]=0; for (int i = 0; i <= N - 1; i++)
} else { //shortening output[i] = 0;
for (int i=0; i<=N-1; i++) output[i]=INFINITY; } else { // shortening
for (int i = 0; i <= N - 1; i++)
output[i] = INFINITY;
} }
for (int i=0; i<=E-1; i++){ for (int i = 0; i <= E - 1; i++) {
output[rmp[i]]=input[i]; output[rmp[i]] = input[i];
} }
} }
} }
...@@ -50,30 +50,17 @@ static void nr_polar_delete_list(t_nrPolar_params * polarParams) { ...@@ -50,30 +50,17 @@ static void nr_polar_delete_list(t_nrPolar_params * polarParams) {
delete_decoder_tree(polarParams); delete_decoder_tree(polarParams);
// From build_polar_tables() // From build_polar_tables()
free(polarParams->G_N_tab);
free(polarParams->rm_tab); free(polarParams->rm_tab);
if (polarParams->crc_generator_matrix) if (polarParams->crc_generator_matrix)
free(polarParams->crc_generator_matrix); free(polarParams->crc_generator_matrix);
//polar_encoder vectors: // Polar Coding vectors
free(polarParams->nr_polar_crc);
free(polarParams->nr_polar_aPrime);
free(polarParams->nr_polar_APrime);
free(polarParams->nr_polar_D);
free(polarParams->nr_polar_E);
//Polar Coding vectors
free(polarParams->nr_polar_U);
free(polarParams->nr_polar_CPrime);
free(polarParams->nr_polar_B);
free(polarParams->nr_polar_A);
free(polarParams->interleaving_pattern); free(polarParams->interleaving_pattern);
free(polarParams->deinterleaving_pattern);
free(polarParams->rate_matching_pattern); free(polarParams->rate_matching_pattern);
free(polarParams->information_bit_pattern); free(polarParams->information_bit_pattern);
free(polarParams->parity_check_bit_pattern); free(polarParams->parity_check_bit_pattern);
free(polarParams->Q_I_N); free(polarParams->Q_I_N);
free(polarParams->Q_F_N); free(polarParams->Q_F_N);
free(polarParams->Q_PC_N); free(polarParams->Q_PC_N);
free(polarParams->channel_interleaver_pattern);
free(polarParams); free(polarParams);
} }
...@@ -113,11 +100,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui ...@@ -113,11 +100,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui
t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1); t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1);
AssertFatal(newPolarInitNode, "[nr_polar_init] New t_nrPolar_params * could not be created"); AssertFatal(newPolarInitNode, "[nr_polar_init] New t_nrPolar_params * could not be created");
newPolarInitNode->busy = true; newPolarInitNode->busy = true;
newPolarInitNode->nextPtr = NULL;
newPolarInitNode->nextPtr = PolarList;
PolarList = newPolarInitNode;
pthread_mutex_unlock(&PolarListMutex); pthread_mutex_unlock(&PolarListMutex);
// LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime); // LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime);
newPolarInitNode->idx = PolarKey; newPolarInitNode->idx = PolarKey;
newPolarInitNode->nextPtr = NULL;
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); //printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
if (messageType == NR_POLAR_PBCH_MESSAGE_TYPE) { if (messageType == NR_POLAR_PBCH_MESSAGE_TYPE) {
...@@ -217,26 +205,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui ...@@ -217,26 +205,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui
newPolarInitNode->n_max); newPolarInitNode->n_max);
newPolarInitNode->n = log2(newPolarInitNode->N); newPolarInitNode->n = log2(newPolarInitNode->N);
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
//polar_encoder vectors: // polar_encoder vectors:
newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits);
newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3));
newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K);
newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N);
newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength);
//Polar Coding vectors
newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat
newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat
newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat
newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat
newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n);
newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
nr_polar_interleaving_pattern(newPolarInitNode->K, nr_polar_interleaving_pattern(newPolarInitNode->K,
newPolarInitNode->i_il, newPolarInitNode->i_il,
newPolarInitNode->interleaving_pattern); newPolarInitNode->interleaving_pattern);
newPolarInitNode->deinterleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
for (int i=0; i<newPolarInitNode->K; i++)
newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i;
newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
uint16_t J[newPolarInitNode->N]; uint16_t J[newPolarInitNode->N];
...@@ -270,18 +244,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui ...@@ -270,18 +244,12 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui
// 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);
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
newPolarInitNode->i_bil,
newPolarInitNode->encoderLength);
if (decoder_flag == 1) if (decoder_flag == 1)
build_decoder_tree(newPolarInitNode); build_decoder_tree(newPolarInitNode);
build_polar_tables(newPolarInitNode); build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode);
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
newPolarInitNode->nextPtr=PolarList; init_polar_deinterleaver_table(newPolarInitNode);
PolarList=newPolarInitNode;
return newPolarInitNode; return newPolarInitNode;
} }
......
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