[hamradio-commits] [gnss-sdr] 20/251: Faster local carrier generation

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Wed Sep 2 00:22:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit 90ae04ee196e67411f82262b2033956a20b6f627
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Tue May 5 16:14:46 2015 +0200

    Faster local carrier generation
---
 src/algorithms/libs/gnss_signal_processing.cc | 33 ++++------------
 src/tests/arithmetic/code_generation_test.cc  | 55 ++++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc
index 9de66ca..8c505fe 100644
--- a/src/algorithms/libs/gnss_signal_processing.cc
+++ b/src/algorithms/libs/gnss_signal_processing.cc
@@ -32,43 +32,24 @@
  */
 
 #include "gnss_signal_processing.h"
-#include <gnuradio/fxpt.h>  // fixed point sine and cosine
+#include <gnuradio/fxpt_nco.h>
 
 
 void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps)
 {
-    int phase_i = 0;
-    int phase_step_i;
-    float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs);
-    phase_step_i = gr::fxpt::float_to_fixed(phase_step_f);
-    float sin_f, cos_f;
-
-    for(unsigned int i = 0; i < _samps; i++)
-        {
-            gr::fxpt::sincos(phase_i, &sin_f, &cos_f);
-            _dest[i] = std::complex<float>(cos_f, sin_f);
-            phase_i += phase_step_i;
-        }
+    gr::fxpt_nco d_nco;
+    d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs);
+    d_nco.sincos(_dest, _samps, 1); 
 }
 
 
 void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps)
 {
-    int phase_i = 0;
-    int phase_step_i;
-    float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs);
-    phase_step_i = gr::fxpt::float_to_fixed(phase_step_f);
-    float sin_f, cos_f;
-
-    for(unsigned int i = 0; i < _samps; i++)
-        {
-            gr::fxpt::sincos(phase_i, &sin_f, &cos_f);
-            _dest[i] = std::complex<float>(cos_f, -sin_f);
-            phase_i += phase_step_i;
-        }
+    gr::fxpt_nco d_nco;
+    d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs);
+    d_nco.sincos(_dest, _samps, 1); 
 }
 
-
 void hex_to_binary_converter(int * _dest, char _from)
 {
 	switch(_from)
diff --git a/src/tests/arithmetic/code_generation_test.cc b/src/tests/arithmetic/code_generation_test.cc
index aea2f50..e8f87ab 100644
--- a/src/tests/arithmetic/code_generation_test.cc
+++ b/src/tests/arithmetic/code_generation_test.cc
@@ -33,6 +33,7 @@
 #include <complex>
 #include <ctime>
 #include "gps_sdr_signal_processing.h"
+#include "gnss_signal_processing.h"
 
 
 
@@ -42,7 +43,7 @@ TEST(CodeGenGPSL1_Test, CodeGeneration)
     signed int _prn = 1;
     unsigned int _chip_shift = 4;
 
-    int iterations = 100;
+    int iterations = 100000;
 
     struct timeval tv;
     gettimeofday(&tv, NULL);
@@ -128,3 +129,55 @@ TEST(CodeGenGPSL1Sampled_Test, CodeGeneration)
         }
     delete[] _dest2; */
 }
+
+
+TEST(ComplexCarrier_Test, CodeGeneration)
+{
+    //signed int _prn = 1;
+    //unsigned int _chip_shift = 4;
+    double _fs = 8000000;
+    double _f = 4000;
+    const signed int _codeFreqBasis = 1023000; //Hz
+    const signed int _codeLength = 1023;
+    int _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
+    std::complex<float>* _dest = new std::complex<float>[_samplesPerCode];
+
+    int iterations = 100000;
+
+    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_sampled( _dest,  _prn, _fs, _chip_shift);
+            complex_exp_gen_conj( _dest, _f,  _fs,  _samplesPerCode);
+        }
+
+    gettimeofday(&tv, NULL);
+    long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
+    ASSERT_LE(0, end - begin);
+    std::cout << "Carrier generation completed in " << (end - begin) << " microseconds" << std::endl;
+    
+    /* std::complex<float>* _dest2 = new std::complex<float>[_samplesPerCode];
+    gettimeofday(&tv, NULL);
+    long long int begin2 = tv.tv_sec * 1000000 + tv.tv_usec;
+
+    for(int i = 0; i < iterations; i++)
+        {
+            complex_exp_gen_conj2( _dest2, _f,  _fs,  _samplesPerCode);
+        }
+
+    gettimeofday(&tv, NULL);
+    long long int end2 = tv.tv_sec * 1000000 + tv.tv_usec;
+    std::cout << "Carrier generation completed in " << (end2 - begin2) << " microseconds  (New)" << std::endl;
+
+    for (int j=0; j<_samplesPerCode;j++)
+        {
+            if(std::abs(_dest[j] - _dest2[j]) > 0.1) std::cout << "Error!" << std::endl;
+        }
+
+    std::cout << _dest[10] << "and " << _dest2[10] << std::endl;
+    delete[] _dest2;*/
+    delete[] _dest; 
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list