//////////////////////////////////////////////////////////////////////////////// // // // Module: wimax_rando // // // // FUNCTION: Randomiser // // // // 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" /*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); int process_testsequence(); ////////////////////////////////////////////////////////////////////////////////////////// //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("rando: process_inputdata\n"); data_rcved=1; //The execution of this function implies that enough data has been received //Testing flows purposes if(control_rando[0].CExec.status==TEST_FLOW)datainflow_bypass(len); //Testing module processing functionality if(control_rando[0].CExec.status==TEST_PROCESS)process_testsequence; //Normal rsolomon encoder execution if(control_rando[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(); return 1; } int RunCustom() { return 1; } ////////////////////////////////////////////////////////////////////////////////////////// //END SQUELETON CALLED FUNCTIONS////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //######################################################################################// ////////////////////////////////////////////////////////////////////////////////////////// //ESPECIFIC MODULE FUNCTIONS////////////////////////////////////////////////////////////// //CONTROL////////////////////////////////////////////////////////////////////////CONTROL// ////////////////////////////////////////////////////////////////////////////////////////// void Init_Controlfunction() { /*Initializes control variables*/ control_rando[0].CExec.status=NONACTIVE; control_rando[0].CData.ninputbytes=0; control_rando[0].CData.noutputbytes=0; } int control_length() { return(INPUT_MAX_CONTROL); } int process_control_input(int len) { if(len==1){ printf("O---->RANDO (config): TSLOT%d, STATUS=%d\n",\ control_rando[0].CExec.timeslot,\ control_rando[0].CExec.status); printf("O NumInputbytes=%d, NumOutputbytes=%d\n",\ control_rando[0].CData.ninputbytes,\ control_rando[0].CData.noutputbytes); } } ////////////////////////////////////////////////////////////////////////////////////////// //DATA//////////////////////////////////////////////////////////////////////////////DATA// ////////////////////////////////////////////////////////////////////////////////////////// /*Perfom a bypass input output without any data modification*/ int datainflow_bypass(int len) { int i; //printf("RANDO 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; //length=DATA_FLOW_LENGTH; if(control_rando[0].CExec.status==NONACTIVE)length=0; if(control_rando[0].CExec.status==ACTIVE)length=control_rando[0].CData.ninputbytes; if(control_rando[0].CExec.status==TEST_FLOW)length=control_rando[0].CData.ninputbytes; if(control_rando[0].CExec.status==TEST_PROCESS)length=control_rando[0].CData.ninputbytes; return(length); } #define BSIZE 4096 int process_datainflow(int len) { int i, numofbits; int info_in[BSIZE]; int info_out[BSIZE]; if(control_rando[0].CExec.status==NONACTIVE)return(1); if(control_rando[0].CExec.status==ACTIVE){ //CONVERT CHAR RECEIVED TO BITS //numofbits=char2bin(info_in, input_data, len); numofbits=MSBfirstchar2bin (input_data, info_in, len); //RANDOMISE randomize(info_in,info_out,numofbits); //CONVERT BITs to CHARs //control_rando[0].CData.noutputbytes=bin2char(info_out, output_data, numofbits); control_rando[0].CData.noutputbytes=\ MSBfirstbin2char (info_out, output_data,numofbits); } if(control_rando[0].CExec.status==TEST_FLOW){ datainflow_bypass(len); //For testing flows purposes } if(control_rando[0].CExec.status==TEST_PROCESS){ process_testsequence(); //For testing random operation } return(1); } int dataout_length() { int length; length=control_rando[0].CData.noutputbytes; return(length); } int generate_dataflow(int len) { int i; return(1); } void randomize(int datain[],int dataout[],int length) { int xor1=0,i=0, k=0; int arrayinit[15]= {1,0,0,1,0,1,0,1,0,0,0,0,0,0,0}; //ORIGINAL for (i=1; i<=length; i++) { if (arrayinit[13]==arrayinit[14]) xor1=0; else xor1=1; for (k=14;k>=1;k--) arrayinit[k]=arrayinit[k-1]; arrayinit[0]=xor1; if (datain[i-1]==xor1) dataout[i-1]=0; else dataout[i-1]=1; } } #define TESTLENGTH 35 int process_testsequence() { int i, numofbits, j; int info_in[BSIZE]; int info_out[BSIZE]; unsigned char tests[TESTLENGTH]={0x45, 0x29, 0xC4, 0x79, 0xAD, 0x0F, 0x55,\ 0x28, 0xAD, 0x87, 0xB5, 0x76, 0x1A, 0x9C,\ 0x80, 0x50, 0x45, 0x1B, 0x9F, 0xD9, 0x2A,\ 0x88, 0x95, 0xEB, 0xAE, 0xB5, 0x2E, 0x03,\ 0x4F, 0x09, 0x14, 0x69, 0x58, 0x0A, 0x5D}; unsigned char help[TESTLENGTH]; unsigned char res[TESTLENGTH]; //CONVERT TEST SEQUENCE TO BITS printf("bitLrando: process_testsequence\n"); for(i=0; i