From ea162bacad0e6fce379b9ae2c9155ccae4a60f77 Mon Sep 17 00:00:00 2001 From: Cillian O'Driscoll Date: Wed, 2 Dec 2015 14:05:34 +0000 Subject: [PATCH] Added fxpt64 --- src/algorithms/tracking/libs/CMakeLists.txt | 3 +- src/algorithms/tracking/libs/fxpt64.cc | 50 +++++++++++++++++++++ src/algorithms/tracking/libs/fxpt64.h | 41 +++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/algorithms/tracking/libs/fxpt64.cc create mode 100644 src/algorithms/tracking/libs/fxpt64.h diff --git a/src/algorithms/tracking/libs/CMakeLists.txt b/src/algorithms/tracking/libs/CMakeLists.txt index 505c62685..3abcd1e80 100644 --- a/src/algorithms/tracking/libs/CMakeLists.txt +++ b/src/algorithms/tracking/libs/CMakeLists.txt @@ -30,9 +30,10 @@ if(ENABLE_CUDA) endif(ENABLE_CUDA) -set(TRACKING_LIB_SOURCES +set(TRACKING_LIB_SOURCES correlator.cc cpu_multicorrelator.cc + fxpt64.cc lock_detectors.cc tcp_communication.cc tcp_packet_data.cc diff --git a/src/algorithms/tracking/libs/fxpt64.cc b/src/algorithms/tracking/libs/fxpt64.cc new file mode 100644 index 000000000..f4ee86e94 --- /dev/null +++ b/src/algorithms/tracking/libs/fxpt64.cc @@ -0,0 +1,50 @@ +/*! + * \file fxpt64.cc + * \brief Utility functions for fixed point 64 bit arithmetic + * \authors + * + * + * ------------------------------------------------------------------------- + * + * 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 . + * + * ------------------------------------------------------------------------- + */ + +#include "fxpt64.h" +#include + +int64_t double_to_fxpt64( double in, unsigned int frac_len ) +{ + int64_t out = static_cast< int64_t >( in * std::pow(2.0, frac_len) ); + + return out; +} + +double fxpt64_to_double( int64_t in, unsigned int frac_len ) +{ + double out = static_cast< double >( in ) * std::pow( 2.0, -static_cast(frac_len) ); + + return out; +} + diff --git a/src/algorithms/tracking/libs/fxpt64.h b/src/algorithms/tracking/libs/fxpt64.h new file mode 100644 index 000000000..075af2232 --- /dev/null +++ b/src/algorithms/tracking/libs/fxpt64.h @@ -0,0 +1,41 @@ +/*! + * \file fxpt64.h + * \brief Utility functions for fixed point 64 bit arithmetic + * \authors
    + *
  • Cillian O'Driscoll, 2015. cillian.odriscoll(at)gmail.com + *
+ * + * + * ------------------------------------------------------------------------- + * + * 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 . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_FXPT64_H_ +#define GNSS_SDR_FXPT64_H_ +#include + +int64_t double_to_fxpt64( double in, unsigned int frac_len = 32 ); +double fxpt64_to_double( int64_t in, unsigned int frac_len = 32 ); + +#endif