⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlfusc.c

📁 Implementation of common functions required for subchannel allocation and resource management of a W
💻 C
字号:
#include "allocation.h"#define DLFUSC_VARPILOTS 71#define DLFUSC_CONSTPILOTS  12#define DLFUSC_GUARDLEFT 173#define DLFUSC_GUARDRIGHT 172#define DLFUSC_DATA (DLFUSC_NC - DLFUSC_GUARDLEFT - DLFUSC_GUARDRIGHT \				- (DLFUSC_VARPILOTS << 1) - (DLFUSC_CONSTPILOTS<<1))#define DLFUSC_NC OFDMA_NC#define DLFUSC_NUMSUBCARRIERS 48#define DLFUSC_NUMSUBCHANNELS 32static int varset1[DLFUSC_VARPILOTS] ; static int varset2[DLFUSC_VARPILOTS] ;static int dlfusc_setguard(char *cs) ;static int dlfusc_setpilots(char *cs, int symnum) ;static int buildvarsets_dlfusc(int *vset1, int *vset2) ;int dl_subchannel_assign( int, int, int, int *, int *, int, int) ;static int cset1[DLFUSC_CONSTPILOTS] = { 39, 645, 1017, 1407, 330, 726, 1155, 1461, 351, 855, 1185, 1545} ;static int cset2[DLFUSC_CONSTPILOTS] = { 261, 651, 1143, 1419, 342, 849, 1158, 1530, 522, 918, 1206, 1701 } ;extern int debug;int printvarsets(int *vset1, int *vset2){		int i,j;		printf("Varset1\n",i) ;		for (j=0; j<DLFUSC_VARPILOTS; j++) printf("%d,",vset1[j]) ;			printf("\n") ;		printf("Varset2\n",i) ;		for (j=0; j<DLFUSC_VARPILOTS; j++) printf("%d,",vset2[j]) ;			printf("\n") ;}/********************************************************************** * Function: Set carriers. * Description: Key function, which allocates carriers, * Parameters:  * 				- list of carriers, * 				- symbol number  * 				- idcell * 				 *	Returns: Updates input string with updated assignments *********************************************************************/int dlfusc_setcarriers(char *cs, int symnum, int idcell){		int numpilots=0,j,k;		int freelist[DLFUSC_DATA] ;		int alloclist[DLFUSC_DATA] ;		int numalloc;		static int pbase[] = { 3, 18, 2, 8, 16, 10, 11, 15, 26, 22, 6, 9, 				27, 20, 25, 1, 29, 7, 21, 5, 28, 31, 23, 17, 4, 24, 0, 13, 				12, 19, 14, 30 } ;		dlfusc_setguard(cs) ;		numpilots = dlfusc_setpilots(cs, symnum) ;		for (j=k=0; j<DLFUSC_NC; j++)		{				if (cs[j] == UNALLOC_MARK) freelist[k++] = j ;		}		printf("FUSC: %d free carriers\n",k) ;		for (j=0; j<DLFUSC_NUMSUBCHANNELS; j++)		{				numalloc = dl_subchannel_assign(j,								DLFUSC_NUMSUBCHANNELS,								DLFUSC_NUMSUBCARRIERS,								alloclist,pbase, 32, idcell); 				if (debug == 1) printf("Subchannel:%d has %d allocations\n",j,numalloc) ;				for (k=0; k<numalloc; k++)				{						cs[freelist[alloclist[k]]] = marker(j) ;				}		}		return (numpilots) ;}/********************************************************************** * Functions: Bunch of functions for setting guard bands and pilots *********************************************************************/static int dlfusc_setguard(char *cs){		int j;		for (j=0; j<DLFUSC_GUARDLEFT; j++)				cs[j] = GUARD_MARK ;		for (j=0; j<DLFUSC_GUARDRIGHT; j++)				cs[DLFUSC_NC-1-j] = GUARD_MARK ;}static int dlfusc_setpilots(char *cs, int symnum) {		int j, pilotpos;		buildvarsets_dlfusc(varset1,varset2) ;		if (debug == 1) printvarsets(varset1, varset2) ;		/** Allocate constant pilots **/		for (j=0; j<DLFUSC_CONSTPILOTS; j++) 		{				int cp1, cp2;				cp1 = cset1[j] +DLFUSC_GUARDLEFT;				cp2 = cset2[j] +DLFUSC_GUARDLEFT;				if (cs[cp1] != UNALLOC_MARK) 				{ 						printf("Overwriting carrier of type %c at %d by %c\n",										cs[cp1],cp1,PILOT_MARK) ; 				}				cs[cp1] = PILOT_MARK ;				if (cs[cp2] != UNALLOC_MARK) 				{ 						printf("Overwriting carrier of type %c at %d by %c from 2nd set\n",										cs[cp2],cp2, PILOT_MARK) ; 				}				cs[cp2] = PILOT_MARK ;		}		/** Allocate variable pilots **/		for (j=0; j<DLFUSC_VARPILOTS; j++) 		{				int pp1, pp2 ;				pp1 = varset1[j] + 6*(symnum%2) +DLFUSC_GUARDLEFT ;				pp2 = varset2[j] + 6*(symnum%2) +DLFUSC_GUARDLEFT ;				if (pp1 == pp2)				{						printf("Strange: pilots matching!\n");				}				if (cs[pp1] != UNALLOC_MARK) 				{ 						printf("Overwriting carrier of type %c at %d by V, j=%d\n",										cs[pp1],pp1 - DLFUSC_GUARDLEFT,j) ; 				}				if (cs[pp2] != UNALLOC_MARK) 				{ 						printf("Overwriting carrier of type %c at %d by V from 2nd set, j=%d\n",										cs[pp2],pp2 - DLFUSC_GUARDLEFT,j) ; 				}				if (pp1 == pp2)				{						printf("Strange: pilots matching!\n");				}				cs[pp2] = VARPILOT_MARK ;				cs[pp1] = VARPILOT_MARK ;		}		return j;}static int buildvarsets_dlfusc(int * vset1, int * vset2){		int i,j,k;		if (vset2[0]) return vset1[0] ;		vset2[0] = 36 ;		for (j=1; j<DLFUSC_VARPILOTS; j++)		{			vset1[j] = vset1[j-1]+72 ;			vset2[j] = vset2[j-1]+72 ;			if (vset1[j] > 1703)			{					switch(vset1[j-1])					{					case 1656: vset1[j] = 48 ; break ;					case 1632: vset1[j] = 24 ; break ;					default: break ;					}			}			if (vset2[j] > 1703)			{					switch(vset2[j-1])					{					case 1692: vset2[j] = 12 ; break ;					case 1668: vset2[j] = 60 ; break ;					default: break ;					}			}		}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -