#include #include #include #include "interleaver_code.h" //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 // ////////////////////////////////////////////////////////////////////////////////// /* Ncbps: Number of coded bits per the allocated subchannels per OFDM symbol Ncpc: Number of coded bits per subcarrier */ // In the following operations, it is necessary to consider the following values: // k-->index of the bit encoded BEFORE the first permutation // mk-->index of this bit BEFORE the second permutation and AFTER the first one // jk-->index after the SECOND permutation, just before the mapping of the sign. #define INTER 0 #define DEINTER 1 void interleaving(int Ncbps, int Ncpc, int mode, int d, int *in, int *out) { int k, mk, jk, s; float DD; DD=(float)d; s = ceil (((double)Ncpc)/2.0); //printf("INTERLEAVING Ncbps=%d, Ncpc=%d, mode=%d, d=%d\n", Ncbps, Ncpc, mode, d); for (k=0; k=Ncbps)printf("INTERLEAVER error1\n"); if(mode == INTER){ out[jk]=in[k]; } if(mode == DEINTER){ out[k]=in[jk]; } } } #define MAXCODEDBITS 2048 #define MAXD 2 //Return an adequate d value for th interleaving equations int check_interleaver_params(int Ncbps, int Ncpc) { int k, mk, jk, s, d, OK; int index[MAXCODEDBITS]; int Doptions[5]={12, 16, 0, 0, 0}; int inxD; float DD; d=12; DD=(float)d; OK=0; inxD=0; for (k=0; k=Ncbps)printf("INTERLEAVER error1\n"); if(index[jk]==0)index[jk]=k; else { OK=0; //printf("index[%d]=%d, k=%d\n", jk, index[jk], k); } } if(OK == 0)inxD++; d=Doptions[inxD]; if(inxD>=MAXD)return(d); } return(d); } // Again, it is necessary to understand the values: // j-->index of the bit encoded BEFORE the first permutation // mj-->index of this bit BEFORE the second permutation and AFTER the first one // kj-->index after the SECOND permutation, just before the mapping of the sign. void deinter (int Ncbps, int Ncpc, int d, int *in, int *out) { int j, mj, kj, s; //printf("DEINTERLEAVING \n"); s = (int)(ceil (((double)Ncpc)/2.0)); for (j=0; j