Commit a611e0b9 authored by martino's avatar martino

Fixing of some errors

parent 92cdd224
......@@ -121,7 +121,8 @@ int main(int argc, char *argv[]) {
SNR_lin = pow(10, SNR/10);
for (itr = 1; itr <= iterations; itr++) {
for(int i=0; i<testLength; i++) testInput[i]=(uint8_t) (rand() % 2);
for(int i=0; i<testLength; i++)
testInput[i]=(uint8_t) (rand() % 2);
start_meas(&timeEncoder);
polar_encoder(testInput, encoderOutput, &nrPolar_params);
......
......@@ -252,11 +252,10 @@ void nr_crc_computation(uint8_t* input, uint8_t* output, uint16_t payloadBits, u
unsigned int crcBits;
crcBits = crcPayload(input2, payloadBits, crc256Table);
//create crc in byte
unsigned int mask2=0x80000000; //100...
output = (uint8_t*)malloc(sizeof(uint8_t)*crcParityBits);
for(uint8_t ind=0; ind<crcParityBits; ind++)
{
if(crcBits & mask2)
......@@ -264,7 +263,7 @@ void nr_crc_computation(uint8_t* input, uint8_t* output, uint16_t payloadBits, u
else
output[ind]=0;
mask2 = mask2 >> 1;
mask2 = mask2 >> 1;
}
}
......
......@@ -137,7 +137,6 @@ uint32_t poly24c = 0xB2B11700; //101100101011000100010111 -> D^24...
polarParams->crc256Table = malloc(sizeof(uint32_t)*256);
crcTable256Init(polarParams->crc_polynomial, polarParams->crc256Table);
polarParams->Q_0_Nminus1 = nr_polar_sequence_pattern(polarParams->n);
polarParams->interleaving_pattern = malloc(sizeof(uint16_t) * polarParams->K);
......
......@@ -37,8 +37,10 @@ void polar_encoder(
//nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(input, polarParams->crc_generator_matrix,
// polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits);
//for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
// --- NEW ---
nr_crc_computation(input, polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits, polarParams->crc256Table);
//Attach CRC to the Transport Block. (a to b)
for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_b[i] = input[i];
......@@ -56,10 +58,16 @@ void polar_encoder(
// --- OLD ---
//nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_u, polarParams->G_N, polarParams->nr_polar_d, polarParams->N, polarParams->N);
//for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2);
//printf("\nd old: ");
//for (uint16_t i = 0; i < polarParams->N; i++)
//printf("%i ", polarParams->nr_polar_d[i]);
// --- NEW ---
nr_polar_kernal_operation(polarParams->nr_polar_u, polarParams->nr_polar_d, polarParams->N);
for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2);
//printf("\nd new: ");
//for (uint16_t i = 0; i < polarParams->N; i++)
// printf("%i ", polarParams->nr_polar_d[i]);
//for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2);
//Rate matching
//Sub-block interleaving (d to y) and Bit selection (y to e)
......
......@@ -16,12 +16,15 @@ void nr_polar_kernal_operation(uint8_t *u, uint8_t *d, uint16_t N)
d[i]=0;
for(j=0; j<N; j++) // ... looking at all the elements of u
{
d[i]=d[i] || ( (!(j-i)) | (!i) )*u[j];
//d[i]=d[i] || ( (!(j-i)) | (!i) )*u[j];
d[i]=d[i] ^ (!( (j-i)& i ))*u[j];
}
//d[i]=d[i]%2; // modulo 2
}
/*
__m256i maddReg, uReg, orReg;
__m512i maddRegConv;
......
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