Tests with estimator

master
ismagom 10 years ago
parent 491a3c60f2
commit a690c2a232

@ -117,6 +117,7 @@ public:
if (i < nof_timers) {
return &timer_list[i];
} else {
printf("Error accessing invalid timer %d (Only %d timers available)\n", i, nof_timers);
return NULL;
}
}

@ -175,8 +175,8 @@ void mac::main_radio_loop() {
// Step all procedures
ra_procedure.step(tti);
//sr_procedure.step(tti);
bsr_procedure.step(tti);
phr_procedure.step(tti);
//bsr_procedure.step(tti);
//phr_procedure.step(tti);
// Check SR if we need to start RA
/*

@ -36,7 +36,6 @@ bsr_proc::bsr_proc()
initiated = false;
}
void bsr_proc::init(log* log_h_, mac_params* params_db_, mux *mux_unit_)
{
log_h = log_h;

@ -93,7 +93,7 @@ void ra_proc::read_params() {
iniReceivedTargetPower = params_db->get_param(mac_params::RA_INITRECEIVEDPOWER);
contentionResolutionTimer = params_db->get_param(mac_params::RA_CONTENTIONTIMER);
delta_preamble_db = delta_preamble_db_table[configIndex];
delta_preamble_db = delta_preamble_db_table[configIndex%5];
if (contentionResolutionTimer > 0) {
timers_db->get(mac::CONTENTION_TIMER)->set(this, contentionResolutionTimer);
@ -170,6 +170,7 @@ void ra_proc::process_timeadv_cmd(uint32_t ta) {
void* init_prach_thread(void *arg) {
phy* phy_h = (phy*) arg;
printf("thread initiating prach\n");
if (phy_h->init_prach()) {
return (void*) 0;
} else {

@ -148,19 +148,12 @@ int main(int argc, char *argv[])
phy.init_agc(&radio_uhd, &ttisync, &log);
}
// Give it time to create thread
sleep(1);
// Set default parameters
phy.set_param(srslte::ue::phy_params::PRACH_CONFIG_INDEX, 0);
phy.set_param(srslte::ue::phy_params::PRACH_ROOT_SEQ_IDX, 0);
phy.set_param(srslte::ue::phy_params::PRACH_HIGH_SPEED_FLAG, 0);
phy.set_param(srslte::ue::phy_params::PRACH_ZC_CONFIG, 1);
// Set RX freq and gain
phy.get_radio()->set_rx_freq(prog_args.uhd_freq);
phy.get_radio()->set_rx_gain(prog_args.uhd_gain);
// Give it time to create thread
sleep(1);
/* Instruct the PHY to decode BCH */
if (!phy.decode_mib_best(&cell, bch_payload)) {
exit(-1);

@ -289,7 +289,7 @@ int main(int argc, char **argv) {
rssi_utra = SRSLTE_VEC_CMA(srslte_chest_dl_get_rssi(&chest),rssi_utra,nframes);
rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&chest),rsrq,0.05);
rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&chest),rsrp,0.05);
snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&chest),snr,0.05);
snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_noise_estimate(&chest),snr,0.05);
nframes++;
}

