changed names. Added tutorial examples. MMSE not working correctly due to erroneous noise estimation under time misalignment

master
ismagom 10 years ago
parent a85a29afba
commit 1a5e064bbf

@ -4,9 +4,9 @@
clear
plot_noise_estimation_only=true;
plot_noise_estimation_only=false;
SNR_values_db=linspace(0,30,8);
SNR_values_db=20;%linspace(0,30,8);
Nrealizations=1 ;
preEVM = zeros(length(SNR_values_db),Nrealizations);
@ -80,7 +80,7 @@ for sf = 0:10
subframe = lteDLResourceGrid(enb);
% Map input symbols to grid
%subframe(:) = inputSym;
subframe(:) = inputSym;
% Generate synchronizing signals
pssSym = ltePSS(enb);
@ -141,13 +141,13 @@ rxWaveform = rxWaveform + noise;
%% Synchronization
offset = lteDLFrameOffset(enb,rxWaveform);
rxWaveform = rxWaveform(1+offset:end,:);
rxWaveform = rxWaveform(1+offset+2:end,:);
%% OFDM Demodulation
rxGrid = lteOFDMDemodulate(enb,rxWaveform);
rxGrid = rxGrid(:,1:140);
addpath('../../debug/lte/phy/lib/ch_estimation/test')
addpath('../../debug/srslte/lib/ch_estimation/test')
%% Channel Estimation
[estChannel, noiseEst(snr_idx)] = lteDLChannelEstimate(enb,cec,rxGrid);

@ -47,3 +47,5 @@ ADD_CUSTOM_TARGET (add_srslte_headers SOURCES ${HEADERS_ALL})
ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(examples)
add_subdirectory(tutorial_examples)

