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

📄 wib_dl_source_gen.c

📁 802.16e物理层下行子载波分配。严格按照802.16e实现。
💻 C
📖 第 1 页 / 共 5 页
字号:
/*
 * Copyright (c) 2006-2007, Jushri Co.Ltd, Shanghai
 * 
 * Filename: wib_dl_source_gen.c
 * Authors: yiming.song (sym); yanhua.bai(byh);
 * Version: 0.1				Date: 2007/01/15
 * 
 * 
 * Project: Fixed C simulation platform for WIABS
 *
 * Description: 
 *  The global definitions and declearation of source data for downlink frame 
 *  transmission, which including the generation of DL-MAP,FCH,and add them to the 
 *	frame source data. 
 *  The generation of DL-MAP and FCH should based on the 
 *  DL Tx Frame Descriptor information which inputed from configuration files
 *
 *  Correspondly,It also include the analyze of DL-MAP and FCH, based which 
 *  the DL Rx Frame information be configured 
 *
 *
 *  The generation of DL-MAP support PUSC and FUSC permutaion and HARQ Chase combining mode
 *  In HARQ DL MAP IE,not support Region ID.
 *  The content of DL HARQ Chase sub-burst IE is fixed,the length is 4.5 bytes 
 * 
 * Function list:
 *   1. fec_code_diuc    reflect the FEC code to DIUC			(Authors : yiming.song)
 *   2. gen_dlul_map     generate the MAP message				(Authors : yanhua.bai)
 *   3. gen_fch			 generate FCH							(Authors : yiming.song)
 *   4. gen_source_data  generate downlink tx frame source data	(Authors : yiming.song)
 *   5. dl_fch_analyze	 FCH analyze for downlink rx frame		(Authors : yiming.song)
 *   6. dl_dlmap_analyze DL-MAP analyze for downlink rx frame	(Authors : yanhua.bai)	
 *
 * Historys:
 * Authors    Date         Version  Description
 * sym      2007-01-15      0.1     Create
 * byh      2007-03-02      0.2     Modify
 * 
 */

/*
 ***************************************************************************************
 *                                     DEFINES
 ***************************************************************************************
 */
#include "..\include\wib_phy_def.h"
#include "..\include\wib_dl_source_gen.h"
#include "..\include\wib_dl_hcs_crc.h"
#include "..\include\wib_dl_lowmac.h"

/* reflect fec code to DIUC */
UINT16 fec_code_diuc(
	UINT8 fec_code_type
					)
{
	UINT16 diuc;

	switch(fec_code_type){
	case 0:
		diuc = 0;
		break;
	case 1:
		diuc = 1;
		break;
	case 2:
		diuc = 2;
		break;
	case 3:
		diuc = 3;
		break;
	case 4:
		diuc = 4;
		break;
	case 5:
		diuc = 5;
		break;
	case 6:
		diuc = 6;
		break;
	case 13:
		diuc = 7;
		break;
	case 15:
		diuc = 8;
		break;
	case 16:
		diuc = 9;
		break;
	case 17:
		diuc = 10;
		break;
	case 18:
		diuc = 11;
		break;
	case 19:
		diuc = 12;
		break;
	}

	return diuc;
}

