From afaa8a8d7e22bca2de51ce780780a9fd6150a5a6 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 20 Mar 2017 19:55:16 -0400 Subject: [PATCH] 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);