From 77a560cbf38bdaf8f4487954536b89ee7585c32e Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 17 May 2016 09:15:23 +0200 Subject: [PATCH 1/7] chest_dl: Choose noise algorithm --- matlab/tests/equalizer_test.m | 13 +++--- matlab/tests/pdsch_bler_equal.m | 20 +++++---- matlab/tests/pdsch_decode_signal.m | 17 +++---- .../include/srslte/ch_estimation/chest_dl.h | 12 +++++ srslte/lib/ch_estimation/chest_dl.c | 44 ++++++++++--------- 5 files changed, 62 insertions(+), 44 deletions(-) diff --git a/matlab/tests/equalizer_test.m b/matlab/tests/equalizer_test.m index a8fa65edc..0d51c372e 100644 --- a/matlab/tests/equalizer_test.m +++ b/matlab/tests/equalizer_test.m @@ -6,8 +6,8 @@ clear plot_noise_estimation_only=false; -SNR_values_db=linspace(0,10,5); -Nrealizations=10; +SNR_values_db=100;%linspace(20,35,8); +Nrealizations=1; w1=0.1; w2=0.3; @@ -26,11 +26,11 @@ P=K/6; cfg.Seed = 0; % Random channel seed cfg.InitTime = 0; cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'ETU'; +cfg.DelayProfile = 'EPA'; % doppler 5, 70 300 -cfg.DopplerFreq = 70; % 120Hz Doppler frequency +cfg.DopplerFreq = 5; % 120Hz Doppler frequency cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation cfg.NTerms = 16; % Oscillators used in fading model cfg.ModelType = 'GMEDS'; % Rayleigh fading model type @@ -211,13 +211,14 @@ if (length(SNR_values_db) == 1) plot(n,abs(reshape(hest{i}(:,sym),1,[])),colors2{i}); hold on; end - plot(ref_idx_x,abs(hls(3,ref_idx)),'ro'); + plot(n, abs(h(:,sym)),'g-') +% plot(ref_idx_x,real(hls(3,ref_idx)),'ro'); hold off; tmp=cell(Ntests+1,1); for i=1:Ntests tmp{i}=legends{i}; end - tmp{Ntests+1}='LS'; + tmp{Ntests+1}='Real'; legend(tmp) xlabel('SNR (dB)') diff --git a/matlab/tests/pdsch_bler_equal.m b/matlab/tests/pdsch_bler_equal.m index b9bda08ba..665ff8047 100644 --- a/matlab/tests/pdsch_bler_equal.m +++ b/matlab/tests/pdsch_bler_equal.m @@ -7,8 +7,8 @@ recordedSignal=[]; -Npackets = 20; -SNR_values = linspace(2,6,10); +Npackets = 1; +SNR_values = 56;%linspace(2,6,10); Lp=12; N=256; @@ -35,11 +35,11 @@ w2=reshape(transpose(W2),1,[]); %% Choose RMC -[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.0',[1;0;0;1]); +[waveform,rgrid,rmccFgOut] = lteRMCDLTool('R.5',[1;0;0;1]); waveform = sum(waveform,2); if ~isempty(recordedSignal) - rmccFgOut = struct('CellRefP',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal'); + rmccFgOut = struct('CellRefP',1,'NDLRB',25,'DuplexMode','FDD','CyclicPrefix','Normal'); rmccFgOut.PDSCH.RNTI = 1234; rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2); rmccFgOut.PDSCH.TxScheme = 'Port0'; @@ -53,7 +53,7 @@ end flen=rmccFgOut.SamplingRate/1000; -Nsf = 9; +Nsf = 2; %% Setup Fading channel model cfg.Seed = 0; % Random channel seed @@ -71,8 +71,8 @@ cfg.SamplingRate = rmccFgOut.SamplingRate; % Setup channel equalizer cec.PilotAverage = 'UserDefined'; % Type of pilot averaging -cec.FreqWindow = 9; % Frequency window size -cec.TimeWindow = 9; % Time window size +cec.FreqWindow = 1; % Frequency window size +cec.TimeWindow = 1; % Time window size cec.InterpType = 'linear'; % 2D interpolation type cec.InterpWindow = 'Causal'; % Interpolation window type cec.InterpWinSize = 1; % Interpolation window size @@ -95,8 +95,9 @@ for snr_idx=1:length(SNR_values) if isempty(recordedSignal) %% Fading - %rxWaveform = lteFadingChannel(cfg,waveform); - rxWaveform = waveform; + [rxWaveform, chinfo] = lteFadingChannel(cfg,waveform); + rxWaveform = rxWaveform(chinfo.ChannelFilterDelay+1:end); + %rxWaveform = waveform; %% Noise Addition noise = N0*complex(randn(size(rxWaveform)), randn(size(rxWaveform))); % Generate noise @@ -154,6 +155,7 @@ if (length(SNR_values)>1) ylabel('BLER') axis([min(SNR_values) max(SNR_values) 1/Npackets/(Nsf+1) 1]) else + scatter(real(symbols{1}),imag(symbols{1})) fprintf('Matlab: %d OK\nsrsLTE: %d OK\n',decoded, decoded_srslte); end diff --git a/matlab/tests/pdsch_decode_signal.m b/matlab/tests/pdsch_decode_signal.m index cf082ae46..29812f8f6 100644 --- a/matlab/tests/pdsch_decode_signal.m +++ b/matlab/tests/pdsch_decode_signal.m @@ -1,17 +1,17 @@ -enb=struct('NCellID',1,'NDLRB',50,'NSubframe',2,'CFI',2,'CyclicPrefix','Normal','CellRefP',1,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); +enb=struct('NCellID',0,'NDLRB',25,'NSubframe',4,'CFI',3,'CyclicPrefix','Normal','CellRefP',1,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); -RNTI=65535; +RNTI=62; addpath('../../build/srslte/lib/phch/test') cec.PilotAverage = 'UserDefined'; % Type of pilot averaging -cec.FreqWindow = 9; % Frequency window size -cec.TimeWindow = 9; % Time window size +cec.FreqWindow = 1; % Frequency window size +cec.TimeWindow = 1; % Time window size cec.InterpType = 'linear'; % 2D interpolation type cec.InterpWindow = 'Causal'; % Interpolation window type cec.InterpWinSize = 1; % Interpolation window size -subframe_rx=lteOFDMDemodulate(enb,y); +subframe_rx=lteOFDMDemodulate(enb,x); %subframe_rx=reshape(input,[],14); [hest,nest] = lteDLChannelEstimate(enb, cec, subframe_rx); @@ -30,9 +30,9 @@ if ~isempty(dci) % Get the PDSCH configuration from the DCI [pdsch, trblklen] = hPDSCHConfiguration(enb, dci, pdcch.RNTI); pdsch.NTurboDecIts = 10; - pdsch.Modulation = {'QPSK'}; + pdsch.Modulation = {'64QAM'}; pdsch.RV=0; - %trblklen=75376; + trblklen=14112; fprintf('PDSCH settings after DCI decoding:\n'); disp(pdsch); @@ -41,9 +41,10 @@ if ~isempty(dci) [pdschIndices,pdschIndicesInfo] = ltePDSCHIndices(enb, pdsch, pdsch.PRBSet); [pdschRx, pdschHest] = lteExtractResources(pdschIndices, subframe_rx, hest); % Decode PDSCH - [dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, nest); + [dlschBits,pdschSymbols] = ltePDSCHDecode(enb, pdsch, pdschRx, pdschHest, 0); [sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits); + %[dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ... % trblklen, ... % subframe_rx, hest, nest); diff --git a/srslte/include/srslte/ch_estimation/chest_dl.h b/srslte/include/srslte/ch_estimation/chest_dl.h index 95688b07c..165293bb9 100644 --- a/srslte/include/srslte/ch_estimation/chest_dl.h +++ b/srslte/include/srslte/ch_estimation/chest_dl.h @@ -52,6 +52,12 @@ #define SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN 65 +typedef enum { + SRSLTE_NOISE_ALG_REFS, + SRSLTE_NOISE_ALG_PSS, + SRSLTE_NOISE_ALG_EMPTY, +} srslte_chest_dl_noise_alg_t; + typedef struct { srslte_cell_t cell; srslte_refsignal_cs_t csr_signal; @@ -78,6 +84,9 @@ typedef struct { cf_t pss_signal[SRSLTE_PSS_LEN]; cf_t tmp_pss[SRSLTE_PSS_LEN]; cf_t tmp_pss_noisy[SRSLTE_PSS_LEN]; + + srslte_chest_dl_noise_alg_t noise_alg; + } srslte_chest_dl_t; @@ -93,6 +102,9 @@ SRSLTE_API void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, SRSLTE_API void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w); +SRSLTE_API void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q, + srslte_chest_dl_noise_alg_t noise_estimation_alg); + SRSLTE_API int srslte_chest_dl_estimate(srslte_chest_dl_t *q, cf_t *input, cf_t *ce[SRSLTE_MAX_PORTS], diff --git a/srslte/lib/ch_estimation/chest_dl.c b/srslte/lib/ch_estimation/chest_dl.c index e5963aac7..2d06c6fc1 100644 --- a/srslte/lib/ch_estimation/chest_dl.c +++ b/srslte/lib/ch_estimation/chest_dl.c @@ -39,8 +39,6 @@ #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" -#define ESTIMATE_NOISE_LS_PSS - //#define DEFAULT_FILTER_LEN 3 #ifdef DEFAULT_FILTER_LEN @@ -125,6 +123,8 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell) goto clean_exit; } + q->noise_alg = SRSLTE_NOISE_ALG_PSS; + q->smooth_filter_len = 3; srslte_chest_dl_set_smooth_filter3_coeff(q, 0.1); @@ -189,7 +189,6 @@ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id) return power; } -#ifdef ESTIMATE_NOISE_LS_PSS static float estimate_noise_pss(srslte_chest_dl_t *q, cf_t *input, cf_t *ce) { /* Get PSS from received signal */ @@ -209,9 +208,6 @@ static float estimate_noise_pss(srslte_chest_dl_t *q, cf_t *input, cf_t *ce) return power; } - -#else - /* Uses the 5 empty transmitted SC before and after the SSS and PSS sequences for noise estimation */ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { int k_sss = (SRSLTE_CP_NSYMB(q->cell.cp) - 2) * q->cell.nof_prb * SRSLTE_NRE + q->cell.nof_prb * SRSLTE_NRE / 2 - 31; @@ -224,8 +220,6 @@ static float estimate_noise_empty_sc(srslte_chest_dl_t *q, cf_t *input) { return noise_power; } -#endif - #define cesymb(i) ce[SRSLTE_RE_IDX(q->cell.nof_prb,i,0)] @@ -283,6 +277,10 @@ void srslte_chest_dl_set_smooth_filter(srslte_chest_dl_t *q, float *filter, uint } } +void srslte_chest_dl_set_noise_alg(srslte_chest_dl_t *q, srslte_chest_dl_noise_alg_t noise_estimation_alg) { + q->noise_alg = noise_estimation_alg; +} + void srslte_chest_dl_set_smooth_filter3_coeff(srslte_chest_dl_t* q, float w) { q->smooth_filter_len = 3; @@ -321,24 +319,28 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u srslte_vec_prod_conj_ccc(q->pilot_recv_signal, q->csr_signal.pilots[port_id/2][sf_idx], q->pilot_estimates, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id)); if (ce != NULL) { - if (q->smooth_filter_len > 0) { - average_pilots(q, q->pilot_estimates, q->pilot_estimates_average, port_id); - interpolate_pilots(q, q->pilot_estimates_average, ce, port_id); - - /* If averaging, compute noise from difference between received and averaged estimates */ - q->noise_estimate[port_id] = estimate_noise_pilots(q, port_id); - } else { + + /* Smooth estimates (if applicable) and interpolate */ + if (q->smooth_filter_len == 0 || (q->smooth_filter_len == 3 && q->smooth_filter[0] == 0)) { interpolate_pilots(q, q->pilot_estimates, ce, port_id); - - /* If not averaging, compute noise from empty subcarriers */ -#ifdef ESTIMATE_NOISE_LS_PSS + } else { + average_pilots(q, q->pilot_estimates, q->pilot_estimates_average, port_id); + interpolate_pilots(q, q->pilot_estimates_average, ce, port_id); + } + + /* Estimate noise power */ + if (q->noise_alg == SRSLTE_NOISE_ALG_REFS && q->smooth_filter_len > 0) { + q->noise_estimate[port_id] = estimate_noise_pilots(q, port_id); + } else if (q->noise_alg == SRSLTE_NOISE_ALG_PSS) { if (sf_idx == 0 || sf_idx == 5) { q->noise_estimate[port_id] = estimate_noise_pss(q, input, ce); } -#else - q->noise_estimate[port_id] = estimate_noise_empty_sc(q, input); -#endif + } else { + if (sf_idx == 0 || sf_idx == 5) { + q->noise_estimate[port_id] = estimate_noise_empty_sc(q, input); + } } + } /* Compute RSRP for the channel estimates in this port */ From a612009ea754c0f4e9394a5ad1f52912fd9c9071 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 17 May 2016 18:35:23 +0200 Subject: [PATCH 2/7] Fixed PDCCH not looking for aggregation level L=8. Fixed PCFICH encoder not accepting cfi=3 --- srslte/examples/pdsch_enodeb.c | 8 ++++++-- srslte/examples/pdsch_ue.c | 13 +++++++++---- srslte/lib/fec/viterbi.c | 6 ++++-- srslte/lib/phch/cqi.c | 6 +++++- srslte/lib/phch/pcfich.c | 4 ++-- srslte/lib/phch/pdcch.c | 2 +- srslte/lib/ue/ue_dl.c | 7 ++----- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 011164bd8..d593cfac5 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -66,7 +66,7 @@ srslte_cell_t cell = { int net_port = -1; // -1 generates random dataThat means there is some problem sending samples to the device -uint32_t cfi=2; +uint32_t cfi=3; uint32_t mcs_idx = 1, last_mcs_idx = 1; int nof_frames = -1; @@ -597,7 +597,11 @@ int main(int argc, char **argv) { for (i=0;iK = 7; q->R = 3; q->framebits = framebits; - q->gain_quant = 32; + q->gain_quant = DEFAULT_GAIN; q->tail_biting = tail_biting; q->decode = decode37; q->free = free37; @@ -168,7 +170,7 @@ int init37_sse(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool t q->K = 7; q->R = 3; q->framebits = framebits; - q->gain_quant = 20; + q->gain_quant = DEFAULT_GAIN; q->tail_biting = tail_biting; q->decode = decode37_sse; q->free = free37_sse; diff --git a/srslte/lib/phch/cqi.c b/srslte/lib/phch/cqi.c index 175065fcd..cbde55177 100644 --- a/srslte/lib/phch/cqi.c +++ b/srslte/lib/phch/cqi.c @@ -141,7 +141,11 @@ bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) { /* SNR-to-CQI conversion, got from "Downlink SNR to CQI Mapping for Different Multiple Antenna Techniques in LTE" * Table III. */ -static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29}; +// Original version +//static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29}; + +// From experimental measurements @ 5 MHz +static float cqi_to_snr_table[15] = { 0, 1.25, 2.5, 3.75, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5}; uint8_t srslte_cqi_from_snr(float snr) { diff --git a/srslte/lib/phch/pcfich.c b/srslte/lib/phch/pcfich.c index 96e5c9446..c102e2b28 100644 --- a/srslte/lib/phch/pcfich.c +++ b/srslte/lib/phch/pcfich.c @@ -134,7 +134,7 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) { /** Encodes the CFI producing a vector of 32 bits. * 36.211 10.3 section 5.3.4 */ -int srslte_pcfich_cfi_encode(int cfi, uint8_t bits[PCFICH_CFI_LEN]) { +int srslte_pcfich_cfi_encode(uint32_t cfi, uint8_t bits[PCFICH_CFI_LEN]) { if (cfi < 1 || cfi > 3) { return SRSLTE_ERROR_INVALID_INPUTS; } else{ @@ -220,7 +220,7 @@ int srslte_pcfich_encode(srslte_pcfich_t *q, uint32_t cfi, cf_t *slot_symbols[SR int i; if (q != NULL && - cfi < 3 && + cfi <= 3 && slot_symbols != NULL && subframe < SRSLTE_NSUBFRAMES_X_FRAME) { diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index 19256eb14..1123c0192 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -192,7 +192,7 @@ uint32_t srslte_pdcch_ue_locations(srslte_pdcch_t *q, srslte_dci_location_t *c, k = 0; // All aggregation levels from 8 to 1 - for (l = 0; l < 3; l++) { + for (l = 3; l >= 0; l--) { L = (1 << l); // For all possible ncce offset for (i = 0; i < SRSLTE_MIN(q->nof_cce / L, S[l]/PDCCH_FORMAT_NOF_CCE(l)); i++) { diff --git a/srslte/lib/ue/ue_dl.c b/srslte/lib/ue/ue_dl.c index ec8ed2447..fbb449653 100644 --- a/srslte/lib/ue/ue_dl.c +++ b/srslte/lib/ue/ue_dl.c @@ -194,16 +194,12 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf /* Correct SFO multiplying by complex exponential in the time domain */ if (q->sample_offset) { - struct timeval t[3]; - gettimeofday(&t[1], NULL); for (int i=0;i<2*SRSLTE_CP_NSYMB(q->cell.cp);i++) { srslte_cfo_correct(&q->sfo_correct, &q->sf_symbols[i*q->cell.nof_prb*SRSLTE_NRE], &q->sf_symbols[i*q->cell.nof_prb*SRSLTE_NRE], q->sample_offset / q->fft.symbol_sz); } - gettimeofday(&t[2], NULL); - get_time_interval(t); } return srslte_ue_dl_decode_estimate(q, sf_idx, cfi); @@ -221,7 +217,8 @@ int srslte_ue_dl_decode_estimate(srslte_ue_dl_t *q, uint32_t sf_idx, uint32_t *c /* First decode PCFICH and obtain CFI */ if (srslte_pcfich_decode(&q->pcfich, q->sf_symbols, q->ce, - srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, cfi, &cfi_corr)<0) { + srslte_chest_dl_get_noise_estimate(&q->chest), + sf_idx, cfi, &cfi_corr)<0) { fprintf(stderr, "Error decoding PCFICH\n"); return SRSLTE_ERROR; } From 43db80e7db9740f04910468a30de575147270b53 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 17 May 2016 18:36:21 +0200 Subject: [PATCH 3/7] pdsch_enodeb: transmitting all subframes --- srslte/examples/pdsch_enodeb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index d593cfac5..36a9f5a50 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -597,11 +597,12 @@ int main(int argc, char **argv) { for (i=0;i Date: Tue, 17 May 2016 18:47:48 +0200 Subject: [PATCH 4/7] viterbi: fixed failing test --- srslte/lib/fec/viterbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srslte/lib/fec/viterbi.c b/srslte/lib/fec/viterbi.c index 146644edc..6deb89903 100644 --- a/srslte/lib/fec/viterbi.c +++ b/srslte/lib/fec/viterbi.c @@ -40,7 +40,7 @@ #define TB_ITER 3 -#define DEFAULT_GAIN 10 +#define DEFAULT_GAIN 16 //#undef LV_HAVE_SSE From 82d55bde4f5a840e3e048838636173ebfb440e7b Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 18 May 2016 00:16:46 +0200 Subject: [PATCH 5/7] Fixed some issues with unsigned comparisons --- srslte/include/srslte/fec/convcoder.h | 2 +- srslte/include/srslte/fec/viterbi.h | 5 ++--- srslte/lib/fec/test/viterbi_test_mex.c | 2 +- srslte/lib/fec/viterbi.c | 8 ++++---- srslte/lib/fec/viterbi37.h | 4 ++-- srslte/lib/fec/viterbi37_port.c | 6 +++--- srslte/lib/fec/viterbi37_sse.c | 4 ++-- srslte/lib/phch/cqi.c | 2 +- srslte/lib/phch/pbch.c | 2 +- srslte/lib/phch/pdcch.c | 2 +- srslte/lib/phch/prach.c | 2 +- 11 files changed, 19 insertions(+), 20 deletions(-) diff --git a/srslte/include/srslte/fec/convcoder.h b/srslte/include/srslte/fec/convcoder.h index 820289fcf..1d51cbcbc 100644 --- a/srslte/include/srslte/fec/convcoder.h +++ b/srslte/include/srslte/fec/convcoder.h @@ -43,7 +43,7 @@ typedef struct SRSLTE_API { uint32_t R; uint32_t K; - uint32_t poly[3]; + int poly[3]; bool tail_biting; }srslte_convcoder_t; diff --git a/srslte/include/srslte/fec/viterbi.h b/srslte/include/srslte/fec/viterbi.h index 7493730f5..b00f09788 100644 --- a/srslte/include/srslte/fec/viterbi.h +++ b/srslte/include/srslte/fec/viterbi.h @@ -55,7 +55,6 @@ typedef struct SRSLTE_API{ uint32_t framebits; bool tail_biting; float gain_quant; - uint32_t poly[3]; int (*decode) (void*, uint8_t*, uint8_t*, uint32_t); int (*decode_f) (void*, float*, uint8_t*, uint32_t); void (*free) (void*); @@ -65,7 +64,7 @@ typedef struct SRSLTE_API{ SRSLTE_API int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, - uint32_t poly[3], + int poly[3], uint32_t max_frame_length, bool tail_bitting); @@ -88,7 +87,7 @@ SRSLTE_API int srslte_viterbi_decode_uc(srslte_viterbi_t *q, SRSLTE_API int srslte_viterbi_init_sse(srslte_viterbi_t *q, srslte_viterbi_type_t type, - uint32_t poly[3], + int poly[3], uint32_t max_frame_length, bool tail_bitting); diff --git a/srslte/lib/fec/test/viterbi_test_mex.c b/srslte/lib/fec/test/viterbi_test_mex.c index dfec6a533..9d1862ae5 100644 --- a/srslte/lib/fec/test/viterbi_test_mex.c +++ b/srslte/lib/fec/test/viterbi_test_mex.c @@ -60,7 +60,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) output_data = srslte_vec_malloc(nof_bits * sizeof(uint8_t)); - uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; + int poly[3] = { 0x6D, 0x4F, 0x57 }; if (srslte_viterbi_init(&viterbi, SRSLTE_VITERBI_37, poly, nof_bits/3, true)) { return; } diff --git a/srslte/lib/fec/viterbi.c b/srslte/lib/fec/viterbi.c index 6deb89903..218e70639 100644 --- a/srslte/lib/fec/viterbi.c +++ b/srslte/lib/fec/viterbi.c @@ -130,7 +130,7 @@ void free37(void *o) { delete_viterbi37_port(q->ptr); } -int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) { +int init37(srslte_viterbi_t *q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; q->framebits = framebits; @@ -166,7 +166,7 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_ } #ifdef LV_HAVE_SSE -int init37_sse(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) { +int init37_sse(srslte_viterbi_t *q, int poly[3], uint32_t framebits, bool tail_biting) { q->K = 7; q->R = 3; q->framebits = framebits; @@ -205,7 +205,7 @@ void srslte_viterbi_set_gain_quant(srslte_viterbi_t *q, float gain_quant) { q->gain_quant = gain_quant; } -int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_t poly[3], uint32_t max_frame_length, bool tail_bitting) +int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting) { switch (type) { case SRSLTE_VITERBI_37: @@ -221,7 +221,7 @@ int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_ } #ifdef LV_HAVE_SSE -int srslte_viterbi_init_sse(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_t poly[3], uint32_t max_frame_length, bool tail_bitting) +int srslte_viterbi_init_sse(srslte_viterbi_t *q, srslte_viterbi_type_t type, int poly[3], uint32_t max_frame_length, bool tail_bitting) { return init37_sse(q, poly, max_frame_length, tail_bitting); } diff --git a/srslte/lib/fec/viterbi37.h b/srslte/lib/fec/viterbi37.h index 36585daff..f5f304858 100644 --- a/srslte/lib/fec/viterbi37.h +++ b/srslte/lib/fec/viterbi37.h @@ -26,7 +26,7 @@ #include -void *create_viterbi37_port(uint32_t polys[3], +void *create_viterbi37_port(int polys[3], uint32_t len); int init_viterbi37_port(void *p, @@ -45,7 +45,7 @@ int update_viterbi37_blk_port(void *p, uint32_t *best_state); -void *create_viterbi37_sse(uint32_t polys[3], +void *create_viterbi37_sse(int polys[3], uint32_t len); int init_viterbi37_sse(void *p, diff --git a/srslte/lib/fec/viterbi37_port.c b/srslte/lib/fec/viterbi37_port.c index c55d95b4e..cf05b3c53 100644 --- a/srslte/lib/fec/viterbi37_port.c +++ b/srslte/lib/fec/viterbi37_port.c @@ -54,8 +54,8 @@ int init_viterbi37_port(void *p, int starting_state) { return 0; } -void set_viterbi37_polynomial_port(uint32_t polys[3]) { - uint32_t state; +void set_viterbi37_polynomial_port(int polys[3]) { + int state; for (state = 0; state < 32; state++) { Branchtab37[0].c[state] = @@ -68,7 +68,7 @@ void set_viterbi37_polynomial_port(uint32_t polys[3]) { } /* Create a new instance of a Viterbi decoder */ -void *create_viterbi37_port(uint32_t polys[3], uint32_t len) { +void *create_viterbi37_port(int polys[3], uint32_t len) { struct v37 *vp; set_viterbi37_polynomial_port(polys); diff --git a/srslte/lib/fec/viterbi37_sse.c b/srslte/lib/fec/viterbi37_sse.c index ffafd693d..3ecbfeefc 100644 --- a/srslte/lib/fec/viterbi37_sse.c +++ b/srslte/lib/fec/viterbi37_sse.c @@ -44,7 +44,7 @@ struct v37 { decision_t *decisions; /* Beginning of decisions for block */ }; -void set_viterbi37_polynomial_sse(uint32_t polys[3]) { +void set_viterbi37_polynomial_sse(int polys[3]) { int state; for(state=0;state < 32;state++){ @@ -73,7 +73,7 @@ int init_viterbi37_sse(void *p, int starting_state) { } /* Create a new instance of a Viterbi decoder */ -void *create_viterbi37_sse(uint32_t polys[3], uint32_t len) { +void *create_viterbi37_sse(int polys[3], uint32_t len) { void *p; struct v37 *vp; diff --git a/srslte/lib/phch/cqi.c b/srslte/lib/phch/cqi.c index cbde55177..6de7aa9ac 100644 --- a/srslte/lib/phch/cqi.c +++ b/srslte/lib/phch/cqi.c @@ -71,7 +71,7 @@ int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t b uint8_t *body_ptr = buff; srslte_bit_unpack(msg->subband_cqi, &body_ptr, 4); srslte_bit_unpack(msg->subband_label, &body_ptr, msg->subband_label_2_bits?2:1); - return 4+msg->subband_label_2_bits?2:1; + return 4+(msg->subband_label_2_bits)?2:1; } int srslte_cqi_value_pack(srslte_cqi_value_t *value, uint8_t buff[SRSLTE_CQI_MAX_BITS]) diff --git a/srslte/lib/phch/pbch.c b/srslte/lib/phch/pbch.c index 3dfaa07f1..40f9d4b5b 100644 --- a/srslte/lib/phch/pbch.c +++ b/srslte/lib/phch/pbch.c @@ -158,7 +158,7 @@ int srslte_pbch_init(srslte_pbch_t *q, srslte_cell_t cell) { goto clean; } - uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; + int poly[3] = { 0x6D, 0x4F, 0x57 }; if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, 40, true)) { goto clean; } diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index 1123c0192..a6a05decb 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -88,7 +88,7 @@ int srslte_pdcch_init(srslte_pdcch_t *q, srslte_regs_t *regs, srslte_cell_t cell } } - uint32_t poly[3] = { 0x6D, 0x4F, 0x57 }; + int poly[3] = { 0x6D, 0x4F, 0x57 }; if (srslte_viterbi_init(&q->decoder, SRSLTE_VITERBI_37, poly, SRSLTE_DCI_MAX_BITS + 16, true)) { goto clean; } diff --git a/srslte/lib/phch/prach.c b/srslte/lib/phch/prach.c index af9f71f59..dca6699e6 100644 --- a/srslte/lib/phch/prach.c +++ b/srslte/lib/phch/prach.c @@ -232,7 +232,7 @@ int srslte_prach_gen_seqs(srslte_prach_t *p) uint32_t d_u = 0; uint32_t d_start = 0; uint32_t N_shift = 0; - uint32_t N_neg_shift = 0; + int N_neg_shift = 0; uint32_t N_group = 0; uint32_t C_v = 0; cf_t root[839]; From e9d242f6b4ac1c1ea289b7d76b35cb7602219f56 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 18 May 2016 11:51:10 +0200 Subject: [PATCH 6/7] pcfich: fixed incorrect detection --- matlab/tests/pdcch_bler.m | 8 ++++---- srslte/examples/pdsch_ue.c | 4 ++-- srslte/lib/fec/viterbi.c | 2 +- srslte/lib/phch/pcfich.c | 8 +++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/matlab/tests/pdcch_bler.m b/matlab/tests/pdcch_bler.m index 1843d9e8c..d63883b7d 100644 --- a/matlab/tests/pdcch_bler.m +++ b/matlab/tests/pdcch_bler.m @@ -11,7 +11,7 @@ SNR_values = linspace(2,6,6); txCFI = 3; enbConfig.NDLRB = 15; % No of Downlink RBs in total BW enbConfig.CyclicPrefix = 'Normal'; % CP length -enbConfig.CFI = txCFI; ; % 4 PDCCH symbols as NDLRB <= 10 +enbConfig.CFI = txCFI; % 4 PDCCH symbols as NDLRB <= 10 enbConfig.Ng = 'One'; % HICH groups enbConfig.CellRefP = 1; % 1-antenna ports enbConfig.NCellID = 0; % Physical layer cell identity @@ -23,7 +23,7 @@ C_RNTI = 1; % 16-bit UE-specific mask %% Setup Fading channel model cfg.Seed = 8; % Random channel seed cfg.NRxAnts = 1; % 1 receive antenna -cfg.DelayProfile = 'EVA'; % EVA delay spread +cfg.DelayProfile = 'EPA'; % EVA delay spread cfg.DopplerFreq = 5; % 120Hz Doppler frequency cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation cfg.InitTime = 0; % Initialize at time zero @@ -56,7 +56,7 @@ dciConfig.Allocation.RIV = 26; % Resource indication value if C_RNTI<65535 pdcchConfig.RNTI = C_RNTI; % Radio network temporary identifier end -pdcchConfig.PDCCHFormat = 0; % PDCCH format +pdcchConfig.PDCCHFormat = 3; % PDCCH format ueConfig.RNTI = C_RNTI; candidates = ltePDCCHSpace(enbConfig, pdcchConfig, {'bits', '1based'}); @@ -153,7 +153,7 @@ for snr_idx=1:length(SNR_values) %% Same with srsLTE [rxCFI_srslte, pcfichRx2, pcfichSymbols2] = srslte_pcfich(enbConfigRx, subframe_rx); decoded_cfi_srslte(snr_idx) = decoded_cfi_srslte(snr_idx) + (rxCFI_srslte == txCFI); - enbConfigRx.CFI = rxCFI; + enbConfigRx.CFI = txCFI; [found_srslte, pdcchBits2, pdcchRx2, pdcchSymbols2, hest2] = srslte_pdcch(enbConfigRx, ueConfig.RNTI, subframe_rx, hest, nest); decoded_srslte(snr_idx) = decoded_srslte(snr_idx)+found_srslte; end diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 8665fd54e..d9e209aee 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -546,7 +546,7 @@ int main(int argc, char **argv) { #endif } - + nof_trials++; rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.1); @@ -585,7 +585,7 @@ int main(int argc, char **argv) { sfn++; if (sfn == 1024) { sfn = 0; - printf("reset\n"); + printf("\n"); ue_dl.pkt_errors = 0; ue_dl.pkts_total = 0; ue_dl.nof_detected = 0; diff --git a/srslte/lib/fec/viterbi.c b/srslte/lib/fec/viterbi.c index 218e70639..a301964cb 100644 --- a/srslte/lib/fec/viterbi.c +++ b/srslte/lib/fec/viterbi.c @@ -40,7 +40,7 @@ #define TB_ITER 3 -#define DEFAULT_GAIN 16 +#define DEFAULT_GAIN 20 //#undef LV_HAVE_SSE diff --git a/srslte/lib/phch/pcfich.c b/srslte/lib/phch/pcfich.c index c102e2b28..e1fc400a3 100644 --- a/srslte/lib/phch/pcfich.c +++ b/srslte/lib/phch/pcfich.c @@ -117,14 +117,16 @@ float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) { int i; int index = 0; float max_corr = 0; + float corr[3]; for (i = 0; i < 3; i++) { - float corr = fabsf(srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN)); - if (corr > max_corr) { - max_corr = corr; + corr[i] = srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN); + if (corr[i] > max_corr) { + max_corr = corr[i]; index = i; } } + if (cfi) { *cfi = index + 1; } From 3af3d12dffa0795c092c27f874b5a86148606c43 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 19 May 2016 12:40:31 +0200 Subject: [PATCH 7/7] Improved pdcch decoding --- srslte/lib/fec/viterbi.c | 4 ++-- srslte/lib/phch/cqi.c | 2 +- srslte/lib/phch/pdcch.c | 7 +++++-- srslte/lib/ue/ue_dl.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/srslte/lib/fec/viterbi.c b/srslte/lib/fec/viterbi.c index a301964cb..ee83204f0 100644 --- a/srslte/lib/fec/viterbi.c +++ b/srslte/lib/fec/viterbi.c @@ -40,7 +40,7 @@ #define TB_ITER 3 -#define DEFAULT_GAIN 20 +#define DEFAULT_GAIN 16 //#undef LV_HAVE_SSE @@ -248,7 +248,7 @@ int srslte_viterbi_decode_f(srslte_viterbi_t *q, float *symbols, uint8_t *data, } else { len = 3 * (frame_length + q->K - 1); } - if (!q->decode_f) { + if (!q->decode_f) { srslte_vec_quant_fuc(symbols, q->symbols_uc, q->gain_quant, 127.5, 255, len); return srslte_viterbi_decode_uc(q, q->symbols_uc, data, frame_length); } else { diff --git a/srslte/lib/phch/cqi.c b/srslte/lib/phch/cqi.c index 6de7aa9ac..99345968e 100644 --- a/srslte/lib/phch/cqi.c +++ b/srslte/lib/phch/cqi.c @@ -145,7 +145,7 @@ bool srslte_cqi_send(uint32_t I_cqi_pmi, uint32_t tti) { //static float cqi_to_snr_table[15] = { 1.95, 4, 6, 8, 10, 11.95, 14.05, 16, 17.9, 19.9, 21.5, 23.45, 25.0, 27.30, 29}; // From experimental measurements @ 5 MHz -static float cqi_to_snr_table[15] = { 0, 1.25, 2.5, 3.75, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5}; +static float cqi_to_snr_table[15] = { 1, 1.75, 3, 4, 5, 6, 7.5, 9, 11.5, 13.0, 15.0, 18, 20, 22.5, 26.5}; uint8_t srslte_cqi_from_snr(float snr) { diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index a6a05decb..86cf0b6d8 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -273,8 +273,10 @@ static int dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t E, ui { bzero(q->rm_f, sizeof(float)*3 * (SRSLTE_DCI_MAX_BITS + 16)); + uint32_t coded_len = 3 * (nof_bits + 16); + /* unrate matching */ - srslte_rm_conv_rx(e, E, q->rm_f, 3 * (nof_bits + 16)); + srslte_rm_conv_rx(e, E, q->rm_f, coded_len); /* viterbi decoder */ srslte_viterbi_decode_f(&q->decoder, q->rm_f, data, nof_bits + 16); @@ -286,6 +288,7 @@ static int dci_decode(srslte_pdcch_t *q, float *e, uint8_t *data, uint32_t E, ui if (crc) { *crc = p_bits ^ crc_res; } + return SRSLTE_SUCCESS; } else { fprintf(stderr, "Invalid parameters: E: %d, max_bits: %d, nof_bits: %d\n", E, q->max_bits, nof_bits); @@ -399,7 +402,7 @@ int srslte_pdcch_extract_llr(srslte_pdcch_t *q, cf_t *sf_symbols, cf_t *ce[SRSLT /* in control channels, only diversity is supported */ if (q->cell.nof_ports == 1) { /* no need for layer demapping */ - srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, nof_symbols, noise_estimate); + srslte_predecoding_single(q->symbols[0], q->ce[0], q->d, nof_symbols, noise_estimate/2); } else { srslte_predecoding_diversity(q->symbols[0], q->ce, x, q->cell.nof_ports, nof_symbols); srslte_layerdemap_diversity(x, q->d, q->cell.nof_ports, nof_symbols / q->cell.nof_ports); diff --git a/srslte/lib/ue/ue_dl.c b/srslte/lib/ue/ue_dl.c index fbb449653..69984a5d2 100644 --- a/srslte/lib/ue/ue_dl.c +++ b/srslte/lib/ue/ue_dl.c @@ -402,7 +402,7 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u return ret; } - if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, q->cfi)) { + if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, q->cfi)) { fprintf(stderr, "Error extracting LLRs\n"); return SRSLTE_ERROR; }