Merge branch 'nr-polar-encoder-optimizations' of https://gitlab.eurecom.fr/oai/openairinterface5g into nr-polar-encoder-optimizations
Conflicts: openair1/PHY/CODING/TESTBENCH/polartest.c openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c openair1/PHY/CODING/nr_compute_tbs.c openair1/PHY/CODING/nr_segmentation.c openair1/PHY/INIT/nr_parms.c openair1/PHY/NR_TRANSPORT/nr_pbch.c
This commit is contained in:
@@ -259,6 +259,7 @@ int test_ldpc(short No_iteration,
|
||||
//estimated_output=ldpc_decoder(channel_output_fixed, block_length, No_iteration, (double)((float)nom_rate/(float)denom_rate));
|
||||
|
||||
n_iter = nrLDPC_decoder(&decParams, (int8_t*) channel_output_fixed, (int8_t*) estimated_output, NULL);
|
||||
printf("nrLDPC_decoder n_iter=%d\n",n_iter);
|
||||
|
||||
//for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
|
||||
// printf("esimated_output[%d]=%d\n",i,esimated_output[i]);
|
||||
@@ -268,9 +269,9 @@ int test_ldpc(short No_iteration,
|
||||
{
|
||||
if (estimated_output[i] != test_input[0][i])
|
||||
{
|
||||
printf("error pos %d (%d, %d)\n",i,estimated_output[i],test_input[0][i]);
|
||||
*errors = (*errors) + 1;
|
||||
break;
|
||||
printf("error pos %d (%d, %d)\n",i,estimated_output[i],test_input[0][i]);
|
||||
*errors = (*errors) + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.)
|
||||
time_stats_t timeEncoder,timeDecoder;
|
||||
time_stats_t polar_decoder_init,polar_rate_matching,decoding,bit_extraction,deinterleaving;
|
||||
time_stats_t path_metric,sorting,update_LLR;
|
||||
opp_enabled=1;
|
||||
int decoder_int16=0;
|
||||
int generate_optim_code=0;
|
||||
cpu_freq_GHz = get_cpu_freq_GHz();
|
||||
reset_meas(&timeEncoder);
|
||||
reset_meas(&timeDecoder);
|
||||
@@ -71,21 +68,20 @@ int main(int argc, char *argv[]) {
|
||||
pathMetricAppr = (uint8_t) atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
decoder_int16=1;
|
||||
break;
|
||||
case 'q':
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
generate_optim_code=1;
|
||||
iterations=1;
|
||||
SNRstart=-6.0;
|
||||
SNRstop =-6.0;
|
||||
decoder_int16=1;
|
||||
break;
|
||||
case 'g':
|
||||
iterations = 1;
|
||||
SNRstart = -6.0;
|
||||
SNRstop = -6.0;
|
||||
decoder_int16 = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr -q (use fixed point decoder)\n");
|
||||
exit(-1);
|
||||
case 'h':
|
||||
printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n");
|
||||
exit(-1);
|
||||
|
||||
default:
|
||||
perror("[polartest.c] Problem at argument parsing with getopt");
|
||||
@@ -147,18 +143,18 @@ int main(int argc, char *argv[]) {
|
||||
uint8_t testArrayLength = ceil(testLength / 32.0);
|
||||
uint8_t coderArrayLength = ceil(coderLength / 32.0);
|
||||
|
||||
uint32_t *testInput = malloc(sizeof(uint32_t) * testArrayLength); //generate randomly
|
||||
uint32_t *encoderOutput = malloc(sizeof(uint32_t) * coderArrayLength);
|
||||
uint32_t *estimatedOutput = malloc(sizeof(uint32_t) * testArrayLength); //decoder output
|
||||
uint32_t testInput[testArrayLength]; //generate randomly
|
||||
uint32_t encoderOutput[coderArrayLength];
|
||||
uint32_t estimatedOutput[testArrayLength]; //decoder output
|
||||
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
|
||||
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength);
|
||||
|
||||
uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength);
|
||||
double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input
|
||||
double *channelOutput = malloc (sizeof(double) * coderLength); //add noise
|
||||
int16_t *channelOutput_int16;
|
||||
if (decoder_int16 == 1) channelOutput_int16 = (int16_t*)malloc (sizeof(int16_t) * coderLength);
|
||||
uint8_t encoderOutputByte[coderLength];
|
||||
double modulatedInput[coderLength]; //channel input
|
||||
double channelOutput[coderLength]; //add noise
|
||||
|
||||
int16_t channelOutput_int16[coderLength];
|
||||
|
||||
t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL;
|
||||
nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level);
|
||||
@@ -209,6 +205,8 @@ int main(int argc, char *argv[]) {
|
||||
rnti);
|
||||
printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n",
|
||||
dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]);
|
||||
free(encoder_outputByte);
|
||||
free(channel_output);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
@@ -268,7 +266,7 @@ int main(int argc, char *argv[]) {
|
||||
uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1};
|
||||
uint8_t nr_polar_crc[24];
|
||||
uint8_t **crc_generator_matrix = crc24c_generator_matrix(32);
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(nr_polar_A,
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(nr_polar_A,
|
||||
crc_generator_matrix,
|
||||
nr_polar_crc,
|
||||
32,
|
||||
@@ -325,6 +323,7 @@ int main(int argc, char *argv[]) {
|
||||
printf("%d\n",(testInput[0]>>i)&1);*/
|
||||
|
||||
|
||||
|
||||
int len_mod64=currentPtr->payloadBits&63;
|
||||
((uint64_t*)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1);
|
||||
|
||||
@@ -332,7 +331,8 @@ int main(int argc, char *argv[]) {
|
||||
if (decoder_int16==0)
|
||||
polar_encoder(testInput, encoderOutput, currentPtr);
|
||||
else
|
||||
polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr);
|
||||
polar_encoder_fast((uint64_t*)testInput, encoderOutput,0, currentPtr);
|
||||
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr);
|
||||
stop_meas(&timeEncoder);
|
||||
/*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
|
||||
printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/
|
||||
@@ -438,14 +438,5 @@ int main(int argc, char *argv[]) {
|
||||
print_meas(&timeDecoder,"polar_decoder",NULL,NULL);
|
||||
|
||||
fclose(logFile);
|
||||
//Bit
|
||||
free(testInput);
|
||||
free(encoderOutput);
|
||||
free(estimatedOutput);
|
||||
//Byte
|
||||
free(encoderOutputByte);
|
||||
free(modulatedInput);
|
||||
free(channelOutput);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ void ccodedab_init_inv(void);
|
||||
|
||||
/*!\fn void crcTableInit(void)
|
||||
\brief This function initializes the different crc tables.*/
|
||||
//void crcTableInit (void);
|
||||
void crcTableInit (void);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -201,7 +201,13 @@ void encode_parity_check_part_optim(uint8_t *c,uint8_t *d, short BG,short Zc,sho
|
||||
int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,short block_length,short BG,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput)
|
||||
{
|
||||
|
||||
short Kb,Zc,nrows,ncols;
|
||||
short Zc;
|
||||
|
||||
//initialize for BG == 1
|
||||
short Kb = 22;
|
||||
short nrows = 46;//parity check bits
|
||||
short ncols = 22;//info bits
|
||||
|
||||
int i,i1;
|
||||
int no_punctured_columns,removed_bit;
|
||||
|
||||
@@ -211,13 +217,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
|
||||
int simd_size;
|
||||
|
||||
//determine number of bits in codeword
|
||||
if (BG==1)
|
||||
{
|
||||
Kb = 22;
|
||||
nrows=46; //parity check bits
|
||||
ncols=22; //info bits
|
||||
}
|
||||
else if (BG==2)
|
||||
if (BG==2)
|
||||
{
|
||||
nrows=42; //parity check bits
|
||||
ncols=10; // info bits
|
||||
@@ -251,7 +251,7 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
|
||||
#endif
|
||||
|
||||
if ((Zc&31) > 0) simd_size = 16;
|
||||
else simd_size = 32;
|
||||
else simd_size = 32;
|
||||
|
||||
unsigned char c[22*Zc] __attribute__((aligned(32))); //padded input, unpacked, max size
|
||||
unsigned char d[46*Zc] __attribute__((aligned(32))); //coded parity part output, unpacked, max size
|
||||
@@ -316,7 +316,13 @@ int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,sh
|
||||
int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,short block_length,short BG,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput)
|
||||
{
|
||||
|
||||
short Kb,Zc,nrows,ncols;
|
||||
short Zc;
|
||||
|
||||
//initialize for BG == 1
|
||||
short Kb = 22;
|
||||
short nrows = 46;//parity check bits
|
||||
short ncols = 22;//info bits
|
||||
|
||||
int i,i1,j;
|
||||
int no_punctured_columns,removed_bit;
|
||||
//Table of possible lifting sizes
|
||||
@@ -343,13 +349,7 @@ int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_i
|
||||
AssertFatal(n_segments>0&&n_segments<=8,"0 < n_segments %d <= 8\n",n_segments);
|
||||
|
||||
//determine number of bits in codeword
|
||||
if (BG==1)
|
||||
{
|
||||
Kb = 22;
|
||||
nrows=46; //parity check bits
|
||||
ncols=22; //info bits
|
||||
}
|
||||
else if (BG==2)
|
||||
if (BG==2)
|
||||
{
|
||||
nrows=42; //parity check bits
|
||||
ncols=10; // info bits
|
||||
|
||||
@@ -367,7 +367,13 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho
|
||||
unsigned char d[68*384]; //coded output, unpacked, max size
|
||||
unsigned char channel_temp,temp;
|
||||
short *Gen_shift_values, *no_shift_values, *pointer_shift_values;
|
||||
short Zc,Kb,nrows,ncols;
|
||||
short Zc;
|
||||
//initialize for BG == 1
|
||||
short Kb = 22;
|
||||
short nrows = 46;//parity check bits
|
||||
short ncols = 22;//info bits
|
||||
|
||||
|
||||
int i,i1,i2,i3,i4,i5,temp_prime,var;
|
||||
int no_punctured_columns,removed_bit;
|
||||
//Table of possible lifting sizes
|
||||
@@ -378,13 +384,7 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho
|
||||
int indlist2[1000];
|
||||
|
||||
//determine number of bits in codeword
|
||||
if (BG==1)
|
||||
{
|
||||
Kb = 22;
|
||||
nrows=46; //parity check bits
|
||||
ncols=22; //info bits
|
||||
}
|
||||
else if (BG==2)
|
||||
if (BG==2)
|
||||
{
|
||||
nrows=42; //parity check bits
|
||||
ncols=10; // info bits
|
||||
@@ -415,7 +415,7 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,sho
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int K = ncols*Zc;
|
||||
//int K = ncols*Zc; //unused variable
|
||||
|
||||
Gen_shift_values=choose_generator_matrix(BG,Zc);
|
||||
if (Gen_shift_values==NULL) {
|
||||
|
||||
@@ -48,11 +48,11 @@ int8_t polar_decoder(
|
||||
{
|
||||
//Assumes no a priori knowledge.
|
||||
|
||||
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
|
||||
@@ -231,9 +231,9 @@ int8_t polar_decoder(
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ int8_t polar_decoder(
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_t_2D_array(tempECGM, polarParams->K);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
|
||||
/*
|
||||
* Return bits.
|
||||
@@ -287,11 +287,11 @@ int8_t polar_decoder_aPriori(double *input,
|
||||
uint8_t pathMetricAppr,
|
||||
double *aPrioriPayload)
|
||||
{
|
||||
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
|
||||
@@ -484,9 +484,9 @@ int8_t polar_decoder_aPriori(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -519,11 +519,11 @@ int8_t polar_decoder_aPriori(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_t_2D_array(tempECGM, polarParams->K);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
|
||||
/*
|
||||
* Return bits.
|
||||
@@ -546,11 +546,11 @@ int8_t polar_decoder_aPriori_timing(double *input,
|
||||
FILE* logFile)
|
||||
{
|
||||
|
||||
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
|
||||
@@ -742,9 +742,9 @@ int8_t polar_decoder_aPriori_timing(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -777,11 +777,11 @@ int8_t polar_decoder_aPriori_timing(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_t_2D_array(tempECGM, polarParams->K);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
|
||||
/*
|
||||
* Return bits.
|
||||
@@ -799,11 +799,11 @@ int8_t polar_decoder_dci(double *input,
|
||||
uint16_t n_RNTI)
|
||||
{
|
||||
|
||||
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
uint8_t extended_crc_scrambling_pattern[polarParams->crcParityBits];
|
||||
@@ -991,9 +991,9 @@ int8_t polar_decoder_dci(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -1026,11 +1026,11 @@ int8_t polar_decoder_dci(double *input,
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_t_2D_array(tempECGM, polarParams->K);
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
|
||||
/*
|
||||
* Return bits.
|
||||
|
||||
@@ -147,11 +147,10 @@ void polar_encoder_dci(uint32_t *in,
|
||||
t_nrPolar_paramsPtr polarParams,
|
||||
uint16_t n_RNTI);
|
||||
|
||||
void polar_encoder_timing(uint32_t *in,
|
||||
uint32_t *out,
|
||||
t_nrPolar_paramsPtr polarParams,
|
||||
double cpuFreqGHz,
|
||||
FILE* logFile);
|
||||
void polar_encoder_fast(uint64_t *A,
|
||||
uint32_t *out,
|
||||
int32_t crcmask,
|
||||
t_nrPolar_paramsPtr polarParams);
|
||||
|
||||
int8_t polar_decoder(double *input,
|
||||
uint8_t *output,
|
||||
@@ -186,7 +185,12 @@ int8_t polar_decoder_dci(double *input,
|
||||
uint8_t pathMetricAppr,
|
||||
uint16_t n_RNTI);
|
||||
|
||||
void generic_polar_decoder(t_nrPolar_params *,decoder_node_t *);
|
||||
void generic_polar_decoder(t_nrPolar_params *,
|
||||
decoder_node_t *);
|
||||
|
||||
void build_decoder_tree(t_nrPolar_params *pp);
|
||||
void build_polar_tables(t_nrPolar_paramsPtr polarParams);
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
|
||||
|
||||
void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
|
||||
int8_t messageType,
|
||||
@@ -212,153 +216,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);
|
||||
void nr_polar_rate_matching_int16(int16_t *input,
|
||||
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_t_1D_uint8_t_2D(uint8_t *matrix1,
|
||||
uint8_t **matrix2,
|
||||
uint8_t *output,
|
||||
uint16_t row,
|
||||
uint16_t col);
|
||||
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 ***nr_alloc_uint8_t_3D_array(uint16_t xlen,
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen,
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
|
||||
uint8_t **nr_alloc_uint8_t_2D_array(uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
double ***nr_alloc_double_3D_array(uint16_t xlen,
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
|
||||
void nr_free_uint8_t_3D_array(uint8_t ***input,
|
||||
uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
void nr_free_uint8_t_2D_array(uint8_t **input,
|
||||
uint16_t xlen);
|
||||
double **nr_alloc_double_2D_array(uint16_t xlen,
|
||||
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);
|
||||
|
||||
void nr_free_uint8_3D_array(uint8_t ***input,
|
||||
uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
void nr_free_uint8_2D_array(uint8_t **input,
|
||||
uint16_t xlen);
|
||||
|
||||
void nr_sort_asc_double_1D_array_ind(double *matrix,
|
||||
uint8_t *ind,
|
||||
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 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);
|
||||
|
||||
void nr_sort_asc_double_1D_array_ind(double *matrix,
|
||||
uint8_t *ind,
|
||||
uint8_t len);
|
||||
uint8_t **crcGen,
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len);
|
||||
|
||||
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits);
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
/*!\file PHY/CODING/nrPolar_tools/nr_polar_encoder.c
|
||||
* \brief
|
||||
* \author Turker Yilmaz
|
||||
* \author Raymond Knopp, Turker Yilmaz
|
||||
* \date 2018
|
||||
* \version 0.1
|
||||
* \company EURECOM
|
||||
* \email turker.yilmaz@eurecom.fr
|
||||
* \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*
|
||||
*/
|
||||
//Calculate CRC.
|
||||
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A,
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_A,
|
||||
polarParams->crc_generator_matrix,
|
||||
polarParams->nr_polar_crc,
|
||||
polarParams->payloadBits,
|
||||
@@ -116,7 +116,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*
|
||||
/* memset(polarParams->nr_polar_U,0,polarParams->N);
|
||||
polarParams->nr_polar_U[247]=1;
|
||||
polarParams->nr_polar_U[253]=1;*/
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U,
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U,
|
||||
polarParams->G_N,
|
||||
polarParams->nr_polar_D,
|
||||
polarParams->N,
|
||||
@@ -177,7 +177,7 @@ void polar_encoder_dci(uint32_t *in,
|
||||
printf("\n");
|
||||
#endif
|
||||
//Calculate CRC.
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_APrime,
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_APrime,
|
||||
polarParams->crc_generator_matrix,
|
||||
polarParams->nr_polar_crc,
|
||||
polarParams->K,
|
||||
@@ -254,7 +254,7 @@ void polar_encoder_dci(uint32_t *in,
|
||||
polarParams->n_pc);
|
||||
|
||||
//Encoding (u to d)
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U,
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U,
|
||||
polarParams->G_N,
|
||||
polarParams->nr_polar_D,
|
||||
polarParams->N,
|
||||
@@ -284,80 +284,6 @@ void polar_encoder_dci(uint32_t *in,
|
||||
#endif
|
||||
}
|
||||
|
||||
void polar_encoder_timing(uint32_t *in,
|
||||
uint32_t *out,
|
||||
t_nrPolar_paramsPtr polarParams,
|
||||
double cpuFreqGHz,
|
||||
FILE* logFile)
|
||||
{
|
||||
//Initiate timing.
|
||||
time_stats_t timeEncoderCRCByte, timeEncoderCRCBit, timeEncoderInterleaver, timeEncoderBitInsertion, timeEncoder1, timeEncoder2, timeEncoderRateMatching, timeEncoderByte2Bit;
|
||||
reset_meas(&timeEncoderCRCByte); reset_meas(&timeEncoderCRCBit); reset_meas(&timeEncoderInterleaver); reset_meas(&timeEncoderBitInsertion); reset_meas(&timeEncoder1); reset_meas(&timeEncoder2); reset_meas(&timeEncoderRateMatching); reset_meas(&timeEncoderByte2Bit);
|
||||
uint16_t n_RNTI=0x0000;
|
||||
|
||||
start_meas(&timeEncoderCRCByte);
|
||||
nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); //(a to a')
|
||||
polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); //Parity bits computation (p)
|
||||
uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); //(a to b)
|
||||
for (int i=0; i<arrayInd-1; i++)
|
||||
for (int j=0; j<8; j++)
|
||||
polarParams->nr_polar_B[j+(i*8)] = ((polarParams->nr_polar_aPrime[3+i]>>(7-j)) & 1);
|
||||
for (int i=0; i<((polarParams->payloadBits)%8); i++) polarParams->nr_polar_B[i+(arrayInd-1)*8] = ((polarParams->nr_polar_aPrime[3+(arrayInd-1)]>>(7-i)) & 1);
|
||||
for (int i=0; i<8; i++) polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1;
|
||||
for (int i=0; i<16; i++) polarParams->nr_polar_B[polarParams->payloadBits+8+i] = ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; //Scrambling (b to c)
|
||||
stop_meas(&timeEncoderCRCByte);
|
||||
|
||||
|
||||
start_meas(&timeEncoderCRCBit);
|
||||
nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A);
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A, polarParams->crc_generator_matrix, polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits); //Calculate CRC.
|
||||
for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
|
||||
for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i]; //Attach CRC to the Transport Block. (a to b)
|
||||
for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)];
|
||||
stop_meas(&timeEncoderCRCBit);
|
||||
|
||||
|
||||
start_meas(&timeEncoderInterleaver); //Interleaving (c to c')
|
||||
nr_polar_interleaver(polarParams->nr_polar_B, polarParams->nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K);
|
||||
stop_meas(&timeEncoderInterleaver);
|
||||
|
||||
|
||||
start_meas(&timeEncoderBitInsertion); //Bit insertion (c' to u)
|
||||
nr_polar_bit_insertion(polarParams->nr_polar_CPrime, polarParams->nr_polar_U, polarParams->N, polarParams->K, polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc);
|
||||
stop_meas(&timeEncoderBitInsertion);
|
||||
|
||||
|
||||
start_meas(&timeEncoder1); //Encoding (u to d)
|
||||
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U, polarParams->G_N, polarParams->nr_polar_D, polarParams->N, polarParams->N);
|
||||
stop_meas(&timeEncoder1);
|
||||
|
||||
|
||||
start_meas(&timeEncoder2);
|
||||
for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2);
|
||||
stop_meas(&timeEncoder2);
|
||||
|
||||
|
||||
start_meas(&timeEncoderRateMatching);//Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e)
|
||||
nr_polar_interleaver(polarParams->nr_polar_D, polarParams->nr_polar_E, polarParams->rate_matching_pattern, polarParams->encoderLength);
|
||||
stop_meas(&timeEncoderRateMatching);
|
||||
|
||||
|
||||
start_meas(&timeEncoderByte2Bit); //Return bits.
|
||||
nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out);
|
||||
stop_meas(&timeEncoderByte2Bit);
|
||||
/*
|
||||
fprintf(logFile,",%f,%f,%f,%f,%f,%f,%f,%f\n",
|
||||
(timeEncoderCRCByte.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoderCRCBit.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoderInterleaver.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoderBitInsertion.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoder1.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoder2.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoderRateMatching.diff_now/(cpuFreqGHz*1000.0)),
|
||||
(timeEncoderByte2Bit.diff_now/(cpuFreqGHz*1000.0)));
|
||||
*/
|
||||
}
|
||||
|
||||
static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,void *out) __attribute__((always_inline));
|
||||
|
||||
static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,void *out) {
|
||||
@@ -371,7 +297,6 @@ static inline void polar_rate_matching(t_nrPolar_paramsPtr polarParams,void *in,
|
||||
}
|
||||
|
||||
void build_polar_tables(t_nrPolar_paramsPtr polarParams) {
|
||||
|
||||
|
||||
// build table b -> c'
|
||||
|
||||
@@ -446,19 +371,19 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) {
|
||||
}
|
||||
iplast=ip;
|
||||
}
|
||||
AssertFatal(mingroupsize==8 || mingroupsize==16,"mingroupsize %d, needs to be handled\n");
|
||||
AssertFatal(mingroupsize==8 || mingroupsize==16,"mingroupsize %d, needs to be handled\n",mingroupsize);
|
||||
polarParams->groupsize=mingroupsize;
|
||||
int shift=3;
|
||||
if (mingroupsize == 16) shift=4;
|
||||
polarParams->rm_tab=(int*)malloc(sizeof(int)*polarParams->encoderLength/mingroupsize);
|
||||
// rerun again to create groups
|
||||
int tcnt;
|
||||
int tcnt=0;
|
||||
for (int outpos=0;outpos<polarParams->encoderLength; outpos+=mingroupsize,tcnt++)
|
||||
polarParams->rm_tab[tcnt] = polarParams->rate_matching_pattern[outpos]>>shift;
|
||||
|
||||
}
|
||||
|
||||
void polar_encoder_fast(int64_t *A,
|
||||
void polar_encoder_fast(uint64_t *A,
|
||||
uint32_t *out,
|
||||
int32_t crcmask,
|
||||
t_nrPolar_paramsPtr polarParams) {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
|
||||
|
||||
void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2,
|
||||
void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1, uint8_t **matrix2,
|
||||
uint8_t *output, uint16_t row, uint16_t col) {
|
||||
|
||||
for (uint16_t i = 0; i < col; i++) {
|
||||
@@ -43,12 +43,12 @@ void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
|
||||
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
|
||||
uint8_t ***output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_uint8_t_3D_array] Problem at 1D allocation");
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
@@ -57,8 +57,8 @@ uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_uint8_t_3D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_t_3D_array(output, xlen, ylen);
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
@@ -69,14 +69,39 @@ uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
if ((output[i][j] = malloc(zlen * sizeof *output[i][j])) == NULL) {
|
||||
perror("[nr_alloc_uint8_t_3D_array] Problem at 3D allocation");
|
||||
nr_free_uint8_t_3D_array(output, xlen, ylen);
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 3D allocation");
|
||||
nr_free_uint8_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen, uint16_t ylen) {
|
||||
uint8_t **output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_uint8_2D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_uint8_2D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_2D_array(output, xlen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = 0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
|
||||
double ***output;
|
||||
int i, j;
|
||||
@@ -137,31 +162,6 @@ double **nr_alloc_double_2D_array(uint16_t xlen, uint16_t ylen) {
|
||||
return output;
|
||||
}
|
||||
|
||||
uint8_t **nr_alloc_uint8_t_2D_array(uint16_t xlen, uint16_t ylen) {
|
||||
uint8_t **output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_uint8_t_2D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_uint8_t_2D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_t_2D_array(output, xlen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = 0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen) {
|
||||
int i, j;
|
||||
|
||||
@@ -174,7 +174,16 @@ void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen) {
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_uint8_t_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen) {
|
||||
void nr_free_double_2D_array(double **input, uint16_t xlen) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
free(input[i]);
|
||||
}
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_uint8_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
@@ -186,20 +195,11 @@ void nr_free_uint8_t_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen) {
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_uint8_t_2D_array(uint8_t **input, uint16_t xlen) {
|
||||
void nr_free_uint8_2D_array(uint8_t **input, uint16_t xlen) {
|
||||
for (int i = 0; i < xlen; i++) free(input[i]);
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_double_2D_array(double **input, uint16_t xlen) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
free(input[i]);
|
||||
}
|
||||
free(input);
|
||||
}
|
||||
|
||||
// Modified Bubble Sort.
|
||||
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) {
|
||||
int swaps;
|
||||
|
||||
@@ -325,7 +325,7 @@ void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp
|
||||
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<=N-1; i++) output[i]=32767;//instead of INFINITY, to prevent [-Woverflow]
|
||||
}
|
||||
|
||||
for (int i=0; i<=E-1; i++){
|
||||
|
||||
@@ -68,7 +68,8 @@ uint32_t nr_compute_tbs(uint8_t mcs,
|
||||
uint8_t Nl)
|
||||
{
|
||||
uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh, Ninfo,Np_info,n,Qm,R,C;
|
||||
uint32_t nr_tbs=0;
|
||||
|
||||
uint32_t nr_tbs = 0;//Initialization to remove [-Wmaybe-uninitialized]
|
||||
|
||||
nb_rb_oh = 0; //set to 0 if not configured by higher layer
|
||||
Qm = Mcsindextable1[mcs][0];
|
||||
|
||||
@@ -39,7 +39,8 @@ int32_t nr_segmentation(unsigned char *input_buffer,
|
||||
unsigned int *F)
|
||||
{
|
||||
|
||||
unsigned int L,Bprime,Bprime_by_C,Z,r,Kb,k,s,Kprime;
|
||||
|
||||
unsigned int L,Bprime,Bprime_by_C,Z,r,Kb,k,s,Kprime;//crc
|
||||
|
||||
if (B<=8448) {
|
||||
L=0;
|
||||
|
||||
@@ -176,7 +176,9 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
|
||||
}
|
||||
|
||||
int nr_init_frame_parms(nfapi_nr_config_request_t* config,
|
||||
NR_DL_FRAME_PARMS *fp) {
|
||||
NR_DL_FRAME_PARMS *fp)
|
||||
{
|
||||
|
||||
|
||||
return nr_init_frame_parms0(fp,
|
||||
config->subframe_config.numerology_index_mu.value,
|
||||
|
||||
@@ -703,7 +703,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
|
||||
|
||||
|
||||
int dlsch_encoding(PHY_VARS_eNB *eNB,
|
||||
unsigned char *a,
|
||||
unsigned char *a,
|
||||
uint8_t num_pdcch_symbols,
|
||||
LTE_eNB_DLSCH_t *dlsch,
|
||||
int frame,
|
||||
|
||||
@@ -265,7 +265,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
|
||||
#endif
|
||||
|
||||
// Payload interleaving
|
||||
uint32_t in=0;
|
||||
uint32_t in=0;//, out=0;
|
||||
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++)
|
||||
in |= (uint32_t)(pbch->pbch_a[i]<<((3-i)<<3));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user