2015-05-03 08:50:57 +00:00
|
|
|
/*!
|
|
|
|
* \file code_generation_test.cc
|
|
|
|
* \brief This file implements tests for the generation of complex exponentials.
|
|
|
|
* \author Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2015-05-03 08:50:57 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-05-03 08:50:57 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "gnss_signal_processing.h"
|
|
|
|
#include "gps_sdr_signal_processing.h"
|
2019-07-29 19:47:46 +00:00
|
|
|
#include <gsl/gsl>
|
2017-08-11 03:18:38 +00:00
|
|
|
#include <chrono>
|
2015-05-03 08:50:57 +00:00
|
|
|
#include <complex>
|
|
|
|
|
|
|
|
|
2017-07-03 10:43:25 +00:00
|
|
|
TEST(CodeGenerationTest, CodeGenGPSL1Test)
|
2015-05-03 08:50:57 +00:00
|
|
|
{
|
2019-02-11 14:33:24 +00:00
|
|
|
auto* _dest = new std::complex<float>[1023];
|
2015-05-03 08:50:57 +00:00
|
|
|
signed int _prn = 1;
|
|
|
|
unsigned int _chip_shift = 4;
|
|
|
|
|
2015-05-10 11:20:52 +00:00
|
|
|
int iterations = 1000;
|
2015-05-03 08:50:57 +00:00
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
|
|
|
start = std::chrono::system_clock::now();
|
2015-05-03 08:50:57 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
for (int i = 0; i < iterations; i++)
|
2015-05-03 08:50:57 +00:00
|
|
|
{
|
2019-06-28 23:28:30 +00:00
|
|
|
gps_l1_ca_code_gen_complex(gsl::span<std::complex<float>>(_dest, 1023), _prn, _chip_shift);
|
2015-05-03 08:50:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
std::chrono::duration<double> elapsed_seconds = end - start;
|
2015-05-03 08:50:57 +00:00
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
delete[] _dest;
|
2017-08-14 22:04:51 +00:00
|
|
|
ASSERT_LE(0, elapsed_seconds.count());
|
|
|
|
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
2015-05-03 08:50:57 +00:00
|
|
|
}
|
2015-05-05 11:00:24 +00:00
|
|
|
|
|
|
|
|
2017-07-03 10:43:25 +00:00
|
|
|
TEST(CodeGenerationTest, CodeGenGPSL1SampledTest)
|
2015-05-05 11:00:24 +00:00
|
|
|
{
|
|
|
|
signed int _prn = 1;
|
|
|
|
unsigned int _chip_shift = 4;
|
2017-08-18 10:45:47 +00:00
|
|
|
double _fs = 8000000.0;
|
2019-08-18 23:29:04 +00:00
|
|
|
const signed int _codeFreqBasis = 1023000; // Hz
|
2015-05-05 11:00:24 +00:00
|
|
|
const signed int _codeLength = 1023;
|
2017-08-18 10:45:47 +00:00
|
|
|
int _samplesPerCode = round(_fs / static_cast<double>(_codeFreqBasis / _codeLength));
|
2019-02-11 14:33:24 +00:00
|
|
|
auto* _dest = new std::complex<float>[_samplesPerCode];
|
2015-05-05 11:00:24 +00:00
|
|
|
|
2015-05-10 11:20:52 +00:00
|
|
|
int iterations = 1000;
|
2015-05-05 11:00:24 +00:00
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
|
|
|
start = std::chrono::system_clock::now();
|
2015-05-05 11:00:24 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
for (int i = 0; i < iterations; i++)
|
2015-05-05 11:00:24 +00:00
|
|
|
{
|
2019-06-28 23:28:30 +00:00
|
|
|
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(_dest, _samplesPerCode), _prn, _fs, _chip_shift);
|
2015-05-05 11:00:24 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
std::chrono::duration<double> elapsed_seconds = end - start;
|
2015-05-13 14:40:46 +00:00
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
delete[] _dest;
|
2017-08-14 22:04:51 +00:00
|
|
|
ASSERT_LE(0, elapsed_seconds.count());
|
|
|
|
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
2015-05-05 11:00:24 +00:00
|
|
|
}
|
2015-05-05 14:14:46 +00:00
|
|
|
|
|
|
|
|
2017-07-03 10:43:25 +00:00
|
|
|
TEST(CodeGenerationTest, ComplexConjugateTest)
|
2015-05-05 14:14:46 +00:00
|
|
|
{
|
2017-08-18 10:45:47 +00:00
|
|
|
double _fs = 8000000.0;
|
|
|
|
double _f = 4000.0;
|
2019-08-18 23:29:04 +00:00
|
|
|
const signed int _codeFreqBasis = 1023000; // Hz
|
2015-05-05 14:14:46 +00:00
|
|
|
const signed int _codeLength = 1023;
|
2017-08-18 10:45:47 +00:00
|
|
|
int _samplesPerCode = round(_fs / static_cast<double>(_codeFreqBasis / _codeLength));
|
2019-02-11 14:33:24 +00:00
|
|
|
auto* _dest = new std::complex<float>[_samplesPerCode];
|
2015-05-05 14:14:46 +00:00
|
|
|
|
2015-05-10 11:20:52 +00:00
|
|
|
int iterations = 1000;
|
2015-05-05 14:14:46 +00:00
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
|
|
|
start = std::chrono::system_clock::now();
|
2015-05-05 14:14:46 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
for (int i = 0; i < iterations; i++)
|
2015-05-05 14:14:46 +00:00
|
|
|
{
|
2019-06-28 23:28:30 +00:00
|
|
|
complex_exp_gen_conj(gsl::span<std::complex<float>>(_dest, _samplesPerCode), _f, _fs);
|
2015-05-05 14:14:46 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
std::chrono::duration<double> elapsed_seconds = end - start;
|
|
|
|
|
2017-07-03 10:43:25 +00:00
|
|
|
delete[] _dest;
|
2017-08-14 22:04:51 +00:00
|
|
|
ASSERT_LE(0, elapsed_seconds.count());
|
|
|
|
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
2015-05-05 14:14:46 +00:00
|
|
|
}
|