Commit c660a1e5 authored by Raymond Knopp's avatar Raymond Knopp

made original polar encoder/decoder work again in polartest.

parent df8b32b8
...@@ -369,7 +369,7 @@ int main(int argc, char *argv[]) { ...@@ -369,7 +369,7 @@ int main(int argc, char *argv[]) {
aPrioriArray); aPrioriArray);
else else
decoderState = polar_decoder_int16(channelOutput_int16, decoderState = polar_decoder_int16(channelOutput_int16,
estimatedOutput, (uint64_t*)estimatedOutput,
currentPtr); currentPtr);
...@@ -391,7 +391,7 @@ int main(int argc, char *argv[]) { ...@@ -391,7 +391,7 @@ int main(int argc, char *argv[]) {
if (nBitError>0) { if (nBitError>0) {
blockErrorState=1; blockErrorState=1;
printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]); // printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]);
} }
} }
......
...@@ -256,6 +256,7 @@ int8_t polar_decoder( ...@@ -256,6 +256,7 @@ int8_t polar_decoder(
//Deinterleaving (ĉ to b) //Deinterleaving (ĉ to b)
nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K);
//Remove the CRC (â) //Remove the CRC (â)
for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j];
...@@ -280,13 +281,13 @@ int8_t polar_decoder( ...@@ -280,13 +281,13 @@ int8_t polar_decoder(
} }
int8_t polar_decoder_aPriori(double *input, int8_t polar_decoder_aPriori(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_paramsPtr polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload) double *aPrioriPayload)
{ {
uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); 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 **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 **llrUpdated = nr_alloc_uint8_t_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); double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
...@@ -509,8 +510,8 @@ int8_t polar_decoder_aPriori(double *input, ...@@ -509,8 +510,8 @@ int8_t polar_decoder_aPriori(double *input,
nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K);
//Remove the CRC (â) //Remove the CRC (â)
for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; for (int j = 0; j < polarParams->payloadBits; j++)
polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j];
break; break;
} }
} }
...@@ -528,6 +529,7 @@ int8_t polar_decoder_aPriori(double *input, ...@@ -528,6 +529,7 @@ int8_t polar_decoder_aPriori(double *input,
* Return bits. * Return bits.
*/ */
nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out);
return(0); return(0);
} }
...@@ -1064,7 +1066,7 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { ...@@ -1064,7 +1066,7 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
} }
int8_t polar_decoder_int16(int16_t *input, int8_t polar_decoder_int16(int16_t *input,
uint8_t *out, uint64_t *out,
t_nrPolar_params *polarParams) t_nrPolar_params *polarParams)
{ {
...@@ -1103,7 +1105,7 @@ int8_t polar_decoder_int16(int16_t *input, ...@@ -1103,7 +1105,7 @@ int8_t polar_decoder_int16(int16_t *input,
#endif #endif
if ((uint64_t)(crc24c((uint8_t*)&B,polarParams->payloadBits)>>8) == (B>>polarParams->payloadBits)) { if ((uint64_t)(crc24c((uint8_t*)&B,polarParams->payloadBits)>>8) == (B>>polarParams->payloadBits)) {
*((uint64_t *)out) = B & (((uint64_t)1<<polarParams->payloadBits)-1); *out = B & (((uint64_t)1<<polarParams->payloadBits)-1);
return(0); return(0);
} }
else return(-1); else return(-1);
......
...@@ -157,6 +157,10 @@ int8_t polar_decoder(double *input, ...@@ -157,6 +157,10 @@ int8_t polar_decoder(double *input,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr); uint8_t pathMetricAppr);
int8_t polar_decoder_int16(int16_t *input,
uint64_t *out,
t_nrPolar_params *polarParams);
int8_t polar_decoder_aPriori(double *input, int8_t polar_decoder_aPriori(double *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_paramsPtr polarParams,
......
...@@ -45,35 +45,39 @@ void polar_encoder(uint32_t *in, ...@@ -45,35 +45,39 @@ void polar_encoder(uint32_t *in,
t_nrPolar_paramsPtr polarParams) t_nrPolar_paramsPtr polarParams)
{ {
if (polarParams->idx == 0){//PBCH if (polarParams->idx == 0){//PBCH
/*
uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<<polarParams->payloadBits); uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<<polarParams->payloadBits);
#ifdef DEBUG_POLAR_ENCODER #ifdef DEBUG_POLAR_ENCODER
printf("polar_B %llx (crc %x)\n",B,crc24c((uint8_t*)in,polarParams->payloadBits)>>8); printf("polar_B %llx (crc %x)\n",B,crc24c((uint8_t*)in,polarParams->payloadBits)>>8);
#endif #endif
nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B); nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/
nr_bit2byte_uint32_8_t((uint32_t*)in, polarParams->payloadBits, polarParams->nr_polar_A);
/* /*
* Bytewise operations * Bytewise operations
*/ */
//Calculate CRC. //Calculate CRC.
/*
nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A, nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A,
polarParams->crc_generator_matrix, polarParams->crc_generator_matrix,
polarParams->nr_polar_crc, polarParams->nr_polar_crc,
polarParams->payloadBits, polarParams->payloadBits,
polarParams->crcParityBits); polarParams->crcParityBits);
for (uint8_t i = 0; i < polarParams->crcParityBits; i++) for (uint8_t i = 0; i < polarParams->crcParityBits; i++)
polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
//Attach CRC to the Transport Block. (a to b) //Attach CRC to the Transport Block. (a to b)
for (uint16_t i = 0; i < polarParams->payloadBits; i++) for (uint16_t i = 0; i < polarParams->payloadBits; i++)
polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i]; polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i];
for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++)
polarParams->nr_polar_B[i]= 0;//polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)];
*/
#ifdef DEBUG_POLAR_ENCODER
uint64_t B2=0; uint64_t B2=0;
for (int i = 0;i<polarParams->K;i++) B2 = B2 | ((uint64_t)polarParams->nr_polar_B[i] << i); for (int i = 0;i<polarParams->K;i++) B2 = B2 | ((uint64_t)polarParams->nr_polar_B[i] << i);
printf("polar_B %llx\n",B2); printf("polar_B %llx\n",B2);
#endif
/* for (int j=0;j<polarParams->crcParityBits;j++) { /* for (int j=0;j<polarParams->crcParityBits;j++) {
for (int i=0;i<polarParams->payloadBits;i++) for (int i=0;i<polarParams->payloadBits;i++)
printf("%1d.%1d+",polarParams->crc_generator_matrix[i][j],polarParams->nr_polar_A[i]); printf("%1d.%1d+",polarParams->crc_generator_matrix[i][j],polarParams->nr_polar_A[i]);
...@@ -90,13 +94,13 @@ void polar_encoder(uint32_t *in, ...@@ -90,13 +94,13 @@ void polar_encoder(uint32_t *in,
polarParams->interleaving_pattern, polarParams->interleaving_pattern,
polarParams->K); polarParams->K);
#ifdef DEBUG_POLAR_ENCODER
uint64_t Cprime=0; uint64_t Cprime=0;
for (int i = 0;i<polarParams->K;i++) { for (int i = 0;i<polarParams->K;i++) {
Cprime = Cprime | ((uint64_t)polarParams->nr_polar_CPrime[i] << i); Cprime = Cprime | ((uint64_t)polarParams->nr_polar_CPrime[i] << i);
if (polarParams->nr_polar_CPrime[i] == 1) printf("pos %d : %llx\n",i,Cprime); if (polarParams->nr_polar_CPrime[i] == 1) printf("pos %d : %llx\n",i,Cprime);
} }
#ifdef DEBUG_POLAR_ENCODER
printf("polar_Cprime %llx\n",Cprime); printf("polar_Cprime %llx\n",Cprime);
#endif #endif
//Bit insertion (c' to u) //Bit insertion (c' to u)
......
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