Fixed issue in PBCH decoding N_id_2=2. Changed measurements average to exponential. Moved MMSE diversity equalizer to ZF.

master
ismagom 10 years ago
parent d56fc6d26d
commit 92e0db231c

@ -350,17 +350,20 @@ int main(int argc, char **argv) {
} }
break; break;
case MEASURE: case MEASURE:
/* Run FFT for all subframe data */
lte_fft_run_sf(&fft, sf_buffer, sf_symbols);
chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync)); if (ue_sync_get_sfidx(&ue_sync) == 5) {
/* Run FFT for all subframe data */
lte_fft_run_sf(&fft, sf_buffer, sf_symbols);
rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SF_LEN(lte_symbol_sz(cell.nof_prb))),rssi,nframes); chest_dl_estimate(&chest, sf_symbols, ce, ue_sync_get_sfidx(&ue_sync));
rssi_utra = VEC_CMA(chest_dl_get_rssi(&chest),rssi_utra,nframes);
rsrq = VEC_EMA(chest_dl_get_rsrq(&chest),rsrq,0.001); rssi = VEC_CMA(vec_avg_power_cf(sf_buffer,SF_LEN(lte_symbol_sz(cell.nof_prb))),rssi,nframes);
rsrp = VEC_CMA(chest_dl_get_rsrp(&chest),rsrp,nframes); rssi_utra = VEC_CMA(chest_dl_get_rssi(&chest),rssi_utra,nframes);
snr = VEC_CMA(chest_dl_get_snr(&chest),snr,nframes); rsrq = VEC_EMA(chest_dl_get_rsrq(&chest),rsrq,0.001);
nframes++; rsrp = VEC_EMA(chest_dl_get_rsrp(&chest),rsrp,0.001);
snr = VEC_EMA(chest_dl_get_snr(&chest),snr,0.001);
nframes++;
}
// Plot and Printf // Plot and Printf
if ((nframes%10) == 0) { if ((nframes%10) == 0) {

@ -241,7 +241,7 @@ int cell_scanner_cell(cell_scanner_t *q, float frequency, int N_id_2, cell_scann
result->rssi,nframes_measure); result->rssi,nframes_measure);
result->rsrq = VEC_EMA(chest_dl_get_rsrq(chest_ptr),result->rsrq,0.01); result->rsrq = VEC_EMA(chest_dl_get_rsrq(chest_ptr),result->rsrq,0.01);
result->rsrp = VEC_CMA(chest_dl_get_rsrp(chest_ptr),result->rsrp,nframes_measure); result->rsrp = VEC_CMA(chest_dl_get_rsrp(chest_ptr),result->rsrp,nframes_measure);
result->snr = VEC_CMA(chest_dl_get_snr(chest_ptr),result->snr,nframes_measure); result->snr = VEC_EMA(chest_dl_get_snr(chest_ptr),result->snr,0.01);
nframes_measure++; nframes_measure++;
// Plot and Printf // Plot and Printf

@ -246,7 +246,7 @@ int main(int argc, char **argv) {
// Variables for measurements // Variables for measurements
uint32_t nframes=0; uint32_t nframes=0;
float rsrp=1.0, rsrq=1.0, snr=1.0; float rsrp=0.0, rsrq=0.0, snr=0.0;
/* Main loop */ /* Main loop */
while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) {
@ -276,6 +276,7 @@ int main(int argc, char **argv) {
} }
break; break;
case DECODE_SIB: case DECODE_SIB:
sfn=0;
/* We are looking for SI Blocks, search only in appropiate places */ /* We are looking for SI Blocks, search only in appropiate places */
if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) { if ((ue_sync_get_sfidx(&ue_sync) == 5 && (sfn%2)==0)) {
n = ue_dl_decode_sib(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync), n = ue_dl_decode_sib(&ue_dl, sf_buffer, data, ue_sync_get_sfidx(&ue_sync),
@ -285,19 +286,18 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
nof_trials++; nof_trials++;
}
rsrq = VEC_EMA(chest_dl_get_rsrq(&ue_dl.chest),rsrq,0.001);
rsrp = VEC_CMA(chest_dl_get_rsrp(&ue_dl.chest),rsrp,nframes);
snr = VEC_CMA(chest_dl_get_snr(&ue_dl.chest),snr,nframes);
nframes++;
if (isnan(rsrq)) { rsrq = VEC_EMA(chest_dl_get_rsrq(&ue_dl.chest),rsrq,0.001);
rsrq = 0; rsrp = VEC_EMA(chest_dl_get_rsrp(&ue_dl.chest),rsrp,0.001);
snr = VEC_EMA(chest_dl_get_snr(&ue_dl.chest),snr,0.001);
nframes++;
if (isnan(rsrq)) {
rsrq = 0;
}
} }
// Plot and Printf // Plot and Printf
if (ue_sync_get_sfidx(&ue_sync) == 0) { if (ue_sync_get_sfidx(&ue_sync) == 5) {
printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, " printf("CFO: %+8.4f KHz, SFO: %+8.4f Khz, "
"RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %4.1f dB, " "RSRP: %+5.1f dBm, RSRQ: %5.1f dB, SNR: %4.1f dB, "
"PDCCH-Miss: %5.2f%%, PDSCH-BLER: %5.2f%% (%d blocks)\r", "PDCCH-Miss: %5.2f%%, PDSCH-BLER: %5.2f%% (%d blocks)\r",

@ -359,7 +359,8 @@ float chest_dl_get_snr(chest_dl_t *q) {
float snr = 0.0; float snr = 0.0;
for (int i=0;i<q->cell.nof_ports;i++) { for (int i=0;i<q->cell.nof_ports;i++) {
if (q->noise_estimate[i]) { if (q->noise_estimate[i]) {
snr += q->rsrp[i]/(q->noise_estimate[i]*sqrtf(2*q->cell.nof_ports*lte_symbol_sz(q->cell.nof_prb))); float snr_i = q->rsrp[i]/(q->noise_estimate[i]*sqrtf(2*q->cell.nof_ports*lte_symbol_sz(q->cell.nof_prb)));
snr += snr_i;
} }
} }
return snr/q->cell.nof_ports; return snr/q->cell.nof_ports;

@ -169,10 +169,10 @@ int predecoding_diversity(precoding_t *q, cf_t *y, cf_t *h[MAX_PORTS], cf_t *x[M
vec_abs_square_cf(h0, modh0, nof_symbols/2); vec_abs_square_cf(h0, modh0, nof_symbols/2);
vec_abs_square_cf(h1, modh1, nof_symbols/2); vec_abs_square_cf(h1, modh1, nof_symbols/2);
vec_sum_fff(modh0, modh1, modhh, nof_symbols/2); vec_sum_fff(modh0, modh1, modhh, nof_symbols/2);
if (noise_estimate > 0.0) { //if (noise_estimate > 0.0) {
// (H'H + n0) // (H'H + n0)
vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2); //vec_sc_add_fff(modhh, noise_estimate, modhh, nof_symbols/2);
} //}
vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2); vec_sc_prod_fff(modhh, 1/sqrt(2), modhh, nof_symbols/2);

@ -50,10 +50,14 @@ bool pbch_exists(int nframe, int nslot) {
return (!(nframe % 5) && nslot == 1); return (!(nframe % 5) && nslot == 1);
} }
cf_t *offset_original;
int pbch_cp(cf_t *input, cf_t *output, lte_cell_t cell, bool put) { int pbch_cp(cf_t *input, cf_t *output, lte_cell_t cell, bool put) {
int i; int i;
cf_t *ptr; cf_t *ptr;
offset_original = input;
if (put) { if (put) {
ptr = input; ptr = input;
output += cell.nof_prb * RE_X_RB / 2 - 36; output += cell.nof_prb * RE_X_RB / 2 - 36;
@ -66,9 +70,9 @@ int pbch_cp(cf_t *input, cf_t *output, lte_cell_t cell, bool put) {
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put); prb_cp_ref(&input, &output, cell.id % 3, 4, 4*6, put);
if (put) { if (put) {
output += cell.nof_prb * RE_X_RB - 2*36; output += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0);
} else { } else {
input += cell.nof_prb * RE_X_RB - 2*36; input += cell.nof_prb * RE_X_RB - 2*36 + (cell.id%3==2?1:0);
} }
} }
/* symbols 2 & 3 */ /* symbols 2 & 3 */

@ -32,17 +32,20 @@
#include "prb.h" #include "prb.h"
#include "liblte/phy/common/phy_common.h" #include "liblte/phy/common/phy_common.h"
//#define DEBUG_IDX #define DEBUG_IDX
#ifdef DEBUG_IDX #ifdef DEBUG_IDX
extern cf_t *offset_original; extern cf_t *offset_original;
LIBLTE_API int indices[2048];
int indices_ptr=0;
#endif #endif
void print_indexes(cf_t *offset, int len) { void print_indexes(cf_t *offset, int len) {
#ifdef DEBUG_IDX #ifdef DEBUG_IDX
for (int i=0;i<len;i++) { for (int i=0;i<len;i++) {
printf("%d, ",offset-offset_original+i); indices[(i+indices_ptr)%2048]=offset-offset_original+i;
} }
indices_ptr+=len;
#endif #endif
} }

@ -27,6 +27,7 @@
#define INPUT prhs[1] #define INPUT prhs[1]
#define NOF_INPUTS 2 #define NOF_INPUTS 2
extern int indices[2048];
void help() void help()
{ {
@ -47,7 +48,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
int nof_re; int nof_re;
cf_t *ce[MAX_PORTS], *ce_slot[MAX_PORTS]; cf_t *ce[MAX_PORTS], *ce_slot[MAX_PORTS];
if (nrhs != NOF_INPUTS) { if (nrhs < NOF_INPUTS) {
help(); help();
return; return;
} }
@ -84,7 +85,25 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
lte_fft_run_sf(&fft, input_symbols, input_fft); lte_fft_run_sf(&fft, input_symbols, input_fft);
chest_dl_estimate(&chest, input_fft, ce, 0);
if (nrhs > NOF_INPUTS) {
cf_t *cearray;
mexutils_read_cf(prhs[NOF_INPUTS], &cearray);
for (i=0;i<cell.nof_ports;i++) {
for (int j=0;j<nof_re;j++) {
ce[i][j] = *cearray;
cearray++;
}
}
} else {
chest_dl_estimate(&chest, input_fft, ce, 0);
}
float noise_power;
if (nrhs > NOF_INPUTS + 1) {
noise_power = mxGetScalar(prhs[NOF_INPUTS+1]);
} else {
noise_power = chest_dl_get_noise_estimate(&chest);
}
for (int i=0;i<MAX_PORTS;i++) { for (int i=0;i<MAX_PORTS;i++) {
ce_slot[i] = &ce[i][SLOT_LEN_RE(cell.nof_prb, cell.cp)]; ce_slot[i] = &ce[i][SLOT_LEN_RE(cell.nof_prb, cell.cp)];
@ -92,7 +111,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
uint32_t nof_ports; uint32_t nof_ports;
int n = pbch_decode(&pbch, &input_fft[SLOT_LEN_RE(cell.nof_prb, cell.cp)], int n = pbch_decode(&pbch, &input_fft[SLOT_LEN_RE(cell.nof_prb, cell.cp)],
ce_slot, chest_dl_get_noise_estimate(&chest), ce_slot, noise_power,
NULL, &nof_ports, NULL); NULL, &nof_ports, NULL);
if (nlhs >= 1) { if (nlhs >= 1) {
@ -114,6 +133,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (nlhs >= 5) { if (nlhs >= 5) {
mexutils_write_cf(ce[1], &plhs[4], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14); mexutils_write_cf(ce[1], &plhs[4], SF_LEN_RE(cell.nof_prb,cell.cp)/14, 14);
} }
if (nlhs >= 6) {
mexutils_write_cf(pbch.pbch_symbols[0], &plhs[5], pbch.nof_symbols, 1);
}
if (nlhs >= 7) {
mexutils_write_cf(pbch.ce[0], &plhs[6], pbch.nof_symbols, 1);
}
if (nlhs >= 7) {
mexutils_write_int(indices, &plhs[7], 2048, 1);
}
chest_dl_free(&chest); chest_dl_free(&chest);
lte_fft_free(&fft); lte_fft_free(&fft);

@ -302,10 +302,10 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value)
conv_output_len = conv_cc(input, q->pss_signal_freq[q->N_id_2], q->conv_output, q->frame_size, q->fft_size); conv_output_len = conv_cc(input, q->pss_signal_freq[q->N_id_2], q->conv_output, q->frame_size, q->fft_size);
#endif #endif
} else { } else {
for (int i=0;i<q->frame_size-1;i++) { for (int i=0;i<q->frame_size;i++) {
q->conv_output[i] = vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], &input[i], q->fft_size); q->conv_output[i] = vec_dot_prod_ccc(q->pss_signal_freq[q->N_id_2], &input[i], q->fft_size);
} }
conv_output_len = q->frame_size-1; conv_output_len = q->frame_size;
} }
@ -364,13 +364,6 @@ int pss_synch_find_pss(pss_synch_t *q, cf_t *input, float *corr_peak_value)
1000000*q->conv_output_avg[corr_peak_pos], 1000000*side_lobe_value,*corr_peak_value 1000000*q->conv_output_avg[corr_peak_pos], 1000000*side_lobe_value,*corr_peak_value
); );
} }
if (isnan(*corr_peak_value) || isinf(*corr_peak_value)) {
int i=0;
vec_save_file("corrout", q->conv_output_avg, conv_output_len*sizeof(float));
exit(-1);
}
} }
#else #else
if (corr_peak_value) { if (corr_peak_value) {

@ -103,7 +103,7 @@ int ue_sync_init(ue_sync_t *q,
sync_set_threshold(&q->sfind, 1.1); sync_set_threshold(&q->sfind, 1.1);
sync_set_em_alpha(&q->sfind, 0.01); sync_set_em_alpha(&q->sfind, 0.01);
q->nof_avg_find_frames = FIND_NOF_AVG_FRAMES; q->nof_avg_find_frames = FIND_NOF_AVG_FRAMES;
sync_set_threshold(&q->strack, 2.0); sync_set_threshold(&q->strack, 1.2);
} else { } else {
sync_set_N_id_2(&q->sfind, cell.id%3); sync_set_N_id_2(&q->sfind, cell.id%3);

@ -3,8 +3,9 @@ rmc = lteRMCDL('R.10');
NofPortsTx=2; NofPortsTx=2;
SNR_values_db=1;%linspace(-6,5,8); SNR_values_db=linspace(-6,0,4);
Nrealizations=1; Nrealizations=50;
enb = struct('NCellID',0,'NDLRB',50,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
cfg.Seed = 8; % Random channel seed cfg.Seed = 8; % Random channel seed
@ -42,22 +43,20 @@ for snr_idx=1:length(SNR_values_db)
errorReal = zeros(Nrealizations,2); errorReal = zeros(Nrealizations,2);
for i=1:Nrealizations for i=1:Nrealizations
enb = struct('NCellID',311,'NDLRB',6,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
griddims = lteResourceGridSize(enb); % Resource grid dimensions griddims = lteResourceGridSize(enb); % Resource grid dimensions
L = griddims(2); L = griddims(2);
%rxWaveform = lteFadingChannel(cfg,waveform(:,1)); rxWaveform = lteFadingChannel(cfg,waveform(:,1));
%rxWaveform = waveform(:,1);
%% Additive Noise %% Additive Noise
%N0 = 1/(sqrt(2.0*double(enb.CellRefP)*double(info.Nfft))*SNR); N0 = 1/(sqrt(2.0*double(enb.CellRefP)*double(info.Nfft))*SNR);
% Create additive white Gaussian noise % Create additive white Gaussian noise
%noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform))); noise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform)));
%rxWaveform = noise + rxWaveform; rxWaveform = noise + rxWaveform;
rxWaveform = downsampled; % rxWaveform = downsampled;
% Number of OFDM symbols in a subframe % Number of OFDM symbols in a subframe
% OFDM demodulate signal % OFDM demodulate signal
@ -71,17 +70,16 @@ for snr_idx=1:length(SNR_values_db)
pbchIndices, rxgrid(:,1:L,:), hest(:,1:L,:,:)); pbchIndices, rxgrid(:,1:L,:), hest(:,1:L,:,:));
% Decode PBCH % Decode PBCH
[bchBits, pbchSymbols, nfmod4, mib, enb.CellRefP] = ltePBCHDecode( ... [bchBits, pbchSymbols, nfmod4, mib, nof_ports] = ltePBCHDecode( ...
enb, pbchRx, pbchHest, nest); enb, pbchRx, pbchHest, nest);
% Parse MIB bits if (nof_ports ~= NofPortsTx)
enb = lteMIB(mib, enb);
if (enb.CellRefP ~= NofPortsTx)
errorReal(i,1)=1; errorReal(i,1)=1;
end end
enb = struct('NCellID',311,'NDLRB',6,'CellRefP',NofPortsTx,'CyclicPrefix','Normal','DuplexMode','FDD','NSubframe',0);
[nof_ports, pbchSymbols2, pbchBits, ce, ce2]=liblte_pbch(enb, rxWaveform); [nof_ports2, pbchSymbols2, pbchBits, ce, ce2, pbchRx2, pbchHest2,indices]=...
if (nof_ports ~= NofPortsTx) liblte_pbch(enb, rxWaveform, hest, nest);
if (nof_ports2 ~= NofPortsTx)
errorReal(i,2)=1; errorReal(i,2)=1;
end end
% if (errorReal(i,1) ~= errorReal(i,2)) % if (errorReal(i,1) ~= errorReal(i,2))

@ -66,6 +66,11 @@ LIBLTE_API int mexutils_write_uint8(uint8_t *buffer,
uint32_t nr, uint32_t nr,
uint32_t nc); uint32_t nc);
LIBLTE_API int mexutils_write_int(int *buffer,
mxArray **ptr,
uint32_t nr,
uint32_t nc);
LIBLTE_API int mexutils_read_f(const mxArray *ptr, LIBLTE_API int mexutils_read_f(const mxArray *ptr,
float **buffer); float **buffer);

@ -138,3 +138,14 @@ int mexutils_write_uint8(uint8_t *buffer, mxArray **ptr, uint32_t nr, uint32_t n
return -1; return -1;
} }
} }
int mexutils_write_int(int *buffer, mxArray **ptr, uint32_t nr, uint32_t nc) {
*ptr = mxCreateNumericMatrix(nr, nc, mxINT32_CLASS, mxREAL);
if (*ptr) {
int *outr = (int*) mxGetPr(*ptr);
memcpy(outr, buffer, nr*nc*sizeof(int));
return nc*nr;
} else {
return -1;
}
}

Loading…
Cancel
Save