summaryrefslogtreecommitdiff
path: root/gr-digital/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/lib')
-rw-r--r--gr-digital/lib/CMakeLists.txt5
-rw-r--r--gr-digital/lib/correlate_and_sync_cc_impl.cc172
-rw-r--r--gr-digital/lib/correlate_and_sync_cc_impl.h62
-rw-r--r--gr-digital/lib/glfsr.cc19
-rw-r--r--gr-digital/lib/glfsr_source_b_impl.cc38
-rw-r--r--gr-digital/lib/glfsr_source_b_impl.h14
-rw-r--r--gr-digital/lib/glfsr_source_f_impl.cc38
-rw-r--r--gr-digital/lib/glfsr_source_f_impl.h18
-rw-r--r--gr-digital/lib/modulate_vector.cc4
9 files changed, 72 insertions, 298 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index 84f53ec4f3..b07bcc9d87 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -66,7 +66,6 @@ list(APPEND digital_sources
correlate_access_code_tag_bb_impl.cc
correlate_access_code_bb_ts_impl.cc
correlate_access_code_ff_ts_impl.cc
- correlate_and_sync_cc_impl.cc
costas_loop_cc_impl.cc
cpmmod_bc_impl.cc
crc32.cc
@@ -156,7 +155,7 @@ list(APPEND digital_libs
add_library(gnuradio-digital SHARED ${digital_sources})
target_link_libraries(gnuradio-digital ${digital_libs})
-GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel")
+GR_LIBRARY_FOO(gnuradio-digital)
add_dependencies(
gnuradio-digital
@@ -195,7 +194,7 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-digital_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "digital_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
endif(ENABLE_STATIC_LIBS)
diff --git a/gr-digital/lib/correlate_and_sync_cc_impl.cc b/gr-digital/lib/correlate_and_sync_cc_impl.cc
deleted file mode 100644
index b8c8e8669d..0000000000
--- a/gr-digital/lib/correlate_and_sync_cc_impl.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio 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, or (at your option)
- * any later version.
- *
- * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/io_signature.h>
-#include <gnuradio/math.h>
-#include "correlate_and_sync_cc_impl.h"
-#include <volk/volk.h>
-#include <boost/format.hpp>
-#include <boost/math/special_functions/round.hpp>
-#include <gnuradio/filter/pfb_arb_resampler.h>
-#include <gnuradio/filter/firdes.h>
-
-namespace gr {
- namespace digital {
-
- correlate_and_sync_cc::sptr
- correlate_and_sync_cc::make(const std::vector<gr_complex> &symbols,
- const std::vector<float> &filter,
- unsigned int sps, unsigned int nfilts)
- {
- return gnuradio::get_initial_sptr
- (new correlate_and_sync_cc_impl(symbols, filter, sps, nfilts));
- }
-
- correlate_and_sync_cc_impl::correlate_and_sync_cc_impl(const std::vector<gr_complex> &symbols,
- const std::vector<float> &filter,
- unsigned int sps, unsigned int nfilts)
- : sync_block("correlate_and_sync_cc",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(2, 2, sizeof(gr_complex)))
- {
- d_last_index = 0;
- d_sps = sps;
-
- // We want to add padding to the beginning of the symbols so we
- // can do the convolution of the symbols with the pulse shape.
- std::vector<gr_complex> padding((1+filter.size()/nfilts)/2, 0);
- std::vector<gr_complex> padded_symbols = symbols;
- padded_symbols.insert(padded_symbols.begin(), padding.begin(), padding.end());
-
- d_symbols.resize(d_sps*symbols.size(), 0);
- filter::kernel::pfb_arb_resampler_ccf resamp(d_sps, filter, nfilts);
- int nread;
- resamp.filter(&d_symbols[0], &padded_symbols[0], symbols.size(), nread);
- std::reverse(d_symbols.begin(), d_symbols.end());
-
- float corr = 0;
- for(size_t i=0; i < d_symbols.size(); i++)
- corr += abs(d_symbols[i]*conj(d_symbols[i]));
- d_thresh = 0.9*corr*corr;
-
- d_center_first_symbol = (padding.size() + 0.5) * d_sps;
-
- d_filter = new kernel::fft_filter_ccc(1, d_symbols);
-
- set_history(d_filter->ntaps());
-
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- correlate_and_sync_cc_impl::~correlate_and_sync_cc_impl()
- {
- delete d_filter;
- }
-
- std::vector<gr_complex>
- correlate_and_sync_cc_impl::symbols() const
- {
- return d_symbols;
- }
-
- void
- correlate_and_sync_cc_impl::set_symbols(const std::vector<gr_complex> &symbols)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_symbols = symbols;
- d_filter->set_taps(symbols);
- set_history(d_filter->ntaps());
- }
-
- int
- correlate_and_sync_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- const gr_complex *in = (gr_complex *)input_items[0];
- gr_complex *out = (gr_complex*)output_items[0];
- gr_complex *corr = (gr_complex*)output_items[1];
-
- memcpy(out, in, sizeof(gr_complex)*noutput_items);
-
- // Calculate the correlation with the known symbol
- d_filter->filter(noutput_items, in, corr);
-
- // Find the magnitude squared of the correlation
- std::vector<float> corr_mag(noutput_items+1);
- volk_32fc_magnitude_squared_32f(&corr_mag[0], corr, noutput_items);
-
- // Avoid buffer overflow from nested while, putting a stopper at the end
- corr_mag[noutput_items]=0;
- int i = d_sps;
- while(i < (noutput_items-1)) {
- if((corr_mag[i] - corr_mag[i-d_sps]) > d_thresh) {
- while(corr_mag[i] < corr_mag[i+1])
- i++;
-
- double nom = 0, den = 0;
- for(int s = 0; s < 3; s++) {
- nom += (s+1)*corr_mag[i+s-1];
- den += corr_mag[i+s-1];
- }
- double center = nom / den;
- center = (center - 2.0);
-
- // Adjust the results of the fft filter by moving back the
- // length of the filter offset by the number of sps.
- int index = i - d_symbols.size() + d_sps + 1;
-
- // Calculate the phase offset of the incoming signal; always
- // adjust it based on the proper rotation of the expected
- // known word; rotate by pi is the real part is < 0 since
- // the atan doesn't understand the ambiguity.
- float phase = fast_atan2f(corr[index].imag(), corr[index].real());
- if(corr[index].real() < 0.0)
- phase += M_PI;
-
- add_item_tag(0, nitems_written(0) + index, pmt::intern("phase_est"),
- pmt::from_double(phase), pmt::intern(alias()));
- add_item_tag(0, nitems_written(0) + index, pmt::intern("time_est"),
- pmt::from_double(center), pmt::intern(alias()));
- add_item_tag(0, nitems_written(0) + index, pmt::intern("corr_est"),
- pmt::from_double(corr_mag[index]), pmt::intern(alias()));
-
- i += d_sps;
- }
- else
- i++;
- }
-
- return noutput_items;
- }
-
- } /* namespace digital */
-} /* namespace gr */
-
diff --git a/gr-digital/lib/correlate_and_sync_cc_impl.h b/gr-digital/lib/correlate_and_sync_cc_impl.h
deleted file mode 100644
index d95ec517f8..0000000000
--- a/gr-digital/lib/correlate_and_sync_cc_impl.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio 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, or (at your option)
- * any later version.
- *
- * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_DIGITAL_CORRELATE_AND_SYNC_CC_IMPL_H
-#define INCLUDED_DIGITAL_CORRELATE_AND_SYNC_CC_IMPL_H
-
-#include <gnuradio/digital/correlate_and_sync_cc.h>
-#include <gnuradio/filter/fft_filter.h>
-
-using namespace gr::filter;
-
-namespace gr {
- namespace digital {
-
- class correlate_and_sync_cc_impl : public correlate_and_sync_cc
- {
- private:
- std::vector<gr_complex> d_symbols;
- unsigned int d_sps;
- float d_center_first_symbol;
- float d_thresh;
- kernel::fft_filter_ccc *d_filter;
-
- int d_last_index;
-
- public:
- correlate_and_sync_cc_impl(const std::vector<gr_complex> &symbols,
- const std::vector<float> &filter,
- unsigned int sps, unsigned int nfilts=32);
- ~correlate_and_sync_cc_impl();
-
- std::vector<gr_complex> symbols() const;
- void set_symbols(const std::vector<gr_complex> &symbols);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } // namespace digital
-} // namespace gr
-
-#endif /* INCLUDED_DIGITAL_CORRELATE_AND_SYNC_CC_IMPL_H */
diff --git a/gr-digital/lib/glfsr.cc b/gr-digital/lib/glfsr.cc
index fa6c765570..5593bf8615 100644
--- a/gr-digital/lib/glfsr.cc
+++ b/gr-digital/lib/glfsr.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2012 Free Software Foundation, Inc.
+ * Copyright 2007,2012,2016 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,7 +26,7 @@
namespace gr {
namespace digital {
- static int s_polynomial_masks[] = {
+ static uint32_t s_polynomial_masks[] = {
0x00000000,
0x00000001, // x^1 + 1
0x00000003, // x^2 + x^1 + 1
@@ -59,19 +59,28 @@ namespace gr {
0x10000002, // x^29 + x^2 + 1
0x20000029, // x^30 + x^4 + x^1 + 1
0x40000004, // x^31 + x^3 + 1
- (int) 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1
+ 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1
};
glfsr::~glfsr()
{
}
- int glfsr::glfsr_mask(int degree)
+ uint32_t glfsr::glfsr_mask(unsigned int degree)
{
if(degree < 1 || degree > 32)
- throw std::runtime_error("glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive");
+ throw std::runtime_error("glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive");
return s_polynomial_masks[degree];
}
+ uint8_t glfsr::next_bit()
+ {
+ unsigned char bit = d_shift_register & 0x1;
+ d_shift_register >>= 1;
+ if(bit)
+ d_shift_register ^= d_mask;
+ return bit;
+ }
+
} /* namespace digital */
} /* namespace gr */
diff --git a/gr-digital/lib/glfsr_source_b_impl.cc b/gr-digital/lib/glfsr_source_b_impl.cc
index 260bd45c24..6b1a14900f 100644
--- a/gr-digital/lib/glfsr_source_b_impl.cc
+++ b/gr-digital/lib/glfsr_source_b_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2007,2010,2012,2016 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -32,25 +32,25 @@ namespace gr {
namespace digital {
glfsr_source_b::sptr
- glfsr_source_b::make(int degree, bool repeat, int mask, int seed)
+ glfsr_source_b::make(unsigned int degree, bool repeat, uint32_t mask, uint32_t seed)
{
return gnuradio::get_initial_sptr
- (new glfsr_source_b_impl(degree, repeat, mask, seed));
+ (new glfsr_source_b_impl(degree, repeat, mask, seed));
}
- glfsr_source_b_impl::glfsr_source_b_impl(int degree, bool repeat,
- int mask, int seed)
+ glfsr_source_b_impl::glfsr_source_b_impl(unsigned int degree, bool repeat,
+ uint32_t mask, uint32_t seed)
: sync_block("glfsr_source_b",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(unsigned char))),
- d_repeat(repeat), d_index(0)
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof(unsigned char))),
+ d_repeat(repeat), d_index(0),
+ d_length( ( ((uint32_t)1) << degree) - 1)
{
if(degree < 1 || degree > 32)
- throw std::runtime_error("glfsr_source_b_impl: degree must be between 1 and 32 inclusive");
- d_length = (unsigned int)((1ULL << degree)-1);
+ throw std::runtime_error("glfsr_source_b_impl: degree must be between 1 and 32 inclusive");
if(mask == 0)
- mask = glfsr::glfsr_mask(degree);
+ mask = glfsr::glfsr_mask(degree);
d_glfsr = new glfsr(mask, seed);
}
@@ -59,7 +59,7 @@ namespace gr {
delete d_glfsr;
}
- int
+ uint32_t
glfsr_source_b_impl::mask() const
{
return d_glfsr->mask();
@@ -67,19 +67,19 @@ namespace gr {
int
glfsr_source_b_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
char *out = (char*)output_items[0];
if((d_index > d_length) && d_repeat == false)
- return -1; /* once through the sequence */
+ return WORK_DONE; /* once through the sequence */
int i;
for(i = 0; i < noutput_items; i++) {
- out[i] = d_glfsr->next_bit();
- d_index++;
- if(d_index > d_length && d_repeat == false)
- break;
+ out[i] = d_glfsr->next_bit();
+ d_index++;
+ if(d_index > d_length && d_repeat == false)
+ break;
}
return i;
diff --git a/gr-digital/lib/glfsr_source_b_impl.h b/gr-digital/lib/glfsr_source_b_impl.h
index a063eb7c0a..ff2b0586c2 100644
--- a/gr-digital/lib/glfsr_source_b_impl.h
+++ b/gr-digital/lib/glfsr_source_b_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2012 Free Software Foundation, Inc.
+ * Copyright 2007,2012,2016 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -35,20 +35,20 @@ namespace gr {
glfsr *d_glfsr;
bool d_repeat;
- unsigned int d_index;
- unsigned int d_length;
+ uint32_t d_index;
+ uint32_t d_length;
public:
- glfsr_source_b_impl(int degree, bool repeat=true,
- int mask=0, int seed=1);
+ glfsr_source_b_impl(unsigned int degree, bool repeat=true,
+ uint32_t mask=0, uint32_t seed=0x1);
~glfsr_source_b_impl();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- unsigned int period() const { return d_length; }
- int mask() const;
+ uint32_t period() const { return d_length; }
+ uint32_t mask() const;
};
} /* namespace digital */
diff --git a/gr-digital/lib/glfsr_source_f_impl.cc b/gr-digital/lib/glfsr_source_f_impl.cc
index cb637df4ea..0dc24cb51a 100644
--- a/gr-digital/lib/glfsr_source_f_impl.cc
+++ b/gr-digital/lib/glfsr_source_f_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2007,2010,2012,2016 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -33,25 +33,25 @@ namespace gr {
namespace digital {
glfsr_source_f::sptr
- glfsr_source_f::make(int degree, bool repeat, int mask, int seed)
+ glfsr_source_f::make(unsigned int degree, bool repeat, uint32_t mask, uint32_t seed)
{
return gnuradio::get_initial_sptr
- (new glfsr_source_f_impl(degree, repeat, mask, seed));
+ (new glfsr_source_f_impl(degree, repeat, mask, seed));
}
- glfsr_source_f_impl::glfsr_source_f_impl(int degree, bool repeat,
- int mask, int seed)
+ glfsr_source_f_impl::glfsr_source_f_impl(unsigned int degree, bool repeat,
+ uint32_t mask, uint32_t seed)
: sync_block("glfsr_source_f",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(float))),
- d_repeat(repeat), d_index(0)
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof(float))),
+ d_repeat(repeat), d_index(0),
+ d_length( ( ((uint32_t)1) << degree) - 1)
{
if(degree < 1 || degree > 32)
- throw std::runtime_error("glfsr_source_f_impl: degree must be between 1 and 32 inclusive");
- d_length = (unsigned int)((1ULL << degree)-1);
+ throw std::runtime_error("glfsr_source_f_impl: degree must be between 1 and 32 inclusive");
if(mask == 0)
- mask = glfsr::glfsr_mask(degree);
+ mask = glfsr::glfsr_mask(degree);
d_glfsr = new glfsr(mask, seed);
}
@@ -60,7 +60,7 @@ namespace gr {
delete d_glfsr;
}
- int
+ uint32_t
glfsr_source_f_impl::mask() const
{
return d_glfsr->mask();
@@ -68,19 +68,19 @@ namespace gr {
int
glfsr_source_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
float *out = (float *) output_items[0];
if((d_index > d_length) && d_repeat == false)
- return -1; /* once through the sequence */
+ return WORK_DONE; /* once through the sequence */
int i;
for(i = 0; i < noutput_items; i++) {
- out[i] = (float)d_glfsr->next_bit()*2.0-1.0;
- d_index++;
- if(d_index > d_length && d_repeat == false)
- break;
+ out[i] = (float)d_glfsr->next_bit()*2.0-1.0;
+ d_index++;
+ if(d_index > d_length && d_repeat == false)
+ break;
}
return i;
diff --git a/gr-digital/lib/glfsr_source_f_impl.h b/gr-digital/lib/glfsr_source_f_impl.h
index 194e2ff3b9..b6ea966336 100644
--- a/gr-digital/lib/glfsr_source_f_impl.h
+++ b/gr-digital/lib/glfsr_source_f_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2012 Free Software Foundation, Inc.
+ * Copyright 2007,2012,2016 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -35,20 +35,20 @@ namespace gr {
glfsr *d_glfsr;
bool d_repeat;
- unsigned int d_index;
- unsigned int d_length;
+ uint32_t d_index;
+ uint32_t d_length;
public:
- glfsr_source_f_impl(int degree, bool repeat=true,
- int mask=0, int seed=1);
+ glfsr_source_f_impl(unsigned int degree, bool repeat=true,
+ uint32_t mask=0, uint32_t seed=0x1);
~glfsr_source_f_impl();
int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
- unsigned int period() const { return d_length; }
- int mask() const;
+ uint32_t period() const { return d_length; }
+ uint32_t mask() const;
};
} /* namespace digital */
diff --git a/gr-digital/lib/modulate_vector.cc b/gr-digital/lib/modulate_vector.cc
index 281e3435c5..c6ba0f61aa 100644
--- a/gr-digital/lib/modulate_vector.cc
+++ b/gr-digital/lib/modulate_vector.cc
@@ -23,8 +23,8 @@
/*
* Generate a modulated transmit vector corresponding to a particular
* data sequence, resampling rate, and shaping filter. The output is
-* suitable for use as a candidate filter for the correlate_and_sync
-* block, or just for prototyping.
+* suitable for use as a candidate filter for the corr_est block, or
+* just for prototyping.
*
* It accepts a sptr to a modulator block as an argument; given
* suitable data vectors and arguments you should be able to use any of