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

📄 desc_ram.c

📁 开发的802.16e物理层上下行MAP解析
💻 C
字号:

/*
 * =====================================================================================
 * function: desc_ram module
 * parameters: 
 *          DL_SUBFRAME_STRUCT   *p_dl_subframe_rx,    //DL subframe struct
 *          UL_SUBFRAME_STRUCT   *p_ul_subframe_rx,    //UL subframe struct
 *          UINT32               *p_dl_desc_ram,       //DL subframe descriptor RAM content
 *          UINT32               *p_ul_desc_ram)       //UL subframe descriptor RAM content
 * return value:    0 : the program operates correctly
 *                  others : the program is illegal or incorrect 
 * description: generate DL subframe descriptor RAM content and UL subframe descriptor RAM content
 * Author : yanhua.bai
 * -------------------------------------------------------------------------------------
 */
int desc_ram(
    DL_SUBFRAME_STRUCT   *p_dl_subframe_rx,
	UL_SUBFRAME_STRUCT   *p_ul_subframe_rx,
	UINT32               *p_dl_desc_ram,
	UINT32               *p_ul_desc_ram
	)
{

    /*
	 ***************************************************************************************
	 *                             basic parameter definition
	 ***************************************************************************************
	*/

	/* Tempory variable definiton*/
	UINT16 i,j,k;


	/* generic parameter */
	UINT16 num_zone;                                   //number of zone                        
	UINT16 num_bst;                                    //number of burst  
	UINT16 num_blk;                                    //number of block
	UINT16 bst_type;                                   //burst type
	UINT16 dl_ram_len;                                 //dl subframe descriptor ram length
	UINT16 ul_ram_len;                                 //ul subframe descriptor ram length

	FILE *fp_desc_ram;
	fp_desc_ram = fopen("desc_ram.txt","w");

  
    //dl subframe descriptor ram length
	dl_ram_len = 0;

	//dl subframe parameter structure
	*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->subframe_type + 1) << 24) | ((UINT32)(p_dl_subframe_rx->frame_number) << 16);
    dl_ram_len++;
	*(p_dl_desc_ram + dl_ram_len) = 0;
	dl_ram_len++;
	*(p_dl_desc_ram + dl_ram_len) = (UINT32)(p_dl_subframe_rx->number_of_zone) << 24;
	dl_ram_len++;

	//number of zone
	num_zone = p_dl_subframe_rx->number_of_zone;

	//downlink zone parameter structure
	for(i = 0; i < num_zone; i++){
		*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].zone_type + 32) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].zone_index) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].start_symbol_offset) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].end_symbol_offset));
		dl_ram_len++;
		*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].permutation_type) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].use_all_sc_indicator) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].dl_permbase) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].prbs_id));
		dl_ram_len++;
		*(p_dl_desc_ram + dl_ram_len) = 0;
		dl_ram_len++;
		*(p_dl_desc_ram + dl_ram_len) = (UINT32)(p_dl_subframe_rx->zone[i].number_of_burst) << 24;
		dl_ram_len++;

		num_bst = p_dl_subframe_rx->zone[i].number_of_burst;

		//downlink burst parameter structure
		for(j = 0; j < num_bst; j++){
			if(p_dl_subframe_rx->zone[i].burst[j].burst_type == 0){
				bst_type = 64;
			}
			else if(p_dl_subframe_rx->zone[i].burst[j].burst_type == 2){
				bst_type = 65;
			}

			*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(bst_type) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].burst_index) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].fec_code_type));
			dl_ram_len++;
			*(p_dl_desc_ram + dl_ram_len) = (UINT32)(p_dl_subframe_rx->zone[i].burst[j].burst_data_len_byte);
			dl_ram_len++;
			*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].ofdma_symbol_offset) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].subchannel_offset) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].boosting) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].repetition_coding));
			dl_ram_len++;

			num_blk = p_dl_subframe_rx->zone[i].burst[j].number_of_block;
			if(num_blk > 0){
			if((num_blk - 3 >= 0) && (p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 3].block_len_uncoded != p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded)){
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(num_blk - 2) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 3].number_of_slot) << 12) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].number_of_slot) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 4) | ((UINT32)(2) << 2);
				dl_ram_len++;
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 3].block_len_uncoded) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 8);
				dl_ram_len++;
			}
			else if((num_blk - 2 >= 0) && (p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded != p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded)){
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(num_blk - 1) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].number_of_slot) << 12) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 4) | ((UINT32)(1) << 2);
				dl_ram_len++;
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 24) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 8);
				dl_ram_len++;
			}
			else{
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(num_blk) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 12);
				dl_ram_len++;
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded) << 24);
				dl_ram_len++;
			}
			}
			if(p_dl_subframe_rx->zone[i].burst[j].burst_type == 0){
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].number_of_slot) << 16);
				dl_ram_len++;
			}
			else if(p_dl_subframe_rx->zone[i].burst[j].burst_type == 2){
				*(p_dl_desc_ram + dl_ram_len) = ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].number_of_slot) << 16) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].number_of_symbol) << 8) | ((UINT32)(p_dl_subframe_rx->zone[i].burst[j].number_of_subchannel));
				dl_ram_len++;
			}
			*(p_dl_desc_ram + dl_ram_len) = 0;
			dl_ram_len++;
		}
	}


	fprintf(fp_desc_ram,"\n/**********************DL Subframe Descriptor RAM **********************/\n");
	fprintf(fp_desc_ram,"the length of DL Subframe Descriptor RAM is : %d\n",dl_ram_len);
	for(k = 0; k < dl_ram_len; k++){
		fprintf(fp_desc_ram," %08x ",*(p_dl_desc_ram + k));
		if(k%10 == 9){
			fprintf(fp_desc_ram,"\n");
		}					
	}



	//ul subframe descriptor ram length
	ul_ram_len = 0;

	//ul subframe parameter structure
	*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->subframe_type + 1) << 24) | ((UINT32)(p_ul_subframe_rx->frame_number) << 16);
    ul_ram_len++;
	*(p_ul_desc_ram + ul_ram_len) = (UINT32)(p_ul_subframe_rx->alloc_stime);
	ul_ram_len++;
	*(p_ul_desc_ram + ul_ram_len) = (UINT32)(p_ul_subframe_rx->number_of_zone) << 24;
	ul_ram_len++;

	num_zone = p_ul_subframe_rx->number_of_zone;

	//uplink zone parameter structure
	for(i = 0; i < num_zone; i++){
		*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].zone_type + 32) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].zone_index) << 16) | ((UINT32)(p_ul_subframe_rx->zone[i].start_symbol_offset) << 8) | ((UINT32)(p_ul_subframe_rx->zone[i].end_symbol_offset));
		ul_ram_len++;
		*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].permutation_type) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].use_all_sc_indicator) << 20) | ((UINT32)(p_ul_subframe_rx->zone[i].ul_permbase) << 8);
		ul_ram_len++;
		*(p_ul_desc_ram + ul_ram_len) = 0;
		ul_ram_len++;
		*(p_ul_desc_ram + ul_ram_len) = (UINT32)(p_ul_subframe_rx->zone[i].number_of_burst) << 24;
		ul_ram_len++;

		num_bst = p_ul_subframe_rx->zone[i].number_of_burst;

		//uplink burst parameter structure
		for(j = 0; j < num_bst; j++){
			*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].burst_type + 64) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].burst_index) << 8) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].fec_code_type));
			ul_ram_len++;
			*(p_ul_desc_ram + ul_ram_len) = (UINT32)(p_ul_subframe_rx->zone[i].burst[j].burst_data_len_byte);
			ul_ram_len++;
			*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].ofdma_symbol_offset) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].subchannel_offset) << 16) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].repetition_coding));
			ul_ram_len++;
			*(p_ul_desc_ram + ul_ram_len) = 0;
			ul_ram_len++;

			if(p_ul_subframe_rx->zone[i].burst[j].burst_type == 0){
				*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_symbol) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_subchannel) << 16);
				ul_ram_len++;
			}
			else if(p_ul_subframe_rx->zone[i].burst[j].burst_type == 1){
				*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_symbol) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_subchannel) << 16);
				ul_ram_len++;
			}
			else if(p_ul_subframe_rx->zone[i].burst[j].burst_type == 2){
				*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].ranging_method) << 8);
				ul_ram_len++;
			}
			else if(p_ul_subframe_rx->zone[i].burst[j].burst_type == 3){
				*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].ranging_method - 2) << 8);
				ul_ram_len++;
			}
			else if(p_ul_subframe_rx->zone[i].burst[j].burst_type == 7 || p_ul_subframe_rx->zone[i].burst[j].burst_type == 8){
				num_blk = p_ul_subframe_rx->zone[i].burst[j].number_of_block;
				if(num_blk > 0){
					if((num_blk >= 3) && (p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 3].block_len_uncoded != p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded)){
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_slot) << 16) | ((UINT32)(num_blk - 2));
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 3].number_of_slot) << 28) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].number_of_slot) << 24) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 20) | ((UINT32)(2) << 18) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 3].block_len_uncoded) << 8) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded));
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 24);
						ul_ram_len++;				
					}
					else if((num_blk >= 2) && (p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded != p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded)){
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_slot) << 16) | ((UINT32)(num_blk - 1));
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].number_of_slot) << 28) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 20) | ((UINT32)(1) << 18) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 2].block_len_uncoded) << 8);
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 24);
						ul_ram_len++;		
					}
					else{
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].number_of_slot) << 16) | ((UINT32)(num_blk));
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].number_of_slot) << 28) | ((UINT32)(p_ul_subframe_rx->zone[i].burst[j].block[num_blk - 1].block_len_uncoded) << 8);
						ul_ram_len++;
						*(p_ul_desc_ram + ul_ram_len) = 0;
						ul_ram_len++;
					}
				}
			}
			*(p_ul_desc_ram + ul_ram_len) = 0;
			ul_ram_len++;
		}
	}


	fprintf(fp_desc_ram,"\n\n\n/**********************UL Subframe Descriptor RAM **********************/\n");
	fprintf(fp_desc_ram,"the length of UL Subframe Descriptor RAM is : %d\n",ul_ram_len);
	for(k = 0; k < ul_ram_len; k++){
		fprintf(fp_desc_ram," %08x ",*(p_ul_desc_ram + k));
		if(k%10 == 9){
			fprintf(fp_desc_ram,"\n");
		}					
	}


	fclose(fp_desc_ram);
	return(1);
}

	
 

⌨️ 快捷键说明

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