diff --git a/matlab/tests/dlsch_test.m b/matlab/tests/dlsch_test.m index c3b19a98b..e58bc37e1 100644 --- a/matlab/tests/dlsch_test.m +++ b/matlab/tests/dlsch_test.m @@ -1,16 +1,14 @@ +clear enbConfig=struct('NCellID',1,'CyclicPrefix','Normal','CellRefP',1); -pdschConfig=struct('Modulation','QPSK','RV',0,'TxScheme','Port0'); +pdschConfig=struct('Modulation','64QAM','RV',0,'TxScheme','Port0'); -addpath('/home/ismael/work/srsLTE/build/srslte/lib/phch/test') +addpath('../../build/srslte/lib/phch/test') -TBs=40:8:800; -e_bits=1000; +TBs=19848; +e_bits=38460; error=zeros(size(TBs)); for i=1:length(TBs) trblkin=randi(2,TBs(i),1)-1; - %trblkin=ones(104,1); - %trblkin=[1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, ]; - %trblkin=[1, 0]; [mat, info]=lteDLSCH(enbConfig,pdschConfig,e_bits,trblkin); lib=srslte_dlsch_encode(enbConfig,pdschConfig,e_bits,trblkin); diff --git a/matlab/tests/pdsch_bler.m b/matlab/tests/pdsch_bler.m index 2e6cfbd1c..a3b47bbed 100644 --- a/matlab/tests/pdsch_bler.m +++ b/matlab/tests/pdsch_bler.m @@ -6,15 +6,15 @@ recordedSignal=[]; -Npackets = 1; -SNR_values = linspace(15,20,4); +Npackets = 8; +SNR_values = linspace(10.5,13,4); %% Choose RMC -[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.4',[1;0;0;1]); +[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.6',[1;0;0;1]); waveform = sum(waveform,2); if ~isempty(recordedSignal) - rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',15,'SamplingRate',3.84e6,'Nfft',256,'DuplexMode','FDD','CyclicPrefix','Normal'); + rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',50,'SamplingRate',3.84e6,'Nfft',256,'DuplexMode','FDD','CyclicPrefix','Normal'); rmccFgOut.PDSCH.RNTI = 1234; rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2); rmccFgOut.PDSCH.TxScheme = 'Port0'; @@ -79,7 +79,6 @@ for snr_idx=1:length(SNR_values) frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform); for sf_idx=0:Nsf - subframe_waveform = rxWaveform(sf_idx*flen+1:(sf_idx+1)*flen); subframe_rx=frame_rx(:,sf_idx*14+1:(sf_idx+1)*14); rmccFgOut.NSubframe=sf_idx; rmccFgOut.TotSubframes=1; @@ -87,7 +86,7 @@ for snr_idx=1:length(SNR_values) % Perform channel estimation [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); - [cws,symbols,pdschSymbols,hestCH,indices] = ltePDSCHDecode2(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); + [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws); @@ -98,7 +97,7 @@ for snr_idx=1:length(SNR_values) if (rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1) > 0) [dec2, data, pdschRx, pdschSymbols2, deb] = srslte_pdsch(rmccFgOut, rmccFgOut.PDSCH, ... rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1), ... - subframe_waveform); + subframe_rx); else dec2 = 1; end diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 9a93c547d..125c1fb58 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -596,7 +596,7 @@ int main(int argc, char **argv) { /* Configure pdsch_cfg parameters */ srslte_ra_dl_grant_t grant; srslte_ra_dl_dci_to_grant(&ra_dl, cell.nof_prb, true, &grant); - if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, sf_idx, UE_CRNTI, 0)) { + if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, sf_idx, 0)) { fprintf(stderr, "Error configuring PDSCH\n"); exit(-1); } diff --git a/srslte/include/srslte/phch/pdsch.h b/srslte/include/srslte/phch/pdsch.h index dd504466d..c5a733d63 100644 --- a/srslte/include/srslte/phch/pdsch.h +++ b/srslte/include/srslte/phch/pdsch.h @@ -87,7 +87,6 @@ SRSLTE_API int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, - uint16_t rnti, uint32_t rvidx); SRSLTE_API int srslte_pdsch_encode(srslte_pdsch_t *q, diff --git a/srslte/include/srslte/phch/pdsch_cfg.h b/srslte/include/srslte/phch/pdsch_cfg.h index dac764ac7..30661862c 100644 --- a/srslte/include/srslte/phch/pdsch_cfg.h +++ b/srslte/include/srslte/phch/pdsch_cfg.h @@ -45,7 +45,7 @@ typedef struct SRSLTE_API { srslte_ra_dl_grant_t grant; srslte_ra_nbits_t nbits; uint32_t rv; - uint32_t sf_idx; + uint32_t sf_idx; } srslte_pdsch_cfg_t; #endif diff --git a/srslte/include/srslte/ue/ue_dl.h b/srslte/include/srslte/ue/ue_dl.h index fbd02cd0d..e9c7c6e48 100644 --- a/srslte/include/srslte/ue/ue_dl.h +++ b/srslte/include/srslte/ue/ue_dl.h @@ -101,7 +101,6 @@ SRSLTE_API int srslte_ue_dl_cfg_grant(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, - uint16_t rnti, uint32_t rvidx); SRSLTE_API int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, diff --git a/srslte/lib/modem/src/demod_soft.c b/srslte/lib/modem/src/demod_soft.c index 8f362b15d..a89a6734e 100644 --- a/srslte/lib/modem/src/demod_soft.c +++ b/srslte/lib/modem/src/demod_soft.c @@ -33,7 +33,7 @@ #include "srslte/utils/bit.h" #include "srslte/modem/demod_soft.h" -#define SCALE_DEMOD16QAM +//#define SCALE_DEMOD16QAM void demod_bpsk_lte(const cf_t *symbols, float *llr, int nsymbols) { diff --git a/srslte/lib/phch/src/pdsch.c b/srslte/lib/phch/src/pdsch.c index b2e765b49..25060d1fb 100644 --- a/srslte/lib/phch/src/pdsch.c +++ b/srslte/lib/phch/src/pdsch.c @@ -98,7 +98,7 @@ int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_g // 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) { + && n < q->cell.nof_prb / 2 + 3 + (q->cell.nof_prb%2)) { lend = SRSLTE_CP_NSYMB(q->cell.cp) - 2; is_sss = true; } @@ -106,7 +106,7 @@ int srslte_pdsch_cp(srslte_pdsch_t *q, cf_t *input, cf_t *output, srslte_ra_dl_g // Skip PBCH if (s == 1 && nsubframe == 0) { if (n >= q->cell.nof_prb / 2 - 3 - && n <= q->cell.nof_prb / 2 + 3) { + && n < q->cell.nof_prb / 2 + 3 + (q->cell.nof_prb%2)) { lstart = 4; is_pbch = true; } @@ -302,7 +302,7 @@ void srslte_pdsch_free(srslte_pdsch_t *q) { /* Configures the structure srslte_pdsch_cfg_t from the DL DCI allocation dci_msg. * If dci_msg is NULL, the grant is assumed to be already stored in cfg->grant */ -int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx) +int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_grant_t *grant, uint32_t cfi, uint32_t sf_idx, uint32_t rvidx) { if (cfg && grant) { @@ -314,8 +314,8 @@ int srslte_pdsch_cfg(srslte_pdsch_cfg_t *cfg, srslte_cell_t cell, srslte_ra_dl_g } srslte_ra_dl_grant_to_nbits(&cfg->grant, cfi, cell, sf_idx, &cfg->nbits); cfg->sf_idx = sf_idx; - cfg->rv = rvidx; - + cfg->rv = rvidx; + return SRSLTE_SUCCESS; } diff --git a/srslte/lib/phch/src/ra.c b/srslte/lib/phch/src/ra.c index 29eb3f334..b5915a946 100644 --- a/srslte/lib/phch/src/ra.c +++ b/srslte/lib/phch/src/ra.c @@ -55,7 +55,7 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_ /* if it's the prb in the middle, there are less RE due to PBCH and PSS/SSS */ if ((subframe == 0 || subframe == 5) - && (prb_idx >= nof_prb / 2 - 3 && prb_idx <= nof_prb / 2 + 3)) { + && (prb_idx >= nof_prb / 2 - 3 && prb_idx < nof_prb / 2 + 3 + (nof_prb%2))) { if (subframe == 0) { if (slot == 0) { re = (SRSLTE_CP_NSYMB(cp) - nof_ctrl_symbols - 2) * SRSLTE_NRE; @@ -104,7 +104,6 @@ uint32_t ra_re_x_prb(uint32_t subframe, uint32_t slot, uint32_t prb_idx, uint32_ break; } } - return re; } diff --git a/srslte/lib/phch/test/CMakeLists.txt b/srslte/lib/phch/test/CMakeLists.txt index 09039c262..9a84f7847 100644 --- a/srslte/lib/phch/test/CMakeLists.txt +++ b/srslte/lib/phch/test/CMakeLists.txt @@ -93,10 +93,10 @@ BuildMex(MEXNAME pdcch SOURCES pdcch_test_mex.c LIBRARIES srslte srslte_mex) ADD_EXECUTABLE(pdsch_test pdsch_test.c) TARGET_LINK_LIBRARIES(pdsch_test srslte) -ADD_TEST(pdsch_test_bpsk pdsch_test -l 504 -m 1 -n 50 -r 2) -ADD_TEST(pdsch_test_qpsk pdsch_test -l 2216 -m 2 -n 50 -r 1) -ADD_TEST(pdsch_test_qam16 pdsch_test -l 18336 -m 4 -n 100) -ADD_TEST(pdsch_test_qam64 pdsch_test -l 75376 -m 6 -n 100 -r 0) +ADD_TEST(pdsch_test_bpsk pdsch_test -m 0 -n 50 -r 2) +ADD_TEST(pdsch_test_qpsk pdsch_test -m 10 -n 50 -r 1) +ADD_TEST(pdsch_test_qam16 pdsch_test -m 20 -n 100) +ADD_TEST(pdsch_test_qam64 pdsch_test -m 28 -n 100 -r 0) BuildMex(MEXNAME pdsch SOURCES pdsch_test_mex.c LIBRARIES srslte srslte_mex) BuildMex(MEXNAME dlsch_encode SOURCES dlsch_encode_test_mex.c LIBRARIES srslte srslte_mex) diff --git a/srslte/lib/phch/test/pdsch_test.c b/srslte/lib/phch/test/pdsch_test.c index ed3b7ea2c..6c4a90c94 100644 --- a/srslte/lib/phch/test/pdsch_test.c +++ b/srslte/lib/phch/test/pdsch_test.c @@ -45,18 +45,21 @@ srslte_cell_t cell = { }; uint32_t cfi = 2; -uint32_t tbs = 0; +uint32_t mcs = 0; uint32_t subframe = 1; -srslte_mod_t modulation = SRSLTE_MOD_BPSK; uint32_t rv_idx = 0; +uint16_t rnti = 1234; +char *input_file = NULL; void usage(char *prog) { - printf("Usage: %s [Lcpsrnfvmt] -l TBS \n", prog); - printf("\t-m modulation (1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64) [Default BPSK]\n"); + printf("Usage: %s [fmcsrRFpnv] \n", prog); + printf("\t-f read signal from file [Default generate it with pdsch_encode()]\n"); + printf("\t-m MCS [Default %d]\n", mcs); printf("\t-c cell id [Default %d]\n", cell.id); printf("\t-s subframe [Default %d]\n", subframe); printf("\t-r rv_idx [Default %d]\n", rv_idx); - printf("\t-f cfi [Default %d]\n", cfi); + printf("\t-R rnti [Default %d]\n", rnti); + printf("\t-F cfi [Default %d]\n", cfi); printf("\t-p cell.nof_ports [Default %d]\n", cell.nof_ports); printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); printf("\t-v [set srslte_verbose to debug, default none]\n"); @@ -64,27 +67,13 @@ void usage(char *prog) { void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "lcpnfvmtsr")) != -1) { + while ((opt = getopt(argc, argv, "fmcsrRFpnv")) != -1) { switch(opt) { + case 'f': + input_file = argv[optind]; + break; case 'm': - switch(atoi(argv[optind])) { - case 1: - modulation = SRSLTE_MOD_BPSK; - break; - case 2: - modulation = SRSLTE_MOD_QPSK; - break; - case 4: - modulation = SRSLTE_MOD_16QAM; - break; - case 6: - modulation = SRSLTE_MOD_64QAM; - break; - default: - fprintf(stderr, "Invalid modulation %d. Possible values: " - "(1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64)\n", atoi(argv[optind])); - break; - } + mcs = atoi(argv[optind]); break; case 's': subframe = atoi(argv[optind]); @@ -92,8 +81,11 @@ void parse_args(int argc, char **argv) { case 'r': rv_idx = atoi(argv[optind]); break; - case 'l': - tbs = atoi(argv[optind]); + case 'R': + rnti = atoi(argv[optind]); + break; + case 'F': + cfi = atoi(argv[optind]); break; case 'p': cell.nof_ports = atoi(argv[optind]); @@ -112,10 +104,6 @@ void parse_args(int argc, char **argv) { exit(-1); } } - if (tbs == 0) { - usage(argv[0]); - exit(-1); - } } int main(int argc, char **argv) { @@ -140,18 +128,19 @@ int main(int argc, char **argv) { bzero(&softbuffer_rx, sizeof(srslte_softbuffer_rx_t)); bzero(&softbuffer_tx, sizeof(srslte_softbuffer_tx_t)); + srslte_ra_dl_dci_t dci; + bzero(&dci, sizeof(srslte_ra_dl_dci_t)); + dci.mcs_idx = mcs; + dci.rv_idx = rv_idx; + dci.type0_alloc.rbg_bitmask = 0xffffffff; srslte_ra_dl_grant_t grant; - grant.mcs.tbs = tbs; - grant.mcs.mod = modulation; - grant.Qm = srslte_mod_bits_x_symbol(grant.mcs.mod); - grant.nof_prb = cell.nof_prb; // Allocate all PRB - for (i=0;i NOF_INPUTS) { cf_t *cearray = NULL; nof_re = mexutils_read_cf(prhs[NOF_INPUTS], &cearray); @@ -236,14 +228,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } srslte_chest_dl_free(&chest); - srslte_ofdm_rx_free(&fft); srslte_pdsch_free(&pdsch); for (i=0;ipdsch_cfg, q->cell, grant, cfi, sf_idx, rnti, rvidx); + return srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, cfi, sf_idx, rvidx); } int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_ra_dl_grant_t *grant, uint8_t *data, @@ -217,7 +217,7 @@ int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_ra_dl_grant_t * q->nof_detected++; /* Setup PDSCH configuration for this CFI, SFIDX and RVIDX */ - if (srslte_ue_dl_cfg_grant(q, grant, cfi, sf_idx, rnti, rvidx)) { + if (srslte_ue_dl_cfg_grant(q, grant, cfi, sf_idx, rvidx)) { return SRSLTE_ERROR; }