////////////////////////////////////////////////////////////////////////////////////////// // // // FILE: channel_imp.c // // // // // // Description: CHANNEL 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 "channel_code.h" #define NUMBITSBYTE 8 /*GLOBAL VARIABLES*/ int data_rcved; //Data received-->data_rcved=1 //Data non received-->data_rcved=0 int status; int ninputdata; int noutputdata; int CHmode=NONOISE; float EbNo=15.0; /*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){ printf("O---->CHANNEL (config): TSLOT%d, STATUS=%d\n",\ control_channel.CExec.timeslot,\ control_channel.CExec.status); printf("O NumInputdata=%d, NumOutputdata=%d\n",\ control_channel.CData.ninputdata,\ control_channel.CData.noutputdata); printf("O channel mode=%d (0: NONOISE, 1: GAUSSIAN, 2:SUI1, 3:SUI2 \n",\ control_channel.CData.channel_mode); printf("O EbNo=%4.2f \n",\ control_channel.CData.EbNo); status=control_channel.CExec.status; ninputdata=control_channel.CData.ninputdata; noutputdata=control_channel.CData.noutputdata; CHmode=control_channel.CData.channel_mode; EbNo=control_channel.CData.EbNo; } 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(status==NONACTIVE)length=0; if(status==ACTIVE){ length=ninputdata; //printf("CHANNEL ACTIVE\n"); } if(status==TEST_FLOW)length=ninputdata; if(status==TEST_PROCESS)length=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) { data_rcved=1; //The execution of this function implies that enough data has //been received //Testing flows purposes if(status==TEST_FLOW)return(datainflow_bypass(len)); //Testing module processing functionality if(status==TEST_PROCESS)return(test_channelleaver()); //Normal channelleaver execution if(status==ACTIVE)return(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(status==TEST_FLOW)length=ninputdata; //Data send=Data received //Testing module processing functionality if(status==TEST_PROCESS)length=ninputdata; //No data send //Normal execution if(status==ACTIVE)length=ninputdata; 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; } void ConfigInterfaces() { } ////////////////////////////////////////////////////////////////////////////////////////// //END SQUELETON CALLED FUNCTIONS////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //######################################################################################// ////////////////////////////////////////////////////////////////////////////////////////// //ESPECIFIC MODULE FUNCTIONS////////////////////////////////////////////////////////////// //CONTROL////////////////////////////////////////////////////////////////////////CONTROL// ////////////////////////////////////////////////////////////////////////////////////////// void Init_Controlfunction() { status=NONACTIVE; ninputdata=0; noutputdata=0; } ////////////////////////////////////////////////////////////////////////////////////////// //DATA//////////////////////////////////////////////////////////////////////////////DATA// ////////////////////////////////////////////////////////////////////////////////////////// /*Perfom a bypass input output without any data modification*/ int datainflow_bypass(int len) { int i; printf("CHANNEL: datainflow_bypass()\n"); for(i=1; i<=len; i++){ output_data[i-1].re=input_data[i-1].re; output_data[i-1].im=input_data[i-1].im; } return(1); } int process_datainflow(int length) { int i; static int one=1; //printf("CHANNEL.process_datainflow(): length=%d\n", length); if(length==0)return(-1); if(length >= INPUT_MAX_DATA) printf("CHANNEL: ERROR1 INPUT DATA LENGTH=%d > INPUT_MAX_DATA=%d\n",\ length, INPUT_MAX_DATA); if(length == ninputdata){ switch(CHmode){ case NONOISE: for(i=1; i<=length; i++){ output_data[i-1].re=input_data[i-1].re; output_data[i-1].im=input_data[i-1].im; } break; case GAUSSIAN: addnoise(EbNo, length,\ (symbol *) input_data, (symbol *) output_data); break; case SUI1: break; deafault: printf("CHANNEL: ERROR channel mode non properly selected\n"); return(-1); break; } } else{ printf("CHANNEL: ERROR2 length=%d, INPUT_MAX_DATA=%d, ninputdata=%d\n",\ length, INPUT_MAX_DATA, control_channel.CData.ninputdata); return(-1); } //PRINT OUTPUT if(one==0){ printf("CHANNEL process_datainflow() OUTPUT\n"); for(i=1; i<=length; i++){ printf("%4.2f %4.2f ", output_data[i-1].re, output_data[i-1].im); if(i%8 == 0)printf("\n"); } printf("\n"); one=1; } //printf("CHANNEL.process_datainflow(): OUTPUT length=%d\n", length); return(1); } int generate_dataflow(int len) { int i; return(1); } int test_channelleaver(int length){ return(1); } ////////////////////////////////////////////////////////////////////////////////////////// //END OF ESPECIFIC MODULE FUNCTIONS/////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////