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

📄 dlul_map_analyze.c

📁 开发的802.16e物理层上下行MAP解析
💻 C
📖 第 1 页 / 共 5 页
字号:

#include "..\include\wib_phy_def.h"



/* look up this map table to get fec code type from DIUC */
UINT16  diuc_fec_code[13] = {0,1,2,3,4,5,6,13,15,16,17,18,19};



/* look up this map table to get fec code type from UIUC */
UINT16  uiuc_fec_code[10] = {0,1,13,15,16,17,18,19,20,21};



void exit_phy(INT32 exit_code) {
	printf("\nPress any key to exit.\n");
	getchar();
	exit(exit_code);
}




/*
 * *************************************************************************************
 * function: slot_to_blk module
 * parameters: 
 * 			UINT16		      fec,                          // FEC code type
 *          UINT16            num_total_slot,               // number of slots after repetition 
 *          UINT16            repetition,                   // repetition factor
 *          UINT16            *burst_data_len_byte,         // burst data length(byte)
 *	        UINT16            *burst_num_slot,              // number of slots of current burst  
 *          UINT16            *num_block,                   // number of blocks of current burst
 *          UINT16            *uncoded_blk_len,             // each block length before encoded  
 * 			UINT16            *coded_blk_len,               // each block length after encoded  
 *	        UINT16            *blk_num_slot)                // number of slots of each block
 * return value:    0 : the program operates correctly
 *                  others : the program is illegal or incorrect
 * description: generate each fec code block according to slot concatenation rule for both CC and CTC
 * Author : yanhua.bai
 * -------------------------------------------------------------------------------------
 */
int slot_to_blk(
	UINT16            fec,
	UINT16            burst_total_slot,
	UINT16            repetition,
	UINT16            *burst_data_len_byte,	
	UINT16            *burst_num_slot,
	UINT16            *burst_num_slot_remain,
	UINT16            *burst_num_block,
	UINT16            *uncoded_blk_len,
	UINT16            *coded_blk_len,
	UINT16            *blk_num_slot
	)

