void phy_scope_eNB(FD_lte_phy_scope_enb *form, PHY_VARS_eNB *phy_vars_enb, int UE_id) { int eNB_id = 0; int i,arx,atx,ind,k; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->lte_frame_parms; int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE int16_t **rxsig_t; int16_t **chest_t; int16_t **chest_f; int16_t *pusch_llr; int16_t *pusch_comp; float Re,Im,ymax; float *llr, *bit; float I[nsymb_ce*2], Q[nsymb_ce*2]; float rxsig_t_dB[nb_antennas_rx][FRAME_LENGTH_COMPLEX_SAMPLES]; float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size]; float *chest_f_abs; float time[FRAME_LENGTH_COMPLEX_SAMPLES]; float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx]; int frame = phy_vars_enb->proc[0].frame_tx; uint32_t total_dlsch_bitrate = phy_vars_enb->total_dlsch_bitrate; int coded_bits_per_codeword = 0; uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2 int mcs = 0; // choose max MCS to compute coded_bits_per_codeword if (phy_vars_enb->ulsch_eNB[UE_id]!=NULL) { for (harq_pid=0;harq_pid<3;harq_pid++) { mcs = cmax(phy_vars_enb->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs,mcs); } } coded_bits_per_codeword = frame_parms->N_RB_UL*12*get_Qm(mcs)*frame_parms->symbols_per_tti; chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float)); llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero bit = malloc(coded_bits_per_codeword*sizeof(float)); rxsig_t = (int16_t**) phy_vars_enb->lte_eNB_common_vars.rxdata[eNB_id]; chest_t = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id]; chest_f = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates[eNB_id]; pusch_llr = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->llr; pusch_comp = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->rxdataF_comp[eNB_id][0]; // Received signal in time domain of receive antenna 0 if (rxsig_t != NULL) { if (rxsig_t[0] != NULL) { for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) { rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1]))); time[i] = (float) i; } fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],FRAME_LENGTH_COMPLEX_SAMPLES,"","",""); } for (arx=1;arx<nb_antennas_rx;arx++) { if (rxsig_t[arx] != NULL) { for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) { rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1]))); } fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],FRAME_LENGTH_COMPLEX_SAMPLES,rx_antenna_colors[arx]); } } } // Channel Impulse Response (still repeated format) if (chest_t != NULL) { ymax = 0; if (chest_t[0] !=NULL) { for (i=0; i<(frame_parms->ofdm_symbol_size); i++) { chest_t_abs[0][i] = (float) (chest_t[0][4*i]*chest_t[0][4*i]+chest_t[0][4*i+1]*chest_t[0][4*i+1]); if (chest_t_abs[0][i] > ymax) ymax = chest_t_abs[0][i]; } fl_set_xyplot_data(form->chest_t,time,chest_t_abs[0],(frame_parms->ofdm_symbol_size),"","",""); } for (arx=1;arx<nb_antennas_rx;arx++) { if (chest_t[arx] !=NULL) { for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) { chest_t_abs[arx][i] = (float) (chest_t[arx][4*i]*chest_t[arx][4*i]+chest_t[arx][4*i+1]*chest_t[arx][4*i+1]); if (chest_t_abs[arx][i] > ymax) ymax = chest_t_abs[arx][i]; } fl_add_xyplot_overlay(form->chest_t,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]); fl_set_xyplot_overlay_type(form->chest_t,arx,FL_DASHED_XYPLOT); } } // Avoid flickering effect // fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax); fl_set_xyplot_ybounds(form->chest_t,0,ymax); }
int main(int argc, char *argv[]) { int ret,ret2; unsigned int errors,uerrors,errors2,crc_misses,iterations,trials,trials2,block_length,errors3,trials3; double SNR,sigma,rate=.5; unsigned char qbits,mcs; char done0=0; char done1=1; char done2=1; unsigned int coded_bits; unsigned char NB_RB=25; int num_pdcch_symbols = 1; int subframe = 6; randominit(0); logInit(); lte_param_init(1,1,1,0,0,3); PHY_vars_eNB->dlsch_eNB[0][0] = new_eNB_dlsch(1,8,NB_RB,0); PHY_vars_UE->dlsch_ue[0][0] = new_ue_dlsch(1,8,4,NB_RB,0); PHY_vars_eNB->dlsch_eNB[0][1] = new_eNB_dlsch(1,8,NB_RB,0); PHY_vars_UE->dlsch_ue[0][1] = new_ue_dlsch(1,8,4,NB_RB,0); if (argc>1) mcs = atoi(argv[1]); else mcs = 0; printf("NB_RB %d\n",NB_RB); DLSCH_alloc_pdu.rah = 0; DLSCH_alloc_pdu.rballoc = DLSCH_RB_ALLOC; DLSCH_alloc_pdu.TPC = 0; DLSCH_alloc_pdu.dai = 0; DLSCH_alloc_pdu.harq_pid = 0; //DLSCH_alloc_pdu2.tb_swap = 0; DLSCH_alloc_pdu.mcs = mcs; DLSCH_alloc_pdu.ndi = 1; DLSCH_alloc_pdu.rv = 0; if (argc>2) qbits = atoi(argv[2]); else qbits = 4; printf("Quantization bits %d\n",qbits); generate_eNB_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu, 0x1234, format1, PHY_vars_eNB->dlsch_eNB[0], &PHY_vars_eNB->lte_frame_parms, PHY_vars_eNB->pdsch_config_dedicated, SI_RNTI, 0, P_RNTI, 0); //change this later generate_ue_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu, C_RNTI, format1, PHY_vars_UE->dlsch_ue[0], &PHY_vars_UE->lte_frame_parms, PHY_vars_UE->pdsch_config_dedicated, SI_RNTI, 0, P_RNTI); coded_bits = get_G(&PHY_vars_eNB->lte_frame_parms, PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->nb_rb, PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->rb_alloc, get_Qm(mcs), 1, num_pdcch_symbols, 0, subframe); printf("Coded_bits (G) = %d\n",coded_bits); block_length = dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]>>3; printf("Block_length = %d bytes (%d bits, rate %f), mcs %d, I_TBS %d, F %d, NB_RB %d\n",block_length, dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1],(double)dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]/coded_bits, mcs,get_I_TBS(mcs),PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->F,NB_RB); for (SNR=-5; SNR<15; SNR+=.1) { sigma = pow(10.0,-.05*SNR); printf("\n\nSNR %f dB => sigma %f\n",SNR,sigma); errors=0; crc_misses=0; errors2=0; errors3=0; iterations=0; if (done0 == 0) { ret = test_logmap8(PHY_vars_eNB->dlsch_eNB[0][0], PHY_vars_UE->dlsch_ue[0][0], coded_bits, NB_RB, sigma, // noise standard deviation qbits, block_length, // block length bytes NTRIALS, &errors, &trials, &uerrors, &crc_misses, &iterations, num_pdcch_symbols, subframe); if (ret>=0) printf("%f,%f,%f,%f\n",SNR,(double)errors/trials,(double)crc_misses/trials,(double)iterations/trials); if (((double)errors/trials) < 1e-2) done0=1; } if ((done0==1) && (done1==1) && (done2==1)) { printf("done\n"); break; } } return(0); }
int dlsch_encoding(unsigned char *a, LTE_DL_FRAME_PARMS *frame_parms, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, int frame, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *i_stats) { unsigned int G; unsigned int crc=1; unsigned short iind; unsigned char harq_pid = dlsch->current_harq_pid; unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; unsigned int Kr=0,Kr_bytes,r,r_offset=0; unsigned short m=dlsch->harq_processes[harq_pid]->mcs; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); A = dlsch->harq_processes[harq_pid]->TBS; //6228 // printf("Encoder: A: %d\n",A); mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe); // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet /* int i; printf("dlsch (tx): \n"); for (i=0;i<(A>>3);i++) printf("%02x.",a[i]); printf("\n"); */ // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; a[A>>3] = ((uint8_t*)&crc)[2]; a[1+(A>>3)] = ((uint8_t*)&crc)[1]; a[2+(A>>3)] = ((uint8_t*)&crc)[0]; // printf("CRC %x (A %d)\n",crc,A); dlsch->harq_processes[harq_pid]->B = A+24; // dlsch->harq_processes[harq_pid]->b = a; memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, &dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->Cplus, &dlsch->harq_processes[harq_pid]->Cminus, &dlsch->harq_processes[harq_pid]->Kplus, &dlsch->harq_processes[harq_pid]->Kminus, &dlsch->harq_processes[harq_pid]->F)<0) return(-1); for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; else Kr = dlsch->harq_processes[harq_pid]->Kplus; Kr_bytes = Kr>>3; // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) if (Kr_bytes<=64) iind = (Kr_bytes-5); else if (Kr_bytes <=128) iind = 59 + ((Kr_bytes-64)>>1); else if (Kr_bytes <= 256) iind = 91 + ((Kr_bytes-128)>>2); else if (Kr_bytes <= 768)
void rx_ulsch(LTE_eNB_COMMON *eNB_common_vars, LTE_eNB_ULSCH *eNB_ulsch_vars, LTE_DL_FRAME_PARMS *frame_parms, unsigned int subframe, unsigned char eNB_id, // this is the effective sector id LTE_eNB_ULSCH_t *ulsch, u8 cooperation_flag) { unsigned int l,i; int avgs; unsigned char log2_maxh,aarx; int avgs_0,avgs_1; unsigned log2_maxh_0,log2_maxh_1; // unsigned char harq_pid = ( ulsch->RRCConnRequest_flag== 0) ? subframe2harq_pid_tdd(frame_parms->tdd_config,subframe) : 0; unsigned char harq_pid = subframe2harq_pid(frame_parms,subframe); unsigned char Qm = get_Qm(ulsch->harq_processes[harq_pid]->mcs); unsigned short rx_power_correction; #ifdef DEBUG_ULSCH debug_msg("rx_ulsch: eNB_id %d, harq_pid %d, nb_rb %d first_rb %d, cooperation %d\n",eNB_id,harq_pid,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, cooperation_flag); #endif //DEBUG_ULSCH if ( (frame_parms->ofdm_symbol_size == 128) || (frame_parms->ofdm_symbol_size == 512) ) rx_power_correction = 2; else rx_power_correction = 1; for (l=0;l<frame_parms->symbols_per_tti-1;l++) { #ifdef DEBUG_ULSCH msg("rx_ulsch : symbol %d (first_rb %d,nb_rb %d), rxdataF %p, rxdataF_ext %p\n",l, ulsch->harq_processes[harq_pid]->first_rb, ulsch->harq_processes[harq_pid]->nb_rb, eNB_common_vars->rxdataF[eNB_id], eNB_ulsch_vars->rxdataF_ext[eNB_id]); #endif //DEBUG_ULSCH ulsch_extract_rbs_single(eNB_common_vars->rxdataF[eNB_id], eNB_ulsch_vars->rxdataF_ext[eNB_id], ulsch->harq_processes[harq_pid]->first_rb, ulsch->harq_processes[harq_pid]->nb_rb, l%(frame_parms->symbols_per_tti/2), l/(frame_parms->symbols_per_tti/2), frame_parms); lte_ul_channel_estimation(eNB_ulsch_vars->drs_ch_estimates[eNB_id], eNB_ulsch_vars->drs_ch_estimates_time[eNB_id], eNB_ulsch_vars->drs_ch_estimates_0[eNB_id], eNB_ulsch_vars->drs_ch_estimates_1[eNB_id], eNB_ulsch_vars->rxdataF_ext[eNB_id], frame_parms, l%(frame_parms->symbols_per_tti/2), l/(frame_parms->symbols_per_tti/2), ulsch->harq_processes[harq_pid]->nb_rb, ulsch->cyclicShift, cooperation_flag); ulsch_correct_ext(eNB_ulsch_vars->rxdataF_ext[eNB_id], eNB_ulsch_vars->rxdataF_ext2[eNB_id], l, frame_parms, ulsch->harq_processes[harq_pid]->nb_rb); if(cooperation_flag == 2) { for (i=0;i<frame_parms->nb_antennas_rx;i++){ eNB_ulsch_vars->ulsch_power_0[i] = signal_energy_nodc(eNB_ulsch_vars->drs_ch_estimates_0[eNB_id][i], ulsch->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction; eNB_ulsch_vars->ulsch_power_1[i] = signal_energy_nodc(eNB_ulsch_vars->drs_ch_estimates_1[eNB_id][i], ulsch->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction; } } else { for (i=0;i<frame_parms->nb_antennas_rx;i++) eNB_ulsch_vars->ulsch_power[i] = signal_energy_nodc(eNB_ulsch_vars->drs_ch_estimates[eNB_id][i], ulsch->harq_processes[harq_pid]->nb_rb*12)*rx_power_correction; } } if(cooperation_flag == 2) { ulsch_channel_level(eNB_ulsch_vars->drs_ch_estimates_0[eNB_id], frame_parms, avgU_0, ulsch->harq_processes[harq_pid]->nb_rb); // msg("[ULSCH] avg_0[0] %d\n",avgU_0[0]); avgs_0 = 0; for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) avgs_0 = cmax(avgs_0,avgU_0[(aarx<<1)]); log2_maxh_0 = 4+(log2_approx(avgs_0)/2); #ifdef DEBUG_ULSCH msg("[ULSCH] log2_maxh_0 = %d (%d,%d)\n",log2_maxh_0,avgU_0[0],avgs_0); #endif ulsch_channel_level(eNB_ulsch_vars->drs_ch_estimates_1[eNB_id], frame_parms, avgU_1, ulsch->harq_processes[harq_pid]->nb_rb); // msg("[ULSCH] avg_1[0] %d\n",avgU_1[0]); avgs_1 = 0; for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) avgs_1 = cmax(avgs_1,avgU_1[(aarx<<1)]); log2_maxh_1 = 4+(log2_approx(avgs_1)/2); #ifdef DEBUG_ULSCH msg("[ULSCH] log2_maxh_1 = %d (%d,%d)\n",log2_maxh_1,avgU_1[0],avgs_1); #endif } else { ulsch_channel_level(eNB_ulsch_vars->drs_ch_estimates[eNB_id], frame_parms, avgU, ulsch->harq_processes[harq_pid]->nb_rb); // msg("[ULSCH] avg[0] %d\n",avgU[0]); avgs = 0; for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) avgs = cmax(avgs,avgU[(aarx<<1)]); log2_maxh = 2+(log2_approx(avgs)/2); #ifdef DEBUG_ULSCH msg("[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs); #endif } for (l=0;l<frame_parms->symbols_per_tti-1;l++) { if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))|| // skip pilots ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) { l++; } if(cooperation_flag == 2) { ulsch_channel_compensation_alamouti(eNB_ulsch_vars->rxdataF_ext2[eNB_id], eNB_ulsch_vars->drs_ch_estimates_0[eNB_id], eNB_ulsch_vars->drs_ch_estimates_1[eNB_id], eNB_ulsch_vars->ul_ch_mag_0[eNB_id], eNB_ulsch_vars->ul_ch_magb_0[eNB_id], eNB_ulsch_vars->ul_ch_mag_1[eNB_id], eNB_ulsch_vars->ul_ch_magb_1[eNB_id], eNB_ulsch_vars->rxdataF_comp_0[eNB_id], eNB_ulsch_vars->rxdataF_comp_1[eNB_id], frame_parms, l, Qm, ulsch->harq_processes[harq_pid]->nb_rb, log2_maxh_0, log2_maxh_1); // log2_maxh+I0_shift ulsch_alamouti(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->rxdataF_comp_0[eNB_id], eNB_ulsch_vars->rxdataF_comp_1[eNB_id], eNB_ulsch_vars->ul_ch_mag[eNB_id], eNB_ulsch_vars->ul_ch_magb[eNB_id], eNB_ulsch_vars->ul_ch_mag_0[eNB_id], eNB_ulsch_vars->ul_ch_magb_0[eNB_id], eNB_ulsch_vars->ul_ch_mag_1[eNB_id], eNB_ulsch_vars->ul_ch_magb_1[eNB_id], l, ulsch->harq_processes[harq_pid]->nb_rb); } else { ulsch_channel_compensation(eNB_ulsch_vars->rxdataF_ext2[eNB_id], eNB_ulsch_vars->drs_ch_estimates[eNB_id], eNB_ulsch_vars->ul_ch_mag[eNB_id], eNB_ulsch_vars->ul_ch_magb[eNB_id], eNB_ulsch_vars->rxdataF_comp[eNB_id], frame_parms, l, Qm, ulsch->harq_processes[harq_pid]->nb_rb, log2_maxh); // log2_maxh+I0_shift } if (frame_parms->nb_antennas_rx > 1) ulsch_detection_mrc(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->ul_ch_mag[eNB_id], eNB_ulsch_vars->ul_ch_magb[eNB_id], l, ulsch->harq_processes[harq_pid]->nb_rb); #ifndef OFDMA_ULSCH freq_equalization(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->ul_ch_mag[eNB_id], eNB_ulsch_vars->ul_ch_magb[eNB_id], l, ulsch->harq_processes[harq_pid]->nb_rb*12, Qm); #endif } #ifndef OFDMA_ULSCH //#ifdef DEBUG_ULSCH // Inverse-Transform equalized outputs // msg("Doing IDFTs\n"); lte_idft(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id][0], ulsch->harq_processes[harq_pid]->nb_rb*12); // msg("Done\n"); //#endif //DEBUG_ULSCH #endif for (l=0;l<frame_parms->symbols_per_tti-1;l++) { if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))|| // skip pilots ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) { l++; } switch (Qm) { case 2 : ulsch_qpsk_llr(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->llr, l, ulsch->harq_processes[harq_pid]->nb_rb); break; case 4 : ulsch_16qam_llr(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->llr, eNB_ulsch_vars->ul_ch_mag[eNB_id], l,ulsch->harq_processes[harq_pid]->nb_rb); break; case 6 : ulsch_64qam_llr(frame_parms, eNB_ulsch_vars->rxdataF_comp[eNB_id], eNB_ulsch_vars->llr, eNB_ulsch_vars->ul_ch_mag[eNB_id], eNB_ulsch_vars->ul_ch_magb[eNB_id], l,ulsch->harq_processes[harq_pid]->nb_rb); break; default: #ifdef DEBUG_ULSCH msg("ulsch_demodulation.c (rx_ulsch): Unknown Qm!!!!\n"); #endif //DEBUG_ULSCH break; } } }
int main(int argc, char *argv[]) { int ret,ret2; unsigned int errors,uerrors,errors2,crc_misses,iterations,trials,trials2,block_length,errors3,trials3; double SNR,sigma,rate=.5; unsigned char qbits,mcs; char done0=0; char done1=1; char done2=1; unsigned short iind; unsigned int coded_bits; unsigned char NB_RB=25; int num_pdcch_symbols = 3; int subframe = 6; randominit(0); logInit(); lte_param_init(1,1,1,0,0,3); PHY_vars_eNB->dlsch_eNB[0][0] = new_eNB_dlsch(1,8,0); PHY_vars_UE->dlsch_ue[0][0] = new_ue_dlsch(1,8,0); PHY_vars_eNB->dlsch_eNB[0][1] = new_eNB_dlsch(1,8,0); PHY_vars_UE->dlsch_ue[0][1] = new_ue_dlsch(1,8,0); if (argc>1) mcs = atoi(argv[1]); else mcs = 0; printf("NB_RB %d\n",NB_RB); DLSCH_alloc_pdu2.rah = 0; DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; DLSCH_alloc_pdu2.TPC = 0; DLSCH_alloc_pdu2.dai = 0; DLSCH_alloc_pdu2.harq_pid = 0; DLSCH_alloc_pdu2.tb_swap = 0; DLSCH_alloc_pdu2.mcs1 = mcs; DLSCH_alloc_pdu2.ndi1 = 1; DLSCH_alloc_pdu2.rv1 = 0; if (argc>2) qbits = atoi(argv[2]); else qbits = 4; printf("Quantization bits %d\n",qbits); generate_eNB_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu2, 0x1234, format2_2A_M10PRB, PHY_vars_eNB->dlsch_eNB[0], &PHY_vars_eNB->lte_frame_parms, SI_RNTI, 0, P_RNTI, 0); //change this later generate_ue_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu2, C_RNTI, format2_2A_M10PRB, PHY_vars_UE->dlsch_ue[0], &PHY_vars_UE->lte_frame_parms, SI_RNTI, 0, P_RNTI); coded_bits = get_G(&PHY_vars_eNB->lte_frame_parms,NB_RB,PHY_vars_eNB->dlsch_eNB[0][0]->rb_alloc, get_Qm(mcs),num_pdcch_symbols,subframe); printf("Coded_bits (G) = %d\n",coded_bits); block_length = dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]>>3; printf("Block_length = %d bytes (%d bits, rate %f), mcs %d, I_TBS %d, NB_RB %d\n",block_length, dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1],(double)dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]/coded_bits, mcs,get_I_TBS(mcs),NB_RB); // Test Openair0 3GPP encoder /* test_encoder(block_length, f1f2mat[(block_length-5)*2], // f1 (see 36121-820, page 14) f1f2mat[((block_length-5)*2)+1], // f2 (see 36121-820, page 14) 3); */ // exit(0); for (SNR=-6;SNR<16;SNR+=.5) { // printf("\n\nSNR %f dB\n",SNR); sigma = pow(10.0,-.05*SNR); errors=0; crc_misses=0; errors2=0; errors3=0; iterations=0; if (done0 == 0) { ret = test_logmap8(PHY_vars_eNB->dlsch_eNB[0][0], PHY_vars_UE->dlsch_ue[0][0], coded_bits, NB_RB, sigma, // noise standard deviation qbits, block_length, // block length bytes NTRIALS, &errors, &trials, &uerrors, &crc_misses, &iterations, num_pdcch_symbols, subframe); if (ret>=0) // printf("ref: Errors %d (%f), Uerrors %d (%f), CRC Misses %d (%f), Avg iterations %f\n",errors,(double)errors/trials,uerrors,(double)uerrors/trials,crc_misses,(double)crc_misses/trials,(double)iterations/trials); printf("%f,%f,%f,%f\n",SNR,(double)errors/trials,(double)crc_misses/trials,(double)iterations/trials); if (((double)errors/trials) < 1e-2) done0=1; } /* if (done1 == 0) { printf("exmimo\n"); ret = test_logmapexmimo(rate, // code rate sigma, // noise standard deviation qbits, block_length, // block length bytes f1f2mat[iind*2], // f1 (see 36121-820, page 14) f1f2mat[(iind*2)+1], // f2 (see 36121-820, page 14) 3, NTRIALS, &errors3, &trials3); if (ret>=0) printf("exmimo : Errors %d (%f)\n",errors3,(double)errors3/trials3); if (((double)errors3/trials3) < 1e-3) done1=1; } if (done2 == 0) { printf("Viterbi ...\n"); ret2 = test_viterbi(sigma, 8*block_length, NTRIALS, &errors2, &trials2, rate); if (ret2>=0) printf("viterbi : Errors %d (%f)\n",errors2,(double)errors2/trials2); if (((double)errors2/trials2) < 1e-3) done2=1; } */ if ((done0==1) && (done1==1) && (done2==1)) { printf("done\n"); break; } } return(0); }
void configure(int argc, char **argv, int trials, short* iqr, short* iqi, int mmcs, int nrx, int num_bss){ mcs = mmcs; /**************************************************************************/ char c; int i, j,u; double snr0=-2.0,snr1,rate; double input_snr_step=.2,snr_int=30; double forgetting_factor=0.0; //in [0,1] 0 means a new channel every time, 1 means keep the same channel uint8_t extended_prefix_flag=0; int eNB_id = 0; int chMod = 0 ; int UE_id = 0; unsigned char l; int **txdata; unsigned char awgn_flag = 0 ; SCM_t channel_model=Rice1; unsigned int coded_bits_per_codeword,nsymb; uint8_t transmission_mode=1,n_tx=1; n_rx = nrx; FILE *input_fdUL=NULL; short input_val_str, input_val_str2; int n_frames=1000; int n_ch_rlz = 1; int abstx = 0; channel_desc_t *UE2eNB; int delay = 0; double maxDoppler = 0.0; uint8_t srs_flag = 0; uint8_t N_RB_DL=50,osf=1; uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; uint8_t tdd_config=3,frame_type=FDD; uint8_t N0=30; double tx_gain=1.0; double cpu_freq_GHz; int s; int dump_perf=0; int test_perf=0; int dump_table =0; double effective_rate=0.0; char channel_model_input[10]; uint8_t max_turbo_iterations=4; int nb_rb_set = 0; int sf; /***************************************************************************/ logInit(); while ((c = getopt (argc, argv, "hapZbm:n:Y:X:x:s:w:e:q:d:D:O:c:r:i:f:y:c:oA:C:R:g:N:l:S:T:QB:PI:L")) != -1) { switch (c) { case 'a': channel_model = AWGN; chMod = 1; break; case 'b': bundling_flag = 0; break; case 'd': delay = atoi(optarg); break; case 'D': maxDoppler = atoi(optarg); break; case 'm': mcs = atoi(optarg); break; case 'n': n_frames = atoi(optarg); break; case 'Y': n_ch_rlz = atoi(optarg); break; case 'X': abstx= atoi(optarg); break; case 'g': sprintf(channel_model_input,optarg,10); switch((char)*optarg) { case 'A': channel_model=SCM_A; chMod = 2; break; case 'B': channel_model=SCM_B; chMod = 3; break; case 'C': channel_model=SCM_C; chMod = 4; break; case 'D': channel_model=SCM_D; chMod = 5; break; case 'E': channel_model=EPA; chMod = 6; break; case 'F': channel_model=EVA; chMod = 7; break; case 'G': channel_model=ETU; chMod = 8; break; case 'H': channel_model=Rayleigh8; chMod = 9; break; case 'I': channel_model=Rayleigh1; chMod = 10; break; case 'J': channel_model=Rayleigh1_corr; chMod = 11; break; case 'K': channel_model=Rayleigh1_anticorr; chMod = 12; break; case 'L': channel_model=Rice8; chMod = 13; break; case 'M': channel_model=Rice1; chMod = 14; break; case 'N': channel_model=AWGN; chMod = 1; break; default: msg("Unsupported channel model!\n"); exit(-1); break; } break; case 's': snr0 = atof(optarg); break; case 'w': snr_int = atof(optarg); break; case 'e': input_snr_step= atof(optarg); break; case 'x': transmission_mode=atoi(optarg); if ((transmission_mode!=1) && (transmission_mode!=2)) { msg("Unsupported transmission mode %d\n",transmission_mode); exit(-1); } if (transmission_mode>1) { n_tx = 1; } break; case 'y': n_rx = atoi(optarg); break; case 'S': subframe = atoi(optarg); break; case 'T': tdd_config=atoi(optarg); frame_type=TDD; break; case 'p': extended_prefix_flag=1; break; case 'r': nb_rb = atoi(optarg); nb_rb_set = 1; break; case 'f': first_rb = atoi(optarg); break; case 'c': cyclic_shift = atoi(optarg); break; case 'N': N0 = atoi(optarg); break; case 'o': srs_flag = 1; break; case 'i': input_fdUL = fopen(optarg,"r"); printf("Reading in %s (%p)\n",optarg,input_fdUL); if (input_fdUL == (FILE*)NULL) { printf("Unknown file %s\n",optarg); exit(-1); } // input_file=1; break; case 'A': beta_ACK = atoi(optarg); if (beta_ACK>15) { printf("beta_ack must be in (0..15)\n"); exit(-1); } break; case 'C': beta_CQI = atoi(optarg); if ((beta_CQI>15)||(beta_CQI<2)) { printf("beta_cqi must be in (2..15)\n"); exit(-1); } break; case 'R': beta_RI = atoi(optarg); if ((beta_RI>15)||(beta_RI<2)) { printf("beta_ri must be in (0..13)\n"); exit(-1); } break; case 'Q': cqi_flag=1; break; case 'B': N_RB_DL=atoi(optarg); break; case 'P': dump_perf=1; opp_enabled=1; break; case 'O': test_perf=atoi(optarg); //print_perf =1; break; case 'L': llr8_flag=1; break; case 'I': max_turbo_iterations=atoi(optarg); break; case 'Z': dump_table = 1; break; case 'h': default: printf("%s -h(elp) -a(wgn on) -m mcs -n n_frames -s snr0 -t delay_spread -p (extended prefix on) -r nb_rb -f first_rb -c cyclic_shift -o (srs on) -g channel_model [A:M] Use 3GPP 25.814 SCM-A/B/C/D('A','B','C','D') or 36-101 EPA('E'), EVA ('F'),ETU('G') models (ignores delay spread and Ricean factor), Rayghleigh8 ('H'), Rayleigh1('I'), Rayleigh1_corr('J'), Rayleigh1_anticorr ('K'), Rice8('L'), Rice1('M'), -d Channel delay, -D maximum Doppler shift \n", argv[0]); exit(1); break; } } lte_param_init(1,n_rx,1,extended_prefix_flag,N_RB_DL,frame_type,tdd_config,osf, num_bss); int loop = 0; for (loop = 0; loop < num_bss; loop++){ if (nb_rb_set == 0){ nb_rb = PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL; } // frame_parms = &PHY_vars_eNB[loop]->lte_frame_parms; txdata = PHY_vars_UE[loop]->lte_ue_common_vars.txdata; nsymb = (PHY_vars_eNB[loop]->lte_frame_parms.Ncp == 0) ? 14 : 12; coded_bits_per_codeword = nb_rb * (12 * get_Qm(mcs)) * nsymb; rate = (double)2*dlsch_tbs25[get_I_TBS(mcs)][25-1]/(coded_bits_per_codeword); PHY_vars_UE[loop]->lte_ue_pdcch_vars[0]->crnti = 14; PHY_vars_UE[loop]->lte_frame_parms.soundingrs_ul_config_common.srs_BandwidthConfig = 2; PHY_vars_UE[loop]->lte_frame_parms.soundingrs_ul_config_common.srs_SubframeConfig = 7; PHY_vars_UE[loop]->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth = 0; PHY_vars_UE[loop]->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = 0; PHY_vars_UE[loop]->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition = 0; PHY_vars_eNB[loop]->lte_frame_parms.soundingrs_ul_config_common.srs_BandwidthConfig = 2; PHY_vars_eNB[loop]->lte_frame_parms.soundingrs_ul_config_common.srs_SubframeConfig = 7; PHY_vars_eNB[loop]->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex = 1; PHY_vars_eNB[loop]->soundingrs_ul_config_dedicated[UE_id].srs_Bandwidth = 0; PHY_vars_eNB[loop]->soundingrs_ul_config_dedicated[UE_id].transmissionComb = 0; PHY_vars_eNB[loop]->soundingrs_ul_config_dedicated[UE_id].freqDomainPosition = 0; PHY_vars_eNB[loop]->cooperation_flag = cooperation_flag; // PHY_vars_eNB[loop]->eNB_UE_stats[0].SRS_parameters = PHY_vars_UE[loop]->SRS_parameters; PHY_vars_eNB[loop]->pusch_config_dedicated[UE_id].betaOffset_ACK_Index = beta_ACK; PHY_vars_eNB[loop]->pusch_config_dedicated[UE_id].betaOffset_RI_Index = beta_RI; PHY_vars_eNB[loop]->pusch_config_dedicated[UE_id].betaOffset_CQI_Index = beta_CQI; PHY_vars_UE[loop]->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = beta_ACK; PHY_vars_UE[loop]->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = beta_RI; PHY_vars_UE[loop]->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = beta_CQI; PHY_vars_UE[loop]->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled = 1; UE2eNB = new_channel_desc_scm(PHY_vars_eNB[loop]->lte_frame_parms.nb_antennas_tx, PHY_vars_UE[loop]->lte_frame_parms.nb_antennas_rx, channel_model, BW, forgetting_factor, delay, 0); // set Doppler UE2eNB->max_Doppler = maxDoppler; // NN: N_RB_UL has to be defined in ulsim PHY_vars_eNB[loop]->ulsch_eNB[0] = new_eNB_ulsch(8,max_turbo_iterations,N_RB_DL,0); PHY_vars_UE[loop]->ulsch_ue[0] = new_ue_ulsch(8,N_RB_DL,0); // Create transport channel structures for 2 transport blocks (MIMO) for (i=0; i<2; i++) { PHY_vars_eNB[loop]->dlsch_eNB[0][i] = new_eNB_dlsch(1,8,N_RB_DL,0); PHY_vars_UE[loop]->dlsch_ue[0][i] = new_ue_dlsch(1,8,MAX_TURBO_ITERATIONS,N_RB_DL,0); if (!PHY_vars_eNB[loop]->dlsch_eNB[0][i]) { printf("Can't get eNB dlsch structures\n"); exit(-1); } if (!PHY_vars_UE[loop]->dlsch_ue[0][i]) { printf("Can't get ue dlsch structures\n"); exit(-1); } PHY_vars_eNB[loop]->dlsch_eNB[0][i]->rnti = 14; PHY_vars_UE[loop]->dlsch_ue[0][i]->rnti = 14; } switch (PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL) { case 6: break; case 50: if (PHY_vars_eNB[loop]->lte_frame_parms.frame_type == TDD) { ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->type = 0; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc = computeRIV(PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL,((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->cqi_req = cqi_flag&1; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->cshift = 0; ((DCI0_10MHz_TDD_1_6_t*)&UL_alloc_pdu)->dai = 1; } else { ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->type = 0; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc = computeRIV(PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL,first_rb,nb_rb);// 12 RBs from position 8 printf("nb_rb %d/%d, rballoc %d (dci %x)\n",nb_rb,PHY_vars_eNB[loop]->lte_frame_parms.N_RB_UL,((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->rballoc,*(uint32_t *)&UL_alloc_pdu); ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->mcs = mcs; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->ndi = 1; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->TPC = 0; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->cqi_req = cqi_flag&1; ((DCI0_10MHz_FDD_t*)&UL_alloc_pdu)->cshift = 0; } break; default: break; } PHY_vars_UE[loop]->PHY_measurements.rank[0] = 0; PHY_vars_UE[loop]->transmission_mode[0] = 2; PHY_vars_UE[loop]->pucch_config_dedicated[0].tdd_AckNackFeedbackMode = bundling_flag == 1 ? bundling : multiplexing; PHY_vars_eNB[loop]->transmission_mode[0] = 2; PHY_vars_eNB[loop]->pucch_config_dedicated[0].tdd_AckNackFeedbackMode = bundling_flag == 1 ? bundling : multiplexing; PHY_vars_UE[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 1; PHY_vars_eNB[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 1; PHY_vars_UE[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; PHY_vars_eNB[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; PHY_vars_UE[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; PHY_vars_eNB[loop]->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; PHY_vars_UE[loop]->frame_tx=1; for (sf=0; sf<10; sf++) { PHY_vars_eNB[loop]->proc[sf].frame_tx=1; PHY_vars_eNB[loop]->proc[sf].subframe_tx=sf; PHY_vars_eNB[loop]->proc[sf].frame_rx=1; PHY_vars_eNB[loop]->proc[sf].subframe_rx=sf; } msg("Init UL hopping UE\n"); init_ul_hopping(&PHY_vars_UE[loop]->lte_frame_parms); msg("Init UL hopping eNB\n"); init_ul_hopping(&PHY_vars_eNB[loop]->lte_frame_parms); PHY_vars_eNB[loop]->proc[subframe].frame_rx = PHY_vars_UE[loop]->frame_tx; if (ul_subframe2pdcch_alloc_subframe(&PHY_vars_eNB[loop]->lte_frame_parms,subframe) > subframe) // allocation was in previous frame PHY_vars_eNB[loop]->proc[ul_subframe2pdcch_alloc_subframe(&PHY_vars_eNB[loop]->lte_frame_parms,subframe)].frame_tx = (PHY_vars_UE[loop]->frame_tx-1)&1023; PHY_vars_UE[loop]->dlsch_ue[0][0]->harq_ack[ul_subframe2pdcch_alloc_subframe(&PHY_vars_eNB[loop]->lte_frame_parms,subframe)].send_harq_status = 1; PHY_vars_UE[loop]->frame_tx = (PHY_vars_UE[loop]->frame_tx-1)&1023; printf("**********************here=1**************************\n"); generate_ue_ulsch_params_from_dci((void *)&UL_alloc_pdu, 14, ul_subframe2pdcch_alloc_subframe(&PHY_vars_UE[loop]->lte_frame_parms,subframe), format0, PHY_vars_UE[loop], SI_RNTI, 0, P_RNTI, CBA_RNTI, 0, srs_flag); if (PHY_vars_eNB[loop]->ulsch_eNB[0] != NULL) generate_eNB_ulsch_params_from_dci((void *)&UL_alloc_pdu, 14, ul_subframe2pdcch_alloc_subframe(&PHY_vars_eNB[loop]->lte_frame_parms,subframe), format0, 0, PHY_vars_eNB[loop], SI_RNTI, 0, P_RNTI, CBA_RNTI, srs_flag); PHY_vars_UE[loop]->frame_tx = (PHY_vars_UE[loop]->frame_tx+1)&1023; printf("**********************here=2**************************\n"); int round = 0; harq_pid = subframe2harq_pid(&PHY_vars_UE[loop]->lte_frame_parms,PHY_vars_UE[loop]->frame_tx,subframe); // fflush(stdout); PHY_vars_eNB[loop]->ulsch_eNB[0]->harq_processes[harq_pid]->round=round; PHY_vars_UE[loop]->ulsch_ue[0]->harq_processes[harq_pid]->round=round; PHY_vars_eNB[loop]->ulsch_eNB[0]->harq_processes[harq_pid]->rvidx = round>>1; PHY_vars_UE[loop]->ulsch_ue[0]->harq_processes[harq_pid]->rvidx = round>>1; ///////////////////// int aa = 0; int ii=0; for(ii=0; ii< PHY_vars_eNB[loop]->lte_frame_parms.samples_per_tti; ii++){ for (aa=0; aa < n_rx; aa++){ ((short*) &PHY_vars_eNB[loop]->lte_eNB_common_vars.rxdata[0][aa][PHY_vars_eNB[loop]->lte_frame_parms.samples_per_tti*subframe])[2*ii] = iqr[ii]; ((short*) &PHY_vars_eNB[loop]->lte_eNB_common_vars.rxdata[0][aa][PHY_vars_eNB[loop]->lte_frame_parms.samples_per_tti*subframe])[2*ii +1] = iqi[ii]; } } printf("Loaded %d IQ samples\n", PHY_vars_eNB[loop]->lte_frame_parms.samples_per_tti); lte_eNB_I0_measurements(PHY_vars_eNB[loop], 0, 1); PHY_vars_eNB[loop]->ulsch_eNB[0]->cyclicShift = cyclic_shift;// cyclic shift for DMRS remove_7_5_kHz(PHY_vars_eNB[loop],subframe<<1); remove_7_5_kHz(PHY_vars_eNB[loop],1+(subframe<<1)); } }
memcpy(phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->b, a, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); LOG_D(PHY, "[eNB %d] dlsch_encoding_emul pmch , tbs is %d \n", phy_vars_eNB->Mod_id, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); memcpy(&eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].transport_blocks[eNB_transport_info_TB_index[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]], a, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); eNB_transport_info_TB_index[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]+= phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3;//=eNB_transport_info[phy_vars_eNB->Mod_id].tbs[0]; } else { G = get_G(&phy_vars_eNB->lte_frame_parms, phy_vars_eNB->lte_frame_parms.N_RB_DL, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->rb_alloc, get_Qm(phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->mcs),1, 2,phy_vars_eNB->proc[sched_subframe].frame_tx,subframe); generate_mbsfn_pilot(phy_vars_eNB, phy_vars_eNB->lte_eNB_common_vars.txdataF[0], AMP, subframe); if (dlsch_encoding(a, &phy_vars_eNB->lte_frame_parms, 1, phy_vars_eNB->dlsch_eNB_MCH, phy_vars_eNB->proc[sched_subframe].frame_tx, subframe, &phy_vars_eNB->dlsch_rate_matching_stats, &phy_vars_eNB->dlsch_turbo_encoding_stats,
int dlsch_encoding(unsigned char *a, LTE_DL_FRAME_PARMS *frame_parms, u8 num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, u8 subframe) { unsigned short offset; unsigned int G; unsigned int crc=1; unsigned short iind; unsigned short nb_rb = dlsch->nb_rb; unsigned char harq_pid = dlsch->current_harq_pid; unsigned int A; unsigned char mod_order; unsigned int Kr,Kr_bytes,r,r_offset=0; A = dlsch->harq_processes[harq_pid]->TBS; mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); G = get_G(frame_parms,nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,subframe); if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet /* printf("dlsch (tx): \n"); for (i=0;i<4;i++) printf("%x ",a[i]); printf("\n"); */ // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; a[A>>3] = ((u8*)&crc)[2]; a[1+(A>>3)] = ((u8*)&crc)[1]; a[2+(A>>3)] = ((u8*)&crc)[0]; dlsch->harq_processes[harq_pid]->B = A+24; dlsch->harq_processes[harq_pid]->b = a; lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, &dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->Cplus, &dlsch->harq_processes[harq_pid]->Cminus, &dlsch->harq_processes[harq_pid]->Kplus, &dlsch->harq_processes[harq_pid]->Kminus, &dlsch->harq_processes[harq_pid]->F); for (r=0;r<dlsch->harq_processes[harq_pid]->C;r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; else Kr = dlsch->harq_processes[harq_pid]->Kplus; Kr_bytes = Kr>>3; // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) if (Kr_bytes<=64) iind = (Kr_bytes-5); else if (Kr_bytes <=128) iind = 59 + ((Kr_bytes-64)>>1); else if (Kr_bytes <= 256) iind = 91 + ((Kr_bytes-128)>>2); else if (Kr_bytes <= 768)
/** RX_PDSCH Decoding Thread */ static void * rx_pdsch_thread(void *param) { //unsigned long cpuid; uint8_t rx_pdsch_thread_index = 0; uint8_t dlsch_thread_index = 0; uint8_t pilot1,pilot2,pilot3,harq_pid,subframe; // uint8_t last_slot; uint8_t dual_stream_UE = 0; uint8_t i_mod = 0; RTIME time_in,time_out; #ifdef RTAI RT_TASK *task; #endif int m,eNB_id = 0; int eNB_id_i = 1; PHY_VARS_UE *UE = PHY_vars_UE_g[0]; #ifdef RTAI task = rt_task_init_schmod(nam2num("RX_PDSCH_THREAD"), 0, 0, 0, SCHED_FIFO, 0xF); if (task==NULL) { LOG_E(PHY,"[SCHED][RX_PDSCH] Problem starting rx_pdsch thread!!!!\n"); return 0; } else { LOG_I(PHY,"[SCHED][RX_PDSCH] rx_pdsch_thread started for with id %p\n",task); } #endif mlockall(MCL_CURRENT | MCL_FUTURE); //rt_set_runnable_on_cpuid(task,1); //cpuid = rtai_cpuid(); #ifdef HARD_RT rt_make_hard_real_time(); #endif if (UE->lte_frame_parms.Ncp == 0) { // normal prefix pilot1 = 4; pilot2 = 7; pilot3 = 11; } else { // extended prefix pilot1 = 3; pilot2 = 6; pilot3 = 9; } while (!oai_exit){ vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_THREAD, 0); if (pthread_mutex_lock(&rx_pdsch_mutex) != 0) { LOG_E(PHY,"[SCHED][RX_PDSCH] error locking mutex.\n"); } else { while (rx_pdsch_instance_cnt < 0) { pthread_cond_wait(&rx_pdsch_cond,&rx_pdsch_mutex); } if (pthread_mutex_unlock(&rx_pdsch_mutex) != 0) { LOG_E(PHY,"[SCHED][RX_PDSCH] error unlocking mutex.\n"); } } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_THREAD, 1); // last_slot = rx_pdsch_slot; subframe = UE->slot_rx>>1; // Important! assumption that PDCCH procedure of next SF is not called yet harq_pid = UE->dlsch_ue[eNB_id][0]->current_harq_pid; UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->G = get_G(&UE->lte_frame_parms, UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->nb_rb, UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rb_alloc, get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs), UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->Nl, UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols, UE->frame_rx,subframe); if ((UE->transmission_mode[eNB_id] == 5) && (UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off==0) && (openair_daq_vars.use_ia_receiver > 0)) { dual_stream_UE = 1; eNB_id_i = UE->n_connected_eNB; if (openair_daq_vars.use_ia_receiver == 2) { i_mod = get_Qm(((UE->frame_rx%1024)/3)%28); } else { i_mod = get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs); } } else { dual_stream_UE = 0; eNB_id_i = eNB_id+1; i_mod = 0; } if (oai_exit) break; LOG_D(PHY,"[SCHED][RX_PDSCH] Frame %d, slot %d: Calling rx_pdsch_decoding with harq_pid %d\n",UE->frame_rx,UE->slot_rx,harq_pid); time_in = rt_get_time_ns(); // Check if we are in even or odd slot if (UE->slot_rx%2) { // odd slots // measure time //time0 = rt_get_time_ns(); // rt_printk("[SCHED][RX_PDSCH][before rx_pdsch] Frame %d, slot %d, time %llu\n",UE->frame,last_slot,rt_get_time_ns()); for (m=pilot2;m<UE->lte_frame_parms.symbols_per_tti;m++) { rx_pdsch(UE, PDSCH, eNB_id, eNB_id_i, subframe, m, 0, dual_stream_UE, i_mod, harq_pid); } // time1 = rt_get_time_ns(); // rt_printk("[SCHED][RX_PDSCH] Frame %d, slot %d, start %llu, end %llu, proc time: %llu ns\n",UE->frame_rx,last_slot,time0,time1,(time1-time0)); dlsch_thread_index = harq_pid; if (pthread_mutex_lock (&dlsch_mutex[dlsch_thread_index]) != 0) { // Signal MAC_PHY Scheduler LOG_E(PHY,"[UE %d] ERROR pthread_mutex_lock\n",UE->Mod_id); // lock before accessing shared resource // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } dlsch_instance_cnt[dlsch_thread_index]++; dlsch_subframe[dlsch_thread_index] = subframe; pthread_mutex_unlock (&dlsch_mutex[dlsch_thread_index]); if (dlsch_instance_cnt[dlsch_thread_index] == 0) { if (pthread_cond_signal(&dlsch_cond[dlsch_thread_index]) != 0) { LOG_E(PHY,"[UE %d] ERROR pthread_cond_signal for dlsch_cond[%d]\n",UE->Mod_id,dlsch_thread_index); // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } } else { LOG_W(PHY,"[UE %d] DLSCH thread for dlsch_thread_index %d busy!!!\n",UE->Mod_id,dlsch_thread_index); // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } } else { // even slots for (m=UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols;m<pilot2;m++) { rx_pdsch(UE, PDSCH, eNB_id, eNB_id_i, subframe, m, (m==UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols)?1:0, // first_symbol_flag dual_stream_UE, i_mod, harq_pid); } } time_out = rt_get_time_ns(); if (pthread_mutex_lock(&rx_pdsch_mutex) != 0) { msg("[openair][SCHED][RX_PDSCH] error locking mutex.\n"); } else { rx_pdsch_instance_cnt--; if (pthread_mutex_unlock(&rx_pdsch_mutex) != 0) { msg("[openair][SCHED][RX_PDSCH] error unlocking mutex.\n"); } } } #ifdef HARD_RT rt_make_soft_real_time(); #endif LOG_D(PHY,"[openair][SCHED][RX_PDSCH] RX_PDSCH thread exiting\n"); return 0; }
int main(int argc, char **argv) { char c; int i,aa,s,ind,Kr,Kr_bytes;; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1,SNRmeas; //int **txdataF, **txdata; int **txdata; #ifdef IFFT_FPGA int **txdataF2; #endif //LTE_DL_FRAME_PARMS *frame_parms = (LTE_DL_FRAME_PARMS *)malloc(sizeof(LTE_DL_FRAME_PARMS)); //LTE_UE_COMMON *lte_ue_common_vars = (LTE_UE_COMMON *)malloc(sizeof(LTE_UE_COMMON)); double **s_re,**s_im,**r_re,**r_im; double amps[8] = {0.3868472 , 0.3094778 , 0.1547389 , 0.0773694 , 0.0386847 , 0.0193424 , 0.0096712 , 0.0038685}; double aoa=.03,ricean_factor=1; //0.0000005; int channel_length; struct complex **ch; int eNb_id = 0, eNb_id_i = 1; unsigned char mcs,dual_stream_UE = 0; unsigned short NB_RB=conv_nprb(0,DLSCH_RB_ALLOC); unsigned char Ns,l,m; unsigned char *input_data,*decoded_output; unsigned char *input_buffer; unsigned short input_buffer_length; unsigned int ret; unsigned int coded_bits_per_codeword,nsymb,dci_cnt; unsigned int tx_lev,tx_lev_dB,trials,errs=0,dci_errors=0,dlsch_active=0,num_layers; int re_allocated; FILE *bler_fd; FILE *csv_fd; char bler_fname[20]; char csv_fname[20]; unsigned char pbch_pdu[6]; DCI_ALLOC_t dci_alloc[8],dci_alloc_rx[8]; FILE *rx_frame_file; int result; int n_frames; int cnt=0; int rx_lev_data_sym; int rx_lev_null_sym; int rx_snr_dB; void *data; int ii; int bler; double blerr; int ch_realization; channel_length = (int) 11+2*BW*Td; lte_param_init(1,1,1); num_layers = 1; //int cont=0; // default parameters //for (cont =0;cont<29;cont++){ mcs = 0; n_frames = 1000; snr0 = 2; //if(snr0>0) // snr0 = 0; while ((c = getopt (argc, argv, "hm:n:s:")) != -1) { switch (c) { case 'h': printf("%s -h(elp) -m mcs -n n_frames -s snr0\n",argv[0]); exit(1); case 'm': mcs = atoi(optarg); break; case 'n': n_frames = atoi(optarg); break; case 's': snr0 = atoi(optarg); break; default: printf("%s -h(elp) -m mcs -n n_frames -s snr0\n",argv[0]); exit (-1); break; } } printf("Setting mcs = %d\n",mcs); printf("NPRB = %d\n",NB_RB); printf("n_frames = %d\n",n_frames); /* snr0 = -7 + mcs; if(snr0>0) snr0 = ; */ snr1 = snr0+20; printf("SNR0 %f, SNR1 %f\n",snr0,snr1); /* txdataF = (int **)malloc16(2*sizeof(int*)); txdataF[0] = (int *)malloc16(FRAME_LENGTH_BYTES); txdataF[1] = (int *)malloc16(FRAME_LENGTH_BYTES); txdata = (int **)malloc16(2*sizeof(int*)); txdata[0] = (int *)malloc16(FRAME_LENGTH_BYTES); txdata[1] = (int *)malloc16(FRAME_LENGTH_BYTES); */ #ifdef IFFT_FPGA txdata = (int **)malloc16(2*sizeof(int*)); txdata[0] = (int *)malloc16(FRAME_LENGTH_BYTES); txdata[1] = (int *)malloc16(FRAME_LENGTH_BYTES); bzero(txdata[0],FRAME_LENGTH_BYTES); bzero(txdata[1],FRAME_LENGTH_BYTES); txdataF2 = (int **)malloc16(2*sizeof(int*)); txdataF2[0] = (int *)malloc16(FRAME_LENGTH_BYTES_NO_PREFIX); txdataF2[1] = (int *)malloc16(FRAME_LENGTH_BYTES_NO_PREFIX); bzero(txdataF2[0],FRAME_LENGTH_BYTES_NO_PREFIX); bzero(txdataF2[1],FRAME_LENGTH_BYTES_NO_PREFIX); #else txdata = PHY_vars_eNb->lte_eNB_common_vars.txdata[eNb_id]; #endif s_re = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*)); r_re = malloc(2*sizeof(double*)); r_im = malloc(2*sizeof(double*)); nsymb = (lte_frame_parms->Ncp == 0) ? 14 : 12; coded_bits_per_codeword = NB_RB * (12 * get_Qm(mcs)) * (lte_frame_parms->num_dlsch_symbols); printf("Rate = %f (mod %d)\n",(((double)dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1])*3/4)/coded_bits_per_codeword, get_Qm(mcs)); sprintf(bler_fname,"bler_%d.m",mcs); bler_fd = fopen(bler_fname,"w"); fprintf(bler_fd,"bler = ["); // CSV file sprintf(csv_fname,"data_out%d.m",mcs); csv_fd = fopen(csv_fname,"w"); fprintf(csv_fd,"data_all=["); for (i=0;i<2;i++) { s_re[i] = malloc(FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double)); s_im[i] = malloc(FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double)); r_re[i] = malloc(FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double)); r_im[i] = malloc(FRAME_LENGTH_COMPLEX_SAMPLES*sizeof(double)); } PHY_vars_UE->lte_ue_pdcch_vars[0]->crnti = 0x1234; // Fill in UL_alloc UL_alloc_pdu.type = 0; UL_alloc_pdu.hopping = 0; UL_alloc_pdu.rballoc = UL_RB_ALLOC; UL_alloc_pdu.mcs = 1; UL_alloc_pdu.ndi = 1; UL_alloc_pdu.TPC = 0; UL_alloc_pdu.cqi_req = 1; CCCH_alloc_pdu.type = 0; CCCH_alloc_pdu.vrb_type = 0; CCCH_alloc_pdu.rballoc = CCCH_RB_ALLOC; CCCH_alloc_pdu.ndi = 1; CCCH_alloc_pdu.mcs = 1; CCCH_alloc_pdu.harq_pid = 0; DLSCH_alloc_pdu2.rah = 0; DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; DLSCH_alloc_pdu2.TPC = 0; DLSCH_alloc_pdu2.dai = 0; DLSCH_alloc_pdu2.harq_pid = 0; DLSCH_alloc_pdu2.tb_swap = 0; DLSCH_alloc_pdu2.mcs1 = mcs; DLSCH_alloc_pdu2.ndi1 = 1; DLSCH_alloc_pdu2.rv1 = 0; // Forget second codeword DLSCH_alloc_pdu2.tpmi = 5 ; // precoding // Create transport channel structures for SI pdus PHY_vars_eNb->dlsch_eNb_cntl = new_eNb_dlsch(1,1); PHY_vars_UE->dlsch_ue_cntl = new_ue_dlsch(1,1); // Create transport channel structures for 2 transport blocks (MIMO) PHY_vars_eNb->dlsch_eNb = (LTE_eNb_DLSCH_t**) malloc16(2*sizeof(LTE_eNb_DLSCH_t*)); PHY_vars_UE->dlsch_ue = (LTE_UE_DLSCH_t**) malloc16(2*sizeof(LTE_UE_DLSCH_t*)); for (i=0;i<2;i++) { PHY_vars_eNb->dlsch_eNb[i] = new_eNb_dlsch(1,8); PHY_vars_UE->dlsch_ue[i] = new_ue_dlsch(1,8); if (!PHY_vars_eNb->dlsch_eNb[i]) { printf("Can't get eNb dlsch structures\n"); exit(-1); } if (!PHY_vars_UE->dlsch_ue[i]) { printf("Can't get ue dlsch structures\n"); exit(-1); } } if (DLSCH_alloc_pdu2.tpmi == 5) { PHY_vars_eNb->dlsch_eNb[0]->pmi_alloc = (unsigned short)(taus()&0xffff); PHY_vars_UE->dlsch_ue[0]->pmi_alloc = PHY_vars_eNb->dlsch_eNb[0]->pmi_alloc; PHY_vars_eNb->eNB_UE_stats[0].DL_pmi_single[0] = PHY_vars_eNb->dlsch_eNb[0]->pmi_alloc; } generate_eNb_dlsch_params_from_dci(0, &DLSCH_alloc_pdu2, 0x1234, format2_2A_M10PRB, PHY_vars_eNb->dlsch_eNb, lte_frame_parms, SI_RNTI, RA_RNTI, P_RNTI, 0); //change this later /* generate_eNb_dlsch_params_from_dci(0, &CCCH_alloc_pdu, SI_RNTI, format1A, &dlsch_eNb_cntl, lte_frame_parms, SI_RNTI, RA_RNTI, P_RNTI); */ // input_data = (unsigned char*) malloc(block_length/8); // decoded_output = (unsigned char*) malloc(block_length/8); // DCI memcpy(&dci_alloc[0].dci_pdu[0],&DLSCH_alloc_pdu2,sizeof(DCI2_5MHz_2A_M10PRB_TDD_t)); dci_alloc[0].dci_length = sizeof_DCI2_5MHz_2A_M10PRB_TDD_t; dci_alloc[0].L = 3; dci_alloc[0].rnti = 0x1234; /* memcpy(&dci_alloc[0].dci_pdu[0],&CCCH_alloc_pdu,sizeof(DCI1A_5MHz_TDD_1_6_t)); dci_alloc[0].dci_length = sizeof_DCI1A_5MHz_TDD_1_6_t; dci_alloc[0].L = 3; dci_alloc[0].rnti = SI_RNTI; */ memcpy(&dci_alloc[1].dci_pdu[0],&UL_alloc_pdu,sizeof(DCI0_5MHz_TDD0_t)); dci_alloc[1].dci_length = sizeof_DCI0_5MHz_TDD_0_t; dci_alloc[1].L = 3; dci_alloc[1].rnti = 0x1234; // DLSCH if (1) { input_buffer_length = PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->TBS/8; printf("dlsch0: TBS %d\n",PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->TBS); printf("Input buffer size %d bytes\n",input_buffer_length); input_buffer = (unsigned char *)malloc(input_buffer_length+4); for (i=0;i<input_buffer_length;i++) input_buffer[i]= (unsigned char)(taus()&0xff); dlsch_encoding(input_buffer, lte_frame_parms, PHY_vars_eNb->dlsch_eNb[0]); #ifdef OUTPUT_DEBUG for (s=0;s<PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->C;s++) { if (s<PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->Cminus) Kr = PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->Kminus; else Kr = PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->Kplus; Kr_bytes = Kr>>3; for (i=0;i<Kr_bytes;i++) printf("%d : (%x)\n",i,PHY_vars_eNb->dlsch_eNb[0]->harq_processes[0]->c[s][i]); } #endif re_allocated = dlsch_modulation(PHY_vars_eNb->lte_eNB_common_vars.txdataF[eNb_id], 1024, 0, &PHY_vars_eNb->lte_frame_parms, PHY_vars_eNb->dlsch_eNb[0]); printf("RB count %d (%d,%d)\n",re_allocated,re_allocated/lte_frame_parms->num_dlsch_symbols/12,lte_frame_parms->num_dlsch_symbols); if (num_layers>1) re_allocated = dlsch_modulation(PHY_vars_eNb->lte_eNB_common_vars.txdataF[eNb_id], 1024, 0, &PHY_vars_eNb->lte_frame_parms, PHY_vars_eNb->dlsch_eNb[1]); }
void mexFunction( int mlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { /* Declare */ short *dlsch_llr; unsigned char mcs; unsigned int *ret; unsigned char mod_order; unsigned char num_pdcch_symbols; unsigned char harq_pid; unsigned char subframe; unsigned char Kmimo; unsigned char Mdlharq; unsigned char abstraction_flag; LTE_UE_DLSCH_t* dlsch; LTE_DL_FRAME_PARMS *frame_parms; PHY_VARS_UE *phy_vars_ue; extern int *pi2tab16[188],*pi5tab16[188],*pi4tab16[188],*pi6tab16[188]; unsigned long *ptr_td; //Specific Modification for 64bit int *tmp[1]; /* Allocate input */ dlsch_llr = (short*) mxGetData(prhs[0]); /* Create new dlsch */ Kmimo = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Kmimo")); Mdlharq = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Mdlharq")); abstraction_flag = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"abstraction_flag")); mcs = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"mcs")); #ifdef DEBUG_DLSCH_DECODING mexPrintf("Kmimo %d\n",Kmimo); mexPrintf("Mdlharq %d\n",Mdlharq); mexPrintf("abstraction_flag %d\n",abstraction_flag); mexPrintf("mcs %d\n",mcs); #endif /* Create new dlsch */ dlsch = new_ue_dlsch(Kmimo,Mdlharq,8,25,abstraction_flag); // Init CRC tables crcTableInit(); // init_td(); // copy the pointers to memory allocated in dlsch_decoding_init ptr_td = (unsigned int*) mxGetData(mxGetField(prhs[1],0,"ptr_td")); #ifdef DEBUG_DLSCH_DECODING mexPrintf("ptr_td0 %p\n",ptr_td[0]); mexPrintf("ptr_td1 %p\n",ptr_td[1]); mexPrintf("ptr_td2 %p\n",ptr_td[2]); mexPrintf("ptr_td3 %p\n",ptr_td[3]); #endif memcpy(&tmp[0], &ptr_td[0], sizeof(ptr_td[0])); memcpy(&pi2tab16[0], tmp[0], 188*sizeof(pi2tab16[0])); memcpy(&tmp[0], &ptr_td[1], sizeof(ptr_td[1])); memcpy(&pi4tab16[0], tmp[0], 188*sizeof(pi4tab16[0])); memcpy(&tmp[0], &ptr_td[2], sizeof(ptr_td[2])); memcpy(&pi5tab16[0], tmp[0], 188*sizeof(pi5tab16[0])); memcpy(&tmp[0], &ptr_td[3], sizeof(ptr_td[3])); memcpy(&pi6tab16[0], tmp[0], 188*sizeof(pi6tab16[0])); harq_pid = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"harq_pid")); dlsch->current_harq_pid = harq_pid; dlsch->harq_processes[harq_pid]->rvidx = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"rvidx")); dlsch->harq_processes[harq_pid]->Nl = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Nl")); //dlsch->harq_processes[harq_pid]->Ndi = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Ndi")); dlsch->harq_processes[harq_pid]->mcs = mcs; dlsch->harq_processes[harq_pid]->rb_alloc[0] = (unsigned int) mxGetScalar(mxGetField(prhs[1],0,"rb_alloc")); dlsch->harq_processes[harq_pid]->nb_rb = (unsigned short) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); dlsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[get_I_TBS(mcs)][dlsch->harq_processes[harq_pid]->nb_rb-1]; num_pdcch_symbols = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"num_pdcch_symbols")); subframe = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"subframe")); phy_vars_ue = calloc(1,sizeof(PHY_VARS_UE)); // Create a LTE_DL_FRAME_PARMS structure and assign required params frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); frame_parms->N_RB_DL = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); frame_parms->frame_type = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"frame_type")); frame_parms->mode1_flag = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"mode1_flag")); frame_parms->Ncp = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"Ncp")); mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); dlsch->harq_processes[harq_pid]->G = get_G(frame_parms,dlsch->harq_processes[harq_pid]->nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,0,subframe); #ifdef DEBUG_DLSCH_DECODING mexPrintf("TBS %d\n",dlsch->harq_processes[harq_pid]->TBS); mexPrintf("nb_rb %d\n",dlsch->harq_processes[harq_pid]->nb_rb); mexPrintf("ncs %d\n",dlsch->harq_processes[harq_pid]->mcs); mexPrintf("num_pdcch_symbols %d\n",num_pdcch_symbols); mexPrintf("subframe %d\n",subframe); mexPrintf("G %d\n",dlsch->harq_processes[harq_pid]->G); #endif if (dlsch->harq_processes[harq_pid]->G != mxGetM(prhs[0])) { free_ue_dlsch(dlsch); free(frame_parms); free(phy_vars_ue); mexErrMsgTxt("Length of the LLR vector is incorrect."); } /* Allocate Output */ plhs[0] = mxCreateNumericMatrix(1, 1, mxUINT32_CLASS, mxREAL); ret = (unsigned int*) mxGetPr(plhs[0]); /* Algo */ *ret = dlsch_decoding(phy_vars_ue, dlsch_llr, frame_parms, dlsch, dlsch->harq_processes[harq_pid], subframe, dlsch->current_harq_pid, 1,0); /* free dlsch */ free_ue_dlsch(dlsch); free(frame_parms); free(phy_vars_ue); // free_td(); }