srsLTE/srslte/lib/phch/src/pdsch.c

516 lines
16 KiB
C
Raw Normal View History

/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <math.h>
#include "prb_dl.h"
#include "srslte/phch/pdsch.h"
#include "srslte/common/phy_common.h"
#include "srslte/utils/bit.h"
#include "srslte/utils/debug.h"
#include "srslte/utils/vector.h"
2015-03-18 05:59:29 -07:00
#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
2015-03-18 05:59:29 -07:00
const static srslte_mod_t modulations[4] =
2015-03-18 11:14:24 -07:00
{ SRSLTE_MOD_BPSK, SRSLTE_MOD_QPSK, SRSLTE_MOD_16QAM, SRSLTE_MOD_64QAM };
//#define DEBUG_IDX
#ifdef DEBUG_IDX
cf_t *offset_original=NULL;
extern int indices[100000];
extern int indices_ptr;
#endif
int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_alloc_t *prb_alloc,
uint32_t nsubframe, bool put) {
uint32_t s, n, l, lp, lstart, lend, nof_refs;
2014-06-17 07:32:19 -07:00
bool is_pbch, is_sss;
cf_t *in_ptr = input, *out_ptr = output;
uint32_t offset = 0;
2014-06-17 07:32:19 -07:00
INFO("%s %d RE from %d PRB\n", put ? "Putting" : "Getting",
2014-06-17 07:32:19 -07:00
prb_alloc->re_sf[nsubframe], prb_alloc->slot[0].nof_prb);
#ifdef DEBUG_IDX
indices_ptr = 0;
if (put) {
offset_original = output;
} else {
offset_original = input;
}
#endif
if (q->cell.nof_ports == 1) {
2014-06-17 07:32:19 -07:00
nof_refs = 2;
} else {
nof_refs = 4;
}
for (s = 0; s < 2; s++) {
2015-03-18 05:59:29 -07:00
for (l = 0; l < SRSLTE_CP_NSYMB(q->cell.cp); l++) {
for (n = 0; n < q->cell.nof_prb; n++) {
// If this PRB is assigned
if (prb_alloc->slot[s].prb_idx[n]) {
if (s == 0) {
lstart = prb_alloc->lstart;
} else {
lstart = 0;
2014-06-17 07:32:19 -07:00
}
2015-03-18 05:59:29 -07:00
lend = SRSLTE_CP_NSYMB(q->cell.cp);
is_pbch = is_sss = false;
// Skip PSS/SSS signals
if (s == 0 && (nsubframe == 0 || nsubframe == 5)) {
if (n >= q->cell.nof_prb / 2 - 3
&& n < q->cell.nof_prb / 2 + 3) {
2015-03-18 05:59:29 -07:00
lend = SRSLTE_CP_NSYMB(q->cell.cp) - 2;
is_sss = true;
}
2014-06-17 07:32:19 -07:00
}
// Skip PBCH
if (s == 1 && nsubframe == 0) {
if (n >= q->cell.nof_prb / 2 - 3
&& n < q->cell.nof_prb / 2 + 3) {
lstart = 4;
is_pbch = true;
2014-06-17 07:32:19 -07:00
}
}
2015-03-18 05:59:29 -07:00
lp = l + s * SRSLTE_CP_NSYMB(q->cell.cp);
if (put) {
out_ptr = &output[(lp * q->cell.nof_prb + n)
2015-03-18 05:59:29 -07:00
* SRSLTE_NRE];
2014-06-17 07:32:19 -07:00
} else {
in_ptr = &input[(lp * q->cell.nof_prb + n)
2015-03-18 05:59:29 -07:00
* SRSLTE_NRE];
2014-06-17 07:32:19 -07:00
}
// This is a symbol in a normal PRB with or without references
if (l >= lstart && l < lend) {
2015-03-18 05:59:29 -07:00
if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
if (nof_refs == 2 && l != 0) {
offset = q->cell.id % 3 + 3;
} else {
offset = q->cell.id % 3;
}
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs, put);
} else {
prb_cp(&in_ptr, &out_ptr, 1);
}
}
// This is a symbol in a PRB with PBCH or Synch signals (SS).
// If the number or total PRB is odd, half of the the PBCH or SS will fall into the symbol
if ((q->cell.nof_prb % 2) && ((is_pbch && l < lstart) || (is_sss && l >= lend))) {
if (n == q->cell.nof_prb / 2 - 3) {
2015-03-18 05:59:29 -07:00
if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put);
} else {
prb_cp_half(&in_ptr, &out_ptr, 1);
}
} else if (n == q->cell.nof_prb / 2 + 3) {
if (put) {
out_ptr += 6;
} else {
in_ptr += 6;
}
2015-03-18 05:59:29 -07:00
if (SRSLTE_SYMBOL_HAS_REF(l, q->cell.cp, q->cell.nof_ports)) {
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, nof_refs/2, put);
} else {
prb_cp_half(&in_ptr, &out_ptr, 1);
}
}
2014-06-17 07:32:19 -07:00
}
}
}
2014-06-17 07:32:19 -07:00
}
}
int r;
2014-06-17 07:32:19 -07:00
if (put) {
r = abs((int) (input - in_ptr));
2014-06-17 07:32:19 -07:00
} else {
r = abs((int) (output - out_ptr));
2014-06-17 07:32:19 -07:00
}
return r;
}
/**
* Puts PDSCH in slot number 1
*
* Returns the number of symbols written to sf_symbols
*
* 36.211 10.3 section 6.3.5
*/
2015-03-18 11:14:24 -07:00
int srslte_pdsch_put(srslte_pdsch_t *q, cf_t *symbols, cf_t *sf_symbols,
srslte_ra_dl_alloc_t *prb_alloc, uint32_t subframe) {
2015-03-18 11:14:24 -07:00
return srslte_pdsch_cp(q, symbols, sf_symbols, prb_alloc, subframe, true);
}
/**
* Extracts PDSCH from slot number 1
*
* Returns the number of symbols written to PDSCH
*
* 36.211 10.3 section 6.3.5
*/
2015-03-18 11:14:24 -07:00
int srslte_pdsch_get(srslte_pdsch_t *q, cf_t *sf_symbols, cf_t *symbols,
srslte_ra_dl_alloc_t *prb_alloc, uint32_t subframe) {
2015-03-18 11:14:24 -07:00
return srslte_pdsch_cp(q, sf_symbols, symbols, prb_alloc, subframe, false);
}
/** Initializes the PDCCH transmitter and receiver */
2015-03-18 11:14:24 -07:00
int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) {
int ret = SRSLTE_ERROR_INVALID_INPUTS;
2014-06-17 07:32:19 -07:00
int i;
if (q != NULL &&
2015-03-18 05:59:29 -07:00
srslte_cell_isvalid(&cell))
{
2015-03-18 11:14:24 -07:00
bzero(q, sizeof(srslte_pdsch_t));
ret = SRSLTE_ERROR;
q->cell = cell;
q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp);
2014-06-17 07:32:19 -07:00
INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports,
q->cell.nof_prb, q->max_re);
2014-06-17 07:32:19 -07:00
2015-03-18 11:14:24 -07:00
if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) {
fprintf(stderr, "Error initializing precoding\n");
goto clean;
}
for (i = 0; i < 4; i++) {
2015-03-18 11:14:24 -07:00
if (srslte_modem_table_lte(&q->mod[i], modulations[i], true)) {
goto clean;
}
}
2014-06-17 07:32:19 -07:00
2015-03-18 11:14:24 -07:00
srslte_demod_soft_init(&q->demod, q->max_re);
srslte_demod_soft_alg_set(&q->demod, SRSLTE_DEMOD_SOFT_ALG_APPROX);
2015-03-18 11:14:24 -07:00
srslte_sch_init(&q->dl_sch);
q->rnti_is_set = false;
// Allocate floats for reception (LLRs)
2015-03-18 11:14:24 -07:00
q->e = srslte_vec_malloc(sizeof(float) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM));
if (!q->e) {
2014-06-17 07:32:19 -07:00
goto clean;
}
2015-03-18 11:14:24 -07:00
q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
if (!q->d) {
2014-06-17 07:32:19 -07:00
goto clean;
}
for (i = 0; i < q->cell.nof_ports; i++) {
2015-03-18 11:14:24 -07:00
q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
if (!q->ce[i]) {
goto clean;
}
2015-03-18 11:14:24 -07:00
q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
if (!q->x[i]) {
goto clean;
}
2015-03-18 11:14:24 -07:00
q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re);
if (!q->symbols[i]) {
goto clean;
}
}
ret = SRSLTE_SUCCESS;
}
clean:
if (ret == SRSLTE_ERROR) {
2015-03-18 11:14:24 -07:00
srslte_pdsch_free(q);
2014-06-17 07:32:19 -07:00
}
return ret;
}
2015-03-18 11:14:24 -07:00
void srslte_pdsch_free(srslte_pdsch_t *q) {
2014-06-17 07:32:19 -07:00
int i;
2015-03-18 11:14:24 -07:00
if (q->e) {
free(q->e);
2014-06-17 07:32:19 -07:00
}
2015-03-18 11:14:24 -07:00
if (q->d) {
free(q->d);
2014-06-17 07:32:19 -07:00
}
for (i = 0; i < q->cell.nof_ports; i++) {
2014-06-17 07:32:19 -07:00
if (q->ce[i]) {
free(q->ce[i]);
}
2015-03-18 11:14:24 -07:00
if (q->x[i]) {
free(q->x[i]);
2014-06-17 07:32:19 -07:00
}
2015-03-18 11:14:24 -07:00
if (q->symbols[i]) {
free(q->symbols[i]);
2014-06-17 07:32:19 -07:00
}
}
2015-03-18 05:41:50 -07:00
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
2015-03-18 11:14:24 -07:00
srslte_sequence_free(&q->seq[i]);
2014-06-17 07:32:19 -07:00
}
for (i = 0; i < 4; i++) {
2015-03-18 11:14:24 -07:00
srslte_modem_table_free(&q->mod[i]);
2014-06-17 07:32:19 -07:00
}
2015-03-18 11:14:24 -07:00
srslte_demod_soft_free(&q->demod);
srslte_precoding_free(&q->precoding);
srslte_sch_free(&q->dl_sch);
2015-03-18 11:14:24 -07:00
bzero(q, sizeof(srslte_pdsch_t));
}
2015-03-02 02:11:44 -08:00
/* Precalculate the PUSCH scramble sequences for a given RNTI. This function takes a while
* to execute, so shall be called once the final C-RNTI has been allocated for the session.
2015-03-18 11:14:24 -07:00
* For the connection procedure, use srslte_pusch_encode_rnti() or srslte_pusch_decode_rnti() functions
2015-03-02 02:11:44 -08:00
*/
2015-03-18 11:14:24 -07:00
int srslte_pdsch_set_rnti(srslte_pdsch_t *q, uint16_t rnti) {
uint32_t i;
2015-03-18 05:41:50 -07:00
for (i = 0; i < SRSLTE_NSUBFRAMES_X_FRAME; i++) {
2015-03-18 11:14:24 -07:00
if (srslte_sequence_pdsch(&q->seq[i], rnti, 0, 2 * i, q->cell.id,
q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) {
return SRSLTE_ERROR;
}
}
q->rnti_is_set = true;
q->rnti = rnti;
return SRSLTE_SUCCESS;
}
2014-06-17 07:32:19 -07:00
2015-03-18 11:14:24 -07:00
int srslte_pdsch_decode(srslte_pdsch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS], float noise_estimate, uint8_t *data) {
2015-03-02 02:11:44 -08:00
if (q != NULL &&
sf_symbols != NULL &&
data != NULL &&
harq != NULL)
{
if (q->rnti_is_set) {
2015-03-18 11:14:24 -07:00
return srslte_pdsch_decode_rnti(q, harq, sf_symbols, ce, noise_estimate, q->rnti, data);
2015-03-02 02:11:44 -08:00
} else {
2015-03-18 11:14:24 -07:00
fprintf(stderr, "Must call srslte_pdsch_set_rnti() before calling srslte_pdsch_decode()\n");
return SRSLTE_ERROR;
2015-03-02 02:11:44 -08:00
}
} else {
return SRSLTE_ERROR_INVALID_INPUTS;
2015-03-02 02:11:44 -08:00
}
}
/** Decodes the PDSCH from the received symbols
*/
2015-03-18 11:14:24 -07:00
int srslte_pdsch_decode_rnti(srslte_pdsch_t *q, srslte_harq_t *harq, cf_t *sf_symbols, cf_t *ce[SRSLTE_MAX_PORTS],
2015-03-02 02:11:44 -08:00
float noise_estimate, uint16_t rnti, uint8_t *data)
{
2014-06-17 07:32:19 -07:00
/* Set pointers for layermapping & precoding */
uint32_t i, n;
2015-03-18 05:59:29 -07:00
cf_t *x[SRSLTE_MAX_LAYERS];
if (q != NULL &&
sf_symbols != NULL &&
data != NULL &&
harq != NULL)
{
2015-03-02 02:11:44 -08:00
INFO("Decoding PDSCH SF: %d, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
2015-03-18 05:59:29 -07:00
harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
/* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) {
2015-03-18 11:14:24 -07:00
x[i] = q->x[i];
2015-03-02 02:11:44 -08:00
}
2015-03-18 05:59:29 -07:00
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
2015-03-02 02:11:44 -08:00
/* extract symbols */
2015-03-18 11:14:24 -07:00
n = srslte_pdsch_get(q, sf_symbols, q->symbols[0], &harq->dl_alloc, harq->sf_idx);
2015-03-02 02:11:44 -08:00
if (n != harq->nof_re) {
fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n);
return SRSLTE_ERROR;
2015-03-02 02:11:44 -08:00
}
/* extract channel estimates */
for (i = 0; i < q->cell.nof_ports; i++) {
2015-03-18 11:14:24 -07:00
n = srslte_pdsch_get(q, ce[i], q->ce[i], &harq->dl_alloc, harq->sf_idx);
if (n != harq->nof_re) {
fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n);
return SRSLTE_ERROR;
}
2015-03-02 02:11:44 -08:00
}
/* TODO: only diversity is supported */
if (q->cell.nof_ports == 1) {
/* no need for layer demapping */
2015-03-18 11:14:24 -07:00
srslte_predecoding_single(&q->precoding, q->symbols[0], q->ce[0], q->d,
2015-03-02 02:11:44 -08:00
harq->nof_re, noise_estimate);
} else {
2015-03-18 11:14:24 -07:00
srslte_predecoding_diversity(&q->precoding, q->symbols[0], q->ce, x, q->cell.nof_ports,
2015-03-02 02:11:44 -08:00
harq->nof_re, noise_estimate);
2015-03-18 11:14:24 -07:00
srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports,
2015-03-02 02:11:44 -08:00
harq->nof_re / q->cell.nof_ports);
}
2015-03-02 02:11:44 -08:00
/* demodulate symbols
* The MAX-log-MAP algorithm used in turbo decoding is unsensitive to SNR estimation,
* thus we don't need tot set it in the LLRs normalization
*/
2015-03-18 11:14:24 -07:00
srslte_demod_soft_sigma_set(&q->demod, sqrt(0.5));
srslte_demod_soft_table_set(&q->demod, &q->mod[harq->mcs.mod]);
srslte_demod_soft_demodulate(&q->demod, q->d, q->e, harq->nof_re);
2015-03-02 02:11:44 -08:00
/* descramble */
if (rnti != q->rnti) {
2015-03-18 08:05:38 -07:00
srslte_sequence_t seq;
if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * harq->sf_idx, q->cell.id, harq->nof_bits)) {
return SRSLTE_ERROR;
2015-03-02 02:11:44 -08:00
}
2015-03-18 11:14:24 -07:00
srslte_scrambling_f_offset(&seq, q->e, 0, harq->nof_bits);
2015-03-18 08:05:38 -07:00
srslte_sequence_free(&seq);
2015-03-02 02:11:44 -08:00
} else {
2015-03-18 11:14:24 -07:00
srslte_scrambling_f_offset(&q->seq[harq->sf_idx], q->e, 0, harq->nof_bits);
2015-03-02 02:11:44 -08:00
}
2015-03-18 11:14:24 -07:00
return srslte_dlsch_decode(&q->dl_sch, harq, q->e, data);
2015-03-02 02:11:44 -08:00
} else {
return SRSLTE_ERROR_INVALID_INPUTS;
}
}
2015-03-18 11:14:24 -07:00
int srslte_pdsch_encode(srslte_pdsch_t *q, srslte_harq_t *harq, uint8_t *data, cf_t *sf_symbols[SRSLTE_MAX_PORTS])
2015-03-02 02:11:44 -08:00
{
if (q != NULL &&
data != NULL &&
harq != NULL)
{
if (q->rnti_is_set) {
2015-03-18 11:14:24 -07:00
return srslte_pdsch_encode_rnti(q, harq, data, q->rnti, sf_symbols);
2015-03-02 02:11:44 -08:00
} else {
2015-03-18 11:14:24 -07:00
fprintf(stderr, "Must call srslte_pdsch_set_rnti() to set the encoder/decoder RNTI\n");
return SRSLTE_ERROR;
2015-03-02 02:11:44 -08:00
}
} else {
return SRSLTE_ERROR_INVALID_INPUTS;
2015-03-02 02:11:44 -08:00
}
}
/** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission
*/
2015-03-18 11:14:24 -07:00
int srslte_pdsch_encode_rnti(srslte_pdsch_t *q, srslte_harq_t *harq, uint8_t *data, uint16_t rnti, cf_t *sf_symbols[SRSLTE_MAX_PORTS])
{
2014-06-17 07:32:19 -07:00
int i;
/* Set pointers for layermapping & precoding */
2015-03-18 05:59:29 -07:00
cf_t *x[SRSLTE_MAX_LAYERS];
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL &&
data != NULL &&
harq != NULL)
{
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
for (i=0;i<q->cell.nof_ports;i++) {
if (sf_symbols[i] == NULL) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
2015-03-02 02:11:44 -08:00
}
if (harq->mcs.tbs == 0) {
return SRSLTE_ERROR_INVALID_INPUTS;
2015-03-02 02:11:44 -08:00
}
if (harq->mcs.tbs > harq->nof_bits) {
fprintf(stderr, "Invalid code rate %.2f\n", (float) harq->mcs.tbs / harq->nof_bits);
return SRSLTE_ERROR_INVALID_INPUTS;
2015-03-02 02:11:44 -08:00
}
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
if (harq->nof_re > q->max_re) {
fprintf(stderr,
"Error too many RE per subframe (%d). PDSCH configured for %d RE (%d PRB)\n",
harq->nof_re, q->max_re, q->cell.nof_prb);
return SRSLTE_ERROR_INVALID_INPUTS;
2015-03-02 02:11:44 -08:00
}
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
INFO("Encoding PDSCH SF: %d, Mod %s, NofBits: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n",
2015-03-18 05:59:29 -07:00
harq->sf_idx, srslte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv);
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
/* number of layers equals number of ports */
for (i = 0; i < q->cell.nof_ports; i++) {
2015-03-18 11:14:24 -07:00
x[i] = q->x[i];
2015-03-02 02:11:44 -08:00
}
2015-03-18 05:59:29 -07:00
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (SRSLTE_MAX_LAYERS - q->cell.nof_ports));
2014-06-17 07:32:19 -07:00
2015-03-18 11:14:24 -07:00
if (srslte_dlsch_encode(&q->dl_sch, harq, data, q->e)) {
2015-03-02 02:11:44 -08:00
fprintf(stderr, "Error encoding TB\n");
return SRSLTE_ERROR;
2015-03-02 02:11:44 -08:00
}
if (rnti != q->rnti) {
2015-03-18 08:05:38 -07:00
srslte_sequence_t seq;
if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * harq->sf_idx, q->cell.id, harq->nof_bits)) {
return SRSLTE_ERROR;
}
2015-03-18 11:14:24 -07:00
srslte_scrambling_b_offset(&seq, (uint8_t*) q->e, 0, harq->nof_bits);
2015-03-18 08:05:38 -07:00
srslte_sequence_free(&seq);
2015-03-02 02:11:44 -08:00
} else {
2015-03-18 11:14:24 -07:00
srslte_scrambling_b_offset(&q->seq[harq->sf_idx], (uint8_t*) q->e, 0, harq->nof_bits);
2015-03-02 02:11:44 -08:00
}
2014-06-17 07:32:19 -07:00
2015-03-18 11:14:24 -07:00
srslte_mod_modulate(&q->mod[harq->mcs.mod], (uint8_t*) q->e, q->d, harq->nof_bits);
2014-06-17 07:32:19 -07:00
2015-03-02 02:11:44 -08:00
/* TODO: only diversity supported */
if (q->cell.nof_ports > 1) {
2015-03-18 11:14:24 -07:00
srslte_layermap_diversity(q->d, x, q->cell.nof_ports, harq->nof_re);
srslte_precoding_diversity(&q->precoding, x, q->symbols, q->cell.nof_ports,
2015-03-02 02:11:44 -08:00
harq->nof_re / q->cell.nof_ports);
} else {
2015-03-18 11:14:24 -07:00
memcpy(q->symbols[0], q->d, harq->nof_re * sizeof(cf_t));
}
2015-03-02 02:11:44 -08:00
/* mapping to resource elements */
for (i = 0; i < q->cell.nof_ports; i++) {
2015-03-18 11:14:24 -07:00
srslte_pdsch_put(q, q->symbols[i], sf_symbols[i], &harq->dl_alloc, harq->sf_idx);
2015-03-02 02:11:44 -08:00
}
ret = SRSLTE_SUCCESS;
}
return ret;
}