{
	/* Temporary variable definition*/
	UINT16 k;
	UINT16 num_slot;           
	UINT16 num_slot_remain;    //number of remain slot 
	UINT16 num_blk;            //number of block
	UINT16 bst_len;            //burst data length in bytes
	UINT16 CC_j;               //concatenation factor for CC
	UINT16 CTC_j;              //concatenation factor for CTC
	UINT16 mod;                //modulation type (2:QPSK, 4:16QAM, 6:64QAM)
	UINT16 rate_id;            //rate type (1:1/2, 2:2/3, 3:3/4, 4:5/6)
	UINT16 Lb1;                //the second last encoded block length in CTC              
	UINT16 Lb2;                //the last encoded block length in CTC 



	/*
	***************************************************************************************
	*                             function definition
	***************************************************************************************
	*/
	
	
	/* generate number of slot before repetition */
	switch(repetition){
	case 0:
		num_slot = burst_total_slot;                           //repetition factor = 0
		num_slot_remain = 0;
		break;
	case 1:
		num_slot = (UINT16)(burst_total_slot / 2);             //repetition factor = 2
		num_slot_remain = (UINT16)(burst_total_slot % 2);
		break;
	case 2:
		num_slot = (UINT16)(burst_total_slot / 4);             //repetition factor = 4
		num_slot_remain = (UINT16)(burst_total_slot % 4);
		break;
	case 3:
		num_slot = (UINT16)(burst_total_slot / 6);             //repetition factor = 6
		num_slot_remain = (UINT16)(burst_total_slot % 6);
		break;
	}



 
	/************************************ CC fec code ***********************************/

	/* get concatenation factor j, modulation type, rate type when CC fec code is used */
	if(fec == 0 || fec == 1 || fec == 2 || fec == 3 || fec == 4 || fec == 5 || fec == 6){
		switch(fec) {
		case 0:                                             //QPSK1/2   j = 6
			CC_j = 6;
			mod = 2;
			rate_id = 1;
			break;
		case 1:                                             //QPSK3/4   j = 4
			CC_j = 4;
			mod = 2;
			rate_id = 3;
			break;
		case 2:                                             //16QAM1/2   j = 3
			CC_j = 3;
			mod = 4;
			rate_id = 1;
			break;
		case 3:                                             //16QAM3/4   j = 2
			CC_j = 2;
			mod = 4;
			rate_id = 3;
			break;
		case 4:                                             //64QAM1/2   j = 2
			CC_j = 2;
			mod = 6;
			rate_id = 1;
			break;
		case 5:                                             //64QAM2/3   j = 1
			CC_j = 1;
			mod = 6;
			rate_id = 2;
			break;
		case 6:                                             //64QAM3/4   j = 1
			CC_j = 1;
			mod = 6;
			rate_id = 3;
			break;
		}


		/* get number of block and each coded block length in slots according to CC concatenation rule in table 317*/
		if(num_slot <= CC_j){
			num_blk = 1;
			blk_num_slot[0] = num_slot;	
		}
		else if(num_slot % CC_j == 0){
			num_blk = (UINT16)(num_slot / CC_j);
			for(k = 0; k < num_blk; k++){
				blk_num_slot[k] = CC_j;
			}		
		}
		else{
			num_blk = (UINT16)((num_slot / CC_j) + 1);
			for(k = 0; k < num_blk-2; k++){
				blk_num_slot[k] = CC_j;			
			}
			blk_num_slot[num_blk-2] = (UINT16)(((num_slot % CC_j + CC_j + 1) / 2));
			blk_num_slot[num_blk-1] = (UINT16)(((num_slot % CC_j + CC_j) / 2));	
		}		   	
	}

 
	/************************************ CTC fec code ***********************************/

	/* get concatenation factor j, modulation type, rate type when CTC fec code is used */
	else if(fec == 13 || fec == 15 || fec == 16 || fec == 17 || fec == 18 || fec == 19 || fec == 20 || fec == 21){
		switch(fec) {
		case 13:                                            //QPSK1/2   j = 10
			CTC_j = 10;
			mod = 2;
			rate_id = 1;
			break;
		case 15:                                            //QPSK3/4   j = 6
			CTC_j = 6;
			mod = 2;
			rate_id = 3;
			break;
		case 16:                                            //16QAM1/2   j = 5
			CTC_j = 5;
			mod = 4;
			rate_id = 1;
			break;
		case 17:                                            //16QAM3/4   j = 3
			CTC_j = 3;
			mod = 4;
			rate_id = 3;
			break;
		case 18:                                            //64QAM1/2   j = 3
			CTC_j = 3;
			mod = 6;
			rate_id = 1;
			break;
		case 19:                                            //64QAM2/3   j = 2
			CTC_j = 2;
			mod = 6;
			rate_id = 2;
			break;
		case 20:                                            //64QAM3/4   j = 2
			CTC_j = 2;
			mod = 6;
			rate_id = 3;
			break;
		case 21:                                            //64QAM5/6   j = 2
			CTC_j = 2;
			mod = 6;
			rate_id = 4;
			break;
		}

		
		/* get number of block and each coded block length in slots according to CTC concatenation rule in table 324*/
		if(num_slot <= CTC_j && num_slot != 7){
			num_blk = 1;
			blk_num_slot[0] = num_slot;	
		}
		else if(num_slot == 7){
			num_blk = 2;
			blk_num_slot[0] = 4;
			blk_num_slot[1] = 3;		
		}
		else if(num_slot % CTC_j == 0){
			num_blk = (UINT16)(num_slot / CTC_j);
			for(k = 0; k < num_blk; k++){
				blk_num_slot[k] = CTC_j;
			}		
		}
		else{
			num_blk = (UINT16)((num_slot/CTC_j) + 1);
			for(k = 0; k < num_blk-2; k++){
				blk_num_slot[k] = CTC_j;			
			}
			Lb1 = (UINT16)(((num_slot % CTC_j + CTC_j + 1) / 2));
			Lb2 = (UINT16)(((num_slot % CTC_j + CTC_j) / 2));

			if(Lb1 == 7 || Lb2 == 7){
				Lb1 = Lb1 + 1;
				Lb2 = Lb2 - 1;			
			}

			blk_num_slot[num_blk-2] = Lb1;
			blk_num_slot[num_blk-1] = Lb2;	
		}				
	}
	else{
		printf("Error in FEC_CODE_TYPE!");	
		exit_phy(-504);
	}


	
	/* generate each coded block length in bytes according to different modulation type */
	for(k = 0; k < num_blk; k++){
		if(mod == 2){
			coded_blk_len[k] = 12 * blk_num_slot[k];		         //QPSK modulation
		}
		else if(mod == 4){
			coded_blk_len[k] = 24 * blk_num_slot[k];	             //16 QAM modulation			
		}
		else{
			coded_blk_len[k] = 36 * blk_num_slot[k];		         //64 QAM modulation
		}	
	}


	/* initialize burst data length*/
	bst_len = 0;

	
	/* generate each uncoded block length in bytes according to different rate type*/
	for(k = 0; k < num_blk; k++){
		if(rate_id == 1){
			uncoded_blk_len[k] = coded_blk_len[k] >> 1;	             //rate = 1/2
		}
		else if(rate_id == 2){
			uncoded_blk_len[k] = (coded_blk_len[k] << 1)/3;          //rate = 2/3
		}
		else if(rate_id == 3){
			uncoded_blk_len[k] = (coded_blk_len[k] * 3) >> 2;        //rate = 3/4
		}
		else{
			uncoded_blk_len[k] = (coded_blk_len[k] * 5)/6;           //rate = 5/6
		}

		
		/* get burst data length*/
		bst_len = bst_len + uncoded_blk_len[k];	
	}

	


	*burst_num_slot = burst_total_slot;
	*burst_num_slot_remain = num_slot_remain;

⌨️ 快捷键说明

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