@ -43,7 +43,7 @@ typedef enum SRSLTE_API {
typedef struct SRSLTE_API {
float sigma; // noise power
srslte_demod_soft_alg_t alg_type; // soft demapping algorithm (SRSLTE_DEMOD_SOFT_ALG_EXACT or SRSLTE_DEMOD_SOFT_ALG_APPROX)
srslte_srslte_modem_table_t *table; // symbol mapping table (see modem_table.h)
srslte_modem_table_t *table; // symbol mapping table (see modem_table.h)
uint32_t *zones;
float *dd;
uint32_t max_symbols;
@ -55,7 +55,7 @@ SRSLTE_API int srslte_demod_soft_init(srslte_demod_soft_t *q,
SRSLTE_API void srslte_demod_soft_free(srslte_demod_soft_t *q);
SRSLTE_API void srslte_demod_soft_table_set(srslte_demod_soft_t *q,
srslte_srslte_modem_table_t *table);
srslte_modem_table_t *table);
SRSLTE_API void srslte_demod_soft_alg_set(srslte_demod_soft_t *q,
srslte_demod_soft_alg_t alg_type);
@ -72,7 +72,7 @@ SRSLTE_API int srslte_demod_soft_demodulate(srslte_demod_soft_t *q,
/* High-level API */
typedef struct SRSLTE_API {
srslte_demod_soft_t obj;
srslte_srslte_modem_table_t table;
srslte_modem_table_t table;
struct srslte_demod_soft_init{
srslte_mod_t std; // symbol mapping standard (see modem_table.h)

@ -35,14 +35,14 @@
#include "srslte/config.h"
#include "modem_table.h"
SRSLTE_API int srslte_mod_modulate(srslte_srslte_modem_table_t* table,
SRSLTE_API int srslte_mod_modulate(srslte_modem_table_t* table,
uint8_t *bits,
cf_t* symbols,
uint32_t nbits);
/* High-level API */
typedef struct SRSLTE_API {
srslte_srslte_modem_table_t obj;
srslte_modem_table_t obj;
struct mod_init {
srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init;

@ -49,22 +49,22 @@ typedef struct SRSLTE_API {
srslte_soft_table_t soft_table; // symbol-to-bit mapping (used in soft demodulating)
uint32_t nsymbols; // number of modulation symbols
uint32_t nbits_x_symbol; // number of bits per symbol
}srslte_srslte_modem_table_t;
}srslte_modem_table_t;
SRSLTE_API void srslte_modem_table_init(srslte_srslte_modem_table_t* q);
SRSLTE_API void srslte_modem_table_init(srslte_modem_table_t* q);
SRSLTE_API void srslte_modem_table_free(srslte_srslte_modem_table_t* q);
SRSLTE_API void srslte_modem_table_free(srslte_modem_table_t* q);
SRSLTE_API void srslte_modem_table_reset(srslte_srslte_modem_table_t* q);
SRSLTE_API void srslte_modem_table_reset(srslte_modem_table_t* q);
SRSLTE_API int srslte_modem_table_set(srslte_srslte_modem_table_t* q,
SRSLTE_API int srslte_modem_table_set(srslte_modem_table_t* q,
cf_t* table,
srslte_soft_table_t *soft_table,
uint32_t nsymbols,
uint32_t nbits_x_symbol);
SRSLTE_API int srslte_modem_table_lte(srslte_srslte_modem_table_t* q,
SRSLTE_API int srslte_modem_table_lte(srslte_modem_table_t* q,
srslte_mod_t modulation,
bool compute_soft_demod);

@ -69,7 +69,7 @@ typedef struct SRSLTE_API {
uint32_t frame_idx;
/* tx & rx objects */
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_soft_t demod;
srslte_sequence_t seq;
srslte_viterbi_t decoder;

@ -64,7 +64,7 @@ typedef struct SRSLTE_API {
float data_f[PCFICH_CFI_LEN];
/* tx & rx objects */
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_soft_t demod;
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_precoding_t precoding;

@ -69,7 +69,7 @@ typedef struct SRSLTE_API {
float *llr;
/* tx & rx objects */
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_soft_t demod;
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_viterbi_t decoder;

@ -62,7 +62,7 @@ typedef struct SRSLTE_API {
void *e;
/* tx & rx objects */
srslte_srslte_modem_table_t mod[4];
srslte_modem_table_t mod[4];
srslte_demod_soft_t demod;
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_precoding_t precoding;

@ -76,7 +76,7 @@ typedef struct SRSLTE_API {
uint8_t data[SRSLTE_PHICH_NBITS];
/* tx & rx objects */
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_hard_t demod;
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_precoding_t precoding;

@ -81,7 +81,7 @@ typedef struct SRSLTE_API {
void *g;
/* tx & rx objects */
srslte_srslte_modem_table_t mod[4];
srslte_modem_table_t mod[4];
srslte_demod_soft_t demod;
srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];
srslte_sequence_t seq_type2_fo;

@ -71,6 +71,8 @@ typedef struct SRSLTE_API {
cf_t *sf_symbols;
cf_t *ce[SRSLTE_MAX_PORTS];
srslte_dci_format_t dci_format;
uint32_t cfi;
uint64_t pkt_errors;
uint64_t pkts_total;
uint64_t nof_detected;

@ -94,6 +94,7 @@ typedef struct SRSLTE_API {
uint32_t sf_idx;
bool decode_sss_on_track;
bool correct_cfo;
uint32_t peak_idx;
int time_offset;

@ -92,7 +92,6 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
perror("malloc");
goto clean_exit;
}
bzero(q->tmp_timeavg_mult, sizeof(cf_t) * 2*cell.nof_prb);
for (int i=0;i<cell.nof_ports;i++) {
q->pilot_estimates[i] = srslte_vec_malloc(sizeof(cf_t) * SRSLTE_REFSIGNAL_NUM_SF(cell.nof_prb, i));
@ -123,13 +122,13 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
}
/* Set default time/freq filters */
//float f[3]={0.1, 0.8, 0.1};
//float f[3]={0.2, 0.6, 0.2};
//srslte_chest_dl_set_filter_freq(q, f, 3);
float f[5]={0.05, 0.2, 0.5, 0.2, 0.05};
float f[5]={0.1, 0.2, 0.4, 0.2, 0.1};
srslte_chest_dl_set_filter_freq(q, f, 5);
float t[2]={0.1, 0.9};
float t[2]={0.5, 0.5};
srslte_chest_dl_set_filter_time(q, t, 0);
q->cell = cell;
@ -269,14 +268,18 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id)
for (i=0;i<q->filter_time_len-1;i++) {
memcpy(q->tmp_timeavg[i], q->tmp_timeavg[i+1], nref*sizeof(cf_t));
}
/* Put last symbol to buffer */
memcpy(q->tmp_timeavg[i], &pilot_tmp(0), nref*sizeof(cf_t));
/* Save last symbol to buffer */
memcpy(q->tmp_timeavg[q->filter_time_len-1], &pilot_tmp(0), nref*sizeof(cf_t));
/* Multiply all symbols by filter and add them */
bzero(&pilot_avg(0), nref * sizeof(cf_t));
for (i=0;i<q->filter_time_len;i++) {
srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg[i], nref);
srslte_vec_sum_ccc(q->tmp_timeavg[i], &pilot_avg(0), &pilot_avg(0), nref);
if (l > 0) {
bzero(&pilot_avg(0), nref * sizeof(cf_t));
for (i=0;i<q->filter_time_len;i++) {
srslte_vec_sc_prod_cfc(q->tmp_timeavg[i], q->filter_time[i], q->tmp_timeavg_mult, nref);
srslte_vec_sum_ccc(q->tmp_timeavg_mult, &pilot_avg(0), &pilot_avg(0), nref);
}
} else {
memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t));
}
} else {
memcpy(&pilot_avg(0), &pilot_tmp(0), nref * sizeof(cf_t));

@ -71,7 +71,7 @@ void srslte_demod_soft_free(srslte_demod_soft_t *q) {
bzero((void*)q,sizeof(srslte_demod_soft_t));
}
void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_srslte_modem_table_t *table) {
void srslte_demod_soft_table_set(srslte_demod_soft_t *q, srslte_modem_table_t *table) {
q->table = table;
}

@ -35,7 +35,7 @@
/** Low-level API */
int srslte_mod_modulate(srslte_srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) {
int srslte_mod_modulate(srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) {
uint32_t i,j,idx;
uint8_t *b_ptr=(uint8_t*) bits;
j=0;

@ -38,26 +38,26 @@
#include "lte_tables.h"
/** Internal functions */
static int table_create(srslte_srslte_modem_table_t* q) {
static int table_create(srslte_modem_table_t* q) {
q->symbol_table = malloc(q->nsymbols*sizeof(cf_t));
return q->symbol_table==NULL;
}
void srslte_modem_table_init(srslte_srslte_modem_table_t* q) {
bzero((void*)q,sizeof(srslte_srslte_modem_table_t));
void srslte_modem_table_init(srslte_modem_table_t* q) {
bzero((void*)q,sizeof(srslte_modem_table_t));
}
void srslte_modem_table_free(srslte_srslte_modem_table_t* q) {
void srslte_modem_table_free(srslte_modem_table_t* q) {
if (q->symbol_table) {
free(q->symbol_table);
}
bzero(q, sizeof(srslte_srslte_modem_table_t));
bzero(q, sizeof(srslte_modem_table_t));
}
void srslte_modem_table_reset(srslte_srslte_modem_table_t* q) {
void srslte_modem_table_reset(srslte_modem_table_t* q) {
srslte_modem_table_free(q);
srslte_modem_table_init(q);
}
int srslte_modem_table_set(srslte_srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) {
int srslte_modem_table_set(srslte_modem_table_t* q, cf_t* table, srslte_soft_table_t *soft_table, uint32_t nsymbols, uint32_t nbits_x_symbol) {
if (q->nsymbols) {
return SRSLTE_ERROR;
}
@ -71,7 +71,7 @@ int srslte_modem_table_set(srslte_srslte_modem_table_t* q, cf_t* table, srslte_s
return SRSLTE_SUCCESS;
}
int srslte_modem_table_lte(srslte_srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) {
int srslte_modem_table_lte(srslte_modem_table_t* q, srslte_mod_t modulation, bool compute_soft_demod) {
switch(modulation) {
case SRSLTE_MOD_BPSK:
q->nbits_x_symbol = 1;

@ -94,7 +94,7 @@ void parse_args(int argc, char **argv) {
int main(int argc, char **argv) {
int i;
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_hard_t demod_hard;
srslte_demod_soft_t demod_soft;
uint8_t *input, *output;

@ -108,7 +108,7 @@ float mse_threshold() {
int main(int argc, char **argv) {
int i;
srslte_srslte_modem_table_t mod;
srslte_modem_table_t mod;
srslte_demod_soft_t demod_soft;
uint8_t *input, *output;
cf_t *symbols;

@ -802,13 +802,13 @@ int srslte_dci_msg_unpack_pusch(srslte_dci_msg_t *msg, srslte_ra_pusch_t *data,
}
srslte_dci_format_t srslte_dci_format_from_string(char *str) {
if (!strcmp(str, "SRSLTE_DCI_FORMAT0")) {
if (!strcmp(str, "Format0")) {
return SRSLTE_DCI_FORMAT0;
} else if (!strcmp(str, "SRSLTE_DCI_FORMAT1")) {
} else if (!strcmp(str, "Format1")) {
return SRSLTE_DCI_FORMAT1;
} else if (!strcmp(str, "SRSLTE_DCI_FORMAT1A")) {
} else if (!strcmp(str, "Format1A")) {
return SRSLTE_DCI_FORMAT1A;
} else if (!strcmp(str, "SRSLTE_DCI_FORMAT1C")) {
} else if (!strcmp(str, "Format1C")) {
return SRSLTE_DCI_FORMAT1C;
} else {
return SRSLTE_DCI_FORMAT_ERROR;
@ -818,13 +818,13 @@ srslte_dci_format_t srslte_dci_format_from_string(char *str) {
char* srslte_dci_format_string(srslte_dci_format_t format) {
switch (format) {
case SRSLTE_DCI_FORMAT0:
return "SRSLTE_DCI_FORMAT0";
return "Format0";
case SRSLTE_DCI_FORMAT1:
return "SRSLTE_DCI_FORMAT1";
return "Format1";
case SRSLTE_DCI_FORMAT1A:
return "SRSLTE_DCI_FORMAT1A";
return "Format1A";
case SRSLTE_DCI_FORMAT1C:
return "SRSLTE_DCI_FORMAT1C";
return "Format1C";
default:
return "N/A"; // fatal error
}

@ -36,7 +36,7 @@
#include "srslte/sync/cfo.h"
#define MEANPEAK_EMA_ALPHA 0.2
#define CFO_EMA_ALPHA 0.01
#define CFO_EMA_ALPHA 0.1
#define CP_EMA_ALPHA 0.2
static bool fft_size_isvalid(uint32_t fft_size) {

@ -196,7 +196,7 @@ int srslte_ue_dl_decode_fft_estimate(srslte_ue_dl_t *q, cf_t *input, uint32_t sf
}
/* Extract all PDCCH symbols and get LLRs */
if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, *cfi)) {
if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, 0, sf_idx, *cfi)) {
fprintf(stderr, "Error extracting LLRs\n");
return SRSLTE_ERROR;
}
@ -228,7 +228,7 @@ int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_
}
if (q->harq_process[0].mcs.mod > 0 && q->harq_process[0].mcs.tbs >= 0) {
ret = srslte_pdsch_decode_rnti(&q->pdsch, &q->harq_process[0], q->sf_symbols,
q->ce, srslte_chest_dl_get_noise_estimate(&q->chest),
q->ce, 0,
rnti, data);
if (ret == SRSLTE_ERROR) {
q->pkt_errors++;
@ -262,7 +262,7 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint3
int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, uint32_t sf_idx, uint16_t rnti, uint32_t rvidx)
{
uint32_t cfi, i;
uint32_t i;
srslte_dci_msg_t dci_msg;
srslte_dci_location_t locations[MAX_CANDIDATES];
uint32_t nof_locations;
@ -271,17 +271,17 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u
uint32_t nof_formats;
srslte_dci_format_t *formats = NULL;
if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &cfi)) < 0) {
if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &q->cfi)) < 0) {
return ret;
}
/* Generate PDCCH candidates */
if (rnti == SRSLTE_SIRNTI) {
nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, cfi);
nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, q->cfi);
formats = common_formats;
nof_formats = nof_common_formats;
} else {
nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti);
nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, q->cfi, rnti);
formats = ue_formats;
nof_formats = nof_ue_formats;
}
@ -299,8 +299,9 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u
INFO("Decoded DCI message RNTI: 0x%x\n", srslte_crc_rem);
if (srslte_crc_rem == rnti) {
q->dci_format = formats[f];
found_dci++;
ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, cfi, sf_idx, rnti, rvidx);
ret = srslte_ue_dl_decode_rnti_rv_packet(q, &dci_msg, data, q->cfi, sf_idx, rnti, rvidx);
}
}
}

@ -63,7 +63,7 @@ int srslte_ue_sync_init_file(srslte_ue_sync_t *q, uint32_t nof_prb, char *file_n
goto clean_exit;
}
q->input_buffer = srslte_vec_malloc(q->sf_len * sizeof(cf_t));
q->input_buffer = srslte_vec_malloc(2 * q->sf_len * sizeof(cf_t));
if (!q->input_buffer) {
perror("malloc");
goto clean_exit;
@ -102,6 +102,7 @@ int srslte_ue_sync_init(srslte_ue_sync_t *q,
q->fft_size = srslte_symbol_sz(q->cell.nof_prb);
q->sf_len = SRSLTE_SF_LEN(q->fft_size);
q->file_mode = false;
q->correct_cfo = true;
if (cell.id == 1000) {
/* If the cell is unkown, decode SSS on track state */
@ -449,7 +450,7 @@ int srslte_ue_sync_get_buffer(srslte_ue_sync_t *q, cf_t **sf_symbols) {
}
/* Do CFO Correction if not done in track and deliver the frame */
if (!q->strack.correct_cfo) {
if (!q->strack.correct_cfo && q->correct_cfo) {
srslte_cfo_correct(&q->sfind.cfocorr,
q->input_buffer,
q->input_buffer,

Loading…
Cancel
Save