📄 wib_dl_phy.c
字号:
frame_len_symbol = dl_subframe_desc_tx.zone[dl_subframe_desc_tx.number_of_zone - 1].end_symbol_offset;
/********************* Generate source data for downlink subframe *****************************/
/* generate DL-MAP */
p_dl_subframe_desc_tx = &dl_subframe_desc_tx;
gen_dl_map(
p_dl_subframe_desc_tx,
dl_data.dlmap,
&dlmap_length_pdu
);
/* generate FCH */
gen_fch(
p_dl_subframe_desc_tx,
dl_data.fch
);
/* generate block size of every burst */
dl_gen_block_desc(
p_dl_subframe_desc_tx
);
/* generate the source data for downlink subframe */
gen_source_data (
p_dl_subframe_desc_tx, // DL frame desctriptor
dl_data.fch, // FCH data
dl_data.dlmap, // DL-MAP data
&dlmap_length_pdu, // DL-MAP data length in bytes
dl_data.source_data, // DL subframe source data
&source_data_len // DL subframe source data length in bytes
);
/* Get the first address of frame source data */
p_source_data_block = &dl_data.source_data[0];
printf("\n the source data length is :%d\n",source_data_len);
p_log_frame = &dl_data.log_frame[0][0];
block_index_modulation = 0;
/********************* FCH Encode and Modulation ***************************************/
fprintf(fp_fch_data,"/************************** FCH data *****************************/\n");
blocksize_fch = 6; // the block size of FCH is 6 bytes
fec_code_type_fch = 0; // FCH shall be transmitted using rate 1/2 with CC Encode
modulation_type_fch = 0; // FCH shall be transmitted using QPSK
fprintf(fp_fch_data,"/*----- Initial data ---------*/ \n");
for (i = 0; i < blocksize_fch; i++)
{
fprintf(fp_fch_data," %02x ",*(p_source_data_block + i));
}
/* Convolution Encode */
p_cc_data = (UINT8*)dl_data.cc_data;
dl_cc_enc(
p_source_data_block, // input bit
p_cc_data, // CC output bit
(UINT16)(blocksize_fch * 8), // input bit length(p_dat_in).
fec_code_type_fch
);
fprintf(fp_fch_data,"\n/*----- Convolution encode data ---------*/ \n");
for (i = 0; i < (blocksize_fch * 2); i++)
{
fprintf(fp_fch_data," %02x ",dl_data.cc_data[i]);
}
p_source_data_block = p_source_data_block + blocksize_fch;
/* Data Interleave */
dl_interleave(
p_cc_data, // block data input (byte)
dl_data.interleave_data, // block data output(CC interleave result,bit)
(UINT16)(blocksize_fch * 16), // block size
fec_code_type_fch // modulation type 2:QPSK,4:16QAM,6:64QAM
);
fprintf(fp_fch_data,"\n/*----- Interleave data ---------*/ \n");
for (i = 0; i < (blocksize_fch * 2); i++)
{
fprintf(fp_fch_data," %02x ",dl_data.interleave_data[i]);
}
slot_len_coded_bst = slot_coded_len[fec_code_type_fch];
/* For every FCH slot,it should be repeated 4 times*/
for (i = 0; i < 4; i++){
for (j = 0; j < slot_len_coded_bst; j++){
tmp1 = slot_len_coded_bst * i + j;
dl_data.repetititon_data[tmp1] = dl_data.interleave_data[j];
}
}
fprintf(fp_fch_data,"\n/*----- Repetition data ---------*/ \n");
for (i = 0; i < blocksize_fch * 8; i++){
fprintf(fp_fch_data," %02x ",dl_data.repetititon_data[i]);
if (i % 12 == 11){
fprintf(fp_fch_data,"\n");
}
}
/* FCH constellation map*/
for (i = 0 ; i < 4; i++)
{
tmp1 = i * blocksize_fch * 2;
block_index_modulation = i * SC_NUM_SLOT; // current slot start index in map data
p_data_repet_slot = &dl_data.repetititon_data[tmp1]; // Current slot start data pointer before modulation
p_data_map_slot = &dl_data.map_data[block_index_modulation]; // Current slot start data pointer after modulation
dl_modulation(
p_data_repet_slot,
p_data_map_slot,
data_width,
fec_code_type_fch
);
}
fprintf(fp_fch_data,"\n/*----- Modulation data ---------*/ \n");
for (i = 0; i < 48 * 4; i++){
if (i % 48 == 0){
fprintf(fp_fch_data,"//slot # %4d\n",i/48);
}
fprintf(fp_fch_data," %6d + %6d i\n",dl_data.map_data[i].real,dl_data.map_data[i].imag);
}
p_data_map_slot = &dl_data.map_data[0];
// printf("map_data = : %2d + i %2d \n",p_data_map_slot->real,p_data_map_slot->imag);
dl_logic_frame_construct(
p_dl_subframe_desc_tx, // frame descriptor
p_data_map_slot, // input data : modulation data
p_log_frame, // output data: logic frame data
1, // FCH flag
0, // zone number
0 // burst number
);
/********************* Zone data Encode and Modulation *********************************/
#define all
#ifdef all
/* reset the first address of source data after FCH */
data_source_len_frame = 6;
for (i = 0; i < dl_subframe_desc_tx.number_of_zone; i++){ // every zone
fprintf(fp_test_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
fprintf(fp_source_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
fprintf(fp_rand_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
fprintf(fp_encode_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
fprintf(fp_repet_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
fprintf(fp_modulation_data,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
// fprintf(fp_logic_frame,"\n\n/************************** Zone#%2d data *****************************/\n\n",i);
for (j = 0; j < dl_subframe_desc_tx.zone[i].number_of_burst; j++){ // every burst
fprintf(fp_test_data,"\n/*************************** Burst%2d data **************************/\n",j);
fprintf(fp_source_data,"\n/*************************** Burst%2d data **************************/\n",j);
fprintf(fp_rand_data,"\n/*************************** Burst%2d data **************************/\n",j);
fprintf(fp_encode_data,"\n/*************************** Burst%2d data **************************/\n",j);
fprintf(fp_repet_data,"\n/*************************** Burst%2d data **************************/\n",j);
fprintf(fp_modulation_data,"\n/*************************** Burst%2d data **************************/\n",j);
// fprintf(fp_logic_frame,"\n/*************************** Burst%2d data **************************/\n",j);
fec_code_type_bst = dl_subframe_desc_tx.zone[i].burst[j].fec_code_type;
/* Get the repetition coding factor */
if (dl_subframe_desc_tx.zone[i].burst[j].repetition_coding == 0)
{
repet_facotor_bst = 1;
}
else
{
repet_facotor_bst = dl_subframe_desc_tx.zone[i].burst[j].repetition_coding * 2;
}
/* Get the slot data length after encode of current burst */
slot_len_coded_bst = slot_coded_len[fec_code_type_bst];
block_index_modulation = 0; //the map data index of every block should be reset
for (k = 0; k < dl_subframe_desc_tx.zone[i].burst[j].number_of_block; k++){ // every block
fprintf(fp_test_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_source_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_rand_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_encode_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_repet_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_modulation_data,"\n/*------ Block # %2d ; slot number is :%2d -------*/\n",
k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
/* Get the uncoded/coded data length (bytes) of current block */
block_len_uncoded = dl_subframe_desc_tx.zone[i].burst[j].block[k].block_len_uncoded;
block_len_coded = dl_subframe_desc_tx.zone[i].burst[j].block[k].block_len_coded;
fprintf(fp_test_data,"\n/* Initial data length: %3d bytes*/ \n",block_len_uncoded);
fprintf(fp_source_data,"\n/* Initial data length: %3d bytes*/ \n",block_len_uncoded);
/* Output dlmap */
if ((i == 0) && (j == 0)){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data,"\n /*****************block %3d (%3d slots) *********/\n",k,dl_subframe_desc_tx.zone[i].burst[j].block[k].number_of_slot);
fprintf(fp_dlmap_data,"\n/*----- Initial data --------*/\n");
}
for (l = 0; l < block_len_uncoded; l++){
fprintf(fp_test_data," %02x ",*(p_source_data_block + l));
fprintf(fp_source_data," %02x ",*(p_source_data_block + l));
if (l % 10 == 9){
fprintf(fp_test_data,"\n");
fprintf(fp_source_data,"\n");
}
/* Output dlmap */
if (i == 0 && j == 0){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data," %02x ",*(p_source_data_block + l));
if (l % 10 == 9){
fprintf(fp_dlmap_data,"\n");
}
}
}
/*-------------------- Randomize --------------------*/
dl_randomize(
p_source_data_block, // data input byte
dl_data.rand_data, // Randomizing result output
(UINT16)(block_len_uncoded * 8) // the size of FEC block(in Byte)
);
fprintf(fp_test_data,"\n/* Randomize data length: %3d bytes */ \n",block_len_uncoded);
fprintf(fp_rand_data,"\n/* Randomize data length: %3d bytes */ \n",block_len_uncoded);
/* output dlmap*/
if (i == 0 && j == 0 ){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data,"\n/*----- Randomize data --------*/\n");
}
for (l = 0; l < block_len_uncoded; l++){
fprintf(fp_test_data," %02x ",dl_data.rand_data[l]);
fprintf(fp_rand_data," %02x ",dl_data.rand_data[l]);
if (l % 10 == 9){
fprintf(fp_test_data,"\n");
fprintf(fp_rand_data,"\n");
}
/* Output dlmap */
if (i == 0 && j == 0){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data," %02x ",dl_data.rand_data[l]);
if (l % 10 == 9){
fprintf(fp_dlmap_data,"\n");
}
}
}
/* add a block data length */
p_source_data_block = p_source_data_block + block_len_uncoded;
data_source_len_frame = data_source_len_frame + block_len_uncoded;
/*-------------------- FEC Encode --------------------*/
if (fec_code_type_bst <= 6){ // CC Encode
/* Convolution Encode */
dl_cc_enc(
dl_data.rand_data, // input bit
dl_data.cc_data, // CC output bit
(UINT16)(block_len_uncoded * 8), // input bit length(p_dat_in).
fec_code_type_bst
);
fprintf(fp_test_data,"\n/* CC data length: %3d bytes */ \n",block_len_coded);
fprintf(fp_encode_data,"\n/* CC data length: %3d bytes */ \n",block_len_coded);
/* output dlmap*/
if (i == 0 && j == 0 ){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data,"\n/*----- CC Encode data --------*/\n");
}
for (l = 0; l < block_len_coded; l++){
fprintf(fp_test_data," %02x ",dl_data.cc_data[l]);
fprintf(fp_encode_data," %02x ",dl_data.cc_data[l]);
if (l % 10 == 9){
fprintf(fp_test_data,"\n");
fprintf(fp_encode_data,"\n");
}
/* output dlmap*/
if (i == 0 && j == 0 ){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data," %02x ",dl_data.cc_data[l]);
if (l % 10 == 9){
fprintf(fp_dlmap_data,"\n");
}
}
}
/* Data Interleave */
dl_interleave(
dl_data.cc_data, // block data input (byte)
dl_data.interleave_data, // block data output(CC interleave result,bit)
(UINT16)(block_len_coded * 8), // block size
fec_code_type_bst // modulation type 2:QPSK,4:16QAM,6:64QAM
);
fprintf(fp_test_data,"\n/* Interleave data length: %3d bytes*/ \n",block_len_coded);
fprintf(fp_encode_data,"\n/* Interleave data length: %3d bytes*/ \n",block_len_coded);
/* output dlmap*/
if (i == 0 && j == 0 ){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data,"\n/*----- Interleaved data --------*/\n");
}
for (l = 0; l < block_len_coded; l++){
fprintf(fp_test_data," %02x ",dl_data.interleave_data[l]);
fprintf(fp_encode_data," %02x ",dl_data.interleave_data[l]);
if (l % 10 == 9){
fprintf(fp_test_data,"\n");
fprintf(fp_encode_data,"\n");
}
/* output dlmap*/
if (i == 0 && j == 0 ){ // burst#0 is DL-MAP
fprintf(fp_dlmap_data," %02x ",dl_data.interleave_data[l]);
if (l % 10 == 9){
fprintf(fp_dlmap_data,"\n");
}
}
}
/* assign the data point before repeated*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -