int init_sequence(sequence_t *seq, char *name) { if (!strcmp(name, "PBCH")) { return sequence_pbch(seq, cp, cell_id); } else { fprintf(stderr, "Unsupported sequence name %s\n", name); return -1; } }
int compute_sequences(scrambling_hl* h) { switch (h->init.channel) { case PBCH: return sequence_pbch(&h->obj.seq[0], h->init.nof_symbols == CPNORM_NSYMB, h->init.cell_id); case PDSCH: case PCFICH: case PDCCH: case PMCH: case PUCCH: fprintf(stderr, "Not implemented\n"); return -1; default: fprintf(stderr, "Invalid channel %d\n", h->init.channel); return -1; } }
/** Initializes the PBCH transmitter and receiver. * At the receiver, the field nof_ports in the cell structure indicates the * maximum number of BS transmitter ports to look for. */ int pbch_init(pbch_t *q, lte_cell_t cell) { int ret = LIBLTE_ERROR_INVALID_INPUTS; if (q != NULL && lte_cell_isvalid(&cell)) { ret = LIBLTE_ERROR; bzero(q, sizeof(pbch_t)); q->cell = cell; if (modem_table_lte(&q->mod, LTE_QPSK, true)) { goto clean; } demod_soft_init(&q->demod); demod_soft_table_set(&q->demod, &q->mod); demod_soft_alg_set(&q->demod, APPROX); if (sequence_pbch(&q->seq_pbch, q->cell.cp, q->cell.id)) { goto clean; } uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; if (viterbi_init(&q->decoder, viterbi_37, poly, 40, true)) { goto clean; } if (crc_init(&q->crc, LTE_CRC16, 16)) { goto clean; } q->encoder.K = 7; q->encoder.R = 3; q->encoder.tail_biting = true; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); q->nof_symbols = (CP_ISNORM(q->cell.cp)) ? PBCH_RE_CPNORM : PBCH_RE_CPEXT; q->pbch_d = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_d) { goto clean; } int i; for (i = 0; i < q->cell.nof_ports; i++) { q->ce[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->ce[i]) { goto clean; } q->pbch_x[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_x[i]) { goto clean; } q->pbch_symbols[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_symbols[i]) { goto clean; } } q->pbch_llr = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->pbch_llr) { goto clean; } q->temp = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->temp) { goto clean; } q->pbch_rm_f = malloc(sizeof(float) * 120); if (!q->pbch_rm_f) { goto clean; } q->pbch_rm_b = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->pbch_rm_b) { goto clean; } q->data = malloc(sizeof(char) * 40); if (!q->data) { goto clean; } q->data_enc = malloc(sizeof(char) * 120); if (!q->data_enc) { goto clean; } ret = LIBLTE_SUCCESS; } clean: if (ret == LIBLTE_ERROR) { pbch_free(q); } return ret; }
/** Initializes the PBCH transmitter and receiver */ int pbch_init(pbch_t *q, int nof_prb, int cell_id, lte_cp_t cp) { int ret = -1; if (cell_id < 0) { return -1; } bzero(q, sizeof(pbch_t)); q->cell_id = cell_id; q->cp = cp; q->nof_prb = nof_prb; if (modem_table_std(&q->mod, LTE_QPSK, true)) { goto clean; } demod_soft_init(&q->demod); demod_soft_table_set(&q->demod, &q->mod); demod_soft_alg_set(&q->demod, APPROX); if (sequence_pbch(&q->seq_pbch, q->cp, q->cell_id)) { goto clean; } int poly[3] = { 0x6D, 0x4F, 0x57 }; if (viterbi_init(&q->decoder, viterbi_37, poly, 40, true)) { goto clean; } if (crc_init(&q->crc, LTE_CRC16, 16)) { goto clean; } q->encoder.K = 7; q->encoder.R = 3; q->encoder.tail_biting = true; memcpy(q->encoder.poly, poly, 3 * sizeof(int)); q->nof_symbols = (CP_ISNORM(q->cp)) ? PBCH_RE_CPNORM : PBCH_RE_CPEXT; q->pbch_d = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_d) { goto clean; } int i; for (i = 0; i < MAX_PORTS_CTRL; i++) { q->ce[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->ce[i]) { goto clean; } q->pbch_x[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_x[i]) { goto clean; } q->pbch_symbols[i] = malloc(sizeof(cf_t) * q->nof_symbols); if (!q->pbch_symbols[i]) { goto clean; } } q->pbch_llr = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->pbch_llr) { goto clean; } q->temp = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->temp) { goto clean; } q->pbch_rm_f = malloc(sizeof(float) * 120); if (!q->pbch_rm_f) { goto clean; } q->pbch_rm_b = malloc(sizeof(float) * q->nof_symbols * 4 * 2); if (!q->pbch_rm_b) { goto clean; } q->data = malloc(sizeof(char) * 40); if (!q->data) { goto clean; } q->data_enc = malloc(sizeof(char) * 120); if (!q->data_enc) { goto clean; } ret = 0; clean: if (ret == -1) { pbch_free(q); } return ret; }