integrating decimation as a parameter in ue_sync, sync and pss

This commit is contained in:
yagoda 2017-05-08 15:29:34 +01:00
parent 033ef49a26
commit d28532bbfa
7 changed files with 69 additions and 27 deletions

View File

@ -294,6 +294,7 @@ srslte_netsink_t net_sink, net_sink_signal;
int main(int argc, char **argv) {
int ret;
int decimate = 1;
srslte_cell_t cell;
int64_t sf_cnt;
srslte_ue_mib_t ue_mib;
@ -425,10 +426,11 @@ int main(int argc, char **argv) {
}
else
{
ue_sync.decimate = prog_args.decimate;
decimate = prog_args.decimate;
//ue_sync.decimate = prog_args.decimate;
}
}
if (srslte_ue_sync_init_multi(&ue_sync, cell, srslte_rf_recv_wrapper, prog_args.rf_nof_rx_ant, (void*) &rf)) {
if (srslte_ue_sync_init_multi_decim(&ue_sync, cell, srslte_rf_recv_wrapper, prog_args.rf_nof_rx_ant, (void*) &rf,decimate)) {
fprintf(stderr, "Error initiating ue_sync\n");
exit(-1);
}

View File

@ -107,6 +107,12 @@ SRSLTE_API int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q,
uint32_t fft_size,
int cfo_i);
SRSLTE_API int srslte_pps_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
uint32_t frame_size,
uint32_t fft_size,
int cfo_i,
int decimate);
SRSLTE_API int srslte_pss_synch_init(srslte_pss_synch_t *q,
uint32_t frame_size);

View File

@ -112,6 +112,13 @@ SRSLTE_API int srslte_sync_init(srslte_sync_t *q,
uint32_t max_offset,
uint32_t fft_size);
SRSLTE_API int srslte_sync_init_decim(srslte_sync_t *q,
uint32_t frame_size,
uint32_t max_offset,
uint32_t fft_size,
int decimate);
SRSLTE_API void srslte_sync_free(srslte_sync_t *q);
SRSLTE_API void srslte_sync_reset(srslte_sync_t *q);

View File

