Working on CDD precoder (matlab)

master
Ismael Gomez 8 years ago
parent e4a94bcf33
commit 4d77eb9fa1

@ -1,65 +0,0 @@
clear
addpath('../../build/srslte/lib/mimo/test')
%enb = lteRMCDL('R.10'); % 2-ports
enb = lteRMCDL('R.0'); % 1-ports
cec = struct('FreqWindow',9,'TimeWindow',9,'InterpType','cubic');
cec.PilotAverage = 'UserDefined';
cec.InterpWinSize = 1;
cec.InterpWindow = 'Causal';
cfg.Seed = 1; % Random channel seed
cfg.NRxAnts = 2; % 1 receive antenna
cfg.DelayProfile = 'ETU'; % EVA delay spread
cfg.DopplerFreq = 100; % 120Hz Doppler frequency
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
cfg.InitTime = 0; % Initialize at time zero
cfg.NTerms = 16; % Oscillators used in fading model
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
cfg.InitPhase = 'Random'; % Random initial phases
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
[txWaveform, ~, info] = lteRMCDLTool(enb,[1;0;0;1]);
cfg.SamplingRate = info.SamplingRate;
txWaveform = txWaveform+complex(randn(size(txWaveform)),randn(size(txWaveform)))*1e-3;
rxWaveform = lteFadingChannel(cfg,txWaveform);
rxGrid = lteOFDMDemodulate(enb,rxWaveform);
[h,n0] = lteDLChannelEstimate(enb,cec,rxGrid);
s=size(h);
p=s(1);
n=s(2);
if (length(s)>2)
Nr=s(3);
else
Nr=1;
end
if (length(s)>3)
Nt=s(4);
else
Nt=1;
end
rx=reshape(rxGrid,p*n,Nr);
hp=reshape(h,p*n,Nr,Nt);
if (Nt > 1)
output_mat = lteTransmitDiversityDecode(rx, hp);
else
output_mat = lteEqualizeMMSE(rx, hp, n0);
end
output_srs = srslte_diversitydecode(rx, hp, n0);
plot(abs(output_mat(:)-output_srs(:)))
mean(abs(output_mat(:)-output_srs(:)).^2)
t=1:100;
plot(t,real(output_mat(t)),t,real(output_srs(t)))

@ -0,0 +1,84 @@
clear
addpath('../../debug/srslte/lib/mimo/test')
Nt=1;
Nr=1;
Nl=1;
Ncw=1;
txscheme='Port0';
codebook=0;
enb.NDLRB=6;
Ns=enb.NDLRB*12*14;
enb.CyclicPrefix='Normal';
enb.CellRefP=Nt;
enb.TotSubframes=1;
cfg.Seed = 1; % Random channel seed
cfg.NRxAnts = Nr; % 1 receive antenna
cfg.DelayProfile = 'ETU'; % EVA delay spread
cfg.DopplerFreq = 100; % 120Hz Doppler frequency
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
cfg.InitTime = 0; % Initialize at time zero
cfg.NTerms = 16; % Oscillators used in fading model
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
cfg.InitPhase = 'Random'; % Random initial phases
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
cec = struct('FreqWindow',9,'TimeWindow',9,'InterpType','cubic');
cec.PilotAverage = 'UserDefined';
cec.InterpWinSize = 1;
cec.InterpWindow = 'Causal';
sym = 2*rand(Ns*Nl,1)-1;
layermap = lteLayerMap(sym, Nl, txscheme);
tx = lteDLPrecode(layermap, Nt, txscheme, codebook);
tx_srs = srslte_precoder(sym, Nl, Nt, txscheme);
err_tx=mean(abs(tx_srs-tx).^2)
[txwaveform, info] = lteOFDMModulate(enb, reshape(tx,enb.NDLRB*12,[],Nt));
cfg.SamplingRate = info.SamplingRate;
rxwaveform = lteFadingChannel(cfg, txwaveform);
rxGrid = lteOFDMDemodulate(enb, rxwaveform);
h=lteDLPerfectChannelEstimate(enb, cfg);
hp=reshape(h,Ns,Nr,Nt);
rx=reshape(rxGrid,Ns,Nr);
if (Nt > 1)
if (strcmp(txscheme,'TxDiversity')==1)
output_mat = lteTransmitDiversityDecode(rx, hp);
elseif (strcmp(txscheme,'CDD')==1 || strcmp(txscheme,'SpatialMux')==1)
pdsch.NLayers=Nl;
pdsch.RNTI=0;
pdsch.TxScheme=txscheme;
pdsch.PMISet=codebook;
pdsch.NCodewords=Ncw;
deprecoded = lteEqualizeMIMO(enb,pdsch,rx,hp,0);
out_cw = lteLayerDemap(pdsch,deprecoded);
output_mat = [];
for i=1:Ncw
output_mat = [output_mat out_cw{i}];
end
else
error('Unsupported txscheme')
end
else
output_mat = lteEqualizeMMSE(rx, hp, 0);
end
output_srs = srslte_predecoder(rx, hp, 0, txscheme);
plot(abs(output_mat(:)-output_srs(:)))
mean(abs(output_mat(:)-output_srs(:)).^2)
t=1:100;
plot(t,real(output_mat(t)),t,real(output_srs(t)))

