diff --git a/lib/src/phy/phch/prach.c b/lib/src/phy/phch/prach.c index 6c6a954bf..e403f2bee 100644 --- a/lib/src/phy/phch/prach.c +++ b/lib/src/phy/phch/prach.c @@ -753,11 +753,16 @@ int srsran_prach_gen(srsran_prach_t* p, uint32_t seq_index, uint32_t freq_offset DEBUG( "N_zc: %d, N_cp: %d, N_seq: %d, N_ifft_prach=%d begin: %d", p->N_zc, p->N_cp, p->N_seq, p->N_ifft_prach, begin); + // Fill bottom guard frequency domain with zeros + srsran_vec_cf_zero(p->ifft_in, begin); + // Map dft-precoded sequence to ifft bins - memset(p->ifft_in, 0, begin * sizeof(cf_t)); - memcpy(&p->ifft_in[begin], get_precoded_dft(p, seq_index), p->N_zc * sizeof(cf_t)); - memset(&p->ifft_in[begin + p->N_zc], 0, (p->N_ifft_prach - begin - p->N_zc) * sizeof(cf_t)); + srsran_vec_cf_copy(&p->ifft_in[begin], get_precoded_dft(p, seq_index), p->N_zc); + + // Fill top guard frequency domain with zeros + srsran_vec_cf_zero(&p->ifft_in[begin + p->N_zc], p->N_ifft_prach - begin - p->N_zc); + // Generate frequency domain signal srsran_dft_run(&p->ifft, p->ifft_in, p->ifft_out); // Copy CP into buffer @@ -977,7 +982,7 @@ int srsran_prach_detect_offset(srsran_prach_t* p, uint32_t N_rb_ul = srsran_nof_prb(p->N_ifft_ul); uint32_t k_0 = freq_offset * N_RB_SC - N_rb_ul * N_RB_SC / 2 + p->N_ifft_ul / 2; uint32_t K = DELTA_F / DELTA_F_RA; - uint32_t begin = PHI + (K * k_0) + (K / 2); + uint32_t begin = PHI + (K * k_0) + (p->is_nr ? 1 : (K / 2)); memcpy(p->prach_bins, &p->signal_fft[begin], p->N_zc * sizeof(cf_t)); int loops = (p->successive_cancellation) ? SUCCESSIVE_CANCELLATION_ITS : 1;