mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-08-05 05:13:48 +00:00
20% of performance improvement
This commit is contained in:
parent
00d2941267
commit
b7c1469616
@ -37,10 +37,11 @@
|
|||||||
|
|
||||||
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift)
|
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift)
|
||||||
{
|
{
|
||||||
unsigned int G1[1023];
|
bool G1[1023];
|
||||||
unsigned int G2[1023];
|
bool G2[1023];
|
||||||
unsigned int G1_register[10], G2_register[10];
|
bool G1_register[10], G2_register[10];
|
||||||
unsigned int feedback1, feedback2;
|
bool feedback1, feedback2;
|
||||||
|
bool aux;
|
||||||
unsigned int lcv, lcv2;
|
unsigned int lcv, lcv2;
|
||||||
unsigned int delay;
|
unsigned int delay;
|
||||||
signed int prn_idx;
|
signed int prn_idx;
|
||||||
@ -58,7 +59,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prn_idx = _prn-1;
|
prn_idx = _prn - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A simple error check */
|
/* A simple error check */
|
||||||
@ -94,13 +95,18 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns
|
|||||||
delay = 1023 - delays[prn_idx];
|
delay = 1023 - delays[prn_idx];
|
||||||
delay += _chip_shift;
|
delay += _chip_shift;
|
||||||
delay %= 1023;
|
delay %= 1023;
|
||||||
|
|
||||||
/* Generate PRN from G1 and G2 Registers */
|
/* Generate PRN from G1 and G2 Registers */
|
||||||
for(lcv = 0; lcv < 1023; lcv++)
|
for(lcv = 0; lcv < 1023; lcv++)
|
||||||
{
|
{
|
||||||
_dest[lcv] = std::complex<float>(G1[(lcv + _chip_shift)%1023]^G2[delay], 0);
|
aux = G1[(lcv + _chip_shift) % 1023]^G2[delay];
|
||||||
if(_dest[lcv].real() == 0.0) //javi
|
if(aux == true)
|
||||||
{
|
{
|
||||||
_dest[lcv].real(-1.0);
|
_dest[lcv] = std::complex<float>(1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dest[lcv] = std::complex<float>(-1, 0);
|
||||||
}
|
}
|
||||||
delay++;
|
delay++;
|
||||||
delay %= 1023;
|
delay %= 1023;
|
||||||
@ -108,6 +114,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency
|
* Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency
|
||||||
*/
|
*/
|
||||||
|
80
src/tests/arithmetic/code_generation_test.cc
Normal file
80
src/tests/arithmetic/code_generation_test.cc
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*!
|
||||||
|
* \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
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a software defined Global Navigation
|
||||||
|
* Satellite Systems receiver
|
||||||
|
*
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <complex>
|
||||||
|
#include <ctime>
|
||||||
|
#include "gps_sdr_signal_processing.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TEST(CodeGenGPSL1_Test, CodeGeneration)
|
||||||
|
{
|
||||||
|
std::complex<float>* _dest = new std::complex<float>[1023];
|
||||||
|
signed int _prn = 1;
|
||||||
|
unsigned int _chip_shift = 4;
|
||||||
|
|
||||||
|
int iterations = 100;
|
||||||
|
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
|
|
||||||
|
for(int i = 0; i < iterations; i++)
|
||||||
|
{
|
||||||
|
gps_l1_ca_code_gen_complex( _dest, _prn, _chip_shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
|
ASSERT_LE(0, end - begin);
|
||||||
|
std::cout << "Generation completed in " << (end - begin) << " microseconds" << std::endl;
|
||||||
|
delete[] _dest;
|
||||||
|
|
||||||
|
|
||||||
|
/* std::complex<float>* _dest2 = new std::complex<float>[1023];gettimeofday(&tv, NULL);
|
||||||
|
long long int begin2 = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
|
|
||||||
|
for(int i = 0; i < iterations; i++)
|
||||||
|
{
|
||||||
|
gps_l1_ca_code_gen_complex2( _dest2, _prn, _chip_shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
long long int end2 = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||||
|
std::cout << "Generation 2 completed in " << (end2 - begin2) << " microseconds" << std::endl;
|
||||||
|
|
||||||
|
for (int j=0; j<1023;j++)
|
||||||
|
{
|
||||||
|
if(_dest[j] != _dest2[j]) std::cout << "Error!" << std::endl;
|
||||||
|
}
|
||||||
|
delete _dest2; */
|
||||||
|
}
|
@ -70,6 +70,7 @@ DECLARE_string(log_dir);
|
|||||||
#include "arithmetic/conjugate_test.cc"
|
#include "arithmetic/conjugate_test.cc"
|
||||||
#include "arithmetic/magnitude_squared_test.cc"
|
#include "arithmetic/magnitude_squared_test.cc"
|
||||||
#include "arithmetic/multiply_test.cc"
|
#include "arithmetic/multiply_test.cc"
|
||||||
|
#include "arithmetic/code_generation_test.cc"
|
||||||
#include "configuration/file_configuration_test.cc"
|
#include "configuration/file_configuration_test.cc"
|
||||||
#include "configuration/in_memory_configuration_test.cc"
|
#include "configuration/in_memory_configuration_test.cc"
|
||||||
#include "control_thread/control_message_factory_test.cc"
|
#include "control_thread/control_message_factory_test.cc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user