From ed4d50053298c4792b67b8dac004eea6fa02044a Mon Sep 17 00:00:00 2001 From: ismagom Date: Tue, 20 Jan 2015 18:41:20 +0000 Subject: [PATCH] PDSCH CB segmentation computation used erroneous CB length --- lte/phy/include/liblte/phy/fec/turbodecoder.h | 2 +- lte/phy/lib/phch/src/pdsch.c | 8 +++--- lte/phy/lib/phch/test/pdsch_test_mex.c | 25 +++++++++++-------- matlab/tests/pdsch_bler.m | 17 +++++++------ matlab/tests/turbodecoder_bler.m | 9 ++++--- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/lte/phy/include/liblte/phy/fec/turbodecoder.h b/lte/phy/include/liblte/phy/fec/turbodecoder.h index 57de9b7ad..96d9a5b27 100644 --- a/lte/phy/include/liblte/phy/fec/turbodecoder.h +++ b/lte/phy/include/liblte/phy/fec/turbodecoder.h @@ -44,7 +44,7 @@ #define INF 9e4 #define ZERO 9e-4 -#define MAX_LONG_CB 6114 +#define MAX_LONG_CB 6144 #define MAX_LONG_CODED (RATE*MAX_LONG_CB+TOTALTAIL) typedef float llr_t; diff --git a/lte/phy/lib/phch/src/pdsch.c b/lte/phy/lib/phch/src/pdsch.c index d18727fb0..f0138edb7 100644 --- a/lte/phy/lib/phch/src/pdsch.c +++ b/lte/phy/lib/phch/src/pdsch.c @@ -354,11 +354,11 @@ static int codeblock_segmentation(struct cb_segm *s, uint32_t tbs) { B = tbs + 24; /* Calculate CB sizes */ - if (B < 6114) { + if (B < MAX_LONG_CB) { s->C = 1; Bp = B; } else { - s->C = (uint32_t) ceilf((float) B / (6114 - 24)); + s->C = (uint32_t) ceilf((float) B / (MAX_LONG_CB - 24)); Bp = B + 24 * s->C; } ret = lte_find_cb_index(Bp / s->C); @@ -397,7 +397,7 @@ int pdsch_harq_init(pdsch_harq_t *p, pdsch_t *pdsch) { p->cell = pdsch->cell; ret = ra_tbs_from_idx(26, p->cell.nof_prb); if (ret != LIBLTE_ERROR) { - p->max_cb = (uint32_t) ret / (6114 - 24) + 1; + p->max_cb = (uint32_t) ret / (MAX_LONG_CB - 24) + 1; p->pdsch_w_buff_f = malloc(sizeof(float*) * p->max_cb); if (!p->pdsch_w_buff_f) { @@ -722,7 +722,7 @@ int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], float noise_ * 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 */ - demod_soft_sigma_set(&q->demod, sqrt((float) lte_mod_bits_x_symbol(harq_process->mcs.mod)/2)); + demod_soft_sigma_set(&q->demod, sqrt(0.5)); demod_soft_table_set(&q->demod, &q->mod[harq_process->mcs.mod]); demod_soft_demodulate(&q->demod, q->pdsch_d, q->pdsch_e, nof_symbols); diff --git a/lte/phy/lib/phch/test/pdsch_test_mex.c b/lte/phy/lib/phch/test/pdsch_test_mex.c index f500fe54b..fb906cc64 100644 --- a/lte/phy/lib/phch/test/pdsch_test_mex.c +++ b/lte/phy/lib/phch/test/pdsch_test_mex.c @@ -161,7 +161,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) free(prbset); ra_prb_get_re_dl(&prb_alloc, cell.nof_prb, cell.nof_ports, cell.nof_prb<10?(cfi+1):cfi, cell.cp); - + + if (pdsch_harq_setup(&harq_process, mcs, &prb_alloc)) { + mexErrMsgTxt("Error configuring HARQ process\n"); + return; + } + + + //mexPrintf("C: %d, K1: %d, K2: %d\n", harq_process.cb_segm.C, harq_process.cb_segm.K1, harq_process.cb_segm.K2); /** Allocate input buffers */ if (mexutils_read_cf(INPUT, &input_signal) < 0) { mexErrMsgTxt("Error reading input signal\n"); @@ -178,14 +185,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) lte_fft_run_sf(&fft, input_signal, input_fft); if (nrhs > NOF_INPUTS) { - cf_t *cearray; + cf_t *cearray = NULL; nof_re = mexutils_read_cf(prhs[NOF_INPUTS], &cearray); + cf_t *cearray_ptr = cearray; for (i=0;i= 5) { - mexutils_write_cf(ce[0], &plhs[4], 12*14*cell.nof_prb, 1); + mexutils_write_f(pdsch.pdsch_e, &plhs[4], harq_process.prb_alloc.re_sf[sf_idx]*lte_mod_bits_x_symbol(mcs.mod), 1); } chest_dl_free(&chest); diff --git a/matlab/tests/pdsch_bler.m b/matlab/tests/pdsch_bler.m index 1b51b9502..3e295a8cd 100644 --- a/matlab/tests/pdsch_bler.m +++ b/matlab/tests/pdsch_bler.m @@ -7,10 +7,10 @@ recordedSignal=[]; Npackets = 4; -SNR_values = linspace(5,6,4); +SNR_values = linspace(10,20,4); %% Choose RMC -[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.4',[1;0;0;1]); +[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.7',[1;0;0;1]); waveform = sum(waveform,2); if ~isempty(recordedSignal) @@ -78,7 +78,8 @@ for snr_idx=1:length(SNR_values) %% Demodulate frame_rx = lteOFDMDemodulate(rmccFgOut, rxWaveform); - for sf_idx=0:Nsf + %for sf_idx=0:Nsf + sf_idx=1; 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; @@ -87,8 +88,8 @@ for snr_idx=1:length(SNR_values) % Perform channel estimation [hest, nest] = lteDLChannelEstimate(rmccFgOut, cec, subframe_rx); - [cws,symbols,indices,pdschSymbols,pdschHest] = ltePDSCHDecode2(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); - [trblkout,blkcrc] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... + [cws,symbols] = ltePDSCHDecode(rmccFgOut,rmccFgOut.PDSCH,subframe_rx,hest,nest); + [trblkout,blkcrc,dstate] = lteDLSCHDecode(rmccFgOut,rmccFgOut.PDSCH, ... rmccFgOut.PDSCH.TrBlkSizes(sf_idx+1),cws); decoded(snr_idx) = decoded(snr_idx) + ~blkcrc; @@ -103,7 +104,7 @@ for snr_idx=1:length(SNR_values) dec2 = 1; end decoded_liblte(snr_idx) = decoded_liblte(snr_idx)+dec2; - end + %end if ~isempty(recordedSignal) recordedSignal = recordedSignal(flen*10+1:end); @@ -113,8 +114,8 @@ for snr_idx=1:length(SNR_values) end if (length(SNR_values)>1) - semilogy(SNR_values,1-decoded/Npackets/(Nsf),'bo-',... - SNR_values,1-decoded_liblte/Npackets/(Nsf), 'ro-') + semilogy(SNR_values,1-decoded/Npackets/(Nsf+1),'bo-',... + SNR_values,1-decoded_liblte/Npackets/(Nsf+1), 'ro-') grid on; legend('Matlab','libLTE') xlabel('SNR (dB)') diff --git a/matlab/tests/turbodecoder_bler.m b/matlab/tests/turbodecoder_bler.m index 141b1dbd4..88a955ff8 100644 --- a/matlab/tests/turbodecoder_bler.m +++ b/matlab/tests/turbodecoder_bler.m @@ -1,8 +1,8 @@ clear -blen=1008; -SNR_values_db=linspace(-1,0.5,6); -Nrealizations=1000; +blen=5184; +SNR_values_db=linspace(-1.3,-0.7,6); +Nrealizations=600; addpath('../../debug/lte/phy/lib/fec/test') @@ -34,7 +34,8 @@ for snr_idx=1:length(SNR_values_db) errors2(snr_idx) = errors2(snr_idx) + any(decodedData2 ~= Data); end - fprintf('SNR: %.2f\n', SNR_values_db(snr_idx)); + fprintf('SNR: %.2f BLER: %f-%f\n', SNR_values_db(snr_idx), ... + errors1(snr_idx)/Nrealizations, errors2(snr_idx)/Nrealizations); end if (length(SNR_values_db) > 1)