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

📄 wib_dl_source_gen.c

📁 802.16e物理层下行子载波分配。严格按照802.16e实现。
💻 C
📖 第 1 页 / 共 5 页
字号:
						}
					}
				}

				/* if current burst not include CID */
				else if(inc_cid == 0){

					/* if current is align to byte */
					if(byte_align_flag == 0){	
						*(p_dlul_map + dlul_map_len) = (UINT8)((diuc_bst & 0xf) << 4);		//DIUC[3:0]

						/* not align to byte */
						byte_align_flag = 1;		

					}

					/* if current is align to byte */
					else if(byte_align_flag == 1){	
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dlul_map + dlul_map_len) | (diuc_bst & 0xf));	//DIUC[3:0]
						dlul_map_len++;

						/* align to byte */
						byte_align_flag = 0;						
					}
				}		
				
				/********************************** Insert burst profile  IE  *********************************/				
				/* get burst profile parameter */
				dl_burst_profile.symbol_ofst = (UINT8)(dl_subframe_tx->zone[i].burst[j].ofdma_symbol_offset);	// OFDMA Symbol offset
				dl_burst_profile.subchn_ofst = dl_subframe_tx->zone[i].burst[j].subchannel_offset;				// Subchannel offset for current IE
				dl_burst_profile.boosting = dl_subframe_tx->zone[i].burst[j].boosting;							// Boosting for current IE 
				dl_burst_profile.symbol_num = dl_subframe_tx->zone[i].burst[j].number_of_symbol;				// The number of OFDMA symbols are used to carry the current burst	
				dl_burst_profile.subchn_num = (UINT8)(dl_subframe_tx->zone[i].burst[j].number_of_subchannel);	// The number of subchannels are used to carry the current burst
				dl_burst_profile.repet_cod = (UINT8)(dl_subframe_tx->zone[i].burst[j].repetition_coding);		// Indicate the repetition coding used inside current burst

				p_dl_burst_profile = (UINT8*)(&dl_burst_profile);

				/* if current is align to byte */
				if(byte_align_flag == 0){			        	
					
					*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_burst_profile);			// OFDMA Symbol offset[7:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 2));      // Subchannel offset [5:0],Boosting[2:1]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 1));	    // Boosting[0],The number of OFDMA symbols[6:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 3));	    // The number of subchannels[5:0],repetition coding[1:0]
					dlul_map_len++;
				}
				else if(byte_align_flag == 1){			        	
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_burst_profile);			// OFDMA Symbol offset[7:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 2));	    // Subchannel offset [5:0],Boosting[2:1]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 1));	    // Boosting[0],The number of OFDMA symbols[6:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_burst_profile + 3));	    // The number of subchannels[5:0],repetition coding[1:0]

					/* All byte shift left 4bits */
					*(p_dlul_map + dlul_map_len - 4) = (UINT8)((*(p_dlul_map + dlul_map_len - 4)) >> 4);
					for (k = 0; k < 5; k++)	// if the current ie align to byte ,then shift bytes equal ie lenth add 1 : 4 + 1 = 5
					{
						*(p_dlul_map + dlul_map_len - 4 + k) = (UINT8)(((*(p_dlul_map + dlul_map_len - 4 + k)) << 4) 
													| ((*(p_dlul_map + dlul_map_len - 3 + k)) >> 4));
					}

				}

			}

			/********************************** Insert HARQ DL MAP IE Header *********************************/
			/* HARQ DL MAP IE*/
			else if (dl_burst_type == 2)
			{
				/* get burst profile parameter */
				dl_harq_header.diuc = 0xe;
				dl_harq_header.ext_diuc = 0x7;														// DIUC = 14 for Extened-2 DIUC
				dl_harq_header.rcid_type = 0;														// Extened-2 DIUC = 0x07 for HARQ DL MP IE
				dl_harq_header.reserved1 = 0;	
				
				dl_harq_header.boosting = (UINT8)(dl_subframe_tx->zone[i].burst[j].boosting);		// Boosting
				dl_harq_header.regn_id_idc = 0;													    // Region_ID use indicator,should be 0
				dl_harq_header.symbol_ofst = dl_subframe_tx->zone[i].burst[j].ofdma_symbol_offset;	// OFDMA symbol offset
				dl_harq_header.subchn_ofst = dl_subframe_tx->zone[i].burst[j].subchannel_offset;	// Subchannel offset
				dl_harq_header.symbol_num = dl_subframe_tx->zone[i].burst[j].number_of_symbol;		// Number of OFDMA symbols
				dl_harq_header.subchn_num = dl_subframe_tx->zone[i].burst[j].number_of_subchannel;	// Number of subchannels
				dl_harq_header.reserved2 = 0;					

				dl_harq_header.mode = 0;															// Indicates the mode of HARQ region
				dl_harq_header.subburst_ie_len = 11;												// Length,in nibbles,to indicate the size of sub-burst IE in this HARQ mode	
				dl_harq_header.num_subburst = dl_subframe_tx->zone[i].burst[j].number_of_subburst;	// Number of sub-bursts in the 2D region
				dl_harq_header.num_ack_chnl = (UINT8)(dl_harq_header.num_subburst);					// Number of HARQ ACK enable sub-bursts in the 2D region					
				dl_harq_header.harq_ie_len = (UINT8)(dl_harq_header.num_subburst * 5.5 + 9.5);      // Compute HARQ IE Length				
				dl_harq_header.byte_align = 0;														// Byte align[3:0]

				p_dl_harq_header = (UINT8*)(&dl_harq_header);

				/* if current is align to byte */
				if(byte_align_flag == 0){		
					*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_harq_header);		    // DIUC[3:0],Extended-2 DIUC[3:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 1));	// Length[7:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 2));	// RCID_Type[1:0],reserved[1:0],Boosting[2:0],Region_ID use indicator
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 6));	// OFDMA Symbol offset[7:0]
					dlul_map_len++;	
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 5));	// Subchannel offset[6:0],Number of OFDMA symbols[6]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 4));	// Number of OFDMA symbols[5:0],Number of subchannels[6:5]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 3));	// Number of subchannels[4:0],reserved[2:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 8));	// Mode[3:0],Sub-buyrst IE length[7:4]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 7));	// Sub-buyrst IE length[3:0],Number of sub-bursts[3:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 9));	// Number of HARQ ACK[3:0],byte align[3:0]

					/* not align to byte */
					byte_align_flag = 1;
					
				}
				/* if current is not align to byte */
				else if (byte_align_flag == 1){
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_harq_header);		// DIUC[3:0],Extended-2 DIUC[3:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 1));	// Length[7:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 2));	// RCID_Type[1:0],reserved[1:0],Boosting[2:0],Region_ID use indicator
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 6));	// OFDMA Symbol offset[7:0]
					dlul_map_len++;	
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 5));	// Subchannel offset[6:0],Number of OFDMA symbols[6]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 4));	// Number of OFDMA symbols[5:0],Number of subchannels[6:5]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 3));	// Number of subchannels[4:0],reserved[2:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 8));	// Mode[3:0],Sub-buyrst IE length[7:4]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 7));	// Sub-buyrst IE length[3:0],Number of sub-bursts[3:0]
					dlul_map_len++;
					*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_header + 9));	// Number of HARQ ACK[3:0],byte align[3:0]

					/* All byte shift left 4bits */
					*(p_dlul_map + dlul_map_len - 10) = (UINT8)(*(p_dlul_map + dlul_map_len - 10) >> 4);
					for(k = 0; k < 10; k++){	//if the current ie not align to byte ,then shift bytes equal ceil(ie lenth) : Ceil(9.5) = 10
						*(p_dlul_map + dlul_map_len - 10 + k) = (UINT8)(((*(p_dlul_map + dlul_map_len - 10 + k)) << 4) 
									| ((*(p_dlul_map + dlul_map_len - 9 + k)) >> 4));
					}

					/* align to byte */
					byte_align_flag = 0;

				}
	
				/********************************** Insert HARQ Chase sub-burst IE *********************************/

				// should equal the number of sub-burst			
				for (k = 0; k < dl_harq_header.num_subburst; k++)
				{

					/* get fec code type and DIUC of current sub-burst */
					fec_code_type_subbst = dl_subframe_tx->zone[i].burst[j].subburst[k].fec_code_type;	
					diuc_subbst = fec_code_diuc(fec_code_type_subbst);		//reflect to DIUC

					/* get parameter of subburst */
					dl_harq_subburst.rcid = dl_subframe_tx->zone[i].burst[j].subburst[k].cid_subburst;				        // RCID_IE
					dl_harq_subburst.duration = dl_subframe_tx->zone[i].burst[j].subburst[k].number_of_slot;		        // Duration
					dl_harq_subburst.diuc_indic = 1;															 	        // Sub-Burst DIUC Indicator
					dl_harq_subburst.reserved1 = 0;																            // reserved
					dl_harq_subburst.diuc = diuc_subbst;															        // DIUC
					dl_harq_subburst.repet_cod = (UINT8)(dl_subframe_tx->zone[i].burst[j].subburst[k].repetition_coding);	// Repetition Coding Indication
					dl_harq_subburst.reserved2 = 0;																            // reserved
					dl_harq_subburst.acid = 0;																		        // ACID
					dl_harq_subburst.ai_sn = 0;																	            // AI_SN
					dl_harq_subburst.ack_disable = 0;																        // ACK disable
					dl_harq_subburst.dl_ctrl_indc = 0;																        // Dedicated DL Control Indicator
					dl_harq_subburst.byte_align = 0;																        // Byte align[3:0]
					
					p_dl_harq_subburst = (UINT8*)(& dl_harq_subburst);

					/* if current is align to byte */
					if(byte_align_flag == 0){
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 1));	// RCID[15:8]
						dlul_map_len++;						
						*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_harq_subburst);		// RCID[7:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 3));	// Duration[9:2] 
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 2));	// Duration[1:0],Sub-Burst DIUC Indicator,reserved,DIUC[3:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 4));	// repet_cod[1:0],reserved2[1:0],ACID[3:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 5));	// AI_SN,ACK disable flag,Dedicated DL Control Indicator,byte align[3:0]

						/* not align to byte */
						byte_align_flag = 1;							
					}
					else if (byte_align_flag == 1)
					{
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 1));	// RCID[15:8]
						dlul_map_len++;						
						*(p_dlul_map + dlul_map_len) = (UINT8)(*p_dl_harq_subburst);		// RCID[7:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 3));	// Duration[9:2] 
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 2));	// Duration[1:0],Sub-Burst DIUC Indicator,reserved,DIUC[3:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 4));	// repet_cod[1:0],reserved2[1:0],ACID[3:0]
						dlul_map_len++;
						*(p_dlul_map + dlul_map_len) = (UINT8)(*(p_dl_harq_subburst + 5));	// AI_SN,ACK disable flag,Dedicated DL Control Indicator,byte align[3:0]
						
						/* All byte shift left 4bits */
						*(p_dlul_map + dlul_map_len - 6) = (UINT8)(*(p_dlul_map + dlul_map_len - 6) >> 4);
						for(l = 0; l < 6; l++){ //if the current ie not align to byte ,then shift bytes equal ceil(ie lenth) : Ceil(5.5) = 6
							*(p_dlul_map + dlul_map_len - 6 + l) = (UINT8)(((*(p_dlul_map + dlul_map_len - 6 + l)) << 4) 
									| ((*(p_dlul_map + dlul_map_len - 5 + l)) >> 4));
						}
						
						/* align to byte */
						byte_align_flag = 0;
					}
				}
				
				/* padding the HARQ DL MAP IE to byte */
				if ((dl_harq_header.num_subburst % 2) == 0){	// If the number of subburst is even then 
															    // the total length of HARQ DL MAP IE is not align to byte		
					/* if current last byte is align to byte */
					if (byte_align_flag == 0)
					{
						*(p_dlul_map + dlul_map_len) = ((*(p_dlul_map + dlul_map_len)) | 0xf0);
						byte_align_flag = 1;
					}
					/* if current last byte is not align to byte */
					else if (byte_align_flag == 1)
					{
						*(p_dlul_map + dlul_map_len) = ((*(p_dlul_map + dlul_map_len)) | 0x0f);
						dlul_map_len++;
						byte_align_flag = 0;
					}					
				}
			}
		}
	}



	/* continue to assign SUB-DL-UL-MAP message format */
	if(byte_align_flag == 0){
		*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_ulmap_header + 3);	 // OFDMA symbol offset[7:0]
		dlul_map_len++;
		*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_ulmap_header + 4);	 // Subchannel offset[6:0], Reserved[0]
		dlul_map_len++;
	}
	else if (byte_align_flag == 1)
		dlul_map_len++;
		*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_ulmap_header + 3);	 // OFDMA symbol offset[7:0]
		dlul_map_len++;
		*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_ulmap_header + 4);	 // Subchannel offset[6:0], Reserved[0]


		/* All byte shift left 4bits */
		*(p_dlul_map + dlul_map_len - 2) = (UINT8)(*(p_dlul_map + dlul_map_len - 2) >> 4);

		for(l = 0; l < 3; l++){
			*(p_dlul_map + dlul_map_len - 2 + l) = (UINT8)(((*(p_dlul_map + dlul_map_len - 2 + l)) << 4) 
									| ((*(p_dlul_map + dlul_map_len - 1 + l)) >> 4));
		}
	}
	
	
	



	/***********************Generate UL_MAP IE included in SUB-DL-UL-MAP message*****************************/

	ulmap_zone_num = ul_subframe_tx->number_of_zone;		       // get the number of zones of ul subframe;


	for (i = 0; i < ulmap_zone_num; i++){	
	    /* get burst number included in the firt zone of UL subframe*/
		bst_num_zone = ul_subframe_tx->zone[i].number_of_burst;

		/* generate burst IE*/
		for(j = 0; j < bst_num_zone; j++){

			/* get burst type */

⌨️ 快捷键说明

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