Commit 7bc96c61 authored by Raymond Knopp's avatar Raymond Knopp

addition of up to 128-bit polar decoding, tested up to 64-bit

parent a25d97bc
...@@ -1042,9 +1042,9 @@ int8_t polar_decoder_dci(double *input, ...@@ -1042,9 +1042,9 @@ int8_t polar_decoder_dci(double *input,
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K); AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K);
AssertFatal(polarParams->K < 65, "K = %d > 64, is not supported yet\n",polarParams->K); AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
int bit_i,ip; int bit_i,ip,ipmod64;
int numbytes = polarParams->K>>3; int numbytes = polarParams->K>>3;
int residue = polarParams->K&7; int residue = polarParams->K&7;
...@@ -1055,10 +1055,12 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) { ...@@ -1055,10 +1055,12 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
else numbits=residue; else numbits=residue;
for (int i=0;i<numbits;i++) { for (int i=0;i<numbits;i++) {
ip=polarParams->interleaving_pattern[(8*byte)+i]; ip=polarParams->interleaving_pattern[(8*byte)+i];
AssertFatal(ip<64,"ip = %d\n",ip); ipmod64 = ip&63;
AssertFatal(ip<128,"ip = %d\n",ip);
for (int val=0;val<256;val++) { for (int val=0;val<256;val++) {
bit_i=(val>>i)&1; bit_i=(val>>i)&1;
polarParams->B_tab[byte][val] |= (((uint64_t)bit_i)<<ip); if (ip<64) polarParams->B_tab0[byte][val] |= (((uint64_t)bit_i)<<ipmod64);
else polarParams->B_tab1[byte][val] |= (((uint64_t)bit_i)<<ipmod64);
} }
} }
} }
...@@ -1084,28 +1086,53 @@ int8_t polar_decoder_int16(int16_t *input, ...@@ -1084,28 +1086,53 @@ int8_t polar_decoder_int16(int16_t *input,
//Extract the information bits (û to ĉ) //Extract the information bits (û to ĉ)
uint64_t Cprime=0; uint64_t Cprime[4]={0,0,0,0};
uint64_t B; uint64_t B[4]={0,0,0,0};
for (int i=0;i<polarParams->K;i++) Cprime = Cprime | ((uint64_t)polarParams->nr_polar_U[polarParams->Q_I_N[i]])<<i; for (int i=0;i<polarParams->K;i++) Cprime[i>>6] = Cprime[i>>6] | ((uint64_t)polarParams->nr_polar_U[polarParams->Q_I_N[i]])<<(i&63);
//Deinterleaving (ĉ to b) //Deinterleaving (ĉ to b)
uint8_t *Cprimebyte = (uint8_t*)&Cprime; uint8_t *Cprimebyte = (uint8_t*)Cprime;
B = polarParams->B_tab[0][Cprimebyte[0]] | if (polarParams->K<65) {
polarParams->B_tab[1][Cprimebyte[1]] | B[0] = polarParams->B_tab0[0][Cprimebyte[0]] |
polarParams->B_tab[2][Cprimebyte[2]] | polarParams->B_tab0[1][Cprimebyte[1]] |
polarParams->B_tab[3][Cprimebyte[3]] | polarParams->B_tab0[2][Cprimebyte[2]] |
polarParams->B_tab[4][Cprimebyte[4]] | polarParams->B_tab0[3][Cprimebyte[3]] |
polarParams->B_tab[5][Cprimebyte[5]] | polarParams->B_tab0[4][Cprimebyte[4]] |
polarParams->B_tab[6][Cprimebyte[6]] | polarParams->B_tab0[5][Cprimebyte[5]] |
polarParams->B_tab[7][Cprimebyte[7]]; polarParams->B_tab0[6][Cprimebyte[6]] |
polarParams->B_tab0[7][Cprimebyte[7]];
}
if (polarParams->K<129) {
for (int k=0;k<polarParams->K;k++) {
B[0] |= polarParams->B_tab0[k][Cprimebyte[k]];
B[1] |= polarParams->B_tab1[k][Cprimebyte[k]];
}
}
int len=polarParams->payloadBits;
int len_mod64=len&63;
int quadwpos=len>>6;
int crclen = polarParams->crcParityBits;
int quadwpos2 = polarParams->K>>6;
uint64_t rxcrc;
if (len_mod64==0) rxcrc = 0;
else rxcrc = B[quadwpos]>>len_mod64;
if (quadwpos2>quadwpos) { // there are extra CRC bits in the next quadword
rxcrc |= (B[quadwpos2]<<(64-len_mod64));
}
#if 0 #if 0
printf("Decoded B %llx (crc %x,B>>payloadBits %x)\n",B,crc24c((uint8_t*)&B,polarParams->payloadBits)>>8, printf("Decoded B %llx%llx (crc %x,B>>payloadBits %x)\n",B[1],B[0],crc24c((uint8_t*)&B,polarParams->payloadBits)>>8,
(uint32_t)(B>>polarParams->payloadBits)); (uint32_t)rxcrc);
#endif #endif
if ((uint64_t)(crc24c((uint8_t*)&B[0],polarParams->payloadBits)>>8) == rxcrc) {
if ((uint64_t)(crc24c((uint8_t*)&B,polarParams->payloadBits)>>8) == (B>>polarParams->payloadBits)) { int k=0;
*out = B & (((uint64_t)1<<polarParams->payloadBits)-1); // copy quadwords without CRC directly
for (k=0;k<polarParams->payloadBits/64;k++) out[k]=B[k];
// copy last one
out[k] = B[k] & (((uint64_t)1<<(polarParams->payloadBits&63))-1);
return(0); return(0);
} }
......
...@@ -115,7 +115,8 @@ struct nrPolar_params { ...@@ -115,7 +115,8 @@ struct nrPolar_params {
int *rm_tab; int *rm_tab;
uint64_t cprime_tab0[8][256]; uint64_t cprime_tab0[8][256];
uint64_t cprime_tab1[8][256]; uint64_t cprime_tab1[8][256];
uint64_t B_tab[8][256]; uint64_t B_tab0[8][256];
uint64_t B_tab1[8][256];
uint32_t* crc256Table; uint32_t* crc256Table;
uint8_t **extended_crc_generator_matrix; uint8_t **extended_crc_generator_matrix;
//lowercase: bits, Uppercase: Bits stored in bytes //lowercase: bits, Uppercase: Bits stored in bytes
......
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