////////////////////////////////////////////////////////////////////////////////////////// // // // Module: bitLrsolomon_imp.c // // // // FUNCTION: Reed Solomon eccoder // // // // Description: Bit Level Control mode for Downlink WiMAX IEEE802.16e rel 2005 // // // // // // // // // //June 2009 // ////////////////////////////////////////////////////////////////////////////////////////// /** ALOE headers */ #include #include #include #include "itf_types.h" #include "inputs.h" #include "outputs.h" #include "stats.h" #include "utils.h" #include "rsol_code.h" /*GLOBAL VARIABLES*/ int data_rcved=0; //Data received-->data_rcved=1 //Data non received-->data_rcved=0 /*PREDEFINED FUNCTIONS*/ void Init_Controlfunction(); int datainflow_bypass(int len); //void randomize(int datain[],int dataout[],int length); void Init_rsolomon(); ////////////////////////////////////////////////////////////////////////////////////////// //SQUELETON CALLED FUNCTIONS////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //CONTROL ////////////////////////////////////////////////////////////////////////CONTROL/ ////////////////////////////////////////////////////////////////////////////////////////// //INPUT/////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /*Returns the length(in control in type words) of the expected control flow at each time-slot*/ //Funtion activated if control flow has been received*/ /*Check INPUT_MAX_CONTROL*/ int get_controlin_length() { int length=1; length=control_length(); return(length); } /*Process the received control flow according to the length returned by get_controlin_length()*/ /*"len" indicates the number of control words to be processed*/ int process_inputcontrol(int len) { process_control_input(len); return(1); /*return 1 if OK; return 0 if error*/ } ////////////////////////////////////////////////////////////////////////////////////////// //OUTPUT////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /*Returns the length (in control out type words) of the generated control flow at each time-slot*/ /*Check OUTPUT_MAX_CONTROL*/ int get_controlout_length() { int length=1; return(length); } /*Generate the control word to be send according the length provided by get_controlout_length()*/ /*"len" indicates the number of control words to be generated*/ int generate_outputcontrol(int len) { /*return 1 if OK; return 0 if error*/ return(1); } ////////////////////////////////////////////////////////////////////////////////////////// //DATA/////////////////////////////////////////////////////////////////////////////DATA/// ////////////////////////////////////////////////////////////////////////////////////////// //INPUT/////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /*Returns the length(in data in type words) of the expected data flow at each time-slot*/ //Funtion activated only if data flow has been received*/ /*Check INPUT_MAX_DATA*/ int get_datain_length() { int length=1; length=datain_length(); return(length); } /*Process the received data flow according to the length returned by get_datain_length()*/ /** Run function. return 1 if ok, 0 if error*/ /*"len" indicates the number of data words to be processed*/ int process_inputdata(int len) { //printf("rsolomon: process_inputdata\n"); data_rcved=1; //The execution of this function implies that enough data has been received //Testing flows purposes if(control_rsolomon[0].CExec.status==TEST_FLOW)datainflow_bypass(len); //Testing module processing functionality if(control_rsolomon[0].CExec.status==TEST_PROCESS)test_rsolomon(); //Normal rsolomon encoder execution if(control_rsolomon[0].CExec.status==ACTIVE)process_datainflow(len); return 1; } ////////////////////////////////////////////////////////////////////////////////////////// //OUTPUT////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /*Returns the length (in data out type words) of the generated data flow at each time-slot*/ int get_dataout_length() { int length; length=0; if(data_rcved==0)return(length); data_rcved=0; length=dataout_length(); return(length); } /*Generate the control word to be send according the length provided by get_controlout_length()*/ /** Run function. return 1 if ok, 0 if error*/ /*"len" indicates the number of data words to be generated*/ int generate_outputdata(int len) { return 1; } int InitCustom() { Init_Controlfunction(); void Init_rsolomon(); return 1; } int RunCustom() { return 1; } ////////////////////////////////////////////////////////////////////////////////////////// //END SQUELETON CALLED FUNCTIONS////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //######################################################################################// ////////////////////////////////////////////////////////////////////////////////////////// //ESPECIFIC MODULE FUNCTIONS////////////////////////////////////////////////////////////// //CONTROL////////////////////////////////////////////////////////////////////////CONTROL// ////////////////////////////////////////////////////////////////////////////////////////// void Init_Controlfunction() { control_rsolomon[0].CExec.status=NONACTIVE; control_rsolomon[0].CData.ninputbytes=0; control_rsolomon[0].CData.noutputbytes=0; } void Init_rsolomon(){ /* Variables Inicialization */ } int control_length() { return(INPUT_MAX_CONTROL); } int process_control_input(int len) { } ////////////////////////////////////////////////////////////////////////////////////////// //DATA//////////////////////////////////////////////////////////////////////////////DATA// ////////////////////////////////////////////////////////////////////////////////////////// /*Perfom a bypass input output without any data modification*/ int datainflow_bypass(int len) { int i; //printf("RSOLOMON BYPASS\n"); for(i=1; i<=len; i++){ output_data[i-1]=input_data[i-1]; //printf("% d ", output_data[i-1]); //if(i%16==0)printf("\n"); } //printf("\n"); return(1); } #define DATA_FLOW_LENGTH 0 /*data_length(): Define the data flow length in each time-slot*/ int datain_length() { int length=0; if(control_rsolomon[0].CExec.status==NONACTIVE)length=0; if(control_rsolomon[0].CExec.status==ACTIVE)length=control_rsolomon[0].CData.ninputbytes; if(control_rsolomon[0].CExec.status==TEST_FLOW)length=control_rsolomon[0].CData.ninputbytes; if(control_rsolomon[0].CExec.status==TEST_PROCESS)length=control_rsolomon[0].CData.ninputbytes; return(length); } #define BSIZE 4096 int process_datainflow(int len) { int i, numofbits,j, NPARITYBYTES, DATASIZE; int info_in[BSIZE]; int info_out[BSIZE]; unsigned char msg[N_LENGTH]; unsigned char codeword[N_LENGTH]; unsigned char msg0[K_LENGTH] = {0xD4, 0xBA, 0xA1, 0x12, 0xF2, 0x74, 0x96,\ 0x30, 0x27, 0xD4, 0x88, 0x9C, 0x96, 0xE3,\ 0xA9, 0x52, 0xB3, 0x15, 0xAB, 0xFD, 0x92,\ 0x53, 0x07, 0x32, 0xC0, 0x62, 0x48, 0xF0,\ 0x19, 0x22, 0xE0, 0x91, 0x62, 0x1A, 0xC1}; if(len==0)return(-1); if (control_rsolomon[0].CData.modulation != _BPSK) { NPARITYBYTES=control_rsolomon[0].CData.rsolomon_Pbytes; DATASIZE=len; rs802_11e_encoder((unsigned char *)input_data, DATASIZE, codeword, NPARITYBYTES); //rs802_11e_encoder(msg0, DATASIZE, codeword, NPARITYBYTES); len=DATASIZE+NPARITYBYTES; ////Move data to output buffer//// for (i=0; i<(len); i++)output_data[i]=codeword[i]; } else { //BPSK: NO RSOLOMON. INFO_OUT=INFO_IN for (i=0; i< len; i++)output_data[i]=input_data[i]; } return(1); } int dataout_length() { int length; if(control_rsolomon[0].CExec.status==NONACTIVE)length=0; if(control_rsolomon[0].CExec.status==ACTIVE)length=\ control_rsolomon[0].CData.ninputbytes\ +control_rsolomon[0].CData.rsolomon_Pbytes; if(control_rsolomon[0].CExec.status==TEST_FLOW)length=\ control_rsolomon[0].CData.ninputbytes; if(control_rsolomon[0].CExec.status==TEST_PROCESS)length=\ control_rsolomon[0].CData.ninputbytes; return(length); } int generate_dataflow(int len) { int i; return(1); } #define TESTLENGTH 35 int test_rsolomon(int len) { int i, j, numofbits, length=TESTLENGTH; int info_in[BSIZE]; int info_out[BSIZE]; unsigned char msg[K_LENGTH]; unsigned char msg1[K_LENGTH]; int msg2[K_LENGTH]; unsigned char codeword[N_LENGTH]; unsigned char tests[TESTLENGTH]={0xDA, 0xBA, 0xA1, 0x12, 0xF2, 0x74, 0x96,\ 0x30, 0x27, 0xD4, 0x88, 0x9C, 0x96, 0xE3,\ 0xA9, 0x52, 0xB3, 0x15, 0xAB, 0xFD, 0x92,\ 0x53, 0x07, 0x32, 0xC0, 0x62, 0x48, 0xF0,\ 0x19, 0x22, 0xE0, 0x91, 0x62, 0x1A, 0xC1}; unsigned char help[TESTLENGTH]; return(1); } ////////////////////////////////////////////////////////////////////////////////////////// //END OF ESPECIFIC MODULE FUNCTIONS/////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// void ConfigInterfaces() {}