Commit 88d5bf42 authored by Raymond Knopp's avatar Raymond Knopp

16-bit llr decoder integrated

parent fa4a73bb
...@@ -151,6 +151,8 @@ int main(int argc, char *argv[]) { ...@@ -151,6 +151,8 @@ int main(int argc, char *argv[]) {
uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength); uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength);
double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input
double *channelOutput = malloc (sizeof(double) * coderLength); //add noise 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);
t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL;
nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level);
...@@ -323,13 +325,6 @@ int main(int argc, char *argv[]) { ...@@ -323,13 +325,6 @@ int main(int argc, char *argv[]) {
/*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/
/*
if (decoder_int16==1) {
if (channelOutput[i] > 15) channelOutput_int8[i] = 127;
else if (channelOutput[i] < -16) channelOutput_int8[i] = -128;
else channelOutput_int8[i] = (int16_t) (8*channelOutput[i]);
}
*/
//Bit-to-byte: //Bit-to-byte:
nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte);
...@@ -341,6 +336,15 @@ int main(int argc, char *argv[]) { ...@@ -341,6 +336,15 @@ int main(int argc, char *argv[]) {
modulatedInput[i]=(-1)/sqrt(2); modulatedInput[i]=(-1)/sqrt(2);
channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
if (decoder_int16==1) {
if (channelOutput[i] > 15) channelOutput_int16[i] = 127;
else if (channelOutput[i] < -16) channelOutput_int16[i] = -128;
else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]);
}
} }
start_meas(&timeDecoder); start_meas(&timeDecoder);
...@@ -350,12 +354,19 @@ int main(int argc, char *argv[]) { ...@@ -350,12 +354,19 @@ int main(int argc, char *argv[]) {
NR_POLAR_DECODER_LISTSIZE, NR_POLAR_DECODER_LISTSIZE,
aPrioriArray, aPrioriArray,
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/
if (decoder_int16==0)
decoderState = polar_decoder_aPriori(channelOutput, decoderState = polar_decoder_aPriori(channelOutput,
estimatedOutput, estimatedOutput,
currentPtr, currentPtr,
NR_POLAR_DECODER_LISTSIZE, NR_POLAR_DECODER_LISTSIZE,
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION,
aPrioriArray); aPrioriArray);
else
decoderState = polar_decoder_int16(channelOutput_int16,
estimatedOutput,
currentPtr);
stop_meas(&timeDecoder); stop_meas(&timeDecoder);
/*printf("testInput: [0]->0x%08x\n", testInput[0]); /*printf("testInput: [0]->0x%08x\n", testInput[0]);
printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/
......
...@@ -1039,7 +1039,7 @@ int8_t polar_decoder_dci(double *input, ...@@ -1039,7 +1039,7 @@ int8_t polar_decoder_dci(double *input,
int8_t polar_decoder_int16(int16_t *input, int8_t polar_decoder_int16(int16_t *input,
uint8_t *output, uint8_t *out,
t_nrPolar_params *polarParams) t_nrPolar_params *polarParams)
{ {
...@@ -1069,9 +1069,9 @@ int8_t polar_decoder_int16(int16_t *input, ...@@ -1069,9 +1069,9 @@ int8_t polar_decoder_int16(int16_t *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++) output[j]=polarParams->nr_polar_B[j]; for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j];
nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out);
return(0); return(0);
} }
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "PHY/sse_intrin.h" #include "PHY/sse_intrin.h"
#include "PHY/impl_defs_top.h" #include "PHY/impl_defs_top.h"
//#define DEBUG_NEW_IMPL
void updateLLR(double ***llr, void updateLLR(double ***llr,
uint8_t **llrU, uint8_t **llrU,
...@@ -276,6 +277,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -276,6 +277,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
__m256i a256,b256,absa256,absb256,minabs256; __m256i a256,b256,absa256,absb256,minabs256;
int avx2len = node->Nv/2/16; int avx2len = node->Nv/2/16;
// printf("avx2len %d\n",avx2len);
for (int i=0;i<avx2len;i++) { for (int i=0;i<avx2len;i++) {
a256 =((__m256i*)alpha_v)[i]; a256 =((__m256i*)alpha_v)[i];
b256 =((__m256i*)alpha_v)[i+avx2len]; b256 =((__m256i*)alpha_v)[i+avx2len];
...@@ -283,6 +285,13 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -283,6 +285,13 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
absb256 =_mm256_abs_epi16(b256); absb256 =_mm256_abs_epi16(b256);
minabs256 =_mm256_min_epi16(absa256,absb256); minabs256 =_mm256_min_epi16(absa256,absb256);
((__m256i*)alpha_l)[i] =_mm256_sign_epi16(minabs256,_mm256_xor_si256(a256,b256)); ((__m256i*)alpha_l)[i] =_mm256_sign_epi16(minabs256,_mm256_xor_si256(a256,b256));
/* for (int j=0;j<16;j++) printf("alphal[%d] %d (%d,%d,%d)\n",
(16*i) + j,
alpha_l[(16*i)+j],
((int16_t*)&minabs256)[j],
alpha_v[(16*i)+j],
alpha_v[(16*i)+j+(node->Nv/2)]);
*/
} }
} }
else if (avx2mod == 8) { else if (avx2mod == 8) {
...@@ -315,6 +324,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -315,6 +324,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
absb=(b+maskb)^maskb; absb=(b+maskb)^maskb;
minabs = absa<absb ? absa : absb; minabs = absa<absb ? absa : absb;
alpha_l[i] = (maska^maskb)==0 ? minabs : -minabs; alpha_l[i] = (maska^maskb)==0 ? minabs : -minabs;
// printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b);
} }
} }
if (node->Nv == 2) { // apply hard decision on left node if (node->Nv == 2) { // apply hard decision on left node
...@@ -368,7 +378,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { ...@@ -368,7 +378,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *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; pp->nr_polar_U[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 frozen_mask %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0],frozen_mask); printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]);
#endif #endif
} }
} }
......
...@@ -147,6 +147,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -147,6 +147,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
free(J); free(J);
build_decoder_tree(newPolarInitNode);
printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created");
} }
......
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