/* generate map message */                
int gen_dlul_map(
    DL_SUBFRAME_STRUCT  *dl_subframe_tx,
	UL_SUBFRAME_STRUCT  *ul_subframe_tx,
    UINT8				*p_dlul_map,
	UINT16				*dlul_map_length
    )
{
	/*
	 ***************************************************************************************
	 *                             basic parameter definition
	 ***************************************************************************************
	 */

	/* Compressed DL_MAP format parameter definition*/	
	COMP_DLMAP_IE_HEADER comp_dlmap_header;			// Compressed DL_MAP Message Header
	SUBMAP_POINTER_IE submap_pointer;               // HARQ and Sub_MAP Pointer IE Content
	
	/* Compressed UL_MAP format parameter definition*/
	COMP_ULMAP_IE_HEADER comp_ulmap_header;         // Compressed UL_MAP Message Header

	/* SUB_DL_UL_MAP format parameter definition*/
	SUB_MAP_HEADER sub_dlul_map_header;             // SUB_DL_UL_MAP Message Header
	DLMAP_BURST_IE dl_burst_profile;			    // DL_MAP BURST PROFILE IE Content
	DLMAP_ZONE_SWITCH_IE dl_zone_switch;	 	    // STC DL ZONE IE Content
	DLMAP_CID_SWITCH_IE dl_cid_switch;			    // CID SWITCH IE Content
	DLMAP_HARQ_HEADER dl_harq_header;			    // HARQ IE HEADER	
	DLMAP_SUBBURST_IE dl_harq_subbrust;		        // HARQ Subburst IE Content

	ULMAP_BURST_IE ul_burst_profile;			    // UL_MAP BURST PROFILE IE Content
	ULMAP_FAST_FEEDBACK_IE ul_fast_feedback;        // FAST FEEDBACK IE Content
	ULMAP_CDMA_RANGING_IE ul_cdma_ranging;          // CDMA Bandwidth Request, CDMA Ranging IE Content
	ULMAP_CDMA_ALLOC_IE ul_cdma_alloc;              // CDMA Allocation IE Content
	ULMAP_HARQ_ACKCH_IE ul_harq_ackch;              // HARQ ACK Region Allocation IE Content
             

	/* dlmap parameter */
	UINT16 diuc_bst;			// DIUC of current burst;
	UINT16 dl_zone_num;		    // ZONE number in downlink frame	
	UINT16 dl_burst_type;	    // Burst type: 0: Map Data Burst,1: Normal Data Burst,2: Include subburst
	UINT8 inc_cid;			    // INC_CID flag
	UINT16 cid_burst;			// CID include in current burst
	UINT16 number_of_cid_bst;	// number of CID included in this burst
	UINT16 diuc_subbst;			// DIUC of current sub-burst;
	UINT16 harq_ie_len;			// Length value of HARQ DL MAP IE format

	/* ulmap parameter */
	UINT16 uiuc_bst;			// UIUC of current burst;
	UINT16 ulmap_burst_type;	// Burst type: 0: HARQ ACK Channel, 1: Fast Feedback Channel, 2: Initial Ranging/Handover Ranging,
	                            // 3: Periodic Ranging/Bandwidth Request, 4: PAPR/Safety Zone, 5: Sounding Zone, 6: Noise Floor Calculation, 
	                            // 7: Normal Data burst

	/* generic parameter */
	UINT16 bst_num_zone;		// Burst number of current ZONE;	
	UINT16 fec_code_type_bst;	// FEC CODE type;	
	UINT16 fec_code_type_subbst;// FEC CODE type of HARQ Chase sub-burst IE;
	UINT16 dlul_map_len;		// DL_UL_MAP length(bytes)
	UINT16 ie_num;              // number of IEs
	UINT16 nibble_ie_num;       // number of half-byte(nibble) IEs
	UINT16 byte_align_flag;		// Byte align flag : 0 : byte aligned; 1: not byte aligned

	/* Tempory variable definiton*/	
	UINT8 *p_comp_dlmap_header; // Compressed DL_MAP Message Pointer
	UINT8 *p_submap_pointer;    // Sub_MAP Pointer IE Pointer
	UINT8 *p_comp_ulmap_header; // Compressed UL_MAP Message Pointer

	UINT8 *p_sub_dlul_map_header;      // SUB-DL-UL-MAP Message Pointer
	UINT8 *p_dl_burst_profile;	       // DL_MAP BURST PROFILE IE Pointer
	UINT8 *p_dl_zone_switch;		   // DL_MAP STC DL ZONE IE Pointer
	UINT8 *p_dl_cid_switch;	 	       // CID SWITCH IE Pointer
	UINT8 *p_dl_harq_header;		   // HARQ IE HEADER Pointer	
	UINT8 *p_dl_harq_subburst;		   // HARQ Subburst IE Pointer
	UINT8 *p_ul_burst_profile;         // UL_MAP BURST PROFILE IE Pointer
	UINT8 *p_ul_fast_feedback;         // FAST_FEEDBACK IE Pointer
	UINT8 *p_ul_cdma_ranging;          // CDMA_RANGING IE Pointer
	UINT8 *p_ul_cdma_alloc;            // CDMA_ALLOC IE Pointer
	UINT8 *p_ul_harq_ackch;            // HARQ_ACKCH IE Pointer

	UINT8 *p_comp_map;                 // Compressed MAP Message Poiter
	UINT8 *p_sub_map;                  // SUB-DL-UL-MAP Message Poiter
	UINT32 comp_map_crc32;             // Compressed MAP CRC32
	UINT16 sub_map_crc16;              // SUB MAP CRC16

		
	UINT16 i,j,k,l,n;
	UINT8 cid_flag_bst_last;
	UINT8 slot_len_qpsk_1_2 = 6;	   // number of bytes of a slot when QPSK_1_2,PUSC
	UINT16 comp_map_len;               // number of bytes of Compressed DL_MAP Message
	UINT16 sub_map_len;                // number of bytes of SUB-DL-UL-MAP Message
	UINT16 slot_num_dlul_map;          // number of slots of the whold MAP Message
	UINT16 slot_num_sym_zone0;		   // number of slots of a symbol of zone #0
	UINT16 number_of_symbol_dlulmap;   // number of symbols of dlmap 


	p_comp_map = malloc(100*sizeof(UINT8));
	p_sub_map = malloc(400*sizeof(UINT8));

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

	/****************************Generate Compressed DL-MAP message header*********************************/
	
	
	/*initialize dlul_map_len */
	dlul_map_len = 0;

	
	/* assign Compressed DL-MAP IE Header */
	comp_dlmap_header.comp_map_indic = 0b110;                                       // Compressed map indicator
	comp_dlmap_header.ulmap_app = 1;                                                // UL_MAP appended
	comp_dlmap_header.map_len = 19;                                                 // MAP message length
	comp_dlmap_header.frmdur_code = (UINT8)dl_subframe_tx->frame_duration_code;     // Frame Duration Code
	comp_dlmap_header.frm_num = dl_subframe_tx->frame_number;                       // Frame number
	comp_dlmap_header.dcd_cnt = (UINT8)dl_subframe_tx->dcd_cnt;			            // DCD Count
	comp_dlmap_header.operator_id = (UINT8)dl_subframe_tx->operator_id;			    // Operator ID
	comp_dlmap_header.sector_id = (UINT8)dl_subframe_tx->sector_id;			        // Sector ID
	comp_dlmap_header.symb_num = (UINT8)dl_subframe_tx->symbol_num;	 	            // Number of OFDMA symbols in the DL subframe including all zone 
	comp_dlmap_header.dl_ie_cnt = 1;	 	                                        // Number of DL IE in compressed DL_MAP message

	
	/* get the address of compressed dlmap header */
	p_comp_dlmap_header = (UINT8*)(&comp_dlmap_header);


	/* assign compressed dlmap message format (totally 11 bytes)*/
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 1);	// Compressed map indicator, UL_MAP appended, MAP message length[10:8]
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header);	    // MAP message length[7:0]
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 2);	// Frame Duration Code
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 5);	// Frame Number[23:16]
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 4);	// Frame Number[15:8]
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 3);	// Frame Number[7:0]
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 6);	// DCD Count 
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 7);	// Operator ID 
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 8);	// Sector ID 
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 9);	// Number of OFDMA symbols in the DL subframe including all zone 
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_comp_dlmap_header + 10);	// Number of DL IEs 
	dlul_map_len++;


	
	/********************************Generate Sub_MAP Pointer IE *******************************************/	
	/* assign Sub_MAP Pointer IE Content*/
	submap_pointer.diuc = 15;                                           // DIUC = 15 for Extended DIUC
	submap_pointer.ext_diuc = 0x07;                                     // Extended DIUC = 0x07
	submap_pointer.len = 0;                                             // Length	                                     	
	submap_pointer.map_version = 0b01;                                  // Indicates different map version
	submap_pointer.byte_align = 0;                                      // align to byte boundary 


	fec_code_type_bst = dl_subframe_tx->zone[0].burst[1].fec_code_type;	
	diuc_bst = (UINT16)fec_code_diuc((UINT8)(fec_code_type_bst));       

	submap_pointer.amc_diuc = (UINT8)(diuc_bst);                        // Indicates the DIUC of the burst containing the SUB MAP message
	submap_pointer.num_slot = dl_subframe_tx->zone[0].burst[1].number_of_slot;	                                       
	                                                                    // The number of slots allocated for the burst containing the SUB MAP message
	submap_pointer.repet_cod = dl_subframe_tx->zone[0].burst[1].repetition_coding;                                       
	                                                                    // Indicates the repetition code for the burst containing the SUB MAP message


	/* get the address of Sub_MAP Pointer IE */
	p_submap_pointer = (UINT8*)(&submap_pointer);


	/* assign Sub_MAP Pointer IE format (totally 4 bytes)*/
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_submap_pointer);	        // DIUC, extended DIUC
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_submap_pointer);	        // Length, AMC DIUC
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_submap_pointer);	        // Number of slots
	dlul_map_len++;
	*(p_dlul_map + dlul_map_len) = (UINT8)(*p_submap_pointer);	        // Repetition coding indication, MAP Version, 
	dlul_map_len++;


	
	/*****************************Generate Compressed UL-MAP message header**********************************/	
	/* assign Compressed UL-MAP IE Header */
	comp_ulmap_header.ucd_cnt = (UINT8)ul_subframe_tx->ucd_cnt;			 // UCD Count

⌨️ 快捷键说明

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