* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "SIMULATION/TOOLS/defs.h"
#include "Gen_shift_value.h"
#include "test.h"
// 4-bit quantizer
char quantize4bit(double D,double x)
{
double qxd;
qxd = floor(x/D);
// printf("x=%f,qxd=%f\n",x,qxd);
if (qxd <= -8)
qxd = -8;
else if (qxd > 7)
qxd = 7;
return((char)qxd);
}
char quantize(double D,double x,unsigned char B)
{
double qxd;
char maxlev;
qxd = floor(x/D);
// printf("x=%f,qxd=%f\n",x,qxd);
maxlev = 1<<(B-1);
if (qxd <= -maxlev)
qxd = -maxlev;
else if (qxd >= maxlev)
qxd = maxlev-1;
return((char)qxd);
}
//#define MAX_BLOCK_LENGTH 6000
#define MAX_BLOCK_LENGTH 8448
/*
int test_ldpc(unsigned int coded_bits,
double sigma,
unsigned char qbits,
unsigned int block_length,
unsigned int ntrials,
unsigned int *errors,
unsigned int *trials,
unsigned int *uerrors,
unsigned int *crc_misses,
unsigned int *iterations)
*/
int test_ldpc(short No_iteration,
double rate,
double SNR,
unsigned char qbits,
unsigned int block_length,
unsigned int ntrials,
unsigned int *errors,
unsigned int *crc_misses)
{
//unsigned char test_input[block_length+1];
short test_input[block_length];
short *c; //padded codeword
short *esimated_output;
short *channel_input;
double *channel_output;
double *modulated_input;
short *channel_output_fixed;
unsigned int i,trial=0;
unsigned char crc_type;
short *Gen_shift_values, *no_shift_values, *pointer_shift_values;
short BG,Zc,Kb,nrows,ncols;
int i1,i2,i3,i4,t;
//Table of possible lifting sizes
short lift_size[51]={2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384};
int *idxBit, idxCheck,*degBit, *degCheck,*degBit_base_graph, *pointerCheck, *pointerBit, *pointerCheck_temp, *pointerBit_temp;
int *idxEdge2Bit,*idxEdge2Check;
int *no_rows;
int rows_total;
short *msgBit2Check, *msgCheck2Bit, *msgBit; //variables for message passing algorithm
short mini;
short sgn;
int isEqual;
char syn; //syndrome
short lift_size[51]={2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384};
short shift_value[197]={9,117,204,26,189,205,0,0,167,166,253,125,226,156,224,252,0,0,81,114,44,52,240,1,0,0,8,58,158,104,209,54,18,128,0,0,179,214,71,0,231,41,194,159,103,0,155,228,45,28,158,0,129,147,140,3,116,0,142,94,230,0,203,205,61,247,0,11,185,0,117,0,11,236,210,56,0,63,111,14,0,83,2,38,222,0,115,145,3,232,0,51,175,213,0,203,142,8,242,0,254,124,114,64,0,220,194,50,0,87,20,185,0,26,105,29,0,76,42,210,0,222,63,0,23,235,238,0,46,139,8,0,228,156,0,29,143,160,122,0,8,151,0,98,101,135,0,18,28,0,71,240,9,84,0,106,1,0,242,44,166,0,132,164,235,0,147,85,36,0,57,40,63,0,140,38,154,0,219,151,0,31,66,38,0,239,172,34,0,0,75,120,0,129,229,118,0};
short Col_position[197]={0,1,2,3,6,9,10,11,0,3,4,5,6,7,8,9,11,12,0,1,3,4,8,10,12,13,1,2,4,5,6,7,8,9,10,13,0,1,11,14,0,1,5,7,11,15,0,5,7,9,11,16,1,5,7,11,13,17,0,1,12,18,1,8,10,11,19,0,1,6,7,20,0,7,9,13,21,1,3,11,22,0,1,8,13,23,1,6,11,13,24,0,10,11,25,1,9,11,12,26,1,5,11,12,27,0,6,7,28,0,1,10,29,1,4,11,30,0,8,13,31,1,2,32,0,3,5,33,1,2,9,34,0,5,35,2,7,12,13,36,0,6,37,1,2,5,38,0,4,39,2,5,7,9,40,1,13,41,0,5,12,42,2,7,10,43,0,12,13,44,1,5,11,45,0,2,7,46,10,13,47,1,5,11,48,0,7,12,49,2,10,13,50,1,5,11,51};