Commit 838d6b86 authored by Thomas Laurent's avatar Thomas Laurent
Browse files

issue 403 -> astyle on modified files

parent e1fa6be7
This diff is collapsed.
......@@ -81,7 +81,7 @@ struct nrPolar_params {
//messageType: 0=PBCH, 1=DCI, -1=UCI
int idx; //idx = (messageType * messageLength * aggregation_prime);
struct nrPolar_params *nextPtr;
uint8_t n_max;
uint8_t i_il;
uint8_t i_seg;
......@@ -96,7 +96,7 @@ struct nrPolar_params {
uint16_t N;
uint8_t n;
uint32_t crcBit;
uint16_t *interleaving_pattern;
uint16_t *deinterleaving_pattern;
uint16_t *rate_matching_pattern;
......@@ -107,7 +107,7 @@ struct nrPolar_params {
uint8_t *information_bit_pattern;
uint16_t *channel_interleaver_pattern;
uint32_t crc_polynomial;
uint8_t **crc_generator_matrix; //G_P
uint8_t **G_N;
uint64_t **G_N_tab;
......@@ -117,7 +117,7 @@ struct nrPolar_params {
uint64_t cprime_tab1[32][256];
uint64_t B_tab0[32][256];
uint64_t B_tab1[32][256];
uint32_t* crc256Table;
uint32_t *crc256Table;
uint8_t **extended_crc_generator_matrix;
//lowercase: bits, Uppercase: Bits stored in bytes
//polar_encoder vectors
......@@ -126,82 +126,82 @@ struct nrPolar_params {
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;
} __attribute__ ((__packed__));
typedef struct nrPolar_params t_nrPolar_params;
void polar_encoder(uint32_t *input,
uint32_t *output,
t_nrPolar_params* polarParams);
uint32_t *output,
t_nrPolar_params *polarParams);
void polar_encoder_dci(uint32_t *in,
uint32_t *out,
t_nrPolar_params* polarParams,
uint16_t n_RNTI);
uint32_t *out,
t_nrPolar_params *polarParams,
uint16_t n_RNTI);
void polar_encoder_fast(uint64_t *A,
uint32_t *out,
int32_t crcmask,
t_nrPolar_params* polarParams);
uint32_t *out,
int32_t crcmask,
t_nrPolar_params *polarParams);
int8_t polar_decoder(double *input,
uint8_t *output,
t_nrPolar_params* polarParams,
uint8_t listSize,
uint8_t pathMetricAppr);
uint8_t *output,
t_nrPolar_params *polarParams,
uint8_t listSize,
uint8_t pathMetricAppr);
uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out,
const t_nrPolar_params *polarParams);
uint64_t *out,
const t_nrPolar_params *polarParams);
int8_t polar_decoder_aPriori(double *input,
uint32_t *output,
t_nrPolar_params* polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
double *aPrioriPayload);
uint32_t *output,
t_nrPolar_params *polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
double *aPrioriPayload);
int8_t polar_decoder_aPriori_timing(double *input,
uint32_t *output,
t_nrPolar_params* polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
double *aPrioriPayload,
double cpuFreqGHz,
FILE* logFile);
uint32_t *output,
t_nrPolar_params *polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
double *aPrioriPayload,
double cpuFreqGHz,
FILE *logFile);
int8_t polar_decoder_dci(double *input,
uint32_t *out,
t_nrPolar_params* polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
uint16_t n_RNTI);
uint32_t *out,
t_nrPolar_params *polarParams,
uint8_t listSize,
uint8_t pathMetricAppr,
uint16_t n_RNTI);
void generic_polar_decoder(t_nrPolar_params *,
decoder_node_t *);
decoder_node_t *);
void build_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_params* polarParams);
void build_polar_tables(t_nrPolar_params *polarParams);
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
void nr_polar_print_polarParams(t_nrPolar_params* polarParams);
void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
t_nrPolar_params * nr_polar_params ( int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
t_nrPolar_params *nr_polar_params ( int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
uint8_t** nr_polar_kronecker_power_matrices(uint8_t n);
uint8_t **nr_polar_kronecker_power_matrices(uint8_t n);
const uint16_t* nr_polar_sequence_pattern(uint8_t n);
const uint16_t *nr_polar_sequence_pattern(uint8_t n);
/*!@fn uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max)
* @brief Computes...
......@@ -209,168 +209,168 @@ const uint16_t* nr_polar_sequence_pattern(uint8_t n);
* @param E
* @param n_max */
uint32_t nr_polar_output_length(uint16_t K,
uint16_t E,
uint8_t n_max);
uint16_t E,
uint8_t n_max);
void nr_polar_channel_interleaver_pattern(uint16_t *cip,
uint8_t I_BIL,
uint16_t E);
uint8_t I_BIL,
uint16_t E);
void nr_polar_rate_matching_pattern(uint16_t *rmp,
uint16_t *J,
const uint8_t *P_i_,
uint16_t K,
uint16_t N,
uint16_t E);
uint16_t *J,
const uint8_t *P_i_,
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);
double *output,
uint16_t *rmp,
uint16_t K,
uint16_t N,
uint16_t E);
void nr_polar_rate_matching_int16(int16_t *input,
int16_t *output,
uint16_t *rmp,
uint16_t K,
uint16_t N,
uint16_t E);
int16_t *output,
uint16_t *rmp,
uint16_t K,
uint16_t N,
uint16_t E);
void nr_polar_interleaving_pattern(uint16_t K,
uint8_t I_IL,
uint16_t *PI_k_);
uint8_t I_IL,
uint16_t *PI_k_);
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,
uint16_t *J,
const uint16_t *Q_0_Nminus1,
uint16_t K,
uint16_t N,
uint16_t E,
uint8_t n_PC);
void nr_polar_info_bit_extraction(uint8_t *input,
uint8_t *output,
uint8_t *pattern,
uint16_t size);
uint8_t *output,
uint8_t *pattern,
uint16_t size);
void nr_bit2byte_uint32_8_t(uint32_t *in,
uint16_t arraySize,
uint8_t *out);
uint16_t arraySize,
uint8_t *out);
void nr_byte2bit_uint8_32_t(uint8_t *in,
uint16_t arraySize,
uint32_t *out);
uint16_t arraySize,
uint32_t *out);
void nr_crc_bit2bit_uint32_8_t(uint32_t *in,
uint16_t arraySize,
uint8_t *out);
uint16_t arraySize,
uint8_t *out);
void nr_polar_bit_insertion(uint8_t *input,
uint8_t *output,
uint16_t N,
uint16_t K,
int16_t *Q_I_N,
int16_t *Q_PC_N,
uint8_t n_PC);
uint8_t *output,
uint16_t N,
uint16_t K,
int16_t *Q_I_N,
int16_t *Q_PC_N,
uint8_t n_PC);
void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1,
uint8_t **matrix2,
uint8_t *output,
uint16_t row,
uint16_t col);
uint8_t **matrix2,
uint8_t *output,
uint16_t row,
uint16_t col);
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen,
uint16_t ylen,
uint16_t zlen);
uint16_t ylen,
uint16_t zlen);
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen,
uint16_t ylen);
uint16_t ylen);
double ***nr_alloc_double_3D_array(uint16_t xlen,
uint16_t ylen,
uint16_t zlen);
uint16_t ylen,
uint16_t zlen);
double **nr_alloc_double_2D_array(uint16_t xlen,
uint16_t ylen);
uint16_t ylen);
void nr_free_double_3D_array(double ***input,
uint16_t xlen,
uint16_t ylen);
uint16_t xlen,
uint16_t ylen);
void nr_free_double_2D_array(double **input,
uint16_t xlen);
uint16_t xlen);
void nr_free_uint8_3D_array(uint8_t ***input,
uint16_t xlen,
uint16_t ylen);
uint16_t xlen,
uint16_t ylen);
void nr_free_uint8_2D_array(uint8_t **input,
uint16_t xlen);
uint16_t xlen);
void nr_sort_asc_double_1D_array_ind(double *matrix,
uint8_t *ind,
uint8_t len);
uint8_t *ind,
uint8_t len);
void nr_sort_asc_int16_1D_array_ind(int32_t *matrix,
int *ind,
int len);
int *ind,
int len);
void nr_free_double_2D_array(double **input, uint16_t xlen);
void updateLLR(double ***llr,
uint8_t **llrU,
uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen,
uint8_t approximation);
uint8_t **llrU,
uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen,
uint8_t approximation);
void updateBit(uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen);
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen);
void updatePathMetric(double *pathMetric,
double ***llr,
uint8_t listSize,
uint8_t bitValue,
uint16_t row,
uint8_t approximation);
double ***llr,
uint8_t listSize,
uint8_t bitValue,
uint16_t row,
uint8_t approximation);
void updatePathMetric2(double *pathMetric,
double ***llr,
uint8_t listSize,
uint16_t row,
uint8_t approximation);
double ***llr,
uint8_t listSize,
uint16_t row,
uint8_t approximation);
void computeLLR(double ***llr,
uint16_t row,
uint16_t col,
uint8_t i,
uint16_t offset,
uint8_t approximation);
uint16_t row,
uint16_t col,
uint8_t i,
uint16_t offset,
uint8_t approximation);
void updateCrcChecksum(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
void updateCrcChecksum2(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits);
......@@ -380,18 +380,16 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits);
//Also nr_polar_rate_matcher
static inline void nr_polar_interleaver(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[i]=input[pattern[i]];
}
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];
}
......
......@@ -37,186 +37,175 @@
#include "PHY/NR_TRANSPORT/nr_dci.h"
static int intcmp(const void *p1,const void *p2) {
return(*(int16_t*)p1 > *(int16_t*)p2);
return(*(int16_t *)p1 > *(int16_t *)p2);
}
static void nr_polar_init(t_nrPolar_params * *polarParams,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level)
{
t_nrPolar_params * currentPtr = *polarParams;
uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level);
//Parse the list. If the node is already created, return without initialization.
while (currentPtr != NULL) {
//printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength);
if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return;
else currentPtr = currentPtr->nextPtr;
}
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
//Else, initialize and add node to the end of the linked list.
t_nrPolar_params * newPolarInitNode = malloc(sizeof(t_nrPolar_params));
if (newPolarInitNode != NULL) {
newPolarInitNode->idx = (messageType * messageLength * aggregation_prime);
newPolarInitNode->nextPtr = NULL;
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
if (messageType == 0) { //PBCH
newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX;
newPolarInitNode->i_il = NR_POLAR_PBCH_I_IL;
newPolarInitNode->i_seg = NR_POLAR_PBCH_I_SEG;
newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC;
newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM;
newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL;
newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS;
newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS;
newPolarInitNode->encoderLength = NR_POLAR_PBCH_E;
newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS;
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits);//G_P
//printf("Initializing polar parameters for PBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength);
} else if (messageType == 1) { //DCI
newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX;
newPolarInitNode->i_il = NR_POLAR_DCI_I_IL;
newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG;
newPolarInitNode->n_pc = NR_POLAR_DCI_N_PC;
newPolarInitNode->n_pc_wm = NR_POLAR_DCI_N_PC_WM;
newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL;
newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS;
newPolarInitNode->payloadBits = messageLength;
newPolarInitNode->encoderLength = aggregation_level*108;
newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS;
newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
//printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level);
} else if (messageType == -1) { //UCI
} else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
}
newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode.
newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max);
newPolarInitNode->n = log2(newPolarInitNode->N);
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
//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->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
nr_polar_interleaving_pattern(newPolarInitNode->K,
newPolarInitNode->i_il,
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);
uint16_t *J = malloc(sizeof(uint16_t) * newPolarInitNode->N);
nr_polar_rate_matching_pattern(newPolarInitNode->rate_matching_pattern,
J,
nr_polar_subblock_interleaver_pattern,
newPolarInitNode->K,
newPolarInitNode->N,
newPolarInitNode->encoderLength);
newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N);
newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc));
newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value.
newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc));
for (int i = 0; i <= newPolarInitNode->N; i++)
newPolarInitNode->Q_F_N[i] = -1; // Empty array.
nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern,
newPolarInitNode->Q_I_N,
newPolarInitNode->Q_F_N,
J,
newPolarInitNode->Q_0_Nminus1,
newPolarInitNode->K,
newPolarInitNode->N,
newPolarInitNode->encoderLength,
newPolarInitNode->n_pc);
// 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);
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
newPolarInitNode->i_bil,
newPolarInitNode->encoderLength);
free(J);
build_decoder_tree(newPolarInitNode);
build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode);