////////////////////////////////////////////////////////////////////////////////////////// // // // FILE: interlever_imp.c // // // // // // Description: Interleaver Downlink WiMAX IEEE802.16e rel 2005 // // // // // // // // Input: control_flow_in; data_flow_in // // // // Output: data_flow_out // // // //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" #define NUMBITSBYTE 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 bufferAO[INPUT_MAX_DATA]; int bufferB[INPUT_MAX_DATA]; int bufferC[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*NUMBITSBYTE; Ncpc=control_inter.CData.modulation; printf("O---->INTERLEAVER (config): TSLOT%d, STATUS=%d\n",\ control_inter.CExec.timeslot,\ control_inter.CExec.status); printf("O NumInputbytes=%d, NumOutputbytes=%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("INTERLEAVER(datainflow_bypass)ERROR len > INPUT_MAX_DATA\n"); for(i=1; i<=len; i++)output_data[i-1]=input_data[i-1]; /* printf("INTERLEAVER BYPASS\n"); printf("%d ", output_data[i-1]); if(i%16==0)printf("\n"); } printf("\n"); */ return(1); } //INTERLEAVING MODES WIMAX ////////////////////////////////////////////////////////////////////////////////// // subchannels 16 8 4 2 1 // // Ncbps (BPSK: Ncpc=1) 192 96 48 12 12 // // Ncbps (QPSK: Ncpc=2) 384 192 96 24 24 // // Ncbps (16QAM: Ncpc=4) 768 384 192 48 48 // // Ncbps (64QAM: Ncpc=6) 1152 576 288 72 72 // ////////////////////////////////////////////////////////////////////////////////// int process_datainflow(int length) { int i, dvalid; unsigned char bufferCH[INPUT_MAX_DATA]; static int one=1; dvalid=12; /* printf("INTERLEAVER: process_datainflow() Ncbps=%d Ncpc=%d length=%d dvalid=%d\n",\ Ncbps, Ncpc, length, dvalid); */ //CHECK VALID VALUES FOR Ncpc and Ncbps if(Ncpc==1){ if(Ncbps!=192 && Ncbps!=96 && Ncbps!=48 && Ncbps==12) printf("ERROR: INTERLEAVER: Ncpc=1 and Ncbps value non valid\n"); } if(Ncpc==2){ if(Ncbps!=384 && Ncbps!=192 && Ncbps!=96 && Ncbps==24) printf("ERROR: INTERLEAVER: Ncpc=2 and Ncbps value non valid\n"); } if(Ncpc==4){ if(Ncbps!=768 && Ncbps!=384 && Ncbps!=192 && Ncbps==48) printf("ERROR: INTERLEAVER: Ncpc=1 and Ncbps value non valid\n"); } if(Ncpc==6){ if(Ncbps!=1152 && Ncbps!=576 && Ncbps!=288 && Ncbps==72) printf("ERROR: INTERLEAVER: Ncpc=1 and Ncbps value non valid\n"); } for(i=0; 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; i0)printf("TEST_INTERLEAVING-DEINTERLEAVING NOK\n"); return(1); } ////////////////////////////////////////////////////////////////////////////////////////// //END OF ESPECIFIC MODULE FUNCTIONS/////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////