Cleaned viterbi. Reduced number of symbols in CP-based CFO estmation

master
ismagom 9 years ago
parent 9b8709f744
commit fbaa559e37

@ -2,7 +2,7 @@
clear clear
blen=40; blen=40;
SNR_values_db=linspace(-3,4,8); SNR_values_db=linspace(-3,4,8);
Nrealizations=6000; Nrealizations=50000;
addpath('../../build/srslte/lib/fec/test') addpath('../../build/srslte/lib/fec/test')

@ -38,11 +38,12 @@
#define DEB 0 #define DEB 0
#define TB_ITER 3
//#undef LV_HAVE_SSE //#undef LV_HAVE_SSE
int decode37(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) { int decode37(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) {
srslte_viterbi_t *q = o; srslte_viterbi_t *q = o;
uint32_t i;
uint32_t best_state; uint32_t best_state;
@ -56,23 +57,18 @@ int decode37(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) {
init_viterbi37_port(q->ptr, q->tail_biting ? -1 : 0); init_viterbi37_port(q->ptr, q->tail_biting ? -1 : 0);
/* Decode block */ /* Decode block */
uint8_t *tmp = q->tmp;
if (q->tail_biting) { if (q->tail_biting) {
memcpy(tmp, symbols, 3 * frame_length * sizeof(uint8_t)); for (int i=0;i<TB_ITER;i++) {
for (i = 0; i < 3 * (q->K - 1); i++) { memcpy(&q->tmp[i*3*frame_length], symbols, 3*frame_length*sizeof(uint8_t));
q->tmp[i + 3 * frame_length] = q->tmp[i];
} }
update_viterbi37_blk_port(q->ptr, q->tmp, TB_ITER*frame_length, &best_state);
chainback_viterbi37_port(q->ptr, q->tmp, TB_ITER*frame_length, best_state);
memcpy(data, &q->tmp[((int) (TB_ITER/2))*frame_length], frame_length*sizeof(uint8_t));
} else { } else {
tmp = symbols; update_viterbi37_blk_port(q->ptr, symbols, frame_length + q->K - 1, NULL);
chainback_viterbi37_port(q->ptr, data, frame_length, 0);
} }
update_viterbi37_blk_port(q->ptr, tmp, frame_length + q->K - 1,
q->tail_biting ? &best_state : NULL);
/* Do Viterbi chainback */
chainback_viterbi37_port(q->ptr, data, frame_length,
q->tail_biting ? best_state : 0);
return q->framebits; return q->framebits;
} }
@ -90,21 +86,20 @@ int decode37_sse(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length
} }
/* Initialize Viterbi decoder */ /* Initialize Viterbi decoder */
init_viterbi37_sse(q->ptr, -1); init_viterbi37_sse(q->ptr, q->tail_biting?-1:0);
/* Decode block */ /* Decode block */
if (q->tail_biting) { if (q->tail_biting) {
memcpy(q->tmp, symbols, 3*frame_length*sizeof(uint8_t)); for (int i=0;i<TB_ITER;i++) {
memcpy(&q->tmp[3*frame_length], symbols, 3*frame_length*sizeof(uint8_t)); memcpy(&q->tmp[i*3*frame_length], symbols, 3*frame_length*sizeof(uint8_t));
memcpy(&q->tmp[6*frame_length], symbols, 3*frame_length*sizeof(uint8_t)); }
update_viterbi37_blk_sse(q->ptr, q->tmp, 3*frame_length, &best_state); update_viterbi37_blk_sse(q->ptr, q->tmp, TB_ITER*frame_length, &best_state);
chainback_viterbi37_sse(q->ptr, q->tmp, 3*frame_length, best_state); chainback_viterbi37_sse(q->ptr, q->tmp, TB_ITER*frame_length, best_state);
memcpy(data, &q->tmp[frame_length], frame_length*sizeof(uint8_t)); memcpy(data, &q->tmp[((int) (TB_ITER/2))*frame_length], frame_length*sizeof(uint8_t));
} else { } else {
update_viterbi37_blk_sse(q->ptr, symbols, frame_length+q->K-1, &best_state); update_viterbi37_blk_sse(q->ptr, symbols, frame_length+q->K-1, &best_state);
chainback_viterbi37_sse(q->ptr, data, frame_length, best_state); chainback_viterbi37_sse(q->ptr, data, frame_length, best_state);
} }
return q->framebits; return q->framebits;
} }
@ -148,7 +143,7 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_
return -1; return -1;
} }
if (q->tail_biting) { if (q->tail_biting) {
q->tmp = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t)); q->tmp = srslte_vec_malloc(TB_ITER * 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
bzero(q->tmp, 3 * (q->framebits + q->K - 1) * sizeof(uint8_t)); bzero(q->tmp, 3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->tmp) { if (!q->tmp) {
perror("malloc"); perror("malloc");
@ -159,7 +154,7 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_
q->tmp = NULL; q->tmp = NULL;
} }
if ((q->ptr = create_viterbi37_port(poly, framebits)) == NULL) { if ((q->ptr = create_viterbi37_port(poly, TB_ITER*framebits)) == NULL) {
fprintf(stderr, "create_viterbi37 failed\n"); fprintf(stderr, "create_viterbi37 failed\n");
free37(q); free37(q);
return -1; return -1;
@ -184,7 +179,7 @@ int init37_sse(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool t
return -1; return -1;
} }
if (q->tail_biting) { if (q->tail_biting) {
q->tmp = srslte_vec_malloc(10 * (q->framebits + q->K - 1) * sizeof(uint8_t)); q->tmp = srslte_vec_malloc(TB_ITER*3*(q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->tmp) { if (!q->tmp) {
perror("malloc"); perror("malloc");
free37(q); free37(q);
@ -194,7 +189,7 @@ int init37_sse(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool t
q->tmp = NULL; q->tmp = NULL;
} }
if ((q->ptr = create_viterbi37_sse(poly, 3*framebits)) == NULL) { if ((q->ptr = create_viterbi37_sse(poly, TB_ITER*framebits)) == NULL) {
fprintf(stderr, "create_viterbi37 failed\n"); fprintf(stderr, "create_viterbi37 failed\n");
free37(q); free37(q);
return -1; return -1;

@ -51,6 +51,9 @@ void *create_viterbi37_sse(uint32_t polys[3],
int init_viterbi37_sse(void *p, int init_viterbi37_sse(void *p,
int starting_state); int starting_state);
void reset_blk_sse(void *p, int nbits);
int chainback_viterbi37_sse(void *p, int chainback_viterbi37_sse(void *p,
uint8_t *data, uint8_t *data,
uint32_t nbits, uint32_t nbits,

@ -213,7 +213,7 @@ int main(int argc, char **argv) {
gettimeofday(&t[1], NULL); gettimeofday(&t[1], NULL);
int M = 1; int M = 1;
//srslte_vec_fprint_b(stdout, data_tx, frame_length); srslte_vec_fprint_b(stdout, data_tx, frame_length);
for (int i=0;i<M;i++) { for (int i=0;i<M;i++) {
srslte_viterbi_decode_uc(&dec, llr_c, data_rx, frame_length); srslte_viterbi_decode_uc(&dec, llr_c, data_rx, frame_length);

@ -306,7 +306,6 @@ int srslte_pss_synch_find_pss(srslte_pss_synch_t *q, cf_t *input, float *corr_pe
if (q->frame_size >= q->fft_size) { if (q->frame_size >= q->fft_size) {
#ifdef CONVOLUTION_FFT #ifdef CONVOLUTION_FFT
memcpy(q->tmp_input, input, q->frame_size * sizeof(cf_t)); memcpy(q->tmp_input, input, q->frame_size * sizeof(cf_t));
conv_output_len = srslte_conv_fft_cc_run(&q->conv_fft, q->tmp_input, q->pss_signal_time[q->N_id_2], q->conv_output); conv_output_len = srslte_conv_fft_cc_run(&q->conv_fft, q->tmp_input, q->pss_signal_time[q->N_id_2], q->conv_output);
#else #else
conv_output_len = srslte_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); conv_output_len = srslte_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size);

@ -350,7 +350,7 @@ srslte_pss_synch_t* srslte_sync_get_cur_pss_obj(srslte_sync_t *q) {
static float cfo_estimate(srslte_sync_t *q, cf_t *input) { static float cfo_estimate(srslte_sync_t *q, cf_t *input) {
uint32_t cp_offset = 0; uint32_t cp_offset = 0;
cp_offset = srslte_cp_synch(&q->cp_synch, input, q->max_offset, q->nof_symbols, SRSLTE_CP_LEN_NORM(1,q->fft_size)); cp_offset = srslte_cp_synch(&q->cp_synch, input, q->max_offset, 2, SRSLTE_CP_LEN_NORM(1,q->fft_size));
cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset); cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset);
float cfo = -carg(cp_corr_max) / M_PI / 2; float cfo = -carg(cp_corr_max) / M_PI / 2;
return cfo; return cfo;
@ -418,10 +418,9 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, cf_t *input, uint32_t
q->mean_cfo = SRSLTE_VEC_EMA(cfo, q->mean_cfo, q->cfo_ema_alpha); q->mean_cfo = SRSLTE_VEC_EMA(cfo, q->mean_cfo, q->cfo_ema_alpha);
/* Correct CFO with the averaged CFO estimation */ /* Correct CFO with the averaged CFO estimation */
srslte_cfo_correct(&q->cfocorr, input, input, -q->mean_cfo / q->fft_size); srslte_cfo_correct(&q->cfocorr, input, input, -q->mean_cfo / q->fft_size);
} }
/* If integer CFO is enabled, find max PSS correlation for shifted +1/0/-1 integer versions */ /* If integer CFO is enabled, find max PSS correlation for shifted +1/0/-1 integer versions */
if (q->find_cfo_i && q->enable_cfo_corr) { if (q->find_cfo_i && q->enable_cfo_corr) {
q->cfo_i = cfo_i_estimate(q, input, find_offset, &peak_pos); q->cfo_i = cfo_i_estimate(q, input, find_offset, &peak_pos);

@ -528,6 +528,7 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t *q, cf_t *input_buffer) {
break; break;
case SRSLTE_SYNC_FOUND_NOSPACE: case SRSLTE_SYNC_FOUND_NOSPACE:
/* If a peak was found but there is not enough space for SSS/CP detection, discard a few samples */ /* If a peak was found but there is not enough space for SSS/CP detection, discard a few samples */
printf("No space for SSS/CP detection. Realigning frame...\n");
q->recv_callback(q->stream, dummy_offset_buffer, q->frame_len/2, NULL); q->recv_callback(q->stream, dummy_offset_buffer, q->frame_len/2, NULL);
srslte_sync_reset(&q->sfind); srslte_sync_reset(&q->sfind);
ret = SRSLTE_SUCCESS; ret = SRSLTE_SUCCESS;

Loading…
Cancel
Save