|
|
@ -10,6 +10,7 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "srsran/phy/channel/ch_awgn.h"
|
|
|
|
#include "srsran/phy/resampling/resampler.h"
|
|
|
|
#include "srsran/phy/resampling/resampler.h"
|
|
|
|
#include "srsran/phy/utils/debug.h"
|
|
|
|
#include "srsran/phy/utils/debug.h"
|
|
|
|
#include "srsran/phy/utils/vector.h"
|
|
|
|
#include "srsran/phy/utils/vector.h"
|
|
|
@ -20,12 +21,19 @@
|
|
|
|
static uint32_t buffer_size = 1920;
|
|
|
|
static uint32_t buffer_size = 1920;
|
|
|
|
static uint32_t factor = 2;
|
|
|
|
static uint32_t factor = 2;
|
|
|
|
static uint32_t repetitions = 2;
|
|
|
|
static uint32_t repetitions = 2;
|
|
|
|
|
|
|
|
static enum {
|
|
|
|
|
|
|
|
WAVE_SINE = 0,
|
|
|
|
|
|
|
|
WAVE_DELTA,
|
|
|
|
|
|
|
|
WAVE_STEP,
|
|
|
|
|
|
|
|
WAVE_GAUSS,
|
|
|
|
|
|
|
|
} wave = WAVE_SINE;
|
|
|
|
|
|
|
|
|
|
|
|
static void usage(char* prog)
|
|
|
|
static void usage(char* prog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Usage: %s [sfr]\n", prog);
|
|
|
|
printf("Usage: %s [sfr]\n", prog);
|
|
|
|
printf("\t-s Buffer size [Default %d]\n", buffer_size);
|
|
|
|
printf("\t-s Buffer size [Default %d]\n", buffer_size);
|
|
|
|
printf("\t-f Buffer size [Default %d]\n", factor);
|
|
|
|
printf("\t-f Interpolation/Decimation factor [Default %d]\n", factor);
|
|
|
|
|
|
|
|
printf("\t-w Wave type: sine, step, delta [Default sine]\n");
|
|
|
|
printf("\t-f r [Default %d]\n", repetitions);
|
|
|
|
printf("\t-f r [Default %d]\n", repetitions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -33,7 +41,7 @@ static void parse_args(int argc, char** argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int opt;
|
|
|
|
int opt;
|
|
|
|
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "sfr")) != -1) {
|
|
|
|
while ((opt = getopt(argc, argv, "sfrvw")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
switch (opt) {
|
|
|
|
case 's':
|
|
|
|
case 's':
|
|
|
|
buffer_size = (uint32_t)strtol(argv[optind], NULL, 10);
|
|
|
|
buffer_size = (uint32_t)strtol(argv[optind], NULL, 10);
|
|
|
@ -44,6 +52,33 @@ static void parse_args(int argc, char** argv)
|
|
|
|
case 'r':
|
|
|
|
case 'r':
|
|
|
|
repetitions = (uint32_t)strtol(argv[optind], NULL, 10);
|
|
|
|
repetitions = (uint32_t)strtol(argv[optind], NULL, 10);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
|
|
|
|
srsran_verbose++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
|
|
|
|
|
|
|
if (strcmp(argv[optind], "sine") == 0) {
|
|
|
|
|
|
|
|
wave = WAVE_SINE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[optind], "delta") == 0) {
|
|
|
|
|
|
|
|
wave = WAVE_DELTA;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[optind], "step") == 0) {
|
|
|
|
|
|
|
|
wave = WAVE_STEP;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[optind], "gauss") == 0) {
|
|
|
|
|
|
|
|
wave = WAVE_GAUSS;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Invalid wave '%s'\n", argv[optind]);
|
|
|
|
|
|
|
|
usage(argv[0]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
usage(argv[0]);
|
|
|
|
usage(argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
@ -56,6 +91,7 @@ int main(int argc, char** argv)
|
|
|
|
struct timeval t[3] = {};
|
|
|
|
struct timeval t[3] = {};
|
|
|
|
srsran_resampler_fft_t interp = {};
|
|
|
|
srsran_resampler_fft_t interp = {};
|
|
|
|
srsran_resampler_fft_t decim = {};
|
|
|
|
srsran_resampler_fft_t decim = {};
|
|
|
|
|
|
|
|
srsran_channel_awgn_t awgn = {};
|
|
|
|
|
|
|
|
|
|
|
|
parse_args(argc, argv);
|
|
|
|
parse_args(argc, argv);
|
|
|
|
|
|
|
|
|
|
|
@ -72,7 +108,31 @@ int main(int argc, char** argv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
srsran_vec_cf_zero(src, buffer_size);
|
|
|
|
srsran_vec_cf_zero(src, buffer_size);
|
|
|
|
srsran_vec_gen_sine(1.0f, 0.01f, src, buffer_size / 10);
|
|
|
|
|
|
|
|
|
|
|
|
switch (wave) {
|
|
|
|
|
|
|
|
case WAVE_SINE:
|
|
|
|
|
|
|
|
srsran_vec_gen_sine(1.0f, 0.01f, src, buffer_size / 2);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAVE_DELTA:
|
|
|
|
|
|
|
|
src[0] = 1.0f;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAVE_STEP:
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < buffer_size; i++) {
|
|
|
|
|
|
|
|
src[i] = 1.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAVE_GAUSS:
|
|
|
|
|
|
|
|
srsran_channel_awgn_init(&awgn, 0);
|
|
|
|
|
|
|
|
srsran_channel_awgn_set_n0(&awgn, 0);
|
|
|
|
|
|
|
|
srsran_channel_awgn_run_c(&awgn, src, src, buffer_size);
|
|
|
|
|
|
|
|
srsran_channel_awgn_free(&awgn);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
|
|
|
|
|
|
|
|
printf("signal=");
|
|
|
|
|
|
|
|
srsran_vec_fprint_c(stdout, src, buffer_size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gettimeofday(&t[1], NULL);
|
|
|
|
gettimeofday(&t[1], NULL);
|
|
|
|
for (uint32_t r = 0; r < repetitions; r++) {
|
|
|
|
for (uint32_t r = 0; r < repetitions; r++) {
|
|
|
@ -82,22 +142,26 @@ int main(int argc, char** argv)
|
|
|
|
gettimeofday(&t[2], NULL);
|
|
|
|
gettimeofday(&t[2], NULL);
|
|
|
|
get_time_interval(t);
|
|
|
|
get_time_interval(t);
|
|
|
|
uint64_t duration_us = (uint64_t)(t[0].tv_sec * 1000000UL + t[0].tv_usec);
|
|
|
|
uint64_t duration_us = (uint64_t)(t[0].tv_sec * 1000000UL + t[0].tv_usec);
|
|
|
|
printf("Done %.1f Msps\n", factor * buffer_size * repetitions / (double)duration_us);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("interp=");
|
|
|
|
if (srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
|
|
|
|
// srsran_vec_fprint_c(stdout, interpolated, buffer_size * factor);
|
|
|
|
printf("interp=");
|
|
|
|
|
|
|
|
srsran_vec_fprint_c(stdout, interpolated, buffer_size * factor);
|
|
|
|
|
|
|
|
printf("decim=");
|
|
|
|
|
|
|
|
srsran_vec_fprint_c(stdout, decimated, buffer_size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check error
|
|
|
|
// Check error
|
|
|
|
uint32_t delay = srsran_resampler_fft_get_delay(&decim) * 2;
|
|
|
|
uint32_t delay = (srsran_resampler_fft_get_delay(&decim) + srsran_resampler_fft_get_delay(&interp)) / factor;
|
|
|
|
uint32_t nsamples = buffer_size - delay;
|
|
|
|
uint32_t nsamples = buffer_size - delay;
|
|
|
|
srsran_vec_sub_ccc(src, &decimated[delay], interpolated, nsamples);
|
|
|
|
srsran_vec_sub_ccc(src, &decimated[delay], interpolated, nsamples);
|
|
|
|
float mse = sqrtf(srsran_vec_avg_power_cf(interpolated, nsamples));
|
|
|
|
float mse = sqrtf(srsran_vec_avg_power_cf(interpolated, nsamples));
|
|
|
|
printf("MSE: %f\n", mse);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("src=");
|
|
|
|
if (srsran_verbose >= SRSRAN_VERBOSE_INFO && !handler_registered) {
|
|
|
|
// srsran_vec_fprint_c(stdout, src, nsamples);
|
|
|
|
printf("recovered=");
|
|
|
|
// printf("decim=");
|
|
|
|
srsran_vec_fprint_c(stdout, &decimated[delay], nsamples);
|
|
|
|
// srsran_vec_fprint_c(stdout, &decimated[delay], nsamples);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Done %.1f Msps; MSE: %.6f\n", factor * buffer_size * repetitions / (double)duration_us, mse);
|
|
|
|
|
|
|
|
|
|
|
|
srsran_resampler_fft_free(&interp);
|
|
|
|
srsran_resampler_fft_free(&interp);
|
|
|
|
srsran_resampler_fft_free(&decim);
|
|
|
|
srsran_resampler_fft_free(&decim);
|
|
|
|