From c106cd402c004c380ca28fd36aee26e34abafc09 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 16 Mar 2017 20:17:40 +0100 Subject: [PATCH 1/5] minor printf edits --- srslte/lib/phch/dci.c | 2 +- srslte/lib/phch/pdcch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index 3c2f04856..206d2d289 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -1098,7 +1098,7 @@ int srslte_dci_msg_pack_pdsch(srslte_ra_dl_dci_t *data, srslte_dci_format_t form case SRSLTE_DCI_FORMAT1C: return dci_format1Cs_pack(data, msg, nof_prb); default: - fprintf(stderr, "DCI pack pdsch: Invalid DCI format %s in \n", + fprintf(stderr, "DCI pack pdsch: Invalid DCI format %s\n", srslte_dci_format_string(format)); return SRSLTE_ERROR; } diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index 702a5440f..bd3bd2a9a 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -607,7 +607,7 @@ int srslte_pdcch_encode(srslte_pdcch_t *q, srslte_dci_msg_t *msg, srslte_dci_loc ret = SRSLTE_SUCCESS; } else { - fprintf(stderr, "Illegal DCI message nCCE: %d, L: %d, nof_cce: %d\n", location.ncce, location.L, q->nof_cce); + fprintf(stderr, "Illegal DCI message nCCE: %d, L: %d, nof_cce: %d, nof_bits=%d\n", location.ncce, location.L, q->nof_cce, msg->nof_bits); } } else { fprintf(stderr, "Invalid parameters: cfi=%d, L=%d, nCCE=%d\n", cfi, location.L, location.ncce); From 7920b9aa415fd1e096dc609726c0f97204143a62 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 17 Mar 2017 13:20:09 +0100 Subject: [PATCH 2/5] added format2ab to dci pack --- srslte/examples/pdsch_enodeb.c | 2 +- srslte/include/srslte/phch/dci.h | 1 + srslte/lib/enb/enb_dl.c | 2 +- srslte/lib/phch/dci.c | 76 ++++++++++++++++++++++++++++++- srslte/lib/phch/test/pdcch_test.c | 4 +- 5 files changed, 80 insertions(+), 5 deletions(-) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 8a6d3724e..0d3aa6c4a 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -609,7 +609,7 @@ int main(int argc, char **argv) { /* Encode PDCCH */ INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L); - srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_msg, cell.nof_prb, false); + srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_msg, cell.nof_prb, cell.nof_ports, false); if (srslte_pdcch_encode(&pdcch, &dci_msg, locations[sf_idx][0], UE_CRNTI, sf_symbols, sf_idx, cfi)) { fprintf(stderr, "Error encoding DCI message\n"); exit(-1); diff --git a/srslte/include/srslte/phch/dci.h b/srslte/include/srslte/phch/dci.h index dcc8cf215..1bc169f77 100644 --- a/srslte/include/srslte/phch/dci.h +++ b/srslte/include/srslte/phch/dci.h @@ -165,6 +165,7 @@ SRSLTE_API int srslte_dci_msg_pack_pdsch(srslte_ra_dl_dci_t *data, srslte_dci_format_t format, srslte_dci_msg_t *msg, uint32_t nof_prb, + uint32_t nof_ports, bool crc_is_crnti); SRSLTE_API int srslte_dci_msg_unpack_pdsch(srslte_dci_msg_t *msg, diff --git a/srslte/lib/enb/enb_dl.c b/srslte/lib/enb/enb_dl.c index 82fc8491e..33809015d 100644 --- a/srslte/lib/enb/enb_dl.c +++ b/srslte/lib/enb/enb_dl.c @@ -238,7 +238,7 @@ int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant, rnti_is_user = false; } - srslte_dci_msg_pack_pdsch(grant, format, &dci_msg, q->cell.nof_prb, rnti_is_user); + srslte_dci_msg_pack_pdsch(grant, format, &dci_msg, q->cell.nof_prb, q->cell.nof_ports, rnti_is_user); if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) { fprintf(stderr, "Error encoding DCI message\n"); return SRSLTE_ERROR; diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index 206d2d289..9e653e8f5 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -1010,6 +1010,76 @@ int dci_format1D_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_ } +int dci_format2AB_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t nof_prb, uint32_t nof_ports) { + + /* pack bits */ + uint8_t *y = msg->data; + + if (nof_prb > 10) { + *y++ = data->alloc_type; + } + + /* Resource allocation: type0 or type 1 */ + uint32_t P = srslte_ra_type0_P(nof_prb); + uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P); + switch (data->alloc_type) { + case SRSLTE_RA_ALLOC_TYPE0: + srslte_bit_unpack((uint32_t) data->type0_alloc.rbg_bitmask, &y, alloc_size); + break; + case SRSLTE_RA_ALLOC_TYPE1: + srslte_bit_unpack((uint32_t) data->type1_alloc.rbg_subset, &y, (int) ceilf(log2f(P))); + *y++ = data->type1_alloc.shift ? 1 : 0; + srslte_bit_unpack((uint32_t) data->type1_alloc.vrb_bitmask, &y, + alloc_size - (int) ceilf(log2f(P)) - 1); + break; + default: + fprintf(stderr, + "Format 1 accepts type0 or type1 resource allocation only\n"); + return SRSLTE_ERROR; + + } + + // pack TPC command for PUCCH (not implemented) + y+=2; + + /* harq process number */ + srslte_bit_unpack(data->harq_process, &y, harq_pid_len); + + + // Transpor block to codeword swap flag + if (msg->format == SRSLTE_DCI_FORMAT2B) { + *y++ = data->sram_id; + } else { + *y++ = data->tb_cw_swap; + } + + /* pack TB1 */ + srslte_bit_unpack(data->mcs_idx, &y, 5); + *y++ = data->ndi; + srslte_bit_unpack(data->rv_idx, &y, 2); + + /* pack TB2 */ + srslte_bit_unpack(data->mcs_idx_1, &y, 5); + *y++ = data->ndi_1; + srslte_bit_unpack(data->rv_idx_1, &y, 2); + + // Precoding information + if (msg->format == SRSLTE_DCI_FORMAT2A) { + srslte_bit_unpack(data->pinfo, &y, precoding_bits_f2(nof_ports)); + } else if (msg->format == SRSLTE_DCI_FORMAT2A) { + srslte_bit_unpack(data->pinfo, &y, precoding_bits_f2a(nof_ports)); + } + + // Padding with zeros + uint32_t n = srslte_dci_format_sizeof(msg->format, nof_prb, nof_ports); + while (y - msg->data < n) { + *y++ = 0; + } + msg->nof_bits = (y - msg->data); + + return SRSLTE_SUCCESS; +} + int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32_t nof_prb, uint32_t nof_ports) { /* pack bits */ @@ -1086,7 +1156,7 @@ int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 int srslte_dci_msg_pack_pdsch(srslte_ra_dl_dci_t *data, srslte_dci_format_t format, - srslte_dci_msg_t *msg, uint32_t nof_prb, + srslte_dci_msg_t *msg, uint32_t nof_prb, uint32_t nof_ports, bool crc_is_crnti) { msg->format = format; @@ -1097,6 +1167,10 @@ int srslte_dci_msg_pack_pdsch(srslte_ra_dl_dci_t *data, srslte_dci_format_t form return dci_format1As_pack(data, msg, nof_prb, crc_is_crnti); case SRSLTE_DCI_FORMAT1C: return dci_format1Cs_pack(data, msg, nof_prb); + case SRSLTE_DCI_FORMAT2: + case SRSLTE_DCI_FORMAT2A: + case SRSLTE_DCI_FORMAT2B: + return dci_format2AB_pack(data, msg, nof_prb, nof_ports); default: fprintf(stderr, "DCI pack pdsch: Invalid DCI format %s\n", srslte_dci_format_string(format)); diff --git a/srslte/lib/phch/test/pdcch_test.c b/srslte/lib/phch/test/pdcch_test.c index d03532b45..5d4fb0a7c 100644 --- a/srslte/lib/phch/test/pdcch_test.c +++ b/srslte/lib/phch/test/pdcch_test.c @@ -191,11 +191,11 @@ int main(int argc, char **argv) { ra_dl.alloc_type = SRSLTE_RA_ALLOC_TYPE0; ra_dl.type0_alloc.rbg_bitmask = 0x5; - srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_tx[0], cell.nof_prb, false); + srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_tx[0], cell.nof_prb, cell.nof_ports, false); srslte_dci_location_set(&dci_locations[0], 0, 0); ra_dl.mcs_idx = 15; - srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_tx[1], cell.nof_prb, false); + srslte_dci_msg_pack_pdsch(&ra_dl, SRSLTE_DCI_FORMAT1, &dci_tx[1], cell.nof_prb, cell.nof_ports, false); srslte_dci_location_set(&dci_locations[1], 0, 1); for (i=0;i Date: Mon, 20 Mar 2017 09:29:16 +0100 Subject: [PATCH 3/5] fixed format2/2b precoding sizes --- srslte/lib/phch/dci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index 9e653e8f5..df986867d 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -1018,7 +1018,7 @@ int dci_format2AB_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t if (nof_prb > 10) { *y++ = data->alloc_type; } - + /* Resource allocation: type0 or type 1 */ uint32_t P = srslte_ra_type0_P(nof_prb); uint32_t alloc_size = (uint32_t) ceilf((float) nof_prb / P); @@ -1044,7 +1044,6 @@ int dci_format2AB_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t /* harq process number */ srslte_bit_unpack(data->harq_process, &y, harq_pid_len); - // Transpor block to codeword swap flag if (msg->format == SRSLTE_DCI_FORMAT2B) { @@ -1064,19 +1063,21 @@ int dci_format2AB_pack(srslte_ra_dl_dci_t *data, srslte_dci_msg_t *msg, uint32_t srslte_bit_unpack(data->rv_idx_1, &y, 2); // Precoding information - if (msg->format == SRSLTE_DCI_FORMAT2A) { + if (msg->format == SRSLTE_DCI_FORMAT2) { srslte_bit_unpack(data->pinfo, &y, precoding_bits_f2(nof_ports)); } else if (msg->format == SRSLTE_DCI_FORMAT2A) { srslte_bit_unpack(data->pinfo, &y, precoding_bits_f2a(nof_ports)); } - // Padding with zeros + // Padding with zeros uint32_t n = srslte_dci_format_sizeof(msg->format, nof_prb, nof_ports); while (y - msg->data < n) { *y++ = 0; } msg->nof_bits = (y - msg->data); + + return SRSLTE_SUCCESS; } @@ -1143,7 +1144,7 @@ int dci_format2AB_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 } // Precoding information - if (msg->format == SRSLTE_DCI_FORMAT2A) { + if (msg->format == SRSLTE_DCI_FORMAT2) { data->pinfo = srslte_bit_pack(&y, precoding_bits_f2(nof_ports)); } else if (msg->format == SRSLTE_DCI_FORMAT2A) { data->pinfo = srslte_bit_pack(&y, precoding_bits_f2a(nof_ports)); @@ -1162,14 +1163,18 @@ int srslte_dci_msg_pack_pdsch(srslte_ra_dl_dci_t *data, srslte_dci_format_t form msg->format = format; switch (format) { case SRSLTE_DCI_FORMAT1: + msg->format = format; return dci_format1_pack(data, msg, nof_prb); case SRSLTE_DCI_FORMAT1A: + msg->format = format; return dci_format1As_pack(data, msg, nof_prb, crc_is_crnti); case SRSLTE_DCI_FORMAT1C: + msg->format = format; return dci_format1Cs_pack(data, msg, nof_prb); case SRSLTE_DCI_FORMAT2: case SRSLTE_DCI_FORMAT2A: case SRSLTE_DCI_FORMAT2B: + msg->format = format; return dci_format2AB_pack(data, msg, nof_prb, nof_ports); default: fprintf(stderr, "DCI pack pdsch: Invalid DCI format %s\n", From afaa8a8d7e22bca2de51ce780780a9fd6150a5a6 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 20 Mar 2017 19:55:16 -0400 Subject: [PATCH 4/5] added cdd precoding --- srslte/include/srslte/mimo/precoding.h | 9 ++++++++- srslte/lib/mimo/layermap.c | 6 ++---- srslte/lib/mimo/precoding.c | 28 ++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/srslte/include/srslte/mimo/precoding.h b/srslte/include/srslte/mimo/precoding.h index c6926f497..bf842faeb 100644 --- a/srslte/include/srslte/mimo/precoding.h +++ b/srslte/include/srslte/mimo/precoding.h @@ -53,7 +53,14 @@ SRSLTE_API int srslte_precoding_single(cf_t *x, SRSLTE_API int srslte_precoding_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], - int nof_ports, int nof_symbols); + int nof_ports, + int nof_symbols); + +SRSLTE_API int srslte_precoding_cdd(cf_t *x[SRSLTE_MAX_LAYERS], + cf_t *y[SRSLTE_MAX_PORTS], + int nof_layers, + int nof_ports, + int nof_symbols); SRSLTE_API int srslte_precoding_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], diff --git a/srslte/lib/mimo/layermap.c b/srslte/lib/mimo/layermap.c index 1a9058658..58cfc1121 100644 --- a/srslte/lib/mimo/layermap.c +++ b/srslte/lib/mimo/layermap.c @@ -59,7 +59,7 @@ int srslte_layermap_multiplex(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_ n[1] = nof_layers - n[0]; if (nof_symbols[0] / n[0] == nof_symbols[1] / n[1]) { - srslte_layermap_diversity(d[0], x, n[0], nof_symbols[0]); + srslte_layermap_diversity(d[0], x, n[0], nof_symbols[0]); srslte_layermap_diversity(d[1], &x[n[0]], n[1], nof_symbols[1]); return nof_symbols[0] / n[0]; @@ -115,11 +115,9 @@ int srslte_layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYER } break; case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX: + case SRSLTE_MIMO_TYPE_CDD: return srslte_layermap_multiplex(d, x, nof_cw, nof_layers, nof_symbols); break; - case SRSLTE_MIMO_TYPE_CDD: - fprintf(stderr, "CDD Not implemented\n"); - return -1; } return 0; } diff --git a/srslte/lib/mimo/precoding.c b/srslte/lib/mimo/precoding.c index 61f6d367a..b5af62711 100644 --- a/srslte/lib/mimo/precoding.c +++ b/srslte/lib/mimo/precoding.c @@ -620,6 +620,31 @@ int srslte_precoding_diversity(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PO } } +int srslte_precoding_cdd(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, int nof_ports, int nof_symbols) +{ + int i; + if (nof_ports == 2) { + if (nof_layers != 2) { + fprintf(stderr, "Invalid number of layers %d for 2 ports\n", nof_layers); + return -1; + } + for (i = 0; i < nof_symbols; i++) { + y[0][i] = (x[0][i]+x[1][i])/2; + y[1][i] = (x[0][i]-x[1][i])/2; + i++; + y[0][i] = (x[0][i]+x[1][i])/2; + y[1][i] = (-x[0][i]+x[1][i])/2; + } + return 2 * i; + } else if (nof_ports == 4) { + fprintf(stderr, "Not implemented\n"); + return -1; + } else { + fprintf(stderr, "Number of ports must be 2 or 4 for transmit diversity (nof_ports=%d)\n", nof_ports); + return -1; + } +} + /* 36.211 v10.3.0 Section 6.3.4 */ int srslte_precoding_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], int nof_layers, int nof_ports, int nof_symbols, srslte_mimo_type_t type) { @@ -637,8 +662,7 @@ int srslte_precoding_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *y[SRSLTE_MAX_PORTS], switch (type) { case SRSLTE_MIMO_TYPE_CDD: - fprintf(stderr, "CCD not supported\n"); - return -1; + return srslte_precoding_cdd(x, y, nof_layers, nof_ports, nof_symbols); case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: if (nof_ports == 1 && nof_layers == 1) { return srslte_precoding_single(x[0], y[0], nof_symbols); From 781fafa661bf416c6c5a984ff28341aff6209508 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 24 Mar 2017 10:04:43 -0400 Subject: [PATCH 5/5] disabled softbuffer reset on init --- srslte/lib/fec/softbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srslte/lib/fec/softbuffer.c b/srslte/lib/fec/softbuffer.c index 32f16295e..46eaaef69 100644 --- a/srslte/lib/fec/softbuffer.c +++ b/srslte/lib/fec/softbuffer.c @@ -69,7 +69,7 @@ int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t *q, uint32_t nof_prb) { return SRSLTE_ERROR; } } - srslte_softbuffer_rx_reset(q); + //srslte_softbuffer_rx_reset(q); ret = SRSLTE_SUCCESS; } }