@ -64,8 +64,8 @@ sem_t plot_sem;
uint32_t plot_sf_idx=0;
#endif
#define PLOT_CHEST_ARGUMENT
#define PRINT_CHANGE_SCHEDULIGN
//#define PLOT_CHEST_ARGUMENT
//#define PRINT_CHANGE_SCHEDULIGN
/**********************************************************************
* Program arguments processing
@ -394,9 +394,8 @@ int main(int argc, char **argv) {
// Variables for measurements
uint32_t nframes=0;
float rsrp=0.0, rsrq=0.0, snr=0.0;
float rsrp=0.0, rsrq=0.0, noise=0.0;
bool decode_pdsch = false;
int pdcch_tx=0;
#ifndef DISABLE_UHD
if (prog_args.uhd_gain < 0) {
@ -495,45 +494,21 @@ int main(int argc, char **argv) {
rsrq = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrq(&ue_dl.chest), rsrq, 0.05);
rsrp = SRSLTE_VEC_EMA(srslte_chest_dl_get_rsrp(&ue_dl.chest), rsrp, 0.05);
snr = SRSLTE_VEC_EMA(srslte_chest_dl_get_snr(&ue_dl.chest), snr, 0.01);
noise = SRSLTE_VEC_EMA(srslte_chest_dl_get_noise_estimate(&ue_dl.chest), noise, 0.05);
nframes++;
if (isnan(rsrq)) {
rsrq = 0;
}
if (isnan(snr)) {
snr = 0;
if (isnan(noise)) {
noise = 0;
}
if (isnan(rsrp)) {
rsrp = 0;
}
#ifdef adjust_estimator
/* Adjust channel estimator based on SNR */
if (10*log10(snr) < 5.0) {
float f_low_snr[5]={0.05, 0.15, 0.6, 0.15, 0.05};
srslte_chest_dl_set_filter_freq(&ue_dl.chest, f_low_snr, 5);
} else if (10*log10(snr) < 10.0) {
float f_mid_snr[3]={0.1, 0.8, 0.1};
srslte_chest_dl_set_filter_freq(&ue_dl.chest, f_mid_snr, 3);
} else {
float f_high_snr[3]={0.05, 0.9, 0.05};
srslte_chest_dl_set_filter_freq(&ue_dl.chest, f_high_snr, 3);
}
#endif
}
if (srslte_ue_sync_get_sfidx(&ue_sync) != 5 && srslte_ue_sync_get_sfidx(&ue_sync) != 0) {
pdcch_tx++;
}
}
// Plot and Printf
if (srslte_ue_sync_get_sfidx(&ue_sync) == 5) {
#ifdef STDOUT_COMPACT
printf("SFN: %4d, PDCCH-Miss: %5.2f%% (%d missed), PDSCH-BLER: %5.2f%% (%d errors)\r",
sfn, 100*(1-(float) ue_dl.nof_detected/nof_trials),pdcch_tx-ue_dl.nof_detected,
(float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,ue_dl.pkt_errors);
#else
float gain = prog_args.uhd_gain;
if (gain < 0) {
gain = 10*log10(srslte_agc_get_gain(&ue_sync.agc));
@ -542,13 +517,11 @@ int main(int argc, char **argv) {
"RSRP: %+5.1f dBm, SNR: %4.1f dB, "
"PDCCH-Miss: %5.2f%%, PDSCH-BLER: %5.2f%% Peak: %.2f Gain: %.1f dB\r",
srslte_ue_sync_get_cfo(&ue_sync)/1000, srslte_ue_sync_get_sfo(&ue_sync)/1000,
10*log10(rsrp*1000)-gain,
10*log10(snr),
10*log10(rsrp*1000)-gain-cuhd_get_rx_gain_offset(uhd),
10*log10(rsrp/noise),
100*(1-(float) ue_dl.nof_detected/nof_trials),
(float) 100*ue_dl.pkt_errors/ue_dl.pkts_total,
srslte_agc_get_output_level(&ue_sync.agc), gain);
#endif
srslte_agc_get_output_level(&ue_sync.agc), gain);
}
break;
}

@ -103,8 +103,6 @@ SRSLTE_API int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q,
uint32_t sf_idx,
uint32_t port_id);
SRSLTE_API float srslte_chest_dl_get_snr(srslte_chest_dl_t *q);
SRSLTE_API float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q);
SRSLTE_API float srslte_chest_dl_get_rssi(srslte_chest_dl_t *q);

