master
Ismael Gomez 7 years ago
parent 58f204d94a
commit bd258372ea

@ -399,35 +399,41 @@ uint32_t srslte_pbch_crc_check(srslte_pbch_t *q, uint8_t *bits, uint32_t nof_por
int decode_frame(srslte_pbch_t *q, uint32_t src, uint32_t dst, uint32_t n,
uint32_t nof_bits, uint32_t nof_ports) {
int j;
memcpy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits],
n * nof_bits * sizeof(float));
/* descramble */
srslte_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits,
n * nof_bits);
if (dst + n <= 4 && src + n <= 4) {
memcpy(&q->temp[dst * nof_bits], &q->llr[src * nof_bits],
n * nof_bits * sizeof(float));
for (j = 0; j < dst * nof_bits; j++) {
q->temp[j] = SRSLTE_RX_NULL;
}
for (j = (dst + n) * nof_bits; j < 4 * nof_bits; j++) {
q->temp[j] = SRSLTE_RX_NULL;
}
/* descramble */
srslte_scrambling_f_offset(&q->seq, &q->temp[dst * nof_bits], dst * nof_bits,
n * nof_bits);
/* unrate matching */
srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, SRSLTE_BCH_ENCODED_LEN);
/* Normalize LLR */
srslte_vec_sc_prod_fff(q->rm_f, 1.0/((float) 2*n), q->rm_f, SRSLTE_BCH_ENCODED_LEN);
/* decode */
srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSLTE_BCH_PAYLOADCRC_LEN);
for (j = 0; j < dst * nof_bits; j++) {
q->temp[j] = SRSLTE_RX_NULL;
}
for (j = (dst + n) * nof_bits; j < 4 * nof_bits; j++) {
q->temp[j] = SRSLTE_RX_NULL;
}
/* unrate matching */
srslte_rm_conv_rx(q->temp, 4 * nof_bits, q->rm_f, SRSLTE_BCH_ENCODED_LEN);
if (!srslte_pbch_crc_check(q, q->data, nof_ports)) {
return 1;
/* Normalize LLR */
srslte_vec_sc_prod_fff(q->rm_f, 1.0/((float) 2*n), q->rm_f, SRSLTE_BCH_ENCODED_LEN);
/* decode */
srslte_viterbi_decode_f(&q->decoder, q->rm_f, q->data, SRSLTE_BCH_PAYLOADCRC_LEN);
if (!srslte_pbch_crc_check(q, q->data, nof_ports)) {
return 1;
} else {
return SRSLTE_SUCCESS;
}
} else {
return SRSLTE_SUCCESS;
fprintf(stderr, "Error in PBCH decoder: Invalid frame pointers dst=%d, src=%d, n=%d\n", src, dst, n);
return -1;
}
}
/* Decodes the PBCH channel
@ -514,7 +520,7 @@ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRS
for (nb = 0; nb < q->frame_idx; nb++) {
for (dst = 0; (dst < 4 - nb); dst++) {
for (src = 0; src < q->frame_idx - nb; src++) {
ret = decode_frame(q, src, dst, nb + 1, nof_bits, nant);
ret = decode_frame(q, src, dst, nb + 1, nof_bits, nant);
if (ret == 1) {
if (sfn_offset) {
*sfn_offset = (int) dst - src + q->frame_idx - 1;
@ -526,15 +532,16 @@ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRS
memcpy(bch_payload, q->data, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN);
}
INFO("Decoded PBCH: src=%d, dst=%d, nb=%d, sfn_offset=%d\n", src, dst, nb+1, (int) dst - src + q->frame_idx - 1);
return 1;
srslte_pbch_decode_reset(q);
return 1;
}
}
}
}
}
nant++;
} while(nant <= q->cell.nof_ports);
} while(nant <= q->cell.nof_ports);
/* If not found, make room for the next packet of radio frame symbols */
if (q->frame_idx == 4) {
memmove(q->llr, &q->llr[nof_bits], nof_bits * 3 * sizeof(float));

Loading…
Cancel
Save