|
|
@ -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;
|
|
|
|