//////////////////////////////////////////////////////////////////////////////// // // // Module: deinterlever // // // // // // Description: Interleaver 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 "typetools.h" #include "interleaver_code.h" //#include "CInterleaver.h" #define NUMCHARSBYTE 8 /*GLOBAL VARIABLES*/ int data_rcved; //Data received-->data_rcved=1 //Data non received-->data_rcved=0 int Ncbps; //Number of coded bits per the allocated subchannels per OFDM symbol int Ncpc; //Number of coded bits per subcarrier int bufferA[INPUT_MAX_DATA]; int bufferB[INPUT_MAX_DATA]; int bufferC[INPUT_MAX_DATA]; float bufferAF[INPUT_MAX_DATA]; /*PREDEFINED FUNCTIONS*/ void Init_Controlfunction(); int datainflow_bypass(int len); ////////////////////////////////////////////////////////////////////////////////////////// //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(){ return(INPUT_MAX_CONTROL); } /*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){ int i; if(len==1){ Ncbps=control_inter.CData.ninputdata; Ncpc=control_inter.CData.modulation; printf("O---->DEINTERLEAVER (config): TSLOT%d, STATUS=%d\n",\ control_inter.CExec.timeslot,\ control_inter.CExec.status); printf("O STATUS: %d (0: NONACTIVE, 1: ACTIVE, 2: TEST_FLOW, 3: TEST_PROCESS\n",\ control_inter.CExec.status); printf("O NumInputdata=%d, NumOutputdata=%d\n",\ control_inter.CData.ninputdata,\ control_inter.CData.noutputdata); printf("O modulation=%d (1: BPSK, 2: QPSK, 4:16QAM, 6:64QAM \n",\ control_inter.CData.modulation); } 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=0; if(control_inter.CExec.status==NONACTIVE)length=0; if(control_inter.CExec.status==ACTIVE)length=\ control_inter.CData.ninputdata; if(control_inter.CExec.status==TEST_FLOW)length=\ control_inter.CData.ninputdata; if(control_inter.CExec.status==TEST_PROCESS)length=\ control_inter.CData.ninputdata; 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("viterbi: process_inputdata\n"); data_rcved=1; //The execution of this function implies that enough data has //been received //Testing flows purposes if(control_inter.CExec.status==TEST_FLOW)datainflow_bypass(len); //Testing module processing functionality if(control_inter.CExec.status==TEST_PROCESS)test_interleaver(); //Normal interleaver execution if(control_inter.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; //Testing flows purposes if(control_inter.CExec.status==TEST_FLOW) length=control_inter.CData.ninputdata; //Data send=Data received //Testing module processing functionality if(control_inter.CExec.status==TEST_PROCESS) length=control_inter.CData.ninputdata; //No data send //Normal execution if(control_inter.CExec.status==ACTIVE) 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() { return 1; } int RunCustom() { return 1; } void ConfigInterfaces() { } ////////////////////////////////////////////////////////////////////////////////////////// //END SQUELETON CALLED FUNCTIONS////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //######################################################################################// ////////////////////////////////////////////////////////////////////////////////////////// //ESPECIFIC MODULE FUNCTIONS////////////////////////////////////////////////////////////// //CONTROL////////////////////////////////////////////////////////////////////////CONTROL// ////////////////////////////////////////////////////////////////////////////////////////// void Init_Controlfunction() { control_inter.CExec.status=NONACTIVE; control_inter.CData.ninputdata=0; control_inter.CData.noutputdata=0; } ////////////////////////////////////////////////////////////////////////////////////////// //DATA//////////////////////////////////////////////////////////////////////////////DATA// ////////////////////////////////////////////////////////////////////////////////////////// /*Perfom a bypass input output without any data modification*/ int datainflow_bypass(int len) { int i; int info_C[INPUT_MAX_DATA]; if(len>=INPUT_MAX_DATA)printf("DEINTERLEAVER(datainflow_bypass)ERROR len > INPUT_MAX_DATA\n"); // printf("INTERLEAVER BYPASS\n"); for(i=1; i=(INPUT_MAX_DATA*8))printf("ERROR: test_interlaever() Ncbps out of range\n"); printf("INTERLEAVER: test_interleaver(1) Ncbps=%d Ncpc=%d length=%d\n",\ Ncbps, Ncpc, length); //DATA GENERATION for(i=0; i