Fixed bug in pbch_encode

master
Ismael Gomez 9 years ago
parent 8ee9b32c7a
commit c54481e0e1

@ -576,7 +576,7 @@ int main(int argc, char **argv) {
srslte_pbch_mib_pack(&cell, sfn, bch_payload); srslte_pbch_mib_pack(&cell, sfn, bch_payload);
if (sf_idx == 0) { if (sf_idx == 0) {
srslte_pbch_encode(&pbch, bch_payload, slot1_symbols); srslte_pbch_encode(&pbch, bch_payload, slot1_symbols, nf%4);
} }
srslte_pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx); srslte_pcfich_encode(&pcfich, cfi, sf_symbols, sf_idx);

@ -98,7 +98,8 @@ SRSLTE_API int srslte_pbch_decode(srslte_pbch_t *q,
SRSLTE_API int srslte_pbch_encode(srslte_pbch_t *q, SRSLTE_API int srslte_pbch_encode(srslte_pbch_t *q,
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN],
cf_t *slot1_symbols[SRSLTE_MAX_PORTS]); cf_t *slot1_symbols[SRSLTE_MAX_PORTS],
uint32_t frame_idx);
SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t *q); SRSLTE_API void srslte_pbch_decode_reset(srslte_pbch_t *q);

@ -35,6 +35,7 @@
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/dft/dft_precoding.h"
#include "srslte/ch_estimation/chest_ul.h" #include "srslte/ch_estimation/chest_ul.h"
#include "srslte/utils/vector.h" #include "srslte/utils/vector.h"
#include "srslte/utils/convolution.h" #include "srslte/utils/convolution.h"
@ -209,6 +210,11 @@ int srslte_chest_ul_estimate(srslte_chest_ul_t *q, cf_t *input, cf_t *ce,
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (!srslte_dft_precoding_valid_prb(nof_prb)) {
fprintf(stderr, "Error invalid nof_prb=%d\n", nof_prb);
return SRSLTE_ERROR_INVALID_INPUTS;
}
int nrefs_sym = nof_prb*SRSLTE_NRE; int nrefs_sym = nof_prb*SRSLTE_NRE;
int nrefs_sf = nrefs_sym*2; int nrefs_sf = nrefs_sym*2;

@ -177,7 +177,7 @@ void srslte_enb_dl_put_mib(srslte_enb_dl_t *q, uint32_t tti)
{ {
if ((tti%10) == 0) { if ((tti%10) == 0) {
srslte_pbch_mib_pack(&q->cell, tti/10, q->bch_payload); srslte_pbch_mib_pack(&q->cell, tti/10, q->bch_payload);
srslte_pbch_encode(&q->pbch, q->bch_payload, q->slot1_symbols); srslte_pbch_encode(&q->pbch, q->bch_payload, q->slot1_symbols, ((tti/10)%4));
} }
} }

@ -514,7 +514,7 @@ int srslte_pbch_decode(srslte_pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[SRS
/** Converts the MIB message to symbols mapped to SLOT #1 ready for transmission /** Converts the MIB message to symbols mapped to SLOT #1 ready for transmission
*/ */
int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS]) { int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN], cf_t *slot1_symbols[SRSLTE_MAX_PORTS], uint32_t frame_idx) {
int i; int i;
int nof_bits; int nof_bits;
cf_t *x[SRSLTE_MAX_LAYERS]; cf_t *x[SRSLTE_MAX_LAYERS];
@ -536,7 +536,9 @@ int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
if (q->frame_idx == 0) { frame_idx=frame_idx%4;
if (frame_idx == 0) {
memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN); memcpy(q->data, bch_payload, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN);
/* encode & modulate */ /* encode & modulate */
@ -548,9 +550,9 @@ int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_
srslte_rm_conv_tx(q->data_enc, SRSLTE_BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits); srslte_rm_conv_tx(q->data_enc, SRSLTE_BCH_ENCODED_LEN, q->rm_b, 4 * nof_bits);
} }
srslte_scrambling_b_offset(&q->seq, &q->rm_b[q->frame_idx * nof_bits], srslte_scrambling_b_offset(&q->seq, &q->rm_b[frame_idx * nof_bits],
q->frame_idx * nof_bits, nof_bits); frame_idx * nof_bits, nof_bits);
srslte_mod_modulate(&q->mod, &q->rm_b[q->frame_idx * nof_bits], q->d, srslte_mod_modulate(&q->mod, &q->rm_b[frame_idx * nof_bits], q->d,
nof_bits); nof_bits);
/* layer mapping & precoding */ /* layer mapping & precoding */
@ -566,10 +568,6 @@ int srslte_pbch_encode(srslte_pbch_t *q, uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
srslte_pbch_put(q->symbols[i], slot1_symbols[i], q->cell); srslte_pbch_put(q->symbols[i], slot1_symbols[i], q->cell);
} }
q->frame_idx++;
if (q->frame_idx == 4) {
q->frame_idx = 0;
}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} else { } else {
return SRSLTE_ERROR_INVALID_INPUTS; return SRSLTE_ERROR_INVALID_INPUTS;

@ -114,7 +114,7 @@ int main(int argc, char **argv) {
bch_payload_tx[i] = rand()%2; bch_payload_tx[i] = rand()%2;
} }
srslte_pbch_encode(&pbch, bch_payload_tx, slot1_symbols); srslte_pbch_encode(&pbch, bch_payload_tx, slot1_symbols, 0);
/* combine outputs */ /* combine outputs */
for (i=1;i<cell.nof_ports;i++) { for (i=1;i<cell.nof_ports;i++) {

Loading…
Cancel
Save