📄 dlpusc.c
字号:
#include "allocation.h"#define DLPUSC_GUARDLEFT 184#define DLPUSC_GUARDRIGHT 183#define DLPUSC_NC OFDMA_NC#define DLPUSC_NUMCLUSTERS 120#define DLPUSC_NUMSUBCHANNELS 60#define DLPUSC_NUMSUBCARRIERS 24#define DLPUSC_GROUPS 6#define DLPUSC_DCCARRIER 1024typedef struct { int start; int end;} cluster_t ;/** This is the cluster to group mapping **/static cluster_t groups[] = { {0,23}, {24,39}, {40,63}, {64,79}, {80,103}, {104,119}} ;static int dlpusc_setguard(char *cs) ;static int dlpusc_setpilots(char *cs, int symnum) ;extern int dl_subchannel_assign( int, int, int, int *, int *, int, int) ;/********************************************************************** * Function: Set carriers. * Description: Key function, which allocates carriers, * Parameters: * - list of carriers, * - symbol number * - idcell * * Returns: Updates input string with updated assignments *********************************************************************/int dlpusc_setcarriers(char *cs, int symnum, int idcell){ int numpilots=0,j,k=0,m; int freelist[DLPUSC_NC] ; int alloclist[DLPUSC_NC] ; int numalloc; static int pbase1[] = { 6,9,4,8,10,11,5,2,7,3,1,0} ; static int pbase2[] = { 7,4,0,2,1,5,3,6} ; static int renumber[] = { 6, 108, 37, 81, 31, 100, 42, 116, 32, 107, 30, 93, 54, 78, 10, 75, 50, 111, 58, 106, 23, 105, 16, 117, 39, 95, 7, 115, 25, 119, 53, 71, 22, 98, 28, 79, 17, 63, 27, 72, 29, 86, 5, 101, 49, 104, 9, 68, 1, 73, 35, 74, 43, 62, 20, 84, 52, 64, 34, 60, 66, 48, 97, 21, 91, 40, 102, 56, 92, 47, 90, 33, 114, 18, 70, 15, 110, 51, 118, 46, 83, 45, 76, 57, 99, 35, 67, 55, 85, 59, 113, 11, 82, 38, 88, 19, 77, 3, 87, 12, 89, 26, 65, 41, 109, 44, 69, 8, 61, 13, 96, 14, 103, 2, 80, 24, 112, 4, 94, 0 } ; int logclusterid[DLPUSC_NUMCLUSTERS] ; dlpusc_setguard(cs) ; cs[DLPUSC_DCCARRIER] = DC_MARK ; for (j=0; j<DLPUSC_NUMCLUSTERS; j++) { logclusterid[j] = renumber[(j+13*idcell)%DLPUSC_NUMCLUSTERS] ; } for (j=0; j<DLPUSC_GROUPS; j++) {/********************************************************************** * Allocation at the group level. Identify the carriers for the group. * Depending on the symbolnumber, mark every 0th and 14th carrier or * every 5th and 9th carriers. Isolate the others and use to do downlink * assignment * *******************************************************************/ int p1,p2 ; if (symnum%2) { p1 = 5; p2 = 9 ; } else p1 = 0 ; p2 = 12 ; for (k=groups[j].start; k<=groups[j].end; k++) { cs[logclusterid[k]*14+p1+DLPUSC_GUARDLEFT] = PILOT_MARK ; cs[logclusterid[k]*14+p2+DLPUSC_GUARDLEFT] = PILOT_MARK ; numpilots++ ; numpilots++ ; } } printf("PUSC: %d free carriers\n",k) ; for (j=0; j<DLPUSC_GROUPS; j++) { int numsubchannels = (j%2 == 0 ? 12:8) ; /** Now count the number of free sub-carriers.Restrict yourself to * the current group.There will be 12x24 in even number groups * and 8x24 in odd number groups, excluding pilot channels **/ m=0; printf("group %d(%d to %d):",j,groups[j].start, groups[j].end) ; for (k=DLPUSC_GUARDLEFT; k<(DLPUSC_NC-DLPUSC_GUARDRIGHT); k++) { int lcluster,cluster; if (cs[k] != UNALLOC_MARK) continue ; if (k==DLPUSC_DCCARRIER) continue ; else if (k<DLPUSC_DCCARRIER) cluster = (k-DLPUSC_GUARDLEFT)/14 ; else cluster = (k-1-DLPUSC_GUARDLEFT)/14 ; lcluster = renumber[(cluster + 13*idcell)%DLPUSC_NUMCLUSTERS] ; if ((lcluster >= groups[j].start && lcluster <= groups[j].end)) { freelist[m++] = k ; } } printf("\t%d free channels\n",m) ; for (k=0; k<numsubchannels; k++) { int scn = (j/2)*20+(j%2)*12+k ; if (j%2) { numalloc = dl_subchannel_assign(k, numsubchannels, DLPUSC_NUMSUBCARRIERS, alloclist,pbase2, 8, 0); } else { numalloc = dl_subchannel_assign(k, numsubchannels, DLPUSC_NUMSUBCARRIERS, alloclist,pbase1, 12, 0); }// printf("Subchannel:%d(%c):%d\n", k,marker(k),numalloc) ;// for (m=0; m<numalloc; m++) printf("%d,",alloclist[m]) ;// printf("\n") ; for (m=0; m<numalloc; m++) { if (cs[freelist[alloclist[m]]] == GUARD_MARK || cs[freelist[alloclist[m]]] == DC_MARK || cs[freelist[alloclist[m]]] == PILOT_MARK ) { printf("Overwriting channel of type %c at %d\n", cs[freelist[alloclist[m]]], cs[freelist[alloclist[m]]]) ; } cs[freelist[alloclist[m]]] = marker(scn); } } } return (1) ;}/********************************************************************** * Functions: Bunch of functions for setting guard bands and pilots *********************************************************************/static int dlpusc_setguard(char *cs){ int j; for (j=0; j<DLPUSC_GUARDLEFT; j++) cs[j] = GUARD_MARK ; for (j=0; j<DLPUSC_GUARDRIGHT; j++) cs[DLPUSC_NC-1-j] = GUARD_MARK ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -