2014-05-21 07:42:26 +00:00
|
|
|
/*!
|
2020-11-07 21:43:19 +00:00
|
|
|
* \file galileo_e5_signal_replica.cc
|
|
|
|
* \brief This library implements various functions for Galileo E5 signal
|
|
|
|
* replica generation
|
2014-05-21 07:42:26 +00:00
|
|
|
* \author Marc Sales, 2014. marcsales92(at)gmail.com
|
2020-06-01 14:29:42 +00:00
|
|
|
* \author Piyush Gupta, 2020. piyush04111999@gmail.com
|
|
|
|
* \note Code added as part of GSoc 2020 Program.
|
2014-05-20 19:53:12 +00:00
|
|
|
*
|
2020-05-08 07:50:05 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2014-05-21 07:42:26 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2014-05-21 07:42:26 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-05-21 07:42:26 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2014-05-20 19:53:12 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-07 21:43:19 +00:00
|
|
|
#include "galileo_e5_signal_replica.h"
|
2016-01-10 21:21:31 +00:00
|
|
|
#include "Galileo_E5a.h"
|
2020-06-01 14:29:42 +00:00
|
|
|
#include "Galileo_E5b.h"
|
2020-11-07 21:43:19 +00:00
|
|
|
#include "gnss_signal_replica.h"
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <gnuradio/gr_complex.h>
|
2019-06-30 02:47:15 +00:00
|
|
|
#include <memory>
|
2019-08-17 11:56:54 +00:00
|
|
|
#include <utility>
|
2019-11-30 00:09:07 +00:00
|
|
|
#include <vector>
|
2016-01-10 21:21:31 +00:00
|
|
|
|
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
void galileo_e5_a_code_gen_complex_primary(own::span<std::complex<float>> dest,
|
|
|
|
int32_t prn,
|
|
|
|
const std::array<char, 3>& signal_id)
|
2014-05-20 19:53:12 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
const uint32_t prn_ = prn - 1;
|
2018-08-13 08:18:05 +00:00
|
|
|
uint32_t index = 0;
|
2019-07-14 12:09:12 +00:00
|
|
|
std::array<int32_t, 4> a{};
|
2020-12-29 13:47:28 +00:00
|
|
|
if ((prn < 1) || (prn > 50))
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
if (signal_id[0] == '5' && signal_id[1] == 'Q')
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5A_Q_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), 0.0);
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), 0.0);
|
2016-05-02 21:46:30 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_Q_PRIMARY_CODE[prn_][GALILEO_E5A_Q_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
2016-05-02 21:46:30 +00:00
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
else if (signal_id[0] == '5' && signal_id[1] == 'I')
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), 0.0);
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), 0.0);
|
2016-05-02 21:46:30 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn_][GALILEO_E5A_I_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
2016-05-02 21:46:30 +00:00
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
else if (signal_id[0] == '5' && signal_id[1] == 'X')
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2019-07-14 12:09:12 +00:00
|
|
|
std::array<int32_t, 4> b{};
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5A_I_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2016-05-02 21:46:30 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn_][i]);
|
|
|
|
hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), static_cast<float>(b[0]));
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), static_cast<float>(b[1]));
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), static_cast<float>(b[2]));
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), static_cast<float>(b[3]));
|
2016-05-02 21:46:30 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5A_I_PRIMARY_CODE[prn_][GALILEO_E5A_I_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
hex_to_binary_converter(b, GALILEO_E5A_Q_PRIMARY_CODE[prn_][GALILEO_E5A_Q_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), static_cast<float>(b[0]));
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), static_cast<float>(b[1]));
|
2016-05-02 21:46:30 +00:00
|
|
|
}
|
2014-06-17 17:13:24 +00:00
|
|
|
}
|
|
|
|
|
2018-08-13 08:18:05 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
void galileo_e5_a_code_gen_complex_sampled(own::span<std::complex<float>> dest,
|
|
|
|
uint32_t prn,
|
|
|
|
const std::array<char, 3>& signal_id,
|
|
|
|
int32_t sampling_freq,
|
|
|
|
uint32_t chip_shift)
|
2014-05-20 19:53:12 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
constexpr uint32_t codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS;
|
|
|
|
constexpr int32_t codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_CPS;
|
2020-07-11 09:13:53 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
const auto samplesPerCode = static_cast<uint32_t>(static_cast<double>(sampling_freq) / (static_cast<double>(codeFreqBasis) / static_cast<double>(codeLength)));
|
|
|
|
const uint32_t delay = ((codeLength - chip_shift) % codeLength) * samplesPerCode / codeLength;
|
2014-06-17 17:13:24 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
std::vector<std::complex<float>> code_aux(codeLength);
|
|
|
|
galileo_e5_a_code_gen_complex_primary(code_aux, prn, signal_id);
|
2014-06-17 17:13:24 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
if (sampling_freq != codeFreqBasis)
|
2014-05-20 19:53:12 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
std::vector<std::complex<float>> resampled_signal_aux(samplesPerCode);
|
|
|
|
resampler(code_aux, resampled_signal_aux, codeFreqBasis, sampling_freq); // resamples code to sampling_freq
|
|
|
|
code_aux = std::move(resampled_signal_aux);
|
2014-05-20 19:53:12 +00:00
|
|
|
}
|
2019-11-29 23:55:13 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
for (uint32_t i = 0; i < samplesPerCode; i++)
|
2014-05-20 19:53:12 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
dest[(i + delay) % samplesPerCode] = code_aux[i];
|
2014-05-20 19:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-01 14:29:42 +00:00
|
|
|
|
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
void galileo_e5_b_code_gen_complex_primary(own::span<std::complex<float>> dest,
|
|
|
|
int32_t prn,
|
|
|
|
const std::array<char, 3>& signal_id)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
const uint32_t prn_ = prn - 1;
|
2020-06-01 14:29:42 +00:00
|
|
|
uint32_t index = 0;
|
|
|
|
std::array<int32_t, 4> a{};
|
2020-12-29 13:47:28 +00:00
|
|
|
if ((prn < 1) || (prn > 50))
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
if (signal_id[0] == '7' && signal_id[1] == 'Q')
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5B_Q_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_Q_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), 0.0);
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), 0.0);
|
2020-06-01 14:29:42 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_Q_PRIMARY_CODE[prn_][GALILEO_E5B_Q_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
2020-06-01 14:29:42 +00:00
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
else if (signal_id[0] == '7' && signal_id[1] == 'I')
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5B_I_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_I_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), 0.0);
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), 0.0);
|
2020-06-01 14:29:42 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_I_PRIMARY_CODE[prn_][GALILEO_E5B_I_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), 0.0);
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), 0.0);
|
2020-06-01 14:29:42 +00:00
|
|
|
}
|
2020-12-29 13:47:28 +00:00
|
|
|
else if (signal_id[0] == '7' && signal_id[1] == 'X')
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
|
|
|
std::array<int32_t, 4> b{};
|
2020-07-03 09:36:38 +00:00
|
|
|
for (size_t i = 0; i < GALILEO_E5B_I_PRIMARY_CODE_STR_LENGTH - 1; i++)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_I_PRIMARY_CODE[prn_][i]);
|
|
|
|
hex_to_binary_converter(b, GALILEO_E5B_Q_PRIMARY_CODE[prn_][i]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), static_cast<float>(b[0]));
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), static_cast<float>(b[1]));
|
|
|
|
dest[index + 2] = std::complex<float>(static_cast<float>(a[2]), static_cast<float>(b[2]));
|
|
|
|
dest[index + 3] = std::complex<float>(static_cast<float>(a[3]), static_cast<float>(b[3]));
|
2020-06-01 14:29:42 +00:00
|
|
|
index = index + 4;
|
|
|
|
}
|
|
|
|
// last 2 bits are filled up zeros
|
2020-12-29 13:47:28 +00:00
|
|
|
hex_to_binary_converter(a, GALILEO_E5B_I_PRIMARY_CODE[prn_][GALILEO_E5B_I_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
hex_to_binary_converter(b, GALILEO_E5B_Q_PRIMARY_CODE[prn_][GALILEO_E5B_Q_PRIMARY_CODE_STR_LENGTH - 1]);
|
|
|
|
dest[index] = std::complex<float>(static_cast<float>(a[0]), static_cast<float>(b[0]));
|
|
|
|
dest[index + 1] = std::complex<float>(static_cast<float>(a[1]), static_cast<float>(b[1]));
|
2020-06-01 14:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
void galileo_e5_b_code_gen_complex_sampled(own::span<std::complex<float>> dest,
|
|
|
|
uint32_t prn,
|
|
|
|
const std::array<char, 3>& signal_id,
|
|
|
|
int32_t sampling_freq,
|
|
|
|
uint32_t chip_shift)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
constexpr uint32_t codeLength = GALILEO_E5B_CODE_LENGTH_CHIPS;
|
|
|
|
constexpr int32_t codeFreqBasis = GALILEO_E5B_CODE_CHIP_RATE_CPS;
|
2020-07-03 09:36:38 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
const auto samplesPerCode = static_cast<uint32_t>(static_cast<double>(sampling_freq) / (static_cast<double>(codeFreqBasis) / static_cast<double>(codeLength)));
|
|
|
|
const uint32_t delay = ((codeLength - chip_shift) % codeLength) * samplesPerCode / codeLength;
|
2020-06-01 14:29:42 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
std::vector<std::complex<float>> code_aux(codeLength);
|
|
|
|
galileo_e5_b_code_gen_complex_primary(code_aux, prn, signal_id);
|
2020-06-01 14:29:42 +00:00
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
if (sampling_freq != codeFreqBasis)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
std::vector<std::complex<float>> resampled_signal_aux(samplesPerCode);
|
|
|
|
resampler(code_aux, resampled_signal_aux, codeFreqBasis, sampling_freq); // resamples code to sampling_freq
|
|
|
|
code_aux = std::move(resampled_signal_aux);
|
2020-06-01 14:29:42 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 13:47:28 +00:00
|
|
|
for (uint32_t i = 0; i < samplesPerCode; i++)
|
2020-06-01 14:29:42 +00:00
|
|
|
{
|
2020-12-29 13:47:28 +00:00
|
|
|
dest[(i + delay) % samplesPerCode] = code_aux[i];
|
2020-06-01 14:29:42 +00:00
|
|
|
}
|
|
|
|
}
|