@ -51,7 +51,7 @@
#define SRSLTE_MAX_RXANT 2
#define SRSLTE_MAX_PORTS 4
#define SRSLTE_MAX_LAYERS 8
#define SRSLTE_MAX_LAYERS 4
#define SRSLTE_MAX_CODEWORDS 2
#define SRSLTE_LTE_CRC24A 0x1864CFB
@ -169,7 +169,8 @@ typedef struct SRSLTE_API {
typedef enum SRSLTE_API {
SRSLTE_MIMO_TYPE_SINGLE_ANTENNA,
SRSLTE_MIMO_TYPE_TX_DIVERSITY,
SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX
SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX,
SRSLTE_MIMO_TYPE_CDD
} srslte_mimo_type_t;
typedef enum SRSLTE_API {

@ -117,6 +117,9 @@ int srslte_layermap_type(cf_t *d[SRSLTE_MAX_CODEWORDS], cf_t *x[SRSLTE_MAX_LAYER
case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
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;
}
@ -208,6 +211,9 @@ int srslte_layerdemap_type(cf_t *x[SRSLTE_MAX_LAYERS], cf_t *d[SRSLTE_MAX_CODEWO
case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
return srslte_layerdemap_multiplex(x, d, nof_layers, nof_cw, nof_layer_symbols, nof_symbols);
break;
case SRSLTE_MIMO_TYPE_CDD:
fprintf(stderr, "CDD Not implemented\n");
return -1;
}
return 0;
}

@ -53,7 +53,7 @@ add_test(layermap_multiplex_28 layermap_test -n 1000 -m multiplex -c 2 -l 8)
# LAYER MAPPING TEST
########################################################################
add_executable(precoding_test precoding_test.c)
add_executable(precoding_test precoder_test.c)
target_link_libraries(precoding_test srslte)
add_test(precoding_single precoding_test -n 1000 -m single)
@ -62,7 +62,8 @@ add_test(precoding_diversity4 precoding_test -n 1024 -m diversity -l 4 -p 4)
# MEX file for predecoding and layer demapping test
BuildMex(MEXNAME diversitydecode SOURCES diversitydecode_mex.c LIBRARIES srslte_static srslte_mex)
BuildMex(MEXNAME predecoder SOURCES predecoder_mex.c LIBRARIES srslte_static srslte_mex)
BuildMex(MEXNAME precoder SOURCES precoder_mex.c LIBRARIES srslte_static srslte_mex)

@ -0,0 +1,128 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE 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 Affero General Public License for more details.
*
* A copy of the GNU Affero 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 <string.h>
#include "srslte/srslte.h"
#include "srslte/mex/mexutils.h"
/** MEX function to be called from MATLAB to test the predecoder
*/
#define INPUT prhs[0]
#define NLAYERS prhs[1]
#define NPORTS prhs[2]
#define TXSCHEME prhs[3]
#define NOF_INPUTS 3
void help()
{
mexErrMsgTxt
("[output] = srslte_decoder(input, NLayers, NCellRefP, TxScheme)\n\n");
}
/* the gateway function */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
cf_t *input = NULL;
cf_t *output = NULL;
if (nrhs < NOF_INPUTS) {
help();
return;
}
// Read input symbols
int nof_symbols = mexutils_read_cf(INPUT, &input);
if (nof_symbols < 0) {
mexErrMsgTxt("Error reading input\n");
return;
}
uint32_t nof_layers = mxGetScalar(NLAYERS);
uint32_t nof_tx_ports = mxGetScalar(NPORTS);
uint32_t nof_codewords = 1;
mexPrintf("nof_tx_ports=%d, nof_layers=%d, nof_symbols=%d\n", nof_tx_ports, nof_layers, nof_symbols);
cf_t *y[SRSLTE_MAX_PORTS];
cf_t *x[SRSLTE_MAX_LAYERS];
cf_t *d[SRSLTE_MAX_CODEWORDS];
d[0] = input; // Single codeword supported only
/* Allocate memory */
for (int i = 0; i < nof_layers; i++) {
x[i] = srslte_vec_malloc(sizeof(cf_t)*nof_symbols/nof_layers);
}
output = srslte_vec_malloc(sizeof(cf_t)*nof_symbols*nof_tx_ports/nof_layers);
for (int i=0;i<nof_tx_ports;i++) {
y[i] = &output[i*nof_symbols/nof_layers];
}
char *txscheme = "Port0";
if (nrhs >= NOF_INPUTS) {
txscheme = mxArrayToString(TXSCHEME);
}
srslte_mimo_type_t type = SRSLTE_MIMO_TYPE_SINGLE_ANTENNA;
if (!strcmp(txscheme, "Port0")) {
type = SRSLTE_MIMO_TYPE_SINGLE_ANTENNA;
} else if (!strcmp(txscheme, "TxDiversity")) {
type = SRSLTE_MIMO_TYPE_TX_DIVERSITY;
} else if (!strcmp(txscheme, "CDD")) {
type = SRSLTE_MIMO_TYPE_CDD;
} else if (!strcmp(txscheme, "SpatialMux")) {
type = SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX;
} else {
mexPrintf("Unsupported TxScheme=%s\n", txscheme);
return;
}
int symbols_layers[SRSLTE_MAX_LAYERS];
for (int i=0;i<nof_layers;i++) {
symbols_layers[i] = nof_symbols/nof_layers;
}
srslte_layermap_type(d, x, nof_codewords, nof_layers, symbols_layers, type);
srslte_precoding_type(x, y, nof_layers, nof_tx_ports, nof_symbols/nof_layers, type);
if (nlhs >= 1) {
mexutils_write_cf(output, &plhs[0], nof_symbols/nof_layers, nof_tx_ports);
}
if (input) {
free(input);
}
if (output) {
free(output);
}
for (int i=0;i<nof_layers;i++) {
if (x[i]) {
free(x[i]);
}
}
return;
}
Loading…
Cancel
Save