Commit 4c86d4fb authored by Florian Kaltenberger's avatar Florian Kaltenberger

adding latest version of ldpc_encoder from branch feature_ldpc_coding

parent 188a6013
...@@ -1089,6 +1089,7 @@ set(PHY_SRC ...@@ -1089,6 +1089,7 @@ set(PHY_SRC
${OPENAIR1_DIR}/PHY/CODING/nr_segmentation.c ${OPENAIR1_DIR}/PHY/CODING/nr_segmentation.c
${OPENAIR1_DIR}/PHY/CODING/ldpc_decoder.c ${OPENAIR1_DIR}/PHY/CODING/ldpc_decoder.c
${OPENAIR1_DIR}/PHY/CODING/ldpc_encoder.c ${OPENAIR1_DIR}/PHY/CODING/ldpc_encoder.c
${OPENAIR1_DIR}/PHY/CODING/ldpc_generate_coefficient.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c
${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c ${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "SIMULATION/TOOLS/defs.h" #include "SIMULATION/TOOLS/defs.h"
// 4-bit quantizer // 4-bit quantizer
char quantize4bit(double D,double x) char quantize4bit(double D,double x)
{ {
...@@ -81,7 +83,7 @@ int test_ldpc(short No_iteration, ...@@ -81,7 +83,7 @@ int test_ldpc(short No_iteration,
double *modulated_input; double *modulated_input;
short *channel_output_fixed; short *channel_output_fixed;
unsigned int i,trial=0; unsigned int i,trial=0;
short BG,Zc,Kb,nrows,ncols,channel_temp; short BG,Zc,Kb,nrows,ncols;
int no_punctured_columns,removed_bit; int no_punctured_columns,removed_bit;
int i1; int i1;
//Table of possible lifting sizes //Table of possible lifting sizes
...@@ -93,10 +95,9 @@ int test_ldpc(short No_iteration, ...@@ -93,10 +95,9 @@ int test_ldpc(short No_iteration,
channel_input = (unsigned char *)malloc(sizeof(unsigned char) * 68*384); channel_input = (unsigned char *)malloc(sizeof(unsigned char) * 68*384);
modulated_input = (double *)malloc(sizeof(double) * 68*384); modulated_input = (double *)malloc(sizeof(double) * 68*384);
channel_output = (double *)malloc(sizeof(double) * 68*384); channel_output = (double *)malloc(sizeof(double) * 68*384);
reset_meas(&time); reset_meas(&time);
while (trial++ < ntrials)
{
for (i=0; i<block_length/8; i++) for (i=0; i<block_length/8; i++)
{ {
//test_input[i]=(unsigned char) rand(); //test_input[i]=(unsigned char) rand();
...@@ -104,15 +105,13 @@ int test_ldpc(short No_iteration, ...@@ -104,15 +105,13 @@ int test_ldpc(short No_iteration,
} }
//determine number of bits in codeword //determine number of bits in codeword
//if (block_length>3840) if (block_length>3840)
//{ {
BG=1; BG=1;
Kb = 22; Kb = 22;
nrows=46; //parity check bits nrows=46; //parity check bits
ncols=22; //info bits ncols=22; //info bits
}
// }
/*
else if (block_length<=3840) else if (block_length<=3840)
{ {
BG=2; BG=2;
...@@ -128,8 +127,9 @@ int test_ldpc(short No_iteration, ...@@ -128,8 +127,9 @@ int test_ldpc(short No_iteration,
else else
Kb = 6; Kb = 6;
} }
*/
//find minimum value in all sets of lifting size //find minimum value in all sets of lifting size
Zc=0;
for (i1=0; i1 < 51; i1++) for (i1=0; i1 < 51; i1++)
{ {
if (lift_size[i1] >= (double) block_length/Kb) if (lift_size[i1] >= (double) block_length/Kb)
...@@ -140,21 +140,30 @@ int test_ldpc(short No_iteration, ...@@ -140,21 +140,30 @@ int test_ldpc(short No_iteration,
} }
} }
printf("BG %d, Zc %d, Kb %d\n",BG, Zc, Kb);
no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length/rate)/Zc; no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length/rate)/Zc;
//printf("%d\n",no_punctured_columns); //printf("%d\n",no_punctured_columns);
start_meas(&time);
for (trial=0; trial < ntrials; trial++)
{
//// encoder //// encoder
if (ntrials==1)
ldpc_encoder_orig(test_input, channel_input,block_length,rate,1);
else {
start_meas(&time);
if (BG==1)
ldpc_encoder(test_input, channel_input,block_length,rate); ldpc_encoder(test_input, channel_input,block_length,rate);
else
ldpc_encoder_orig(test_input, channel_input,block_length,rate,0);
stop_meas(&time); stop_meas(&time);
print_meas_now(&time, "", stdout); }
//print_meas_now(&time, "", stdout);
for (i=0; i<10; i++)
printf("channel_input[%d]=%d\n",i,channel_input[i]);
ldpc_encoder_orig(test_input, channel_input,block_length,rate);
for (i=0; i<10; i++) // for (i=0;i<8448;i++)
printf("channel_input[%d]=%d\n",i,channel_input[i]); //printf("channel_input[%d]=%d\n",i,channel_input[i]);
//printf("%d ",channel_input[i]);
if ((BG==2) && (Zc==128||Zc==256)) if ((BG==2) && (Zc==128||Zc==256))
{ {
...@@ -210,24 +219,27 @@ int test_ldpc(short No_iteration, ...@@ -210,24 +219,27 @@ int test_ldpc(short No_iteration,
free(channel_output_fixed); free(channel_output_fixed);
} }
else else
if (trial==0)
printf("decoder is not supported\n"); printf("decoder is not supported\n");
} }
print_meas(&time, "ldpc encoder", NULL, NULL); print_meas(&time,"ldpc_encoder",NULL,NULL);
return *errors; return *errors;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
unsigned int errors,crc_misses; unsigned int errors,crc_misses;
short block_length=22*128; // decoder supports length: 1201 -> 1280, 2401 -> 2560 short block_length=22*384; // decoder supports length: 1201 -> 1280, 2401 -> 2560
short No_iteration=25; short No_iteration=25;
double rate=0.333; double rate=0.333;
double SNR,SNR_lin; double SNR,SNR_lin;
unsigned char qbits=4; unsigned char qbits=4;
unsigned int decoded_errors[100]; // initiate the size of matrix equivalent to size of SNR unsigned int decoded_errors[100]; // initiate the size of matrix equivalent to size of SNR
int c,i=0; int c,i=0;
int ntrials = 100; int n_trials = 100;
randominit(0); randominit(0);
while ((c = getopt (argc, argv, "q:r:l:n:")) != -1) while ((c = getopt (argc, argv, "q:r:l:n:")) != -1)
...@@ -246,7 +258,7 @@ int main(int argc, char *argv[]) ...@@ -246,7 +258,7 @@ int main(int argc, char *argv[])
break; break;
case 'n': case 'n':
ntrials = atoi(optarg); n_trials = atoi(optarg);
break; break;
default: default:
...@@ -266,10 +278,10 @@ int main(int argc, char *argv[]) ...@@ -266,10 +278,10 @@ int main(int argc, char *argv[])
SNR_lin, // noise standard deviation SNR_lin, // noise standard deviation
qbits, qbits,
block_length, // block length bytes block_length, // block length bytes
ntrials, n_trials,
&errors, &errors,
&crc_misses); &crc_misses);
printf("SNR %f, BLER %f (%d/%d)\n",SNR,(float)decoded_errors[i]/(float)ntrials,decoded_errors[i],ntrials); printf("SNR %f, BLER %f (%d/%d)\n",SNR,(float)decoded_errors[i]/(float)n_trials,decoded_errors[i],n_trials);
i=i+1; i=i+1;
} }
...@@ -277,3 +289,4 @@ int main(int argc, char *argv[]) ...@@ -277,3 +289,4 @@ int main(int argc, char *argv[])
} }
...@@ -573,5 +573,6 @@ void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t); ...@@ -573,5 +573,6 @@ void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t);
short *ldpc_decoder(short *msgChannel,short block_length,short No_iteration,double rate); short *ldpc_decoder(short *msgChannel,short block_length,short No_iteration,double rate);
int ldpc_encoder(unsigned char *test_input,unsigned char* channel_input,short block_length,double rate); int ldpc_encoder(unsigned char *test_input,unsigned char* channel_input,short block_length,double rate);
int ldpc_encoder_orig(unsigned char *test_input,unsigned char* channel_input,short block_length,double rate,unsigned char gen_code);
#endif #endif
This diff is collapsed.
This diff is collapsed.
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