@ -135,6 +135,13 @@ SRSLTE_API int srslte_ue_sync_init_multi(srslte_ue_sync_t *q,
uint32_t nof_rx_antennas,
void *stream_handler);
SRSLTE_API int srslte_ue_sync_init_multi_decim(srslte_ue_sync_t *q,
srslte_cell_t cell,
int (recv_callback)(void*, cf_t*[SRSLTE_MAX_PORTS], uint32_t, srslte_timestamp_t*),
uint32_t nof_rx_antennas,
void *stream_handler,
int decimate);
SRSLTE_API int srslte_ue_sync_init_file(srslte_ue_sync_t *q,
uint32_t nof_prb,
char *file_name,

View File

@ -84,27 +84,31 @@ int srslte_pss_synch_init_fft(srslte_pss_synch_t *q, uint32_t frame_size, uint32
return srslte_pss_synch_init_fft_offset(q, frame_size, fft_size, 0);
}
int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size, int offset) {
return srslte_pss_synch_init_fft_offset_decim(q, frame_size, fft_size, offset, 1);
}
/* Initializes the PSS synchronization object.
*
* It correlates a signal of frame_size samples with the PSS sequence in the frequency
* domain. The PSS sequence is transformed using fft_size samples.
*/
int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size, int offset) {
int ret = SRSLTE_ERROR_INVALID_INPUTS;
int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size, int offset, int decimate) {
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) {
ret = SRSLTE_ERROR;
uint32_t N_id_2;
uint32_t buffer_size;
int decimation_factor = q->decimate;
bzero(q, sizeof(srslte_pss_synch_t));
q->N_id_2 = 10;
q->ema_alpha = 0.2;
q->decimate = decimation_factor;
q->decimate = decimate;
fft_size = fft_size/q->decimate;
frame_size = frame_size/q->decimate;
@ -121,11 +125,7 @@ int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size,
q->filter.downsampled_input = srslte_vec_malloc((buffer_size + filter_order) * sizeof(cf_t));
printf("decimation for the PSS search is %d \n",q->decimate);
}
if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) {
fprintf(stderr, "Error creating DFT plan \n");
goto clean_and_exit;
@ -199,8 +199,10 @@ clean_and_exit:
srslte_pss_synch_free(q);
}
return ret;
}
void srslte_pss_synch_free(srslte_pss_synch_t *q) {
uint32_t i;
@ -434,7 +436,7 @@ int srslte_pss_synch_find_pss(srslte_pss_synch_t *q, cf_t *input, float *corr_pe
if(q->decimate >1)
{
int decimation_correction = (q->filter.num_taps -2);
int decimation_correction = (q->filter.num_taps - 2);
corr_peak_pos = corr_peak_pos - decimation_correction;
corr_peak_pos = corr_peak_pos*q->decimate;
}

View File

@ -47,7 +47,13 @@ static bool fft_size_isvalid(uint32_t fft_size) {
}
}
int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) {
int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size)
{
return srslte_sync_init_decim(q, frame_size, max_offset, fft_size, 1);
}
int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate) {
int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -56,8 +62,6 @@ int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset,
fft_size_isvalid(fft_size))
{
ret = SRSLTE_ERROR;
int decimate = q->decimate;
bzero(q, sizeof(srslte_sync_t));
q->detect_cp = true;
q->sss_en = true;
@ -106,12 +110,12 @@ int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset,
}
srslte_sync_set_cp(q, SRSLTE_CP_NORM);
q->decimate = decimate;
if(!decimate)
decimate = 1;
q->pss.decimate = decimate;
if (srslte_pss_synch_init_fft(&q->pss, max_offset, fft_size)) {
if (srslte_pss_synch_init_fft_offset_decim(&q->pss, max_offset, fft_size,0,decimate)) {
fprintf(stderr, "Error initializing PSS object\n");
goto clean_exit;
}
@ -462,8 +466,13 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t
} else {
srslte_pss_synch_set_N_id_2(&q->pss, q->N_id_2);
peak_pos = srslte_pss_synch_find_pss(&q->pss, &input_cfo[find_offset], &q->peak_value);
// this compensates for the constant time shift caused by the low pass filter
if(q->decimate && peak_pos < 0)
{
peak_pos = 0 ;//peak_pos + q->decimate*(2);// replace 2 with q->filter_size -2;
}
if (peak_pos < 0) {
fprintf(stderr, "Error calling finding PSS sequence\n");
fprintf(stderr, "Error calling finding PSS sequence at : %d \n", peak_pos);
return SRSLTE_ERROR;
}
}

View File

@ -128,6 +128,18 @@ int srslte_ue_sync_init_multi(srslte_ue_sync_t *q,
int (recv_callback)(void*, cf_t*[SRSLTE_MAX_PORTS], uint32_t,srslte_timestamp_t*),
uint32_t nof_rx_antennas,
void *stream_handler)
{
return srslte_ue_sync_init_multi_decim(q, cell,recv_callback ,nof_rx_antennas,stream_handler,1);
}
int srslte_ue_sync_init_multi_decim(srslte_ue_sync_t *q,
srslte_cell_t cell,
int (recv_callback)(void*, cf_t*[SRSLTE_MAX_PORTS], uint32_t,srslte_timestamp_t*),
uint32_t nof_rx_antennas,
void *stream_handler,
int decimate)
{
int ret = SRSLTE_ERROR_INVALID_INPUTS;
@ -138,7 +150,7 @@ int srslte_ue_sync_init_multi(srslte_ue_sync_t *q,
recv_callback != NULL)
{
ret = SRSLTE_ERROR;
int decimate = q->decimate;
//int decimate = q->decimate;
bzero(q, sizeof(srslte_ue_sync_t));
q->decimate = decimate;
q->stream = stream_handler;
@ -170,16 +182,13 @@ int srslte_ue_sync_init_multi(srslte_ue_sync_t *q,
q->frame_len = q->nof_recv_sf*q->sf_len;
if(q->fft_size > 700 && q->decimate)
if(q->fft_size < 700 && q->decimate)
{
q->sfind.decimate = q->decimate;
}
else
{
q->sfind.decimate = 1;
q->decimate = 1;
}
if(srslte_sync_init(&q->sfind, q->frame_len, q->frame_len, q->fft_size)) {
if(srslte_sync_init_decim(&q->sfind, q->frame_len, q->frame_len, q->fft_size,q->decimate)) {
fprintf(stderr, "Error initiating sync find\n");
goto clean_exit;
}