int main(int argc, char **argv) { char c; int i,l,aa; double sigma2, sigma2_dB=0,SNR,snr0=-2.0,snr1; int **txdata; double s_re[2][30720*2],s_im[2][30720*2],r_re[2][30720*2],r_im[2][30720*2]; double iqim=0.0; // int subframe_offset; uint8_t subframe=0; #ifdef XFORMS FD_lte_phy_scope_ue *form_ue; char title[255]; #endif int trial, n_errors_common=0,n_errors_ul=0,n_errors_dl=0,n_errors_cfi=0,n_errors_hi=0; unsigned char eNb_id = 0; uint8_t awgn_flag=0; int n_frames=1; channel_desc_t *eNB2UE; uint32_t nsymb,tx_lev,tx_lev_dB=0,num_pdcch_symbols=3; uint8_t extended_prefix_flag=0,transmission_mode=1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; // int8_t interf1=-128,interf2=-128; uint8_t dci_cnt=0; LTE_DL_FRAME_PARMS *frame_parms; uint8_t log2L=2, log2Lcommon=2; DCI_format_t format_selector[MAX_NUM_DCI]; uint8_t num_dci=0; uint8_t numCCE,common_active=0,ul_active=0,dl_active=0; uint32_t n_trials_common=0,n_trials_ul=0,n_trials_dl=0,false_detection_cnt=0; uint8_t common_rx,ul_rx,dl_rx; uint8_t tdd_config=3; FILE *input_fd=NULL; char input_val_str[50],input_val_str2[50]; uint16_t n_rnti=0x1234; uint8_t osf=1,N_RB_DL=25; SCM_t channel_model=Rayleigh1_anticorr; DCI_ALLOC_t dci_alloc_rx[8]; int ret; uint8_t harq_pid; uint8_t phich_ACK; uint8_t num_phich_interf = 0; lte_frame_type_t frame_type=TDD; // int re_offset; // uint32_t *txptr; int aarx; int k; uint32_t perfect_ce = 0; int CCE_table[800]; number_of_cards = 1; cpuf = get_cpu_freq_GHz(); logInit(); while ((c = getopt (argc, argv, "hapFg:R:c:n:s:x:y:z:L:M:N:I:f:i:S:P:Y")) != -1) { switch (c) { case 'a': printf("Running AWGN simulation\n"); awgn_flag = 1; break; case 'R': N_RB_DL = atoi(optarg); break; case 'F': frame_type = FDD; break; case 'c': tdd_config=atoi(optarg); if (tdd_config>6) { printf("Illegal tdd_config %d (should be 0-6)\n",tdd_config); exit(-1); } break; case 'g': switch((char)*optarg) { case 'A': channel_model=SCM_A; break; case 'B': channel_model=SCM_B; break; case 'C': channel_model=SCM_C; break; case 'D': channel_model=SCM_D; break; case 'E': channel_model=EPA; break; case 'F': channel_model=EVA; break; case 'G': channel_model=ETU; break; default: printf("Unsupported channel model!\n"); exit(-1); } break; /* case 'i': interf1=atoi(optarg); break; case 'j': interf2=atoi(optarg); break; */ case 'n': n_frames = atoi(optarg); break; case 's': snr0 = atoi(optarg); break; case 'p': extended_prefix_flag=1; break; case 'x': transmission_mode=atoi(optarg); if ((transmission_mode!=1) && (transmission_mode!=2) && (transmission_mode!=6)) { printf("Unsupported transmission mode %d\n",transmission_mode); exit(-1); } break; case 'y': n_tx=atoi(optarg); if ((n_tx==0) || (n_tx>2)) { printf("Unsupported number of tx antennas %d\n",n_tx); exit(-1); } break; case 'z': n_rx=atoi(optarg); if ((n_rx==0) || (n_rx>2)) { printf("Unsupported number of rx antennas %d\n",n_rx); exit(-1); } break; case 'S': subframe=atoi(optarg); break; case 'L': log2L=atoi(optarg); if ((log2L!=0)&& (log2L!=1)&& (log2L!=2)&& (log2L!=3)) { printf("Unsupported DCI aggregation level %d (should be 0,1,2,3)\n",log2L); exit(-1); } break; case 'M': log2Lcommon=atoi(optarg); if ((log2Lcommon!=2)&& (log2Lcommon!=3)) { printf("Unsupported Common DCI aggregation level %d (should be 2 or 3)\n",log2Lcommon); exit(-1); } break; case 'N': format_selector[num_dci] = (DCI_format_t) atoi(optarg); if ((format_selector[num_dci]<format0) || (format_selector[num_dci] > format1A)) { printf("only formats 0, 1, and 1A supported for the moment\n"); exit(-1); } if (format_selector[num_dci]==format0) ul_active=1; if (format_selector[num_dci]==format1A) common_active=1; if (format_selector[num_dci]==format1) dl_active=1; num_dci++; break; case 'O': osf = atoi(optarg); break; case 'I': Nid_cell = atoi(optarg); break; case 'f': input_fd = fopen(optarg,"r"); if (input_fd==NULL) { printf("Problem with filename %s\n",optarg); exit(-1); } break; case 'i': n_rnti=atoi(optarg); break; case 'P': num_phich_interf=atoi(optarg); break; case 'Y': perfect_ce = 1; break; case 'h': printf("%s -h(elp) -a(wgn on) -c tdd_config -n n_frames -r RiceanFactor -s snr0 -t Delayspread -x transmission mode (1,2,6) -y TXant -z RXant -L AggregLevelUEspec -M AggregLevelCommonDCI -N DCIFormat\n\n", argv[0]); printf("-h This message\n"); printf("-a Use AWGN channel and not multipath\n"); printf("-c TDD config\n"); printf("-S Subframe number (0..9)\n"); printf("-R N_RB_DL\n"); printf("-F use FDD frame\n"); printf("-p Use extended prefix mode\n"); printf("-n Number of frames to simulate\n"); printf("-r Ricean factor (dB, 0 means Rayleigh, 100 is almost AWGN\n"); printf("-s Starting SNR, runs from SNR to SNR + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-t Delay spread for multipath channel\n"); printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); printf("-P Number of interfering PHICH\n"); printf("-L log2 of Aggregation level for UE Specific DCI (0,1,2,3)\n"); printf("-M log2 Aggregation level for Common DCI (4,8)\n"); printf("-N Format for UE Spec DCI (0 - format0,\n"); printf(" 1 - format1,\n"); printf(" 2 - format1A,\n"); printf(" 3 - format1B_2A,\n"); printf(" 4 - format1B_4A,\n"); printf(" 5 - format1C,\n"); printf(" 6 - format1D_2A,\n"); printf(" 7 - format1D_4A,\n"); printf(" 8 - format2A_2A_L10PRB,\n"); printf(" 9 - format2A_2A_M10PRB,\n"); printf(" 10 - format2A_4A_L10PRB,\n"); printf(" 11 - format2A_4A_M10PRB,\n"); printf(" 12 - format2_2A_L10PRB,\n"); printf(" 13 - format2_2A_M10PRB,\n"); printf(" 14 - format2_4A_L10PRB,\n"); printf(" 15 - format2_4A_M10PRB\n"); printf(" 16 - format2_2D_M10PRB\n"); printf(" 17 - format2_2D_L10PRB\n"); printf(" can be called multiple times to add more than one DCI\n"); printf("-O Oversampling factor\n"); printf("-I Cell Id\n"); printf("-F Input sample stream\n"); exit(1); break; } } if ((transmission_mode>1) && (n_tx==1)) n_tx=2; lte_param_init(n_tx, n_tx, n_rx, transmission_mode, extended_prefix_flag, frame_type, Nid_cell, tdd_config, N_RB_DL, 0, osf, perfect_ce); #ifdef XFORMS fl_initialize (&argc, argv, NULL, 0, 0); form_ue = create_lte_phy_scope_ue(); sprintf (title, "LTE PHY SCOPE UE"); fl_show_form (form_ue->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); #endif mac_xface->computeRIV = computeRIV; mac_xface->frame_parms = &eNB->frame_parms; // init_transport_channels(transmission_mode); if (n_frames==1) snr1 = snr0+.1; else snr1 = snr0+8.0; printf("SNR0 %f, SNR1 %f\n",snr0,snr1); frame_parms = &eNB->frame_parms; printf("Getting %d dcis\n",num_dci); get_dci(frame_parms, log2L, log2Lcommon, format_selector, num_dci, n_rnti); txdata = eNB->common_vars.txdata[eNb_id]; nsymb = (eNB->frame_parms.Ncp == 0) ? 14 : 12; printf("Subframe %d, FFT Size %d, Extended Prefix %d, Samples per subframe %d, Symbols per subframe %d\n", subframe,NUMBER_OF_OFDM_CARRIERS, eNB->frame_parms.Ncp,eNB->frame_parms.samples_per_tti,nsymb); eNB2UE = new_channel_desc_scm(eNB->frame_parms.nb_antennas_tx, UE->frame_parms.nb_antennas_rx, channel_model, N_RB2sampling_rate(eNB->frame_parms.N_RB_DL), N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL), 0, 0, 0); eNB_rxtx_proc_t *proc_rxtx = &eNB->proc.proc_rxtx[subframe&1]; eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,N_RB_DL,0); UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); proc_rxtx->frame_tx = 0; proc_rxtx->subframe_tx = subframe; if (input_fd==NULL) { printf("No input file, so starting TX\n"); } else { i=0; while (!feof(input_fd)) { ret=fscanf(input_fd,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2); if (ret != 2) { printf("%s:%d:%s: fscanf error, exiting\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } if ((i%4)==0) { ((short*)txdata[0])[i/2] = (short)((1<<15)*strtod(input_val_str,NULL)); ((short*)txdata[0])[(i/2)+1] = (short)((1<<15)*strtod(input_val_str2,NULL)); if ((i/4)<100) printf("sample %d => %e + j%e (%d +j%d)\n",i/4,strtod(input_val_str,NULL),strtod(input_val_str2,NULL),((short*)txdata[0])[i/4],((short*)txdata[0])[(i/4)+1]);//1,input_val2,); } i++; if (i>(4*FRAME_LENGTH_SAMPLES)) break; } printf("Read in %d samples\n",i/4); write_output("txsig0.m","txs0", txdata[0],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); // write_output("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); tx_lev = signal_energy(&txdata[0][0], OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES); tx_lev_dB = (unsigned int) dB_fixed(tx_lev); } UE->UE_mode[0] = PUSCH; // nCCE_max = get_nCCE(3,&eNB->frame_parms,get_mi(&eNB->frame_parms,0)); //printf("nCCE_max %d\n",nCCE_max); //printf("num_phich interferers %d\n",num_phich_interf); for (SNR=snr0; SNR<snr1; SNR+=0.2) { n_errors_common = 0; n_errors_ul = 0; n_errors_dl = 0; n_errors_cfi = 0; n_errors_hi = 0; n_trials_common=0; n_trials_ul=0; n_trials_dl=0; for (trial=0; trial<n_frames; trial++) { // printf("DCI (SF %d): txdataF %p (0 %p)\n",subframe,&eNB->common_vars.txdataF[eNb_id][aa][512*14*subframe],&eNB->common_vars.txdataF[eNb_id][aa][0]); for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) { memset(&eNB->common_vars.txdataF[eNb_id][aa][0],0,FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t)); } generate_pilots_slot(eNB, eNB->common_vars.txdataF[eNb_id], AMP, //1024, (subframe*2), 0); generate_pilots_slot(eNB, eNB->common_vars.txdataF[eNb_id], AMP, //1024, (subframe*2)+1, 0); if (input_fd == NULL) { numCCE=0; n_trials_common++; common_active = 1; if (eNB->frame_parms.N_RB_DL >= 50) { if (ul_active==1) { n_trials_ul++; } } if (eNB->frame_parms.N_RB_DL >= 25) { if (dl_active==1) { n_trials_dl++; } } num_pdcch_symbols = get_num_pdcch_symbols(DCI_pdu.Num_dci, DCI_pdu.dci_alloc, frame_parms, subframe); numCCE = get_nCCE(num_pdcch_symbols,&eNB->frame_parms,get_mi(&eNB->frame_parms,subframe)); if (n_frames==1) { printf("num_dci %d, num_pddch_symbols %d, nCCE %d\n", DCI_pdu.Num_dci, num_pdcch_symbols,numCCE); } // apply RNTI-based nCCE allocation memset(CCE_table,0,800*sizeof(int)); for (i = 0; i < DCI_pdu.Num_dci; i++) { // SI RNTI if (DCI_pdu.dci_alloc[i].rnti == SI_RNTI) { DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table, 1<<DCI_pdu.dci_alloc[i].L, numCCE, 1, SI_RNTI, subframe); } // RA RNTI else if (DCI_pdu.dci_alloc[i].ra_flag == 1) { DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table, 1<<DCI_pdu.dci_alloc[i].L, numCCE, 1, DCI_pdu.dci_alloc[i].rnti, subframe); } // C RNTI else { DCI_pdu.dci_alloc[i].firstCCE = get_nCCE_offset_l1(CCE_table, 1<<DCI_pdu.dci_alloc[i].L, numCCE, 0, DCI_pdu.dci_alloc[i].rnti, subframe); } if (n_frames==1) printf("dci %d: rnti 0x%x, format %d, L %d (aggreg %d), nCCE %d/%d dci_length %d\n",i,DCI_pdu.dci_alloc[i].rnti, DCI_pdu.dci_alloc[i].format, DCI_pdu.dci_alloc[i].L, 1<<DCI_pdu.dci_alloc[i].L, DCI_pdu.dci_alloc[i].firstCCE, numCCE, DCI_pdu.dci_alloc[i].dci_length); if (DCI_pdu.dci_alloc[i].firstCCE==-1) exit(-1); } num_pdcch_symbols = generate_dci_top(DCI_pdu.Num_dci, DCI_pdu.dci_alloc, 0, AMP, &eNB->frame_parms, eNB->common_vars.txdataF[eNb_id], subframe); if (n_frames==1) printf("num_pdcch_symbols at TX %d\n",num_pdcch_symbols); if (is_phich_subframe(&eNB->frame_parms,subframe)) { if (n_frames==1) printf("generating PHICH\n"); harq_pid = phich_subframe_to_harq_pid(&eNB->frame_parms, proc_rxtx->frame_tx, subframe); phich_ACK = taus()&1; eNB->ulsch[0]->harq_processes[harq_pid]->phich_active = 1; eNB->ulsch[0]->harq_processes[harq_pid]->first_rb = 0; eNB->ulsch[0]->harq_processes[harq_pid]->n_DMRS = 0; eNB->ulsch[0]->harq_processes[harq_pid]->phich_ACK = phich_ACK; eNB->ulsch[0]->harq_processes[harq_pid]->dci_alloc = 1; UE->ulsch[0]->harq_processes[harq_pid]->first_rb = 0; UE->ulsch[0]->harq_processes[harq_pid]->n_DMRS = 0; generate_phich_top(eNB,proc_rxtx,AMP,0); // generate 3 interfering PHICH if (num_phich_interf>0) { eNB->ulsch[0]->harq_processes[harq_pid]->first_rb = 4; generate_phich_top(eNB,proc_rxtx,1024,0); } if (num_phich_interf>1) { eNB->ulsch[0]->harq_processes[harq_pid]->first_rb = 8; eNB->ulsch[0]->harq_processes[harq_pid]->n_DMRS = 1; generate_phich_top(eNB,proc_rxtx,1024,0); } if (num_phich_interf>2) { eNB->ulsch[0]->harq_processes[harq_pid]->first_rb = 12; eNB->ulsch[0]->harq_processes[harq_pid]->n_DMRS = 1; generate_phich_top(eNB,proc_rxtx,1024,0); } eNB->ulsch[0]->harq_processes[harq_pid]->first_rb = 0; } // write_output("pilotsF.m","rsF",txdataF[0],lte_eNB->frame_parms.ofdm_symbol_size,1,1); if (n_frames==1) { write_output("txsigF0.m","txsF0", eNB->common_vars.txdataF[eNb_id][0],4*nsymb*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES_NO_PREFIX,1,1); if (eNB->frame_parms.nb_antenna_ports_eNB > 1) write_output("txsigF1.m","txsF1", eNB->common_vars.txdataF[eNb_id][1],4*nsymb*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES_NO_PREFIX,1,1); } tx_lev = 0; for (aa=0; aa<eNB->frame_parms.nb_antenna_ports_eNB; aa++) { if (eNB->frame_parms.Ncp == 1) PHY_ofdm_mod(&eNB->common_vars.txdataF[eNb_id][aa][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size], // input, &txdata[aa][subframe*eNB->frame_parms.samples_per_tti], // output eNB->frame_parms.ofdm_symbol_size, 2*nsymb, // number of symbols eNB->frame_parms.nb_prefix_samples, // number of prefix samples CYCLIC_PREFIX); else { normal_prefix_mod(&eNB->common_vars.txdataF[eNb_id][aa][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size], &txdata[aa][subframe*eNB->frame_parms.samples_per_tti], 2*nsymb, frame_parms); } tx_lev += signal_energy(&txdata[aa][subframe*eNB->frame_parms.samples_per_tti], eNB->frame_parms.ofdm_symbol_size); } tx_lev_dB = (unsigned int) dB_fixed(tx_lev); } for (i=0; i<2*nsymb*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; i++) { for (aa=0; aa<eNB->frame_parms.nb_antenna_ports_eNB; aa++) { if (awgn_flag == 0) { s_re[aa][i] = ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)]); s_im[aa][i] = ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)+1]); } else { for (aarx=0; aarx<UE->frame_parms.nb_antennas_rx; aarx++) { if (aa==0) { r_re[aarx][i] = ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)]); r_im[aarx][i] = ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)+1]); } else { r_re[aarx][i] += ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)]); r_im[aarx][i] += ((double)(((short *)txdata[aa]))[(2*subframe*UE->frame_parms.samples_per_tti) + (i<<1)+1]); } } } } } if (awgn_flag == 0) { multipath_channel(eNB2UE,s_re,s_im,r_re,r_im, 2*nsymb*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES,0); } //write_output("channel0.m","chan0",ch[0],channel_length,1,8); // scale by path_loss = NOW - P_noise //sigma2 = pow(10,sigma2_dB/10); //N0W = -95.87; sigma2_dB = (double)tx_lev_dB +10*log10((double)eNB->frame_parms.ofdm_symbol_size/(double)(12*eNB->frame_parms.N_RB_DL)) - SNR; if (n_frames==1) printf("sigma2_dB %f (SNR %f dB) tx_lev_dB %d\n",sigma2_dB,SNR,tx_lev_dB); //AWGN sigma2 = pow(10,sigma2_dB/10); // printf("Sigma2 %f (sigma2_dB %f)\n",sigma2,sigma2_dB); for (i=0; i<2*nsymb*OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; i++) { for (aa=0; aa<UE->frame_parms.nb_antennas_rx; aa++) { ((short*) UE->common_vars.rxdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i] = (short) (.667*(r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0))); ((short*) UE->common_vars.rxdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i+1] = (short) (.667*(r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble( 0.0,1.0))); /* ((short*)UE->common_vars.rxdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i] = ((short*)txdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i]; ((short*)UE->common_vars.rxdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i+1] = ((short*)txdata[aa])[(2*subframe*UE->frame_parms.samples_per_tti) + 2*i+1]; */ } } // UE receiver for (l=0; l<eNB->frame_parms.symbols_per_tti; l++) { // subframe_offset = (l/eNB->frame_parms.symbols_per_tti)*eNB->frame_parms.samples_per_tti; // printf("subframe_offset = %d\n",subframe_offset); slot_fep(UE, l%(eNB->frame_parms.symbols_per_tti/2), (2*subframe)+(l/(eNB->frame_parms.symbols_per_tti/2)), 0, 0, 0); if (UE->perfect_ce == 1) { if (awgn_flag==0) { // fill in perfect channel estimates freq_channel(eNB2UE,UE->frame_parms.N_RB_DL,12*UE->frame_parms.N_RB_DL + 1); //write_output("channel.m","ch",desc1->ch[0],desc1->channel_length,1,8); //write_output("channelF.m","chF",desc1->chF[0],nb_samples,1,8); for(k=0; k<NUMBER_OF_eNB_MAX; k++) { for(aa=0; aa<frame_parms->nb_antennas_tx; aa++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (i=0; i<frame_parms->N_RB_DL*12; i++) { ((int16_t *) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[k][(aa<<1)+aarx])[2*i+(l*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)( eNB2UE->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].x*AMP); ((int16_t *) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[k][(aa<<1)+aarx])[2*i+1+(l*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(int16_t)( eNB2UE->chF[aarx+(aa*frame_parms->nb_antennas_rx)][i].y*AMP); } } } } } else { for(aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (i=0; i<frame_parms->N_RB_DL*12; i++) { ((int16_t *) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0][(aa<<1)+aarx])[2*i+(l*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=(short)(AMP); ((int16_t *) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0][(aa<<1)+aarx])[2*i+1+(l*frame_parms->ofdm_symbol_size+LTE_CE_FILTER_LENGTH)*2]=0/2; } } } } } if (l==((eNB->frame_parms.Ncp==0)?4:3)) { // write_output("H00.m","h00",&(UE->common_vars.dl_ch_estimates[0][0][0]),((frame_parms->Ncp==0)?7:6)*(eNB->frame_parms.ofdm_symbol_size),1,1); // do PDCCH procedures here UE->pdcch_vars[0][0]->crnti = n_rnti; // printf("Doing RX : num_pdcch_symbols at TX %d\n",num_pdcch_symbols); rx_pdcch(UE, trial, subframe, 0, (UE->frame_parms.mode1_flag == 1) ? SISO : ALAMOUTI, UE->high_speed_flag, UE->is_secondary_ue); if (is_phich_subframe(&UE->frame_parms,subframe)) { UE->ulsch[0]->harq_processes[phich_subframe_to_harq_pid(&UE->frame_parms,0,subframe)]->status = ACTIVE; //UE->ulsch[0]->harq_processes[phich_subframe_to_harq_pid(&UE->frame_parms,0,subframe)]->Ndi = 1; rx_phich(UE, &UE->proc.proc_rxtx[subframe&1], subframe, 0); } // if (UE->pdcch_vars[0]->num_pdcch_symbols != num_pdcch_symbols) // break; dci_cnt = dci_decoding_procedure(UE, dci_alloc_rx,1, 0,subframe); common_rx=0; ul_rx=0; dl_rx=0; if (n_frames==1) { numCCE = get_nCCE(UE->pdcch_vars[0][0]->num_pdcch_symbols, &UE->frame_parms, get_mi(&UE->frame_parms,subframe)); for (i = 0; i < dci_cnt; i++) printf("dci %d: rnti 0x%x, format %d, L %d, nCCE %d/%d dci_length %d\n",i, dci_alloc_rx[i].rnti, dci_alloc_rx[i].format, dci_alloc_rx[i].L, dci_alloc_rx[i].firstCCE, numCCE, dci_alloc_rx[i].dci_length); } for (i=0; i<dci_cnt; i++) { if (dci_alloc_rx[i].rnti == SI_RNTI) { if (n_frames==1) dump_dci(&UE->frame_parms, &dci_alloc_rx[i]); common_rx=1; } if ((dci_alloc_rx[i].rnti == n_rnti) && (dci_alloc_rx[i].format == format0)) { if (n_frames==1) dump_dci(&UE->frame_parms, &dci_alloc_rx[i]); ul_rx=1; } if ((dci_alloc_rx[i].rnti == n_rnti) && ((dci_alloc_rx[i].format == format1))) { if (n_frames==1) dump_dci(&UE->frame_parms, &dci_alloc_rx[i]); dl_rx=1; } if ((dci_alloc_rx[i].rnti != n_rnti) && (dci_alloc_rx[i].rnti != SI_RNTI)) false_detection_cnt++; } if (n_frames==1) printf("RX DCI Num %d (Common DCI %d, DL DCI %d, UL DCI %d)\n", dci_cnt, common_rx, dl_rx, ul_rx); if ((common_rx==0)&&(common_active==1)) n_errors_common++; if ((ul_rx==0)&&(ul_active==1)) { n_errors_ul++; // exit(-1); } if ((dl_rx==0)&&(dl_active==1)) { n_errors_dl++; // exit(-1); } if (UE->pdcch_vars[0][0]->num_pdcch_symbols != num_pdcch_symbols) n_errors_cfi++; /* if (is_phich_subframe(&UE->frame_parms,subframe)) if (UE->ulsch[0]->harq_processes[phich_subframe_to_harq_pid(&UE->frame_parms, UE->frame, subframe)]->Ndi != phich_ACK) n_errors_hi++; */ if (n_errors_cfi > 10) break; } } // symbol loop if (n_errors_cfi > 100) break; if ((n_errors_ul>1000) && (n_errors_dl>1000) && (n_errors_common>1000)) break; #ifdef XFORMS phy_scope_UE(form_ue, UE, eNb_id,0,subframe); #endif } //trials if (common_active) printf("SNR %f : n_errors_common = %d/%d (%e)\n", SNR,n_errors_common,n_trials_common,(double)n_errors_common/n_trials_common); if (ul_active==1) printf("SNR %f : n_errors_ul = %d/%d (%e)\n", SNR,n_errors_ul,n_trials_ul,(double)n_errors_ul/n_trials_ul); if (dl_active==1) printf("SNR %f : n_errors_dl = %d/%d (%e)\n", SNR,n_errors_dl,n_trials_dl,(double)n_errors_dl/n_trials_dl); printf("SNR %f : n_errors_cfi = %d/%d (%e)\n", SNR,n_errors_cfi,trial,(double)n_errors_cfi/trial); printf("SNR %f : n_errors_hi = %d/%d (%e)\n", SNR,n_errors_hi,trial,(double)n_errors_hi/trial); } // SNR if (n_frames==1) { write_output("txsig0.m","txs0", txdata[0],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); if (n_tx>1) write_output("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); write_output("rxsig0.m","rxs0", UE->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1); write_output("rxsigF0.m","rxsF0", UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[0],NUMBER_OF_OFDM_CARRIERS*2*((frame_parms->Ncp==0)?14:12),2,1); if (n_rx>1) { write_output("rxsig1.m","rxs1", UE->common_vars.rxdata[1],10*frame_parms->samples_per_tti,1,1); write_output("rxsigF1.m","rxsF1", UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[1],NUMBER_OF_OFDM_CARRIERS*2*((frame_parms->Ncp==0)?14:12),2,1); } write_output("H00.m","h00",&(UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0][0][0]),((frame_parms->Ncp==0)?7:6)*(eNB->frame_parms.ofdm_symbol_size),1,1); if (n_tx==2) write_output("H10.m","h10",&(UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[0][2][0]),((frame_parms->Ncp==0)?7:6)*(eNB->frame_parms.ofdm_symbol_size),1,1); write_output("pdcch_rxF_ext0.m","pdcch_rxF_ext0",UE->pdcch_vars[0][eNb_id]->rxdataF_ext[0],3*12*UE->frame_parms.N_RB_DL,1,1); write_output("pdcch_rxF_comp0.m","pdcch0_rxF_comp0",UE->pdcch_vars[0][eNb_id]->rxdataF_comp[0],4*12*UE->frame_parms.N_RB_DL,1,1); write_output("pdcch_rxF_llr.m","pdcch_llr",UE->pdcch_vars[0][eNb_id]->llr,2400,1,4); } lte_sync_time_free(); return(n_errors_ul); }
PHY_VARS_eNB* init_lte_eNB(LTE_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, uint8_t Nid_cell, uint8_t cooperation_flag, uint8_t transmission_mode, uint8_t abstraction_flag) { int i,j; PHY_VARS_eNB* PHY_vars_eNB = malloc(sizeof(PHY_VARS_eNB)); memset(PHY_vars_eNB,0,sizeof(PHY_VARS_eNB)); PHY_vars_eNB->Mod_id=eNB_id; PHY_vars_eNB->cooperation_flag=cooperation_flag; memcpy(&(PHY_vars_eNB->lte_frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS)); PHY_vars_eNB->lte_frame_parms.Nid_cell = ((Nid_cell/3)*3)+((eNB_id+Nid_cell)%3); PHY_vars_eNB->lte_frame_parms.nushift = PHY_vars_eNB->lte_frame_parms.Nid_cell%6; phy_init_lte_eNB(PHY_vars_eNB,0,cooperation_flag,abstraction_flag); LOG_I(PHY,"init eNB: Nid_cell %d\n", frame_parms->Nid_cell); LOG_I(PHY,"init eNB: frame_type %d,tdd_config %d\n", frame_parms->frame_type,frame_parms->tdd_config); LOG_I(PHY,"init eNB: number of ue max %d number of enb max %d number of harq pid max %d\n", NUMBER_OF_UE_MAX, NUMBER_OF_eNB_MAX, NUMBER_OF_HARQ_PID_MAX); LOG_I(PHY,"init eNB: N_RB_DL %d\n", frame_parms->N_RB_DL); LOG_I(PHY,"init eNB: Transmission mode %d\n", transmission_mode); for (i=0; i<NUMBER_OF_UE_MAX; i++) { for (j=0; j<2; j++) { PHY_vars_eNB->dlsch_eNB[i][j] = new_eNB_dlsch(1,NUMBER_OF_HARQ_PID_MAX,frame_parms->N_RB_DL,abstraction_flag); if (!PHY_vars_eNB->dlsch_eNB[i][j]) { LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); exit(-1); } else { LOG_D(PHY,"dlsch_eNB[%d][%d] => %p\n",i,j,PHY_vars_eNB->dlsch_eNB[i][j]); PHY_vars_eNB->dlsch_eNB[i][j]->rnti=0; } } PHY_vars_eNB->ulsch_eNB[1+i] = new_eNB_ulsch(NUMBER_OF_HARQ_PID_MAX,MAX_TURBO_ITERATIONS, frame_parms->N_RB_UL, abstraction_flag); if (!PHY_vars_eNB->ulsch_eNB[1+i]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } // this is the transmission mode for the signalling channels // this will be overwritten with the real transmission mode by the RRC once the UE is connected PHY_vars_eNB->transmission_mode[i] = transmission_mode; #ifdef LOCALIZATION PHY_vars_eNB->ulsch_eNB[1+i]->aggregation_period_ms = 5000; // 5000 milliseconds // could be given as an argument (TBD)) struct timeval ts; gettimeofday(&ts, NULL); PHY_vars_eNB->ulsch_eNB[1+i]->reference_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; int j; for (j=0; j<10; j++) { initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->loc_rss_list[j]); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->loc_rssi_list[j]); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->loc_subcarrier_rss_list[j]); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->loc_timing_advance_list[j]); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->loc_timing_update_list[j]); } initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->tot_loc_rss_list); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->tot_loc_rssi_list); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->tot_loc_subcarrier_rss_list); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->tot_loc_timing_advance_list); initialize(&PHY_vars_eNB->ulsch_eNB[1+i]->tot_loc_timing_update_list); #endif } // ULSCH for RA PHY_vars_eNB->ulsch_eNB[0] = new_eNB_ulsch(NUMBER_OF_HARQ_PID_MAX,MAX_TURBO_ITERATIONS, frame_parms->N_RB_UL, abstraction_flag); if (!PHY_vars_eNB->ulsch_eNB[0]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } PHY_vars_eNB->dlsch_eNB_SI = new_eNB_dlsch(1,1,frame_parms->N_RB_DL, abstraction_flag); LOG_D(PHY,"eNB %d : SI %p\n",eNB_id,PHY_vars_eNB->dlsch_eNB_SI); PHY_vars_eNB->dlsch_eNB_ra = new_eNB_dlsch(1,1,frame_parms->N_RB_DL, abstraction_flag); LOG_D(PHY,"eNB %d : RA %p\n",eNB_id,PHY_vars_eNB->dlsch_eNB_ra); PHY_vars_eNB->dlsch_eNB_MCH = new_eNB_dlsch(1,NUMBER_OF_HARQ_PID_MAX,frame_parms->N_RB_DL, 0); LOG_D(PHY,"eNB %d : MCH %p\n",eNB_id,PHY_vars_eNB->dlsch_eNB_MCH); PHY_vars_eNB->rx_total_gain_eNB_dB=130; for(i=0; i<NUMBER_OF_UE_MAX; i++) PHY_vars_eNB->mu_mimo_mode[i].dl_pow_off = 2; PHY_vars_eNB->check_for_total_transmissions = 0; PHY_vars_eNB->check_for_MUMIMO_transmissions = 0; PHY_vars_eNB->FULL_MUMIMO_transmissions = 0; PHY_vars_eNB->check_for_SUMIMO_transmissions = 0; PHY_vars_eNB->lte_frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; return (PHY_vars_eNB); }
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)); } }