Esempio n. 1
0
int pss_synch_init_N_id_2(cf_t *pss_signal_freq, uint32_t N_id_2, uint32_t fft_size) {
  dft_plan_t plan;
  cf_t pss_signal_pad[2048];
  cf_t pss_signal_time[PSS_LEN];
  int ret = LIBLTE_ERROR_INVALID_INPUTS;
  
  if (lte_N_id_2_isvalid(N_id_2)    && 
      fft_size                  <= 2048) 
  {
    
    pss_generate(pss_signal_time, N_id_2);

    bzero(pss_signal_pad, fft_size * sizeof(cf_t));
    bzero(pss_signal_freq, fft_size * sizeof(cf_t));
    memcpy(&pss_signal_pad[(fft_size-PSS_LEN)/2], pss_signal_time, PSS_LEN * sizeof(cf_t));

    if (dft_plan(&plan, fft_size, BACKWARD, COMPLEX)) {
      return LIBLTE_ERROR;
    }
    
    dft_plan_set_mirror(&plan, true);
    dft_plan_set_dc(&plan, true);
    dft_plan_set_norm(&plan, true);
    dft_run_c(&plan, pss_signal_pad, pss_signal_freq);

    vec_conj_cc(pss_signal_freq, pss_signal_freq, fft_size);
    vec_sc_prod_cfc(pss_signal_freq, 1.0/62.0, pss_signal_freq, fft_size);

    dft_plan_free(&plan);
    
    ret = LIBLTE_SUCCESS;
  }
  return ret;
}
Esempio n. 2
0
/* Assumes input points to the beginning of the SSS symbol. The SSS symbol start is
 * given by SSS_SYMBOL_ST() macro in sss.h.
 * Estimates the m0 and m1 values and saves in m0_value and m1_value
 * the resulted correlation (higher is more likely)
 *
 *
 * Source: "SSS Detection Method for Initial Cell Search in 3GPP LTE FDD/TDD Dual Mode Receiver"
 * 			Jung-In Kim, Jung-Su Han, Hee-Jin Roh and Hyung-Jin Choi

 *
 */
void sss_synch_m0m1(sss_synch_t *q, cf_t *input, int *m0, float *m0_value,
		int *m1, float *m1_value) {

	/* This is aprox 3-4 kbytes of stack. Consider moving to sss_synch_t?? */
	cf_t zdelay[N_SSS+1],zconj[N_SSS+1],zprod[N_SSS+1];
	cf_t y[2][N_SSS+1], z[N_SSS+1], tmp[N_SSS+1];
	float tmp_real[N_SSS+1];
	cf_t input_fft[SSS_DFT_LEN];

	int i;

	dft_run_c2c(&q->dftp_input, input, input_fft);

	for (i = 0; i < N_SSS; i++) {
		y[0][i] = input_fft[SSS_POS_SYMBOL + 2 * i];
		y[1][i] = input_fft[SSS_POS_SYMBOL + 2 * i + 1];
	}

	vec_prod_ccc(y[0], q->fc_tables.c[0], z, N_SSS);
	memcpy(zdelay, &z[1], (N_SSS - 1) * sizeof(cf_t));
	vec_conj_cc(z, zconj, N_SSS - 1);
	vec_prod_ccc(zdelay, zconj, zprod, N_SSS - 1);

	corr_all_zs(zprod, q->fc_tables.s, tmp);
	vec_abs_cf(tmp, tmp_real, N_SSS);
	*m0 = vec_max_fi(tmp_real, N_SSS);
	if (m0_value) {
		*m0_value = tmp_real[*m0];
	}

	vec_prod_ccc(y[1], q->fc_tables.c[1], tmp, N_SSS);
	vec_prod_ccc(tmp, q->fc_tables.z1[*m0], z, N_SSS);
	memcpy(zdelay, &z[1], (N_SSS - 1) * sizeof(cf_t));
	vec_conj_cc(z, zconj, N_SSS - 1);
	vec_prod_ccc(zdelay, zconj, zprod, N_SSS - 1);

	corr_all_zs(zprod, q->fc_tables.s, tmp);
	vec_abs_cf(tmp, tmp_real, N_SSS);
	*m1 = vec_max_fi(tmp_real, N_SSS);
	if (m1_value) {
		*m1_value = tmp_real[*m1];
	}

}