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

📄 sc_alloc.c

📁 802.16e物理层上行子载波分配。严格按照802.16e实现。
💻 C
字号:
/*
 * 
  * 
 * 
 * Project: Fixed C simulation platform for IEEE 802.16e-2005
 *
 * Description: 
 *  The global definitions and declearation for Reed-Solomon encoder/decoder
 *  Changing from Phil Karn KA9Q, September 1996
 *
 *  In this file compute the physical location of every subchannel subcarrier
 *	and also list the used pilot of current sgement
 *
 *  This file support PUSC and FUSC permutaion 
 *	
 *	You can define BW_10M to fit 1024 points fft size else to fit 512 points fft
 * 
 * Function list:
 *   1. dl_subcarrier_alloc_pusc    downlink subchannel subcarriers allocation PUSC 
 *   2. dl_subcarrier_alloc_fusc    downlink subchannel subcarriers allocation FUSC 
 *
 * 
 */

/*
 ***************************************************************************************
 *                                     DEFINES
 ***************************************************************************************
 */
#include "..\include\wib_phy_def.h"
#define DEBUG_OUT_FILE

/*
 * *************************************************************************************
 * function: ul_subcarrier_alloc_pusc module
 * parameters: 
 *
 *			UINT16 	*sc_index_addr,	        //sequence of data and pilot subcarrier of symbol:[MAX_SC_NUM]
 *			UINT16  zone_use_all_sc,        //use all subcarrier indicator
 *          UINT16 	zone_ul_permbase,		//UL_permbase of zone
 *			UINT16 *zone_bitmap			    //bitmap indicator
 * return: int 1
 * description: uplink PUSC zone subchannel subcarriers allocation module
 * -------------------------------------------------------------------------------------
 */
