diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 18939b33f263147b5fb8f2df6407f67cda14b6c4..797118b3829b7bcc14431b9cb865f62821bb4e07 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -88,7 +88,7 @@ int main(int argc, char **argv){ double **s_re, **s_im, **r_re, **r_im, iqim = 0.0, delay_avg = 0, ue_speed = 0, fs, bw; int i, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; - uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format; + uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; uint8_t frame = 1, subframe = 9, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, num_root_sequences = 16, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; uint32_t tx_lev = 10000, prach_errors = 0, samp_count; //,tx_lev_dB; @@ -131,6 +131,10 @@ int main(int argc, char **argv){ config_index = atoi(optarg); break; + case 'r': + msg1_frequencystart = atoi(optarg); + break; + case 'd': delay = atoi(optarg); break; @@ -401,15 +405,15 @@ int main(int argc, char **argv){ if (format1 != 0xff) { switch(format0) { - case 0xa1: - prach_format = 9; - break; - case 0xa2: - prach_format = 10; - break; - case 0xa3: - prach_format = 11; - break; + case 0xa1: + prach_format = 9; + break; + case 0xa2: + prach_format = 10; + break; + case 0xa3: + prach_format = 11; + break; default: AssertFatal(1==0, "Only formats A1/B1 A2/B2 A3/B3 are valid for dual format"); } @@ -459,6 +463,8 @@ int main(int argc, char **argv){ } } + printf("PRACH format %d\n",prach_format); + prach_config->num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index.value = rootSequenceIndex; prach_config->num_prach_fd_occasions_list[fd_occasion].k1.value = msg1_frequencystart; prach_config->restricted_set_config.value = restrictedSetConfig; @@ -578,16 +584,14 @@ int main(int argc, char **argv){ /* tx_lev_dB not used later, no need to set */ //tx_lev_dB = (unsigned int) dB_fixed(tx_lev); - if (mu == 0) - samp_count = frame_parms->samples_per_subframe; - else - samp_count = ((slot)%(frame_parms->slots_per_subframe/2)) ? frame_parms->samples_per_slotN0 : frame_parms->samples_per_slot0; - - prach_start = slot*samp_count - UE->N_TA_offset; + samp_count=0; + for (int s=0; s<slot; s++) samp_count+=frame_parms->get_samples_per_slot(s,frame_parms); + + prach_start = samp_count - UE->N_TA_offset; #ifdef NR_PRACH_DEBUG - LOG_M("txsig0.m", "txs0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); - //LOG_M("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); + LOG_M("txsig0.m", "txs0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); + LOG_M("txsig0_frame.m","txs0", txdata[0],frame_parms->samples_per_frame,1,1); #endif // multipath channel @@ -628,7 +632,7 @@ int main(int argc, char **argv){ ue_speed1 = ue_speed0 + 50; } - rx_prach_start = slot*frame_parms->get_samples_per_slot(slot,frame_parms); + rx_prach_start = subframe*frame_parms->samples_per_subframe; if (n_frames==1) printf("slot %d, rx_prach_start %d\n",slot,rx_prach_start); uint16_t preamble_rx, preamble_energy, N_ZC; N_ZC = prach_sequence_length == 0 ? 839 : 139; @@ -688,7 +692,7 @@ int main(int argc, char **argv){ if (n_frames==1) { printf("preamble %d (tx %d) : energy %d, delay %d\n",preamble_rx,preamble_tx,preamble_energy,preamble_delay); #ifdef NR_PRACH_DEBUG - LOG_M("prach0.m","prach0", &txdata[0][prach_start], samp_count, 1, 1); + LOG_M("prach0.m","prach0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1); LOG_M("prachF0.m","prachF0", &gNB->prach_vars.prachF[0], N_ZC, 1, 1); LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1); //LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1);