@ -66,6 +66,9 @@ SRSLTE_API void cuhd_set_tx_rx_gain_offset(void *h,
SRSLTE_API double cuhd_set_rx_gain_th(void *h,
double gain);
SRSLTE_API float cuhd_get_rx_gain_offset(void *h);
SRSLTE_API double cuhd_get_rx_gain(void *h);
SRSLTE_API double cuhd_set_rx_freq(void *h,

@ -43,7 +43,7 @@
#define CHEST_RS_AVERAGE_TIME 2
#define CHEST_RS_AVERAGE_FREQ 3
#define NOISE_POWER_USE_ESTIMATES
#define NOISE_POWER_METHOD 1 // 0: Difference between noisy received and noiseless; 1: power of empty subcarriers
/** 3GPP LTE Downlink channel estimator and equalizer.
@ -123,11 +123,11 @@ int srslte_chest_dl_init(srslte_chest_dl_t *q, srslte_cell_t cell)
}
/* Set default time/freq filters */
//float f[3]={0.2, 0.6, 0.2};
//srslte_chest_dl_set_filter_freq(q, f, 3);
float f[3]={0.2, 0.6, 0.2};
srslte_chest_dl_set_filter_freq(q, f, 3);
float f[5]={0.1, 0.2, 0.4, 0.2, 0.1};
srslte_chest_dl_set_filter_freq(q, f, 5);
//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.5, 0.5};
srslte_chest_dl_set_filter_time(q, t, 0);
@ -205,7 +205,7 @@ int srslte_chest_dl_set_filter_time(srslte_chest_dl_t *q, float *filter, uint32_
#ifdef NOISE_POWER_USE_ESTIMATES
#if NOISE_POWER_METHOD==0
/* Uses the difference between the averaged and non-averaged pilot estimates */
static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *avg_pilots) {
@ -215,11 +215,12 @@ static float estimate_noise_port(srslte_chest_dl_t *q, uint32_t port_id, cf_t *a
return srslte_vec_avg_power_cf(q->tmp_noise, SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id));
}
#endif
#else
#if NOISE_POWER_METHOD==1
/* 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) {
static float estimate_noise_port(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;
float noise_power = 0;
noise_power += srslte_vec_avg_power_cf(&input[k_sss-5], 5); // 5 empty SC before SSS
@ -258,7 +259,7 @@ static void average_pilots(srslte_chest_dl_t *q, uint32_t port_id)
}
}
#ifdef NOISE_POWER_USE_ESTIMATES
#if NOISE_POWER_METHOD==0
q->noise_estimate[port_id] = estimate_noise_port(q, port_id, q->tmp_freqavg);
#endif
@ -343,7 +344,7 @@ float srslte_chest_dl_rssi(srslte_chest_dl_t *q, cf_t *input, uint32_t port_id)
return rssi/nsymbols;
}
//#define RSRP_FROM_ESTIMATES
#define RSRP_FROM_ESTIMATES
float srslte_chest_dl_rsrp(srslte_chest_dl_t *q, uint32_t port_id) {
#ifdef RSRP_FROM_ESTIMATES
@ -366,7 +367,11 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u
/* Average pilot estimates */
average_pilots(q, port_id);
#if NOISE_POWER_METHOD==1
q->noise_estimate[port_id] = estimate_noise_port(q, input);
#endif
/* Compute RSRP for the channel estimates in this port */
q->rsrp[port_id] = srslte_chest_dl_rsrp(q, port_id);
if (port_id == 0) {
@ -379,9 +384,6 @@ int srslte_chest_dl_estimate_port(srslte_chest_dl_t *q, cf_t *input, cf_t *ce, u
interpolate_pilots(q, ce, port_id);
}
#ifndef NOISE_POWER_USE_ESTIMATES
q->noise_estimate[port_id] = estimate_noise_empty_sc(q, input);
#endif
return 0;
}
@ -396,18 +398,7 @@ int srslte_chest_dl_estimate(srslte_chest_dl_t *q, cf_t *input, cf_t *ce[SRSLTE_
}
float srslte_chest_dl_get_noise_estimate(srslte_chest_dl_t *q) {
float noise = srslte_vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports;
#ifdef NOISE_POWER_USE_ESTIMATES
return noise*sqrtf(srslte_symbol_sz(q->cell.nof_prb));
#else
return noise;
#endif
}
float srslte_chest_dl_get_snr(srslte_chest_dl_t *q) {
// Uses RSRP as an estimation of the useful signal power
return srslte_chest_dl_get_rsrp(q)/srslte_chest_dl_get_noise_estimate(q)/sqrt(2)/q->cell.nof_ports;
return srslte_vec_acc_ff(q->noise_estimate, q->cell.nof_ports)/q->cell.nof_ports;
}
float srslte_chest_dl_get_rssi(srslte_chest_dl_t *q) {

@ -244,13 +244,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
}
if (nlhs >= 4) {
plhs[3] = mxCreateDoubleScalar(srslte_chest_dl_get_snr(&chest));
plhs[3] = mxCreateDoubleScalar(srslte_chest_dl_get_noise_estimate(&chest));
}
if (nlhs >= 5) {
plhs[4] = mxCreateDoubleScalar(srslte_chest_dl_get_noise_estimate(&chest));
}
if (nlhs >= 6) {
plhs[5] = mxCreateDoubleScalar(srslte_chest_dl_get_rsrp(&chest));
plhs[4] = mxCreateDoubleScalar(srslte_chest_dl_get_rsrp(&chest));
}
srslte_chest_dl_free(&chest);

@ -152,6 +152,10 @@ static void* thread_gain_fcn(void *h) {
}
}
float cuhd_get_rx_gain_offset(void *h) {
return 15;
}
int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx)
{
cuhd_handler *handler = new cuhd_handler();

Loading…
Cancel
Save