int ul_subcarrier_alloc_pusc
	(
	    UINT16 *sc_index_addr, 	
		UINT16 zone_use_all_sc,
		UINT16 zone_ul_permbase,
		UINT16 *zone_bitmap
		
	)
{
	/*
	 ***************************************************************************************
	 *                             basic parameter definition
	 ***************************************************************************************
	 */
	
		/* basic parameter of UL PUSC for 1024 FFT */
		UINT16 nb_tile_pusc = 210;					// tile number
		UINT16 nb_subchn_pusc = 35;					// subchannel number
		UINT16 nb_tile_per_subchn = 6;              // tile number of a subchannel
		UINT16 sc_per_subchn_pusc = 24;				// all subcarrier number of a subchannel
		
		UINT16 tile_perm[35] = {11,19,12,32,33,9,30,7,4,2,13,8,17,23,27,5,15,34,22,14,21,1,0,24,3,26,29,31,20,25,16,10,6,28,18};       //tile permutation
		UINT16 nb_subchn_used;                      // used subchannel number


	/*
	 ***************************************************************************************
	 *                            variable definition
	 ***************************************************************************************
	 */
                                	               		
		/* variable of UL PUSC permutiaon for 1024 FFT size */ 
		UINT16 tile_phys_pusc[210][4];				 //subcarrier of physical tile
		UINT16 tile_subchn[35][6];                   //tile of subchannel
		UINT16 sc_subchn_pusc[35][24];               //subcarrier of subchannel
		UINT16 sc_subchn_used[35][24];               //subcarrier of used subchannel
		


			
		FILE *fp_scallc_PUSC_10M;					 //file pionter of ouput file



		/* tempory variable */
		UINT16 tile_index;
		UINT16 i,j,k;

	
	/*
	 ***************************************************************************************
	 *                             function definition
	 ***************************************************************************************
	 */

		/* create scallc_PUSC_10M.txt to store debug information of PUSC 10M */
		fp_scallc_PUSC_10M = fopen("scallc_PUSC_10M.txt","w");

		fprintf(fp_scallc_PUSC_10M,"\n/******************************tile***************************/\n");
		fprintf(fp_scallc_PUSC_10M,"the subcarriers of tile 0 ~ 209 is :\n"); 


	/*------------------------------ assign subcarriers to  tile -----------------------------------*/
		
		/* subcarriers are allocated into physical tile*/
		/* 0 ~ 91,512,933 ~ 1023 is zero subcarriers */
		for (i = 0; i < nb_tile_pusc; i++)
		{
			for(j = 0; j < 4; j++)
			{
				/* 92 ~ 511 also (-420 ~ -1) */
				if(i < nb_tile_pusc/2)			
					tile_phys_pusc[i][j] =  92 + i * 4 + j;
				
				/* 512 ~ 932(1 ~ 420) */
				else							
					tile_phys_pusc[i][j] =  92 + i * 4 + j + 1;

				
				/*output tile subcarrier */
				if(j == 3)
					fprintf(fp_scallc_PUSC_10M,"%4d \n",tile_phys_pusc[i][j]);
				else
					fprintf(fp_scallc_PUSC_10M,"%4d ",tile_phys_pusc[i][j]);

			}
		}
		


	/*----------------------------- assign tiles into subchannels  --------------------------------*/

		/* assign tiles into subchannels */
		for (i = 0; i < nb_subchn_pusc; i++){
			for(j = 0; j < nb_tile_per_subchn; j++){
				tile_subchn[i][j] = nb_subchn_pusc * j + ((tile_perm[(i + j) % nb_subchn_pusc] + zone_ul_permbase) % nb_subchn_pusc);
			} 
		}

	
		/* output tiles of subchannel */
		fprintf(fp_scallc_PUSC_10M,"subchannel tiles \n");
		for (i = 0; i < nb_subchn_pusc; i++){
			for(j = 0; j < nb_tile_per_subchn; j++){
				if(j ==  nb_tile_per_subchn - 1){
					fprintf(fp_scallc_PUSC_10M,"%4d \n",tile_subchn[i][j]);
				}
				else{
					fprintf(fp_scallc_PUSC_10M,"%4d ",tile_subchn[i][j]);
				}
			}
		}


	
	/*----------------------------- assign all subcarriers into subchannel  --------------------------------*/

		/* assign subcarriers into subchannel */
		for (i = 0; i < nb_subchn_pusc; i++){
			for(j = 0; j < nb_tile_per_subchn; j++){
				tile_index = tile_subchn[i][j];
				for(k = 0; k < 4; k++){
					sc_subchn_pusc[i][j * 4 + k] = tile_phys_pusc[tile_index][k];
				}
			} 
		}

	
		/* output subcarriers of subchannel */
		fprintf(fp_scallc_PUSC_10M,"subchannel subcarriers \n");
		for (i = 0; i < nb_subchn_pusc; i++){
			for(j = 0; j < sc_per_subchn_pusc; j++){
				if(j ==  sc_per_subchn_pusc - 1){
					fprintf(fp_scallc_PUSC_10M,"%4d \n",sc_subchn_pusc[i][j]);
				}
				else{
					fprintf(fp_scallc_PUSC_10M,"%4d ",sc_subchn_pusc[i][j]);
				}
			}
		}



	    /*------------------------------ renumber subchannel ---------------------------------*/
	    /* renumber subchannel order */
	    fprintf(fp_scallc_PUSC_10M,"\n/**********************the renumber suchannel subcarriers *********************/\n");	
	

		/* initialize used subchannel number */
		nb_subchn_used = 0;

	    /* use all subchannel*/
	    if(zone_use_all_sc == 1){
			nb_subchn_used = nb_subchn_pusc;
			for(i = 0; i < nb_subchn_used; i++){
				for(j = 0; j < sc_per_subchn_pusc; j++){
					sc_subchn_used[i][j] = sc_subchn_pusc[i][j];
				}
			}
		}
		/* not use all subchannel*/
		else{
			for(i = 0; i < nb_subchn_pusc; i++){
				if(*(zone_bitmap + i) == 1){
					for(j = 0; j < sc_per_subchn_pusc; j++){
						sc_subchn_used[nb_subchn_used][j] = sc_subchn_pusc[i][j];
					}
					nb_subchn_used++;
				}
			}
		}


	    /*------------------------- assign data and pilot subcarriers of subchannel-------------------------*/
		
		/* assign data and pilot subcarriers */
			for (i = 0; i < nb_subchn_used; i++){		
				for(j = 0; j < nb_tile_per_subchn; j++){			
					*sc_index_addr = sc_subchn_used[i][4*j];
					sc_index_addr ++;
					*sc_index_addr = sc_subchn_used[i][4*j + 1];
					sc_index_addr ++ ;
					*sc_index_addr = sc_subchn_used[i][4*j + 2];
					sc_index_addr ++ ;
					*sc_index_addr = sc_subchn_used[i][4*j + 3];
					sc_index_addr ++;									
				}
			}
	

		
		
		/* output data and pilot subcarriers */
			fprintf(fp_scallc_PUSC_10M,"output subcarriers \n");
			for (i = 0; i < nb_subchn_used; i++){
				for(j = 0; j < sc_per_subchn_pusc; j++){
					if(j ==  sc_per_subchn_pusc - 1){
						fprintf(fp_scallc_PUSC_10M,"%4d \n",sc_subchn_used[i][j]);
					}
					else{
						fprintf(fp_scallc_PUSC_10M,"%4d ",sc_subchn_used[i][j]);
					}	
				}				
			}
				
		fclose(fp_scallc_PUSC_10M); 




	return 1;
}



	/*====================================================================*/
void main()
{
 
		UINT16 zone_use_all_sc;
		UINT16 zone_ul_permbase;
		UINT16 zone_bitmap[35]={1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};	

		UINT16 ul_datasc_index_addr[35][24];
		

		zone_use_all_sc = 0;
		zone_ul_permbase = 4;


		ul_subcarrier_alloc_pusc(
	        &ul_datasc_index_addr[0][0],
		     zone_use_all_sc,
		     zone_ul_permbase,
	         zone_bitmap);
		
	 




}

⌨️ 快捷键说明

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