mirror of https://github.com/PentHertz/srsLTE.git
Added amplitude and power conversions to dB and viceversa
This commit is contained in:
parent
f75d0e5b26
commit
8dd1c59e18
|
@ -130,7 +130,8 @@ void sig_int_handler(int signo)
|
|||
}
|
||||
}
|
||||
|
||||
double srslte_rf_set_rx_gain_wrapper(void *h, double f) {
|
||||
float srslte_rf_set_rx_gain_wrapper(void* h, float f)
|
||||
{
|
||||
return srslte_rf_set_rx_gain((srslte_rf_t*) h, f);
|
||||
}
|
||||
|
||||
|
@ -249,14 +250,13 @@ int main(int argc, char **argv) {
|
|||
|
||||
printf("\n\nFound %d cells\n", n_found_cells);
|
||||
for (int i=0;i<n_found_cells;i++) {
|
||||
printf("Found CELL %.1f MHz, EARFCN=%d, PHYID=%d, %d PRB, %d ports, PSS power=%.1f dBm\n",
|
||||
printf("Found CELL %.1f MHz, EARFCN=%d, PHYID=%d, %d PRB, %d ports, PSS power=%.1f dBm\n",
|
||||
results[i].freq,
|
||||
results[i].dl_earfcn,
|
||||
results[i].cell.id,
|
||||
results[i].cell.nof_prb,
|
||||
results[i].cell.nof_ports,
|
||||
10*log10(results[i].power));
|
||||
|
||||
results[i].cell.id,
|
||||
results[i].cell.nof_prb,
|
||||
results[i].cell.nof_ports,
|
||||
srslte_convert_power_to_dB(results[i].power));
|
||||
}
|
||||
|
||||
printf("\nBye\n");
|
||||
|
|
|
@ -999,7 +999,7 @@ int main(int argc, char **argv) {
|
|||
if (!null_file_sink) {
|
||||
/* Apply AWGN */
|
||||
if (output_file_snr != +INFINITY) {
|
||||
float var = powf(10.0f, -(output_file_snr + 3.0f) / 20.0f);
|
||||
float var = srslte_convert_dB_to_amplitude(-(output_file_snr + 3.0f));
|
||||
for (int k = 0; k < cell.nof_ports; k++) {
|
||||
srslte_ch_awgn_c(output_buffer[k], output_buffer[k], var, sf_n_samples);
|
||||
}
|
||||
|
|
|
@ -339,17 +339,18 @@ cf_t *sf_buffer[SRSLTE_MAX_PORTS] = {NULL};
|
|||
|
||||
#ifndef DISABLE_RF
|
||||
|
||||
int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
|
||||
int srslte_rf_recv_wrapper(void* h, cf_t* data_[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
|
||||
{
|
||||
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
|
||||
void* ptr[SRSLTE_MAX_PORTS];
|
||||
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
|
||||
ptr[i] = data[i];
|
||||
ptr[i] = data_[i];
|
||||
}
|
||||
return srslte_rf_recv_with_time_multi(h, ptr, nsamples, true, NULL, NULL);
|
||||
}
|
||||
|
||||
double srslte_rf_set_rx_gain_th_wrapper_(void *h, double f) {
|
||||
float srslte_rf_set_rx_gain_th_wrapper_(void* h, float f)
|
||||
{
|
||||
return srslte_rf_set_rx_gain_th((srslte_rf_t*)h, f);
|
||||
}
|
||||
|
||||
|
@ -879,7 +880,7 @@ int main(int argc, char **argv) {
|
|||
if (sf_idx == 5) {
|
||||
float gain = prog_args.rf_gain;
|
||||
if (gain < 0) {
|
||||
gain = 10 * log10(srslte_agc_get_gain(&ue_sync.agc));
|
||||
gain = srslte_convert_power_to_dB(srslte_agc_get_gain(&ue_sync.agc));
|
||||
}
|
||||
|
||||
/* Print transmission scheme */
|
||||
|
@ -1051,7 +1052,7 @@ void *plot_thread_run(void *arg) {
|
|||
uint32_t nof_symbols = pdsch_cfg.grant.nof_re;
|
||||
if (!prog_args.disable_plots_except_constellation) {
|
||||
for (i = 0; i < nof_re; i++) {
|
||||
tmp_plot[i] = 20 * log10f(cabsf(ue_dl.sf_symbols[0][i]));
|
||||
tmp_plot[i] = srslte_convert_amplitude_to_dB(cabsf(ue_dl.sf_symbols[0][i]));
|
||||
if (isinf(tmp_plot[i])) {
|
||||
tmp_plot[i] = -80;
|
||||
}
|
||||
|
@ -1060,7 +1061,7 @@ void *plot_thread_run(void *arg) {
|
|||
bzero(tmp_plot2, sizeof(float) * sz);
|
||||
int g = (sz - 12 * ue_dl.cell.nof_prb) / 2;
|
||||
for (i = 0; i < 12 * ue_dl.cell.nof_prb; i++) {
|
||||
tmp_plot2[g + i] = 20 * log10(cabs(ue_dl.chest_res.ce[0][0][i]));
|
||||
tmp_plot2[g + i] = srslte_convert_amplitude_to_dB(cabs(ue_dl.chest_res.ce[0][0][i]));
|
||||
if (isinf(tmp_plot2[g + i])) {
|
||||
tmp_plot2[g + i] = -80;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
virtual void set_tx_freq(const uint32_t& radio_idx, const uint32_t& channel_idx, const double& freq) = 0;
|
||||
virtual void set_rx_freq(const uint32_t& radio_idx, const uint32_t& channel_idx, const double& freq) = 0;
|
||||
|
||||
virtual double set_rx_gain_th(const float& gain) = 0;
|
||||
virtual float set_rx_gain_th(const float& gain) = 0;
|
||||
virtual void set_rx_gain(const uint32_t& radio_idx, const float& gain) = 0;
|
||||
virtual void set_tx_srate(const uint32_t& radio_idx, const double& srate) = 0;
|
||||
virtual void set_rx_srate(const uint32_t& radio_idx, const double& srate) = 0;
|
||||
|
|
|
@ -47,14 +47,14 @@ typedef enum SRSLTE_API {
|
|||
|
||||
typedef struct SRSLTE_API{
|
||||
float bandwidth;
|
||||
double gain;
|
||||
double min_gain;
|
||||
double max_gain;
|
||||
float gain;
|
||||
float min_gain;
|
||||
float max_gain;
|
||||
float y_out;
|
||||
bool lock;
|
||||
bool isfirst;
|
||||
void *uhd_handler;
|
||||
double (*set_gain_callback) (void*,double);
|
||||
bool isfirst;
|
||||
void* uhd_handler;
|
||||
float (*set_gain_callback)(void*, float);
|
||||
srslte_agc_mode_t mode;
|
||||
float target;
|
||||
uint32_t nof_frames;
|
||||
|
@ -66,17 +66,17 @@ SRSLTE_API int srslte_agc_init(srslte_agc_t *q, srslte_agc_mode_t mode);
|
|||
|
||||
SRSLTE_API int srslte_agc_init_acc(srslte_agc_t *q, srslte_agc_mode_t mode, uint32_t nof_frames);
|
||||
|
||||
SRSLTE_API int srslte_agc_init_uhd(srslte_agc_t *q,
|
||||
srslte_agc_mode_t mode,
|
||||
uint32_t nof_frames,
|
||||
double (set_gain_callback)(void*, double),
|
||||
void *uhd_handler);
|
||||
SRSLTE_API int srslte_agc_init_uhd(srslte_agc_t* q,
|
||||
srslte_agc_mode_t mode,
|
||||
uint32_t nof_frames,
|
||||
float(set_gain_callback)(void*, float),
|
||||
void* uhd_handler);
|
||||
|
||||
SRSLTE_API void srslte_agc_free(srslte_agc_t *q);
|
||||
|
||||
SRSLTE_API void srslte_agc_reset(srslte_agc_t *q);
|
||||
|
||||
SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t *q, double min_gain, double max_gain);
|
||||
SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain, float max_gain);
|
||||
|
||||
SRSLTE_API void srslte_agc_set_bandwidth(srslte_agc_t *q,
|
||||
float bandwidth);
|
||||
|
|
|
@ -200,10 +200,10 @@ SRSLTE_API void srslte_ue_sync_set_nof_find_frames(srslte_ue_sync_t* q, uint32_t
|
|||
SRSLTE_API srslte_frame_type_t srslte_ue_sync_get_frame_type(srslte_ue_sync_t* q);
|
||||
|
||||
SRSLTE_API int srslte_ue_sync_start_agc(srslte_ue_sync_t* q,
|
||||
double(set_gain_callback)(void*, double),
|
||||
double min_gain,
|
||||
double max_gain,
|
||||
double init_gain_value);
|
||||
float(set_gain_callback)(void*, float),
|
||||
float min_gain,
|
||||
float max_gain,
|
||||
float init_gain_value);
|
||||
|
||||
SRSLTE_API uint32_t srslte_ue_sync_sf_len(srslte_ue_sync_t *q);
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "srslte/config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define SRSLTE_MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define SRSLTE_MIN(a,b) ((a)<(b)?(a):(b))
|
||||
|
@ -51,6 +51,26 @@ extern "C" {
|
|||
// Exponential moving average
|
||||
#define SRSLTE_VEC_EMA(data, average, alpha) ((alpha)*(data)+(1-alpha)*(average))
|
||||
|
||||
static inline float srslte_convert_amplitude_to_dB(float v)
|
||||
{
|
||||
return 20.0f * log10f(v);
|
||||
}
|
||||
static inline float srslte_convert_power_to_dB(float v)
|
||||
{
|
||||
return 10.0f * log10f(v);
|
||||
}
|
||||
static inline float srslte_convert_power_to_dBm(float v)
|
||||
{
|
||||
return srslte_convert_power_to_dB(v) + 30.0f;
|
||||
}
|
||||
static inline float srslte_convert_dB_to_amplitude(float v)
|
||||
{
|
||||
return powf(10.0f, v / 20.0f);
|
||||
}
|
||||
static inline float srslte_convert_dB_to_power(float v)
|
||||
{
|
||||
return powf(10.0f, v / 10.0f);
|
||||
}
|
||||
|
||||
/*logical operations */
|
||||
SRSLTE_API void srslte_vec_xor_bbb(int8_t *x,int8_t *y,int8_t *z, const uint32_t len);
|
||||
|
|
|
@ -98,7 +98,7 @@ class radio {
|
|||
void set_tx_gain(float gain);
|
||||
void set_rx_gain(float gain);
|
||||
void set_tx_rx_gain_offset(float offset);
|
||||
double set_rx_gain_th(float gain);
|
||||
float set_rx_gain_th(float gain);
|
||||
|
||||
void set_freq_offset(double freq);
|
||||
void set_tx_freq(uint32_t chan, double freq);
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
return radios.at(radio_idx)->rx_now(buffer, nof_samples, rxd_time);
|
||||
}
|
||||
void set_rx_gain(const uint32_t& radio_idx, const float& gain) override { radios.at(radio_idx)->set_rx_gain(gain); }
|
||||
double set_rx_gain_th(const float& gain) override { return radios.at(0)->set_rx_gain_th(gain); }
|
||||
float set_rx_gain_th(const float& gain) override { return radios.at(0)->set_rx_gain_th(gain); }
|
||||
float get_rx_gain(const uint32_t& radio_idx) override { return radios.at(radio_idx)->get_rx_gain(); }
|
||||
void set_tx_freq(const uint32_t& radio_idx, const uint32_t& channel_idx, const double& freq) override
|
||||
{
|
||||
|
|
|
@ -54,7 +54,12 @@ int srslte_agc_init_acc(srslte_agc_t *q, srslte_agc_mode_t mode, uint32_t nof_fr
|
|||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
int srslte_agc_init_uhd(srslte_agc_t *q, srslte_agc_mode_t mode, uint32_t nof_frames, double (set_gain_callback)(void*, double), void *uhd_handler) {
|
||||
int srslte_agc_init_uhd(srslte_agc_t* q,
|
||||
srslte_agc_mode_t mode,
|
||||
uint32_t nof_frames,
|
||||
float(set_gain_callback)(void*, float),
|
||||
void* uhd_handler)
|
||||
{
|
||||
if (!srslte_agc_init_acc(q, mode, nof_frames)) {
|
||||
q->set_gain_callback = set_gain_callback;
|
||||
q->uhd_handler = uhd_handler;
|
||||
|
@ -73,16 +78,17 @@ void srslte_agc_free(srslte_agc_t *q) {
|
|||
|
||||
void srslte_agc_reset(srslte_agc_t *q) {
|
||||
q->bandwidth = SRSLTE_AGC_DEFAULT_BW;
|
||||
q->lock = false;
|
||||
q->gain = pow(10,50/10);
|
||||
q->lock = false;
|
||||
q->gain = srslte_convert_dB_to_power(50.0f);
|
||||
q->y_out = 1.0;
|
||||
q->isfirst = true;
|
||||
if (q->set_gain_callback && q->uhd_handler) {
|
||||
q->set_gain_callback(q->uhd_handler, 10*log10(q->gain));
|
||||
q->set_gain_callback(q->uhd_handler, srslte_convert_power_to_dB(q->gain));
|
||||
}
|
||||
}
|
||||
|
||||
void srslte_agc_set_gain_range(srslte_agc_t *q, double min_gain, double max_gain) {
|
||||
void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain, float max_gain)
|
||||
{
|
||||
if (q) {
|
||||
q->min_gain = min_gain;
|
||||
q->max_gain = max_gain;
|
||||
|
@ -119,8 +125,8 @@ void srslte_agc_lock(srslte_agc_t *q, bool enable) {
|
|||
|
||||
void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
||||
if (!q->lock) {
|
||||
double gain_db = 10.0 * log10(q->gain);
|
||||
double gain_uhd_db = 50.0;
|
||||
float gain_db = srslte_convert_power_to_dB(q->gain);
|
||||
float gain_uhd_db = 50.0f;
|
||||
|
||||
float y = 0;
|
||||
// Apply current gain to input signal
|
||||
|
@ -140,7 +146,7 @@ void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
|||
|
||||
// Set gain
|
||||
gain_uhd_db = q->set_gain_callback(q->uhd_handler, gain_db);
|
||||
q->gain = pow(10, gain_uhd_db / 10);
|
||||
q->gain = srslte_convert_dB_to_power(gain_uhd_db);
|
||||
}
|
||||
float *t;
|
||||
switch(q->mode) {
|
||||
|
|
|
@ -839,33 +839,32 @@ static float get_rsrp_neighbour(srslte_chest_dl_t* q)
|
|||
return max;
|
||||
}
|
||||
|
||||
#define dbm(a) (10 * log10(a) + 30)
|
||||
#define db(a) (10 * log10(a))
|
||||
|
||||
static void fill_res(srslte_chest_dl_t* q, srslte_chest_dl_res_t* res)
|
||||
{
|
||||
res->noise_estimate = get_noise(q);
|
||||
res->noise_estimate_dbm = dbm(res->noise_estimate);
|
||||
res->noise_estimate_dbm = srslte_convert_power_to_dBm(res->noise_estimate);
|
||||
res->cfo = q->cfo;
|
||||
res->rsrp = get_rsrp(q);
|
||||
res->rsrp_dbm = dbm(res->rsrp);
|
||||
res->rsrp_dbm = srslte_convert_power_to_dBm(res->rsrp);
|
||||
res->rsrp_neigh = get_rsrp_neighbour(q);
|
||||
res->rsrq = get_rsrq(q);
|
||||
res->rsrq_db = db(res->rsrq);
|
||||
res->snr_db = db(get_snr(q));
|
||||
res->rssi_dbm = dbm(get_rssi(q));
|
||||
res->rsrq_db = srslte_convert_power_to_dB(res->rsrq);
|
||||
res->snr_db = srslte_convert_power_to_dB(get_snr(q));
|
||||
res->rssi_dbm = srslte_convert_power_to_dBm(get_rssi(q));
|
||||
res->sync_error = q->sync_err[0][0]; // Take only the channel used for synch
|
||||
|
||||
for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) {
|
||||
res->rsrp_port_dbm[port_id] = dbm(get_rsrp_port(q, port_id));
|
||||
res->rsrp_port_dbm[port_id] = srslte_convert_power_to_dBm(get_rsrp_port(q, port_id));
|
||||
for (uint32_t a = 0; a < q->nof_rx_antennas; a++) {
|
||||
if (q->noise_estimate[a]) {
|
||||
res->snr_ant_port_db[a][port_id] = db(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]);
|
||||
res->snr_ant_port_db[a][port_id] =
|
||||
srslte_convert_power_to_dB(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]);
|
||||
} else {
|
||||
res->snr_ant_port_db[a][port_id] = 0.0;
|
||||
res->snr_ant_port_db[a][port_id] = 0.0f;
|
||||
}
|
||||
res->rsrp_ant_port_dbm[a][port_id] = dbm(q->rsrp[a][port_id]);
|
||||
res->rsrq_ant_port_db[a][port_id] = db(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]);
|
||||
res->rsrp_ant_port_dbm[a][port_id] = srslte_convert_power_to_dBm(q->rsrp[a][port_id]);
|
||||
res->rsrq_ant_port_db[a][port_id] =
|
||||
srslte_convert_power_to_dB(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,8 +320,8 @@ int srslte_chest_ul_estimate_pusch(
|
|||
res->snr = NAN;
|
||||
}
|
||||
|
||||
res->snr_db = 10 * log10(res->snr);
|
||||
res->noise_estimate_dbm = 10 * log10(res->noise_estimate) + 30;
|
||||
res->snr_db = srslte_convert_power_to_dB(res->snr);
|
||||
res->noise_estimate_dbm = srslte_convert_power_to_dBm(res->noise_estimate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
srslte_nbiot_cell_t cell = {.base = {.nof_prb = 1, .cp = SRSLTE_CP_NORM, .id = 0},
|
||||
.base.nof_ports = 1,
|
||||
.base.nof_prb = 1,
|
||||
.nbiot_prb = 0,
|
||||
.n_id_ncell = 0};
|
||||
|
||||
|
@ -184,7 +183,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (have_channel) {
|
||||
// Add noise
|
||||
float std_dev = powf(10, -(snr_db + 3.0f) / 20.0f) * 0.1f;
|
||||
float std_dev = srslte_convert_dB_to_amplitude(-(snr_db + 3.0f)) * 0.1f;
|
||||
srslte_ch_awgn_c(est.pilot_recv_signal, est.pilot_recv_signal, std_dev, SRSLTE_REFSIGNAL_MAX_NUM_SF(1));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#include <complex.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gauss.h"
|
||||
#include "srslte/phy/channel/ch_awgn.h"
|
||||
#include <srslte/phy/channel/ch_awgn.h>
|
||||
#include <srslte/phy/utils/vector.h>
|
||||
|
||||
float srslte_ch_awgn_get_variance(float ebno_db, float rate) {
|
||||
float esno_db = ebno_db + 10 * log10f(rate);
|
||||
return sqrtf(1 / (powf(10, esno_db / 10)));
|
||||
float esno_db = ebno_db + srslte_convert_power_to_dB(rate);
|
||||
return srslte_convert_dB_to_amplitude(-esno_db);
|
||||
}
|
||||
|
||||
void srslte_ch_awgn_c(const cf_t* x, cf_t* y, float variance, uint32_t len) {
|
||||
|
|
|
@ -90,7 +90,7 @@ static inline float get_doppler_dispersion(double t, double a, double w, double
|
|||
static inline void
|
||||
generate_tap(float delay_ns, float power_db, float srate, float phase, cf_t* buf, uint32_t N, uint32_t path_delay)
|
||||
{
|
||||
float amplitude = powf(10.0f, power_db / 20.0f);
|
||||
float amplitude = srslte_convert_dB_to_power(power_db);
|
||||
float O = (delay_ns * 1e-9f * srate + path_delay) / (float)N;
|
||||
cf_t a0 = amplitude * cexpf(-_Complex_I * phase) / N;
|
||||
|
||||
|
|
|
@ -33,5 +33,5 @@ float rand_gauss (void) {
|
|||
s = v1*v1 + v2*v2;
|
||||
} while ( s >= 1.0 || s == 0.0);
|
||||
|
||||
return (v1*sqrt(-2.0 * log(s) / s));
|
||||
return (v1 * sqrtf(-2.0 * log(s) / s));
|
||||
}
|
||||
|
|
|
@ -196,12 +196,12 @@ int main(int argc, char** argv)
|
|||
srslte_dft_run_c_zerocopy(&fft, output_buffer, fft_buffer);
|
||||
srslte_vec_prod_conj_ccc(fft_buffer, fft_buffer, fft_buffer, srate / 1000);
|
||||
for (int i = 0; i < srate / 1000; i++) {
|
||||
fft_mag[i] = 10.0f * log10f(__real__ fft_buffer[i]);
|
||||
fft_mag[i] = srslte_convert_power_to_dB(__real__ fft_buffer[i]);
|
||||
}
|
||||
plot_real_setNewData(&plot_fft, fft_mag, srate / 1000);
|
||||
|
||||
for (int i = 0; i < channel_fading.N; i++) {
|
||||
fft_mag[i] = 20.0f * log10f(cabsf(channel_fading.h_freq[i]));
|
||||
fft_mag[i] = srslte_convert_amplitude_to_dB(cabsf(channel_fading.h_freq[i]));
|
||||
}
|
||||
plot_real_setNewData(&plot_h, fft_mag, channel_fading.N);
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ void srslte_dft_run_c(srslte_dft_plan_t *plan, const cf_t *in, cf_t *out) {
|
|||
}
|
||||
if (plan->db) {
|
||||
for (i=0;i<plan->size;i++) {
|
||||
f_out[i] = 10*log10(f_out[i]);
|
||||
f_out[i] = srslte_convert_power_to_dB(f_out[i]);
|
||||
}
|
||||
}
|
||||
copy_post((uint8_t*)out, (uint8_t*)plan->out, sizeof(cf_t), plan->size,
|
||||
|
@ -342,7 +342,7 @@ void srslte_dft_run_r(srslte_dft_plan_t *plan, const float *in, float *out) {
|
|||
}
|
||||
if (plan->db) {
|
||||
for (i=0;i<len;i++) {
|
||||
f_out[i] = 10*log10(f_out[i]);
|
||||
f_out[i] = srslte_convert_power_to_dB(f_out[i]);
|
||||
}
|
||||
}
|
||||
memcpy(out,plan->out,sizeof(float)*plan->size);
|
||||
|
|
|
@ -402,7 +402,7 @@ int srslte_enb_dl_put_pmch(srslte_enb_dl_t* q, srslte_pmch_cfg_t* pmch_cfg, uint
|
|||
void srslte_enb_dl_gen_signal(srslte_enb_dl_t* q)
|
||||
{
|
||||
// TODO: PAPR control
|
||||
float norm_factor = 0.05f / sqrt(q->cell.nof_prb);
|
||||
float norm_factor = 0.05f / sqrtf(q->cell.nof_prb);
|
||||
|
||||
if (q->dl_sf.sf_type == SRSLTE_SF_MBSFN) {
|
||||
srslte_ofdm_tx_sf(&q->ifft_mbsfn);
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "srslte/srslte.h"
|
||||
#include <srslte/phy/utils/random.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include "srslte/srslte.h"
|
||||
|
||||
#include "turbodecoder_test.h"
|
||||
|
||||
|
@ -114,6 +115,7 @@ void parse_args(int argc, char **argv) {
|
|||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
srslte_random_t random_gen = srslte_random_init(0);
|
||||
uint32_t frame_cnt;
|
||||
float *llr;
|
||||
short *llr_s;
|
||||
|
@ -122,7 +124,7 @@ int main(int argc, char **argv) {
|
|||
uint32_t i, j;
|
||||
float var[SNR_POINTS];
|
||||
uint32_t snr_points;
|
||||
uint32_t errors;
|
||||
uint32_t errors = 0;
|
||||
uint32_t coded_length;
|
||||
struct timeval tdata[3];
|
||||
float mean_usec;
|
||||
|
@ -210,12 +212,12 @@ int main(int argc, char **argv) {
|
|||
snr_points = SNR_POINTS;
|
||||
for (i = 0; i < snr_points; i++) {
|
||||
ebno_db = SNR_MIN + i * ebno_inc;
|
||||
esno_db = ebno_db + 10 * log10((double) 1 / 3);
|
||||
var[i] = sqrt(1 / (pow(10, esno_db / 10)));
|
||||
esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f);
|
||||
var[i] = srslte_convert_dB_to_amplitude(-esno_db);
|
||||
}
|
||||
} else {
|
||||
esno_db = ebno_db + 10 * log10((double) 1 / 3);
|
||||
var[0] = sqrt(1 / (pow(10, esno_db / 10)));
|
||||
esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f);
|
||||
var[0] = srslte_convert_dB_to_amplitude(-esno_db);
|
||||
snr_points = 1;
|
||||
}
|
||||
for (i = 0; i < snr_points; i++) {
|
||||
|
@ -229,7 +231,7 @@ int main(int argc, char **argv) {
|
|||
if (test_known_data) {
|
||||
data_tx[j] = known_data[j];
|
||||
} else {
|
||||
data_tx[j] = rand() % 2;
|
||||
data_tx[j] = srslte_random_uniform_int_dist(random_gen, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,9 +294,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (data_rx_bytes) {
|
||||
free(data_rx_bytes);
|
||||
}
|
||||
free(data_rx_bytes);
|
||||
free(data_tx);
|
||||
free(symbols);
|
||||
free(llr);
|
||||
|
@ -304,6 +304,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
srslte_tdec_free(&tdec);
|
||||
srslte_tcod_free(&tcod);
|
||||
srslte_random_free(random_gen);
|
||||
|
||||
printf("\n");
|
||||
printf("Done\n");
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <srslte/phy/utils/random.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "srslte/srslte.h"
|
||||
|
||||
|
@ -87,7 +88,7 @@ int main(int argc, char **argv) {
|
|||
uint16_t *llr_s;
|
||||
uint8_t *llr_c;
|
||||
uint8_t *data_tx, *data_rx, *data_rx2, *symbols;
|
||||
int i, j;
|
||||
int j;
|
||||
float var[SNR_POINTS], varunc[SNR_POINTS];
|
||||
int snr_points;
|
||||
uint32_t errors;
|
||||
|
@ -170,20 +171,20 @@ int main(int argc, char **argv) {
|
|||
ebno_inc = (SNR_MAX - SNR_MIN) / SNR_POINTS;
|
||||
if (ebno_db == 100.0) {
|
||||
snr_points = SNR_POINTS;
|
||||
for (i = 0; i < snr_points; i++) {
|
||||
for (uint32_t i = 0; i < snr_points; i++) {
|
||||
ebno_db = SNR_MIN + i * ebno_inc;
|
||||
esno_db = ebno_db + 10 * log10((double) 1 / 3);
|
||||
var[i] = sqrt(1 / (pow(10, esno_db / 10)));
|
||||
varunc[i] = sqrt(1 / (pow(10, ebno_db / 10)));
|
||||
esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f);
|
||||
var[i] = srslte_convert_dB_to_amplitude(esno_db);
|
||||
varunc[i] = srslte_convert_dB_to_amplitude(ebno_db);
|
||||
}
|
||||
} else {
|
||||
esno_db = ebno_db + 10 * log10((double) 1 / 3);
|
||||
var[0] = sqrt(1 / (pow(10, esno_db / 10)));
|
||||
varunc[0] = sqrt(1 / (pow(10, ebno_db / 10)));
|
||||
esno_db = ebno_db + srslte_convert_power_to_dB(1.0f / 3.0f);
|
||||
var[0] = srslte_convert_dB_to_amplitude(esno_db);
|
||||
varunc[0] = srslte_convert_dB_to_amplitude(ebno_db);
|
||||
snr_points = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < snr_points; i++) {
|
||||
for (uint32_t i = 0; i < snr_points; i++) {
|
||||
frame_cnt = 0;
|
||||
errors = 0;
|
||||
#ifdef TEST_SSE
|
||||
|
@ -192,9 +193,11 @@ int main(int argc, char **argv) {
|
|||
while (frame_cnt < nof_frames) {
|
||||
|
||||
/* generate data_tx */
|
||||
srslte_random_t random_gen = srslte_random_init(0);
|
||||
for (j = 0; j < frame_length; j++) {
|
||||
data_tx[j] = rand() % 2;
|
||||
data_tx[j] = srslte_random_uniform_int_dist(random_gen, 0, 1);
|
||||
}
|
||||
srslte_random_free(random_gen);
|
||||
|
||||
/* uncoded BER */
|
||||
for (j = 0; j < frame_length; j++) {
|
||||
|
@ -217,10 +220,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
struct timeval t[3];
|
||||
gettimeofday(&t[1], NULL);
|
||||
int M = 1;
|
||||
|
||||
|
||||
for (int i=0;i<M;i++) {
|
||||
int M = 1;
|
||||
|
||||
for (uint32_t i = 0; i < M; i++) {
|
||||
#ifdef VITERBI_16
|
||||
srslte_viterbi_decode_us(&dec, llr_s, data_rx, frame_length);
|
||||
#else
|
||||
|
|
|
@ -2469,8 +2469,12 @@ int srslte_precoding_pmi_select_1l(cf_t *h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS],
|
|||
ret = srslte_precoding_pmi_select_1l_gen(h, nof_symbols, noise_estimate, pmi, sinr_list);
|
||||
#endif
|
||||
#endif
|
||||
INFO("Precoder PMI Select for 1 layer SINR=[%.1fdB; %.1fdB; %.1fdB; %.1fdB] PMI=%d\n", 10 * log10(sinr_list[0]),
|
||||
10 * log10(sinr_list[1]), 10 * log10(sinr_list[2]), 10 * log10(sinr_list[3]), *pmi);
|
||||
INFO("Precoder PMI Select for 1 layer SINR=[%.1fdB; %.1fdB; %.1fdB; %.1fdB] PMI=%d\n",
|
||||
srslte_convert_power_to_dB(sinr_list[0]),
|
||||
srslte_convert_power_to_dB(sinr_list[1]),
|
||||
srslte_convert_power_to_dB(sinr_list[2]),
|
||||
srslte_convert_power_to_dB(sinr_list[3]),
|
||||
*pmi);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2865,8 +2869,10 @@ int srslte_precoding_pmi_select_2l(cf_t *h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS],
|
|||
#endif /* LV_HAVE_SSE */
|
||||
#endif /* LV_HAVE_AVX */
|
||||
|
||||
INFO("Precoder PMI Select for 2 layers SINR=[%.1fdB; %.1fdB] PMI=%d\n", 10 * log10(sinr_list[0]),
|
||||
10 * log10(sinr_list[1]), *pmi);
|
||||
INFO("Precoder PMI Select for 2 layers SINR=[%.1fdB; %.1fdB] PMI=%d\n",
|
||||
srslte_convert_power_to_dB(sinr_list[0]),
|
||||
srslte_convert_power_to_dB(sinr_list[1]),
|
||||
*pmi);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ char *mimo_type_name = NULL;
|
|||
char decoder_type_name [17] = "zf";
|
||||
float snr_db = 100.0f;
|
||||
float scaling = 0.1f;
|
||||
static srslte_random_t random_gen = NULL;
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s -m [%s|%s|%s|%s] -l [nof_layers] -p [nof_tx_ports]\n"
|
||||
|
@ -108,7 +109,7 @@ void populate_channel_cdd(cf_t *h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], uint32_t
|
|||
for (i = 0; i < nof_tx_ports; i++) {
|
||||
for (j = 0; j < nof_rx_ports; j++) {
|
||||
for (k = 0; k < n; k++) {
|
||||
h[i][j][k] = (float) rand() / RAND_MAX + ((float) rand() / RAND_MAX) * _Complex_I;
|
||||
h[i][j][k] = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ void populate_channel_diversity(cf_t *h[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS], uin
|
|||
for (i = 0; i < nof_tx_ports; i++) {
|
||||
for (j = 0; j < nof_rx_ports; j++) {
|
||||
for (k = 0; k < n / nof_layers; k++) {
|
||||
cf_t hsymb = (float) rand() / RAND_MAX + ((float) rand() / RAND_MAX) * _Complex_I;
|
||||
cf_t hsymb = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f);
|
||||
for (l = 0; l < nof_layers; l++) {
|
||||
// assume the channel is the same for all symbols
|
||||
h[i][j][k * nof_layers + l] = hsymb;
|
||||
|
@ -134,7 +135,7 @@ void populate_channel_single(cf_t *h) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < nof_re; i++) {
|
||||
h[i] = (float)rand() / RAND_MAX + ((float)rand() / RAND_MAX) * _Complex_I;
|
||||
h[i] = srslte_random_uniform_complex_dist(random_gen, -1.0f, +1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,7 @@ void populate_channel(srslte_tx_scheme_t type, cf_t* h[SRSLTE_MAX_PORTS][SRSLTE_
|
|||
|
||||
static void awgn(cf_t *y[SRSLTE_MAX_PORTS], uint32_t n, float snr) {
|
||||
int i;
|
||||
float std_dev = powf(10, - (snr + 3.0f) / 20.0f) * scaling;
|
||||
float std_dev = srslte_convert_dB_to_amplitude(-(snr + 3.0f)) * scaling;
|
||||
|
||||
for (i = 0; i < nof_rx_ports; i++) {
|
||||
srslte_ch_awgn_c(y[i], y[i], std_dev, n);
|
||||
|
@ -251,14 +252,13 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/* Generate source random data */
|
||||
srslte_random_t random_gen = srslte_random_init(0);
|
||||
random_gen = srslte_random_init(0);
|
||||
for (i = 0; i < nof_layers; i++) {
|
||||
for (j = 0; j < nof_symbols; j++) {
|
||||
__real__ x[i][j] = (2 * srslte_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2;
|
||||
__imag__ x[i][j] = (2 * srslte_random_uniform_int_dist(random_gen, 0, 1) - 1) * M_SQRT1_2;
|
||||
}
|
||||
}
|
||||
srslte_random_free(random_gen);
|
||||
|
||||
/* Execute Precoding (Tx) */
|
||||
if (srslte_precoding_type(x, y, nof_layers, nof_tx_ports, codebook_idx, nof_symbols, scaling, type) < 0) {
|
||||
|
@ -296,8 +296,18 @@ int main(int argc, char** argv)
|
|||
/* predecoding / equalization */
|
||||
struct timeval t[3];
|
||||
gettimeofday(&t[1], NULL);
|
||||
srslte_predecoding_type(r, h, xr, NULL, nof_rx_ports, nof_tx_ports, nof_layers,
|
||||
codebook_idx, nof_re, type, scaling, powf(10, -snr_db / 10));
|
||||
srslte_predecoding_type(r,
|
||||
h,
|
||||
xr,
|
||||
NULL,
|
||||
nof_rx_ports,
|
||||
nof_tx_ports,
|
||||
nof_layers,
|
||||
codebook_idx,
|
||||
nof_re,
|
||||
type,
|
||||
scaling,
|
||||
srslte_convert_dB_to_power(-snr_db));
|
||||
gettimeofday(&t[2], NULL);
|
||||
get_time_interval(t);
|
||||
|
||||
|
@ -322,10 +332,12 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
quit:
|
||||
/* Free all data */
|
||||
for (i = 0; i < nof_layers; i++) {
|
||||
free(x[i]);
|
||||
free(xr[i]);
|
||||
srslte_random_free(random_gen);
|
||||
|
||||
/* Free all data */
|
||||
for (i = 0; i < nof_layers; i++) {
|
||||
free(x[i]);
|
||||
free(xr[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < nof_rx_ports; i++) {
|
||||
|
|
|
@ -130,8 +130,8 @@ void demod_16qam_lte(const cf_t *symbols, float *llr, int nsymbols) {
|
|||
|
||||
llr[4*i+0] = -yre;
|
||||
llr[4*i+1] = -yim;
|
||||
llr[4*i+2] = fabsf(yre)-2/sqrt(10);
|
||||
llr[4*i+3] = fabsf(yim)-2/sqrt(10);
|
||||
llr[4 * i + 2] = fabsf(yre) - 2 / sqrtf(10);
|
||||
llr[4 * i + 3] = fabsf(yim) - 2 / sqrtf(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ void demod_16qam_lte_s_neon(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
int8x16_t result11, result21;
|
||||
result11 = vdupq_n_s8(0);
|
||||
result21 = vdupq_n_s8(0);
|
||||
int16x8_t offset = vdupq_n_s16(2 * SCALE_SHORT_CONV_QAM16 / sqrt(10));
|
||||
int16x8_t offset = vdupq_n_s16(2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10));
|
||||
float32x4_t scale_v = vdupq_n_f32(-SCALE_SHORT_CONV_QAM16);
|
||||
|
||||
for (int i = 0; i < nsymbols / 4; i++) {
|
||||
|
@ -180,8 +180,8 @@ void demod_16qam_lte_s_neon(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
|
||||
llr[4 * i + 0] = -yre;
|
||||
llr[4 * i + 1] = -yim;
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_SHORT_CONV_QAM16 / sqrt(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_SHORT_CONV_QAM16 / sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ void demod_16qam_lte_b_neon(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
int8x16_t symbol_i, symbol_abs;
|
||||
int16x8_t symbol_12, symbol_34;
|
||||
int32x4_t symbol_i1, symbol_i2, symbol_i3, symbol_i4;
|
||||
int8x16_t offset = vdupq_n_s8(2 * SCALE_BYTE_CONV_QAM16 / sqrt(10));
|
||||
int8x16_t offset = vdupq_n_s8(2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10));
|
||||
int8x16_t result1n, result2n;
|
||||
float32x4_t scale_v = vdupq_n_f32(-SCALE_BYTE_CONV_QAM16);
|
||||
|
||||
|
@ -240,8 +240,8 @@ void demod_16qam_lte_b_neon(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
|
||||
llr[4 * i + 0] = -yre;
|
||||
llr[4 * i + 1] = -yim;
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_BYTE_CONV_QAM16 / sqrt(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_BYTE_CONV_QAM16 / sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ void demod_16qam_lte_s_sse(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
__m128i *resultPtr = (__m128i*) llr;
|
||||
__m128 symbol1, symbol2;
|
||||
__m128i symbol_i1, symbol_i2, symbol_i, symbol_abs;
|
||||
__m128i offset = _mm_set1_epi16(2*SCALE_SHORT_CONV_QAM16/sqrt(10));
|
||||
__m128i offset = _mm_set1_epi16(2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10));
|
||||
__m128i result11, result12, result22, result21;
|
||||
__m128 scale_v = _mm_set1_ps(-SCALE_SHORT_CONV_QAM16);
|
||||
__m128i shuffle_negated_1 = _mm_set_epi8(0xff,0xff,0xff,0xff,7,6,5,4,0xff,0xff,0xff,0xff,3,2,1,0);
|
||||
|
@ -289,8 +289,8 @@ void demod_16qam_lte_s_sse(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
|
||||
llr[4*i+0] = -yre;
|
||||
llr[4*i+1] = -yim;
|
||||
llr[4*i+2] = abs(yre)-2*SCALE_SHORT_CONV_QAM16/sqrt(10);
|
||||
llr[4*i+3] = abs(yim)-2*SCALE_SHORT_CONV_QAM16/sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ void demod_16qam_lte_b_sse(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
__m128i *resultPtr = (__m128i*) llr;
|
||||
__m128 symbol1, symbol2, symbol3, symbol4;
|
||||
__m128i symbol_i1, symbol_i2, symbol_i3, symbol_i4, symbol_i, symbol_abs, symbol_12, symbol_34;
|
||||
__m128i offset = _mm_set1_epi8(2*SCALE_BYTE_CONV_QAM16/sqrt(10));
|
||||
__m128i offset = _mm_set1_epi8(2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10));
|
||||
__m128i result1n, result1a, result2n, result2a;
|
||||
__m128 scale_v = _mm_set1_ps(-SCALE_BYTE_CONV_QAM16);
|
||||
|
||||
|
@ -342,8 +342,8 @@ void demod_16qam_lte_b_sse(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
|
||||
llr[4*i+0] = -yre;
|
||||
llr[4*i+1] = -yim;
|
||||
llr[4*i+2] = abs(yre)-2*SCALE_BYTE_CONV_QAM16/sqrt(10);
|
||||
llr[4*i+3] = abs(yim)-2*SCALE_BYTE_CONV_QAM16/sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,8 +362,8 @@ void demod_16qam_lte_s(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
|
||||
llr[4*i+0] = -yre;
|
||||
llr[4*i+1] = -yim;
|
||||
llr[4*i+2] = abs(yre)-2*SCALE_SHORT_CONV_QAM16/sqrt(10);
|
||||
llr[4*i+3] = abs(yim)-2*SCALE_SHORT_CONV_QAM16/sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_SHORT_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -382,8 +382,8 @@ void demod_16qam_lte_b(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
|
||||
llr[4*i+0] = -yre;
|
||||
llr[4*i+1] = -yim;
|
||||
llr[4*i+2] = abs(yre)-2*SCALE_BYTE_CONV_QAM16/sqrt(10);
|
||||
llr[4*i+3] = abs(yim)-2*SCALE_BYTE_CONV_QAM16/sqrt(10);
|
||||
llr[4 * i + 2] = abs(yre) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
llr[4 * i + 3] = abs(yim) - 2 * SCALE_BYTE_CONV_QAM16 / sqrtf(10);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -397,10 +397,10 @@ void demod_64qam_lte(const cf_t *symbols, float *llr, int nsymbols)
|
|||
|
||||
llr[6*i+0] = -yre;
|
||||
llr[6*i+1] = -yim;
|
||||
llr[6*i+2] = fabsf(yre)-4/sqrt(42);
|
||||
llr[6*i+3] = fabsf(yim)-4/sqrt(42);
|
||||
llr[6*i+4] = fabsf(llr[6*i+2])-2/sqrt(42);
|
||||
llr[6*i+5] = fabsf(llr[6*i+3])-2/sqrt(42);
|
||||
llr[6 * i + 2] = fabsf(yre) - 4 / sqrtf(42);
|
||||
llr[6 * i + 3] = fabsf(yim) - 4 / sqrtf(42);
|
||||
llr[6 * i + 4] = fabsf(llr[6 * i + 2]) - 2 / sqrtf(42);
|
||||
llr[6 * i + 5] = fabsf(llr[6 * i + 3]) - 2 / sqrtf(42);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -412,8 +412,8 @@ void demod_64qam_lte_s_neon(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
float32x4_t symbol1, symbol2;
|
||||
int16x8_t symbol_i, symbol_abs, symbol_abs2;
|
||||
int32x4_t symbol_i1, symbol_i2;
|
||||
int16x8_t offset1 = vdupq_n_s16(4 * SCALE_SHORT_CONV_QAM64 / sqrt(42));
|
||||
int16x8_t offset2 = vdupq_n_s16(2 * SCALE_SHORT_CONV_QAM64 / sqrt(42));
|
||||
int16x8_t offset1 = vdupq_n_s16(4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42));
|
||||
int16x8_t offset2 = vdupq_n_s16(2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42));
|
||||
float32x4_t scale_v = vdupq_n_f32(-SCALE_SHORT_CONV_QAM64);
|
||||
|
||||
int16x8_t result11 = vdupq_n_s16(0);
|
||||
|
@ -461,12 +461,10 @@ void demod_64qam_lte_s_neon(const cf_t *symbols, short *llr, int nsymbols) {
|
|||
|
||||
llr[6 * i + 0] = -yre;
|
||||
llr[6 * i + 1] = -yim;
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_SHORT_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_SHORT_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 4] =
|
||||
abs(llr[6 * i + 2]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 5] =
|
||||
abs(llr[6 * i + 3]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,8 +475,8 @@ void demod_64qam_lte_b_neon(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
int8x16_t symbol_i, symbol_abs, symbol_abs2;
|
||||
int16x8_t symbol_12, symbol_34;
|
||||
int32x4_t symbol_i1, symbol_i2, symbol_i3, symbol_i4;
|
||||
int8x16_t offset1 = vdupq_n_s8(4 * SCALE_BYTE_CONV_QAM64 / sqrt(42));
|
||||
int8x16_t offset2 = vdupq_n_s8(2 * SCALE_BYTE_CONV_QAM64 / sqrt(42));
|
||||
int8x16_t offset1 = vdupq_n_s8(4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42));
|
||||
int8x16_t offset2 = vdupq_n_s8(2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42));
|
||||
float32x4_t scale_v = vdupq_n_f32(-SCALE_BYTE_CONV_QAM64);
|
||||
int8x16_t result11 = vdupq_n_s8(0);
|
||||
int8x16_t result21 = vdupq_n_s8(0);
|
||||
|
@ -561,10 +559,10 @@ void demod_64qam_lte_b_neon(const cf_t *symbols, int8_t *llr, int nsymbols) {
|
|||
|
||||
llr[6 * i + 0] = -yre;
|
||||
llr[6 * i + 1] = -yim;
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_BYTE_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_BYTE_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,8 +576,8 @@ void demod_64qam_lte_s_sse(const cf_t *symbols, short *llr, int nsymbols)
|
|||
__m128i *resultPtr = (__m128i*) llr;
|
||||
__m128 symbol1, symbol2;
|
||||
__m128i symbol_i1, symbol_i2, symbol_i, symbol_abs, symbol_abs2;
|
||||
__m128i offset1 = _mm_set1_epi16(4*SCALE_SHORT_CONV_QAM64/sqrt(42));
|
||||
__m128i offset2 = _mm_set1_epi16(2*SCALE_SHORT_CONV_QAM64/sqrt(42));
|
||||
__m128i offset1 = _mm_set1_epi16(4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42));
|
||||
__m128i offset2 = _mm_set1_epi16(2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42));
|
||||
__m128 scale_v = _mm_set1_ps(-SCALE_SHORT_CONV_QAM64);
|
||||
__m128i result11, result12, result13, result22, result21,result23, result31, result32, result33;
|
||||
|
||||
|
@ -628,10 +626,10 @@ void demod_64qam_lte_s_sse(const cf_t *symbols, short *llr, int nsymbols)
|
|||
|
||||
llr[6*i+0] = -yre;
|
||||
llr[6*i+1] = -yim;
|
||||
llr[6*i+2] = abs(yre)-4*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+3] = abs(yim)-4*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+4] = abs(llr[6*i+2])-2*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+5] = abs(llr[6*i+3])-2*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,8 +639,8 @@ void demod_64qam_lte_b_sse(const cf_t *symbols, int8_t *llr, int nsymbols)
|
|||
__m128i *resultPtr = (__m128i*) llr;
|
||||
__m128 symbol1, symbol2, symbol3, symbol4;
|
||||
__m128i symbol_i1, symbol_i2, symbol_i3, symbol_i4, symbol_i, symbol_abs, symbol_abs2,symbol_12, symbol_34;
|
||||
__m128i offset1 = _mm_set1_epi8(4*SCALE_BYTE_CONV_QAM64/sqrt(42));
|
||||
__m128i offset2 = _mm_set1_epi8(2*SCALE_BYTE_CONV_QAM64/sqrt(42));
|
||||
__m128i offset1 = _mm_set1_epi8(4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42));
|
||||
__m128i offset2 = _mm_set1_epi8(2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42));
|
||||
__m128 scale_v = _mm_set1_ps(-SCALE_BYTE_CONV_QAM64);
|
||||
__m128i result11, result12, result13, result22, result21,result23, result31, result32, result33;
|
||||
|
||||
|
@ -697,10 +695,10 @@ void demod_64qam_lte_b_sse(const cf_t *symbols, int8_t *llr, int nsymbols)
|
|||
|
||||
llr[6*i+0] = -yre;
|
||||
llr[6*i+1] = -yim;
|
||||
llr[6*i+2] = abs(yre)-4*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+3] = abs(yim)-4*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+4] = abs(llr[6*i+2])-2*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+5] = abs(llr[6*i+3])-2*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,10 +718,10 @@ void demod_64qam_lte_s(const cf_t *symbols, short *llr, int nsymbols)
|
|||
|
||||
llr[6*i+0] = -yre;
|
||||
llr[6*i+1] = -yim;
|
||||
llr[6*i+2] = abs(yre)-4*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+3] = abs(yim)-4*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+4] = abs(llr[6*i+2])-2*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+5] = abs(llr[6*i+3])-2*SCALE_SHORT_CONV_QAM64/sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_SHORT_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -743,10 +741,10 @@ void demod_64qam_lte_b(const cf_t *symbols, int8_t *llr, int nsymbols)
|
|||
|
||||
llr[6*i+0] = -yre;
|
||||
llr[6*i+1] = -yim;
|
||||
llr[6*i+2] = abs(yre)-4*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+3] = abs(yim)-4*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+4] = abs(llr[6*i+2])-2*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6*i+5] = abs(llr[6*i+3])-2*SCALE_BYTE_CONV_QAM64/sqrt(42);
|
||||
llr[6 * i + 2] = abs(yre) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 3] = abs(yim) - 4 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 4] = abs(llr[6 * i + 2]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
llr[6 * i + 5] = abs(llr[6 * i + 3]) - 2 * SCALE_BYTE_CONV_QAM64 / sqrtf(42);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -176,7 +176,7 @@ void set_256QAMtable(cf_t* table)
|
|||
real *= ((i & (1 << (2 * j + 1)))) ? +1 : -1;
|
||||
imag *= ((i & (1 << (2 * j + 0)))) ? +1 : -1;
|
||||
}
|
||||
__real__ table[i] = real / sqrt(170);
|
||||
__imag__ table[i] = imag / sqrt(170);
|
||||
__real__ table[i] = real / sqrtf(170);
|
||||
__imag__ table[i] = imag / sqrtf(170);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
#define QPSK_LEVEL M_SQRT1_2
|
||||
|
||||
#define QAM16_LEVEL_1 (1.0f / sqrt(10.0f))
|
||||
#define QAM16_LEVEL_2 (3.0f / sqrt(10.0f))
|
||||
#define QAM16_LEVEL_1 (1.0f / sqrtf(10.0f))
|
||||
#define QAM16_LEVEL_2 (3.0f / sqrtf(10.0f))
|
||||
|
||||
#define QAM64_LEVEL_1 (1.0f / sqrtf(42.0f))
|
||||
#define QAM64_LEVEL_2 (3.0f / sqrtf(42.0f))
|
||||
|
@ -38,7 +38,7 @@
|
|||
#define QAM64_THRESHOLD_3 (6.0f / sqrtf(42.0f))
|
||||
//=========================================//
|
||||
|
||||
#define QAM64_LEVEL_x 2/sqrt(42)
|
||||
#define QAM64_LEVEL_x 2 / sqrtf(42)
|
||||
/* this is not an QAM64 level, but, rather, an auxiliary value that can be used for computing the
|
||||
* symbol from the bit sequence */
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ static float apply_power_allocation(srslte_pdsch_t* q, srslte_pdsch_cfg_t* cfg,
|
|||
uint32_t nof_re_symbol = SRSLTE_NRE * q->cell.nof_prb;
|
||||
|
||||
/* Set power allocation according to 3GPP 36.213 clause 5.2 Downlink power allocation */
|
||||
float rho_a = powf(10.0f, cfg->p_a / 20.0f) * ((q->cell.nof_ports == 1) ? 1.0f : M_SQRT2);
|
||||
float rho_a = srslte_convert_dB_to_amplitude(cfg->p_a) * ((q->cell.nof_ports == 1) ? 1.0f : M_SQRT2);
|
||||
|
||||
uint32_t idx0 = (q->cell.nof_ports == 1) ? 0 : 1;
|
||||
float cell_specific_ratio = pdsch_cfg_cell_specific_ratio_table[idx0][cfg->p_b];
|
||||
|
|
|
@ -63,7 +63,8 @@ int rf_rssi_scan(srslte_rf_t *rf, float *freqs, float *rssi, int nof_bands, doub
|
|||
}
|
||||
}
|
||||
rssi[i] = srslte_vec_avg_power_cf(buffer, nsamp);
|
||||
printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f/1000000, 10*log10f(rssi[i]) + 30); fflush(stdout);
|
||||
printf("[%3d]: Freq %4.1f Mhz - RSSI: %3.2f dBm\r", i, f / 1000000, srslte_convert_power_to_dBm(rssi[i]));
|
||||
fflush(stdout);
|
||||
if (SRSLTE_VERBOSE_ISINFO()) {
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ int rf_cell_search(srslte_rf_t *rf, uint32_t nof_rx_antennas,
|
|||
srslte_cp_string(found_cells[i].cp),
|
||||
found_cells[i].mode * 100,
|
||||
found_cells[i].psr,
|
||||
20 * log10(found_cells[i].peak * 1000));
|
||||
srslte_convert_amplitude_to_dB(found_cells[i].peak * 1000));
|
||||
}
|
||||
|
||||
// Save result
|
||||
|
|
|
@ -627,7 +627,7 @@ int rf_zmq_recv_with_time_multi(
|
|||
}
|
||||
|
||||
// Set gain
|
||||
float scale = powf(10.0f, handler->rx_gain / 20);
|
||||
float scale = srslte_convert_dB_to_amplitude(handler->rx_gain);
|
||||
srslte_vec_sc_prod_cfc(data[0], scale, data[0], nsamples);
|
||||
|
||||
// update rx time
|
||||
|
|
|
@ -278,13 +278,13 @@ void srslte_refsignal_dl_sync_run(srslte_refsignal_dl_sync_t* q, cf_t* buffer, u
|
|||
}
|
||||
|
||||
// Calculate in dBm
|
||||
q->rsrp_dBfs = 10.0f * log10f(rsrp_lin) + 30.0f;
|
||||
q->rsrp_dBfs = srslte_convert_power_to_dBm(rsrp_lin);
|
||||
|
||||
// Calculate RSSI in dBm
|
||||
q->rssi_dBfs = 10.0f * log10f(rssi_lin) + 30.0f;
|
||||
q->rssi_dBfs = srslte_convert_power_to_dBm(rssi_lin);
|
||||
|
||||
// Calculate RSRQ
|
||||
q->rsrq_dB = 10.0f * log10f(q->refsignal.cell.nof_prb) + q->rsrp_dBfs - q->rssi_dBfs;
|
||||
q->rsrq_dB = srslte_convert_power_to_dB(q->refsignal.cell.nof_prb) + q->rsrp_dBfs - q->rssi_dBfs;
|
||||
|
||||
q->found = true;
|
||||
q->cfo_Hz = cfo_acc;
|
||||
|
|
|
@ -184,7 +184,7 @@ int main(int argc, char** argv)
|
|||
if (snr != -1.0) {
|
||||
snr -= 10.0;
|
||||
printf("Adding AWGN with target SNR: %.2fdB\n", snr);
|
||||
float nstd = powf(10.0f, -snr / 20.0f);
|
||||
float nstd = srslte_convert_dB_to_amplitude(-snr);
|
||||
srslte_ch_awgn_c(fft_buffer, fft_buffer, nstd, SFLEN);
|
||||
}
|
||||
|
||||
|
|
|
@ -725,7 +725,7 @@ static int select_pmi(srslte_ue_dl_t* q, uint32_t ri, uint32_t* pmi, float* sinr
|
|||
|
||||
/* Set PMI */
|
||||
if (sinr_db != NULL) {
|
||||
*sinr_db = 10.0f * log10f(sinr_list[*pmi % SRSLTE_MAX_CODEBOOKS]);
|
||||
*sinr_db = srslte_convert_power_to_dB(sinr_list[*pmi % SRSLTE_MAX_CODEBOOKS]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,11 +136,12 @@ void srslte_ue_sync_reset(srslte_ue_sync_t *q) {
|
|||
q->frame_find_cnt = 0;
|
||||
}
|
||||
|
||||
int srslte_ue_sync_start_agc(srslte_ue_sync_t *q,
|
||||
double (set_gain_callback)(void *, double),
|
||||
double min_gain,
|
||||
double max_gain,
|
||||
double init_gain_value) {
|
||||
int srslte_ue_sync_start_agc(srslte_ue_sync_t* q,
|
||||
float(set_gain_callback)(void*, float),
|
||||
float min_gain,
|
||||
float max_gain,
|
||||
float init_gain_value)
|
||||
{
|
||||
int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream);
|
||||
q->do_agc = n==0?true:false;
|
||||
if (q->do_agc) {
|
||||
|
|
|
@ -354,7 +354,7 @@ float srslte_ue_ul_pusch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float
|
|||
MPR = q->pusch_cfg.last_O_cqi;
|
||||
}
|
||||
MPR /= q->pusch.dci.nof_re;
|
||||
delta = 10 * log10((pow(2, MPR * 1.25) - 1) * beta_offset_pusch);
|
||||
delta = 10 * log10f((powf(2, MPR * 1.25) - 1) * beta_offset_pusch);
|
||||
}
|
||||
#else
|
||||
printf("Do this in pusch??");
|
||||
|
@ -362,10 +362,10 @@ float srslte_ue_ul_pusch_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float
|
|||
// TODO: This implements closed-loop power control
|
||||
float f = 0;
|
||||
|
||||
float pusch_power = 10 * log10(cfg->ul_cfg.pusch.grant.L_prb) + p0_pusch + alpha * PL + delta + f;
|
||||
float pusch_power = 10 * log10f(cfg->ul_cfg.pusch.grant.L_prb) + p0_pusch + alpha * PL + delta + f;
|
||||
DEBUG("PUSCH: P=%f -- 10M=%f, p0=%f,alpha=%f,PL=%f,\n",
|
||||
pusch_power,
|
||||
10 * log10(cfg->ul_cfg.pusch.grant.L_prb),
|
||||
10 * log10f(cfg->ul_cfg.pusch.grant.L_prb),
|
||||
p0_pusch,
|
||||
alpha,
|
||||
PL);
|
||||
|
@ -464,12 +464,12 @@ float srs_power(srslte_ue_ul_t* q, srslte_ue_ul_cfg_t* cfg, float PL)
|
|||
p_srs_offset = -10.5 + 1.5 * cfg->ul_cfg.power_ctrl.p_srs_offset;
|
||||
}
|
||||
|
||||
float p_srs = p_srs_offset + 10 * log10(M_sc) + p0_pusch + alpha * PL + f;
|
||||
float p_srs = p_srs_offset + 10 * log10f(M_sc) + p0_pusch + alpha * PL + f;
|
||||
|
||||
DEBUG("SRS: P=%f -- p_offset=%f, 10M=%f, p0_pusch=%f, alpha=%f, PL=%f, f=%f\n",
|
||||
p_srs,
|
||||
p_srs_offset,
|
||||
10 * log10(M_sc),
|
||||
10 * log10f(M_sc),
|
||||
p0_pusch,
|
||||
alpha,
|
||||
PL,
|
||||
|
|
|
@ -390,7 +390,7 @@ void srslte_vec_abs_dB_cf(const cf_t* x, float default_value, float* abs, const
|
|||
// Check boundaries
|
||||
if (isnormal(abs[i])) {
|
||||
// Avoid infinites and zeros
|
||||
abs[i] = 20.0f * log10f(abs[i]);
|
||||
abs[i] = srslte_convert_amplitude_to_dB(abs[i]);
|
||||
} else {
|
||||
// Set to default value instead
|
||||
abs[i] = default_value;
|
||||
|
|
|
@ -274,7 +274,7 @@ void radio::set_rx_gain(float gain)
|
|||
srslte_rf_set_rx_gain(&rf_device, gain);
|
||||
}
|
||||
|
||||
double radio::set_rx_gain_th(float gain)
|
||||
float radio::set_rx_gain_th(float gain)
|
||||
{
|
||||
return srslte_rf_set_rx_gain_th(&rf_device, gain);
|
||||
}
|
||||
|
|
|
@ -150,9 +150,9 @@ void parse_args(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
static double set_gain_callback(void* h, double gain)
|
||||
static float set_gain_callback(void* h, float gain)
|
||||
{
|
||||
radio* r = (radio*)h;
|
||||
auto r = (radio*)h;
|
||||
return r->set_rx_gain_th(gain);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ static void* plot_thread_run(void* arg)
|
|||
srslte_vec_abs_square_cf(fft_plot_buffer[r], fft_plot_temp, fft_plot_buffer_size);
|
||||
|
||||
for (uint32_t j = 0; j < fft_plot_buffer_size; j++) {
|
||||
fft_plot_temp[j] = 10.0f * log10f(fft_plot_temp[j]);
|
||||
fft_plot_temp[j] = srslte_convert_power_to_dB(fft_plot_temp[j]);
|
||||
}
|
||||
|
||||
plot_real_setNewData(&fft_plot[r], fft_plot_temp, fft_plot_buffer_size);
|
||||
|
@ -189,7 +189,7 @@ static void* plot_thread_run(void* arg)
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int init_plots(uint32_t frame_size)
|
||||
|
|
|
@ -107,7 +107,7 @@ void metrics_csv::set_metrics(enb_metrics_t &metrics, const uint32_t period_usec
|
|||
std::string metrics_csv::float_to_string(float f, int digits, bool add_semicolon)
|
||||
{
|
||||
std::ostringstream os;
|
||||
const int precision = (f == 0.0) ? digits-1 : digits - log10(fabs(f))-2*DBL_EPSILON;
|
||||
const int precision = (f == 0.0) ? digits - 1 : digits - log10f(fabs(f)) - 2 * DBL_EPSILON;
|
||||
os << std::fixed << std::setprecision(precision) << f;
|
||||
if (add_semicolon)
|
||||
os << ';';
|
||||
|
|
|
@ -150,7 +150,7 @@ std::string metrics_stdout::float_to_string(float f, int digits)
|
|||
precision = digits-1;
|
||||
}
|
||||
else {
|
||||
precision = digits - (int)(log10(fabs(f))-2*DBL_EPSILON);
|
||||
precision = digits - (int)(log10f(fabs(f)) - 2 * DBL_EPSILON);
|
||||
}
|
||||
os << std::setw(6) << std::fixed << std::setprecision(precision) << f;
|
||||
return os.str();
|
||||
|
@ -158,7 +158,7 @@ std::string metrics_stdout::float_to_string(float f, int digits)
|
|||
|
||||
std::string metrics_stdout::float_to_eng_string(float f, int digits)
|
||||
{
|
||||
const int degree = (f == 0.0) ? 0 : lrint( floor( log10( fabs( f ) ) / 3) );
|
||||
const int degree = (f == 0.0) ? 0 : lrint(floor(log10f(fabs(f)) / 3));
|
||||
|
||||
std::string factor;
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void metrics_csv::set_metrics(ue_metrics_t &metrics, const uint32_t period_usec)
|
|||
std::string metrics_csv::float_to_string(float f, int digits, bool add_semicolon)
|
||||
{
|
||||
std::ostringstream os;
|
||||
const int precision = (f == 0.0) ? digits-1 : digits - log10(fabs(f))-2*DBL_EPSILON;
|
||||
const int precision = (f == 0.0) ? digits - 1 : digits - log10f(fabs(f)) - 2 * DBL_EPSILON;
|
||||
os << std::fixed << std::setprecision(precision) << f;
|
||||
if (add_semicolon)
|
||||
os << ';';
|
||||
|
|
|
@ -129,7 +129,7 @@ std::string metrics_stdout::float_to_string(float f, int digits)
|
|||
|
||||
std::string metrics_stdout::float_to_eng_string(float f, int digits)
|
||||
{
|
||||
const int degree = (f == 0.0) ? 0 : lrint( floor( log10( fabs( f ) ) / 3) );
|
||||
const int degree = (f == 0.0) ? 0 : lrint(floor(log10f(fabs(f)) / 3));
|
||||
|
||||
std::string factor;
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ static int radio_recv_callback(void* obj, cf_t* data[SRSLTE_MAX_PORTS], uint32_t
|
|||
return ((async_scell_recv*)obj)->radio_recv_fnc(data, nsamples, rx_time);
|
||||
}
|
||||
|
||||
static double callback_set_rx_gain(void* h, double gain)
|
||||
static float callback_set_rx_gain(void* h, float gain)
|
||||
{
|
||||
return ((async_scell_recv*)h)->set_rx_gain(gain);
|
||||
return (float)((async_scell_recv*)h)->set_rx_gain(gain);
|
||||
}
|
||||
|
||||
void async_scell_recv::init(srslte::radio_interface_phy* _radio_handler, phy_common* _worker_com, srslte::log* _log_h)
|
||||
|
|
|
@ -84,17 +84,17 @@ void measure::set_cell(srslte_cell_t cell)
|
|||
|
||||
float measure::rssi()
|
||||
{
|
||||
return 10 * log10(mean_rssi);
|
||||
return srslte_convert_power_to_dB(mean_rssi);
|
||||
}
|
||||
|
||||
float measure::rsrp()
|
||||
{
|
||||
return 10 * log10(mean_rsrp) + 30 - rx_gain_offset;
|
||||
return srslte_convert_power_to_dBm(mean_rsrp) - rx_gain_offset;
|
||||
}
|
||||
|
||||
float measure::rsrq()
|
||||
{
|
||||
return 10 * log10(mean_rsrq);
|
||||
return srslte_convert_power_to_dB(mean_rsrq);
|
||||
}
|
||||
|
||||
float measure::snr()
|
||||
|
@ -112,9 +112,9 @@ uint32_t measure::frame_st_idx()
|
|||
return final_offset;
|
||||
}
|
||||
|
||||
void measure::set_rx_gain_offset(float rx_gain_offset)
|
||||
void measure::set_rx_gain_offset(float rx_gain_offset_)
|
||||
{
|
||||
this->rx_gain_offset = rx_gain_offset;
|
||||
rx_gain_offset = rx_gain_offset_;
|
||||
}
|
||||
|
||||
measure::ret_code measure::run_multiple_subframes(cf_t* input_buffer, uint32_t offset, uint32_t sf_idx, uint32_t max_sf)
|
||||
|
|
|
@ -294,11 +294,11 @@ void sf_worker::update_measurements()
|
|||
if (get_id() == 0) {
|
||||
|
||||
// Average RSSI over all symbols in antenna port 0 (make sure SF length is non-zero)
|
||||
float rssi_dbm =
|
||||
SRSLTE_SF_LEN_PRB(cell.nof_prb) > 0
|
||||
? (10 * log10(srslte_vec_avg_power_cf(cc_workers[0]->get_rx_buffer(0), SRSLTE_SF_LEN_PRB(cell.nof_prb))) +
|
||||
30)
|
||||
: 0;
|
||||
float rssi_dbm = SRSLTE_SF_LEN_PRB(cell.nof_prb) > 0
|
||||
? (srslte_convert_power_to_dB(srslte_vec_avg_power_cf(cc_workers[0]->get_rx_buffer(0),
|
||||
SRSLTE_SF_LEN_PRB(cell.nof_prb))) +
|
||||
30)
|
||||
: 0;
|
||||
if (std::isnormal(rssi_dbm)) {
|
||||
phy->avg_rssi_dbm = SRSLTE_VEC_EMA(rssi_dbm, phy->avg_rssi_dbm, phy->args->snr_ema_coeff);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ int radio_recv_callback(void *obj, cf_t *data[SRSLTE_MAX_PORTS], uint32_t nsampl
|
|||
return ((sync*)obj)->radio_recv_fnc(data, nsamples, rx_time);
|
||||
}
|
||||
|
||||
double callback_set_rx_gain(void *h, double gain) {
|
||||
float callback_set_rx_gain(void* h, float gain)
|
||||
{
|
||||
return ((sync*)h)->set_rx_gain(gain);
|
||||
}
|
||||
|
||||
|
|
|
@ -194,12 +194,11 @@ public:
|
|||
}
|
||||
|
||||
// Undo srslte_enb_dl_gen_signal scaling
|
||||
float scale = sqrt(cell_base.nof_prb) / 0.05f / enb_dl.ifft->symbol_sz;
|
||||
float scale = sqrtf(cell_base.nof_prb) / 0.05f / enb_dl.ifft->symbol_sz;
|
||||
|
||||
// Apply Neighbour cell attenuation
|
||||
if (enb_dl.cell.id != cell_id_start) {
|
||||
float scale_dB = -ncell_attenuation_dB;
|
||||
scale *= powf(10.0f, scale_dB / 20.0f);
|
||||
scale *= srslte_convert_dB_to_amplitude(-ncell_attenuation_dB);
|
||||
}
|
||||
|
||||
// Scale signal
|
||||
|
|
Loading…
Reference in New Issue