diff options
761 files changed, 17431 insertions, 49379 deletions
diff --git a/docs/doxygen/other/pfb_intro.dox b/docs/doxygen/other/pfb_intro.dox index 01d08b0fad..429e8fe5b6 100644 --- a/docs/doxygen/other/pfb_intro.dox +++ b/docs/doxygen/other/pfb_intro.dox @@ -91,6 +91,6 @@ channels. NOTE: you need the Scipy and Matplotlib Python modules installed to run this example. -\include gnuradio-core/src/examples/pfb/channelize.py +\include gr-filter/examples/channelize.py */ diff --git a/gnuradio-core/src/examples/CMakeLists.txt b/gnuradio-core/src/examples/CMakeLists.txt index c2b847c919..fc06c23476 100644 --- a/gnuradio-core/src/examples/CMakeLists.txt +++ b/gnuradio-core/src/examples/CMakeLists.txt @@ -19,6 +19,5 @@ add_subdirectory(mp-sched) add_subdirectory(network) -add_subdirectory(pfb) add_subdirectory(tags) add_subdirectory(volk_benchmark)
\ No newline at end of file diff --git a/gnuradio-core/src/examples/pfb/channelize.py b/gnuradio-core/src/examples/pfb/channelize.py deleted file mode 100755 index 442f263f47..0000000000 --- a/gnuradio-core/src/examples/pfb/channelize.py +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys, time - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab - from pylab import mlab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -class pfb_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self._N = 2000000 # number of samples to use - self._fs = 9000 # initial sampling rate - self._M = 9 # Number of channels to channelize - - # Create a set of taps for the PFB channelizer - self._taps = gr.firdes.low_pass_2(1, self._fs, 475.50, 50, - attenuation_dB=100, window=gr.firdes.WIN_BLACKMAN_hARRIS) - - # Calculate the number of taps per channel for our own information - tpc = scipy.ceil(float(len(self._taps)) / float(self._M)) - print "Number of taps: ", len(self._taps) - print "Number of channels: ", self._M - print "Taps per channel: ", tpc - - # Create a set of signals at different frequencies - # freqs lists the frequencies of the signals that get stored - # in the list "signals", which then get summed together - self.signals = list() - self.add = gr.add_cc() - freqs = [-4070, -3050, -2030, -1010, 10, 1020, 2040, 3060, 4080] - for i in xrange(len(freqs)): - self.signals.append(gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freqs[i], 1)) - self.connect(self.signals[i], (self.add,i)) - - self.head = gr.head(gr.sizeof_gr_complex, self._N) - - # Construct the channelizer filter - self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps, 1) - - # Construct a vector sink for the input signal to the channelizer - self.snk_i = gr.vector_sink_c() - - # Connect the blocks - self.connect(self.add, self.head, self.pfb) - self.connect(self.add, self.snk_i) - - # Use this to play with the channel mapping - #self.pfb.set_channel_map([5,6,7,8,0,1,2,3,4]) - - # Create a vector sink for each of M output channels of the filter and connect it - self.snks = list() - for i in xrange(self._M): - self.snks.append(gr.vector_sink_c()) - self.connect((self.pfb, i), self.snks[i]) - - -def main(): - tstart = time.time() - - tb = pfb_top_block() - tb.run() - - tend = time.time() - print "Run time: %f" % (tend - tstart) - - if 1: - fig_in = pylab.figure(1, figsize=(16,9), facecolor="w") - fig1 = pylab.figure(2, figsize=(16,9), facecolor="w") - fig2 = pylab.figure(3, figsize=(16,9), facecolor="w") - - Ns = 1000 - Ne = 10000 - - fftlen = 8192 - winfunc = scipy.blackman - fs = tb._fs - - # Plot the input signal on its own figure - d = tb.snk_i.data()[Ns:Ne] - spin_f = fig_in.add_subplot(2, 1, 1) - - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*scipy.log10(abs(X)) - f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) - pin_f = spin_f.plot(f_in, X_in, "b") - spin_f.set_xlim([min(f_in), max(f_in)+1]) - spin_f.set_ylim([-200.0, 50.0]) - - spin_f.set_title("Input Signal", weight="bold") - spin_f.set_xlabel("Frequency (Hz)") - spin_f.set_ylabel("Power (dBW)") - - - Ts = 1.0/fs - Tmax = len(d)*Ts - - t_in = scipy.arange(0, Tmax, Ts) - x_in = scipy.array(d) - spin_t = fig_in.add_subplot(2, 1, 2) - pin_t = spin_t.plot(t_in, x_in.real, "b") - pin_t = spin_t.plot(t_in, x_in.imag, "r") - - spin_t.set_xlabel("Time (s)") - spin_t.set_ylabel("Amplitude") - - Ncols = int(scipy.floor(scipy.sqrt(tb._M))) - Nrows = int(scipy.floor(tb._M / Ncols)) - if(tb._M % Ncols != 0): - Nrows += 1 - - # Plot each of the channels outputs. Frequencies on Figure 2 and - # time signals on Figure 3 - fs_o = tb._fs / tb._M - Ts_o = 1.0/fs_o - Tmax_o = len(d)*Ts_o - for i in xrange(len(tb.snks)): - # remove issues with the transients at the beginning - # also remove some corruption at the end of the stream - # this is a bug, probably due to the corner cases - d = tb.snks[i].data()[Ns:Ne] - - sp1_f = fig1.add_subplot(Nrows, Ncols, 1+i) - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(X)) - f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size)) - p2_f = sp1_f.plot(f_o, X_o, "b") - sp1_f.set_xlim([min(f_o), max(f_o)+1]) - sp1_f.set_ylim([-200.0, 50.0]) - - sp1_f.set_title(("Channel %d" % i), weight="bold") - sp1_f.set_xlabel("Frequency (Hz)") - sp1_f.set_ylabel("Power (dBW)") - - x_o = scipy.array(d) - t_o = scipy.arange(0, Tmax_o, Ts_o) - sp2_o = fig2.add_subplot(Nrows, Ncols, 1+i) - p2_o = sp2_o.plot(t_o, x_o.real, "b") - p2_o = sp2_o.plot(t_o, x_o.imag, "r") - sp2_o.set_xlim([min(t_o), max(t_o)+1]) - sp2_o.set_ylim([-2, 2]) - - sp2_o.set_title(("Channel %d" % i), weight="bold") - sp2_o.set_xlabel("Time (s)") - sp2_o.set_ylabel("Amplitude") - - pylab.show() - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-core/src/examples/pfb/chirp_channelize.py b/gnuradio-core/src/examples/pfb/chirp_channelize.py deleted file mode 100755 index 1c485ea9dd..0000000000 --- a/gnuradio-core/src/examples/pfb/chirp_channelize.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys, time - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab - from pylab import mlab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -class pfb_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self._N = 200000 # number of samples to use - self._fs = 9000 # initial sampling rate - self._M = 9 # Number of channels to channelize - - # Create a set of taps for the PFB channelizer - self._taps = gr.firdes.low_pass_2(1, self._fs, 500, 20, - attenuation_dB=10, window=gr.firdes.WIN_BLACKMAN_hARRIS) - - # Calculate the number of taps per channel for our own information - tpc = scipy.ceil(float(len(self._taps)) / float(self._M)) - print "Number of taps: ", len(self._taps) - print "Number of channels: ", self._M - print "Taps per channel: ", tpc - - repeated = True - if(repeated): - self.vco_input = gr.sig_source_f(self._fs, gr.GR_SIN_WAVE, 0.25, 110) - else: - amp = 100 - data = scipy.arange(0, amp, amp/float(self._N)) - self.vco_input = gr.vector_source_f(data, False) - - # Build a VCO controlled by either the sinusoid or single chirp tone - # Then convert this to a complex signal - self.vco = gr.vco_f(self._fs, 225, 1) - self.f2c = gr.float_to_complex() - - self.head = gr.head(gr.sizeof_gr_complex, self._N) - - # Construct the channelizer filter - self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps) - - # Construct a vector sink for the input signal to the channelizer - self.snk_i = gr.vector_sink_c() - - # Connect the blocks - self.connect(self.vco_input, self.vco, self.f2c) - self.connect(self.f2c, self.head, self.pfb) - self.connect(self.f2c, self.snk_i) - - # Create a vector sink for each of M output channels of the filter and connect it - self.snks = list() - for i in xrange(self._M): - self.snks.append(gr.vector_sink_c()) - self.connect((self.pfb, i), self.snks[i]) - - -def main(): - tstart = time.time() - - tb = pfb_top_block() - tb.run() - - tend = time.time() - print "Run time: %f" % (tend - tstart) - - if 1: - fig_in = pylab.figure(1, figsize=(16,9), facecolor="w") - fig1 = pylab.figure(2, figsize=(16,9), facecolor="w") - fig2 = pylab.figure(3, figsize=(16,9), facecolor="w") - fig3 = pylab.figure(4, figsize=(16,9), facecolor="w") - - Ns = 650 - Ne = 20000 - - fftlen = 8192 - winfunc = scipy.blackman - fs = tb._fs - - # Plot the input signal on its own figure - d = tb.snk_i.data()[Ns:Ne] - spin_f = fig_in.add_subplot(2, 1, 1) - - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) - pin_f = spin_f.plot(f_in, X_in, "b") - spin_f.set_xlim([min(f_in), max(f_in)+1]) - spin_f.set_ylim([-200.0, 50.0]) - - spin_f.set_title("Input Signal", weight="bold") - spin_f.set_xlabel("Frequency (Hz)") - spin_f.set_ylabel("Power (dBW)") - - - Ts = 1.0/fs - Tmax = len(d)*Ts - - t_in = scipy.arange(0, Tmax, Ts) - x_in = scipy.array(d) - spin_t = fig_in.add_subplot(2, 1, 2) - pin_t = spin_t.plot(t_in, x_in.real, "b") - pin_t = spin_t.plot(t_in, x_in.imag, "r") - - spin_t.set_xlabel("Time (s)") - spin_t.set_ylabel("Amplitude") - - Ncols = int(scipy.floor(scipy.sqrt(tb._M))) - Nrows = int(scipy.floor(tb._M / Ncols)) - if(tb._M % Ncols != 0): - Nrows += 1 - - # Plot each of the channels outputs. Frequencies on Figure 2 and - # time signals on Figure 3 - fs_o = tb._fs / tb._M - Ts_o = 1.0/fs_o - Tmax_o = len(d)*Ts_o - for i in xrange(len(tb.snks)): - # remove issues with the transients at the beginning - # also remove some corruption at the end of the stream - # this is a bug, probably due to the corner cases - d = tb.snks[i].data()[Ns:Ne] - - sp1_f = fig1.add_subplot(Nrows, Ncols, 1+i) - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(X)) - f_o = freq - p2_f = sp1_f.plot(f_o, X_o, "b") - sp1_f.set_xlim([min(f_o), max(f_o)+1]) - sp1_f.set_ylim([-200.0, 50.0]) - - sp1_f.set_title(("Channel %d" % i), weight="bold") - sp1_f.set_xlabel("Frequency (Hz)") - sp1_f.set_ylabel("Power (dBW)") - - x_o = scipy.array(d) - t_o = scipy.arange(0, Tmax_o, Ts_o) - sp2_o = fig2.add_subplot(Nrows, Ncols, 1+i) - p2_o = sp2_o.plot(t_o, x_o.real, "b") - p2_o = sp2_o.plot(t_o, x_o.imag, "r") - sp2_o.set_xlim([min(t_o), max(t_o)+1]) - sp2_o.set_ylim([-2, 2]) - - sp2_o.set_title(("Channel %d" % i), weight="bold") - sp2_o.set_xlabel("Time (s)") - sp2_o.set_ylabel("Amplitude") - - - sp3 = fig3.add_subplot(1,1,1) - p3 = sp3.plot(t_o, x_o.real) - sp3.set_xlim([min(t_o), max(t_o)+1]) - sp3.set_ylim([-2, 2]) - - sp3.set_title("All Channels") - sp3.set_xlabel("Time (s)") - sp3.set_ylabel("Amplitude") - - pylab.show() - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-core/src/examples/pfb/decimate.py b/gnuradio-core/src/examples/pfb/decimate.py deleted file mode 100755 index 5322d746db..0000000000 --- a/gnuradio-core/src/examples/pfb/decimate.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys, time - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab - from pylab import mlab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -class pfb_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self._N = 10000000 # number of samples to use - self._fs = 10000 # initial sampling rate - self._decim = 20 # Decimation rate - - # Generate the prototype filter taps for the decimators with a 200 Hz bandwidth - self._taps = gr.firdes.low_pass_2(1, self._fs, 200, 150, - attenuation_dB=120, window=gr.firdes.WIN_BLACKMAN_hARRIS) - - # Calculate the number of taps per channel for our own information - tpc = scipy.ceil(float(len(self._taps)) / float(self._decim)) - print "Number of taps: ", len(self._taps) - print "Number of filters: ", self._decim - print "Taps per channel: ", tpc - - # Build the input signal source - # We create a list of freqs, and a sine wave is generated and added to the source - # for each one of these frequencies. - self.signals = list() - self.add = gr.add_cc() - freqs = [10, 20, 2040] - for i in xrange(len(freqs)): - self.signals.append(gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freqs[i], 1)) - self.connect(self.signals[i], (self.add,i)) - - self.head = gr.head(gr.sizeof_gr_complex, self._N) - - # Construct a PFB decimator filter - self.pfb = blks2.pfb_decimator_ccf(self._decim, self._taps, 0) - - # Construct a standard FIR decimating filter - self.dec = gr.fir_filter_ccf(self._decim, self._taps) - - self.snk_i = gr.vector_sink_c() - - # Connect the blocks - self.connect(self.add, self.head, self.pfb) - self.connect(self.add, self.snk_i) - - # Create the sink for the decimated siganl - self.snk = gr.vector_sink_c() - self.connect(self.pfb, self.snk) - - -def main(): - tb = pfb_top_block() - - tstart = time.time() - tb.run() - tend = time.time() - print "Run time: %f" % (tend - tstart) - - if 1: - fig1 = pylab.figure(1, figsize=(16,9)) - fig2 = pylab.figure(2, figsize=(16,9)) - - Ns = 10000 - Ne = 10000 - - fftlen = 8192 - winfunc = scipy.blackman - fs = tb._fs - - # Plot the input to the decimator - - d = tb.snk_i.data()[Ns:Ns+Ne] - sp1_f = fig1.add_subplot(2, 1, 1) - - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) - p1_f = sp1_f.plot(f_in, X_in, "b") - sp1_f.set_xlim([min(f_in), max(f_in)+1]) - sp1_f.set_ylim([-200.0, 50.0]) - - sp1_f.set_title("Input Signal", weight="bold") - sp1_f.set_xlabel("Frequency (Hz)") - sp1_f.set_ylabel("Power (dBW)") - - Ts = 1.0/fs - Tmax = len(d)*Ts - - t_in = scipy.arange(0, Tmax, Ts) - x_in = scipy.array(d) - sp1_t = fig1.add_subplot(2, 1, 2) - p1_t = sp1_t.plot(t_in, x_in.real, "b") - p1_t = sp1_t.plot(t_in, x_in.imag, "r") - sp1_t.set_ylim([-tb._decim*1.1, tb._decim*1.1]) - - sp1_t.set_xlabel("Time (s)") - sp1_t.set_ylabel("Amplitude") - - - # Plot the output of the decimator - fs_o = tb._fs / tb._decim - - sp2_f = fig2.add_subplot(2, 1, 1) - d = tb.snk.data()[Ns:Ns+Ne] - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size)) - p2_f = sp2_f.plot(f_o, X_o, "b") - sp2_f.set_xlim([min(f_o), max(f_o)+1]) - sp2_f.set_ylim([-200.0, 50.0]) - - sp2_f.set_title("PFB Decimated Signal", weight="bold") - sp2_f.set_xlabel("Frequency (Hz)") - sp2_f.set_ylabel("Power (dBW)") - - - Ts_o = 1.0/fs_o - Tmax_o = len(d)*Ts_o - - x_o = scipy.array(d) - t_o = scipy.arange(0, Tmax_o, Ts_o) - sp2_t = fig2.add_subplot(2, 1, 2) - p2_t = sp2_t.plot(t_o, x_o.real, "b-o") - p2_t = sp2_t.plot(t_o, x_o.imag, "r-o") - sp2_t.set_ylim([-2.5, 2.5]) - - sp2_t.set_xlabel("Time (s)") - sp2_t.set_ylabel("Amplitude") - - pylab.show() - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-core/src/examples/pfb/fmtest.py b/gnuradio-core/src/examples/pfb/fmtest.py deleted file mode 100755 index b9dd9b3823..0000000000 --- a/gnuradio-core/src/examples/pfb/fmtest.py +++ /dev/null @@ -1,225 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys, math, time - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - - -class fmtx(gr.hier_block2): - def __init__(self, lo_freq, audio_rate, if_rate): - - gr.hier_block2.__init__(self, "build_fm", - gr.io_signature(1, 1, gr.sizeof_float), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6) - - # Local oscillator - lo = gr.sig_source_c (if_rate, # sample rate - gr.GR_SIN_WAVE, # waveform type - lo_freq, #frequency - 1.0, # amplitude - 0) # DC Offset - mixer = gr.multiply_cc () - - self.connect (self, fmtx, (mixer, 0)) - self.connect (lo, (mixer, 1)) - self.connect (mixer, self) - -class fmtest(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self._nsamples = 1000000 - self._audio_rate = 8000 - - # Set up N channels with their own baseband and IF frequencies - self._N = 5 - chspacing = 16000 - freq = [10, 20, 30, 40, 50] - f_lo = [0, 1*chspacing, -1*chspacing, 2*chspacing, -2*chspacing] - - self._if_rate = 4*self._N*self._audio_rate - - # Create a signal source and frequency modulate it - self.sum = gr.add_cc () - for n in xrange(self._N): - sig = gr.sig_source_f(self._audio_rate, gr.GR_SIN_WAVE, freq[n], 0.5) - fm = fmtx(f_lo[n], self._audio_rate, self._if_rate) - self.connect(sig, fm) - self.connect(fm, (self.sum, n)) - - self.head = gr.head(gr.sizeof_gr_complex, self._nsamples) - self.snk_tx = gr.vector_sink_c() - self.channel = blks2.channel_model(0.1) - - self.connect(self.sum, self.head, self.channel, self.snk_tx) - - - # Design the channlizer - self._M = 10 - bw = chspacing/2.0 - t_bw = chspacing/10.0 - self._chan_rate = self._if_rate / self._M - self._taps = gr.firdes.low_pass_2(1, self._if_rate, bw, t_bw, - attenuation_dB=100, - window=gr.firdes.WIN_BLACKMAN_hARRIS) - tpc = math.ceil(float(len(self._taps)) / float(self._M)) - - print "Number of taps: ", len(self._taps) - print "Number of channels: ", self._M - print "Taps per channel: ", tpc - - self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps) - - self.connect(self.channel, self.pfb) - - # Create a file sink for each of M output channels of the filter and connect it - self.fmdet = list() - self.squelch = list() - self.snks = list() - for i in xrange(self._M): - self.fmdet.append(blks2.nbfm_rx(self._audio_rate, self._chan_rate)) - self.squelch.append(blks2.standard_squelch(self._audio_rate*10)) - self.snks.append(gr.vector_sink_f()) - self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i]) - - def num_tx_channels(self): - return self._N - - def num_rx_channels(self): - return self._M - -def main(): - - fm = fmtest() - - tstart = time.time() - fm.run() - tend = time.time() - - if 1: - fig1 = pylab.figure(1, figsize=(12,10), facecolor="w") - fig2 = pylab.figure(2, figsize=(12,10), facecolor="w") - fig3 = pylab.figure(3, figsize=(12,10), facecolor="w") - - Ns = 10000 - Ne = 100000 - - fftlen = 8192 - winfunc = scipy.blackman - - # Plot transmitted signal - fs = fm._if_rate - - d = fm.snk_tx.data()[Ns:Ns+Ne] - sp1_f = fig1.add_subplot(2, 1, 1) - - X,freq = sp1_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - visible=False) - X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) - p1_f = sp1_f.plot(f_in, X_in, "b") - sp1_f.set_xlim([min(f_in), max(f_in)+1]) - sp1_f.set_ylim([-120.0, 20.0]) - - sp1_f.set_title("Input Signal", weight="bold") - sp1_f.set_xlabel("Frequency (Hz)") - sp1_f.set_ylabel("Power (dBW)") - - Ts = 1.0/fs - Tmax = len(d)*Ts - - t_in = scipy.arange(0, Tmax, Ts) - x_in = scipy.array(d) - sp1_t = fig1.add_subplot(2, 1, 2) - p1_t = sp1_t.plot(t_in, x_in.real, "b-o") - #p1_t = sp1_t.plot(t_in, x_in.imag, "r-o") - sp1_t.set_ylim([-5, 5]) - - # Set up the number of rows and columns for plotting the subfigures - Ncols = int(scipy.floor(scipy.sqrt(fm.num_rx_channels()))) - Nrows = int(scipy.floor(fm.num_rx_channels() / Ncols)) - if(fm.num_rx_channels() % Ncols != 0): - Nrows += 1 - - # Plot each of the channels outputs. Frequencies on Figure 2 and - # time signals on Figure 3 - fs_o = fm._audio_rate - for i in xrange(len(fm.snks)): - # remove issues with the transients at the beginning - # also remove some corruption at the end of the stream - # this is a bug, probably due to the corner cases - d = fm.snks[i].data()[Ns:Ne] - - sp2_f = fig2.add_subplot(Nrows, Ncols, 1+i) - X,freq = sp2_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, - window = lambda d: d*winfunc(fftlen), - visible=False) - #X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - X_o = 10.0*scipy.log10(abs(X)) - #f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size)) - f_o = scipy.arange(0, fs_o/2.0, fs_o/2.0/float(X_o.size)) - p2_f = sp2_f.plot(f_o, X_o, "b") - sp2_f.set_xlim([min(f_o), max(f_o)+0.1]) - sp2_f.set_ylim([-120.0, 20.0]) - sp2_f.grid(True) - - sp2_f.set_title(("Channel %d" % i), weight="bold") - sp2_f.set_xlabel("Frequency (kHz)") - sp2_f.set_ylabel("Power (dBW)") - - - Ts = 1.0/fs_o - Tmax = len(d)*Ts - t_o = scipy.arange(0, Tmax, Ts) - - x_t = scipy.array(d) - sp2_t = fig3.add_subplot(Nrows, Ncols, 1+i) - p2_t = sp2_t.plot(t_o, x_t.real, "b") - p2_t = sp2_t.plot(t_o, x_t.imag, "r") - sp2_t.set_xlim([min(t_o), max(t_o)+1]) - sp2_t.set_ylim([-1, 1]) - - sp2_t.set_xlabel("Time (s)") - sp2_t.set_ylabel("Amplitude") - - - pylab.show() - - -if __name__ == "__main__": - main() diff --git a/gnuradio-core/src/examples/pfb/interpolate.py b/gnuradio-core/src/examples/pfb/interpolate.py deleted file mode 100755 index 98068f220b..0000000000 --- a/gnuradio-core/src/examples/pfb/interpolate.py +++ /dev/null @@ -1,233 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys, time - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab - from pylab import mlab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -class pfb_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - self._N = 100000 # number of samples to use - self._fs = 2000 # initial sampling rate - self._interp = 5 # Interpolation rate for PFB interpolator - self._ainterp = 5.5 # Resampling rate for the PFB arbitrary resampler - - # Frequencies of the signals we construct - freq1 = 100 - freq2 = 200 - - # Create a set of taps for the PFB interpolator - # This is based on the post-interpolation sample rate - self._taps = gr.firdes.low_pass_2(self._interp, self._interp*self._fs, freq2+50, 50, - attenuation_dB=120, window=gr.firdes.WIN_BLACKMAN_hARRIS) - - # Create a set of taps for the PFB arbitrary resampler - # The filter size is the number of filters in the filterbank; 32 will give very low side-lobes, - # and larger numbers will reduce these even farther - # The taps in this filter are based on a sampling rate of the filter size since it acts - # internally as an interpolator. - flt_size = 32 - self._taps2 = gr.firdes.low_pass_2(flt_size, flt_size*self._fs, freq2+50, 150, - attenuation_dB=120, window=gr.firdes.WIN_BLACKMAN_hARRIS) - - # Calculate the number of taps per channel for our own information - tpc = scipy.ceil(float(len(self._taps)) / float(self._interp)) - print "Number of taps: ", len(self._taps) - print "Number of filters: ", self._interp - print "Taps per channel: ", tpc - - # Create a couple of signals at different frequencies - self.signal1 = gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freq1, 0.5) - self.signal2 = gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freq2, 0.5) - self.signal = gr.add_cc() - - self.head = gr.head(gr.sizeof_gr_complex, self._N) - - # Construct the PFB interpolator filter - self.pfb = blks2.pfb_interpolator_ccf(self._interp, self._taps) - - # Construct the PFB arbitrary resampler filter - self.pfb_ar = blks2.pfb_arb_resampler_ccf(self._ainterp, self._taps2, flt_size) - self.snk_i = gr.vector_sink_c() - - #self.pfb_ar.pfb.print_taps() - #self.pfb.pfb.print_taps() - - # Connect the blocks - self.connect(self.signal1, self.head, (self.signal,0)) - self.connect(self.signal2, (self.signal,1)) - self.connect(self.signal, self.pfb) - self.connect(self.signal, self.pfb_ar) - self.connect(self.signal, self.snk_i) - - # Create the sink for the interpolated signals - self.snk1 = gr.vector_sink_c() - self.snk2 = gr.vector_sink_c() - self.connect(self.pfb, self.snk1) - self.connect(self.pfb_ar, self.snk2) - - -def main(): - tb = pfb_top_block() - - tstart = time.time() - tb.run() - tend = time.time() - print "Run time: %f" % (tend - tstart) - - - if 1: - fig1 = pylab.figure(1, figsize=(12,10), facecolor="w") - fig2 = pylab.figure(2, figsize=(12,10), facecolor="w") - fig3 = pylab.figure(3, figsize=(12,10), facecolor="w") - - Ns = 10000 - Ne = 10000 - - fftlen = 8192 - winfunc = scipy.blackman - - # Plot input signal - fs = tb._fs - - d = tb.snk_i.data()[Ns:Ns+Ne] - sp1_f = fig1.add_subplot(2, 1, 1) - - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) - p1_f = sp1_f.plot(f_in, X_in, "b") - sp1_f.set_xlim([min(f_in), max(f_in)+1]) - sp1_f.set_ylim([-200.0, 50.0]) - - - sp1_f.set_title("Input Signal", weight="bold") - sp1_f.set_xlabel("Frequency (Hz)") - sp1_f.set_ylabel("Power (dBW)") - - Ts = 1.0/fs - Tmax = len(d)*Ts - - t_in = scipy.arange(0, Tmax, Ts) - x_in = scipy.array(d) - sp1_t = fig1.add_subplot(2, 1, 2) - p1_t = sp1_t.plot(t_in, x_in.real, "b-o") - #p1_t = sp1_t.plot(t_in, x_in.imag, "r-o") - sp1_t.set_ylim([-2.5, 2.5]) - - sp1_t.set_title("Input Signal", weight="bold") - sp1_t.set_xlabel("Time (s)") - sp1_t.set_ylabel("Amplitude") - - - # Plot output of PFB interpolator - fs_int = tb._fs*tb._interp - - sp2_f = fig2.add_subplot(2, 1, 1) - d = tb.snk1.data()[Ns:Ns+(tb._interp*Ne)] - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_o = scipy.arange(-fs_int/2.0, fs_int/2.0, fs_int/float(X_o.size)) - p2_f = sp2_f.plot(f_o, X_o, "b") - sp2_f.set_xlim([min(f_o), max(f_o)+1]) - sp2_f.set_ylim([-200.0, 50.0]) - - sp2_f.set_title("Output Signal from PFB Interpolator", weight="bold") - sp2_f.set_xlabel("Frequency (Hz)") - sp2_f.set_ylabel("Power (dBW)") - - Ts_int = 1.0/fs_int - Tmax = len(d)*Ts_int - - t_o = scipy.arange(0, Tmax, Ts_int) - x_o1 = scipy.array(d) - sp2_t = fig2.add_subplot(2, 1, 2) - p2_t = sp2_t.plot(t_o, x_o1.real, "b-o") - #p2_t = sp2_t.plot(t_o, x_o.imag, "r-o") - sp2_t.set_ylim([-2.5, 2.5]) - - sp2_t.set_title("Output Signal from PFB Interpolator", weight="bold") - sp2_t.set_xlabel("Time (s)") - sp2_t.set_ylabel("Amplitude") - - - # Plot output of PFB arbitrary resampler - fs_aint = tb._fs * tb._ainterp - - sp3_f = fig3.add_subplot(2, 1, 1) - d = tb.snk2.data()[Ns:Ns+(tb._interp*Ne)] - X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) - f_o = scipy.arange(-fs_aint/2.0, fs_aint/2.0, fs_aint/float(X_o.size)) - p3_f = sp3_f.plot(f_o, X_o, "b") - sp3_f.set_xlim([min(f_o), max(f_o)+1]) - sp3_f.set_ylim([-200.0, 50.0]) - - sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", weight="bold") - sp3_f.set_xlabel("Frequency (Hz)") - sp3_f.set_ylabel("Power (dBW)") - - Ts_aint = 1.0/fs_aint - Tmax = len(d)*Ts_aint - - t_o = scipy.arange(0, Tmax, Ts_aint) - x_o2 = scipy.array(d) - sp3_f = fig3.add_subplot(2, 1, 2) - p3_f = sp3_f.plot(t_o, x_o2.real, "b-o") - p3_f = sp3_f.plot(t_o, x_o1.real, "m-o") - #p3_f = sp3_f.plot(t_o, x_o2.imag, "r-o") - sp3_f.set_ylim([-2.5, 2.5]) - - sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", weight="bold") - sp3_f.set_xlabel("Time (s)") - sp3_f.set_ylabel("Amplitude") - - pylab.show() - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-core/src/examples/pfb/reconstruction.py b/gnuradio-core/src/examples/pfb/reconstruction.py deleted file mode 100755 index 59910e4d6d..0000000000 --- a/gnuradio-core/src/examples/pfb/reconstruction.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python - -import scipy, math, pylab -from scipy import fftpack -from gnuradio import gr, digital, blks2 - -fftlen = 8192 - -def main(): - N = 10000 - fs = 2000.0 - Ts = 1.0/fs - t = scipy.arange(0, N*Ts, Ts) - - # When playing with the number of channels, be careful about the filter - # specs and the channel map of the synthesizer set below. - nchans = 10 - - # Build the filter(s) - bw = 1000 - tb = 400 - proto_taps = gr.firdes.low_pass_2(1, nchans*fs, bw, tb, 80, - gr.firdes.WIN_BLACKMAN_hARRIS) - print "Filter length: ", len(proto_taps) - - - # Create a modulated signal - npwr = 0.01 - data = scipy.random.randint(0, 256, N) - rrc_taps = gr.firdes.root_raised_cosine(1, 2, 1, 0.35, 41) - - src = gr.vector_source_b(data.astype(scipy.uint8).tolist(), False) - mod = digital.bpsk_mod(samples_per_symbol=2) - chan = gr.channel_model(npwr) - rrc = gr.fft_filter_ccc(1, rrc_taps) - - # Split it up into pieces - channelizer = blks2.pfb_channelizer_ccf(nchans, proto_taps, 2) - - # Put the pieces back together again - syn_taps = [nchans*t for t in proto_taps] - synthesizer = gr.pfb_synthesizer_ccf(nchans, syn_taps, True) - src_snk = gr.vector_sink_c() - snk = gr.vector_sink_c() - - # Remap the location of the channels - # Can be done in synth or channelizer (watch out for rotattions in - # the channelizer) - synthesizer.set_channel_map([ 0, 1, 2, 3, 4, - 15, 16, 17, 18, 19]) - - tb = gr.top_block() - tb.connect(src, mod, chan, rrc, channelizer) - tb.connect(rrc, src_snk) - - vsnk = [] - for i in xrange(nchans): - tb.connect((channelizer,i), (synthesizer, i)) - - vsnk.append(gr.vector_sink_c()) - tb.connect((channelizer,i), vsnk[i]) - - tb.connect(synthesizer, snk) - tb.run() - - sin = scipy.array(src_snk.data()[1000:]) - sout = scipy.array(snk.data()[1000:]) - - - # Plot original signal - fs_in = nchans*fs - f1 = pylab.figure(1, figsize=(16,12), facecolor='w') - s11 = f1.add_subplot(2,2,1) - s11.psd(sin, NFFT=fftlen, Fs=fs_in) - s11.set_title("PSD of Original Signal") - s11.set_ylim([-200, -20]) - - s12 = f1.add_subplot(2,2,2) - s12.plot(sin.real[1000:1500], "o-b") - s12.plot(sin.imag[1000:1500], "o-r") - s12.set_title("Original Signal in Time") - - start = 1 - skip = 4 - s13 = f1.add_subplot(2,2,3) - s13.plot(sin.real[start::skip], sin.imag[start::skip], "o") - s13.set_title("Constellation") - s13.set_xlim([-2, 2]) - s13.set_ylim([-2, 2]) - - # Plot channels - nrows = int(scipy.sqrt(nchans)) - ncols = int(scipy.ceil(float(nchans)/float(nrows))) - - f2 = pylab.figure(2, figsize=(16,12), facecolor='w') - for n in xrange(nchans): - s = f2.add_subplot(nrows, ncols, n+1) - s.psd(vsnk[n].data(), NFFT=fftlen, Fs=fs_in) - s.set_title("Channel {0}".format(n)) - s.set_ylim([-200, -20]) - - # Plot reconstructed signal - fs_out = 2*nchans*fs - f3 = pylab.figure(3, figsize=(16,12), facecolor='w') - s31 = f3.add_subplot(2,2,1) - s31.psd(sout, NFFT=fftlen, Fs=fs_out) - s31.set_title("PSD of Reconstructed Signal") - s31.set_ylim([-200, -20]) - - s32 = f3.add_subplot(2,2,2) - s32.plot(sout.real[1000:1500], "o-b") - s32.plot(sout.imag[1000:1500], "o-r") - s32.set_title("Reconstructed Signal in Time") - - start = 2 - skip = 4 - s33 = f3.add_subplot(2,2,3) - s33.plot(sout.real[start::skip], sout.imag[start::skip], "o") - s33.set_title("Constellation") - s33.set_xlim([-2, 2]) - s33.set_ylim([-2, 2]) - - pylab.show() - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-core/src/examples/pfb/resampler.py b/gnuradio-core/src/examples/pfb/resampler.py deleted file mode 100755 index 555938d281..0000000000 --- a/gnuradio-core/src/examples/pfb/resampler.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, blks2 -import sys - -try: - import scipy -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -class mytb(gr.top_block): - def __init__(self, fs_in, fs_out, fc, N=10000): - gr.top_block.__init__(self) - - rerate = float(fs_out) / float(fs_in) - print "Resampling from %f to %f by %f " %(fs_in, fs_out, rerate) - - # Creating our own taps - taps = gr.firdes.low_pass_2(32, 32, 0.25, 0.1, 80) - - self.src = gr.sig_source_c(fs_in, gr.GR_SIN_WAVE, fc, 1) - #self.src = gr.noise_source_c(gr.GR_GAUSSIAN, 1) - self.head = gr.head(gr.sizeof_gr_complex, N) - - # A resampler with our taps - self.resamp_0 = blks2.pfb_arb_resampler_ccf(rerate, taps, - flt_size=32) - - # A resampler that just needs a resampling rate. - # Filter is created for us and designed to cover - # entire bandwidth of the input signal. - # An optional atten=XX rate can be used here to - # specify the out-of-band rejection (default=80). - self.resamp_1 = blks2.pfb_arb_resampler_ccf(rerate) - - self.snk_in = gr.vector_sink_c() - self.snk_0 = gr.vector_sink_c() - self.snk_1 = gr.vector_sink_c() - - self.connect(self.src, self.head, self.snk_in) - self.connect(self.head, self.resamp_0, self.snk_0) - self.connect(self.head, self.resamp_1, self.snk_1) - -def main(): - fs_in = 8000 - fs_out = 20000 - fc = 1000 - N = 10000 - - tb = mytb(fs_in, fs_out, fc, N) - tb.run() - - - # Plot PSD of signals - nfftsize = 2048 - fig1 = pylab.figure(1, figsize=(10,10), facecolor="w") - sp1 = fig1.add_subplot(2,1,1) - sp1.psd(tb.snk_in.data(), NFFT=nfftsize, - noverlap=nfftsize/4, Fs = fs_in) - sp1.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0))) - sp1.set_xlim([-fs_in/2, fs_in/2]) - - sp2 = fig1.add_subplot(2,1,2) - sp2.psd(tb.snk_0.data(), NFFT=nfftsize, - noverlap=nfftsize/4, Fs = fs_out, - label="With our filter") - sp2.psd(tb.snk_1.data(), NFFT=nfftsize, - noverlap=nfftsize/4, Fs = fs_out, - label="With auto-generated filter") - sp2.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0))) - sp2.set_xlim([-fs_out/2, fs_out/2]) - sp2.legend() - - # Plot signals in time - Ts_in = 1.0/fs_in - Ts_out = 1.0/fs_out - t_in = scipy.arange(0, len(tb.snk_in.data())*Ts_in, Ts_in) - t_out = scipy.arange(0, len(tb.snk_0.data())*Ts_out, Ts_out) - - fig2 = pylab.figure(2, figsize=(10,10), facecolor="w") - sp21 = fig2.add_subplot(2,1,1) - sp21.plot(t_in, tb.snk_in.data()) - sp21.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0))) - sp21.set_xlim([t_in[100], t_in[200]]) - - sp22 = fig2.add_subplot(2,1,2) - sp22.plot(t_out, tb.snk_0.data(), - label="With our filter") - sp22.plot(t_out, tb.snk_1.data(), - label="With auto-generated filter") - sp22.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0))) - r = float(fs_out)/float(fs_in) - sp22.set_xlim([t_out[r * 100], t_out[r * 200]]) - sp22.legend() - - pylab.show() - -if __name__ == "__main__": - main() - diff --git a/gnuradio-core/src/examples/pfb/synth_filter.py b/gnuradio-core/src/examples/pfb/synth_filter.py deleted file mode 100755 index c0f7376ec0..0000000000 --- a/gnuradio-core/src/examples/pfb/synth_filter.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2010 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. -# - -from gnuradio import gr, blks2 -import sys - -try: - import scipy -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -def main(): - N = 1000000 - fs = 8000 - - freqs = [100, 200, 300, 400, 500] - nchans = 7 - - sigs = list() - for fi in freqs: - s = gr.sig_source_c(fs, gr.GR_SIN_WAVE, fi, 1) - sigs.append(s) - - taps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) - print "Num. Taps = %d (taps per filter = %d)" % (len(taps), - len(taps)/nchans) - filtbank = gr.pfb_synthesizer_ccf(nchans, taps) - - head = gr.head(gr.sizeof_gr_complex, N) - snk = gr.vector_sink_c() - - tb = gr.top_block() - tb.connect(filtbank, head, snk) - - for i,si in enumerate(sigs): - tb.connect(si, (filtbank, i)) - - tb.run() - - if 1: - f1 = pylab.figure(1) - s1 = f1.add_subplot(1,1,1) - s1.plot(snk.data()[1000:]) - - fftlen = 2048 - f2 = pylab.figure(2) - s2 = f2.add_subplot(1,1,1) - winfunc = scipy.blackman - s2.psd(snk.data()[10000:], NFFT=fftlen, - Fs = nchans*fs, - noverlap=fftlen/4, - window = lambda d: d*winfunc(fftlen)) - - pylab.show() - -if __name__ == "__main__": - main() diff --git a/gnuradio-core/src/examples/pfb/synth_to_chan.py b/gnuradio-core/src/examples/pfb/synth_to_chan.py deleted file mode 100755 index 18b2e7b53f..0000000000 --- a/gnuradio-core/src/examples/pfb/synth_to_chan.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2010 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. -# - -from gnuradio import gr, blks2 -import sys - -try: - import scipy -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - import pylab -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -def main(): - N = 1000000 - fs = 8000 - - freqs = [100, 200, 300, 400, 500] - nchans = 7 - - sigs = list() - fmtx = list() - for fi in freqs: - s = gr.sig_source_f(fs, gr.GR_SIN_WAVE, fi, 1) - fm = blks2.nbfm_tx (fs, 4*fs, max_dev=10000, tau=75e-6) - sigs.append(s) - fmtx.append(fm) - - syntaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) - print "Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps), - len(syntaps)/nchans) - chtaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) - print "Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps), - len(chtaps)/nchans) - filtbank = gr.pfb_synthesizer_ccf(nchans, syntaps) - channelizer = blks2.pfb_channelizer_ccf(nchans, chtaps) - - noise_level = 0.01 - head = gr.head(gr.sizeof_gr_complex, N) - noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level) - addnoise = gr.add_cc() - snk_synth = gr.vector_sink_c() - - tb = gr.top_block() - - tb.connect(noise, (addnoise,0)) - tb.connect(filtbank, head, (addnoise, 1)) - tb.connect(addnoise, channelizer) - tb.connect(addnoise, snk_synth) - - snk = list() - for i,si in enumerate(sigs): - tb.connect(si, fmtx[i], (filtbank, i)) - - for i in xrange(nchans): - snk.append(gr.vector_sink_c()) - tb.connect((channelizer, i), snk[i]) - - tb.run() - - if 1: - channel = 1 - data = snk[channel].data()[1000:] - - f1 = pylab.figure(1) - s1 = f1.add_subplot(1,1,1) - s1.plot(data[10000:10200] ) - s1.set_title(("Output Signal from Channel %d" % channel)) - - fftlen = 2048 - winfunc = scipy.blackman - #winfunc = scipy.hamming - - f2 = pylab.figure(2) - s2 = f2.add_subplot(1,1,1) - s2.psd(data, NFFT=fftlen, - Fs = nchans*fs, - noverlap=fftlen/4, - window = lambda d: d*winfunc(fftlen)) - s2.set_title(("Output PSD from Channel %d" % channel)) - - f3 = pylab.figure(3) - s3 = f3.add_subplot(1,1,1) - s3.psd(snk_synth.data()[1000:], NFFT=fftlen, - Fs = nchans*fs, - noverlap=fftlen/4, - window = lambda d: d*winfunc(fftlen)) - s3.set_title("Output of Synthesis Filter") - - pylab.show() - -if __name__ == "__main__": - main() diff --git a/gnuradio-core/src/gen_interpolator_taps/Makefile.am.obsolete b/gnuradio-core/src/gen_interpolator_taps/Makefile.am.obsolete deleted file mode 100644 index cd0edaf5c4..0000000000 --- a/gnuradio-core/src/gen_interpolator_taps/Makefile.am.obsolete +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright 2002 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. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST += \ - praxis.txt \ - simpson.h \ - objective_fct.c \ - gen_interpolator_taps.c \ - simpson.c \ - praxis.f - -# if ENABLE_FORTRAN -# noinst_PROGRAMS = gen_interpolator_taps -# noinst_HEADERS = simpson.h -# -# gen_interpolator_taps_SOURCES = gen_interpolator_taps.c objective_fct.c simpson.c praxis.f -# gen_interpolator_taps_LDADD = $(FLIBS) -lm -# -# endif diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 9c980157db..9dfa47fd23 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -33,7 +33,6 @@ GR_INCLUDE_SUBDIRECTORY(general) GR_INCLUDE_SUBDIRECTORY(gengen) GR_INCLUDE_SUBDIRECTORY(reed-solomon) GR_INCLUDE_SUBDIRECTORY(io) -GR_INCLUDE_SUBDIRECTORY(hier) list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) diff --git a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S b/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S deleted file mode 100644 index 0cd6867365..0000000000 --- a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_really_simple.S +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# sse_float_dotprod (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - - - .file "3dnow_float_dotprod_really_simple.s" - .version "01.01" -.text - .p2align 4 -.globl sse_float_dotprod - .type sse_float_dotprod,@function -sse_float_dotprod: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # The plan is to get it computing the correct answer, and - # then to unroll and schedule the inner loop. - - pxor %mm4, %mm4 # mm4 = 0 0 - shll $1, %ecx # count * 2 - - .p2align 4 -.Loop1: - movq (%eax), %mm0 - pfmul (%edx), %mm0 - pfadd %mm0, %mm4 - addl $8, %edx - addl $8, %eax - decl %ecx - jne .Loop1 - - # at this point mm4 contains partial sums - - pfacc %mm4, %mm4 - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret -.Lfe1: - .size sse_float_dotprod,.Lfe1-sse_float_dotprod - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S b/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S deleted file mode 100644 index 5af3fc5c93..0000000000 --- a/gnuradio-core/src/lib/filter/3dnow_float_dotprod_simple.S +++ /dev/null @@ -1,106 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# sse_float_dotprod (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - - - .file "3dnow_float_dotprod_simple.s" - .version "01.01" -.text - .p2align 4 -.globl sse_float_dotprod - .type sse_float_dotprod,@function -sse_float_dotprod: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # The plan is to get it computing the correct answer, and - # then to unroll and schedule the inner loop. - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - - .p2align 4 -.Loop1: - movq 0(%eax), %mm0 - movq 8(%eax), %mm1 - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - - addl $16, %edx - addl $16, %eax - decl %ecx - jne .Loop1 - - # at this point mm4 and mm5 contain partial sums - - pfadd %mm5, %mm4 - pfacc %mm4, %mm4 - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret -.Lfe1: - .size sse_float_dotprod,.Lfe1-sse_float_dotprod - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt index 088d3376d1..703580213e 100644 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -21,337 +21,21 @@ # This file included, use CMake directory variables ######################################################################## -#set the C language property on the assembly files so the compiler will pick them up -file(GLOB gr_core_filter_asms ${CMAKE_CURRENT_SOURCE_DIR}/*.S) -foreach(gr_core_filter_asm ${gr_core_filter_asms}) - set_property(SOURCE ${gr_core_filter_asm} PROPERTY LANGUAGE C) -endforeach(gr_core_filter_asm) - -#detect 32 or 64 bit compiler -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|x86_64|amd64)$") - include(CheckTypeSize) - check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY) - if (${SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_SYSTEM_PROCESSOR_x86 64) - else() - set(CMAKE_SYSTEM_PROCESSOR_x86 32) - endif() -endif() - -######################################################################## -# Generate the makefile.gen, then extract its sources: -# This is a round-about way to extract the sources, -# but it requires minimum changed to the python utils. -# -# The recommended way to do this: -# - Make a generation macro that registers the sources command. -# - List the generation macro with each templated source file. -# - Create a python script (very generic) to perform generation. -# - This way the targets would depend only on their sources. -######################################################################## -execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c " -import os, sys -sys.path.append('${GR_CORE_PYTHONPATH}') -sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.environ['gendir'] = '${CMAKE_CURRENT_BINARY_DIR}' -os.environ['do_makefile'] = '1' -os.environ['do_sources'] = '0' -from generate_all import generate_all -generate_all() - " WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) - -macro(FILTER_GEN_EXTRACT outvar ext) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; print ';'.join( - map(lambda x: os.path.join('${CMAKE_CURRENT_BINARY_DIR}', x.replace('\\\\', '').strip()), - filter(lambda f: '${ext}' in f, open('${CMAKE_CURRENT_BINARY_DIR}/Makefile.gen').readlines() - )))" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ${outvar}) - file(TO_CMAKE_PATH "${${outvar}}" ${outvar}) -endmacro(FILTER_GEN_EXTRACT) - -FILTER_GEN_EXTRACT(generated_filter_sources ".cc") -FILTER_GEN_EXTRACT(generated_filter_includes ".h") -FILTER_GEN_EXTRACT(generated_filter_swigs ".i") - -#TODO simplify this list with a triple-threat for loop -set(generated_filter_deps - ${CMAKE_CURRENT_SOURCE_DIR}/generate_all.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_interp_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_rational_resampler_base_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_sysconfig_generic.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_fir_util.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gr_freq_xlating_fir_filter_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_gri_fir_filter_with_buffer_XXX.py - ${CMAKE_CURRENT_SOURCE_DIR}/generate_utils.py - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_XXX_generic.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_interp_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rational_resampler_base_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.h.t - ${CMAKE_CURRENT_SOURCE_DIR}/gr_freq_xlating_fir_filter_XXX.i.t - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fir_filter_with_buffer_XXX.h.t -) - -add_custom_command( - OUTPUT - ${generated_filter_sources} - ${generated_filter_includes} - ${generated_filter_swigs} - DEPENDS ${generated_filter_deps} - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c - "import os, sys;sys.path.append('${GR_CORE_PYTHONPATH}');sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}');os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}';from generate_all import generate_all;generate_all()" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "generating filter files" - VERBATIM -) - -add_custom_target(filter_generated DEPENDS - ${generated_filter_sources} - ${generated_filter_includes} - ${generated_filter_swigs} -) - -######################################################################## -# Add target specific files -# May VOLK put a rest to all the insanity below. -######################################################################## -if(MSVC) - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_generic.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc - ) -else(MSVC) -if(CMAKE_SYSTEM_PROCESSOR_x86) - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fsf_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_scc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fcc_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_simd.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.c - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_float_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_complex_dotprod_x86.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_ccomplex_dotprod_x86.cc - ) -endif() - -if(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "64") - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow64.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse64.S - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx64.S - ) -elseif(CMAKE_SYSTEM_PROCESSOR_x86 AND "${CMAKE_SYSTEM_PROCESSOR_x86}" STREQUAL "32") - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnowext.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnowext.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_3dnow.S - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_sse.S - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_mmx.S - ) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") - if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-maltivec) - endif() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_powerpc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_altivec.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.c - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_altivec.c - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_powerpc.cc - ) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") - if(have_mfpu_neon) - add_definitions(-DHAVE_MFPU_NEON) - endif() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_fff_armv7_a.cc - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_fff_armv7_a.c - ${CMAKE_CURRENT_SOURCE_DIR}/dotprod_ccf_armv7_a.c - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_ccf_armv7_a.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_armv7_a.cc - ) -else() - list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_generic.cc - ) - list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_generic.cc - ) -endif() -endif(MSVC) - ######################################################################## # Append gnuradio-core library sources ######################################################################## list(APPEND gnuradio_core_sources - ${generated_filter_sources} - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.cc - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.c - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.c -) - -######################################################################## -# Append gnuradio-core test sources -######################################################################## -list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fcc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_fff.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_ccc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fir_scc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_rotator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_mmse_fir_interpolator_cc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_ccc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fcc.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fff.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_fsf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gri_fir_filter_with_buffer_scc.cc ) ######################################################################## # Install runtime headers ######################################################################## install(FILES - ${generated_filter_includes} - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/complex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/fcomplex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/ccomplex_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/float_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_altivec.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_cpu.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_fff_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft_filter_ccc_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_powerpc.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_single_pole_iir.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_vec_types.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_iir.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_mmse_fir_interpolator_cc.h - ${CMAKE_CURRENT_SOURCE_DIR}/qa_filter.h - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_generic.h - ${CMAKE_CURRENT_SOURCE_DIR}/short_dotprod_x86.h - ${CMAKE_CURRENT_SOURCE_DIR}/sse_debug.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) - -######################################################################## -# Install swig headers -######################################################################## -if(ENABLE_PYTHON) -install(FILES - ${generated_filter_swigs} - ${CMAKE_CURRENT_SOURCE_DIR}/filter.i - ${CMAKE_CURRENT_BINARY_DIR}/filter_generated.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" -) -endif(ENABLE_PYTHON) - -######################################################################## -# Handle triple-threat files that have cc, h, and i -######################################################################## -set(gr_core_filter_triple_threats - gr_adaptive_fir_ccc - gr_adaptive_fir_ccf - gr_dc_blocker_cc - gr_dc_blocker_ff - gr_fft_filter_ccc - gr_fft_filter_fff - gr_filter_delay_fc - gr_fractional_interpolator_ff - gr_fractional_interpolator_cc - gr_goertzel_fc - gr_hilbert_fc - gr_iir_filter_ffd - gr_single_pole_iir_filter_ff - gr_single_pole_iir_filter_cc - gr_pfb_channelizer_ccf - gr_pfb_synthesizer_ccf - gr_pfb_decimator_ccf - gr_pfb_interpolator_ccf - gr_pfb_arb_resampler_ccf - gr_pfb_arb_resampler_fff - gr_pfb_clock_sync_ccf - gr_pfb_clock_sync_fff -) - -foreach(file_tt ${gr_core_filter_triple_threats}) - list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") - if(ENABLE_PYTHON) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") - endif(ENABLE_PYTHON) -endforeach(file_tt ${gr_core_filter_triple_threats}) diff --git a/gnuradio-core/src/lib/filter/Makefile.gen b/gnuradio-core/src/lib/filter/Makefile.gen deleted file mode 100644 index 909899c054..0000000000 --- a/gnuradio-core/src/lib/filter/Makefile.gen +++ /dev/null @@ -1,124 +0,0 @@ -# -# This file is machine generated. All edits will be overwritten -# -GENERATED_H = \ - gr_fir_ccc.h \ - gr_fir_ccc_generic.h \ - gr_fir_ccf.h \ - gr_fir_ccf_generic.h \ - gr_fir_fcc.h \ - gr_fir_fcc_generic.h \ - gr_fir_fff.h \ - gr_fir_fff_generic.h \ - gr_fir_filter_ccc.h \ - gr_fir_filter_ccf.h \ - gr_fir_filter_fcc.h \ - gr_fir_filter_fff.h \ - gr_fir_filter_fsf.h \ - gr_fir_filter_scc.h \ - gr_fir_fsf.h \ - gr_fir_fsf_generic.h \ - gr_fir_scc.h \ - gr_fir_scc_generic.h \ - gr_fir_sysconfig.h \ - gr_fir_sysconfig_generic.h \ - gr_fir_util.h \ - gr_freq_xlating_fir_filter_ccc.h \ - gr_freq_xlating_fir_filter_ccf.h \ - gr_freq_xlating_fir_filter_fcc.h \ - gr_freq_xlating_fir_filter_fcf.h \ - gr_freq_xlating_fir_filter_scc.h \ - gr_freq_xlating_fir_filter_scf.h \ - gr_interp_fir_filter_ccc.h \ - gr_interp_fir_filter_ccf.h \ - gr_interp_fir_filter_fcc.h \ - gr_interp_fir_filter_fff.h \ - gr_interp_fir_filter_fsf.h \ - gr_interp_fir_filter_scc.h \ - gr_rational_resampler_base_ccc.h \ - gr_rational_resampler_base_ccf.h \ - gr_rational_resampler_base_fcc.h \ - gr_rational_resampler_base_fff.h \ - gr_rational_resampler_base_fsf.h \ - gr_rational_resampler_base_scc.h \ - gri_fir_filter_with_buffer_ccc.h \ - gri_fir_filter_with_buffer_ccf.h \ - gri_fir_filter_with_buffer_fcc.h \ - gri_fir_filter_with_buffer_fff.h \ - gri_fir_filter_with_buffer_fsf.h \ - gri_fir_filter_with_buffer_scc.h - - -GENERATED_I = \ - gr_fir_filter_ccc.i \ - gr_fir_filter_ccf.i \ - gr_fir_filter_fcc.i \ - gr_fir_filter_fff.i \ - gr_fir_filter_fsf.i \ - gr_fir_filter_scc.i \ - gr_freq_xlating_fir_filter_ccc.i \ - gr_freq_xlating_fir_filter_ccf.i \ - gr_freq_xlating_fir_filter_fcc.i \ - gr_freq_xlating_fir_filter_fcf.i \ - gr_freq_xlating_fir_filter_scc.i \ - gr_freq_xlating_fir_filter_scf.i \ - gr_interp_fir_filter_ccc.i \ - gr_interp_fir_filter_ccf.i \ - gr_interp_fir_filter_fcc.i \ - gr_interp_fir_filter_fff.i \ - gr_interp_fir_filter_fsf.i \ - gr_interp_fir_filter_scc.i \ - gr_rational_resampler_base_ccc.i \ - gr_rational_resampler_base_ccf.i \ - gr_rational_resampler_base_fcc.i \ - gr_rational_resampler_base_fff.i \ - gr_rational_resampler_base_fsf.i \ - gr_rational_resampler_base_scc.i - -GENERATED_CC = \ - gr_fir_ccc.cc \ - gr_fir_ccc_generic.cc \ - gr_fir_ccf.cc \ - gr_fir_ccf_generic.cc \ - gr_fir_fcc.cc \ - gr_fir_fcc_generic.cc \ - gr_fir_fff.cc \ - gr_fir_fff_generic.cc \ - gr_fir_filter_ccc.cc \ - gr_fir_filter_ccf.cc \ - gr_fir_filter_fcc.cc \ - gr_fir_filter_fff.cc \ - gr_fir_filter_fsf.cc \ - gr_fir_filter_scc.cc \ - gr_fir_fsf.cc \ - gr_fir_fsf_generic.cc \ - gr_fir_scc.cc \ - gr_fir_scc_generic.cc \ - gr_fir_sysconfig.cc \ - gr_fir_sysconfig_generic.cc \ - gr_fir_util.cc \ - gr_freq_xlating_fir_filter_ccc.cc \ - gr_freq_xlating_fir_filter_ccf.cc \ - gr_freq_xlating_fir_filter_fcc.cc \ - gr_freq_xlating_fir_filter_fcf.cc \ - gr_freq_xlating_fir_filter_scc.cc \ - gr_freq_xlating_fir_filter_scf.cc \ - gr_interp_fir_filter_ccc.cc \ - gr_interp_fir_filter_ccf.cc \ - gr_interp_fir_filter_fcc.cc \ - gr_interp_fir_filter_fff.cc \ - gr_interp_fir_filter_fsf.cc \ - gr_interp_fir_filter_scc.cc \ - gr_rational_resampler_base_ccc.cc \ - gr_rational_resampler_base_ccf.cc \ - gr_rational_resampler_base_fcc.cc \ - gr_rational_resampler_base_fff.cc \ - gr_rational_resampler_base_fsf.cc \ - gr_rational_resampler_base_scc.cc \ - gri_fir_filter_with_buffer_ccc.cc \ - gri_fir_filter_with_buffer_ccf.cc \ - gri_fir_filter_with_buffer_fcc.cc \ - gri_fir_filter_with_buffer_fff.cc \ - gri_fir_filter_with_buffer_fsf.cc \ - gri_fir_filter_with_buffer_scc.cc - diff --git a/gnuradio-core/src/lib/filter/README b/gnuradio-core/src/lib/filter/README deleted file mode 100644 index 90c1584fcb..0000000000 --- a/gnuradio-core/src/lib/filter/README +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2004 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. -# - -This directory holds filtering code, some of which is machine -generated. Which variations are generated is controlled by two -variables. For most everything, the global "signatures" -in generate_utils.py controls. - -For GrFreqXlatingFIRfilter<foo>, the global "fx_signatures" in -generate_GrFreqXlatingFIRfilterXXX.py controls. diff --git a/gnuradio-core/src/lib/filter/assembly.h b/gnuradio-core/src/lib/filter/assembly.h deleted file mode 100644 index 32477dfd7b..0000000000 --- a/gnuradio-core/src/lib/filter/assembly.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _ASSEMBLY_H_ -#define _ASSEMBLY_H_ - -#if defined (__APPLE__) && defined (__APPLE_CC__) - -// XCode ignores the .scl and .type functions in XCode 2.2.1 and 2.3, -// but creates an error in XCode 2.4. Just ignore them. - -#define GLOB_SYMB(f) _ ## f - -#define DEF_FUNC_HEAD(f) /* none */ - -#define FUNC_TAIL(f) /* none*/ - -#elif !defined (__ELF__) - -/* - * Too bad, the following define does not work as expected --SF - * #define GLOB_SYMB(f) __USER_LABEL_PREFIX__ ## f - */ -#define GLOB_SYMB(f) _ ## f - -#define DEF_FUNC_HEAD(f) \ - .def GLOB_SYMB(f); .scl 2; .type 32; .endef - -#define FUNC_TAIL(f) /* none */ - - -#else /* !__ELF__ */ - - -#define GLOB_SYMB(f) f - -#define DEF_FUNC_HEAD(f) \ - .type GLOB_SYMB(f),@function \ - -#define FUNC_TAIL(f) \ - .Lfe1: \ - .size GLOB_SYMB(f),.Lfe1-GLOB_SYMB(f) - - -#endif /* !__ELF__ */ - - -#endif /* _ASSEMBLY_H_ */ diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S deleted file mode 100644 index 8844e51085..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow.S +++ /dev/null @@ -1,220 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnow.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnow) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnow) -GLOB_SYMB(ccomplex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - - movq 0(%eax), %mm0 - - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%edx), %mm2 - - movq 8(%eax), %mm1 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - movq 8(%edx), %mm3 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z, mmPN=$80000000 -# -# movq (%eax), %mmA -# movq (%edx), %mmB -# -# # 3DNow! replacement for: pswapd %mmA, %mmZ -# # TODO: optimize the punpckhdq -# movq %mmA, %mmZ -# punpckhdq %mmZ, %mmZ -# punpckldq %mmA, %mmZ -# -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# -# # 3DNow! replacement for: pfpnacc %mmB, %mmA -# pxor %mmPN, %mmA -# pfacc %mmB, %mmA -# -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 16(%edx), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 16(%eax), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 24(%edx), %mm1 - - movq %mm0, %mm4 - movq %mm1, %mm5 - - pfadd %mm3, %mm7 - movq 24(%eax), %mm3 - -# unroll - - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 32(%edx), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 32(%eax), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 40(%edx), %mm1 - - addl $32, %eax - addl $32, %edx - - pfadd %mm3, %mm7 - movq 8(%eax), %mm3 - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - pfmul %mm5, %mm3 - pfadd %mm1, %mm6 - pfadd %mm3, %mm7 - -.Leven: - # mmNP: negative inversor - - pcmpeqd %mm0, %mm0 # set all bits to 1 - psllq $63, %mm0 # keep only hsb - - pxor %mm0, %mm6 - pfacc %mm7, %mm6 - - movl 20(%ebp), %eax # result - movq %mm6, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S deleted file mode 100644 index d92fe17a32..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnow64.S +++ /dev/null @@ -1,217 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "ccomplex_dotprod_3dnow64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnow) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnow) -GLOB_SYMB(ccomplex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - - movq 0(%rdi), %mm0 - - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%rsi), %mm2 - - movq 8(%rdi), %mm1 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - movq 8(%rsi), %mm3 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z, mmPN=$80000000 -# -# movq (%rdx), %mmA -# movq (%rsi), %mmB -# -# # 3DNow! replacement for: pswapd %mmA, %mmZ -# # TODO: optimize the punpckhdq -# movq %mmA, %mmZ -# punpckhdq %mmZ, %mmZ -# punpckldq %mmA, %mmZ -# -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# -# # 3DNow! replacement for: pfpnacc %mmB, %mmA -# pxor %mmPN, %mmA -# pfacc %mmB, %mmA -# -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 16(%rsi), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 16(%rdi), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 24(%rsi), %mm1 - - movq %mm0, %mm4 - movq %mm1, %mm5 - - pfadd %mm3, %mm7 - movq 24(%rdi), %mm3 - -# unroll - - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - movq 32(%rsi), %mm0 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - movq 32(%rdi), %mm2 - pfadd %mm1, %mm6 - pfmul %mm5, %mm3 - movq 40(%rsi), %mm1 - - add $32, %rdi - add $32, %rsi - - pfadd %mm3, %mm7 - movq 8(%rdi), %mm3 - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - - movq %mm0, %mm4 - movq %mm1, %mm5 - punpckhdq %mm4, %mm4 - punpckhdq %mm5, %mm5 - punpckldq %mm0, %mm4 - pfmul %mm2, %mm0 - punpckldq %mm1, %mm5 - pfmul %mm4, %mm2 - pfadd %mm0, %mm6 - pfmul %mm3, %mm1 - pfadd %mm2, %mm7 - pfmul %mm5, %mm3 - pfadd %mm1, %mm6 - pfadd %mm3, %mm7 - -.Leven: - # mmNP: negative inversor - - pcmpeqd %mm0, %mm0 # set all bits to 1 - psllq $63, %mm0 # keep only hsb - - pxor %mm0, %mm6 - pfacc %mm7, %mm6 - - movq %mm6, (%rcx) - - femms - - retq - -FUNC_TAIL(ccomplex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S deleted file mode 100644 index c4a02d7fb6..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext.S +++ /dev/null @@ -1,195 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnowext.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnowext) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnowext) -GLOB_SYMB(ccomplex_dotprod_3dnowext): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%eax), %mm0 - movq 0(%edx), %mm2 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - movq 8(%eax), %mm1 - movq 8(%edx), %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z -# -# movq 0(%eax), %mmA -# movq 0(%edx), %mmB -# pswapd %mmA, %mmZ -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# pfpnacc %mmB, %mmA -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 16(%edx), %mm2 - pfpnacc %mm3, %mm1 - movq 24(%edx), %mm3 - - pfadd %mm0, %mm6 - movq 16(%eax), %mm0 - pfadd %mm1, %mm7 - movq 24(%eax), %mm1 - -# unroll - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 32(%edx), %mm2 - pfpnacc %mm3, %mm1 - movq 40(%edx), %mm3 - - pfadd %mm0, %mm6 - movq 32(%eax), %mm0 - pfadd %mm1, %mm7 - movq 40(%eax), %mm1 - - addl $32, %edx - addl $32, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - pfpnacc %mm3, %mm1 - - pfadd %mm0, %mm6 - pfadd %mm1, %mm7 - -.Leven: - # at this point mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - - movl 20(%ebp), %eax # result - movq %mm6, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_3dnowext) - .ident "Hand coded x86 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S deleted file mode 100644 index c4f9e19700..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_3dnowext64.S +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_3dnowext64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_3dnowext) - DEF_FUNC_HEAD(ccomplex_dotprod_3dnowext) -GLOB_SYMB(ccomplex_dotprod_3dnowext): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - - # zero accumulators - - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - movq 0(%rdi), %mm0 - movq 0(%rsi), %mm2 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - movq 8(%rdi), %mm1 - movq 8(%rsi), %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z -# -# movq 0(%rdi), %mmA -# movq 0(%rsi), %mmB -# pswapd %mmA, %mmZ -# pfmul %mmB, %mmA -# pfmul %mmZ, %mmB -# pfpnacc %mmB, %mmA -# pfadd %mmA, %mmC - - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 16(%rsi), %mm2 - pfpnacc %mm3, %mm1 - movq 24(%rsi), %mm3 - - pfadd %mm0, %mm6 - movq 16(%rdi), %mm0 - pfadd %mm1, %mm7 - movq 24(%rdi), %mm1 - -# unroll - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - movq 32(%rsi), %mm2 - pfpnacc %mm3, %mm1 - movq 40(%rsi), %mm3 - - pfadd %mm0, %mm6 - movq 32(%rdi), %mm0 - pfadd %mm1, %mm7 - movq 40(%rdi), %mm1 - - add $32, %rsi - add $32, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's see if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 & mm1/mm3 preloaded - # from the main loop. - -# A=mm0, B=mm2, Z=mm4 -# A'=mm1, B'=mm3, Z'=mm5 - - pswapd %mm0, %mm4 - pfmul %mm2, %mm0 - pswapd %mm1, %mm5 - pfmul %mm4, %mm2 - pfmul %mm3, %mm1 - pfpnacc %mm2, %mm0 - pfmul %mm5, %mm3 - pfpnacc %mm3, %mm1 - - pfadd %mm0, %mm6 - pfadd %mm1, %mm7 - -.Leven: - # at this point mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - - movq %mm6, (%rcx) # result - - femms - - retq - -FUNC_TAIL(ccomplex_dotprod_3dnowext) - .ident "Hand coded x86_64 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc deleted file mode 100644 index a6f3922117..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 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 <gr_complex.h> -#include "ccomplex_dotprod_generic.h" - -#include <iostream> - -void -ccomplex_dotprod_generic (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result) -{ - gr_complex sum0(0,0); - gr_complex sum1(0,0); - - std::cerr << "Blah!!!\n"; - do { - const gr_complex tap0(taps[0], taps[1]); - const gr_complex tap1(taps[2], taps[3]); - const gr_complex input0(input[0], input[1]); - const gr_complex input1(input[2], input[3]); - - sum0 += input0 * tap0; - sum1 += input1 * tap1; - - input += 8; - taps += 8; - - } while (--n_2_ccomplex_blocks != 0); - - - sum0 += sum1; - result[0] = sum0.real(); - result[1] = sum0.imag(); -} diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h b/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h deleted file mode 100644 index c7d761c079..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_generic.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _CCOMPLEX_DOTPROD_GENERIC_H_ -#define _CCOMPLEX_DOTPROD_GENERIC_H_ - -#include <gr_core_api.h> - -GR_CORE_API void -ccomplex_dotprod_generic (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result); - - -#endif /* _CCOMPLEX_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S deleted file mode 100644 index b50a3690d0..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse.S +++ /dev/null @@ -1,198 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - .file "ccomplex_dotprod_sse.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_sse) - DEF_FUNC_HEAD(ccomplex_dotprod_sse) -GLOB_SYMB(ccomplex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - - xorps %xmm6, %xmm6 # zero accumulators - - movaps 0(%eax), %xmm0 - - xorps %xmm7, %xmm7 # zero accumulators - - movaps 0(%edx), %xmm2 - - shrl $1, %ecx # ecx = n_2_ccomplex_blocks / 2 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z & Y (or B), xmmPN=$0x8000000080000000 -# -# movaps (%eax), %xmmA -# movaps (%edx), %xmmB -# -# movaps %xmmA, %xmmZ -# shufps $0xb1, %xmmZ, %xmmZ # swap internals -# -# mulps %xmmB, %xmmA -# mulps %xmmZ, %xmmB -# -# # SSE replacement for: pfpnacc %xmmB, %xmmA -# xorps %xmmPN, %xmmA -# movaps %xmmA, %xmmZ -# unpcklps %xmmB, %xmmA -# unpckhps %xmmB, %xmmZ -# movaps %xmmZ, %xmmY -# shufps $0x44, %xmmA, %xmmZ # b01000100 -# shufps $0xee, %xmmY, %xmmA # b11101110 -# addps %xmmZ, %xmmA -# -# addps %xmmA, %xmmC - -# A=xmm0, B=xmm2, Z=xmm4 -# A'=xmm1, B'=xmm3, Z'=xmm5 - - movaps 16(%eax), %xmm1 - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - - shufps $0xb1, %xmm4, %xmm4 # swap internals - movaps 16(%edx), %xmm3 - movaps %xmm1, %xmm5 - addps %xmm0, %xmm6 - mulps %xmm3, %xmm1 - shufps $0xb1, %xmm5, %xmm5 # swap internals - addps %xmm1, %xmm6 - mulps %xmm4, %xmm2 - movaps 32(%eax), %xmm0 - addps %xmm2, %xmm7 - mulps %xmm5, %xmm3 - - addl $32, %eax - - movaps 32(%edx), %xmm2 - addps %xmm3, %xmm7 - - addl $32, %edx - - - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's sse if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - movl 16(%ebp), %ecx # n_2_ccomplex_blocks - andl $1, %ecx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 preloaded - # from the main loop. - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - shufps $0xb1, %xmm4, %xmm4 # swap internals - addps %xmm0, %xmm6 - mulps %xmm4, %xmm2 - addps %xmm2, %xmm7 - - -.Leven: - # neg inversor - xorps %xmm1, %xmm1 - movl $0x80000000, 16(%ebp) - movss 16(%ebp), %xmm1 - shufps $0x11, %xmm1, %xmm1 # b00010001 # 0 -0 0 -0 - - # pfpnacc - xorps %xmm1, %xmm6 - - movaps %xmm6, %xmm2 - unpcklps %xmm7, %xmm6 - unpckhps %xmm7, %xmm2 - movaps %xmm2, %xmm3 - shufps $0x44, %xmm6, %xmm2 # b01000100 - shufps $0xee, %xmm3, %xmm6 # b11101110 - addps %xmm2, %xmm6 - - # xmm6 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm6, %xmm4 # xmm4 = r3 i4 ?? ?? - addps %xmm4, %xmm6 # xmm6 = r1+r3 i2+i4 ?? ?? - movlps %xmm6, (%eax) # store low 2x32 bits (complex) to memory - - popl %ebp - ret - -FUNC_TAIL(ccomplex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S deleted file mode 100644 index ef89ae6380..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_sse64.S +++ /dev/null @@ -1,195 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_ccomplex_blocks is != 0 -# -# -# ccomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_ccomplex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0] - input[1] * taps[1]; -# sum1 += input[0] * taps[1] + input[1] * taps[0]; -# sum2 += input[2] * taps[2] - input[3] * taps[3]; -# sum3 += input[2] * taps[3] + input[3] * taps[2]; -# -# input += 4; -# taps += 4; -# -# } while (--n_2_ccomplex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "ccomplex_dotprod_sse64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(ccomplex_dotprod_sse) - DEF_FUNC_HEAD(ccomplex_dotprod_sse) -GLOB_SYMB(ccomplex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - xorps %xmm6, %xmm6 # zero accumulators - - movaps 0(%rdi), %xmm0 - - xorps %xmm7, %xmm7 # zero accumulators - - movaps 0(%rsi), %xmm2 - - shr $1, %rax # rax = n_2_ccomplex_blocks / 2 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - -# complex prod: C += A * B, w/ temp Z & Y (or B), xmmPN=$0x8000000080000000 -# -# movaps (%rdi), %xmmA -# movaps (%rsi), %xmmB -# -# movaps %xmmA, %xmmZ -# shufps $0xb1, %xmmZ, %xmmZ # swap internals -# -# mulps %xmmB, %xmmA -# mulps %xmmZ, %xmmB -# -# # SSE replacement for: pfpnacc %xmmB, %xmmA -# xorps %xmmPN, %xmmA -# movaps %xmmA, %xmmZ -# unpcklps %xmmB, %xmmA -# unpckhps %xmmB, %xmmZ -# movaps %xmmZ, %xmmY -# shufps $0x44, %xmmA, %xmmZ # b01000100 -# shufps $0xee, %xmmY, %xmmA # b11101110 -# addps %xmmZ, %xmmA -# -# addps %xmmA, %xmmC - -# A=xmm0, B=xmm2, Z=xmm4 -# A'=xmm1, B'=xmm3, Z'=xmm5 - - movaps 16(%rdi), %xmm1 - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - - shufps $0xb1, %xmm4, %xmm4 # swap internals - movaps 16(%rsi), %xmm3 - movaps %xmm1, %xmm5 - addps %xmm0, %xmm6 - mulps %xmm3, %xmm1 - shufps $0xb1, %xmm5, %xmm5 # swap internals - addps %xmm1, %xmm6 - mulps %xmm4, %xmm2 - movaps 32(%rdi), %xmm0 - addps %xmm2, %xmm7 - mulps %xmm5, %xmm3 - - add $32, %rdi - - movaps 32(%rsi), %xmm2 - addps %xmm3, %xmm7 - - add $32, %rsi - - - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Let's sse if original n_2_ccomplex_blocks was odd. - # If so, we've got 2 more taps to do. - - and $1, %rdx - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0/mm2 preloaded - # from the main loop. - - movaps %xmm0, %xmm4 - mulps %xmm2, %xmm0 - shufps $0xb1, %xmm4, %xmm4 # swap internals - addps %xmm0, %xmm6 - mulps %xmm4, %xmm2 - addps %xmm2, %xmm7 - - -.Leven: - # neg inversor - xorps %xmm1, %xmm1 - movl $0x80000000, -8(%rsp) - movss -8(%rsp), %xmm1 - shufps $0x11, %xmm1, %xmm1 # b00010001 # 0 -0 0 -0 - - # pfpnacc - xorps %xmm1, %xmm6 - - movaps %xmm6, %xmm2 - unpcklps %xmm7, %xmm6 - unpckhps %xmm7, %xmm2 - movaps %xmm2, %xmm3 - shufps $0x44, %xmm6, %xmm2 # b01000100 - shufps $0xee, %xmm3, %xmm6 # b11101110 - addps %xmm2, %xmm6 - - # xmm6 = r1 i2 r3 i4 - movhlps %xmm6, %xmm4 # xmm4 = r3 i4 ?? ?? - addps %xmm4, %xmm6 # xmm6 = r1+r3 i2+i4 ?? ?? - movlps %xmm6, (%rcx) # store low 2x32 bits (complex) to memory - - retq - -FUNC_TAIL(ccomplex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h deleted file mode 100644 index ebb63c2587..0000000000 --- a/gnuradio-core/src/lib/filter/ccomplex_dotprod_x86.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _CCOMPLEX_DOTPROD_X86_H_ -#define _CCOMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -ccomplex_dotprod_3dnow (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -void -ccomplex_dotprod_3dnowext (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -void -ccomplex_dotprod_sse (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _CCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S deleted file mode 100644 index df7761c407..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow.S +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - .file "complex_dotprod_3dnow.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnow) - DEF_FUNC_HEAD(complex_dotprod_3dnow) -GLOB_SYMB(complex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - # pshufw & pi2fw - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - pi2fd %mm0, %mm0 - - pxor %mm1, %mm1 - punpcklwd 0(%eax), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - pi2fd %mm1, %mm1 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - pxor %mm2, %mm2 - punpcklwd 4(%eax), %mm2 - psrad $16, %mm2 - punpckldq %mm2, %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - pi2fd %mm2, %mm2 - - pxor %mm3, %mm3 - punpcklwd 4(%eax), %mm3 - psrad $16, %mm3 - punpckhdq %mm3, %mm3 - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - pi2fd %mm3, %mm3 - - pxor %mm0, %mm0 - punpcklwd 8(%eax), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - - pxor %mm1, %mm1 - punpcklwd 8(%eax), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - - pi2fd %mm0, %mm0 - pi2fd %mm1, %mm1 - -#TODO: add prefetch - - addl $32, %edx - addl $8, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - - pfadd %mm6, %mm4 - - movq %mm4, (%eax) - femms - - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S deleted file mode 100644 index ac5a7d1be8..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnow64.S +++ /dev/null @@ -1,187 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "complex_dotprod_3dnow64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnow) - DEF_FUNC_HEAD(complex_dotprod_3dnow) -GLOB_SYMB(complex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - # pshufw & pi2fw - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - pi2fd %mm0, %mm0 - - pxor %mm1, %mm1 - punpcklwd 0(%rdi), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - pi2fd %mm1, %mm1 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - pxor %mm2, %mm2 - punpcklwd 4(%rdi), %mm2 - psrad $16, %mm2 - punpckldq %mm2, %mm2 - - pfmul 8(%rsi), %mm1 - pfadd %mm3, %mm7 - pi2fd %mm2, %mm2 - - pxor %mm3, %mm3 - punpcklwd 4(%rdi), %mm3 - psrad $16, %mm3 - punpckhdq %mm3, %mm3 - - pfmul 16(%rsi), %mm2 - pfadd %mm0, %mm4 - pi2fd %mm3, %mm3 - - pxor %mm0, %mm0 - punpcklwd 8(%rdi), %mm0 - psrad $16, %mm0 - punpckldq %mm0, %mm0 - - pfmul 24(%rsi), %mm3 - pfadd %mm1, %mm5 - - pxor %mm1, %mm1 - punpcklwd 8(%rdi), %mm1 - psrad $16, %mm1 - punpckhdq %mm1, %mm1 - - pi2fd %mm0, %mm0 - pi2fd %mm1, %mm1 - -#TODO: add prefetch - - add $32, %rsi - add $8, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - - movq %mm4, (%rcx) - femms - - retq - -FUNC_TAIL(complex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S deleted file mode 100644 index 1d4be32c3b..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext.S +++ /dev/null @@ -1,171 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - .file "complex_dotprod_3dnowext.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnowext) - DEF_FUNC_HEAD(complex_dotprod_3dnowext) -GLOB_SYMB(complex_dotprod_3dnowext): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - movd 0(%eax), %mm0 - pshufw $0x55, %mm0, %mm1 # b01010101 - pshufw $0, %mm0, %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - pi2fw %mm1, %mm1 - pi2fw %mm0, %mm0 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - pshufw $0, 4(%eax), %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - pi2fw %mm2, %mm2 - - pshufw $0x55, 4(%eax), %mm3 # b01010101 - - pfmul 16(%edx), %mm2 - pi2fw %mm3, %mm3 - pfadd %mm0, %mm4 - - pshufw $0, 8(%eax), %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - - pshufw $0x55, 8(%eax), %mm1 # b01010101 - pi2fw %mm0, %mm0 - -#TODO: add prefetch - - addl $32, %edx - addl $8, %eax - pi2fw %mm1, %mm1 - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - pfadd %mm6, %mm4 - movq %mm4, (%eax) - - femms - - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_3dnowext) - .ident "Hand coded x86 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S b/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S deleted file mode 100644 index 018fefe28a..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_3dnowext64.S +++ /dev/null @@ -1,168 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "complex_dotprod_3dnowext64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_3dnowext) - DEF_FUNC_HEAD(complex_dotprod_3dnowext) -GLOB_SYMB(complex_dotprod_3dnowext): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - movd 0(%rdi), %mm0 - pshufw $0x55, %mm0, %mm1 # b01010101 - pshufw $0, %mm0, %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - pi2fw %mm1, %mm1 - pi2fw %mm0, %mm0 - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - pshufw $0, 4(%rdi), %mm2 - - pfmul 8(%rsi), %mm1 - pfadd %mm3, %mm7 - pi2fw %mm2, %mm2 - - pshufw $0x55, 4(%rdi), %mm3 # b01010101 - - pfmul 16(%rsi), %mm2 - pi2fw %mm3, %mm3 - pfadd %mm0, %mm4 - - pshufw $0, 8(%rdi), %mm0 - - pfmul 24(%rsi), %mm3 - pfadd %mm1, %mm5 - - pshufw $0x55, 8(%rdi), %mm1 # b01010101 - pi2fw %mm0, %mm0 - -#TODO: add prefetch - - add $32, %rsi - add $8, %rdi - pi2fw %mm1, %mm1 - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - pfadd %mm6, %mm4 - movq %mm4, (%rcx) - - femms - - retq - -FUNC_TAIL(complex_dotprod_3dnowext) - .ident "Hand coded x86_64 3DNow!Ext assembly" - - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc b/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc deleted file mode 100644 index 229cbe9785..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_generic.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 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 <gr_complex.h> -#include "complex_dotprod_generic.h" - - -void -complex_dotprod_generic (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result) -{ - gr_complex sum0(0,0); - gr_complex sum1(0,0); - - do { - const gr_complex tap0(taps[0], taps[1]); - const gr_complex tap1(taps[2], taps[3]); - - sum0 += (float)input[0] * tap0; - sum1 += (float)input[1] * tap1; - - input += 4; - taps += 8; - - } while (--n_2_complex_blocks != 0); - - - sum0 += sum1; - result[0] = sum0.real(); - result[1] = sum0.imag(); -} diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h b/gnuradio-core/src/lib/filter/complex_dotprod_generic.h deleted file mode 100644 index 152f6e4592..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_generic.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _COMPLEX_DOTPROD_GENERIC_H_ -#define _COMPLEX_DOTPROD_GENERIC_H_ - -#include <gr_core_api.h> - -GR_CORE_API void -complex_dotprod_generic (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result); - - -#endif /* _COMPLEX_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_sse.S b/gnuradio-core/src/lib/filter/complex_dotprod_sse.S deleted file mode 100644 index fff1057ddb..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_sse.S +++ /dev/null @@ -1,206 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "complex_dotprod_sse.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_sse) - DEF_FUNC_HEAD(complex_dotprod_sse) -GLOB_SYMB(complex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $4, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - pxor %mm0, %mm0 - punpcklwd 0(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - movaps %xmm5, %xmm2 - - pxor %mm1, %mm1 - punpcklwd 4(%eax), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - movaps %xmm5, %xmm3 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%edx), %xmm0 - addps %xmm2, %xmm6 - - pxor %mm2, %mm2 - punpcklwd 8(%eax), %mm2 - psrad $16, %mm2 - cvtpi2ps %mm2, %xmm2 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%edx), %xmm1 - addps %xmm3, %xmm7 - - pxor %mm3, %mm3 - punpcklwd 12(%eax), %mm3 - psrad $16, %mm3 - cvtpi2ps %mm3, %xmm3 - shufps $0x50, %xmm3, %xmm3 - - mulps 0x20(%edx), %xmm2 - addps %xmm0, %xmm4 - - pxor %mm0, %mm0 - punpcklwd 16(%eax), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%edx), %xmm3 - addps %xmm1, %xmm5 - - pxor %mm1, %mm1 - punpcklwd 20(%eax), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - addl $0x40, %edx - addl $0x10, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%eax) # store low 2x32 bits (complex) to memory - - emms - popl %ebp - ret - -FUNC_TAIL(complex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S deleted file mode 100644 index 77f0c31782..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_sse64.S +++ /dev/null @@ -1,202 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# complex_dotprod_generic (const short *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "complex_dotprod_sse64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(complex_dotprod_sse) - DEF_FUNC_HEAD(complex_dotprod_sse) -GLOB_SYMB(complex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps (%rsi), %xmm0 - add $0x10, %rsi - add $4, %rdi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - shr $2, %rdx # n_2_complex_blocks / 4 - movaps %xmm5, %xmm7 - - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - pxor %mm0, %mm0 - punpcklwd 0(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - movaps %xmm5, %xmm2 - - pxor %mm1, %mm1 - punpcklwd 4(%rdi), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - movaps %xmm5, %xmm3 - - # we know rax is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%rsi), %xmm0 - addps %xmm2, %xmm6 - - pxor %mm2, %mm2 - punpcklwd 8(%rdi), %mm2 - psrad $16, %mm2 - cvtpi2ps %mm2, %xmm2 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%rsi), %xmm1 - addps %xmm3, %xmm7 - - pxor %mm3, %mm3 - punpcklwd 12(%rdi), %mm3 - psrad $16, %mm3 - cvtpi2ps %mm3, %xmm3 - shufps $0x50, %xmm3, %xmm3 - - mulps 0x20(%rsi), %xmm2 - addps %xmm0, %xmm4 - - pxor %mm0, %mm0 - punpcklwd 16(%rdi), %mm0 - psrad $16, %mm0 - cvtpi2ps %mm0, %xmm0 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%rsi), %xmm3 - addps %xmm1, %xmm5 - - pxor %mm1, %mm1 - punpcklwd 20(%rdi), %mm1 - psrad $16, %mm1 - cvtpi2ps %mm1, %xmm1 - shufps $0x50, %xmm1, %xmm1 - - add $0x40, %rsi - add $0x10, %rdi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%rcx) # store low 2x32 bits (complex) to memory - - emms - retq - -FUNC_TAIL(complex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/complex_dotprod_x86.h b/gnuradio-core/src/lib/filter/complex_dotprod_x86.h deleted file mode 100644 index aad9fb5e9d..0000000000 --- a/gnuradio-core/src/lib/filter/complex_dotprod_x86.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _COMPLEX_DOTPROD_X86_H_ -#define _COMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -complex_dotprod_3dnow (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -complex_dotprod_3dnowext (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -complex_dotprod_sse (const short *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _COMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c deleted file mode 100644 index c125b49b3c..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2011 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dotprod_ccf_armv7_a.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#ifndef HAVE_MFPU_NEON - -void -dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n) -{ - size_t i; - res[0] = 0; - res[1] = 0; - - for (i = 0; i < n; i++){ - res[0] += a[2*i] * b[i]; - res[1] += a[2*i+1] * b[i]; - } -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -void -dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n) -{ - - asm volatile( - "vmov.f32 q14, #0.0 \n\t" - "vmov.f32 q15, #0.0 \n\t" - "1: \n\t" - "subs %2, %2, #4 \n\t" - "vld2.f32 {q0-q1}, [%0]! \n\t" - "vld1.f32 {q2}, [%1]! \n\t" - "vmla.f32 q14, q0, q2 \n\t" - "vmla.f32 q15, q1, q2 \n\t" - "bgt 1b \n\t" - "vpadd.f32 d0, d28, d29 \n\t" - "vpadd.f32 d1, d30, d31 \n\t" - "vpadd.f32 d0, d0, d1 \n\t" - "vst1.f32 {d0}, [%3] \n\t" - - : "+&r"(a), "+&r"(b), "+&r"(n) - : "r"(res) - : "memory", "d0", "d1", "d2", "d3", "d4", "d5", - "d28", "d29", "d30", "d31" ); -} - - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h deleted file mode 100644 index e42d6d10be..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2011 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_CCF_ARMV7_A_H -#define INCLUDED_DOTPROD_CCF_ARMV7_A_H - -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -void dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n); - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_DOTPROD_CCF_ARMV7_A_H */ diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c deleted file mode 100644 index 53d6df714f..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <dotprod_fff_altivec.h> -#include <gr_altivec.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#if 0 - -float -dotprod_fff_altivec(const float *a, const float *b, size_t n) -{ - float sum = 0; - for (size_t i = 0; i < n; i++){ - sum += a[i] * b[i]; - } - return sum; -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -float -dotprod_fff_altivec(const float *_a, const float *_b, size_t n) -{ - const vec_float4 *a = (const vec_float4 *) _a; - const vec_float4 *b = (const vec_float4 *) _b; - - static const size_t UNROLL_CNT = 4; - - n = gr_p2_round_down(n, 4); - size_t loop_cnt = n / (UNROLL_CNT * FLOATS_PER_VEC); - size_t nleft = n % (UNROLL_CNT * FLOATS_PER_VEC); - - // printf("n = %zd, loop_cnt = %zd, nleft = %zd\n", n, loop_cnt, nleft); - - // Used with vperm to build a* from p* - vec_uchar16 lvsl_a = vec_lvsl(0, _a); - - vec_float4 p0, p1, p2, p3; - vec_float4 a0, a1, a2, a3; - vec_float4 b0, b1, b2, b3; - vec_float4 acc0 = {0, 0, 0, 0}; - vec_float4 acc1 = {0, 0, 0, 0}; - vec_float4 acc2 = {0, 0, 0, 0}; - vec_float4 acc3 = {0, 0, 0, 0}; - - // wind in - - p0 = vec_ld(0*VS, a); - p1 = vec_ld(1*VS, a); - p2 = vec_ld(2*VS, a); - p3 = vec_ld(3*VS, a); - a += UNROLL_CNT; - - a0 = vec_perm(p0, p1, lvsl_a); - b0 = vec_ld(0*VS, b); - p0 = vec_ld(0*VS, a); - - size_t i; - for (i = 0; i < loop_cnt; i++){ - - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - p1 = vec_ld(1*VS, a); - acc0 = vec_madd(a0, b0, acc0); - - a2 = vec_perm(p2, p3, lvsl_a); - b2 = vec_ld(2*VS, b); - p2 = vec_ld(2*VS, a); - acc1 = vec_madd(a1, b1, acc1); - - a3 = vec_perm(p3, p0, lvsl_a); - b3 = vec_ld(3*VS, b); - p3 = vec_ld(3*VS, a); - acc2 = vec_madd(a2, b2, acc2); - - a += UNROLL_CNT; - b += UNROLL_CNT; - - a0 = vec_perm(p0, p1, lvsl_a); - b0 = vec_ld(0*VS, b); - p0 = vec_ld(0*VS, a); - acc3 = vec_madd(a3, b3, acc3); - } - - /* - * The compiler ought to be able to figure out that 0, 4, 8 and 12 - * are the only possible values for nleft. - */ - switch (nleft){ - case 0: - break; - - case 4: - acc0 = vec_madd(a0, b0, acc0); - break; - - case 8: - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - acc0 = vec_madd(a0, b0, acc0); - acc1 = vec_madd(a1, b1, acc1); - break; - - case 12: - a1 = vec_perm(p1, p2, lvsl_a); - b1 = vec_ld(1*VS, b); - acc0 = vec_madd(a0, b0, acc0); - a2 = vec_perm(p2, p3, lvsl_a); - b2 = vec_ld(2*VS, b); - acc1 = vec_madd(a1, b1, acc1); - acc2 = vec_madd(a2, b2, acc2); - break; - } - - acc0 = acc0 + acc1; - acc2 = acc2 + acc3; - acc0 = acc0 + acc2; - - return horizontal_add_f(acc0); -} - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h deleted file mode 100644 index a52370d56f..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_FFF_ALTIVEC_H -#define INCLUDED_DOTPROD_FFF_ALTIVEC_H - -#include <gr_core_api.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -float -dotprod_fff_altivec(const float *a, const float *b, size_t n); - -#ifdef __cplusplus -} -#endif - - -#endif /* INCLUDED_DOTPROD_FFF_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c deleted file mode 100644 index 23bbef0338..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dotprod_fff_armv7_a.h> - -/*! - * \param x any value - * \param pow2 must be a power of 2 - * \returns \p x rounded down to a multiple of \p pow2. - */ -static inline size_t -gr_p2_round_down(size_t x, size_t pow2) -{ - return x & -pow2; -} - - -#ifndef HAVE_MFPU_NEON - -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n) -{ - float sum = 0; - size_t i; - for (i = 0; i < n; i++){ - sum += a[i] * b[i]; - } - return sum; -} - -#else - -/* - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - */ -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n) -{ - float s = 0; - - asm ("vmov.f32 q8, #0.0 \n\t" - "vmov.f32 q9, #0.0 \n\t" - "1: \n\t" - "subs %3, %3, #8 \n\t" - "vld1.32 {d0,d1,d2,d3}, [%1]! \n\t" - "vld1.32 {d4,d5,d6,d7}, [%2]! \n\t" - "vmla.f32 q8, q0, q2 \n\t" - "vmla.f32 q9, q1, q3 \n\t" - "bgt 1b \n\t" - "vadd.f32 q8, q8, q9 \n\t" - "vpadd.f32 d0, d16, d17 \n\t" - "vadd.f32 %0, s0, s1 \n\t" - : "=w"(s), "+r"(a), "+r"(b), "+r"(n) - :: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "d16", "d17", "d18", "d19"); - - return s; - -} - -#endif diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h deleted file mode 100644 index 6cea45cea3..0000000000 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_DOTPROD_FFF_ARMV7_A_H -#define INCLUDED_DOTPROD_FFF_ARMV7_A_H - -#include <gr_core_api.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * <pre> - * - * preconditions: - * - * n > 0 and a multiple of 4 - * a 4-byte aligned - * b 16-byte aligned - * - * </pre> - */ -float -dotprod_fff_armv7_a(const float *a, const float *b, size_t n); - -#ifdef __cplusplus -} -#endif - - -#endif /* INCLUDED_DOTPROD_FFF_ARMV7_A_H */ diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S deleted file mode 100644 index a4e69461e5..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow.S +++ /dev/null @@ -1,176 +0,0 @@ -# -# Copyright 2002 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. -# - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "fcomplex_dotprod_3dnow.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_3dnow) - DEF_FUNC_HEAD(fcomplex_dotprod_3dnow) -GLOB_SYMB(fcomplex_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shrl $1, %ecx # ecx = n_2_complex_blocks / 2 - - movq 0(%eax), %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - punpckhdq %mm1, %mm1 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - - movq 8(%eax), %mm2 - - pfadd %mm3, %mm7 - - pfmul 8(%edx), %mm1 - - movq %mm2, %mm3 - punpckldq %mm2, %mm2 - punpckhdq %mm3, %mm3 - - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - - movq 16(%eax), %mm0 - - pfadd %mm1, %mm5 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - - pfmul 24(%edx), %mm3 - - punpckhdq %mm1, %mm1 - - -#TODO: add prefetch? - - addl $32, %edx - addl $16, %eax - -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - - movl 20(%ebp), %eax # result - - pfadd %mm6, %mm4 - - movq %mm4, (%eax) - femms - - popl %ebp - ret - -FUNC_TAIL(fcomplex_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S deleted file mode 100644 index 9bbf56301f..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_3dnow64.S +++ /dev/null @@ -1,170 +0,0 @@ -# -# Copyright 2002,2005 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. -# - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -#include "assembly.h" - - - .file "fcomplex_dotprod_3dnow64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_3dnow) - DEF_FUNC_HEAD(fcomplex_dotprod_3dnow) -GLOB_SYMB(fcomplex_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shr $1, %rax # rax = n_2_complex_blocks / 2 - - movq 0(%rdi), %mm0 - - pxor %mm2, %mm2 - pxor %mm3, %mm3 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - punpckhdq %mm1, %mm1 - - - jmp .L1_test - - # - # 4 taps / loop - # something like ?? cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rsi), %mm0 - pfadd %mm2, %mm6 - - movq 8(%rdi), %mm2 - - pfadd %mm3, %mm7 - - pfmul 8(%rsi), %mm1 - - movq %mm2, %mm3 - punpckldq %mm2, %mm2 - punpckhdq %mm3, %mm3 - - - pfmul 16(%rsi), %mm2 - pfadd %mm0, %mm4 - - movq 16(%rdi), %mm0 - - pfadd %mm1, %mm5 - - movq %mm0, %mm1 - punpckldq %mm0, %mm0 - - pfmul 24(%rsi), %mm3 - - punpckhdq %mm1, %mm1 - - -#TODO: add prefetch? - - add $32, %rsi - add $16, %rdi - -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_2_complex_blocks was odd. If so, we've got 2 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 2 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rsi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rsi), %mm1 - pfadd %mm1, %mm5 - - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - - movq %mm4, (%rcx) # result - femms - - retq - -FUNC_TAIL(fcomplex_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S deleted file mode 100644 index e516f0a611..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse.S +++ /dev/null @@ -1,188 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "fcomplex_dotprod_sse.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_sse) - DEF_FUNC_HEAD(fcomplex_dotprod_sse) -GLOB_SYMB(fcomplex_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax # input - movl 12(%ebp), %edx # taps - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - - movlps 0(%eax), %xmm0 - shufps $0x50, %xmm0, %xmm0 # b01010000 - - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $8, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movlps 0(%eax), %xmm0 - - movaps %xmm5, %xmm2 - movaps %xmm5, %xmm3 - - movlps 8(%eax), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - shufps $0x50, %xmm1, %xmm1 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - addps %xmm2, %xmm6 - movlps 0x10(%eax), %xmm2 - - addps %xmm3, %xmm7 - - mulps (%edx), %xmm0 - - movlps 0x18(%eax), %xmm3 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%edx), %xmm1 - - shufps $0x50, %xmm3, %xmm3 - - addps %xmm0, %xmm4 - movlps 0x20(%eax), %xmm0 - - addps %xmm1, %xmm5 - - mulps 0x20(%edx), %xmm2 - - movlps 0x28(%eax), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%edx), %xmm3 - - shufps $0x50, %xmm1, %xmm1 - - addl $0x40, %edx - addl $0x20, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movl 20(%ebp), %eax # @result - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%eax) # store low 2x32 bits (complex) to memory - - popl %ebp - ret - -FUNC_TAIL(fcomplex_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S b/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S deleted file mode 100644 index 605d87130f..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_sse64.S +++ /dev/null @@ -1,183 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_2_complex_blocks is != 0 -# -# -# fcomplex_dotprod_generic (const float *input, -# const float *taps, unsigned n_2_complex_blocks, float *result) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[0] * taps[1]; -# sum2 += input[1] * taps[2]; -# sum3 += input[1] * taps[3]; -# -# input += 2; -# taps += 4; -# -# } while (--n_2_complex_blocks != 0); -# -# -# result[0] = sum0 + sum2; -# result[1] = sum1 + sum3; -# } -# - -# TODO: prefetch and better scheduling - -#include "assembly.h" - - - .file "fcomplex_dotprod_sse64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(fcomplex_dotprod_sse) - DEF_FUNC_HEAD(fcomplex_dotprod_sse) -GLOB_SYMB(fcomplex_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx, result: rcx - - mov %rdx, %rax - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_2_complex_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - - movlps 0(%rdi), %xmm0 - shufps $0x50, %xmm0, %xmm0 # b01010000 - - mulps (%rsi), %xmm0 - add $0x10, %rsi - add $8, %rdi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shr $2, %rdx # n_2_complex_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movlps 0(%rdi), %xmm0 - - movaps %xmm5, %xmm2 - movaps %xmm5, %xmm3 - - movlps 8(%rdi), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - shufps $0x50, %xmm1, %xmm1 - - # we know rdx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - addps %xmm2, %xmm6 - movlps 0x10(%rdi), %xmm2 - - addps %xmm3, %xmm7 - - mulps (%rsi), %xmm0 - - movlps 0x18(%rdi), %xmm3 - shufps $0x50, %xmm2, %xmm2 - - mulps 0x10(%rsi), %xmm1 - - shufps $0x50, %xmm3, %xmm3 - - addps %xmm0, %xmm4 - movlps 0x20(%rdi), %xmm0 - - addps %xmm1, %xmm5 - - mulps 0x20(%rsi), %xmm2 - - movlps 0x28(%rdi), %xmm1 - shufps $0x50, %xmm0, %xmm0 - - mulps 0x30(%rsi), %xmm3 - - shufps $0x50, %xmm1, %xmm1 - - add $0x40, %rsi - add $0x20, %rdi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 2x2 partial sums. We need - # to compute a "horizontal complex add" across xmm4. - -.Lcleanup: # xmm4 = r1 i2 r3 i4 - movhlps %xmm4, %xmm0 # xmm0 = ?? ?? r1 r2 - addps %xmm4, %xmm0 # xmm0 = ?? ?? r1+r3 i2+i4 - movlps %xmm0, (%rcx) # store low 2x32 bits (complex) to memory - - retq - -FUNC_TAIL(fcomplex_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h deleted file mode 100644 index b7eddf936b..0000000000 --- a/gnuradio-core/src/lib/filter/fcomplex_dotprod_x86.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _FCOMPLEX_DOTPROD_X86_H_ -#define _FCOMPLEX_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void -fcomplex_dotprod_3dnow (const float *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -void -fcomplex_dotprod_sse (const float *input, - const float *taps, unsigned n_2_complex_blocks, float *result); - -#ifdef __cplusplus -} -#endif - -#endif /* _FCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/filter.i b/gnuradio-core/src/lib/filter/filter.i deleted file mode 100644 index 12580aa101..0000000000 --- a/gnuradio-core/src/lib/filter/filter.i +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006,2007,2009 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. - */ - -%{ -#include <gr_iir_filter_ffd.h> -#include <gr_single_pole_iir_filter_ff.h> -#include <gr_single_pole_iir_filter_cc.h> -#include <gr_hilbert_fc.h> -#include <gr_filter_delay_fc.h> -#include <gr_fft_filter_ccc.h> -#include <gr_fft_filter_fff.h> -#include <gr_fractional_interpolator_ff.h> -#include <gr_fractional_interpolator_cc.h> -#include <gr_goertzel_fc.h> -#include <gr_pfb_channelizer_ccf.h> -#include <gr_pfb_synthesizer_ccf.h> -#include <gr_pfb_decimator_ccf.h> -#include <gr_pfb_interpolator_ccf.h> -#include <gr_pfb_arb_resampler_ccf.h> -#include <gr_pfb_arb_resampler_fff.h> -#include <gr_pfb_clock_sync_ccf.h> -#include <gr_pfb_clock_sync_fff.h> -#include <gr_dc_blocker_cc.h> -#include <gr_dc_blocker_ff.h> -%} - -%include "gr_iir_filter_ffd.i" -%include "gr_single_pole_iir_filter_ff.i" -%include "gr_single_pole_iir_filter_cc.i" -%include "gr_hilbert_fc.i" -%include "gr_filter_delay_fc.i" -%include "gr_fft_filter_ccc.i" -%include "gr_fft_filter_fff.i" -%include "gr_fractional_interpolator_ff.i" -%include "gr_fractional_interpolator_cc.i" -%include "gr_goertzel_fc.i" -%include "gr_pfb_channelizer_ccf.i" -%include "gr_pfb_synthesizer_ccf.i" -%include "gr_pfb_decimator_ccf.i" -%include "gr_pfb_interpolator_ccf.i" -%include "gr_pfb_arb_resampler_ccf.i" -%include "gr_pfb_arb_resampler_fff.i" -%include "gr_pfb_decimator_ccf.i" -%include "gr_pfb_interpolator_ccf.i" -%include "gr_pfb_arb_resampler_ccf.i" -%include "gr_pfb_clock_sync_ccf.i" -%include "gr_pfb_clock_sync_fff.i" -%include "gr_dc_blocker_cc.i" -%include "gr_dc_blocker_ff.i" - -%include "filter_generated.i" diff --git a/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S b/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S deleted file mode 100644 index 914b652af5..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_3dnow.S +++ /dev/null @@ -1,152 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_3dnow.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_3dnow) - DEF_FUNC_HEAD(float_dotprod_3dnow) -GLOB_SYMB(float_dotprod_3dnow): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shrl $1, %ecx # ecx = n_4_float_blocks / 2 - movq 0(%eax), %mm0 - movq 8(%eax), %mm1 - pxor %mm2, %mm2 - pxor %mm3, %mm3 - jmp .L1_test - - # - # 8 taps / loop - # something like 6 cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%edx), %mm0 - pfadd %mm2, %mm6 - movq 16(%eax), %mm2 - - pfmul 8(%edx), %mm1 - pfadd %mm3, %mm7 - movq 24(%eax), %mm3 - - pfmul 16(%edx), %mm2 - pfadd %mm0, %mm4 - movq 32(%eax), %mm0 - - pfmul 24(%edx), %mm3 - pfadd %mm1, %mm5 - movq 40(%eax), %mm1 - - addl $32, %edx - addl $32, %eax -.L1_test: - decl %ecx - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_4_float_blocks was odd. If so, we've got 4 more - # taps to do. - - movl 16(%ebp), %ecx - pfadd %mm2, %mm6 - andl $1, %ecx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 4 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%edx), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%edx), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - pfacc %mm4, %mm4 - - movd %mm4, 16(%ebp) - femms - flds 16(%ebp) - - popl %ebp - ret - -FUNC_TAIL(float_dotprod_3dnow) - .ident "Hand coded x86 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S b/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S deleted file mode 100644 index 6670553a36..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_3dnow64.S +++ /dev/null @@ -1,149 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_3dnow64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_3dnow) - DEF_FUNC_HEAD(float_dotprod_3dnow) -GLOB_SYMB(float_dotprod_3dnow): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx - - mov %rdx, %rax - - # zero accumulators - - pxor %mm4, %mm4 # mm4 = 0 0 - pxor %mm5, %mm5 # mm5 = 0 0 - pxor %mm6, %mm6 # mm6 = 0 0 - pxor %mm7, %mm7 # mm7 = 0 0 - - shr $1, %rax # rax = n_4_float_blocks / 2 - movq 0(%rsi), %mm0 - movq 8(%rsi), %mm1 - pxor %mm2, %mm2 - pxor %mm3, %mm3 - jmp .L1_test - - # - # 8 taps / loop - # something like 6 cycles / loop - # - - .p2align 4 -.Loop1: - pfmul 0(%rdi), %mm0 - pfadd %mm2, %mm6 - movq 16(%rsi), %mm2 - - pfmul 8(%rdi), %mm1 - pfadd %mm3, %mm7 - movq 24(%rsi), %mm3 - - pfmul 16(%rdi), %mm2 - pfadd %mm0, %mm4 - movq 32(%rsi), %mm0 - - pfmul 24(%rdi), %mm3 - pfadd %mm1, %mm5 - movq 40(%rsi), %mm1 - - add $32, %rdi - add $32, %rsi -.L1_test: - dec %rax - jge .Loop1 - - # We've handled the bulk of multiplies up to here. - # Now accumulate the final two additions and see if original - # n_4_float_blocks was odd. If so, we've got 4 more - # taps to do. - - pfadd %mm2, %mm6 - and $1, %rdx - pfadd %mm3, %mm7 - je .Leven - - # The count was odd, do 4 more taps. - # Note that we've already got mm0 and mm1 preloaded - # from the main loop. - - pfmul 0(%rdi), %mm0 - pfadd %mm0, %mm4 - pfmul 8(%rdi), %mm1 - pfadd %mm1, %mm5 - -.Leven: - # at this point mm4, mm5, mm6 and mm7 contain partial sums - - pfadd %mm7, %mm6 - pfadd %mm5, %mm4 - pfadd %mm6, %mm4 - pfacc %mm4, %mm4 - - movd %mm4, -8(%rsp) - movss -8(%rsp), %xmm0 - femms - - retq - -FUNC_TAIL(float_dotprod_3dnow) - .ident "Hand coded x86_64 3DNow! assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_generic.c b/gnuradio-core/src/lib/filter/float_dotprod_generic.c deleted file mode 100644 index fb91390362..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_generic.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 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. - */ - -#include "float_dotprod_generic.h" - - -float -float_dotprod_generic (const float *input, - const float *taps, unsigned n_4_float_blocks) -{ - float sum0 = 0; - float sum1 = 0; - float sum2 = 0; - float sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_float_blocks != 0); - - - return sum0 + sum1 + sum2 + sum3; -} diff --git a/gnuradio-core/src/lib/filter/float_dotprod_generic.h b/gnuradio-core/src/lib/filter/float_dotprod_generic.h deleted file mode 100644 index dee967642a..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_generic.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _FLOAT_DOTPROD_GENERIC_H_ -#define _FLOAT_DOTPROD_GENERIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -float -float_dotprod_generic (const float *input, - const float *taps, unsigned n_4_float_blocks); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* _FLOAT_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/float_dotprod_sse.S b/gnuradio-core/src/lib/filter/float_dotprod_sse.S deleted file mode 100644 index beddc75b08..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_sse.S +++ /dev/null @@ -1,171 +0,0 @@ -# -# Copyright 2002 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_sse.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_sse) - DEF_FUNC_HEAD(float_dotprod_sse) -GLOB_SYMB(float_dotprod_sse): - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %edx - movl 12(%ebp), %eax - movl 16(%ebp), %ecx - - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_4_float_blocks % 4) - - andl $0x3, %ecx - jmp .L1_test - - .p2align 4 -.Loop1: - movaps (%eax), %xmm0 - mulps (%edx), %xmm0 - addl $0x10, %edx - addl $0x10, %eax - addps %xmm0, %xmm4 -.L1_test: - decl %ecx - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movl 16(%ebp), %ecx - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shrl $2, %ecx # n_4_float_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movaps 0x00(%eax), %xmm0 - movaps %xmm5, %xmm2 - movaps 0x10(%eax), %xmm1 - movaps %xmm5, %xmm3 - - # we know ecx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%edx), %xmm0 - addps %xmm2, %xmm6 - movaps 0x20(%eax), %xmm2 - - mulps 0x10(%edx), %xmm1 - addps %xmm3, %xmm7 - movaps 0x30(%eax), %xmm3 - - mulps 0x20(%edx), %xmm2 - addps %xmm0, %xmm4 - movaps 0x40(%eax), %xmm0 - - mulps 0x30(%edx), %xmm3 - addps %xmm1, %xmm5 - movaps 0x50(%eax), %xmm1 - - addl $0x40, %edx - addl $0x40, %eax - decl %ecx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 4 partial sums. We need - # to compute a "horizontal add" across xmm4. - # This is a fairly nasty operation... - -.Lcleanup: # xmm4 = d1 d2 d3 d4 - xorps %xmm0, %xmm0 # xmm0 = 0 0 0 0 (may be unnecessary) - movhlps %xmm4, %xmm0 # xmm0 = 0 0 d1 d2 - addps %xmm4, %xmm0 # xmm0 = d1 d2 d1+d3 d2+d4 - movaps %xmm0, %xmm1 # xmm1 = d1 d2 d1+d3 d2+d4 - shufps $0xE1, %xmm4, %xmm1 # xmm1 = d1 d2 d2+d4 d1+d3 - addss %xmm1, %xmm0 # xmm1 = d1 d2 d1+d3 d1+d2+d3+d4 - movss %xmm0, 16(%ebp) # store low 32 bits (sum) to memory - flds 16(%ebp) # and load onto FPU stack for return - - popl %ebp - ret - -FUNC_TAIL(float_dotprod_sse) - .ident "Hand coded x86 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_sse64.S b/gnuradio-core/src/lib/filter/float_dotprod_sse64.S deleted file mode 100644 index 3d425b26bf..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_sse64.S +++ /dev/null @@ -1,165 +0,0 @@ -# -# Copyright 2002,2005 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. -# - - -# input and taps are guarenteed to be 16 byte aligned. -# n_4_float_blocks is != 0 -# -# -# float -# float_dotprod_generic (const float *input, -# const float *taps, unsigned n_4_float_blocks) -# { -# float sum0 = 0; -# float sum1 = 0; -# float sum2 = 0; -# float sum3 = 0; -# -# do { -# -# sum0 += input[0] * taps[0]; -# sum1 += input[1] * taps[1]; -# sum2 += input[2] * taps[2]; -# sum3 += input[3] * taps[3]; -# -# input += 4; -# taps += 4; -# -# } while (--n_4_float_blocks != 0); -# -# -# return sum0 + sum1 + sum2 + sum3; -# } -# - -#include "assembly.h" - - - .file "float_dotprod_sse64.S" - .version "01.01" -.text - .p2align 4 -.globl GLOB_SYMB(float_dotprod_sse) - DEF_FUNC_HEAD(float_dotprod_sse) -GLOB_SYMB(float_dotprod_sse): - - # intput: rdi, taps: rsi, n_2_ccomplex_blocks: rdx - - mov %rdx, %rax - - # xmm0 xmm1 xmm2 xmm3 are used to hold taps and the result of mults - # xmm4 xmm5 xmm6 xmm7 are used to hold the accumulated results - - xorps %xmm4, %xmm4 # zero two accumulators - xorps %xmm5, %xmm5 # xmm5 holds zero for use below - - # first handle any non-zero remainder of (n_4_float_blocks % 4) - - and $0x3, %rax - jmp .L1_test - - .p2align 4 -.Loop1: - movaps (%rsi), %xmm0 - mulps (%rdi), %xmm0 - add $0x10, %rdi - add $0x10, %rsi - addps %xmm0, %xmm4 -.L1_test: - dec %rax - jge .Loop1 - - - # set up for primary loop which is unrolled 4 times - - movaps %xmm5, %xmm6 # zero remaining accumulators - movaps %xmm5, %xmm7 - - shr $2, %rdx # n_4_float_blocks / 4 - je .Lcleanup # if zero, take short path - - # finish setup and loop priming - - movaps 0x00(%rsi), %xmm0 - movaps %xmm5, %xmm2 - movaps 0x10(%rsi), %xmm1 - movaps %xmm5, %xmm3 - - # we know rdx is not zero, we checked above, - # hence enter loop at top - - .p2align 4 -.Loop2: - mulps (%rdi), %xmm0 - addps %xmm2, %xmm6 - movaps 0x20(%rsi), %xmm2 - - mulps 0x10(%rdi), %xmm1 - addps %xmm3, %xmm7 - movaps 0x30(%rsi), %xmm3 - - mulps 0x20(%rdi), %xmm2 - addps %xmm0, %xmm4 - movaps 0x40(%rsi), %xmm0 - - mulps 0x30(%rdi), %xmm3 - addps %xmm1, %xmm5 - movaps 0x50(%rsi), %xmm1 - - add $0x40, %rdi - add $0x40, %rsi - dec %rdx - jne .Loop2 - - # OK, now we've done with all the multiplies, but - # we still need to handle the unaccumulated - # products in xmm2 and xmm3 - - addps %xmm2, %xmm6 - addps %xmm3, %xmm7 - - # now we want to add all accumulators into xmm4 - - addps %xmm5, %xmm4 - addps %xmm6, %xmm7 - addps %xmm7, %xmm4 - - - # At this point, xmm4 contains 4 partial sums. We need - # to compute a "horizontal add" across xmm4. - # This is a fairly nasty operation... - -.Lcleanup: # xmm4 = d1 d2 d3 d4 - xorps %xmm0, %xmm0 # xmm0 = 0 0 0 0 (may be unnecessary) - movhlps %xmm4, %xmm0 # xmm0 = 0 0 d1 d2 - addps %xmm4, %xmm0 # xmm0 = d1 d2 d1+d3 d2+d4 - movaps %xmm0, %xmm1 # xmm1 = d1 d2 d1+d3 d2+d4 - shufps $0xE1, %xmm4, %xmm1 # xmm1 = d1 d2 d2+d4 d1+d3 - addss %xmm1, %xmm0 # xmm1 = d1 d2 d1+d3 d1+d2+d3+d4 - - retq - -FUNC_TAIL(float_dotprod_sse) - .ident "Hand coded x86_64 SSE assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/float_dotprod_x86.h b/gnuradio-core/src/lib/filter/float_dotprod_x86.h deleted file mode 100644 index fd1a2cc937..0000000000 --- a/gnuradio-core/src/lib/filter/float_dotprod_x86.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _FLOAT_DOTPROD_X86_H_ -#define _FLOAT_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -float -float_dotprod_3dnow (const float *input, - const float *taps, unsigned n_4_float_blocks); - -float -float_dotprod_sse (const float *input, - const float *taps, unsigned n_4_float_blocks); - -#ifdef __cplusplus -} -#endif - - - -#endif /* _FLOAT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h b/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h deleted file mode 100644 index 98eeb33a31..0000000000 --- a/gnuradio-core/src/lib/filter/gcc_x86_cpuid.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. - * - * This file 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. - * - * This file 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. - * - * Under Section 7 of GPL version 3, you are granted additional - * permissions described in the GCC Runtime Library Exception, version - * 3.1, as published by the Free Software Foundation. - * - * You should have received a copy of the GNU General Public License and - * a copy of the GCC Runtime Library Exception along with this program; - * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - * <http://www.gnu.org/licenses/>. - */ - -/* %ecx */ -#define bit_SSE3 (1 << 0) -#define bit_PCLMUL (1 << 1) -#define bit_SSSE3 (1 << 9) -#define bit_FMA (1 << 12) -#define bit_CMPXCHG16B (1 << 13) -#define bit_SSE4_1 (1 << 19) -#define bit_SSE4_2 (1 << 20) -#define bit_MOVBE (1 << 22) -#define bit_POPCNT (1 << 23) -#define bit_AES (1 << 25) -#define bit_XSAVE (1 << 26) -#define bit_OSXSAVE (1 << 27) -#define bit_AVX (1 << 28) - -/* %edx */ -#define bit_CMPXCHG8B (1 << 8) -#define bit_CMOV (1 << 15) -#define bit_MMX (1 << 23) -#define bit_FXSAVE (1 << 24) -#define bit_SSE (1 << 25) -#define bit_SSE2 (1 << 26) - -/* Extended Features */ -/* %ecx */ -#define bit_LAHF_LM (1 << 0) -#define bit_SSE4a (1 << 6) -#define bit_SSE5 (1 << 11) - -/* %edx */ -#define bit_LM (1 << 29) -#define bit_3DNOWP (1 << 30) -#define bit_3DNOW (1 << 31) - - -#if defined(__i386__) && defined(__PIC__) -/* %ebx may be the PIC register. */ -#if __GNUC__ >= 3 -#define __cpuid(level, a, b, c, d) \ - __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchg{l}\t{%%}ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchg{l}\t{%%}ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#else -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax - nor alternatives in i386 code. */ -#define __cpuid(level, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#endif -#else -#define __cpuid(level, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - -#define __cpuid_count(level, count, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level), "2" (count)) -#endif - -/* Return highest supported input value for cpuid instruction. ext can - be either 0x0 or 0x8000000 to return highest supported value for - basic or extended cpuid information. Function returns 0 if cpuid - is not supported or whatever cpuid returns in eax register. If sig - pointer is non-null, then first four bytes of the signature - (as found in ebx register) are returned in location pointed by sig. */ - -static __inline unsigned int -__get_cpuid_max (unsigned int __ext, unsigned int *__sig) -{ - unsigned int __eax, __ebx, __ecx, __edx; - -#ifndef __x86_64__ -#if __GNUC__ >= 3 - /* See if we can use cpuid. On AMD64 we always can. */ - __asm__ ("pushf{l|d}\n\t" - "pushf{l|d}\n\t" - "pop{l}\t%0\n\t" - "mov{l}\t{%0, %1|%1, %0}\n\t" - "xor{l}\t{%2, %0|%0, %2}\n\t" - "push{l}\t%0\n\t" - "popf{l|d}\n\t" - "pushf{l|d}\n\t" - "pop{l}\t%0\n\t" - "popf{l|d}\n\t" - : "=&r" (__eax), "=&r" (__ebx) - : "i" (0x00200000)); -#else -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax - nor alternatives in i386 code. */ - __asm__ ("pushfl\n\t" - "pushfl\n\t" - "popl\t%0\n\t" - "movl\t%0, %1\n\t" - "xorl\t%2, %0\n\t" - "pushl\t%0\n\t" - "popfl\n\t" - "pushfl\n\t" - "popl\t%0\n\t" - "popfl\n\t" - : "=&r" (__eax), "=&r" (__ebx) - : "i" (0x00200000)); -#endif - - if (!((__eax ^ __ebx) & 0x00200000)) - return 0; -#endif - - /* Host supports cpuid. Return highest supported cpuid input value. */ - __cpuid (__ext, __eax, __ebx, __ecx, __edx); - - if (__sig) - *__sig = __ebx; - - return __eax; -} - -/* Return cpuid data for requested cpuid level, as found in returned - eax, ebx, ecx and edx registers. The function checks if cpuid is - supported and returns 1 for valid cpuid information or 0 for - unsupported cpuid level. All pointers are required to be non-null. */ - -static __inline int -__get_cpuid (unsigned int __level, - unsigned int *__eax, unsigned int *__ebx, - unsigned int *__ecx, unsigned int *__edx) -{ - unsigned int __ext = __level & 0x80000000; - - if (__get_cpuid_max (__ext, 0) < __level) - return 0; - - __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); - return 1; -} diff --git a/gnuradio-core/src/lib/filter/generate_all.py b/gnuradio-core/src/lib/filter/generate_all.py deleted file mode 100755 index 1da9f7209a..0000000000 --- a/gnuradio-core/src/lib/filter/generate_all.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2003 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. -# - -from build_utils import output_glue - -import generate_gr_fir_filter_XXX -import generate_gr_interp_fir_filter_XXX -import generate_gr_rational_resampler_base_XXX -import generate_gr_freq_xlating_fir_filter_XXX -import generate_gr_fir_sysconfig_generic -import generate_gr_fir_sysconfig -import generate_gr_fir_util -import generate_gr_fir_XXX -import generate_gri_fir_filter_with_buffer_XXX - -def generate_all(): - generate_gr_fir_XXX.generate() - generate_gr_fir_filter_XXX.generate() - generate_gr_interp_fir_filter_XXX.generate() - generate_gr_rational_resampler_base_XXX.generate() - generate_gr_freq_xlating_fir_filter_XXX.generate() - generate_gr_fir_sysconfig_generic.generate() - generate_gr_fir_sysconfig.generate() - generate_gr_fir_util.generate() - generate_gri_fir_filter_with_buffer_XXX.generate() - output_glue('filter') - -if __name__ == '__main__': - generate_all() diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py deleted file mode 100755 index cf37fbb24d..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003 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. -# - -import re -from generate_utils import * - -roots = ['gr_fir_XXX', 'gr_fir_XXX_generic'] - - -# figure out accumulator type. Use biggest of input, output and tap type - -def code3_to_acc_code (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c': - return 'c' - if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f': - return 'f' - if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i': - return 'i' - return 'i' # even short short short needs int accumulator - - -def code3_to_input_cast (code3): - if i_code (code3) == 's' and o_code (code3) == 'c': - return '(float)' - return '' - -def expand_h_cc (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - d['INPUT_CAST'] = code3_to_input_cast (code3) - acc_code = code3_to_acc_code (code3) - d['ACC_TYPE'] = char_to_type[acc_code] - if acc_code == 'c': - d['N_UNROLL'] = '2' - d['VRCOMPLEX_INCLUDE'] = '#include <gr_types.h>' - else: - d['N_UNROLL'] = '4' - d['VRCOMPLEX_INCLUDE'] = '' - return d - - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py deleted file mode 100755 index 50cc586e59..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 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. -# - -import re -from generate_utils import * - -roots = ['gr_fir_filter_XXX'] - - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py b/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py deleted file mode 100755 index 50d819fd18..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2009 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. -# - -from generate_utils import * - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_h (): - out = open_and_log_name ('gr_fir_sysconfig.h', 'w') - if not out: - return - - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py - * Any changes made to this file will be overwritten. - */ - -#ifndef INCLUDED_GR_FIR_SYSCONFIG_H -#define INCLUDED_GR_FIR_SYSCONFIG_H - -#include <gr_types.h> - -''') - - # for sig in fir_signatures: - # out.write ('class gr_fir_' + sig + ';\n') - - out.write ('#include <gr_fir_util.h>\n') - - out.write ( -''' -/*! - * \\brief abstract base class for configuring the automatic selection of the - * fastest gr_fir for your platform. - * - * This is used internally by gr_fir_util. - */ - -class gr_fir_sysconfig { -public: - virtual ~gr_fir_sysconfig (); - -''') - - for sig in fir_signatures: - out.write ((' virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps) = 0;\n' % - (sig, sig, tap_type (sig)))) - - out.write ('\n') - - for sig in fir_signatures: - out.write ((' virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) = 0;\n' % - (sig, sig))) - - out.write ( -''' -}; - -/* - * This returns the single instance of the appropriate derived class. - * This function must be defined only once in the system, and should be defined - * in the platform specific code. - */ - -gr_fir_sysconfig *gr_fir_sysconfig_singleton (); - - -#endif /* INCLUDED_GR_FIR_SYSCONFIG_H */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_cc (): - out = open_and_log_name ('gr_fir_sysconfig.cc', 'w') - if not out: - return - - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by generate_gr_fir_sysconfig.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig.h> - -gr_fir_sysconfig::~gr_fir_sysconfig () -{ -} -''') - out.close () - - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_sysconfig_h () - make_gr_fir_sysconfig_cc () - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py b/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py deleted file mode 100755 index dcbadd30f7..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2009 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. -# - -from generate_utils import * - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_generic_h (): - out = open_and_log_name ('gr_fir_sysconfig_generic.h', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_sysconfig_generic.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifndef _GR_FIR_SYSCONFIG_GENERIC_H_ -#define _GR_FIR_SYSCONFIG_GENERIC_H_ - -#include <gr_fir_sysconfig.h> - -''') - - out.write ( -''' -class gr_fir_sysconfig_generic : public gr_fir_sysconfig { -public: -''') - - for sig in fir_signatures: - out.write ((' virtual gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps);\n' % - (sig, sig, tap_type (sig)))) - - out.write ('\n') - - for sig in fir_signatures: - out.write ((' virtual void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info);\n' % - (sig, sig))) - - out.write ( -''' -}; - - -#endif /* _GR_FIR_SYSCONFIG_GENERIC_H_ */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_constructor (sig, out): - out.write (''' -static gr_fir_%s * -make_gr_fir_%s (const std::vector<%s> &taps) -{ - return new gr_fir_%s_generic (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_creator (sig, out): - out.write (''' -gr_fir_%s * -gr_fir_sysconfig_generic::create_gr_fir_%s (const std::vector<%s> &taps) -{ - return make_gr_fir_%s (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_info (sig, out): - out.write (''' -void -gr_fir_sysconfig_generic::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) -{ - info->resize (1); - (*info)[0].name = "generic"; - (*info)[0].create = make_gr_fir_%s; -} -''' % (sig, sig, sig)) - - -# ---------------------------------------------------------------- - -def make_gr_fir_sysconfig_generic_cc (): - out = open_and_log_name ('gr_fir_sysconfig_generic.cc', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_sysconfig_generic.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_sysconfig_generic.h> - -''') - - for sig in fir_signatures: - out.write ('#include <gr_fir_%s_generic.h>\n' % (sig)) - - out.write ( -''' -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors returned by info - * ---------------------------------------------------------------- - */ -''') - - for sig in fir_signatures: - make_constructor (sig, out) - - out.write ( -''' -/* - * ---------------------------------------------------------------- - * return instances of the generic C++ versions of these classes. - * ---------------------------------------------------------------- - */ -''') - - for sig in fir_signatures: - make_creator (sig, out) - - out.write ( -''' -/* - * Return info about available implementations. - * - * This is the bottom of the concrete hierarchy, so we set the - * size of the vector to 1, and install our info. Classes derived - * from us invoke us first, then append their own info. - */ -''') - - for sig in fir_signatures: - make_info (sig, out) - - - out.close () - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_sysconfig_generic_h () - make_gr_fir_sysconfig_generic_cc () - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py b/gnuradio-core/src/lib/filter/generate_gr_fir_util.py deleted file mode 100755 index 79fa51c278..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_fir_util.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/env python -# -# Copyright 2003,2009 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. -# - -from generate_utils import * - -def make_info_struct (out, sig): - out.write ( -''' -struct GR_CORE_API gr_fir_%s_info { - const char *name; // implementation name, e.g., "generic", "SSE", "3DNow!" - gr_fir_%s *(*create)(const std::vector<%s> &taps); -}; -''' % (sig, sig, tap_type(sig))) - -def make_create (out, sig): - out.write (''' static gr_fir_%s *create_gr_fir_%s (const std::vector<%s> &taps); -''' % (sig, sig, tap_type (sig))) - -def make_info (out, sig): - out.write (''' static void get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info); -''' % (sig, sig)) - - -# ---------------------------------------------------------------- - -def make_gr_fir_util_h (): - out = open_and_log_name ('gr_fir_util.h', 'w') - if not out: - return - out.write (copyright) - - out.write ( -''' -/* - * WARNING: This file is automatically generated by - * generate_gr_fir_util.py. - * - * Any changes made to this file will be overwritten. - */ - -#ifndef INCLUDED_GR_FIR_UTIL_H -#define INCLUDED_GR_FIR_UTIL_H - -/*! - * \\brief routines to create gr_fir_XXX's - * - * This class handles selecting the fastest version of the finite - * implulse response filter available for your platform. This - * interface should be used by the rest of the system for creating - * gr_fir_XXX's. - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), - * 'i' (short) - */ - -#include <gr_core_api.h> -#include <gr_types.h> - -''') - - for sig in fir_signatures: - out.write ('class gr_fir_%s;\n' % sig); - - out.write ('\n// structures returned by get_gr_fir_XXX_info methods\n\n') - - for sig in fir_signatures: - make_info_struct (out, sig) - - out.write (''' -struct GR_CORE_API gr_fir_util { - - // create a fast version of gr_fir_XXX. - -''') - - for sig in fir_signatures: - make_create (out, sig) - - out.write (''' - // Get information about all gr_fir_XXX implementations. - // This is useful for benchmarking, testing, etc without having to - // know a priori what's linked into this image - // - // The caller must pass in a valid pointer to a vector. - // The vector will be filled with structs describing the - // available implementations. - -''') - - for sig in fir_signatures: - make_info (out, sig) - - out.write (''' -}; - -#endif /* INCLUDED_GR_FIR_UTIL_H */ -''') - out.close () - - -# ---------------------------------------------------------------- - -def make_constructor_cc (out, sig): - out.write ( -''' -gr_fir_%s * -gr_fir_util::create_gr_fir_%s (const std::vector<%s> &taps) -{ - return gr_fir_sysconfig_singleton()->create_gr_fir_%s (taps); -} -''' % (sig, sig, tap_type (sig), sig)) - - -def make_info_cc (out, sig): - out.write ( -''' -void -gr_fir_util::get_gr_fir_%s_info (std::vector<gr_fir_%s_info> *info) -{ - gr_fir_sysconfig_singleton()->get_gr_fir_%s_info (info); -} -''' % (sig, sig, sig)) - - -def make_gr_fir_util_cc (): - out = open_and_log_name ('gr_fir_util.cc', 'w') - if not out: - return - out.write (copyright) - out.write (''' - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_util.h> -#include <gr_fir_sysconfig.h> - -// -// There's no problem that can't be solved by the addition of -// another layer of indirection... -// - -// --- constructors --- - -''') - - for sig in fir_signatures: - make_constructor_cc (out, sig) - - out.write (''' -// --- info gatherers --- - -''') - - for sig in fir_signatures: - make_info_cc (out, sig) - - out.close () - - -# ---------------------------------------------------------------- - -def generate (): - make_gr_fir_util_h () - make_gr_fir_util_cc () - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py deleted file mode 100755 index 41c0b2b70c..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 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. -# - -import re -from generate_utils import * - -# files to generate - -fx_signatures = [ 'scf', 'scc', 'fcf', 'fcc', 'ccf', 'ccc' ] - -roots = ['gr_freq_xlating_fir_filter_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + i_code (code3) + 'cc' - return d - - -def generate (): - for r in roots: - for s in fx_signatures: - expand_h_cc_i (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py deleted file mode 100644 index 1dcfdadede..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 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. -# - -import re -from generate_utils import * - -roots = ['gr_interp_fir_filter_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py b/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py deleted file mode 100644 index 1dafec3fbe..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/env python -# -*- python -*- -# -# Copyright 2003,2004 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. -# - -import re -from generate_utils import * - -roots = ['gr_rational_resampler_base_XXX'] - -def expand_h_cc_i (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['FIR_TYPE'] = 'gr_fir_' + code3 - return d - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - diff --git a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py deleted file mode 100755 index 6442fb3dc2..0000000000 --- a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- python -*- -# -# Copyright 2010 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. -# - -import re -from generate_utils import * - -roots = ['gri_fir_filter_with_buffer_XXX',] - -def code3_to_acc_code (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c': - return 'c' - if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f': - return 'f' - if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i': - return 'i' - return 'i' # even short short short needs int accumulator - -def code3_to_input_cast (code3): - if i_code (code3) == 's' and o_code (code3) == 'c': - return '(float)' - return '' - -def expand_h_cc (root, code3): - d = init_dict (root, code3) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - -def init_dict (root, code3): - name = re.sub ('X+', code3, root) - d = standard_dict (name, code3) - d['INPUT_CAST'] = code3_to_input_cast (code3) - acc_code = code3_to_acc_code (code3) - d['ACC_TYPE'] = char_to_type[acc_code] - return d - - -def generate (): - for r in roots: - for s in fir_signatures: - expand_h_cc (r, s) - - -if __name__ == '__main__': - generate () diff --git a/gnuradio-core/src/lib/filter/generate_utils.py b/gnuradio-core/src/lib/filter/generate_utils.py deleted file mode 100644 index 212ea95f9c..0000000000 --- a/gnuradio-core/src/lib/filter/generate_utils.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright 2003,2005 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. -# - -## ----------------------------------------------------------------------- -## signatures defines which variations to generate (input, output, taps) - -fir_signatures = [ 'ccf', 'fcc', 'ccc', 'fff', 'scc', 'fsf' ] - - -## ----------------------------------------------------------------------- - -from build_utils import expand_template, copyright, open_and_log_name, standard_dict -from build_utils_codes import * diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc deleted file mode 100644 index da407caa0c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <gr_adaptive_fir_ccc.h> -#include <gr_io_signature.h> - -gr_adaptive_fir_ccc::gr_adaptive_fir_ccc(const char *name, int decimation, - const std::vector<gr_complex> &taps) - : gr_sync_decimator (name, - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - decimation), - d_updated(false), d_taps(taps) -{ - set_history(d_taps.size()); -} - -void -gr_adaptive_fir_ccc::set_taps(const std::vector<gr_complex> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -gr_complex -gr_adaptive_fir_ccc::filter(gr_complex *x) -{ - // Generic dot product of d_taps[] and in[] - gr_complex acc(0.0, 0.0); - int l = d_taps.size(); - for (int k = 0; k < l; k++) - acc += d_taps[l-k-1] * x[k]; - return acc; -} - -int -gr_adaptive_fir_ccc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - if (d_updated) { - d_taps = d_new_taps; - set_history(d_taps.size()); - d_updated = false; - return 0; // history requirements may have changed. - } - - int j = 0, k, l = d_taps.size(); - for (int i = 0; i < noutput_items; i++) { - out[i] = filter(&in[j]); - - // Adjust taps - d_error = error(out[i]); - for (k = 0; k < l; k++) { - update_tap(d_taps[l-k-1], in[j+k]); - } - - j += decimation(); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h deleted file mode 100644 index d144c3eb46..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_GR_ADAPTIVE_FIR_CCC_H -#define INCLUDED_GR_ADAPTIVE_FIR_CCC_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -/*! - * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_adaptive_fir_ccc : public gr_sync_decimator -{ -private: - std::vector<gr_complex> d_new_taps; - bool d_updated; - -protected: - gr_complex d_error; - std::vector<gr_complex> d_taps; - - // Override to calculate error signal per output - virtual gr_complex error(const gr_complex &out) = 0; - - // Override to calculate new weight from old, corresponding input - virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; - - gr_complex filter(gr_complex *x); - - gr_adaptive_fir_ccc(const char *name, int decimation, - const std::vector<gr_complex> &taps); - -public: - void set_taps(const std::vector<gr_complex> &taps); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i deleted file mode 100644 index a3c875a3dc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -class gr_adaptive_fir_ccc : public gr_sync_decimator -{ -protected: - gr_adaptive_fir_ccc(char *name, int decimation, - const std::vector<gr_complex> &taps); - -public: - void set_taps(const std::vector<gr_complex> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc deleted file mode 100644 index 045d9faf92..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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 <gr_adaptive_fir_ccf.h> -#include <gr_io_signature.h> - -gr_adaptive_fir_ccf::gr_adaptive_fir_ccf(const char *name, int decimation, const std::vector<float> &taps) - : gr_sync_decimator (name, - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - decimation), - d_updated(false) -{ - d_taps = taps; - set_history(d_taps.size()); -} - -void gr_adaptive_fir_ccf::set_taps(const std::vector<float> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -int gr_adaptive_fir_ccf::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - if (d_updated) { - d_taps = d_new_taps; - set_history(d_taps.size()); - d_updated = false; - return 0; // history requirements may have changed. - } - - int j = 0, k, l = d_taps.size(); - for (int i = 0; i < noutput_items; i++) { - // Generic dot product of d_taps[] and in[] - gr_complex sum(0.0, 0.0); - for (k = 0; k < l; k++) - sum += d_taps[l-k-1]*in[j+k]; - out[i] = sum; - - // Adjust taps - d_error = error(sum); - for (k = 0; k < l; k++) { - //printf("%f ", d_taps[k]); - update_tap(d_taps[l-k-1], in[j+k]); - } - //printf("\n"); - - j += decimation(); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h deleted file mode 100644 index 7ec78099f8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_GR_ADAPTIVE_FIR_CCF_H -#define INCLUDED_GR_ADAPTIVE_FIR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -/*! - * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_adaptive_fir_ccf : public gr_sync_decimator -{ -private: - std::vector<float> d_new_taps; - bool d_updated; - -protected: - float d_error; - std::vector<float> d_taps; - - // Override to calculate error signal per output - virtual float error(const gr_complex &out) = 0; - - // Override to calculate new weight from old, corresponding input - virtual void update_tap(float &tap, const gr_complex &in) = 0; - - gr_adaptive_fir_ccf(const char *name, int decimation, const std::vector<float> &taps); - -public: - void set_taps(const std::vector<float> &taps); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i deleted file mode 100644 index 346defd4d1..0000000000 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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. - */ - -class gr_adaptive_fir_ccf : public gr_sync_decimator -{ -protected: - gr_adaptive_fir_ccf(char *name, int decimation, const std::vector<float> &taps); - -public: - void set_taps(const std::vector<float> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_altivec.c b/gnuradio-core/src/lib/filter/gr_altivec.c deleted file mode 100644 index 22a67291d4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_altivec.c +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <gr_altivec.h> - -void -gr_print_vector_float(FILE *fp, vec_float4 v) -{ - union v_float_u u; - u.v = v; - fprintf(fp, "{ %f, %f, %f, %f }", u.f[0], u.f[1], u.f[2], u.f[3]); -} - -void -gr_pvf(FILE *fp, const char *label, vec_float4 v) -{ - fprintf(fp, "%s = ", label); - gr_print_vector_float(fp, v); - putc('\n', fp); -} diff --git a/gnuradio-core/src/lib/filter/gr_altivec.h b/gnuradio-core/src/lib/filter/gr_altivec.h deleted file mode 100644 index ed11490f58..0000000000 --- a/gnuradio-core/src/lib/filter/gr_altivec.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_ALTIVEC_H -#define INCLUDED_GR_ALTIVEC_H - -/* - * N.B., always use "vec_float4" et al. instead of "vector float" to - * ensure portability across the various powerpc compilers. Some of - * them treat "vector" as a context specific keyword, some don't. - * Avoid the problem by always using the defines in vec_types.h - * (included below) - */ - -#include <gr_core_api.h> -#include <altivec.h> -#undef bool // repair namespace pollution -#undef vector // repair namespace pollution - -#ifdef HAVE_VEC_TYPES_H -#include <vec_types.h> // use system version if we've got it -#else -#include <gr_vec_types.h> // fall back to our local copy -#endif -#undef qword // repair namespace pollution - -#include <stddef.h> -#include <stdio.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define VS sizeof(vec_float4) -#define FLOATS_PER_VEC (sizeof(vec_float4)/sizeof(float)) - -union v_float_u { - vec_float4 v; - float f[FLOATS_PER_VEC]; -}; - -GR_CORE_API void gr_print_vector_float(FILE *fp, vec_float4 v); -GR_CORE_API void gr_pvf(FILE *fp, const char *label, vec_float4 v); - -static inline float -horizontal_add_f(vec_float4 v) -{ - union v_float_u u; - vec_float4 t0 = vec_add(v, vec_sld(v, v, 8)); - vec_float4 t1 = vec_add(t0, vec_sld(t0, t0, 4)); - u.v = t1; - return u.f[0]; -} - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_GR_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_cpu.h b/gnuradio-core/src/lib/filter/gr_cpu.h deleted file mode 100644 index 35824ac1ee..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 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 _GR_CPU_H_ -#define _GR_CPU_H_ - -#include <gr_core_api.h> - -struct GR_CORE_API gr_cpu { - static bool has_mmx (); - static bool has_sse (); - static bool has_sse2 (); - static bool has_sse3 (); - static bool has_ssse3 (); - static bool has_sse4_1 (); - static bool has_sse4_2 (); - static bool has_3dnow (); - static bool has_3dnowext (); - static bool has_altivec (); - static bool has_armv7_a (); -}; - -#endif /* _GR_CPU_H_ */
\ No newline at end of file diff --git a/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc deleted file mode 100644 index 2450492066..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_armv7_a.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 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. - */ - -#include <gr_cpu.h> - -bool -gr_cpu::has_mmx () -{ - return false; -} - -bool -gr_cpu::has_sse () -{ - return false; -} - -bool -gr_cpu::has_sse2 () -{ - return false; -} - -bool -gr_cpu::has_3dnow () -{ - return false; -} - -bool -gr_cpu::has_3dnowext () -{ - return false; -} - -bool -gr_cpu::has_altivec () -{ - return false; -} - -bool -gr_cpu::has_armv7_a () -{ - return true; -} diff --git a/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc b/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc deleted file mode 100644 index d613f0ae45..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_powerpc.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 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. - */ - -#include <gr_cpu.h> - -bool -gr_cpu::has_mmx () -{ - return false; -} - -bool -gr_cpu::has_sse () -{ - return false; -} - -bool -gr_cpu::has_sse2 () -{ - return false; -} - -bool -gr_cpu::has_3dnow () -{ - return false; -} - -bool -gr_cpu::has_3dnowext () -{ - return false; -} - -bool -gr_cpu::has_altivec () -{ - return true; // FIXME assume we've always got it -} - -bool -gr_cpu::has_armv7_a () -{ - return false; -} diff --git a/gnuradio-core/src/lib/filter/gr_cpu_x86.cc b/gnuradio-core/src/lib/filter/gr_cpu_x86.cc deleted file mode 100644 index 3acd694d55..0000000000 --- a/gnuradio-core/src/lib/filter/gr_cpu_x86.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2009 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. - */ - -#include <gr_cpu.h> -#include "gcc_x86_cpuid.h" - -/* - * execute CPUID instruction, return EAX, EBX, ECX and EDX values in result - */ -#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3) - -/* - * CPUID functions returning a single datum - */ - -static inline unsigned int cpuid_eax(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[0]; -} - -static inline unsigned int cpuid_ebx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[1]; -} - -static inline unsigned int cpuid_ecx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[2]; -} - -static inline unsigned int cpuid_edx(unsigned int op) -{ - unsigned int regs[4] = {0,0,0,0}; - cpuid_x86 (op, regs); - return regs[3]; -} - -// ---------------------------------------------------------------- - -bool -gr_cpu::has_mmx () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 23)) != 0; -} - -bool -gr_cpu::has_sse () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 25)) != 0; -} - -bool -gr_cpu::has_sse2 () -{ - unsigned int edx = cpuid_edx (1); // standard features - return (edx & (1 << 26)) != 0; -} - -bool -gr_cpu::has_3dnow () -{ - unsigned int extended_fct_count = cpuid_eax (0x80000000); - if (extended_fct_count < 0x80000001) - return false; - - unsigned int extended_features = cpuid_edx (0x80000001); - return (extended_features & (1 << 31)) != 0; -} - -bool -gr_cpu::has_3dnowext () -{ - unsigned int extended_fct_count = cpuid_eax (0x80000000); - if (extended_fct_count < 0x80000001) - return false; - - unsigned int extended_features = cpuid_edx (0x80000001); - return (extended_features & (1 << 30)) != 0; -} - -bool -gr_cpu::has_altivec () -{ - return false; -} - -bool -gr_cpu::has_armv7_a () -{ - return false; -} - diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc deleted file mode 100644 index 0438a193fa..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <gr_dc_blocker_cc.h> -#include <gr_io_signature.h> -#include <cstdio> - -moving_averager_c::moving_averager_c(int D) - : d_length(D), d_out(0), d_out_d1(0), d_out_d2(0) -{ - d_delay_line = std::deque<gr_complex>(d_length-1, gr_complex(0,0)); -} - -moving_averager_c::~moving_averager_c() -{ -} - -gr_complex -moving_averager_c::filter(gr_complex x) -{ - d_out_d1 = d_out; - d_delay_line.push_back(x); - d_out = d_delay_line[0]; - d_delay_line.pop_front(); - - gr_complex y = x - d_out_d1 + d_out_d2; - d_out_d2 = y; - - return (y / (float)(d_length)); -} - - - -gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form) -{ - return gnuradio::get_initial_sptr(new gr_dc_blocker_cc(D, long_form)); -} - - -gr_dc_blocker_cc::gr_dc_blocker_cc (int D, bool long_form) - : gr_sync_block ("dc_blocker_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_length(D), d_long_form(long_form) -{ - if(d_long_form) { - d_ma_0 = new moving_averager_c(D); - d_ma_1 = new moving_averager_c(D); - d_ma_2 = new moving_averager_c(D); - d_ma_3 = new moving_averager_c(D); - d_delay_line = std::deque<gr_complex>(d_length-1, gr_complex(0,0)); - } - else { - d_ma_0 = new moving_averager_c(D); - d_ma_1 = new moving_averager_c(D); - } -} - -gr_dc_blocker_cc::~gr_dc_blocker_cc() -{ - if(d_long_form) { - delete d_ma_0; - delete d_ma_1; - delete d_ma_2; - delete d_ma_3; - } - else { - delete d_ma_0; - delete d_ma_1; - } -} - -int -gr_dc_blocker_cc::get_group_delay() -{ - if(d_long_form) - return (2*d_length-2); - else - return d_length - 1; -} - -int -gr_dc_blocker_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - gr_complex *out = (gr_complex*)output_items[0]; - - if(d_long_form) { - gr_complex y1, y2, y3, y4, d; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - y3 = d_ma_2->filter(y2); - y4 = d_ma_3->filter(y3); - - d_delay_line.push_back(d_ma_0->delayed_sig()); - d = d_delay_line[0]; - d_delay_line.pop_front(); - - out[i] = d - y4; - } - } - else { - gr_complex y1, y2; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - out[i] = d_ma_0->delayed_sig() - y2; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h deleted file mode 100644 index e4d89a775c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_GR_DC_BLOCKER_CC_H -#define INCLUDED_GR_DC_BLOCKER_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <deque> - -class GR_CORE_API moving_averager_c -{ -public: - moving_averager_c(int D); - ~moving_averager_c(); - - gr_complex filter(gr_complex x); - gr_complex delayed_sig() { return d_out; } - -private: - int d_length; - gr_complex d_out, d_out_d1, d_out_d2; - std::deque<gr_complex> d_delay_line; -}; - -class gr_dc_blocker_cc; -typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr; -GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); - -/*! - * \class gr_dc_blocker_cc - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> - */ -class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block -{ - private: - /*! - * Build the DC blocker. - * \param D (int) the length of the delay line - * \param long_form (bool) whether to use long (true, default) or short form - */ - friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); - - int d_length; - bool d_long_form; - moving_averager_c *d_ma_0; - moving_averager_c *d_ma_1; - moving_averager_c *d_ma_2; - moving_averager_c *d_ma_3; - std::deque<gr_complex> d_delay_line; - - gr_dc_blocker_cc (int D, bool long_form); - -public: - ~gr_dc_blocker_cc (); - - /*! - * Get the blocker's group delay that is based on length of delay lines - */ - int get_group_delay(); - - //int set_length(int D); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i deleted file mode 100644 index 83d05044b8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,dc_blocker_cc); - -gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); - -class gr_dc_blocker_cc : public gr_sync_block -{ - private: - gr_dc_blocker_cc (int D, bool long_form); - - public: - ~gr_dc_blocker_cc (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc deleted file mode 100644 index 04ee648797..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <gr_dc_blocker_ff.h> -#include <gr_io_signature.h> -#include <cstdio> - -moving_averager_f::moving_averager_f(int D) - : d_length(D), d_out(0), d_out_d1(0), d_out_d2(0) -{ - d_delay_line = std::deque<float>(d_length-1, 0); -} - -moving_averager_f::~moving_averager_f() -{ -} - -float -moving_averager_f::filter(float x) -{ - d_out_d1 = d_out; - d_delay_line.push_back(x); - d_out = d_delay_line[0]; - d_delay_line.pop_front(); - - float y = x - d_out_d1 + d_out_d2; - d_out_d2 = y; - - return (y / (float)(d_length)); -} - - - -gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form) -{ - return gnuradio::get_initial_sptr(new gr_dc_blocker_ff(D, long_form)); -} - - -gr_dc_blocker_ff::gr_dc_blocker_ff (int D, bool long_form) - : gr_sync_block ("dc_blocker_ff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (1, 1, sizeof(float))), - d_length(D), d_long_form(long_form) -{ - if(d_long_form) { - d_ma_0 = new moving_averager_f(D); - d_ma_1 = new moving_averager_f(D); - d_ma_2 = new moving_averager_f(D); - d_ma_3 = new moving_averager_f(D); - d_delay_line = std::deque<float>(d_length-1, 0); - } - else { - d_ma_0 = new moving_averager_f(D); - d_ma_1 = new moving_averager_f(D); - } -} - -gr_dc_blocker_ff::~gr_dc_blocker_ff() -{ - if(d_long_form) { - delete d_ma_0; - delete d_ma_1; - delete d_ma_2; - delete d_ma_3; - } - else { - delete d_ma_0; - delete d_ma_1; - } -} - -int -gr_dc_blocker_ff::get_group_delay() -{ - if(d_long_form) - return (2*d_length-2); - else - return d_length - 1; -} - -int -gr_dc_blocker_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float*)input_items[0]; - float *out = (float*)output_items[0]; - - if(d_long_form) { - float y1, y2, y3, y4, d; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - y3 = d_ma_2->filter(y2); - y4 = d_ma_3->filter(y3); - - d_delay_line.push_back(d_ma_0->delayed_sig()); - d = d_delay_line[0]; - d_delay_line.pop_front(); - - out[i] = d - y4; - } - } - else { - float y1, y2; - for(int i = 0; i < noutput_items; i++) { - y1 = d_ma_0->filter(in[i]); - y2 = d_ma_1->filter(y1); - out[i] = d_ma_0->delayed_sig() - y2; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h deleted file mode 100644 index d69f24835b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_GR_DC_BLOCKER_FF_H -#define INCLUDED_GR_DC_BLOCKER_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <deque> - -class GR_CORE_API moving_averager_f -{ -public: - moving_averager_f(int D); - ~moving_averager_f(); - - float filter(float x); - float delayed_sig() { return d_out; } - -private: - int d_length; - float d_out, d_out_d1, d_out_d2; - std::deque<float> d_delay_line; -}; - - -class gr_dc_blocker_ff; -typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr; -GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); - -/*! - * \class gr_dc_blocker_ff - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> - */ -class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block -{ - private: - /*! - * Build the DC blocker. - * \param D (int) the length of the delay line - * \param long_form (bool) whether to use long (true, default) or short form - */ - friend GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); - - int d_length; - bool d_long_form; - moving_averager_f *d_ma_0; - moving_averager_f *d_ma_1; - moving_averager_f *d_ma_2; - moving_averager_f *d_ma_3; - std::deque<float> d_delay_line; - - gr_dc_blocker_ff (int D, bool long_form); - -public: - ~gr_dc_blocker_ff (); - - /*! - * Get the blocker's group delay that is based on length of delay lines - */ - int get_group_delay(); - - //int set_length(int D); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i deleted file mode 100644 index 065eb441d6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,dc_blocker_ff); - -gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); - -class gr_dc_blocker_ff : public gr_sync_block -{ - private: - gr_dc_blocker_ff (int D, bool long_form); - - public: - ~gr_dc_blocker_ff (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc deleted file mode 100644 index 08e231a442..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fft_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fft_filter_ccc.h> -#include <gri_fft_filter_ccc_generic.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <assert.h> -#include <stdexcept> -#include <gr_firdes.h> - -#include <cstdio> -#include <iostream> -#include <string.h> - -gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_filter_ccc (decimation, taps, nthreads)); -} - - -gr_fft_filter_ccc::gr_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) - : gr_sync_decimator ("fft_filter_ccc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - decimation), - d_updated(false) -{ - set_history(1); - -#if 1 // don't enable the sse version until handling it is worked out - d_filter = new gri_fft_filter_ccc_generic(decimation, taps, nthreads); -#else - d_filter = new gri_fft_filter_ccc_sse(decimation, taps); -#endif - - d_new_taps = taps; - d_nsamples = d_filter->set_taps(taps); - set_output_multiple(d_nsamples); -} - -gr_fft_filter_ccc::~gr_fft_filter_ccc () -{ - delete d_filter; -} - -void -gr_fft_filter_ccc::set_taps (const std::vector<gr_complex> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<gr_complex> -gr_fft_filter_ccc::taps () const -{ - return d_new_taps; -} - -void -gr_fft_filter_ccc::set_nthreads(int n) -{ - if(d_filter) - d_filter->set_nthreads(n); -} - -int -gr_fft_filter_ccc::nthreads() const -{ - if(d_filter) - return d_filter->nthreads(); - else - return 0; -} - - -int -gr_fft_filter_ccc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated){ - d_nsamples = d_filter->set_taps(d_new_taps); - d_updated = false; - set_output_multiple(d_nsamples); - return 0; // output multiple may have changed - } - - assert(noutput_items % d_nsamples == 0); - - d_filter->filter(noutput_items, in, out); - - //assert((out - (gr_complex *) output_items[0]) == noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h deleted file mode 100644 index 4b478b65f7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_GR_FFT_FILTER_CCC_H -#define INCLUDED_GR_FFT_FILTER_CCC_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_fft_filter_ccc; -typedef boost::shared_ptr<gr_fft_filter_ccc> gr_fft_filter_ccc_sptr; -GR_CORE_API gr_fft_filter_ccc_sptr -gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - -//class gri_fft_filter_ccc_sse; -class gri_fft_filter_ccc_generic; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_fft_filter_ccc : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_fft_filter_ccc_sptr - gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads); - - int d_nsamples; - bool d_updated; -#if 1 // don't enable the sse version until handling it is worked out - gri_fft_filter_ccc_generic *d_filter; -#else - gri_fft_filter_ccc_sse *d_filter; -#endif - std::vector<gr_complex> d_new_taps; - - /*! - * Construct a FFT filter with the given taps - * - * \param decimation >= 1 - * \param taps complex filter taps - * \param nthreads number of threads for the FFT to use - */ - gr_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_ccc (); - - void set_taps (const std::vector<gr_complex> &taps); - std::vector<gr_complex> taps () const; - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - - -#endif /* INCLUDED_GR_FFT_FILTER_CCC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i deleted file mode 100644 index 76837b582b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fft_filter_ccc) - -gr_fft_filter_ccc_sptr -gr_make_fft_filter_ccc (int decimation, - const std::vector<gr_complex> &taps, - int nthreads=1 - ) throw (std::invalid_argument); - -class gr_fft_filter_ccc : public gr_sync_decimator -{ - private: - gr_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_ccc (); - - void set_taps (const std::vector<gr_complex> &taps); - std::vector<gr_complex> taps () const; - - void set_nthreads(int n); - int nthreads() const; - -}; diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc deleted file mode 100644 index a09feb7f1f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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 <gr_fft_filter_fff.h> -#include <gri_fft_filter_fff_generic.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> - -#include <cstdio> -#include <iostream> -#include <string.h> - -gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_filter_fff (decimation, taps, nthreads)); -} - - -gr_fft_filter_fff::gr_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads) - : gr_sync_decimator ("fft_filter_fff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float)), - decimation), - d_updated(false) -{ - set_history(1); - -#if 1 // don't enable the sse version until handling it is worked out - d_filter = new gri_fft_filter_fff_generic(decimation, taps, nthreads); -#else - d_filter = new gri_fft_filter_fff_sse(decimation, taps); -#endif - - d_new_taps = taps; - d_nsamples = d_filter->set_taps(taps); - set_output_multiple(d_nsamples); -} - -gr_fft_filter_fff::~gr_fft_filter_fff () -{ - delete d_filter; -} - -void -gr_fft_filter_fff::set_taps (const std::vector<float> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<float> -gr_fft_filter_fff::taps () const -{ - return d_new_taps; -} - -void -gr_fft_filter_fff::set_nthreads(int n) -{ - if(d_filter) - d_filter->set_nthreads(n); -} - -int -gr_fft_filter_fff::nthreads() const -{ - if(d_filter) - return d_filter->nthreads(); - else - return 0; -} - -int -gr_fft_filter_fff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - if (d_updated){ - d_nsamples = d_filter->set_taps(d_new_taps); - d_updated = false; - set_output_multiple(d_nsamples); - return 0; // output multiple may have changed - } - - assert(noutput_items % d_nsamples == 0); - - d_filter->filter(noutput_items, in, out); - - //assert((out - (float *) output_items[0]) == noutput_items); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h deleted file mode 100644 index 309a551352..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_GR_FFT_FILTER_FFF_H -#define INCLUDED_GR_FFT_FILTER_FFF_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_fft_filter_fff; -typedef boost::shared_ptr<gr_fft_filter_fff> gr_fft_filter_fff_sptr; -GR_CORE_API gr_fft_filter_fff_sptr -gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - -class gri_fft_filter_fff_generic; -//class gri_fft_filter_fff_sse; - -/*! - * \brief Fast FFT filter with float input, float output and float taps - * \ingroup filter_blk - */ -class GR_CORE_API gr_fft_filter_fff : public gr_sync_decimator -{ - private: - friend GR_CORE_API gr_fft_filter_fff_sptr - gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads); - - int d_nsamples; - bool d_updated; -#if 1 // don't enable the sse version until handling it is worked out - gri_fft_filter_fff_generic *d_filter; -#else - gri_fft_filter_fff_sse *d_filter; -#endif - std::vector<float> d_new_taps; - - /*! - * Construct a FFT filter with the given taps - * - * \param decimation >= 1 - * \param taps float filter taps - * \param nthreads number of threads for the FFT to use - */ - gr_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_fff (); - - void set_taps (const std::vector<float> &taps); - std::vector<float> taps () const; - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FFT_FILTER_FFF_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i deleted file mode 100644 index 86c554893e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fft_filter_fff) - -gr_fft_filter_fff_sptr -gr_make_fft_filter_fff (int decimation, - const std::vector<float> &taps, - int nthreads=1 - ) throw (std::invalid_argument); - -class gr_fft_filter_fff : public gr_sync_decimator -{ - private: - gr_fft_filter_fff (int decimation, const std::vector<float> &taps, - int nthreads=1); - - public: - ~gr_fft_filter_fff (); - - void set_taps (const std::vector<float> &taps); - std::vector<float> taps () const; - void set_nthreads(int n); - int nthreads() const; - -}; diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc deleted file mode 100644 index af8a8e9e7d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <gr_filter_delay_fc.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> - -// public constructor -gr_filter_delay_fc_sptr -gr_make_filter_delay_fc (const std::vector<float> &taps) -{ - return gnuradio::get_initial_sptr(new gr_filter_delay_fc (taps)); -} - -gr_filter_delay_fc::gr_filter_delay_fc (const std::vector<float> &taps) - : gr_sync_block ("filter_delay_fc", - gr_make_io_signature (1, 2, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - d_fir = gr_fir_util::create_gr_fir_fff (taps); - d_delay = d_fir->ntaps () / 2; - set_history (d_fir->ntaps ()); -} - -gr_filter_delay_fc::~gr_filter_delay_fc () -{ - delete d_fir; -} - -int -gr_filter_delay_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in0 = (float *) input_items[0]; - float *in1 = (float *) input_items[1]; - gr_complex *out = (gr_complex *) output_items[0]; - - switch (input_items.size ()){ - case 1: - for (int i = 0; i < noutput_items; i++) - out[i] = gr_complex (in0[i + d_delay], - d_fir->filter (&in0[i])); - break; - - case 2: - for (int j = 0; j < noutput_items; j++) - out[j] = gr_complex (in0[j + d_delay], - d_fir->filter (&in1[j])); - break; - - default: - assert (0); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h deleted file mode 100644 index fee11243a5..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_GR_FILTER_DELAY_FC_H -#define INCLUDED_GR_FILTER_DELAY_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_io_signature.h> -#include <gr_types.h> - -class gr_filter_delay_fc; -typedef boost::shared_ptr<gr_filter_delay_fc> gr_filter_delay_fc_sptr; - -// public constructor -GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); - -class gr_fir_fff; - -/*! - * \brief Filter-Delay Combination Block. - * \ingroup filter_blk - * - * The block takes one or two float stream and outputs a complex - * stream. If only one float stream is input, the real output is - * a delayed version of this input and the imaginary output is the - * filtered output. If two floats are connected to the input, then - * the real output is the delayed version of the first input, and - * the imaginary output is the filtered output. The delay in the - * real path accounts for the group delay introduced by the filter - * in the imaginary path. The filter taps needs to be calculated - * before initializing this block. - * - */ -class GR_CORE_API gr_filter_delay_fc : public gr_sync_block -{ - public: - ~gr_filter_delay_fc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - protected: - gr_filter_delay_fc (const std::vector<float> &taps); - - private: - unsigned int d_delay; - gr_fir_fff *d_fir; - - friend GR_CORE_API gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); -}; - -#endif /* INCLUDED_GR_FILTER_DELAY_FC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i deleted file mode 100644 index 54b721cee7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,filter_delay_fc); - -gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps); - -class gr_filter_delay_fc : public gr_sync_block -{ -private: - gr_filter_delay_fc (); -}; - -// ---------------------------------------------------------------- - diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t deleted file mode 100644 index 2396f0fe66..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX.cc.t +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <@FIR_TYPE@.h> - -@FIR_TYPE@::~@FIR_TYPE@ () -{ -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t deleted file mode 100644 index 197bb3cd2c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX.h.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2003 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_XXX.py - * Any changes made to this file will be overwritten. - */ - - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <vector> -@VRCOMPLEX_INCLUDE@ -#include <gr_reverse.h> - -/*! - * \brief Abstract class for FIR with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_primitive - * - * This is the abstract class for a Finite Impulse Response filter. - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) - */ - -class GR_CORE_API @FIR_TYPE@ { - -protected: - std::vector<@TAP_TYPE@> d_taps; // reversed taps - -public: - - // CONSTRUCTORS - - /*! - * \brief construct new FIR with given taps. - * - * Note that taps must be in forward order, e.g., coefficient 0 is - * stored in new_taps[0], coefficient 1 is stored in - * new_taps[1], etc. - */ - @FIR_TYPE@ () {} - @FIR_TYPE@ (const std::vector<@TAP_TYPE@> &taps) : d_taps (gr_reverse(taps)) {} - - virtual ~@FIR_TYPE@ (); - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \returns the filtered input value. - */ - virtual @O_TYPE@ filter (const @I_TYPE@ input[]) = 0; - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - virtual void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n) = 0; - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - virtual void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned decimate) = 0; - - /*! - * \brief install \p new_taps as the current taps. - */ - virtual void set_taps (const std::vector<@TAP_TYPE@> &taps) - { - d_taps = gr_reverse(taps); - } - - // ACCESSORS - - /*! - * \return number of taps in filter. - */ - unsigned ntaps () const { return d_taps.size (); } - - /*! - * \return current taps - */ - virtual const std::vector<@TAP_TYPE@> get_taps () const - { - return gr_reverse(d_taps); - } -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t deleted file mode 100644 index 11b4fd50fb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.cc.t +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <@FIR_TYPE@_generic.h> - -#if (@N_UNROLL@ == 4) - -@O_TYPE@ -@FIR_TYPE@_generic::filter (const @I_TYPE@ input[]) -{ - static const int N_UNROLL = 4; - - @ACC_TYPE@ acc0 = 0; - @ACC_TYPE@ acc1 = 0; - @ACC_TYPE@ acc2 = 0; - @ACC_TYPE@ acc3 = 0; - - - unsigned i = 0; - unsigned n = (ntaps () / N_UNROLL) * N_UNROLL; - - for (i = 0; i < n; i += N_UNROLL){ - acc0 += d_taps[i + 0] * @INPUT_CAST@ input[i + 0]; - acc1 += d_taps[i + 1] * @INPUT_CAST@ input[i + 1]; - acc2 += d_taps[i + 2] * @INPUT_CAST@ input[i + 2]; - acc3 += d_taps[i + 3] * @INPUT_CAST@ input[i + 3]; - } - - for (; i < ntaps (); i++) - acc0 += d_taps[i] * @INPUT_CAST@ input[i]; - - return (@O_TYPE@) (acc0 + acc1 + acc2 + acc3); -} - -#else - -@O_TYPE@ -@FIR_TYPE@_generic::filter (const @I_TYPE@ input[]) -{ - static const int N_UNROLL = 2; - - @ACC_TYPE@ acc0 = 0; - @ACC_TYPE@ acc1 = 0; - - unsigned i = 0; - unsigned n = (ntaps () / N_UNROLL) * N_UNROLL; - - for (i = 0; i < n; i += N_UNROLL){ - acc0 += d_taps[i + 0] * @INPUT_CAST@ input[i + 0]; - acc1 += d_taps[i + 1] * @INPUT_CAST@ input[i + 1]; - } - - for (; i < ntaps (); i++) - acc0 += d_taps[i] * @INPUT_CAST@ input[i]; - - return (@O_TYPE@) (acc0 + acc1); -} - -#endif // N_UNROLL - -void -@FIR_TYPE@_generic::filterN (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (&input[i]); -} - -void -@FIR_TYPE@_generic::filterNdec (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n, - unsigned decimate) -{ - unsigned j = 0; - for (unsigned i = 0; i < n; i++){ - output[i] = filter (&input[j]); - j += decimate; - } -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t b/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t deleted file mode 100644 index f7382d7393..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_XXX_generic.h.t +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <@FIR_TYPE@.h> - -/*! - * \brief Concrete class for generic implementation of FIR with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * - * The trailing suffix has the form _IOT where I codes the input type, - * O codes the output type, and T codes the tap type. - * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int) - */ - -class GR_CORE_API @FIR_TYPE@_generic : public @FIR_TYPE@ { - -public: - - // CREATORS - - @FIR_TYPE@_generic () {} - @FIR_TYPE@_generic (const std::vector<@TAP_TYPE@> &taps) : @FIR_TYPE@ (taps) {} - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \returns the filtered input value. - */ - virtual @O_TYPE@ filter (const @I_TYPE@ input[]); - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - virtual void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n); - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - virtual void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned decimate); - -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc deleted file mode 100644 index d88b696c9a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 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 <gr_fir_ccc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> -#include <stdexcept> - -using std::cerr; -using std::endl; - -gr_fir_ccc_simd::gr_fir_ccc_simd () - : gr_fir_ccc_generic () -{ - // cerr << "@@@ gr_fir_ccc_simd\n"; - - d_ccomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_ccc_simd::gr_fir_ccc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_ccc_simd\n"; - - d_ccomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_ccc_simd::~gr_fir_ccc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_ccc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_ccc::set_taps (inew_taps); // call superclass - - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_ccc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_ccc_simd::filter (const gr_complex input[]) -{ - if (ntaps () == 0) - return 0.0; - - if (((intptr_t) input & 0x7) != 0) - throw std::invalid_argument("gr_complex must be 8-byte aligned"); - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const gr_complex *ar = (gr_complex *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_ccomplex_dotprod ((float*)ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h deleted file mode 100644 index ed7249c91d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_simd.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_CCC_SIMD_H -#define INCLUDED_GR_FIR_CCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_ccc_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_ccc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_ccc_simd : public gr_fir_ccc_generic -{ -protected: - typedef void (*ccomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_ccomplex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - ccomplex_dotprod_t d_ccomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_ccc_simd (); - gr_fir_ccc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_ccc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc deleted file mode 100644 index 28bc008e8a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_ccc_x86.h> -#include <ccomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_ccc_3dnow::gr_fir_ccc_3dnow () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnow; -} - -gr_fir_ccc_3dnow::gr_fir_ccc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnow; -} - - -/* - * --- 3DNow!Ext version --- - */ - -gr_fir_ccc_3dnowext::gr_fir_ccc_3dnowext () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnowext; -} - -gr_fir_ccc_3dnowext::gr_fir_ccc_3dnowext (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_3dnowext; -} - - -/* - * --- SSE version --- - */ - -gr_fir_ccc_sse::gr_fir_ccc_sse () - : gr_fir_ccc_simd () -{ - d_ccomplex_dotprod = ccomplex_dotprod_sse; -} - -gr_fir_ccc_sse::gr_fir_ccc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_ccc_simd (new_taps) -{ - d_ccomplex_dotprod = ccomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h deleted file mode 100644 index 0a9d2c83c3..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccc_x86.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_CCC_X86_H -#define INCLUDED_GR_FIR_CCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_ccc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_ccc - */ -class GR_CORE_API gr_fir_ccc_3dnow : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_3dnow (); - gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps); -}; - -class GR_CORE_API gr_fir_ccc_3dnowext : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_3dnowext (); - gr_fir_ccc_3dnowext (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_ccc - */ -class GR_CORE_API gr_fir_ccc_sse : public gr_fir_ccc_simd -{ -public: - gr_fir_ccc_sse (); - gr_fir_ccc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc deleted file mode 100644 index d849c3dd57..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2011 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_fir_ccf_armv7_a.h> -#include <stdlib.h> -#include <string.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <dotprod_ccf_armv7_a.h> - -#define FLOATS_PER_VEC 4 - -gr_fir_ccf_armv7_a::gr_fir_ccf_armv7_a() - : gr_fir_ccf_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_ccf_armv7_a::gr_fir_ccf_armv7_a (const std::vector<float> &new_taps) - : gr_fir_ccf_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_ccf_armv7_a::~gr_fir_ccf_armv7_a() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_ccf_armv7_a::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_ccf_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(float), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -gr_complex -gr_fir_ccf_armv7_a::filter (const gr_complex input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - gr_complex result; - float *presult = reinterpret_cast<float *>(&result); - const float *pinput = reinterpret_cast<const float *>(input); - - dotprod_ccf_armv7_a(pinput, d_aligned_taps, presult, d_naligned_taps); - return result; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h deleted file mode 100644 index e4844bae1a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_armv7_a.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009,2011 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_CCF_ARMV7_A_H -#define INCLUDED_GR_FIR_CCF_ARMV7_A_H - -#include <gr_fir_ccf_generic.h> - -/*! - * \brief armv7_a using NEON coprocessor version of gr_fir_ccf - */ -class gr_fir_ccf_armv7_a : public gr_fir_ccf_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_ccf_armv7_a(); - gr_fir_ccf_armv7_a(const std::vector<float> &taps); - ~gr_fir_ccf_armv7_a(); - - virtual void set_taps (const std::vector<float> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif /* INCLUDED_GR_FIR_CCF_ARMV7_A*_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc deleted file mode 100644 index 872415e8eb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 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 <gr_fir_ccf_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> -#include <stdexcept> - -using std::cerr; -using std::endl; - -gr_fir_ccf_simd::gr_fir_ccf_simd () - : gr_fir_ccf_generic () -{ - // cerr << "@@@ gr_fir_ccf_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_ccf_simd::gr_fir_ccf_simd (const std::vector<float> &new_taps) - : gr_fir_ccf_generic (new_taps) -{ - // cerr << "@@@ gr_fir_ccf_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_ccf_simd::~gr_fir_ccf_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_ccf_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_ccf::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_ccf_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -gr_complex -gr_fir_ccf_simd::filter (const gr_complex input[]) -{ - if (ntaps () == 0) - return 0.0; - - if (((intptr_t) input & 0x7) != 0) - throw std::invalid_argument("gr_complex must be 8-byte aligned"); - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const gr_complex *ar = (gr_complex *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - // the trick here is to invert input and taps, and reuse FCC speedup - d_fcomplex_dotprod (d_aligned_taps[al], (float*)ar, (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h deleted file mode 100644 index 3c3e7e4f5b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_simd.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_CCF_SIMD_H -#define INCLUDED_GR_FIR_CCF_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_ccf_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_ccf - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_ccf_simd : public gr_fir_ccf_generic -{ -protected: - typedef void (*fcomplex_dotprod_t)(const float *taps, - const float *input, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - fcomplex_dotprod_t d_fcomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_ccf_simd (); - gr_fir_ccf_simd (const std::vector<float> &taps); - ~gr_fir_ccf_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual gr_complex filter (const gr_complex input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc deleted file mode 100644 index f26d4ecc2c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_ccf_x86.h> -#include <fcomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_ccf_3dnow::gr_fir_ccf_3dnow () - : gr_fir_ccf_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - -gr_fir_ccf_3dnow::gr_fir_ccf_3dnow (const std::vector<float> &new_taps) - : gr_fir_ccf_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_ccf_sse::gr_fir_ccf_sse () - : gr_fir_ccf_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} - -gr_fir_ccf_sse::gr_fir_ccf_sse (const std::vector<float> &new_taps) - : gr_fir_ccf_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h deleted file mode 100644 index 6b260c3dbb..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_ccf_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_CCF_X86_H -#define INCLUDED_GR_FIR_CCF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_ccf_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_ccf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_ccf_3dnow : public gr_fir_ccf_simd -{ -public: - gr_fir_ccf_3dnow (); - gr_fir_ccf_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_ccf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_ccf_sse : public gr_fir_ccf_simd -{ -public: - gr_fir_ccf_sse (); - gr_fir_ccf_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc deleted file mode 100644 index 5b75a43fd2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fcc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; -using std::endl; - -gr_fir_fcc_simd::gr_fir_fcc_simd () - : gr_fir_fcc_generic () -{ - // cerr << "@@@ gr_fir_fcc_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fcc_simd::gr_fir_fcc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fcc_simd\n"; - - d_fcomplex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fcc_simd::~gr_fir_fcc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fcc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_fcc::set_taps (inew_taps); // call superclass - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fcc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_fcc_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_fcomplex_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h deleted file mode 100644 index b7463070bc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_simd.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_FCC_SIMD_H -#define INCLUDED_GR_FIR_FCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_fcc_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_fcc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fcc_simd : public gr_fir_fcc_generic -{ -protected: - typedef void (*fcomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - fcomplex_dotprod_t d_fcomplex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fcc_simd (); - gr_fir_fcc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_fcc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc deleted file mode 100644 index d9904133c4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fcc_x86.h> -#include <fcomplex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fcc_3dnow::gr_fir_fcc_3dnow () - : gr_fir_fcc_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - -gr_fir_fcc_3dnow::gr_fir_fcc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fcc_sse::gr_fir_fcc_sse () - : gr_fir_fcc_simd () -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} - -gr_fir_fcc_sse::gr_fir_fcc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_fcc_simd (new_taps) -{ - d_fcomplex_dotprod = fcomplex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h deleted file mode 100644 index 3fc6c4855b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_FCC_X86_H -#define INCLUDED_GR_FIR_FCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fcc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fcc - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fcc_3dnow : public gr_fir_fcc_simd -{ -public: - gr_fir_fcc_3dnow (); - gr_fir_fcc_3dnow (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fcc - * \ingroup filter_blk - */ -class GR_CORE_API gr_fir_fcc_sse : public gr_fir_fcc_simd -{ -public: - gr_fir_fcc_sse (); - gr_fir_fcc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc deleted file mode 100644 index b81283ce56..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_fir_fff_altivec.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <gr_altivec.h> -#include <dotprod_fff_altivec.h> -#include <string.h> -#include "posix_memalign.h" - -gr_fir_fff_altivec::gr_fir_fff_altivec() - : gr_fir_fff_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_fff_altivec::gr_fir_fff_altivec (const std::vector<float> &new_taps) - : gr_fir_fff_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_fff_altivec::~gr_fir_fff_altivec() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_fff_altivec::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_fff_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(vec_float4), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -float -gr_fir_fff_altivec::filter (const float input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - return dotprod_fff_altivec(input, d_aligned_taps, d_naligned_taps); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h deleted file mode 100644 index a3d4a2aae9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_FFF_ALTIVEC_H -#define INCLUDED_GR_FIR_FFF_ALTIVEC_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief altivec version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_altivec : public gr_fir_fff_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_fff_altivec(); - gr_fir_fff_altivec(const std::vector<float> &taps); - ~gr_fir_fff_altivec(); - - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif /* INCLUDED_GR_FIR_FFF_ALTIVEC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc deleted file mode 100644 index b437254202..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_fir_fff_armv7_a.h> -#include <stdlib.h> -#include <string.h> -#include <stdexcept> -#include <assert.h> -#include <gr_math.h> -#include <dotprod_fff_armv7_a.h> - -#define FLOATS_PER_VEC 8 - -gr_fir_fff_armv7_a::gr_fir_fff_armv7_a() - : gr_fir_fff_generic(), - d_naligned_taps(0), d_aligned_taps(0) -{ -} - -gr_fir_fff_armv7_a::gr_fir_fff_armv7_a (const std::vector<float> &new_taps) - : gr_fir_fff_generic(new_taps), - d_naligned_taps(0), d_aligned_taps(0) -{ - set_taps(new_taps); -} - -gr_fir_fff_armv7_a::~gr_fir_fff_armv7_a() -{ - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } -} - -void -gr_fir_fff_armv7_a::set_taps(const std::vector<float> &inew_taps) -{ - gr_fir_fff_generic::set_taps(inew_taps); // call superclass - d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC); - - if (d_aligned_taps){ - free(d_aligned_taps); - d_aligned_taps = 0; - } - void *p; - int r = posix_memalign(&p, sizeof(float), d_naligned_taps * sizeof(d_aligned_taps[0])); - if (r != 0){ - throw std::bad_alloc(); - } - d_aligned_taps = (float *) p; - memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0])); - for (size_t i = ntaps(); i < d_naligned_taps; i++) - d_aligned_taps[i] = 0.0; -} - - -float -gr_fir_fff_armv7_a::filter (const float input[]) -{ - if (d_naligned_taps == 0) - return 0.0; - - return dotprod_fff_armv7_a(input, d_aligned_taps, d_naligned_taps); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h deleted file mode 100644 index 78863d2866..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_armv7_a.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GR_FIR_FFF_ARMV7_A_H -#define INCLUDED_GR_FIR_FFF_ARMV7_A_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief armv7_a using NEON coprocessor version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_armv7_a : public gr_fir_fff_generic -{ -protected: - - size_t d_naligned_taps; // number of taps (multiple of 4) - float *d_aligned_taps; // 16-byte aligned, and zero padded to multiple of 4 - -public: - gr_fir_fff_armv7_a(); - gr_fir_fff_armv7_a(const std::vector<float> &taps); - ~gr_fir_fff_armv7_a(); - - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif /* INCLUDED_GR_FIR_FFF_ARMV7_A*_H */ diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc deleted file mode 100644 index d6c28ed45b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fff_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; - -gr_fir_fff_simd::gr_fir_fff_simd () - : gr_fir_fff_generic () -{ - // cerr << "@@@ gr_fir_fff_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fff_simd::gr_fir_fff_simd (const std::vector<float> &new_taps) - : gr_fir_fff_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fff_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fff_simd::~gr_fir_fff_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fff_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_fff::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fff_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -float -gr_fir_fff_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/4 + 1: " << (ntaps() + al -1) / 4 + 1 << endl; - - float r = d_float_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 4 + 1); - - // cerr << "result = " << r << endl; - - return r; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h deleted file mode 100644 index 9d61062664..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_simd.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_FFF_SIMD_H -#define INCLUDED_GR_FIR_FFF_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_fff_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_fff - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fff_simd : public gr_fir_fff_generic -{ -protected: - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - float_dotprod_t d_float_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fff_simd (); - gr_fir_fff_simd (const std::vector<float> &taps); - ~gr_fir_fff_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual float filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc deleted file mode 100644 index 40ac266be6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fff_x86.h> -#include <float_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fff_3dnow::gr_fir_fff_3dnow () - : gr_fir_fff_simd () -{ - d_float_dotprod = float_dotprod_3dnow; -} - -gr_fir_fff_3dnow::gr_fir_fff_3dnow (const std::vector<float> &new_taps) - : gr_fir_fff_simd (new_taps) -{ - d_float_dotprod = float_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fff_sse::gr_fir_fff_sse () - : gr_fir_fff_simd () -{ - d_float_dotprod = float_dotprod_sse; -} - -gr_fir_fff_sse::gr_fir_fff_sse (const std::vector<float> &new_taps) - : gr_fir_fff_simd (new_taps) -{ - d_float_dotprod = float_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h deleted file mode 100644 index 8d451f0c95..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_x86.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_FFF_X86_H -#define INCLUDED_GR_FIR_FFF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fff_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_3dnow : public gr_fir_fff_simd -{ -public: - gr_fir_fff_3dnow (); - gr_fir_fff_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fff - */ -class GR_CORE_API gr_fir_fff_sse : public gr_fir_fff_simd -{ -public: - gr_fir_fff_sse (); - gr_fir_fff_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t deleted file mode 100644 index 39bc756301..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps)); -} - - -@NAME@::@NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps) - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decimation), - d_updated (false) -{ - d_fir = gr_fir_util::create_@FIR_TYPE@ (taps); - set_history (d_fir->ntaps ()); -} - -@NAME@::~@NAME@ () -{ - delete d_fir; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; -} - -std::vector<@TAP_TYPE@> -@NAME@::taps () const -{ - return d_new_taps; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *in = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - d_fir->set_taps (d_new_taps); - set_history (d_fir->ntaps ()); - d_updated = false; - return 0; // history requirements may have changed. - } - - if (decimation() == 1) - d_fir->filterN (out, in, noutput_items); - - else - d_fir->filterNdec (out, in, noutput_items, decimation()); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t deleted file mode 100644 index b32e04bd35..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ - private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - @FIR_TYPE@ *d_fir; - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - std::vector<@TAP_TYPE@> taps () const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t deleted file mode 100644 index d9dc86180e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.i.t +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -/* - * WARNING: This file is automatically generated by generate_GrFIRfilterXXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_sync_decimator -{ - private: - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - std::vector<@TAP_TYPE@> taps () const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc deleted file mode 100644 index a49503e6ab..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fsf_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; - -gr_fir_fsf_simd::gr_fir_fsf_simd () - : gr_fir_fsf_generic () -{ - // cerr << "@@@ gr_fir_fsf_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_fsf_simd::gr_fir_fsf_simd (const std::vector<float> &new_taps) - : gr_fir_fsf_generic (new_taps) -{ - // cerr << "@@@ gr_fir_fsf_simd\n"; - - d_float_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_fsf_simd::~gr_fir_fsf_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_fsf_simd::set_taps (const std::vector<float> &inew_taps) -{ - gr_fir_fsf::set_taps (inew_taps); // call superclass - const std::vector<float> new_taps = gr_reverse(inew_taps); - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 4, - 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_fsf_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) - d_aligned_taps[i][j+i] = new_taps[j]; - } -} - -short -gr_fir_fsf_simd::filter (const float input[]) -{ - if (ntaps () == 0) - return 0; - - - // Round input data address down to 16 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const float *ar = (float *)((unsigned long) input & ~15); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 4-float blocks. - - // assert (((unsigned long) ar & 15) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/4 + 1: " << (ntaps() + al -1) / 4 + 1 << endl; - - float r = d_float_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 4 + 1); - - // cerr << "result = " << r << endl; - - return (short) r; // FIXME? may want to saturate here -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h deleted file mode 100644 index d63e9dd17d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_simd.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _GR_FIR_FSF_SIMD_H_ -#define _GR_FIR_FSF_SIMD_H_ - -#include <gr_core_api.h> -#include <gr_fir_fsf_generic.h> - -/*! - * \brief common base class for SIMD versions of gr_fir_fsf - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ - -class GR_CORE_API gr_fir_fsf_simd : public gr_fir_fsf_generic -{ -protected: - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 floats to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - float_dotprod_t d_float_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_fsf_simd (); - gr_fir_fsf_simd (const std::vector<float> &taps); - ~gr_fir_fsf_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<float> &taps); - virtual short filter (const float input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc deleted file mode 100644 index 40ba17d3a7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_fsf_x86.h> -#include <float_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_fsf_3dnow::gr_fir_fsf_3dnow () - : gr_fir_fsf_simd () -{ - d_float_dotprod = float_dotprod_3dnow; -} - -gr_fir_fsf_3dnow::gr_fir_fsf_3dnow (const std::vector<float> &new_taps) - : gr_fir_fsf_simd (new_taps) -{ - d_float_dotprod = float_dotprod_3dnow; -} - - -/* - * --- SSE version --- - */ - -gr_fir_fsf_sse::gr_fir_fsf_sse () - : gr_fir_fsf_simd () -{ - d_float_dotprod = float_dotprod_sse; -} - -gr_fir_fsf_sse::gr_fir_fsf_sse (const std::vector<float> &new_taps) - : gr_fir_fsf_simd (new_taps) -{ - d_float_dotprod = float_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h deleted file mode 100644 index df664d5e27..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_fsf_x86.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_FSF_X86_H -#define INCLUDED_GR_FIR_FSF_X86_H - -#include <gr_core_api.h> -#include <gr_fir_fsf_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_fsf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fsf_3dnow : public gr_fir_fsf_simd -{ -public: - gr_fir_fsf_3dnow (); - gr_fir_fsf_3dnow (const std::vector<float> &taps); -}; - -/*! - * \brief SSE version of gr_fir_fsf - * \ingroup filter_primitive - */ -class GR_CORE_API gr_fir_fsf_sse : public gr_fir_fsf_simd -{ -public: - gr_fir_fsf_sse (); - gr_fir_fsf_sse (const std::vector<float> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc deleted file mode 100644 index 0b2dd7e613..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_scc_simd.h> - -#include <assert.h> -#include <malloc16.h> -#include <iostream> - -using std::cerr; -using std::endl; - -gr_fir_scc_simd::gr_fir_scc_simd () - : gr_fir_scc_generic () -{ - // cerr << "@@@ gr_fir_scc_simd\n"; - - d_complex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; -} - -gr_fir_scc_simd::gr_fir_scc_simd (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_generic (new_taps) -{ - // cerr << "@@@ gr_fir_scc_simd\n"; - - d_complex_dotprod = 0; - - d_aligned_taps[0] = 0; - d_aligned_taps[1] = 0; - d_aligned_taps[2] = 0; - d_aligned_taps[3] = 0; - set_taps (new_taps); -} - -gr_fir_scc_simd::~gr_fir_scc_simd () -{ - free16Align (d_aligned_taps[0]); - free16Align (d_aligned_taps[1]); - free16Align (d_aligned_taps[2]); - free16Align (d_aligned_taps[3]); -} - -void -gr_fir_scc_simd::set_taps (const std::vector<gr_complex> &inew_taps) -{ - gr_fir_scc::set_taps (inew_taps); // call superclass - - const std::vector<gr_complex> new_taps = gr_reverse(inew_taps); - - unsigned len = new_taps.size (); - - // Make 4 copies of the coefficients, one for each data alignment - // Note use of special 16-byte-aligned version of calloc() - - for (unsigned i = 0; i < 4; i++){ - free16Align (d_aligned_taps[i]); // free old value - - // this works because the bit representation of a IEEE floating point - // +zero is all zeros. If you're using a different representation, - // you'll need to explictly set the result to the appropriate 0.0 value. - - d_aligned_taps[i] = (float *) calloc16Align (1 + (len + i - 1) / 2, - 2 * 4 * sizeof (float)); - if (d_aligned_taps[i] == 0){ - // throw something... - cerr << "@@@ gr_fir_scc_simd d_aligned_taps[" << i << "] == 0\n"; - } - - for (unsigned j = 0; j < len; j++) { - d_aligned_taps[i][2*(j+i)] = new_taps[j].real(); - d_aligned_taps[i][2*(j+i)+1] = new_taps[j].imag(); - } - } -} - -gr_complex -gr_fir_scc_simd::filter (const short input[]) -{ - if (ntaps () == 0) - return 0.0; - - - // Round input data address down to 8 byte boundary - // NB: depending on the alignment of input[], memory - // before input[] will be accessed. The contents don't matter since - // they'll be multiplied by zero coefficients. I can't conceive of any - // situation where this could cause a segfault since memory protection - // in the x86 machines is done on much larger boundaries. - - const short *ar = (short *)((unsigned long) input & ~7); - - // Choose one of 4 sets of pre-shifted coefficients. al is both the - // index into d_aligned_taps[] and the number of 0 words padded onto - // that coefficients array for alignment purposes. - - unsigned al = input - ar; - - // call assembler routine to do the work, passing number of 2x4-float blocks. - - // assert (((unsigned long) ar & 7) == 0); - // assert (((unsigned long) d_aligned_taps[al] & 15) == 0); - - // cerr << "ar: " << ar << " d_aligned_taps[ar]: " << d_aligned_taps[al] - // << " (ntaps() + al - 1)/2 + 1: " << (ntaps() + al -1) / 2 + 1 << endl; - - float result[2]; - - d_complex_dotprod (ar, d_aligned_taps[al], (ntaps() + al - 1) / 2 + 1, result); - - // cerr << "result = " << result[0] << " " << result[1] << endl; - - return gr_complex(result[0], result[1]); -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h b/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h deleted file mode 100644 index 72c15f93b3..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_simd.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_SCC_SIMD_H -#define INCLUDED_GR_FIR_SCC_SIMD_H - -#include <gr_core_api.h> -#include <gr_fir_scc_generic.h> - - -/*! - * \brief common base class for SIMD versions of gr_fir_scc - * \ingroup filter_primitive - * - * This base class handles alignment issues common to SSE and 3DNOW - * subclasses. - */ -class GR_CORE_API gr_fir_scc_simd : public gr_fir_scc_generic -{ -protected: - typedef void (*complex_dotprod_t)(const short *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - /*! - * \p aligned_taps holds 4 copies of the coefficients preshifted - * by 0, 1, 2, or 3 float pairs to meet all possible input data alignments. - * This allows us to always fetch data and taps that are 128-bit aligned. - */ - float *d_aligned_taps[4]; - - complex_dotprod_t d_complex_dotprod; // fast dot product primitive - -public: - - // CREATORS - gr_fir_scc_simd (); - gr_fir_scc_simd (const std::vector<gr_complex> &taps); - ~gr_fir_scc_simd (); - - // MANIPULATORS - virtual void set_taps (const std::vector<gr_complex> &taps); - virtual gr_complex filter (const short input[]); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc deleted file mode 100644 index ab0668c63a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_scc_x86.h> -#include <complex_dotprod_x86.h> - -/* - * --- 3DNow! version --- - */ - -gr_fir_scc_3dnow::gr_fir_scc_3dnow () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_3dnow; -} - -gr_fir_scc_3dnow::gr_fir_scc_3dnow (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_3dnow; -} - - -/* - * --- 3DNow! Ext version --- - */ - -gr_fir_scc_3dnowext::gr_fir_scc_3dnowext () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_3dnowext; -} - -gr_fir_scc_3dnowext::gr_fir_scc_3dnowext (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_3dnowext; -} - - -/* - * --- SSE version --- - */ - -gr_fir_scc_sse::gr_fir_scc_sse () - : gr_fir_scc_simd () -{ - d_complex_dotprod = complex_dotprod_sse; -} - -gr_fir_scc_sse::gr_fir_scc_sse (const std::vector<gr_complex> &new_taps) - : gr_fir_scc_simd (new_taps) -{ - d_complex_dotprod = complex_dotprod_sse; -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h deleted file mode 100644 index 85a63251b2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_scc_x86.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_SCC_X86_H -#define INCLUDED_GR_FIR_SCC_X86_H - -#include <gr_core_api.h> -#include <gr_fir_scc_simd.h> - -/*! - * \brief 3DNow! version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_3dnow : public gr_fir_scc_simd -{ -public: - gr_fir_scc_3dnow (); - gr_fir_scc_3dnow (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief 3DNow! Ext version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_3dnowext : public gr_fir_scc_simd -{ -public: - gr_fir_scc_3dnowext (); - gr_fir_scc_3dnowext (const std::vector<gr_complex> &taps); -}; - -/*! - * \brief SSE version of gr_fir_scc - */ -class GR_CORE_API gr_fir_scc_sse : public gr_fir_scc_simd -{ -public: - gr_fir_scc_sse (); - gr_fir_scc_sse (const std::vector<gr_complex> &taps); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc deleted file mode 100644 index 70adbc0920..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.cc +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009,2011 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 <gr_fir_sysconfig_armv7_a.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -#include <gr_fir_ccf_armv7_a.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_armv7_a.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> - -#include <iostream> -using std::cerr; - -///\todo Remove commented out code for altivec and replace with NEON versions. - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * ---------------------------------------------------------------- - */ - -static gr_fir_ccf * -make_gr_fir_ccf_armv7_a (const std::vector<float> &taps) -{ - return new gr_fir_ccf_armv7_a(taps); -} - -#if 0 -static gr_fir_fcc * -make_gr_fir_fcc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_altivec(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_altivec (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_altivec (taps); -} -#endif - -static gr_fir_fff * -make_gr_fir_fff_armv7_a (const std::vector<float> &taps) -{ - return new gr_fir_fff_armv7_a (taps); -} - -#if 0 -static gr_fir_fsf * -make_gr_fir_fsf_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fsf_altivec (taps); -} - -static gr_fir_scc * -make_gr_fir_scc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_altivec(taps); -} -#endif - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest arm versions of these classes. - * - * check CPUID, if has armv7-a, return armv7-a version, - * else return generic version. This will break - * when someone makes an armv7-a without a NEON - * coprocessor. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_armv7_a::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_armv7_a ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using armv7_a\n"; - first = false; - } - return make_gr_fir_ccf_armv7_a (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_armv7_a::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using altivec\n"; - first = false; - } - return make_gr_fir_fcc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_armv7_a::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using altivec\n"; - first = false; - } - return make_gr_fir_ccc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_armv7_a::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_armv7_a ()){ - if (first){ - cerr << ">>> gr_fir_fff: using armv7_a\n"; - first = false; - } - return make_gr_fir_fff_armv7_a (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_armv7_a::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using altivec\n"; - first = false; - } - return make_gr_fir_fsf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - - -gr_fir_scc * -gr_fir_sysconfig_armv7_a::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_scc: using altivec\n"; - first = false; - } - return make_gr_fir_scc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - - // add our stuff... - gr_fir_ccf_info t; - if (gr_cpu::has_armv7_a ()){ - t.name = "armv7_a"; - t.create = make_gr_fir_ccf_armv7_a; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - -#if 0 - // add our stuff... - gr_fir_fcc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fcc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - -#if 0 - // add our stuff... - gr_fir_ccc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - gr_fir_fff_info t; - if (gr_cpu::has_armv7_a ()){ - t.name = "armv7_a"; - t.create = make_gr_fir_fff_armv7_a; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - -#if 0 - // add our stuff... - gr_fir_fsf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fsf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_armv7_a::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - -#if 0 - // add our stuff... - gr_fir_scc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_scc_altivec; - (*info).push_back (t); - } -#endif -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h deleted file mode 100644 index 7295475f64..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_armv7_a.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 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_GR_FIR_SYSCONFIG_ARMV7_A_H -#define INCLUDED_GR_FIR_SYSCONFIG_ARMV7_A_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_armv7_a : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc deleted file mode 100644 index f706bd5bf2..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 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 <gr_fir_sysconfig_powerpc.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -//#include <gr_fir_ccf_altivec.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -//#include <gr_fir_fcc_altivec.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_altivec.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -//#include <gr_fir_fsf_powerpc.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -//#include <gr_fir_ccc_altivec.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> -//#include <gr_fir_scc_altivec.h> - -#include <iostream> -using std::cerr; - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * ---------------------------------------------------------------- - */ - -#if 0 -static gr_fir_ccf * -make_gr_fir_ccf_altivec(const std::vector<float> &taps) -{ - return new gr_fir_ccf_altivec(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_altivec(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_altivec (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_altivec (taps); -} -#endif - -static gr_fir_fff * -make_gr_fir_fff_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fff_altivec (taps); -} - -#if 0 -static gr_fir_fsf * -make_gr_fir_fsf_altivec (const std::vector<float> &taps) -{ - return new gr_fir_fsf_altivec (taps); -} - -static gr_fir_scc * -make_gr_fir_scc_altivec(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_altivec(taps); -} -#endif - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest powerpc versions of these classes. - * - * check CPUID, if has altivec, return altivec version, - * else return generic version. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_powerpc::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using altivec\n"; - first = false; - } - return make_gr_fir_ccf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_powerpc::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using altivec\n"; - first = false; - } - return make_gr_fir_fcc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_powerpc::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using altivec\n"; - first = false; - } - return make_gr_fir_ccc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_powerpc::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fff: using altivec\n"; - first = false; - } - return make_gr_fir_fff_altivec (taps); - } - - if (0 && first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_powerpc::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using altivec\n"; - first = false; - } - return make_gr_fir_fsf_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - - -gr_fir_scc * -gr_fir_sysconfig_powerpc::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - -#if 0 - if (gr_cpu::has_altivec ()){ - if (first){ - cerr << ">>> gr_fir_scc: using altivec\n"; - first = false; - } - return make_gr_fir_scc_altivec (taps); - } -#endif - - if (0 && first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_powerpc::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - -#if 0 - // add our stuff... - gr_fir_ccf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - -#if 0 - // add our stuff... - gr_fir_fcc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fcc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - -#if 0 - // add our stuff... - gr_fir_ccc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_ccc_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - gr_fir_fff_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fff_altivec; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - -#if 0 - // add our stuff... - gr_fir_fsf_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_fsf_altivec; - (*info).push_back (t); - } -#endif -} - -void -gr_fir_sysconfig_powerpc::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - -#if 0 - // add our stuff... - gr_fir_scc_info t; - if (gr_cpu::has_altivec ()){ - t.name = "altivec"; - t.create = make_gr_fir_scc_altivec; - (*info).push_back (t); - } -#endif -} diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h deleted file mode 100644 index 09a7a0ba04..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 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_GR_FIR_SYSCONFIG_POWERPC_H -#define INCLUDED_GR_FIR_SYSCONFIG_POWERPC_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_powerpc : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc deleted file mode 100644 index 97b8106994..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc +++ /dev/null @@ -1,553 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_sysconfig_x86.h> -#include <gr_cpu.h> - -#include <gr_fir_ccf.h> -#include <gr_fir_ccf_generic.h> -#include <gr_fir_ccf_x86.h> -#include <gr_fir_fcc.h> -#include <gr_fir_fcc_generic.h> -#include <gr_fir_fcc_x86.h> -#include <gr_fir_fff.h> -#include <gr_fir_fff_generic.h> -#include <gr_fir_fff_x86.h> -#include <gr_fir_fsf.h> -#include <gr_fir_fsf_generic.h> -#include <gr_fir_fsf_x86.h> -#include <gr_fir_ccc.h> -#include <gr_fir_ccc_generic.h> -#include <gr_fir_ccc_x86.h> -#include <gr_fir_scc.h> -#include <gr_fir_scc_generic.h> -#include <gr_fir_scc_x86.h> -// #include <gr_fir_sss.h> -// #include <gr_fir_sss_generic.h> -// #include <gr_fir_sss_mmx.h> -// #include <gr_fir_sss_sse2.h> - -#include <iostream> -using std::cerr; - -/* - * ---------------------------------------------------------------- - * static functions that serve as constructors... - * Is it possible to take the address of a normal constructor? - * ---------------------------------------------------------------- - */ - -static gr_fir_ccf * -make_gr_fir_ccf_3dnow(const std::vector<float> &taps) -{ - return new gr_fir_ccf_3dnow(taps); -} - -static gr_fir_ccf * -make_gr_fir_ccf_sse(const std::vector<float> &taps) -{ - return new gr_fir_ccf_sse(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_3dnow(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_3dnow(taps); -} - -static gr_fir_fcc * -make_gr_fir_fcc_sse(const std::vector<gr_complex> &taps) -{ - return new gr_fir_fcc_sse(taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_3dnow (taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_3dnowext (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_3dnowext (taps); -} - -static gr_fir_ccc * -make_gr_fir_ccc_sse (const std::vector<gr_complex> &taps) -{ - return new gr_fir_ccc_sse (taps); -} - -static gr_fir_fff * -make_gr_fir_fff_3dnow (const std::vector<float> &taps) -{ - return new gr_fir_fff_3dnow (taps); -} - -static gr_fir_fff * -make_gr_fir_fff_sse (const std::vector<float> &taps) -{ - return new gr_fir_fff_sse (taps); -} - -static gr_fir_fsf * -make_gr_fir_fsf_3dnow (const std::vector<float> &taps) -{ - return new gr_fir_fsf_3dnow (taps); -} - -static gr_fir_fsf * -make_gr_fir_fsf_sse (const std::vector<float> &taps) -{ - return new gr_fir_fsf_sse (taps); -} - -#if 0 -static gr_fir_sss * -make_gr_fir_sss_mmx (const std::vector<short> &taps) -{ - return new gr_fir_sss_mmx (taps); -} - -static gr_fir_sss * -make_gr_fir_sss_sse2 (const std::vector<short> &taps) -{ - return new gr_fir_sss_sse2 (taps); -} -#endif - -static gr_fir_scc * -make_gr_fir_scc_3dnow(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_3dnow(taps); -} - -static gr_fir_scc * -make_gr_fir_scc_3dnowext(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_3dnowext(taps); -} - -static gr_fir_scc * -make_gr_fir_scc_sse(const std::vector<gr_complex> &taps) -{ - return new gr_fir_scc_sse(taps); -} - -/* - * ---------------------------------------------------------------- - * Return instances of the fastest x86 versions of these classes. - * - * check CPUID, if has 3DNowExt, return 3DNow!Ext version, - * else if 3DNow, return 3DNow! version, - * else if SSE2, return SSE2 version, - * else if SSE, return SSE version, - * else if MMX, return MMX version, - * else return generic version. - * - * FIXME: benchmark, store result, use stored result to - * select the fastest version. - * ---------------------------------------------------------------- - */ - -gr_fir_ccf * -gr_fir_sysconfig_x86::create_gr_fir_ccf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using 3DNow!\n"; - first = false; - } - return make_gr_fir_ccf_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_ccf: using SSE\n"; - first = false; - } - return make_gr_fir_ccf_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_ccf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps); -} - -gr_fir_fcc * -gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fcc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fcc: using SSE\n"; - first = false; - } - return make_gr_fir_fcc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fcc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps); -} - -gr_fir_ccc * -gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnowext ()){ - if (first) { - cerr << ">>> gr_fir_ccc: using 3DNow!Ext\n"; - first = false; - } - return make_gr_fir_ccc_3dnowext (taps); - } - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_ccc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_ccc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_ccc: using SSE\n"; - first = false; - } - return make_gr_fir_ccc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_ccc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps); -} - -gr_fir_fff * -gr_fir_sysconfig_x86::create_gr_fir_fff (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_fff: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fff_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fff: using SSE\n"; - first = false; - } - return make_gr_fir_fff_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fff: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fff (taps); -} - -gr_fir_fsf * -gr_fir_sysconfig_x86::create_gr_fir_fsf (const std::vector<float> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnow ()){ - if (first) { - cerr << ">>> gr_fir_fsf: using 3DNow!\n"; - first = false; - } - return make_gr_fir_fsf_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_fsf: using SSE\n"; - first = false; - } - return make_gr_fir_fsf_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_fsf: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps); -} - -#if 0 -gr_fir_sss * -gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps) -{ - // FIXME -- probably want to figure out best answer for Athlon and code - // add code to select it here... - - if (gr_cpu::has_sse2 ()){ - cerr << ">>> gr_fir_sss: using SSE2\n"; - return make_gr_fir_sss_sse2 (taps); - } - - if (gr_cpu::has_mmx ()){ - cerr << ">>> gr_fir_sss: using MMX\n"; - return make_gr_fir_sss_mmx (taps); - } - - cerr << ">>> gr_fir_sss: handing off to parent class\n"; - return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); -} -#endif - -gr_fir_scc * -gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps) -{ - static bool first = true; - - if (gr_cpu::has_3dnowext ()){ - if (first){ - cerr << ">>> gr_fir_scc: using 3DNow!Ext\n"; - first = false; - } - return make_gr_fir_scc_3dnowext (taps); - } - - if (gr_cpu::has_3dnow ()){ - if (first){ - cerr << ">>> gr_fir_scc: using 3DNow!\n"; - first = false; - } - return make_gr_fir_scc_3dnow (taps); - } - - if (gr_cpu::has_sse ()){ - if (first){ - cerr << ">>> gr_fir_scc: using SSE\n"; - first = false; - } - return make_gr_fir_scc_sse (taps); - } - - if (first){ - cerr << ">>> gr_fir_scc: handing off to parent class\n"; - first = false; - } - return gr_fir_sysconfig_generic::create_gr_fir_scc (taps); -} - -/* - * ---------------------------------------------------------------- - * Return info about available implementations - * ---------------------------------------------------------------- - */ - -void -gr_fir_sysconfig_x86::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info) -{ - gr_fir_ccf_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_ccf_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_ccf_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info) -{ - gr_fir_fcc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fcc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fcc_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info) -{ - gr_fir_ccc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnowext ()){ - t.name = "3DNow!Ext"; - t.create = make_gr_fir_ccc_3dnowext; - (*info).push_back (t); - } - - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_ccc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_ccc_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info) -{ - gr_fir_fff_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fff_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fff_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fff_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info) -{ - gr_fir_fsf_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info); - - // add our stuff... - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_fsf_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_fsf_sse; - (*info).push_back (t); - } -} - -void -gr_fir_sysconfig_x86::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info) -{ - gr_fir_scc_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_scc_info (info); - - // add our stuff... - if (gr_cpu::has_3dnowext ()){ - t.name = "3DNow!Ext"; - t.create = make_gr_fir_scc_3dnowext; - (*info).push_back (t); - } - - if (gr_cpu::has_3dnow ()){ - t.name = "3DNow!"; - t.create = make_gr_fir_scc_3dnow; - (*info).push_back (t); - } - - if (gr_cpu::has_sse ()){ - t.name = "SSE"; - t.create = make_gr_fir_scc_sse; - (*info).push_back (t); - } -} - -#if 0 -void -gr_fir_sysconfig_x86::get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info) -{ - gr_fir_sss_info t; - - // invoke parent.. - gr_fir_sysconfig_generic::get_gr_fir_sss_info (info); - - // add our stuff... - if (gr_cpu::has_mmx ()){ - t.name = "MMX"; - t.create = make_gr_fir_sss_mmx; - (*info).push_back (t); - } - - if (gr_cpu::has_sse2 ()){ - t.name = "SSE2"; - t.create = make_gr_fir_sss_sse2; - (*info).push_back (t); - } -} -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h deleted file mode 100644 index ebb399c8ba..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GR_FIR_SYSCONFIG_X86_H -#define INCLUDED_GR_FIR_SYSCONFIG_X86_H - -#include <gr_core_api.h> -#include <gr_fir_sysconfig_generic.h> - -class GR_CORE_API gr_fir_sysconfig_x86 : public gr_fir_sysconfig_generic { -public: - virtual gr_fir_ccf *create_gr_fir_ccf (const std::vector<float> &taps); - virtual gr_fir_fcc *create_gr_fir_fcc (const std::vector<gr_complex> &taps); - virtual gr_fir_fff *create_gr_fir_fff (const std::vector<float> &taps); - virtual gr_fir_fsf *create_gr_fir_fsf (const std::vector<float> &taps); - virtual gr_fir_scc *create_gr_fir_scc (const std::vector<gr_complex> &taps); - virtual gr_fir_ccc *create_gr_fir_ccc (const std::vector<gr_complex> &taps); -//virtual gr_fir_sss *create_gr_fir_sss (const std::vector<short> &taps); - - virtual void get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info); - virtual void get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info); - virtual void get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info); - virtual void get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info); - virtual void get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info); - virtual void get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info); -//virtual void get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc deleted file mode 100644 index 500958e3da..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2010 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 <gr_io_signature.h> -#include <gr_fractional_interpolator_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdexcept> - -// Public constructor -gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc(float phase_shift, float interp_ratio) -{ - return gnuradio::get_initial_sptr(new gr_fractional_interpolator_cc(phase_shift, interp_ratio)); -} - -gr_fractional_interpolator_cc::gr_fractional_interpolator_cc(float phase_shift, float interp_ratio) - : gr_block ("fractional_interpolator_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator_cc()) -{ - if (interp_ratio <= 0) - throw std::out_of_range ("interpolation ratio must be > 0"); - if (phase_shift < 0 || phase_shift > 1) - throw std::out_of_range ("phase shift ratio must be > 0 and < 1"); - - set_relative_rate (1.0 / interp_ratio); -} - -gr_fractional_interpolator_cc::~gr_fractional_interpolator_cc() -{ - delete d_interp; -} - -void -gr_fractional_interpolator_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - - ninput_items_required[i] = - (int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); -} - -int -gr_fractional_interpolator_cc::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - - while (oo < noutput_items) { - - out[oo++] = d_interp->interpolate(&in[ii], d_mu); - - double s = d_mu + d_mu_inc; - double f = floor (s); - int incr = (int) f; - d_mu = s - f; - ii += incr; - } - - consume_each (ii); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h deleted file mode 100644 index 29c67895a4..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 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_GR_FRACTIONAL_INTERPOLATOR_CC_H -#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_CC_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gri_mmse_fir_interpolator_cc; - -class gr_fractional_interpolator_cc; -typedef boost::shared_ptr<gr_fractional_interpolator_cc> gr_fractional_interpolator_cc_sptr; - -// public constructor -GR_CORE_API gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -/*! - * \brief Interpolating mmse filter with gr_complex input, gr_complex output - * \ingroup filter_blk - */ -class GR_CORE_API gr_fractional_interpolator_cc : public gr_block -{ -public: - ~gr_fractional_interpolator_cc (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - float mu() const { return d_mu;} - float interp_ratio() const { return d_mu_inc;} - void set_mu (float mu) { d_mu = mu; } - void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; } - -protected: - gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -private: - float d_mu; - float d_mu_inc; - gri_mmse_fir_interpolator_cc *d_interp; - - friend GR_CORE_API gr_fractional_interpolator_cc_sptr - gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i deleted file mode 100644 index d7341176a7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_cc); - -gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -class gr_fractional_interpolator_cc : public gr_block -{ -private: - gr_fractional_interpolator_cc (float phase_shift, float interp_ratio); - -public: - float mu() const; - float interp_ratio() const; - void set_mu (float mu); - void set_interp_ratio (float interp_ratio); -}; diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc deleted file mode 100644 index 9cbe31635d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2010 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 <gr_io_signature.h> -#include <gr_fractional_interpolator_ff.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdexcept> - -// Public constructor -gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff(float phase_shift, float interp_ratio) -{ - return gnuradio::get_initial_sptr(new gr_fractional_interpolator_ff(phase_shift, interp_ratio)); -} - -gr_fractional_interpolator_ff::gr_fractional_interpolator_ff(float phase_shift, float interp_ratio) - : gr_block ("fractional_interpolator_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_mu (phase_shift), d_mu_inc (interp_ratio), d_interp(new gri_mmse_fir_interpolator()) -{ - if (interp_ratio <= 0) - throw std::out_of_range ("interpolation ratio must be > 0"); - if (phase_shift < 0 || phase_shift > 1) - throw std::out_of_range ("phase shift ratio must be > 0 and < 1"); - - set_relative_rate (1.0 / interp_ratio); -} - -gr_fractional_interpolator_ff::~gr_fractional_interpolator_ff() -{ - delete d_interp; -} - -void -gr_fractional_interpolator_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - - ninput_items_required[i] = - (int) ceil((noutput_items * d_mu_inc) + d_interp->ntaps()); -} - -int -gr_fractional_interpolator_ff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - - while (oo < noutput_items) { - - out[oo++] = d_interp->interpolate(&in[ii], d_mu); - - double s = d_mu + d_mu_inc; - double f = floor (s); - int incr = (int) f; - d_mu = s - f; - ii += incr; - } - - consume_each (ii); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h deleted file mode 100644 index 7e000a6d1c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 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_GR_FRACTIONAL_INTERPOLATOR_FF_H -#define INCLUDED_GR_FRACTIONAL_INTERPOLATOR_FF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gri_mmse_fir_interpolator; - -class gr_fractional_interpolator_ff; -typedef boost::shared_ptr<gr_fractional_interpolator_ff> gr_fractional_interpolator_ff_sptr; - -// public constructor -GR_CORE_API gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -/*! - * \brief Interpolating mmse filter with float input, float output - * \ingroup filter_blk - */ -class GR_CORE_API gr_fractional_interpolator_ff : public gr_block -{ -public: - ~gr_fractional_interpolator_ff (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - float mu() const { return d_mu;} - float interp_ratio() const { return d_mu_inc;} - void set_mu (float mu) { d_mu = mu; } - void set_interp_ratio (float interp_ratio) { d_mu_inc = interp_ratio; } - -protected: - gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -private: - float d_mu; - float d_mu_inc; - gri_mmse_fir_interpolator *d_interp; - - friend GR_CORE_API gr_fractional_interpolator_ff_sptr - gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i deleted file mode 100644 index 4ec7c85cfc..0000000000 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,fractional_interpolator_ff); - -gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -class gr_fractional_interpolator_ff : public gr_block -{ -private: - gr_fractional_interpolator_ff (float phase_shift, float interp_ratio); - -public: - float mu() const; - float interp_ratio() const; - void set_mu (float mu); - void set_interp_ratio (float interp_ratio); -}; diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t deleted file mode 100644 index 3d65f872e6..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2010 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq) -{ - return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps, center_freq, sampling_freq)); -} - - -@NAME@::@NAME@ ( - - int decimation, - const std::vector<@TAP_TYPE@> &taps, - double center_freq, - double sampling_freq) - - : gr_sync_decimator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - decimation), - d_proto_taps (taps), d_center_freq (center_freq), d_sampling_freq (sampling_freq), - d_updated (false) -{ - std::vector<gr_complex> dummy_taps; - d_composite_fir = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_history (d_proto_taps.size ()); - build_composite_fir (); -} - -@NAME@::~@NAME@ () -{ - delete d_composite_fir; -} - -void -@NAME@::build_composite_fir () -{ - std::vector<gr_complex> ctaps (d_proto_taps.size ()); - - float fwT0 = 2 * M_PI * d_center_freq / d_sampling_freq; - for (unsigned int i = 0; i < d_proto_taps.size (); i++) - ctaps[i] = d_proto_taps[i] * exp (gr_complex (0, i * fwT0)); - - d_composite_fir->set_taps (gr_reverse(ctaps)); - d_r.set_phase_incr (exp (gr_complex (0, fwT0 * decimation ()))); -} - -void -@NAME@::set_center_freq (double center_freq) -{ - d_center_freq = center_freq; - d_updated = true; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_proto_taps = taps; - d_updated = true; -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @I_TYPE@ *in = (@I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - // rebuild composite FIR if the center freq has changed - - if (d_updated){ - set_history (d_proto_taps.size ()); - build_composite_fir (); - d_updated = false; - return 0; // history requirements may have changed. - } - - unsigned j = 0; - for (int i = 0; i < noutput_items; i++){ - out[i] = d_r.rotate (d_composite_fir->filter (&in[j])); - j += decimation (); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t deleted file mode 100644 index 97d20e04f5..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py Any changes made to this file - * will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> -#include <gr_rotator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -/*! - * Construct a FIR filter with the given taps and a composite frequency - * translation that shifts center_freq down to zero Hz. The frequency - * translation logically comes before the filtering operation. - */ -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - -class @FIR_TYPE@; - -/*! - * \brief FIR filter combined with frequency translation with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - * - * This class efficiently combines a frequency translation - * (typically "down conversion") with a FIR filter (typically low-pass) - * and decimation. It is ideally suited for a "channel selection filter" - * and can be efficiently used to select and decimate a narrow band signal - * out of wide bandwidth input. - * - * Uses a single input array to produce a single output array. - * Additional inputs and/or outputs are ignored. - */ -class GR_CORE_API @NAME@ : public gr_sync_decimator -{ - public: - virtual ~@NAME@ (); - - void set_center_freq (double center_freq); - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - private: - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - protected: - std::vector<@TAP_TYPE@> d_proto_taps; - @FIR_TYPE@ *d_composite_fir; - gr_rotator d_r; - double d_center_freq; - double d_sampling_freq; - bool d_updated; - - virtual void build_composite_fir (); - - /*! - * Construct a FIR filter with the given taps and a composite frequency - * translation that shifts center_freq down to zero Hz. The frequency - * translation logically comes before the filtering operation. - */ - @NAME@ (int decimation, - const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); -}; - -#endif /* _@NAME@_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t deleted file mode 100644 index ac6c8c9e1e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.i.t +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_freq_xlating_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - -class @NAME@ : public gr_sync_decimator -{ - protected: - @NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, - double center_freq, double sampling_freq); - - public: - ~@NAME@ (); - - void set_center_freq (double center_freq); - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc b/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc deleted file mode 100644 index 07bed8157b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010,2011 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 <gr_goertzel_fc.h> -#include <gr_io_signature.h> - -// public constructor -gr_goertzel_fc_sptr -gr_make_goertzel_fc(int rate, int len, float freq) -{ - return gnuradio::get_initial_sptr(new gr_goertzel_fc(rate, len, freq)); -} - -gr_goertzel_fc::gr_goertzel_fc(int rate, int len, float freq) - : gr_sync_decimator("goertzel_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex)), - len), - d_goertzel(rate, len, freq) -{ - d_len = len; - d_rate = rate; - d_freq = freq; -} - -int gr_goertzel_fc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *)input_items[0]; - gr_complex *out = (gr_complex *)output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - *out++ = d_goertzel.batch(in); - in += d_len; - } - - return noutput_items; -} - -void -gr_goertzel_fc::set_freq(float freq) -{ - d_freq = freq; - d_goertzel.gri_setparms(d_rate, d_len, d_freq); -} - -void -gr_goertzel_fc::set_rate(int rate) -{ - d_rate = rate; - d_goertzel.gri_setparms(d_rate, d_len, d_freq); -} diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h deleted file mode 100644 index 5fb6e0ee05..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 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_GR_GOERTZEL_FC_H -#define INCLUDED_GR_GOERTZEL_FC_H - -#include <gr_core_api.h> -#include <gri_goertzel.h> -#include <gr_sync_decimator.h> - -class gr_goertzel_fc; -typedef boost::shared_ptr<gr_goertzel_fc> gr_goertzel_fc_sptr; - -// public constructor -GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); - -/*! - * \brief Goertzel single-bin DFT calculation. - * \ingroup dft_blk - */ -class GR_CORE_API gr_goertzel_fc : public gr_sync_decimator -{ -private: - friend GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc (int rate, int len, float freq); - - gr_goertzel_fc(int rate, int len, float freq); - gri_goertzel d_goertzel; - int d_len; - float d_freq; - int d_rate; - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_freq (float freq); - void set_rate (int rate); -}; - -#endif /* INCLUDED_GR_GOERTZEL_FC_H */ - diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.i b/gnuradio-core/src/lib/filter/gr_goertzel_fc.i deleted file mode 100644 index 775c78cc8e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,goertzel_fc); - -gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq); - -class gr_goertzel_fc : public gr_sync_decimator -{ -private: - gr_goertzel_fc(); - -public: - void set_freq (float freq); - void set_rate (int rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc b/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc deleted file mode 100644 index 385e24ad2b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <gr_hilbert_fc.h> -#include <gr_firdes.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> - -// public constructor -gr_hilbert_fc_sptr -gr_make_hilbert_fc (unsigned int ntaps) -{ - return gnuradio::get_initial_sptr(new gr_hilbert_fc (ntaps)); -} - -gr_hilbert_fc::gr_hilbert_fc (unsigned int ntaps) - : gr_sync_block ("hilbert_fc", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_ntaps (ntaps | 0x1), // ensure ntaps is odd - d_hilb (gr_fir_util::create_gr_fir_fff (gr_firdes::hilbert (d_ntaps))) -{ - set_history (d_ntaps); -} - -gr_hilbert_fc::~gr_hilbert_fc () -{ - delete d_hilb; -} - -int -gr_hilbert_fc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = gr_complex (in[i + d_ntaps/2], - d_hilb->filter (&in[i])); - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h deleted file mode 100644 index 2bb5ff9e37..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_GR_HILBERT_FC_H -#define INCLUDED_GR_HILBERT_FC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_io_signature.h> -#include <gr_types.h> - -class gr_hilbert_fc; -typedef boost::shared_ptr<gr_hilbert_fc> gr_hilbert_fc_sptr; - -// public constructor -GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); - - -class gr_fir_fff; - -/*! - * \brief Hilbert transformer. - * \ingroup filter_blk - * - * real output is input appropriately delayed. - * imaginary output is hilbert filtered (90 degree phase shift) - * version of input. - */ -class GR_CORE_API gr_hilbert_fc : public gr_sync_block -{ - public: - ~gr_hilbert_fc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - protected: - gr_hilbert_fc (unsigned int ntaps); - - private: - unsigned int d_ntaps; - gr_fir_fff *d_hilb; - - friend GR_CORE_API gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); -}; - - - -#endif /* INCLUDED_GR_HILBERT_FC_H */ diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.i b/gnuradio-core/src/lib/filter/gr_hilbert_fc.i deleted file mode 100644 index 91d4e23eb7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,hilbert_fc); - -gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps); - -class gr_hilbert_fc : public gr_sync_block -{ -protected: - gr_hilbert_fc (unsigned int ntaps); - -public: - ~gr_hilbert_fc (); -}; diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc deleted file mode 100644 index 4da2aa310b..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <gr_iir_filter_ffd.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) -{ - return gnuradio::get_initial_sptr(new gr_iir_filter_ffd (fftaps, fbtaps)); -} - -gr_iir_filter_ffd::gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) - - : gr_sync_block ("iir_filter_ffd", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_iir (fftaps, fbtaps), - d_updated (false) -{ - // fprintf (stderr, "gr_iir_filter_ffd::ctor\n"); -} - -gr_iir_filter_ffd::~gr_iir_filter_ffd () -{ - // nop -} - -void -gr_iir_filter_ffd::set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument) -{ - - d_new_fftaps = fftaps; - d_new_fbtaps = fbtaps; - d_updated = true; -} - -int -gr_iir_filter_ffd::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - - if (d_updated){ - d_iir.set_taps (d_new_fftaps, d_new_fbtaps); - d_updated = false; - } - - d_iir.filter_n (out, in, noutput_items); - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h deleted file mode 100644 index ab7065e921..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_GR_IIR_FILTER_FFD_H -#define INCLUDED_GR_IIR_FILTER_FFD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_iir.h> -#include <stdexcept> - -class gr_iir_filter_ffd; -typedef boost::shared_ptr<gr_iir_filter_ffd> gr_iir_filter_ffd_sptr; -GR_CORE_API gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - -/*! - * \brief IIR filter with float input, float output and double taps - * \ingroup filter_blk - * - * This filter uses the Direct Form I implementation, where - * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. - * - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \f} - \endhtmlonly - - \xmlonly - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}} - \f} - \endhtmlonly - - \xmlonly - H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback taps. - */ -class GR_CORE_API gr_iir_filter_ffd : public gr_sync_block -{ - private: - friend GR_CORE_API gr_iir_filter_ffd_sptr - gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - gri_iir<float,float,double> d_iir; - std::vector<double> d_new_fftaps; - std::vector<double> d_new_fbtaps; - bool d_updated; - - /*! - * Construct an IIR filter with the given taps - */ - gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - public: - ~gr_iir_filter_ffd (); - - void set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i deleted file mode 100644 index 0a35ad89e1..0000000000 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,iir_filter_ffd); - -gr_iir_filter_ffd_sptr -gr_make_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - -class gr_iir_filter_ffd : public gr_sync_block -{ - private: - gr_iir_filter_ffd (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); - - public: - ~gr_iir_filter_ffd (); - - void set_taps (const std::vector<double> &fftaps, - const std::vector<double> &fbtaps) throw (std::invalid_argument); -}; diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t deleted file mode 100644 index 55297d1eb9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -@SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (interpolation, taps)); -} - - -@NAME@::@NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps) - : gr_sync_interpolator ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@)), - interpolation), - d_updated (false), d_firs (interpolation) -{ - if (interpolation == 0) - throw std::out_of_range ("interpolation must be > 0"); - - std::vector<@TAP_TYPE@> dummy_taps; - - for (unsigned i = 0; i < interpolation; i++) - d_firs[i] = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_taps (taps); - install_taps(d_new_taps); -} - -@NAME@::~@NAME@ () -{ - int interp = interpolation (); - for (int i = 0; i < interp; i++) - delete d_firs[i]; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; - - // round up length to a multiple of the interpolation factor - int n = taps.size () % interpolation (); - if (n > 0){ - n = interpolation () - n; - while (n-- > 0) - d_new_taps.insert(d_new_taps.begin(), 0); - } - - assert (d_new_taps.size () % interpolation () == 0); -} - - -void -@NAME@::install_taps (const std::vector<@TAP_TYPE@> &taps) -{ - int nfilters = interpolation (); - int nt = taps.size () / nfilters; - - assert (nt * nfilters == (int) taps.size ()); - - std::vector< std::vector <@TAP_TYPE@> > xtaps (nfilters); - - for (int n = 0; n < nfilters; n++) - xtaps[n].resize (nt); - - for (int i = 0; i < (int) taps.size(); i++) - xtaps[i % nfilters][i / nfilters] = taps[i]; - - for (int n = 0; n < nfilters; n++) - d_firs[n]->set_taps (xtaps[n]); - - set_history (nt); - d_updated = false; - -#if 0 - for (int i = 0; i < nfilters; i++){ - std::cout << "filter[" << i << "] = "; - for (int j = 0; j < nt; j++) - std::cout << xtaps[i][j] << " "; - - std::cout << "\n"; - } -#endif - -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - install_taps (d_new_taps); - return 0; // history requirements may have changed. - } - - int nfilters = interpolation (); - int ni = noutput_items / interpolation (); - - for (int i = 0; i < ni; i++){ - for (int nf = 0; nf < nfilters; nf++) - out[nf] = d_firs[nf]->filter (&in[i]); - out += nfilters; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t deleted file mode 100644 index 83904dce21..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py - * Any changes made to this file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_sync_interpolator -{ - private: - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - std::vector<@FIR_TYPE@ *> d_firs; - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps); - - void install_taps (const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t deleted file mode 100644 index 2747530016..0000000000 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.i.t +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -/* - * WARNING: This file is automatically generated by generate_GrFIRfilterXXX.py - * Any changes made to this file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int interpolation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_sync_interpolator -{ - private: - @NAME@ (int interpolation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc deleted file mode 100644 index 06e98447ec..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <gr_pfb_arb_resampler_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size) -{ - return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_ccf (rate, taps, - filter_size)); -} - - -gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size) - : gr_block ("pfb_arb_resampler_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_updated (false) -{ - d_acc = 0; // start accumulator at 0 - - /* The number of filters is specified by the user as the filter size; - this is also the interpolation rate of the filter. We use it and the - rate provided to determine the decimation rate. This acts as a - rational resampler. The flt_rate is calculated as the residual - between the integer decimation rate and the real decimation rate and - will be used to determine to interpolation point of the resampling - process. - */ - d_int_rate = filter_size; - set_rate(rate); - - // Store the last filter between calls to work - d_last_filter = 0; - - d_start_index = 0; - - d_filters = std::vector<gr_fir_ccf*>(d_int_rate); - d_diff_filters = std::vector<gr_fir_ccf*>(d_int_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_int_rate); - for(unsigned int i = 0; i < d_int_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - create_taps(taps, d_taps, d_filters); - create_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_arb_resampler_ccf::~gr_pfb_arb_resampler_ccf () -{ - for(unsigned int i = 0; i < d_int_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_arb_resampler_ccf::create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter) -{ - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_int_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_int_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(unsigned int i = 0; i < d_int_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(unsigned int j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + 1); - - d_updated = true; -} - -void -gr_pfb_arb_resampler_ccf::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - // Calculate the differential taps (derivative filter) by taking the difference - // between two taps. Duplicate the last one to make both filters the same length. - float tap; - difftaps.clear(); - for(unsigned int i = 0; i < newtaps.size()-1; i++) { - tap = newtaps[i+1] - newtaps[i]; - difftaps.push_back(tap); - } - difftaps.push_back(tap); -} - -void -gr_pfb_arb_resampler_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_int_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n"); - } -} - -int -gr_pfb_arb_resampler_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = d_start_index; - unsigned int j; - gr_complex o0, o1; - - // Restore the last filter position - j = d_last_filter; - - // produce output as long as we can and there are enough input samples - int max_input = ninput_items[0]-(int)d_taps_per_filter; - while((i < noutput_items) && (count < max_input)) { - // start j by wrapping around mod the number of channels - while((j < d_int_rate) && (i < noutput_items)) { - // Take the current filter and derivative filter output - o0 = d_filters[j]->filter(&in[count]); - o1 = d_diff_filters[j]->filter(&in[count]); - - out[i] = o0 + o1*d_acc; // linearly interpolate between samples - i++; - - // Adjust accumulator and index into filterbank - d_acc += d_flt_rate; - j += d_dec_rate + (int)floor(d_acc); - d_acc = fmodf(d_acc, 1.0); - } - if(i < noutput_items) { // keep state for next entry - float ss = (int)(j / d_int_rate); // number of items to skip ahead by - count += ss; // we have fully consumed another input - j = j % d_int_rate; // roll filter around - } - } - - // Store the current filter position and start of next sample - d_last_filter = j; - d_start_index = std::max(0, count - ninput_items[0]); - - // consume all we've processed but no more than we can - consume_each(std::min(count, ninput_items[0])); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h deleted file mode 100644 index d92898a23e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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_GR_PFB_ARB_RESAMPLER_CCF_H -#define INCLUDED_GR_PFB_ARB_RESAMPLER_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_arb_resampler_ccf; -typedef boost::shared_ptr<gr_pfb_arb_resampler_ccf> gr_pfb_arb_resampler_ccf_sptr; -GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_arb_resampler_ccf - * - * \brief Polyphase filterbank arbitrary resampler with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs arbitrary - * resampling. The resampling rate can be any real - * number <EM>r</EM>. The resampling is done by constructing - * <EM>N</EM> filters where <EM>N</EM> is the interpolation rate. We - * then calculate <EM>D</EM> where <EM>D = floor(N/r)</EM>. - * - * Using <EM>N</EM> and <EM>D</EM>, we can perform rational resampling - * where <EM>N/D</EM> is a rational number close to the input rate - * <EM>r</EM> where we have <EM>N</EM> filters and we cycle through - * them as a polyphase filterbank with a stride of <EM>D</EM> so that - * <EM>i+1 = (i + D) % N</EM>. - * - * To get the arbitrary rate, we want to interpolate between two - * points. For each value out, we take an output from the current - * filter, <EM>i</EM>, and the next filter <EM>i+1</EM> and then - * linearly interpolate between the two based on the real resampling - * rate we want. - * - * The linear interpolation only provides us with an approximation to - * the real sampling rate specified. The error is a quantization error - * between the two filters we used as our interpolation points. To - * this end, the number of filters, <EM>N</EM>, used determines the - * quantization error; the larger <EM>N</EM>, the smaller the - * noise. You can design for a specified noise floor by setting the - * filter size (parameters <EM>filter_size</EM>). The size defaults to - * 32 filters, which is about as good as most implementations need. - * - * The trick with designing this filter is in how to specify the taps - * of the prototype filter. Like the PFB interpolator, the taps are - * specified using the interpolated filter rate. In this case, that - * rate is the input sample rate multiplied by the number of filters - * in the filterbank, which is also the interpolation rate. All other - * values should be relative to this rate. - * - * For example, for a 32-filter arbitrary resampler and using the - * GNU Radio's firdes utility to build the filter, we build a low-pass - * filter with a sampling rate of <EM>fs</EM>, a 3-dB bandwidth of - * <EM>BW</EM> and a transition bandwidth of <EM>TB</EM>. We can also - * specify the out-of-band attenuation to use, <EM>ATT</EM>, and the - * filter window function (a Blackman-harris window in this case). The - * first input is the gain of the filter, which we specify here as the - * interpolation rate (<EM>32</EM>). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(32, 32*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The theory behind this block can be found in Chapter 7.5 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_arb_resampler_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - friend GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - unsigned int d_int_rate; // the number of filters (interpolation rate) - unsigned int d_dec_rate; // the stride through the filters (decimation rate) - float d_flt_rate; // residual rate for the linear interpolation - float d_acc; - unsigned int d_last_filter; - int d_start_index; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param newtaps (vector of floats) The prototype filter to populate the filterbank. - * The taps should be generated at the interpolated sampling rate. - * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. - * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. - */ - void create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - -public: - ~gr_pfb_arb_resampler_ccf (); - - // FIXME: See about a set_taps function during runtime. - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - void set_rate (float rate) { - d_dec_rate = (unsigned int)floor(d_int_rate/rate); - d_flt_rate = (d_int_rate/rate) - d_dec_rate; - set_relative_rate(rate); - } - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i deleted file mode 100644 index da58947e92..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_arb_resampler_ccf); - -gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_pfb_arb_resampler_ccf : public gr_block -{ - private: - gr_pfb_arb_resampler_ccf (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - public: - ~gr_pfb_arb_resampler_ccf (); - - //void set_taps (const std::vector<float> &taps); - void print_taps(); - void set_rate (float rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc deleted file mode 100644 index 9a9b869929..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-2011 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 <gr_pfb_arb_resampler_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size) -{ - return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_fff (rate, taps, - filter_size)); -} - - -gr_pfb_arb_resampler_fff::gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size) - : gr_block ("pfb_arb_resampler_fff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (1, 1, sizeof(float))), - d_updated (false) -{ - d_acc = 0; // start accumulator at 0 - - /* The number of filters is specified by the user as the filter size; - this is also the interpolation rate of the filter. We use it and the - rate provided to determine the decimation rate. This acts as a - rational resampler. The flt_rate is calculated as the residual - between the integer decimation rate and the real decimation rate and - will be used to determine to interpolation point of the resampling - process. - */ - d_int_rate = filter_size; - set_rate(rate); - - // Store the last filter between calls to work - d_last_filter = 0; - - d_start_index = 0; - - d_filters = std::vector<gr_fir_fff*>(d_int_rate); - d_diff_filters = std::vector<gr_fir_fff*>(d_int_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_int_rate); - for(unsigned int i = 0; i < d_int_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - create_taps(taps, d_taps, d_filters); - create_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_arb_resampler_fff::~gr_pfb_arb_resampler_fff () -{ - for(unsigned int i = 0; i < d_int_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_arb_resampler_fff::create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter) -{ - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_int_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_int_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(unsigned int i = 0; i < d_int_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_int_rate-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(unsigned int j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_int_rate-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + 1); - - d_updated = true; -} - -void -gr_pfb_arb_resampler_fff::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - // Calculate the differential taps (derivative filter) by taking the difference - // between two taps. Duplicate the last one to make both filters the same length. - float tap; - difftaps.clear(); - for(unsigned int i = 0; i < newtaps.size()-1; i++) { - tap = newtaps[i+1] - newtaps[i]; - difftaps.push_back(tap); - } - difftaps.push_back(tap); -} - -void -gr_pfb_arb_resampler_fff::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_int_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n"); - } -} - -int -gr_pfb_arb_resampler_fff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - float *out = (float *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = d_start_index; - unsigned int j; - float o0, o1; - - // Restore the last filter position - j = d_last_filter; - - // produce output as long as we can and there are enough input samples - int max_input = ninput_items[0]-(int)d_taps_per_filter; - while((i < noutput_items) && (count < max_input)) { - // start j by wrapping around mod the number of channels - while((j < d_int_rate) && (i < noutput_items)) { - // Take the current filter and derivative filter output - o0 = d_filters[j]->filter(&in[count]); - o1 = d_diff_filters[j]->filter(&in[count]); - - out[i] = o0 + o1*d_acc; // linearly interpolate between samples - i++; - - // Adjust accumulator and index into filterbank - d_acc += d_flt_rate; - j += d_dec_rate + (int)floor(d_acc); - d_acc = fmodf(d_acc, 1.0); - } - if(i < noutput_items) { // keep state for next entry - float ss = (int)(j / d_int_rate); // number of items to skip ahead by - count += ss; // we have fully consumed another input - j = j % d_int_rate; // roll filter around - } - } - - // Store the current filter position and start of next sample - d_last_filter = j; - d_start_index = std::max(0, count - ninput_items[0]); - - // consume all we've processed but no more than we can - consume_each(std::min(count, ninput_items[0])); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h deleted file mode 100644 index d2e375210d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-2011 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_GR_PFB_ARB_RESAMPLER_FFF_H -#define INCLUDED_GR_PFB_ARB_RESAMPLER_FFF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_arb_resampler_fff; -typedef boost::shared_ptr<gr_pfb_arb_resampler_fff> gr_pfb_arb_resampler_fff_sptr; -GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_fir_fff; - -/*! - * \class gr_pfb_arb_resampler_fff - * - * \brief Polyphase filterbank arbitrary resampler with - * float input, float output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs arbitrary - * resampling. The resampling rate can be any real - * number <EM>r</EM>. The resampling is done by constructing - * <EM>N</EM> filters where <EM>N</EM> is the interpolation rate. We - * then calculate <EM>D</EM> where <EM>D = floor(N/r)</EM>. - * - * Using <EM>N</EM> and <EM>D</EM>, we can perform rational resampling - * where <EM>N/D</EM> is a rational number close to the input rate - * <EM>r</EM> where we have <EM>N</EM> filters and we cycle through - * them as a polyphase filterbank with a stride of <EM>D</EM> so that - * <EM>i+1 = (i + D) % N</EM>. - * - * To get the arbitrary rate, we want to interpolate between two - * points. For each value out, we take an output from the current - * filter, <EM>i</EM>, and the next filter <EM>i+1</EM> and then - * linearly interpolate between the two based on the real resampling - * rate we want. - * - * The linear interpolation only provides us with an approximation to - * the real sampling rate specified. The error is a quantization error - * between the two filters we used as our interpolation points. To - * this end, the number of filters, <EM>N</EM>, used determines the - * quantization error; the larger <EM>N</EM>, the smaller the - * noise. You can design for a specified noise floor by setting the - * filter size (parameters <EM>filter_size</EM>). The size defaults to - * 32 filters, which is about as good as most implementations need. - * - * The trick with designing this filter is in how to specify the taps - * of the prototype filter. Like the PFB interpolator, the taps are - * specified using the interpolated filter rate. In this case, that - * rate is the input sample rate multiplied by the number of filters - * in the filterbank, which is also the interpolation rate. All other - * values should be relative to this rate. - * - * For example, for a 32-filter arbitrary resampler and using the - * GNU Radio's firdes utility to build the filter, we build a low-pass - * filter with a sampling rate of <EM>fs</EM>, a 3-dB bandwidth of - * <EM>BW</EM> and a transition bandwidth of <EM>TB</EM>. We can also - * specify the out-of-band attenuation to use, <EM>ATT</EM>, and the - * filter window function (a Blackman-harris window in this case). The - * first input is the gain of the filter, which we specify here as the - * interpolation rate (<EM>32</EM>). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(32, 32*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The theory behind this block can be found in Chapter 7.5 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_arb_resampler_fff : public gr_block -{ - private: - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - friend GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - std::vector<gr_fir_fff*> d_filters; - std::vector<gr_fir_fff*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - unsigned int d_int_rate; // the number of filters (interpolation rate) - unsigned int d_dec_rate; // the stride through the filters (decimation rate) - float d_flt_rate; // residual rate for the linear interpolation - float d_acc; - unsigned int d_last_filter; - int d_start_index; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Build the polyphase filterbank arbitray resampler. - * \param rate (float) Specifies the resampling rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the filter_size sampling rate. - * \param filter_size (unsigned int) The number of filters in the filter bank. This is directly - related to quantization noise introduced during the resampling. - Defaults to 32 filters. - */ - gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param newtaps (vector of floats) The prototype filter to populate the filterbank. - * The taps should be generated at the interpolated sampling rate. - * \param ourtaps (vector of floats) Reference to our internal member of holding the taps. - * \param ourfilter (vector of filters) Reference to our internal filter to set the taps for. - */ - void create_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - -public: - ~gr_pfb_arb_resampler_fff (); - - // FIXME: See about a set_taps function during runtime. - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - void set_rate (float rate) { - d_dec_rate = (unsigned int)floor(d_int_rate/rate); - d_flt_rate = (d_int_rate/rate) - d_dec_rate; - set_relative_rate(rate); - } - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i deleted file mode 100644 index ad09053610..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_arb_resampler_fff); - -gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size=32); - -class gr_pfb_arb_resampler_fff : public gr_block -{ - private: - gr_pfb_arb_resampler_fff (float rate, - const std::vector<float> &taps, - unsigned int filter_size); - - public: - ~gr_pfb_arb_resampler_fff (); - - //void set_taps (const std::vector<float> &taps); - void print_taps(); - void set_rate (float rate); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc deleted file mode 100644 index a8cb849e27..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <gr_pfb_channelizer_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <cstring> - -gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate) -{ - return gnuradio::get_initial_sptr(new gr_pfb_channelizer_ccf (numchans, taps, - oversample_rate)); -} - - -gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate) - : gr_block ("pfb_channelizer_ccf", - gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, numchans, sizeof(gr_complex))), - d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate) -{ - // The over sampling rate must be rationally related to the number of channels - // in that it must be N/i for i in [1,N], which gives an outputsample rate - // of [fs/N, fs] where fs is the input sample rate. - // This tests the specified input sample rate to see if it conforms to this - // requirement within a few significant figures. - double intp = 0; - double fltp = modf(numchans / oversample_rate, &intp); - if(fltp != 0.0) - throw std::invalid_argument("gr_pfb_channelizer: oversample rate must be N/i for i in [1, N]"); - - set_relative_rate(1.0/intp); - - d_filters = std::vector<gr_fir_ccf*>(d_numchans); - d_channel_map.resize(d_numchans); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_numchans); - for(unsigned int i = 0; i < d_numchans; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_channel_map[i] = i; - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the FFT to handle the output de-spinning of the channels - d_fft = new gri_fft_complex (d_numchans, false); - - // Although the filters change, we use this look up table - // to set the index of the FFT input buffer, which equivalently - // performs the FFT shift operation on every other turn. - d_rate_ratio = (int)rintf(d_numchans / d_oversample_rate); - d_idxlut = new int[d_numchans]; - for(unsigned int i = 0; i < d_numchans; i++) { - d_idxlut[i] = d_numchans - ((i + d_rate_ratio) % d_numchans) - 1; - } - - // Calculate the number of filtering rounds to do to evenly - // align the input vectors with the output channels - d_output_multiple = 1; - while((d_output_multiple * d_rate_ratio) % d_numchans != 0) - d_output_multiple++; - set_output_multiple(d_output_multiple); -} - -gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf () -{ - delete d_fft; - delete [] d_idxlut; - - for(unsigned int i = 0; i < d_numchans; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_channelizer_ccf::set_taps (const std::vector<float> &taps) -{ - gruel::scoped_lock guard(d_mutex); - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_channelizer_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_numchans; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -std::vector< std::vector<float> > -gr_pfb_channelizer_ccf::taps() const -{ - return d_taps; -} - -void -gr_pfb_channelizer_ccf::set_channel_map(const std::vector<int> &map) -{ - gruel::scoped_lock guard(d_mutex); - - if(map.size() > 0) { - unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_numchans) || (min < 0)) { - throw std::invalid_argument("gr_pfb_channelizer_ccf::set_channel_map: map range out of bounds.\n"); - } - d_channel_map = map; - } -} - -std::vector<int> -gr_pfb_channelizer_ccf::channel_map() const -{ - return d_channel_map; -} - - -int -gr_pfb_channelizer_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock guard(d_mutex); - - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - size_t noutputs = output_items.size(); - - int n=1, i=-1, j=0, oo=0, last; - int toconsume = (int)rintf(noutput_items/d_oversample_rate); - while(n <= toconsume) { - j = 0; - i = (i + d_rate_ratio) % d_numchans; - last = i; - while(i >= 0) { - in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n]); - j++; - i--; - } - - i = d_numchans-1; - while(i > last) { - in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n-1]); - j++; - i--; - } - - n += (i+d_rate_ratio) >= (int)d_numchans; - - // despin through FFT - d_fft->execute(); - - // Send to output channels - for(unsigned int nn = 0; nn < noutputs; nn++) { - out = (gr_complex*)output_items[nn]; - out[oo] = d_fft->get_outbuf()[d_channel_map[nn]]; - } - oo++; - } - - consume_each(toconsume); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h deleted file mode 100644 index 79ad322f9a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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_GR_PFB_CHANNELIZER_CCF_H -#define INCLUDED_GR_PFB_CHANNELIZER_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <gruel/thread.h> - -class gr_pfb_channelizer_ccf; -typedef boost::shared_ptr<gr_pfb_channelizer_ccf> gr_pfb_channelizer_ccf_sptr; -GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate=1); - -class gr_fir_ccf; -class gri_fft_complex; - - -/*! - * \class gr_pfb_channelizer_ccf - * - * \brief Polyphase filterbank channelizer with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in complex inputs and channelizes it to <EM>M</EM> - * channels of equal bandwidth. Each of the resulting channels is - * decimated to the new rate that is the input sampling rate - * <EM>fs</EM> divided by the number of channels, <EM>M</EM>. - * - * The PFB channelizer code takes the taps generated above and builds - * a set of filters. The set contains <EM>M</EM> number of filters - * and each filter contains ceil(taps.size()/decim) number of taps. - * Each tap from the filter prototype is sequentially inserted into - * the next filter. When all of the input taps are used, the remaining - * filters in the filterbank are filled out with 0's to make sure each - * filter has the same number of taps. - * - * Each filter operates using the gr_fir filter classs of GNU Radio, - * which takes the input stream at <EM>i</EM> and performs the inner - * product calculation to <EM>i+(n-1)</EM> where <EM>n</EM> is the - * number of filter taps. To efficiently handle this in the GNU Radio - * structure, each filter input must come from its own input - * stream. So the channelizer must be provided with <EM>M</EM> streams - * where the input stream has been deinterleaved. This is most easily - * done using the gr_stream_to_streams block. - * - * The output is then produced as a vector, where index <EM>i</EM> in - * the vector is the next sample from the <EM>i</EM>th channel. This - * is most easily handled by sending the output to a - * gr_vector_to_streams block to handle the conversion and passing - * <EM>M</EM> streams out. - * - * The input and output formatting is done using a hier_block2 called - * pfb_channelizer_ccf. This can take in a single stream and outputs - * <EM>M</EM> streams based on the behavior described above. - * - * The filter's taps should be based on the input sampling rate. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, <EM>ATT</EM>, and the filter window - * function (a Blackman-harris window in this case). The first input - * is the gain of the filter, which we specify here as unity. - * - * <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The filter output can also be overs ampled. The over sampling rate - * is the ratio of the the actual output sampling rate to the normal - * output sampling rate. It must be rationally related to the number - * of channels as N/i for i in [1,N], which gives an outputsample rate - * of [fs/N, fs] where fs is the input sample rate and N is the number - * of channels. - * - * For example, for 6 channels with fs = 6000 Hz, the normal rate is - * 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4, - * 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample - * ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2, - * so the output rate would be 1200 Hz. - * - * The theory behind this block can be found in Chapter 6 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - * - */ - -class GR_CORE_API gr_pfb_channelizer_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank decimator. - * \param numchans (unsigned integer) Specifies the number of channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param oversample_rate (float) The over sampling rate is the ratio of the the actual - * output sampling rate to the normal output sampling rate. - * It must be rationally related to the number of channels - * as N/i for i in [1,N], which gives an outputsample rate - * of [fs/N, fs] where fs is the input sample rate and N is - * the number of channels. - * - * For example, for 6 channels with fs = 6000 Hz, the normal - * rate is 6000/6 = 1000 Hz. Allowable oversampling rates - * are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output - * sample rate of a 6/1 oversample ratio is 6000 Hz, or - * 6 times the normal 1000 Hz. - */ - friend GR_CORE_API gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - - bool d_updated; - unsigned int d_numchans; - float d_oversample_rate; - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - unsigned int d_taps_per_filter; - gri_fft_complex *d_fft; - int *d_idxlut; - int d_rate_ratio; - int d_output_multiple; - std::vector<int> d_channel_map; - gruel::mutex d_mutex; // mutex to protect set/work access - - /*! - * Build the polyphase filterbank decimator. - * \param numchans (unsigned integer) Specifies the number of channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param oversample_rate (float) The output over sampling rate. - */ - gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - -public: - ~gr_pfb_channelizer_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Return a vector<vector<>> of the filterbank taps - */ - std::vector<std::vector<float> > taps() const; - - /*! - * Set the channel map. Channels are numbers as: - * - * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2 - * <------------------- 0 --------------------> - * freq - * - * So output stream 0 comes from channel 0, etc. Setting a new - * channel map allows the user to specify which channel in frequency - * he/she wants to got to which output stream. - * - * The map should have the same number of elements as the number of - * output connections from the block. The minimum value of the map - * is 0 (for the 0th channel) and the maximum number is N-1 where N - * is the number of channels. - * - * We specify M as the number of output connections made where M <= - * N, so only M out of N channels are driven to an output - * stream. The number of items in the channel map should be at least - * M long. If there are more channels specified, any value in the - * map over M-1 will be ignored. If the size of the map is less than - * M the behavior is unknown (we don't wish to check every entry - * into the work function). - * - * This means that if the channelizer is splitting the signal up - * into N channels but only M channels are specified in the map - * (where M <= N), then M output streams must be connected and the - * map and the channel numbers used must be less than N-1. Output - * channel number can be reused, too. By default, the map is - * [0...M-1] with M = N. - */ - void set_channel_map(const std::vector<int> &map); - - /*! - * Gets the current channel map. - */ - std::vector<int> channel_map() const; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i deleted file mode 100644 index 1f2b49452f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_channelizer_ccf); - -gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate=1); - -class gr_pfb_channelizer_ccf : public gr_block -{ - private: - gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - float oversample_rate); - - public: - ~gr_pfb_channelizer_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); - std::vector<std::vector<float> > taps() const; - - void set_channel_map(const std::vector<int> &map); - std::vector<int> channel_map() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc deleted file mode 100644 index efe417918a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc +++ /dev/null @@ -1,441 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-2011 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 <cstdio> -#include <cmath> - -#include <gr_pfb_clock_sync_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) -{ - return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_ccf (sps, loop_bw, taps, - filter_size, - init_phase, - max_rate_deviation, - osps)); -} - -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_pfb_clock_sync_ccf::gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) - : gr_block ("pfb_clock_sync_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation), - d_osps(osps), d_error(0), d_out_idx(0) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Set the damping factor for a critically damped system - d_damping = sqrtf(2.0f)/2.0f; - - // Set the bandwidth, which will then call update_gains() - set_loop_bandwidth(loop_bw); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_ccf*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_ccf*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_clock_sync_ccf::~gr_pfb_clock_sync_ccf () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -gr_pfb_clock_sync_ccf::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - - - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - - -void -gr_pfb_clock_sync_ccf::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -gr_pfb_clock_sync_ccf::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -gr_pfb_clock_sync_ccf::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -gr_pfb_clock_sync_ccf::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("gr_pfb_clock_sync_cc: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -gr_pfb_clock_sync_ccf::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -gr_pfb_clock_sync_ccf::get_damping_factor() const -{ - return d_damping; -} - -float -gr_pfb_clock_sync_ccf::get_alpha() const -{ - return d_alpha; -} - -float -gr_pfb_clock_sync_ccf::get_beta() const -{ - return d_beta; -} - -float -gr_pfb_clock_sync_ccf::get_clock_rate() const -{ - return d_rate_f; -} - -/******************************************************************* -*******************************************************************/ - -void -gr_pfb_clock_sync_ccf::update_gains() -{ - float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); - d_alpha = (4*d_damping*d_loop_bw) / denom; - d_beta = (4*d_loop_bw*d_loop_bw) / denom; -} - - -void -gr_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - //ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); - ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - //ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; - ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - //ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); - ourfilter[i]->set_taps(ourtaps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - // Make sure there is enough output space for d_osps outputs/input. - set_output_multiple(d_osps); - - d_updated = true; -} - -void -gr_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - std::vector<float> diff_filter(3); - diff_filter[0] = -1; - diff_filter[1] = 0; - diff_filter[2] = 1; - - float pwr = 0; - difftaps.push_back(0); - for(unsigned int i = 0; i < newtaps.size()-2; i++) { - float tap = 0; - for(int j = 0; j < 3; j++) { - tap += diff_filter[j]*newtaps[i+j]; - pwr += fabsf(tap); - } - difftaps.push_back(tap); - } - difftaps.push_back(0); - - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] *= pwr; - } -} - -std::string -gr_pfb_clock_sync_ccf::get_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_taps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_taps[i][j] << ", "; - } - str << d_taps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::string -gr_pfb_clock_sync_ccf::get_diff_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_dtaps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_dtaps[i][j] << ", "; - } - str << d_dtaps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::vector< std::vector<float> > -gr_pfb_clock_sync_ccf::get_taps() -{ - return d_taps; -} - -std::vector< std::vector<float> > -gr_pfb_clock_sync_ccf::get_diff_taps() -{ - return d_dtaps; -} - -std::vector<float> -gr_pfb_clock_sync_ccf::get_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -gr_pfb_clock_sync_ccf::get_diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - - -int -gr_pfb_clock_sync_ccf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - float *err = NULL, *outrate = NULL, *outk = NULL; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; - - int i = 0, count = 0; - float error_r, error_i; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - while(d_out_idx < d_osps) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); - d_k = d_k + d_rate_i + d_rate_f; // update phase - d_out_idx++; - - if(output_items.size() == 4) { - err[i] = d_error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - - // We've run out of output items we can create; return now. - if(i+d_out_idx >= noutput_items) { - consume_each(count); - return i; - } - } - - // reset here; if we didn't complete a full osps samples last time, - // the early return would take care of it. - d_out_idx = 0; - - // Update the phase and rate estimates for this symbol - gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error_r = out[i].real() * diff.real(); - error_i = out[i].imag() * diff.imag(); - d_error = (error_i + error_r) / 2.0; // average error from I&Q channel - - // Run the control loop to update the current phase (k) and - // tracking rate estimates based on the error value - d_rate_f = d_rate_f + d_beta*d_error; - d_k = d_k + d_alpha*d_error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i+=d_osps; - count += (int)floor(d_sps); - } - - consume_each(count); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h deleted file mode 100644 index 8715b4b106..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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_GR_PFB_CLOCK_SYNC_CCF_H -#define INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_clock_sync_ccf; -typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr; -GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_clock_sync_ccf - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps (default=1): The osps is the number of output samples per symbol. By default, - * the algorithm produces 1 sample per symbol, sampled at the exact - * sample value. This osps value was added to better work with - * equalizers, which do a better job of modeling the channel if they - * have 2 samps/sym. - */ - -class GR_CORE_API gr_pfb_clock_sync_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per symbol in the incoming signal - * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * \param osps (int) The number of output samples per symbol (default=1). - * - */ - - friend GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_loop_bw; - float d_damping; - float d_alpha; - float d_beta; - - int d_nfilters; - int d_taps_per_filter; - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_osps; - float d_error; - int d_out_idx; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~gr_pfb_clock_sync_ccf (); - - /*! \brief update the system gains from omega and eta - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void update_gains(); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - /*! - * Returns all of the taps of the matched filter - */ - std::vector< std::vector<float> > get_taps(); - - /*! - * Returns all of the taps of the derivative filter - */ - std::vector< std::vector<float> > get_diff_taps(); - - /*! - * Returns the taps of the matched filter for a particular channel - */ - std::vector<float> get_channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter for a particular channel - */ - std::vector<float> get_diff_channel_taps(int channel); - - /*! - * Return the taps as a formatted string for printing - */ - std::string get_taps_as_string(); - - /*! - * Return the derivative filter taps as a formatted string for printing - */ - std::string get_diff_taps_as_string(); - - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - - /*! - * \brief Set the loop bandwidth - * - * Set the loop filter's bandwidth to \p bw. This should be between - * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive - * number. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param bw (float) new bandwidth - * - */ - void set_loop_bandwidth(float bw); - - /*! - * \brief Set the loop damping factor - * - * Set the loop filter's damping factor to \p df. The damping factor - * should be sqrt(2)/2.0 for critically damped systems. - * Set it to anything else only if you know what you are doing. It must - * be a number between 0 and 1. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param df (float) new damping factor - * - */ - void set_damping_factor(float df); - - /*! - * \brief Set the loop gain alpha - * - * Set's the loop filter's alpha gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param alpha (float) new alpha gain - * - */ - void set_alpha(float alpha); - - /*! - * \brief Set the loop gain beta - * - * Set's the loop filter's beta gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param beta (float) new beta gain - * - */ - void set_beta(float beta); - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the loop bandwidth - */ - float get_loop_bandwidth() const; - - /*! - * \brief Returns the loop damping factor - */ - float get_damping_factor() const; - - /*! - * \brief Returns the loop gain alpha - */ - float get_alpha() const; - - /*! - * \brief Returns the loop gain beta - */ - float get_beta() const; - - /*! - * \brief Returns the current clock rate - */ - float get_clock_rate() const; - - /******************************************************************* - *******************************************************************/ - - bool check_topology(int ninputs, int noutputs); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i deleted file mode 100644 index 85915196f8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.i +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_ccf); - -gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_pfb_clock_sync_ccf : public gr_block -{ - private: - gr_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - public: - ~gr_pfb_clock_sync_ccf (); - - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - std::vector< std::vector<float> > get_taps(); - std::vector< std::vector<float> > get_diff_taps(); - std::vector<float> get_channel_taps(int channel); - std::vector<float> get_diff_channel_taps(int channel); - std::string get_taps_as_string(); - std::string get_diff_taps_as_string(); - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_clock_rate() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc deleted file mode 100644 index 886f989130..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc +++ /dev/null @@ -1,288 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <cstdio> -#include <cmath> - -#include <gr_pfb_clock_sync_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation) -{ - return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_fff (sps, gain, taps, - filter_size, - init_phase, - max_rate_deviation)); -} - -static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_pfb_clock_sync_fff::gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation) - : gr_block ("pfb_clock_sync_fff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - set_alpha(gain); - set_beta(0.25*gain*gain); - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_fff*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_fff*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -gr_pfb_clock_sync_fff::~gr_pfb_clock_sync_fff () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -gr_pfb_clock_sync_fff::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - -void -gr_pfb_clock_sync_fff::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[d_nfilters-1-i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[d_nfilters - 1 - i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[d_nfilters-1-i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - d_updated = true; -} - -void -gr_pfb_clock_sync_fff::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - float maxtap = 1e-20; - difftaps.clear(); - difftaps.push_back(0); //newtaps[0]); - for(unsigned int i = 1; i < newtaps.size()-1; i++) { - float tap = newtaps[i+1] - newtaps[i-1]; - difftaps.push_back(tap); - if(tap > maxtap) { - maxtap = tap; - } - } - difftaps.push_back(0);//-newtaps[newtaps.size()-1]); - - // Scale the differential taps; helps scale error term to better update state - // FIXME: should this be scaled this way or use the same gain as the taps? - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] /= maxtap; - } -} - -void -gr_pfb_clock_sync_fff::print_taps() -{ - int i, j; - printf("[ "); - for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_taps[i][0]); - for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_taps[i][j]); - } - printf("%.4e],", d_taps[i][j]); - } - printf(" ]\n"); -} - -void -gr_pfb_clock_sync_fff::print_diff_taps() -{ - int i, j; - printf("[ "); - for(i = 0; i < d_nfilters; i++) { - printf("[%.4e, ", d_dtaps[i][0]); - for(j = 1; j < d_taps_per_filter-1; j++) { - printf("%.4e,", d_dtaps[i][j]); - } - printf("%.4e],", d_dtaps[i][j]); - } - printf(" ]\n"); -} - - -std::vector<float> -gr_pfb_clock_sync_fff::channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -gr_pfb_clock_sync_fff::diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - - -int -gr_pfb_clock_sync_fff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - float *out = (float *) output_items[0]; - - float *err = 0, *outrate = 0, *outk = 0; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter; - - int i = 0, count = 0; - float error; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i] = d_filters[d_filtnum]->filter(&in[count]); - float diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error = out[i] * diff; - - // Run the control loop to update the current phase (k) and tracking rate - d_k = d_k + d_alpha*error + d_rate_i + d_rate_f; - d_rate_f = d_rate_f + d_beta*error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i++; - count += (int)floor(d_sps); - - if(output_items.size() == 4) { - err[i] = error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - } - consume_each(count); - - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h deleted file mode 100644 index 4909d556b9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h +++ /dev/null @@ -1,266 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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_GR_PFB_CLOCK_SYNC_FFF_H -#define INCLUDED_GR_PFB_CLOCK_SYNC_FFF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_pfb_clock_sync_fff; -typedef boost::shared_ptr<gr_pfb_clock_sync_fff> gr_pfb_clock_sync_fff_sptr; -GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5); - -class gr_fir_fff; - -/*! - * \class gr_pfb_clock_sync_fff - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps: note that unlike the ccf version of this algorithm, - * this block does \a not have a setting for the number of output - * samples per symbol. This is mostly because it should not be - * necessary as the reason for having multiple output sps is to - * perform equalization and the equalizers will take in complex - * numbers in order to do magnitude and phase correction. - */ - -class GR_CORE_API gr_pfb_clock_sync_fff : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per second in the incoming signal - * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * - */ - friend GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_alpha; - float d_beta; - int d_nfilters; - std::vector<gr_fir_fff*> d_filters; - std::vector<gr_fir_fff*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_taps_per_filter; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~gr_pfb_clock_sync_fff (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - /*! - * Returns the taps of the matched filter - */ - std::vector<float> channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter - */ - std::vector<float> diff_channel_taps(int channel); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Print all of the filterbank taps of the derivative filter to screen. - */ - void print_diff_taps(); - - /*! - * Set the gain value alpha for the control loop - */ - void set_alpha(float alpha) - { - d_alpha = alpha; - } - - /*! - * Set the gain value beta for the control loop - */ - void set_beta(float beta) - { - d_beta = beta; - } - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - bool check_topology(int ninputs, int noutputs); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i deleted file mode 100644 index 754af1a87f..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.i +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_clock_sync_fff); - -gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5); - -class gr_pfb_clock_sync_fff : public gr_block -{ - private: - gr_pfb_clock_sync_fff (double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation); - - public: - ~gr_pfb_clock_sync_fff (); - - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - std::vector<float> channel_taps(int channel); - std::vector<float> diff_channel_taps(int channel); - void print_taps(); - void print_diff_taps(); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc deleted file mode 100644 index e563daa513..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <gr_pfb_decimator_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <cstdio> - -gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel) -{ - return gnuradio::get_initial_sptr(new gr_pfb_decimator_ccf (decim, taps, channel)); -} - - -gr_pfb_decimator_ccf::gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel) - : gr_sync_block ("pfb_decimator_ccf", - gr_make_io_signature (decim, decim, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex))), - d_updated (false) -{ - d_rate = decim; - d_filters = std::vector<gr_fir_ccf*>(d_rate); - d_chan = channel; - d_rotator = new gr_complex[d_rate]; - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_rate); - for(unsigned int i = 0; i < d_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_rotator[i] = gr_expj(i*2*M_PI*d_chan/d_rate); - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the FFT to handle the output de-spinning of the channels - d_fft = new gri_fft_complex (d_rate, false); -} - -gr_pfb_decimator_ccf::~gr_pfb_decimator_ccf () -{ - delete d_fft; - for(unsigned int i = 0; i < d_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_decimator_ccf::set_taps (const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_rate]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter); - - d_updated = true; -} - -void -gr_pfb_decimator_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -#define ROTATEFFT - -int -gr_pfb_decimator_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i; - for(i = 0; i < noutput_items; i++) { - // Move through filters from bottom to top - out[i] = 0; - for(int j = d_rate-1; j >= 0; j--) { - // Take in the items from the first input stream to d_rate - in = (gr_complex*)input_items[d_rate - 1 - j]; - - // Filter current input stream from bottom filter to top - // The rotate them by expj(j*k*2pi/M) where M is the number of filters - // (the decimation rate) and k is the channel number to extract - - // This is the real math that goes on; we abuse the FFT to do this quickly - // for decimation rates > N where N is a small number (~5): - // out[i] += d_filters[j]->filter(&in[i])*gr_expj(j*d_chan*2*M_PI/d_rate); -#ifdef ROTATEFFT - d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]); -#else - out[i] += d_filters[j]->filter(&in[i])*d_rotator[i]; -#endif - } - -#ifdef ROTATEFFT - // Perform the FFT to do the complex multiply despinning for all channels - d_fft->execute(); - - // Select only the desired channel out - out[i] = d_fft->get_outbuf()[d_chan]; -#endif - - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h deleted file mode 100644 index a2b347ae24..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_GR_PFB_DECIMATOR_CCF_H -#define INCLUDED_GR_PFB_DECIMATOR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_pfb_decimator_ccf; -typedef boost::shared_ptr<gr_pfb_decimator_ccf> gr_pfb_decimator_ccf_sptr; -GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel=0); - -class gr_fir_ccf; -class gri_fft_complex; - -/*! - * \class gr_pfb_decimator_ccf - * \brief Polyphase filterbank bandpass decimator with gr_complex - * input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs interger down- - * sampling (decimation) with a polyphase filterbank. The first input - * is the integer specifying how much to decimate by. The second - * input is a vector (Python list) of floating-point taps of the - * prototype filter. The third input specifies the channel to extract. - * By default, the zeroth channel is used, which is the baseband - * channel (first Nyquist zone). - * - * The <EM>channel</EM> parameter specifies which channel to use since - * this class is capable of bandpass decimation. Given a complex input - * stream at a sampling rate of <EM>fs</EM> and a decimation rate of - * <EM>decim</EM>, the input frequency domain is split into - * <EM>decim</EM> channels that represent the Nyquist zones. Using the - * polyphase filterbank, we can select any one of these channels to - * decimate. - * - * The output signal will be the basebanded and decimated signal from - * that channel. This concept is very similar to the PFB channelizer - * (see #gr_pfb_channelizer_ccf) where only a single channel is - * extracted at a time. - * - * The filter's taps should be based on the sampling rate before - * decimation. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, <EM>ATT</EM>, and the filter window - * function (a Blackman-harris window in this case). The first input - * is the gain of the filter, which we specify here as unity. - * - * <B><EM>self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The PFB decimator code takes the taps generated above and builds a - * set of filters. The set contains <EM>decim</EM> number of filters - * and each filter contains ceil(taps.size()/decim) number of taps. - * Each tap from the filter prototype is sequentially inserted into - * the next filter. When all of the input taps are used, the remaining - * filters in the filterbank are filled out with 0's to make sure each - * filter has the same number of taps. - * - * The theory behind this block can be found in Chapter 6 of - * the following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems," Upper Saddle River, NJ: Prentice Hall, Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_decimator_ccf : public gr_sync_block -{ - private: - /*! - * Build the polyphase filterbank decimator. - * \param decim (unsigned integer) Specifies the decimation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param channel (unsigned integer) Selects the channel to return [default=0]. - */ - friend GR_CORE_API gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - gri_fft_complex *d_fft; - unsigned int d_rate; - unsigned int d_chan; - unsigned int d_taps_per_filter; - bool d_updated; - gr_complex *d_rotator; - - /*! - * Build the polyphase filterbank decimator. - * \param decim (unsigned integer) Specifies the decimation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - * \param channel (unsigned integer) Selects the channel to return [default=0]. - */ - gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - -public: - ~gr_pfb_decimator_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - //void set_channel (unsigned int channel); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i deleted file mode 100644 index e40d00fa9d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_decimator_ccf); - -gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - -class gr_pfb_decimator_ccf : public gr_sync_block -{ - private: - gr_pfb_decimator_ccf (unsigned int decim, - const std::vector<float> &taps, - unsigned int channel); - - public: - ~gr_pfb_decimator_ccf (); - - void set_taps (const std::vector<float> &taps); - //void set_channel (unsigned int channel); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc deleted file mode 100644 index 9c8e734ea9..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010 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 <gr_pfb_interpolator_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <cstdio> - -gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps) -{ - return gnuradio::get_initial_sptr(new gr_pfb_interpolator_ccf (interp, taps)); -} - - -gr_pfb_interpolator_ccf::gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps) - : gr_sync_interpolator ("pfb_interpolator_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - interp), - d_updated (false) -{ - d_rate = interp; - d_filters = std::vector<gr_fir_ccf*>(d_rate); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_rate); - for(unsigned int i = 0; i < d_rate; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - set_taps(taps); -} - -gr_pfb_interpolator_ccf::~gr_pfb_interpolator_ccf () -{ - for(unsigned int i = 0; i < d_rate; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_interpolator_ccf::set_taps (const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_rate); - - // Create d_numchan vectors to store each channel's taps - //std::vector< std::vector<float> > vtaps(d_rate); - d_taps.resize(d_rate); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_rate*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_rate; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_rate]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter); - - d_updated = true; -} - -void -gr_pfb_interpolator_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_rate; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - -int -gr_pfb_interpolator_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i = 0, count = 0; - - while(i < noutput_items) { - for(unsigned int j = 0; j < d_rate; j++) { - out[i] = d_filters[j]->filter(&in[count]); - i++; - } - count++; - } - - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h deleted file mode 100644 index aeae86e408..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_GR_PFB_INTERPOLATOR_CCF_H -#define INCLUDED_GR_PFB_INTERPOLATOR_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_pfb_interpolator_ccf; -typedef boost::shared_ptr<gr_pfb_interpolator_ccf> gr_pfb_interpolator_ccf_sptr; -GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -class gr_fir_ccf; - -/*! - * \class gr_pfb_interpolator_ccf - * \brief Polyphase filterbank interpolator with gr_complex input, - * gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block takes in a signal stream and performs interger up- - * sampling (interpolation) with a polyphase filterbank. The first - * input is the integer specifying how much to interpolate by. The - * second input is a vector (Python list) of floating-point taps of - * the prototype filter. - * - * The filter's taps should be based on the interpolation rate - * specified. That is, the bandwidth specified is relative to the - * bandwidth after interpolation. - * - * For example, using the GNU Radio's firdes utility to building - * filters, we build a low-pass filter with a sampling rate of - * <EM>fs</EM>, a 3-dB bandwidth of <EM>BW</EM> and a transition - * bandwidth of <EM>TB</EM>. We can also specify the out-of-band - * attenuation to use, ATT, and the filter window function (a - * Blackman-harris window in this case). The first input is the gain, - * which is also specified as the interpolation rate so that the - * output levels are the same as the input (this creates an overall - * increase in power). - * - * <B><EM>self._taps = gr.firdes.low_pass_2(interp, interp*fs, BW, TB, - * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS)</EM></B> - * - * The PFB interpolator code takes the taps generated above and builds - * a set of filters. The set contains <EM>interp</EM> number of - * filters and each filter contains ceil(taps.size()/interp) number of - * taps. Each tap from the filter prototype is sequentially inserted - * into the next filter. When all of the input taps are used, the - * remaining filters in the filterbank are filled out with 0's to make - * sure each filter has the same number of taps. - * - * The theory behind this block can be found in Chapter 7.1 of the - * following book. - * - * <B><EM>f. harris, "Multirate Signal Processing for Communication - * Systems</EM>," Upper Saddle River, NJ: Prentice Hall, - * Inc. 2004.</EM></B> - */ - -class GR_CORE_API gr_pfb_interpolator_ccf : public gr_sync_interpolator -{ - private: - /*! - * Build the polyphase filterbank interpolator. - * \param interp (unsigned integer) Specifies the interpolation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - friend GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - - std::vector<gr_fir_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - unsigned int d_rate; - unsigned int d_taps_per_filter; - bool d_updated; - - /*! - * Construct a Polyphase filterbank interpolator - * \param interp (unsigned integer) Specifies the interpolation rate to use - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -public: - ~gr_pfb_interpolator_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to populate the filterbank. The taps - * should be generated at the interpolated sampling rate. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i deleted file mode 100644 index 427f1b913d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_interpolator_ccf); - -gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - -class gr_pfb_interpolator_ccf : public gr_sync_interpolator -{ - private: - gr_pfb_interpolator_ccf (unsigned int interp, - const std::vector<float> &taps); - - public: - ~gr_pfb_interpolator_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); -}; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc deleted file mode 100644 index cd01aaff5c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 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 <gr_pfb_synthesizer_ccf.h> -#include <gri_fft.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <cstring> - -gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox) -{ - return gr_pfb_synthesizer_ccf_sptr - (new gr_pfb_synthesizer_ccf (numchans, taps, twox)); -} - - -gr_pfb_synthesizer_ccf::gr_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox) - : gr_sync_interpolator ("pfb_synthesizer_ccf", - gr_make_io_signature (1, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - numchans), - d_updated (false), d_numchans(numchans), d_state(0) -{ - // set up 2x multiplier; if twox==True, set to 2, otherwise to 1 - d_twox = (twox ? 2 : 1); - if(d_numchans % d_twox != 0) { - throw std::invalid_argument("gr_pfb_synthesizer_ccf: number of channels must be even for 2x oversampling.\n"); - } - - d_filters = std::vector<gri_fir_filter_with_buffer_ccf*>(d_twox*d_numchans); - d_channel_map.resize(d_twox*d_numchans); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_twox*d_numchans); - for(unsigned int i = 0; i < d_twox*d_numchans; i++) { - d_filters[i] = new gri_fir_filter_with_buffer_ccf(vtaps); - d_channel_map[i] = i; - } - - // Now, actually set the filters' taps - set_taps(taps); - - // Create the IFFT to handle the input channel rotations - d_fft = new gri_fft_complex (d_twox*d_numchans, false); - memset(d_fft->get_inbuf(), 0, d_twox*d_numchans*sizeof(gr_complex)); - - set_output_multiple(d_numchans); -} - -gr_pfb_synthesizer_ccf::~gr_pfb_synthesizer_ccf () -{ - delete d_fft; - for(unsigned int i = 0; i < d_twox*d_numchans; i++) { - delete d_filters[i]; - } -} - -void -gr_pfb_synthesizer_ccf::set_taps(const std::vector<float> &taps) -{ - gruel::scoped_lock guard(d_mutex); - if(d_twox == 1) - set_taps1(taps); - else - set_taps2(taps); -} - -void -gr_pfb_synthesizer_ccf::set_taps1(const std::vector<float> &taps) -{ - unsigned int i,j; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; // add taps to channels in reverse order - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_synthesizer_ccf::set_taps2 (const std::vector<float> &taps) -{ - unsigned int i,j; - int state = 0; - - unsigned int ntaps = taps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); - - // Create d_numchan vectors to store each channel's taps - d_taps.resize(d_twox*d_numchans); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = taps; - while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_numchans; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - d_taps[i] = std::vector<float>(d_taps_per_filter, 0); - d_taps[d_numchans+i] = std::vector<float>(d_taps_per_filter, 0); - state = 0; - for(j = 0; j < d_taps_per_filter; j++) { - // add taps to channels in reverse order - // Zero out every other tap - if(state == 0) { - d_taps[i][j] = tmp_taps[i + j*d_numchans]; - d_taps[d_numchans + i][j] = 0; - state = 1; - } - else { - d_taps[i][j] = 0; - d_taps[d_numchans + i][j] = tmp_taps[i + j*d_numchans]; - state = 0; - } - } - - // Build a filter for each channel and add it's taps to it - d_filters[i]->set_taps(d_taps[i]); - d_filters[d_numchans + i]->set_taps(d_taps[d_numchans + i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter+1); - - d_updated = true; -} - -void -gr_pfb_synthesizer_ccf::print_taps() -{ - unsigned int i, j; - for(i = 0; i < d_twox*d_numchans; i++) { - printf("filter[%d]: [", i); - for(j = 0; j < d_taps_per_filter; j++) { - printf(" %.4e", d_taps[i][j]); - } - printf("]\n\n"); - } -} - - -std::vector< std::vector<float> > -gr_pfb_synthesizer_ccf::taps() const -{ - return d_taps; -} - -void -gr_pfb_synthesizer_ccf::set_channel_map(const std::vector<int> &map) -{ - gruel::scoped_lock guard(d_mutex); - - if(map.size() > 0) { - unsigned int max = (unsigned int)*std::max_element(map.begin(), map.end()); - unsigned int min = (unsigned int)*std::min_element(map.begin(), map.end()); - if((max >= d_twox*d_numchans) || (min < 0)) { - throw std::invalid_argument("gr_pfb_synthesizer_ccf::set_channel_map: map range out of bounds.\n"); - } - d_channel_map = map; - - // Zero out fft buffer so that unused channels are always 0 - memset(d_fft->get_inbuf(), 0,d_twox*d_numchans*sizeof(gr_complex)); - } -} - -std::vector<int> -gr_pfb_synthesizer_ccf::channel_map() const -{ - return d_channel_map; -} - -int -gr_pfb_synthesizer_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock guard(d_mutex); - - gr_complex *in = (gr_complex*) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - unsigned int n, i; - size_t ninputs = input_items.size(); - - // Algoritm for critically sampled channels - if(d_twox == 1) { - for(n = 0; n < noutput_items/d_numchans; n++) { - for(i = 0; i < ninputs; i++) { - in = (gr_complex*)input_items[i]; - d_fft->get_inbuf()[d_channel_map[i]] = in[n]; - } - - // spin through IFFT - d_fft->execute(); - - for(i = 0; i < d_numchans; i++) { - out[i] = d_filters[i]->filter(d_fft->get_outbuf()[i]); - } - out += d_numchans; - } - } - - // Algorithm for oversampling by 2x - else { - for(n = 0; n < noutput_items/d_numchans; n++) { - for(i = 0; i < ninputs; i++) { - in = (gr_complex*)input_items[i]; - d_fft->get_inbuf()[d_channel_map[i]] = in[n]; - } - - // spin through IFFT - d_fft->execute(); - - // Output is sum of two filters, but the input buffer to the filters must be circularly - // shifted by numchans every time through, done by using d_state to determine which IFFT - // buffer position to pull from. - for(i = 0; i < d_numchans; i++) { - out[i] = d_filters[i]->filter(d_fft->get_outbuf()[d_state*d_numchans+i]); - out[i] += d_filters[d_numchans+i]->filter(d_fft->get_outbuf()[(d_state^1)*d_numchans+i]); - } - d_state ^= 1; - - out += d_numchans; - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h deleted file mode 100644 index 9e4f85497d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 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_GR_PFB_SYNTHESIZER_CCF_H -#define INCLUDED_GR_PFB_SYNTHESIZER_CCF_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> -#include <gri_fir_filter_with_buffer_ccf.h> -#include <gruel/thread.h> - -class gr_pfb_synthesizer_ccf; -typedef boost::shared_ptr<gr_pfb_synthesizer_ccf> gr_pfb_synthesizer_ccf_sptr; -GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox=false); - -class gri_fft_complex; - - -/*! - * \class gr_pfb_synthesizer_ccf - * - * \brief Polyphase synthesis filterbank with - * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk - */ - -class GR_CORE_API gr_pfb_synthesizer_ccf : public gr_sync_interpolator -{ - private: - /*! - * Build the polyphase synthesis filterbank. - * \param numchans (unsigned integer) Specifies the number of - channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter to - populate the filterbank. - * \param twox (bool) use 2x oversampling or not (default is no) - */ - friend GR_CORE_API gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox); - - bool d_updated; - unsigned int d_numchans; - unsigned int d_taps_per_filter; - gri_fft_complex *d_fft; - std::vector< gri_fir_filter_with_buffer_ccf*> d_filters; - std::vector< std::vector<float> > d_taps; - int d_state; - std::vector<int> d_channel_map; - unsigned int d_twox; - gruel::mutex d_mutex; // mutex to protect set/work access - - /*! - * \brief Tap setting algorithm for critically sampled channels - */ - void set_taps1(const std::vector<float> &taps); - - /*! - * \brief Tap setting algorithm for 2x over-sampled channels - */ - void set_taps2(const std::vector<float> &taps); - - /*! - * Build the polyphase synthesis filterbank. - * \param numchans (unsigned integer) Specifies the number of - channels <EM>M</EM> - * \param taps (vector/list of floats) The prototype filter - to populate the filterbank. - * \param twox (bool) use 2x oversampling or not (default is no) - */ - gr_pfb_synthesizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - bool twox); - -public: - ~gr_pfb_synthesizer_ccf (); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - * \param taps (vector/list of floats) The prototype filter to - populate the filterbank. - */ - void set_taps (const std::vector<float> &taps); - - /*! - * Print all of the filterbank taps to screen. - */ - void print_taps(); - - /*! - * Return a vector<vector<>> of the filterbank taps - */ - std::vector<std::vector<float> > taps() const; - - /*! - * Set the channel map. Channels are numbers as: - * N/2+1 | ... | N-1 | 0 | 1 | 2 | ... | N/2 - * <------------------- 0 --------------------> - * freq - * - * So input stream 0 goes to channel 0, etc. Setting a new channel - * map allows the user to specify where in frequency he/she wants - * the input stream to go. This is especially useful to avoid - * putting signals into the channels on the edge of the spectrum - * which can either wrap around (in the case of odd number of - * channels) and be affected by filter rolloff in the transmitter. - * - * The map must be at least the number of streams being sent to the - * block. Less and the algorithm will not have enough data to - * properly setup the buffers. Any more channels specified will be - * ignored. - */ - void set_channel_map(const std::vector<int> &map); - - /*! - * Gets the current channel map. - */ - std::vector<int> channel_map() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i deleted file mode 100644 index c186ae355a..0000000000 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.i +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pfb_synthesizer_ccf); - -gr_pfb_synthesizer_ccf_sptr gr_make_pfb_synthesizer_ccf - (unsigned int numchans, const std::vector<float> &taps, bool twox=false); - -class gr_pfb_synthesizer_ccf : public gr_sync_interpolator -{ - private: - gr_pfb_synthesizer_ccf (unsigned int numchans, - const std::vector<float> &taps, - bool twox=false); - - public: - ~gr_pfb_synthesizer_ccf (); - - void set_taps (const std::vector<float> &taps); - void print_taps(); - std::vector< std::vector<float> > taps() const; - - void set_channel_map(const std::vector<int> &map); - std::vector<int> channel_map() const; -}; diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t deleted file mode 100644 index 445834dda0..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <@FIR_TYPE@.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned interpolation, - unsigned decimation, - const std::vector<@TAP_TYPE@> &taps) -{ - return gnuradio::get_initial_sptr (new @NAME@ (interpolation, decimation, taps)); -} - -@NAME@::@NAME@ (unsigned interpolation, unsigned decimation, - const std::vector<@TAP_TYPE@> &taps) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_history(1), - d_interpolation(interpolation), d_decimation(decimation), - d_ctr(0), d_updated(false), - d_firs(interpolation) -{ - if (interpolation == 0) - throw std::out_of_range ("interpolation must be > 0"); - if (decimation == 0) - throw std::out_of_range ("decimation must be > 0"); - - set_relative_rate (1.0 * interpolation / decimation); - set_output_multiple (1); - - std::vector<@TAP_TYPE@> dummy_taps; - - for (unsigned i = 0; i < interpolation; i++) - d_firs[i] = gr_fir_util::create_@FIR_TYPE@ (dummy_taps); - - set_taps (taps); - install_taps (d_new_taps); -} - -@NAME@::~@NAME@ () -{ - int interp = interpolation(); - for (int i = 0; i < interp; i++) - delete d_firs[i]; -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_new_taps = taps; - d_updated = true; - - // round up length to a multiple of the interpolation factor - int n = taps.size () % interpolation (); - if (n > 0){ - n = interpolation () - n; - while (n-- > 0) - d_new_taps.insert(d_new_taps.begin(), 0); - } - - assert (d_new_taps.size () % interpolation () == 0); -} - - -void -@NAME@::install_taps (const std::vector<@TAP_TYPE@> &taps) -{ - int nfilters = interpolation (); - int nt = taps.size () / nfilters; - - assert (nt * nfilters == (int) taps.size ()); - - std::vector< std::vector <@TAP_TYPE@> > xtaps (nfilters); - - for (int n = 0; n < nfilters; n++) - xtaps[n].resize (nt); - - for (int i = 0; i < (int) taps.size(); i++) - xtaps[i % nfilters][i / nfilters] = taps[i]; - - for (int n = 0; n < nfilters; n++) - d_firs[n]->set_taps (xtaps[n]); - - set_history (nt); - d_updated = false; - -#if 0 - for (int i = 0; i < nfilters; i++){ - std::cout << "filter[" << i << "] = "; - for (int j = 0; j < nt; j++) - std::cout << xtaps[i][j] << " "; - - std::cout << "\n"; - } -#endif - -} - -void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - int nreqd = std::max((unsigned)1, (int)((double) (noutput_items+1) * decimation() / interpolation()) + history() - 1); - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = nreqd; -} - -int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[0]; - - if (d_updated) { - install_taps (d_new_taps); - return 0; // history requirement may have increased. - } - - unsigned int ctr = d_ctr; - - int i = 0; - while (i < noutput_items){ - out[i++] = d_firs[ctr]->filter(in); - ctr += decimation(); - while (ctr >= interpolation()){ - ctr -= interpolation(); - in++; - } - } - - d_ctr = ctr; - consume_each(in - (@I_TYPE@ *) input_items[0]); - return i; -} diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t deleted file mode 100644 index 3eb85a9795..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -GR_CORE_API @SPTR_NAME@ -gr_make_@BASE_NAME@ (unsigned interpolation, - unsigned decimation, - const std::vector<@TAP_TYPE@> &taps); - -class @FIR_TYPE@; - -/*! - * \brief Rational Resampling Polyphase FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk - */ -class GR_CORE_API @NAME@ : public gr_block -{ - private: - unsigned d_history; - unsigned d_interpolation, d_decimation; - unsigned d_ctr; - std::vector<@TAP_TYPE@> d_new_taps; - bool d_updated; - std::vector<@FIR_TYPE@ *> d_firs; - - friend GR_CORE_API @SPTR_NAME@ - gr_make_@BASE_NAME@ (unsigned interpolation, unsigned decimation, const std::vector<@TAP_TYPE@> &taps); - - - /*! - * Construct a FIR filter with the given taps - */ - @NAME@ (unsigned interpolation, unsigned decimation, - const std::vector<@TAP_TYPE@> &taps); - - void install_taps (const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - unsigned history () const { return d_history; } - void set_history (unsigned history) { d_history = history; } - - unsigned interpolation() const { return d_interpolation; } - unsigned decimation() const { return d_decimation; } - - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t deleted file mode 100644 index 1f789b0a35..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.i.t +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -/* - * WARNING: This file is automatically generated by - * generate_gr_rational_resampler_base_XXX.py Any changes made to this - * file will be overwritten. - */ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@SPTR_NAME@ gr_make_@BASE_NAME@ (int interpolation, int decimation, const std::vector<@TAP_TYPE@> &taps); - -class @NAME@ : public gr_block -{ - private: - @NAME@ (int interpolation, int decimation, const std::vector<@TAP_TYPE@> &taps); - - public: - ~@NAME@ (); - - void set_taps (const std::vector<@TAP_TYPE@> &taps); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc deleted file mode 100644 index ae4f654dda..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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 <gr_single_pole_iir_filter_cc.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_cc(alpha, vlen)); -} - -gr_single_pole_iir_filter_cc::gr_single_pole_iir_filter_cc ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_iir_filter_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen)), - d_vlen(vlen), d_iir(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_iir_filter_cc::~gr_single_pole_iir_filter_cc () -{ - // nop -} - -void -gr_single_pole_iir_filter_cc::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_iir[i].set_taps(alpha); -} - -int -gr_single_pole_iir_filter_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_iir[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_iir[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h deleted file mode 100644 index 13c595826d..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2006 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_GR_SINGLE_POLE_IIR_FILTER_CC_H -#define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> -#include <gr_complex.h> -#include <stdexcept> - -class gr_single_pole_iir_filter_cc; -typedef boost::shared_ptr<gr_single_pole_iir_filter_cc> gr_single_pole_iir_filter_cc_sptr; - -GR_CORE_API gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole IIR filter with complex input, complex output - * \ingroup filter_blk - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f} - \endhtmlonly - - \xmlonly - y[n] - (1-alpha) y[n-1] = alpha x[n] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f} - \endhtmlonly - - \xmlonly - H(z) = \ frac{alpha}{1 - (1-alpha) z^{-1}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class GR_CORE_API gr_single_pole_iir_filter_cc : public gr_sync_block -{ - private: - friend GR_CORE_API gr_single_pole_iir_filter_cc_sptr - gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_iir<gr_complex,gr_complex,double> > d_iir; - - gr_single_pole_iir_filter_cc (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_iir_filter_cc (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i deleted file mode 100644 index 2f1f285de7..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_iir_filter_cc); - -gr_single_pole_iir_filter_cc_sptr -gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); - -class gr_single_pole_iir_filter_cc : public gr_sync_block -{ - public: - ~gr_single_pole_iir_filter_cc (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc deleted file mode 100644 index 047b2ba25c..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 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 <gr_single_pole_iir_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_ff(alpha, vlen)); -} - -gr_single_pole_iir_filter_ff::gr_single_pole_iir_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_iir_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_iir(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_iir_filter_ff::~gr_single_pole_iir_filter_ff () -{ - // nop -} - -void -gr_single_pole_iir_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_iir[i].set_taps(alpha); -} - -int -gr_single_pole_iir_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_iir[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_iir[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h deleted file mode 100644 index 8dcdad2c94..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 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_GR_SINGLE_POLE_IIR_FILTER_FF_H -#define INCLUDED_GR_SINGLE_POLE_IIR_FILTER_FF_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> -#include <stdexcept> - -class gr_single_pole_iir_filter_ff; -typedef boost::shared_ptr<gr_single_pole_iir_filter_ff> gr_single_pole_iir_filter_ff_sptr; - -GR_CORE_API gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole IIR filter with float input, float output - * \ingroup filter_blk - * - * The input and output satisfy a difference equation of the form - \htmlonly - \f{ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f} - \endhtmlonly - - \xmlonly - y[n] - (1-alpha) y[n-1] = alpha x[n] - \endxmlonly - - * with the corresponding rational system function - \htmlonly - \f{ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f} - \endhtmlonly - - \xmlonly -H(z) = \ frac{alpha}{1 - (1-alpha) z^{-1}} - \endxmlonly - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class GR_CORE_API gr_single_pole_iir_filter_ff : public gr_sync_block -{ - private: - friend GR_CORE_API gr_single_pole_iir_filter_ff_sptr - gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_iir<float,float,double> > d_iir; - - gr_single_pole_iir_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_iir_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i deleted file mode 100644 index a835fabb2e..0000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_iir_filter_ff); - -gr_single_pole_iir_filter_ff_sptr -gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_pole_iir_filter_ff : public gr_sync_block -{ - public: - ~gr_single_pole_iir_filter_ff (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_vec_types.h b/gnuradio-core/src/lib/filter/gr_vec_types.h deleted file mode 100644 index 2bcec44bf8..0000000000 --- a/gnuradio-core/src/lib/filter/gr_vec_types.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Cell single token vector types - Copyright (C) 2007 Free Software Foundation, Inc. - - This file 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 2 of the License, or (at your option) - any later version. - - This file 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 this file; see the file COPYING. If not, write to the Free - Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ - -/* As a special exception, if you include this header file into source files - compiled by GCC, this header file does not by itself cause the resulting - executable to be covered by the GNU General Public License. This exception - does not however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -/* Single token vector data types for the PowerPC SIMD/Vector Multi-media - eXtension */ - -#ifndef INCLUDED_GR_VEC_TYPES_H -#define INCLUDED_GR_VEC_TYPES_H - -#define qword __vector unsigned char - -#define vec_uchar16 __vector unsigned char -#define vec_char16 __vector signed char -#define vec_bchar16 __vector bool char - -#define vec_ushort8 __vector unsigned short -#define vec_short8 __vector signed short -#define vec_bshort8 __vector bool short - -#define vec_pixel8 __vector pixel - -#define vec_uint4 __vector unsigned int -#define vec_int4 __vector signed int -#define vec_bint4 __vector bool int - -#define vec_float4 __vector float - -#define vec_ullong2 __vector bool char -#define vec_llong2 __vector bool short - -#define vec_double2 __vector bool int - -#endif /* INCLUDED_GR_VEC_TYPES_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc deleted file mode 100644 index e958c5061f..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gri_fft_filter_ccc_generic.h> -#include <gri_fft.h> -#include <volk/volk.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <cstring> -#include <fftw3.h> - -gri_fft_filter_ccc_generic::gri_fft_filter_ccc_generic (int decimation, - const std::vector<gr_complex> &taps, - int nthreads) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0), d_nthreads(nthreads) -{ - set_taps(taps); -} - -gri_fft_filter_ccc_generic::~gri_fft_filter_ccc_generic () -{ - delete d_fwdfft; - delete d_invfft; - gri_fft_free(d_xformed_taps); -} - -#if 0 -static void -print_vector_complex(const std::string label, const std::vector<gr_complex> &x) -{ - std::cout << label; - for (unsigned i = 0; i < x.size(); i++) - std::cout << x[i] << " "; - std::cout << "\n"; -} -#endif - - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_ccc_generic::set_taps (const std::vector<gr_complex> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - gr_complex *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_ccc_generic::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_ccc_generic: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_complex(d_fftsize, true, d_nthreads); - d_invfft = new gri_fft_complex(d_fftsize, false, d_nthreads); - d_xformed_taps = gri_fft_malloc_complex(d_fftsize); - } -} - -void -gri_fft_filter_ccc_generic::set_nthreads(int n) -{ - d_nthreads = n; - if(d_fwdfft) - d_fwdfft->set_nthreads(n); - if(d_invfft) - d_invfft->set_nthreads(n); -} - -int -gri_fft_filter_ccc_generic::nthreads() const -{ - return d_nthreads; -} - -int -gri_fft_filter_ccc_generic::filter (int nitems, const gr_complex *input, gr_complex *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(gr_complex)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - gr_complex *a = d_fwdfft->get_outbuf(); - gr_complex *b = d_xformed_taps; - gr_complex *c = d_invfft->get_inbuf(); - - volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(gr_complex)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h deleted file mode 100644 index 648c2b8c54..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_GRI_FFT_FILTER_CCC_GENERIC_H -#define INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_complex; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gri_fft_filter_ccc_generic -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_complex *d_fwdfft; // forward "plan" - gri_fft_complex *d_invfft; // inverse "plan" - int d_nthreads; // number of FFTW threads to use - std::vector<gr_complex> d_tail; // state carried between blocks for overlap-add - std::vector<gr_complex> d_new_taps; - gr_complex *d_xformed_taps; // Fourier xformed taps - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for complex vectors (such as gr_fft_filter_ccc). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (complex) - * \param nthreads The number of threads for the FFT to use (int) - */ - gri_fft_filter_ccc_generic (int decimation, const std::vector<gr_complex> &taps, - int nthreads=1); - ~gri_fft_filter_ccc_generic (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (complex) - */ - int set_taps (const std::vector<gr_complex> &taps); - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const gr_complex *input, gr_complex *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc deleted file mode 100644 index bfc939869e..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gri_fft_filter_ccc_sse.h> -#include <gri_fft.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <xmmintrin.h> -#include <fftw3.h> - -gri_fft_filter_ccc_sse::gri_fft_filter_ccc_sse (int decimation, - const std::vector<gr_complex> &taps) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0) -{ - d_xformed_taps = (gr_complex*)fftwf_malloc(1*sizeof(gr_complex)); - set_taps(taps); -} - -gri_fft_filter_ccc_sse::~gri_fft_filter_ccc_sse () -{ - fftwf_free(d_xformed_taps); - delete d_fwdfft; - delete d_invfft; -} - -#if 0 -static void -print_vector_complex(const std::string label, const std::vector<gr_complex> &x) -{ - std::cout << label; - for (unsigned i = 0; i < x.size(); i++) - std::cout << x[i] << " "; - std::cout << "\n"; -} -#endif - - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_ccc_sse::set_taps (const std::vector<gr_complex> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - gr_complex *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_ccc_sse::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_ccc_sse: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_complex(d_fftsize, true); - d_invfft = new gri_fft_complex(d_fftsize, false); - - fftwf_free(d_xformed_taps); - d_xformed_taps = (gr_complex*)fftwf_malloc((d_fftsize)*sizeof(gr_complex)); - } -} - -int -gri_fft_filter_ccc_sse::filter (int nitems, const gr_complex *input, gr_complex *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(gr_complex)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - float *a = (float*)(d_fwdfft->get_outbuf()); - float *b = (float*)(&d_xformed_taps[0]); - float *c = (float*)(d_invfft->get_inbuf()); - - __m128 x0, x1, x2, t0, t1, m; - m = _mm_set_ps(-1, 1, -1, 1); - for (j = 0; j < 2*d_fftsize; j+=4) { // filter in the freq domain - x0 = _mm_load_ps(&a[j]); - t0 = _mm_load_ps(&b[j]); - - t1 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(3, 3, 1, 1)); - t0 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(2, 2, 0, 0)); - t1 = _mm_mul_ps(t1, m); - - x1 = _mm_mul_ps(x0, t0); - x2 = _mm_mul_ps(x0, t1); - - x2 = _mm_shuffle_ps(x2, x2, _MM_SHUFFLE(2, 3, 0, 1)); - x2 = _mm_add_ps(x1, x2); - - _mm_store_ps(&c[j], x2); - } - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(gr_complex)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h deleted file mode 100644 index 64b8c0c153..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_GRI_FFT_FILTER_CCC_SSE_H -#define INCLUDED_GRI_FFT_FILTER_CCC_SSE_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_complex; - -/*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - */ -class GR_CORE_API gri_fft_filter_ccc_sse -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_complex *d_fwdfft; // forward "plan" - gri_fft_complex *d_invfft; // inverse "plan" - std::vector<gr_complex> d_tail; // state carried between blocks for overlap-add - gr_complex *d_xformed_taps; - std::vector<gr_complex> d_new_taps; - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for complex vectors (such as gr_fft_filter_ccc). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (complex) - */ - gri_fft_filter_ccc_sse (int decimation, const std::vector<gr_complex> &taps); - ~gri_fft_filter_ccc_sse (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (complex) - */ - int set_taps (const std::vector<gr_complex> &taps); - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const gr_complex *input, gr_complex *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_CCC_SSE_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc deleted file mode 100644 index c6e923ee11..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gri_fft_filter_fff_generic.h> -#include <gri_fft.h> -#include <volk/volk.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <cstring> - -gri_fft_filter_fff_generic::gri_fft_filter_fff_generic (int decimation, - const std::vector<float> &taps, - int nthreads) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0), d_nthreads(nthreads) -{ - set_taps(taps); -} - -gri_fft_filter_fff_generic::~gri_fft_filter_fff_generic () -{ - delete d_fwdfft; - delete d_invfft; - gri_fft_free(d_xformed_taps); -} - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_fff_generic::set_taps (const std::vector<float> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - float *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize/2+1; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_fff_generic::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_fff_generic: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_real_fwd(d_fftsize); - d_invfft = new gri_fft_real_rev(d_fftsize); - d_xformed_taps = gri_fft_malloc_complex(d_fftsize/2+1); - } -} - -void -gri_fft_filter_fff_generic::set_nthreads(int n) -{ - d_nthreads = n; - if(d_fwdfft) - d_fwdfft->set_nthreads(n); - if(d_invfft) - d_invfft->set_nthreads(n); -} - -int -gri_fft_filter_fff_generic::nthreads() const -{ - return d_nthreads; -} - -int -gri_fft_filter_fff_generic::filter (int nitems, const float *input, float *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(float)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - gr_complex *a = d_fwdfft->get_outbuf(); - gr_complex *b = d_xformed_taps; - gr_complex *c = d_invfft->get_inbuf(); - - volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize/2+1); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - - //memcpy(out, d_invfft->get_outbuf(), d_nsamples * sizeof(float)); - //out += d_nsamples; - - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(float)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h deleted file mode 100644 index 528bf5dd7d..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_GRI_FFT_FILTER_FFF_GENERIC_H -#define INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_real_fwd; -class gri_fft_real_rev; - -class GR_CORE_API gri_fft_filter_fff_generic -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_real_fwd *d_fwdfft; // forward "plan" - gri_fft_real_rev *d_invfft; // inverse "plan" - int d_nthreads; // number of FFTW threads to use - std::vector<float> d_tail; // state carried between blocks for overlap-add - std::vector<float> d_new_taps; - gr_complex *d_xformed_taps; // Fourier xformed taps - - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct a FFT filter for float vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for floating point vectors (such as gr_fft_filter_fff). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (float) - * \param nthreads The number of threads for the FFT to use (int) - */ - gri_fft_filter_fff_generic (int decimation, const std::vector<float> &taps, - int nthreads=1); - ~gri_fft_filter_fff_generic (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (float) - */ - int set_taps (const std::vector<float> &taps); - - /*! - * \brief Set number of threads to use. - */ - void set_nthreads(int n); - - /*! - * \brief Get number of threads being used. - */ - int nthreads() const; - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const float *input, float *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc deleted file mode 100644 index 84fcfa4380..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gri_fft_filter_fff_sse.h> -#include <gri_fft.h> -#include <assert.h> -#include <stdexcept> -#include <cstdio> -#include <xmmintrin.h> -#include <fftw3.h> - -gri_fft_filter_fff_sse::gri_fft_filter_fff_sse (int decimation, - const std::vector<float> &taps) - : d_fftsize(-1), d_decimation(decimation), d_fwdfft(0), d_invfft(0) -{ - d_xformed_taps = (gr_complex*)fftwf_malloc(1*sizeof(gr_complex)); - set_taps(taps); -} - -gri_fft_filter_fff_sse::~gri_fft_filter_fff_sse () -{ - fftwf_free(d_xformed_taps); - delete d_fwdfft; - delete d_invfft; -} - -/* - * determines d_ntaps, d_nsamples, d_fftsize, d_xformed_taps - */ -int -gri_fft_filter_fff_sse::set_taps (const std::vector<float> &taps) -{ - int i = 0; - compute_sizes(taps.size()); - - d_tail.resize(tailsize()); - for (i = 0; i < tailsize(); i++) - d_tail[i] = 0; - - float *in = d_fwdfft->get_inbuf(); - gr_complex *out = d_fwdfft->get_outbuf(); - - float scale = 1.0 / d_fftsize; - - // Compute forward xform of taps. - // Copy taps into first ntaps slots, then pad with zeros - for (i = 0; i < d_ntaps; i++) - in[i] = taps[i] * scale; - - for (; i < d_fftsize; i++) - in[i] = 0; - - d_fwdfft->execute(); // do the xform - - // now copy output to d_xformed_taps - for (i = 0; i < d_fftsize/2+1; i++) - d_xformed_taps[i] = out[i]; - - return d_nsamples; -} - -// determine and set d_ntaps, d_nsamples, d_fftsize - -void -gri_fft_filter_fff_sse::compute_sizes(int ntaps) -{ - int old_fftsize = d_fftsize; - d_ntaps = ntaps; - d_fftsize = (int) (2 * pow(2.0, ceil(log(ntaps) / log(2)))); - d_nsamples = d_fftsize - d_ntaps + 1; - - if (0) - fprintf(stderr, "gri_fft_filter_fff_sse: ntaps = %d, fftsize = %d, nsamples = %d\n", - d_ntaps, d_fftsize, d_nsamples); - - assert(d_fftsize == d_ntaps + d_nsamples -1 ); - - if (d_fftsize != old_fftsize){ // compute new plans - delete d_fwdfft; - delete d_invfft; - d_fwdfft = new gri_fft_real_fwd(d_fftsize); - d_invfft = new gri_fft_real_rev(d_fftsize); - //d_xformed_taps.resize(d_fftsize/2+1); - - fftwf_free(d_xformed_taps); - d_xformed_taps = (gr_complex*)fftwf_malloc((d_fftsize/2+1)*sizeof(gr_complex)); - } -} - -int -gri_fft_filter_fff_sse::filter (int nitems, const float *input, float *output) -{ - int dec_ctr = 0; - int j = 0; - int ninput_items = nitems * d_decimation; - - for (int i = 0; i < ninput_items; i += d_nsamples){ - - memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(float)); - - for (j = d_nsamples; j < d_fftsize; j++) - d_fwdfft->get_inbuf()[j] = 0; - - d_fwdfft->execute(); // compute fwd xform - - float *a = (float*)(d_fwdfft->get_outbuf()); - float *b = (float*)(&d_xformed_taps[0]); - float *c = (float*)(d_invfft->get_inbuf()); - - __m128 x0, x1, x2, t0, t1, m; - m = _mm_set_ps(-1, 1, -1, 1); - for (j = 0; j < d_fftsize; j+=4) { // filter in the freq domain - x0 = _mm_load_ps(&a[j]); - t0 = _mm_load_ps(&b[j]); - - t1 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(3, 3, 1, 1)); - t0 = _mm_shuffle_ps(t0, t0, _MM_SHUFFLE(2, 2, 0, 0)); - t1 = _mm_mul_ps(t1, m); - - x1 = _mm_mul_ps(x0, t0); - x2 = _mm_mul_ps(x0, t1); - - x2 = _mm_shuffle_ps(x2, x2, _MM_SHUFFLE(2, 3, 0, 1)); - x2 = _mm_add_ps(x1, x2); - - _mm_store_ps(&c[j], x2); - } - - // Finish off the last one; do the complex multiply as floats - j = d_fftsize/2; - c[j] = (a[j] * b[j]) - (a[j+1] * b[j+1]); - c[j+1] = (a[j] * b[j+1]) + (a[j+1] * b[j]); - - d_invfft->execute(); // compute inv xform - - // add in the overlapping tail - - for (j = 0; j < tailsize(); j++) - d_invfft->get_outbuf()[j] += d_tail[j]; - - // copy nsamples to output - - //memcpy(out, d_invfft->get_outbuf(), d_nsamples * sizeof(float)); - //out += d_nsamples; - - j = dec_ctr; - while (j < d_nsamples) { - *output++ = d_invfft->get_outbuf()[j]; - j += d_decimation; - } - dec_ctr = (j - d_nsamples); - - // stash the tail - memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples, - tailsize() * sizeof(float)); - } - - assert(dec_ctr == 0); - - return nitems; -} diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h deleted file mode 100644 index b6086562d9..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_fff_sse.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_GRI_FFT_FILTER_FFF_SSE_H -#define INCLUDED_GRI_FFT_FILTER_FFF_SSE_H - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gri_fft_real_fwd; -class gri_fft_real_rev; - -class GR_CORE_API gri_fft_filter_fff_sse -{ - private: - int d_ntaps; - int d_nsamples; - int d_fftsize; // fftsize = ntaps + nsamples - 1 - int d_decimation; - gri_fft_real_fwd *d_fwdfft; // forward "plan" - gri_fft_real_rev *d_invfft; // inverse "plan" - std::vector<float> d_tail; // state carried between blocks for overlap-add - //std::vector<gr_complex> d_xformed_taps; // Fourier xformed taps - gr_complex *d_xformed_taps; - std::vector<float> d_new_taps; - - - void compute_sizes(int ntaps); - int tailsize() const { return d_ntaps - 1; } - - public: - /*! - * \brief Construct a FFT filter for float vectors with the given taps and decimation rate. - * - * This is the basic implementation for performing FFT filter for fast convolution - * in other blocks for floating point vectors (such as gr_fft_filter_fff). - * \param decimation The decimation rate of the filter (int) - * \param taps The filter taps (float) - */ - gri_fft_filter_fff_sse (int decimation, const std::vector<float> &taps); - ~gri_fft_filter_fff_sse (); - - /*! - * \brief Set new taps for the filter. - * - * Sets new taps and resets the class properties to handle different sizes - * \param taps The filter taps (float) - */ - int set_taps (const std::vector<float> &taps); - - /*! - * \brief Perform the filter operation - * - * \param nitems The number of items to produce - * \param input The input vector to be filtered - * \param output The result of the filter operation - */ - int filter (int nitems, const float *input, float *output); - -}; - -#endif /* INCLUDED_GRI_FFT_FILTER_FFF_SSE_H */ diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t deleted file mode 100644 index 0ae644cc65..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <@NAME@.h> - -@NAME@::@NAME@(const std::vector<@TAP_TYPE@> &taps) -{ - d_buffer = NULL; - set_taps(taps); -} - -@NAME@::~@NAME@() -{ - if(d_buffer != NULL) - free(d_buffer); -} - -void -@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) -{ - d_taps = gr_reverse(taps); - - if(d_buffer != NULL) { - free(d_buffer); - d_buffer = NULL; - } - - // FIXME: memalign this to 16-byte boundaries for SIMD later - size_t t = sizeof(@I_TYPE@) * 2 * d_taps.size(); - d_buffer = (@I_TYPE@*)malloc(t); - memset(d_buffer, 0x00, t); - d_idx = 0; -} - -@O_TYPE@ -@NAME@::filter (@I_TYPE@ input) -{ - unsigned int i; - - d_buffer[d_idx] = input; - d_buffer[d_idx+ntaps()] = input; - - // using the later for the case when ntaps=0; - // profiling shows this doesn't make a difference - //d_idx = (d_idx + 1) % ntaps(); - d_idx++; - if(d_idx >= ntaps()) - d_idx = 0; - - @ACC_TYPE@ out = 0; - for(i = 0; i < ntaps(); i++) { - out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; - } - return (@O_TYPE@)out; -} - -@O_TYPE@ -@NAME@::filter (const @I_TYPE@ input[], unsigned long dec) -{ - unsigned int i; - - for(i = 0; i < dec; i++) { - d_buffer[d_idx] = input[i]; - d_buffer[d_idx+ntaps()] = input[i]; - d_idx++; - if(d_idx >= ntaps()) - d_idx = 0; - } - - @ACC_TYPE@ out = 0; - for(i = 0; i < ntaps(); i++) { - out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; - } - return (@O_TYPE@)out; -} - -void -@NAME@::filterN (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n) -{ - for(unsigned long i = 0; i < n; i++) { - output[i] = filter(input[i]); - } -} - -void -@NAME@::filterNdec (@O_TYPE@ output[], - const @I_TYPE@ input[], - unsigned long n, - unsigned long decimate) -{ - unsigned long j = 0; - for(unsigned long i = 0; i < n; i++) { - output[i] = filter(&input[j], decimate); - j += decimate; - } -} diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t deleted file mode 100644 index efb314bed0..0000000000 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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. - */ - -/* - * WARNING: This file is automatically generated by generate_gri_fir_XXX.py - * Any changes made to this file will be overwritten. - */ - - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <vector> -#include <gr_types.h> -#include <gr_reverse.h> -#include <string.h> -#include <cstdio> - -/*! - * \brief FIR with internal buffer for @I_TYPE@ input, - @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter - * - */ - -class GR_CORE_API @NAME@ { - -protected: - std::vector<@TAP_TYPE@> d_taps; // reversed taps - @I_TYPE@ *d_buffer; - unsigned int d_idx; - -public: - - // CONSTRUCTORS - - /*! - * \brief construct new FIR with given taps. - * - * Note that taps must be in forward order, e.g., coefficient 0 is - * stored in new_taps[0], coefficient 1 is stored in - * new_taps[1], etc. - */ - @NAME@ (const std::vector<@TAP_TYPE@> &taps); - - ~@NAME@ (); - - // MANIPULATORS - - /*! - * \brief compute a single output value. - * - * \p input is a single input value of the filter type - * - * \returns the filtered input value. - */ - @O_TYPE@ filter (@I_TYPE@ input); - - - /*! - * \brief compute a single output value; designed for decimating filters. - * - * \p input is a single input value of the filter type. The value of dec is the - * decimating value of the filter, so input[] must have dec valid values. - * The filter pushes dec number of items onto the circ. buffer before computing - * a single output. - * - * \returns the filtered input value. - */ - @O_TYPE@ filter (const @I_TYPE@ input[], unsigned long dec); - - /*! - * \brief compute an array of N output values. - * - * \p input must have (n - 1 + ntaps()) valid entries. - * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. - */ - void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n); - - /*! - * \brief compute an array of N output values, decimating the input - * - * \p input must have (decimate * (n - 1) + ntaps()) valid entries. - * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to - * compute the output values. - */ - void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned long decimate); - - /*! - * \brief install \p new_taps as the current taps. - */ - void set_taps (const std::vector<@TAP_TYPE@> &taps); - - // ACCESSORS - - /*! - * \return number of taps in filter. - */ - unsigned ntaps () const { return d_taps.size (); } - - /*! - * \return current taps - */ - const std::vector<@TAP_TYPE@> get_taps () const - { - return gr_reverse(d_taps); - } -}; - -#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/gri_iir.h b/gnuradio-core/src/lib/filter/gri_iir.h deleted file mode 100644 index 86345f6c09..0000000000 --- a/gnuradio-core/src/lib/filter/gri_iir.h +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_GRI_IIR_H -#define INCLUDED_GRI_IIR_H - -#include <gr_core_api.h> -#include <vector> -#include <stdexcept> - -/*! - * \brief base class template for Infinite Impulse Response filter (IIR) - */ -template<class i_type, class o_type, class tap_type> -class gri_iir { -public: - /*! - * \brief Construct an IIR with the given taps. - * - * This filter uses the Direct Form I implementation, where - * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. - * - * \p fftaps and \p fbtaps must have equal numbers of taps - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k] - \f] - - * with the corresponding rational system function - - \f[ - H(z) = \frac{\sum_{k=0}^{N} b_k z^{-k}}{1 - \sum_{k=1}^{M} a_k z^{-k}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback taps. - */ - gri_iir (const std::vector<tap_type>& fftaps, - const std::vector<tap_type>& fbtaps) throw (std::invalid_argument) - { - set_taps (fftaps, fbtaps); - } - - gri_iir () : d_latest_n(0),d_latest_m(0) { } - - ~gri_iir () {} - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have N valid entries. - */ - void filter_n (o_type output[], const i_type input[], long n); - - /*! - * \return number of taps in filter. - */ - unsigned ntaps_ff () const { return d_fftaps.size (); } - unsigned ntaps_fb () const { return d_fbtaps.size (); } - - /*! - * \brief install new taps. - */ - void set_taps (const std::vector<tap_type> &fftaps, - const std::vector<tap_type> &fbtaps) throw (std::invalid_argument) - { - - - d_latest_n = 0; - d_latest_m = 0; - d_fftaps = fftaps; - d_fbtaps = fbtaps; - - int n = fftaps.size (); - int m = fbtaps.size (); - d_prev_input.resize (2 * n); - d_prev_output.resize (2 * m); - - for (int i = 0; i < 2 * n; i++){ - d_prev_input[i] = 0; - } - for (int i = 0; i < 2 * m; i++){ - d_prev_output[i] = 0; - } - } - -protected: - std::vector<tap_type> d_fftaps; - std::vector<tap_type> d_fbtaps; - int d_latest_n; - int d_latest_m; - std::vector<tap_type> d_prev_output; - std::vector<i_type> d_prev_input; -}; - - -// -// general case. We may want to specialize this -// -template<class i_type, class o_type, class tap_type> -o_type -gri_iir<i_type, o_type, tap_type>::filter (const i_type input) -{ - tap_type acc; - unsigned i = 0; - unsigned n = ntaps_ff (); - unsigned m = ntaps_fb (); - - if (n == 0) - return (o_type) 0; - - int latest_n = d_latest_n; - int latest_m = d_latest_m; - - acc = d_fftaps[0] * input; - for (i = 1; i < n; i ++) - acc += (d_fftaps[i] * d_prev_input[latest_n + i]); - for (i = 1; i < m; i ++) - acc += (d_fbtaps[i] * d_prev_output[latest_m + i]); - - // store the values twice to avoid having to handle wrap-around in the loop - d_prev_output[latest_m] = acc; - d_prev_output[latest_m+m] = acc; - d_prev_input[latest_n] = input; - d_prev_input[latest_n+n] = input; - - latest_n--; - latest_m--; - if (latest_n < 0) - latest_n += n; - if (latest_m < 0) - latest_m += m; - - d_latest_m = latest_m; - d_latest_n = latest_n; - return (o_type) acc; -} - - -template<class i_type, class o_type, class tap_type> -void -gri_iir<i_type, o_type, tap_type>::filter_n (o_type output[], - const i_type input[], - long n) -{ - for (int i = 0; i < n; i++) - output[i] = filter (input[i]); -} - -#endif /* INCLUDED_GRI_IIR_H */ - diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc deleted file mode 100644 index 52098bf1aa..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gri_mmse_fir_interpolator.h> -#include <gr_fir_util.h> -#include <gr_fir_fff.h> -#include <assert.h> -#include <cmath> -#include "interpolator_taps.h" - -gri_mmse_fir_interpolator::gri_mmse_fir_interpolator () -{ - filters.resize (NSTEPS + 1); - - for (int i = 0; i < NSTEPS + 1; i++){ - std::vector<float> t (&taps[i][0], &taps[i][NTAPS]); - filters[i] = gr_fir_util::create_gr_fir_fff (t); - } -} - -gri_mmse_fir_interpolator::~gri_mmse_fir_interpolator () -{ - for (int i = 0; i < NSTEPS + 1; i++) - delete filters[i]; -} - -unsigned -gri_mmse_fir_interpolator::ntaps () const -{ - return NTAPS; -} - -unsigned -gri_mmse_fir_interpolator::nsteps () const -{ - return NSTEPS; -} - -float -gri_mmse_fir_interpolator::interpolate (const float input[], float mu) const -{ - int imu = (int) rint (mu * NSTEPS); - - assert (imu >= 0); - assert (imu <= NSTEPS); - - float r = filters[imu]->filter (input); - return r; -} diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h deleted file mode 100644 index f479169bc8..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _GRI_MMSE_FIR_INTERPOLATOR_H_ -#define _GRI_MMSE_FIR_INTERPOLATOR_H_ - -#include <gr_core_api.h> -#include <vector> - -class gr_fir_fff; - -/*! - * \brief Compute intermediate samples between signal samples x(k*Ts) - * \ingroup filter_primitive - * - * This implements a Mininum Mean Squared Error interpolator with 8 taps. - * It is suitable for signals where the bandwidth of interest B = 1/(4*Ts) - * Where Ts is the time between samples. - * - * Although mu, the fractional delay, is specified as a float, it is actually - * quantized. 0.0 <= mu <= 1.0. That is, mu is quantized in the interpolate - * method to 32nd's of a sample. - * - * For more information, in the GNU Radio source code, see: - * \li gnuradio-core/src/gen_interpolator_taps/README - * \li gnuradio-core/src/gen_interpolator_taps/praxis.txt - */ - -class GR_CORE_API gri_mmse_fir_interpolator { -public: - gri_mmse_fir_interpolator (); - ~gri_mmse_fir_interpolator (); - - unsigned ntaps () const; - unsigned nsteps () const; - - /*! - * \brief compute a single interpolated output value. - * \p input must have ntaps() valid entries. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * - * \p mu must be in the range [0, 1] and specifies the fractional delay. - * - * \returns the interpolated input value. - */ - float interpolate (const float input[], float mu) const; - -protected: - std::vector<gr_fir_fff *> filters; -}; - - -#endif /* _GRI_MMSE_FIR_INTERPOLATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc deleted file mode 100644 index 174378c22a..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gri_mmse_fir_interpolator_cc.h> -#include <gr_fir_util.h> -#include <gr_fir_ccf.h> -#include <assert.h> -#include <cmath> -#include "interpolator_taps.h" - -gri_mmse_fir_interpolator_cc::gri_mmse_fir_interpolator_cc () -{ - filters.resize (NSTEPS + 1); - - for (int i = 0; i < NSTEPS + 1; i++){ - std::vector<float> t (&taps[i][0], &taps[i][NTAPS]); - filters[i] = gr_fir_util::create_gr_fir_ccf (t); - } -} - -gri_mmse_fir_interpolator_cc::~gri_mmse_fir_interpolator_cc () -{ - for (int i = 0; i < NSTEPS + 1; i++) - delete filters[i]; -} - -unsigned -gri_mmse_fir_interpolator_cc::ntaps () const -{ - return NTAPS; -} - -unsigned -gri_mmse_fir_interpolator_cc::nsteps () const -{ - return NSTEPS; -} - -gr_complex -gri_mmse_fir_interpolator_cc::interpolate (const gr_complex input[], float mu) -{ - int imu = (int) rint (mu * NSTEPS); - - assert (imu >= 0); - assert (imu <= NSTEPS); - - gr_complex r = filters[imu]->filter (input); - return r; -} diff --git a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h b/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h deleted file mode 100644 index bacd9ed92a..0000000000 --- a/gnuradio-core/src/lib/filter/gri_mmse_fir_interpolator_cc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 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 _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ -#define _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <vector> - -class gr_fir_ccf; - -/*! - * \brief Compute intermediate samples between signal samples x(k*Ts) - * \ingroup filter_primitive - * - * This implements a Mininum Mean Squared Error interpolator with 8 taps. - * It is suitable for signals where the bandwidth of interest B = 1/(4*Ts) - * Where Ts is the time between samples. - * - * Although mu, the fractional delay, is specified as a float, it is actually - * quantized. 0.0 <= mu <= 1.0. That is, mu is quantized in the interpolate - * method to 32nd's of a sample. - * - * For more information, in the GNU Radio source code, see: - * \li gnuradio-core/src/gen_interpolator_taps/README - * \li gnuradio-core/src/gen_interpolator_taps/praxis.txt - */ - -class GR_CORE_API gri_mmse_fir_interpolator_cc { -public: - gri_mmse_fir_interpolator_cc (); - ~gri_mmse_fir_interpolator_cc (); - - unsigned ntaps () const; - unsigned nsteps () const; - - /*! - * \brief compute a single interpolated output value. - * - * \p input must have ntaps() valid entries and be 8-byte aligned. - * input[0] .. input[ntaps() - 1] are referenced to compute the output value. - * \throws std::invalid_argument if input is not 8-byte aligned. - * - * \p mu must be in the range [0, 1] and specifies the fractional delay. - * - * \returns the interpolated input value. - */ - gr_complex interpolate (const gr_complex input[], float mu); - -protected: - std::vector<gr_fir_ccf *> filters; -}; - - -#endif /* _GRI_MMSE_FIR_INTERPOLATOR_CC_H_ */ diff --git a/gnuradio-core/src/lib/filter/interpolator_taps.h b/gnuradio-core/src/lib/filter/interpolator_taps.h deleted file mode 100644 index 76702b63fa..0000000000 --- a/gnuradio-core/src/lib/filter/interpolator_taps.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file was machine generated by gen_interpolator_taps. - * DO NOT EDIT BY HAND. - */ - -static const int NTAPS = 8; -static const int NSTEPS = 128; - -static const float taps[NSTEPS+1][NTAPS] = { - // -4 -3 -2 -1 0 1 2 3 mu - { 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 1.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00 }, // 0/128 - { -1.54700e-04, 8.53777e-04, -2.76968e-03, 7.89295e-03, 9.98534e-01, -5.41054e-03, 1.24642e-03, -1.98993e-04 }, // 1/128 - { -3.09412e-04, 1.70888e-03, -5.55134e-03, 1.58840e-02, 9.96891e-01, -1.07209e-02, 2.47942e-03, -3.96391e-04 }, // 2/128 - { -4.64053e-04, 2.56486e-03, -8.34364e-03, 2.39714e-02, 9.95074e-01, -1.59305e-02, 3.69852e-03, -5.92100e-04 }, // 3/128 - { -6.18544e-04, 3.42130e-03, -1.11453e-02, 3.21531e-02, 9.93082e-01, -2.10389e-02, 4.90322e-03, -7.86031e-04 }, // 4/128 - { -7.72802e-04, 4.27773e-03, -1.39548e-02, 4.04274e-02, 9.90917e-01, -2.60456e-02, 6.09305e-03, -9.78093e-04 }, // 5/128 - { -9.26747e-04, 5.13372e-03, -1.67710e-02, 4.87921e-02, 9.88580e-01, -3.09503e-02, 7.26755e-03, -1.16820e-03 }, // 6/128 - { -1.08030e-03, 5.98883e-03, -1.95925e-02, 5.72454e-02, 9.86071e-01, -3.57525e-02, 8.42626e-03, -1.35627e-03 }, // 7/128 - { -1.23337e-03, 6.84261e-03, -2.24178e-02, 6.57852e-02, 9.83392e-01, -4.04519e-02, 9.56876e-03, -1.54221e-03 }, // 8/128 - { -1.38589e-03, 7.69462e-03, -2.52457e-02, 7.44095e-02, 9.80543e-01, -4.50483e-02, 1.06946e-02, -1.72594e-03 }, // 9/128 - { -1.53777e-03, 8.54441e-03, -2.80746e-02, 8.31162e-02, 9.77526e-01, -4.95412e-02, 1.18034e-02, -1.90738e-03 }, // 10/128 - { -1.68894e-03, 9.39154e-03, -3.09033e-02, 9.19033e-02, 9.74342e-01, -5.39305e-02, 1.28947e-02, -2.08645e-03 }, // 11/128 - { -1.83931e-03, 1.02356e-02, -3.37303e-02, 1.00769e-01, 9.70992e-01, -5.82159e-02, 1.39681e-02, -2.26307e-03 }, // 12/128 - { -1.98880e-03, 1.10760e-02, -3.65541e-02, 1.09710e-01, 9.67477e-01, -6.23972e-02, 1.50233e-02, -2.43718e-03 }, // 13/128 - { -2.13733e-03, 1.19125e-02, -3.93735e-02, 1.18725e-01, 9.63798e-01, -6.64743e-02, 1.60599e-02, -2.60868e-03 }, // 14/128 - { -2.28483e-03, 1.27445e-02, -4.21869e-02, 1.27812e-01, 9.59958e-01, -7.04471e-02, 1.70776e-02, -2.77751e-03 }, // 15/128 - { -2.43121e-03, 1.35716e-02, -4.49929e-02, 1.36968e-01, 9.55956e-01, -7.43154e-02, 1.80759e-02, -2.94361e-03 }, // 16/128 - { -2.57640e-03, 1.43934e-02, -4.77900e-02, 1.46192e-01, 9.51795e-01, -7.80792e-02, 1.90545e-02, -3.10689e-03 }, // 17/128 - { -2.72032e-03, 1.52095e-02, -5.05770e-02, 1.55480e-01, 9.47477e-01, -8.17385e-02, 2.00132e-02, -3.26730e-03 }, // 18/128 - { -2.86289e-03, 1.60193e-02, -5.33522e-02, 1.64831e-01, 9.43001e-01, -8.52933e-02, 2.09516e-02, -3.42477e-03 }, // 19/128 - { -3.00403e-03, 1.68225e-02, -5.61142e-02, 1.74242e-01, 9.38371e-01, -8.87435e-02, 2.18695e-02, -3.57923e-03 }, // 20/128 - { -3.14367e-03, 1.76185e-02, -5.88617e-02, 1.83711e-01, 9.33586e-01, -9.20893e-02, 2.27664e-02, -3.73062e-03 }, // 21/128 - { -3.28174e-03, 1.84071e-02, -6.15931e-02, 1.93236e-01, 9.28650e-01, -9.53307e-02, 2.36423e-02, -3.87888e-03 }, // 22/128 - { -3.41815e-03, 1.91877e-02, -6.43069e-02, 2.02814e-01, 9.23564e-01, -9.84679e-02, 2.44967e-02, -4.02397e-03 }, // 23/128 - { -3.55283e-03, 1.99599e-02, -6.70018e-02, 2.12443e-01, 9.18329e-01, -1.01501e-01, 2.53295e-02, -4.16581e-03 }, // 24/128 - { -3.68570e-03, 2.07233e-02, -6.96762e-02, 2.22120e-01, 9.12947e-01, -1.04430e-01, 2.61404e-02, -4.30435e-03 }, // 25/128 - { -3.81671e-03, 2.14774e-02, -7.23286e-02, 2.31843e-01, 9.07420e-01, -1.07256e-01, 2.69293e-02, -4.43955e-03 }, // 26/128 - { -3.94576e-03, 2.22218e-02, -7.49577e-02, 2.41609e-01, 9.01749e-01, -1.09978e-01, 2.76957e-02, -4.57135e-03 }, // 27/128 - { -4.07279e-03, 2.29562e-02, -7.75620e-02, 2.51417e-01, 8.95936e-01, -1.12597e-01, 2.84397e-02, -4.69970e-03 }, // 28/128 - { -4.19774e-03, 2.36801e-02, -8.01399e-02, 2.61263e-01, 8.89984e-01, -1.15113e-01, 2.91609e-02, -4.82456e-03 }, // 29/128 - { -4.32052e-03, 2.43930e-02, -8.26900e-02, 2.71144e-01, 8.83893e-01, -1.17526e-01, 2.98593e-02, -4.94589e-03 }, // 30/128 - { -4.44107e-03, 2.50946e-02, -8.52109e-02, 2.81060e-01, 8.77666e-01, -1.19837e-01, 3.05345e-02, -5.06363e-03 }, // 31/128 - { -4.55932e-03, 2.57844e-02, -8.77011e-02, 2.91006e-01, 8.71305e-01, -1.22047e-01, 3.11866e-02, -5.17776e-03 }, // 32/128 - { -4.67520e-03, 2.64621e-02, -9.01591e-02, 3.00980e-01, 8.64812e-01, -1.24154e-01, 3.18153e-02, -5.28823e-03 }, // 33/128 - { -4.78866e-03, 2.71272e-02, -9.25834e-02, 3.10980e-01, 8.58189e-01, -1.26161e-01, 3.24205e-02, -5.39500e-03 }, // 34/128 - { -4.89961e-03, 2.77794e-02, -9.49727e-02, 3.21004e-01, 8.51437e-01, -1.28068e-01, 3.30021e-02, -5.49804e-03 }, // 35/128 - { -5.00800e-03, 2.84182e-02, -9.73254e-02, 3.31048e-01, 8.44559e-01, -1.29874e-01, 3.35600e-02, -5.59731e-03 }, // 36/128 - { -5.11376e-03, 2.90433e-02, -9.96402e-02, 3.41109e-01, 8.37557e-01, -1.31581e-01, 3.40940e-02, -5.69280e-03 }, // 37/128 - { -5.21683e-03, 2.96543e-02, -1.01915e-01, 3.51186e-01, 8.30432e-01, -1.33189e-01, 3.46042e-02, -5.78446e-03 }, // 38/128 - { -5.31716e-03, 3.02507e-02, -1.04150e-01, 3.61276e-01, 8.23188e-01, -1.34699e-01, 3.50903e-02, -5.87227e-03 }, // 39/128 - { -5.41467e-03, 3.08323e-02, -1.06342e-01, 3.71376e-01, 8.15826e-01, -1.36111e-01, 3.55525e-02, -5.95620e-03 }, // 40/128 - { -5.50931e-03, 3.13987e-02, -1.08490e-01, 3.81484e-01, 8.08348e-01, -1.37426e-01, 3.59905e-02, -6.03624e-03 }, // 41/128 - { -5.60103e-03, 3.19495e-02, -1.10593e-01, 3.91596e-01, 8.00757e-01, -1.38644e-01, 3.64044e-02, -6.11236e-03 }, // 42/128 - { -5.68976e-03, 3.24843e-02, -1.12650e-01, 4.01710e-01, 7.93055e-01, -1.39767e-01, 3.67941e-02, -6.18454e-03 }, // 43/128 - { -5.77544e-03, 3.30027e-02, -1.14659e-01, 4.11823e-01, 7.85244e-01, -1.40794e-01, 3.71596e-02, -6.25277e-03 }, // 44/128 - { -5.85804e-03, 3.35046e-02, -1.16618e-01, 4.21934e-01, 7.77327e-01, -1.41727e-01, 3.75010e-02, -6.31703e-03 }, // 45/128 - { -5.93749e-03, 3.39894e-02, -1.18526e-01, 4.32038e-01, 7.69305e-01, -1.42566e-01, 3.78182e-02, -6.37730e-03 }, // 46/128 - { -6.01374e-03, 3.44568e-02, -1.20382e-01, 4.42134e-01, 7.61181e-01, -1.43313e-01, 3.81111e-02, -6.43358e-03 }, // 47/128 - { -6.08674e-03, 3.49066e-02, -1.22185e-01, 4.52218e-01, 7.52958e-01, -1.43968e-01, 3.83800e-02, -6.48585e-03 }, // 48/128 - { -6.15644e-03, 3.53384e-02, -1.23933e-01, 4.62289e-01, 7.44637e-01, -1.44531e-01, 3.86247e-02, -6.53412e-03 }, // 49/128 - { -6.22280e-03, 3.57519e-02, -1.25624e-01, 4.72342e-01, 7.36222e-01, -1.45004e-01, 3.88454e-02, -6.57836e-03 }, // 50/128 - { -6.28577e-03, 3.61468e-02, -1.27258e-01, 4.82377e-01, 7.27714e-01, -1.45387e-01, 3.90420e-02, -6.61859e-03 }, // 51/128 - { -6.34530e-03, 3.65227e-02, -1.28832e-01, 4.92389e-01, 7.19116e-01, -1.45682e-01, 3.92147e-02, -6.65479e-03 }, // 52/128 - { -6.40135e-03, 3.68795e-02, -1.30347e-01, 5.02377e-01, 7.10431e-01, -1.45889e-01, 3.93636e-02, -6.68698e-03 }, // 53/128 - { -6.45388e-03, 3.72167e-02, -1.31800e-01, 5.12337e-01, 7.01661e-01, -1.46009e-01, 3.94886e-02, -6.71514e-03 }, // 54/128 - { -6.50285e-03, 3.75341e-02, -1.33190e-01, 5.22267e-01, 6.92808e-01, -1.46043e-01, 3.95900e-02, -6.73929e-03 }, // 55/128 - { -6.54823e-03, 3.78315e-02, -1.34515e-01, 5.32164e-01, 6.83875e-01, -1.45993e-01, 3.96678e-02, -6.75943e-03 }, // 56/128 - { -6.58996e-03, 3.81085e-02, -1.35775e-01, 5.42025e-01, 6.74865e-01, -1.45859e-01, 3.97222e-02, -6.77557e-03 }, // 57/128 - { -6.62802e-03, 3.83650e-02, -1.36969e-01, 5.51849e-01, 6.65779e-01, -1.45641e-01, 3.97532e-02, -6.78771e-03 }, // 58/128 - { -6.66238e-03, 3.86006e-02, -1.38094e-01, 5.61631e-01, 6.56621e-01, -1.45343e-01, 3.97610e-02, -6.79588e-03 }, // 59/128 - { -6.69300e-03, 3.88151e-02, -1.39150e-01, 5.71370e-01, 6.47394e-01, -1.44963e-01, 3.97458e-02, -6.80007e-03 }, // 60/128 - { -6.71985e-03, 3.90083e-02, -1.40136e-01, 5.81063e-01, 6.38099e-01, -1.44503e-01, 3.97077e-02, -6.80032e-03 }, // 61/128 - { -6.74291e-03, 3.91800e-02, -1.41050e-01, 5.90706e-01, 6.28739e-01, -1.43965e-01, 3.96469e-02, -6.79662e-03 }, // 62/128 - { -6.76214e-03, 3.93299e-02, -1.41891e-01, 6.00298e-01, 6.19318e-01, -1.43350e-01, 3.95635e-02, -6.78902e-03 }, // 63/128 - { -6.77751e-03, 3.94578e-02, -1.42658e-01, 6.09836e-01, 6.09836e-01, -1.42658e-01, 3.94578e-02, -6.77751e-03 }, // 64/128 - { -6.78902e-03, 3.95635e-02, -1.43350e-01, 6.19318e-01, 6.00298e-01, -1.41891e-01, 3.93299e-02, -6.76214e-03 }, // 65/128 - { -6.79662e-03, 3.96469e-02, -1.43965e-01, 6.28739e-01, 5.90706e-01, -1.41050e-01, 3.91800e-02, -6.74291e-03 }, // 66/128 - { -6.80032e-03, 3.97077e-02, -1.44503e-01, 6.38099e-01, 5.81063e-01, -1.40136e-01, 3.90083e-02, -6.71985e-03 }, // 67/128 - { -6.80007e-03, 3.97458e-02, -1.44963e-01, 6.47394e-01, 5.71370e-01, -1.39150e-01, 3.88151e-02, -6.69300e-03 }, // 68/128 - { -6.79588e-03, 3.97610e-02, -1.45343e-01, 6.56621e-01, 5.61631e-01, -1.38094e-01, 3.86006e-02, -6.66238e-03 }, // 69/128 - { -6.78771e-03, 3.97532e-02, -1.45641e-01, 6.65779e-01, 5.51849e-01, -1.36969e-01, 3.83650e-02, -6.62802e-03 }, // 70/128 - { -6.77557e-03, 3.97222e-02, -1.45859e-01, 6.74865e-01, 5.42025e-01, -1.35775e-01, 3.81085e-02, -6.58996e-03 }, // 71/128 - { -6.75943e-03, 3.96678e-02, -1.45993e-01, 6.83875e-01, 5.32164e-01, -1.34515e-01, 3.78315e-02, -6.54823e-03 }, // 72/128 - { -6.73929e-03, 3.95900e-02, -1.46043e-01, 6.92808e-01, 5.22267e-01, -1.33190e-01, 3.75341e-02, -6.50285e-03 }, // 73/128 - { -6.71514e-03, 3.94886e-02, -1.46009e-01, 7.01661e-01, 5.12337e-01, -1.31800e-01, 3.72167e-02, -6.45388e-03 }, // 74/128 - { -6.68698e-03, 3.93636e-02, -1.45889e-01, 7.10431e-01, 5.02377e-01, -1.30347e-01, 3.68795e-02, -6.40135e-03 }, // 75/128 - { -6.65479e-03, 3.92147e-02, -1.45682e-01, 7.19116e-01, 4.92389e-01, -1.28832e-01, 3.65227e-02, -6.34530e-03 }, // 76/128 - { -6.61859e-03, 3.90420e-02, -1.45387e-01, 7.27714e-01, 4.82377e-01, -1.27258e-01, 3.61468e-02, -6.28577e-03 }, // 77/128 - { -6.57836e-03, 3.88454e-02, -1.45004e-01, 7.36222e-01, 4.72342e-01, -1.25624e-01, 3.57519e-02, -6.22280e-03 }, // 78/128 - { -6.53412e-03, 3.86247e-02, -1.44531e-01, 7.44637e-01, 4.62289e-01, -1.23933e-01, 3.53384e-02, -6.15644e-03 }, // 79/128 - { -6.48585e-03, 3.83800e-02, -1.43968e-01, 7.52958e-01, 4.52218e-01, -1.22185e-01, 3.49066e-02, -6.08674e-03 }, // 80/128 - { -6.43358e-03, 3.81111e-02, -1.43313e-01, 7.61181e-01, 4.42134e-01, -1.20382e-01, 3.44568e-02, -6.01374e-03 }, // 81/128 - { -6.37730e-03, 3.78182e-02, -1.42566e-01, 7.69305e-01, 4.32038e-01, -1.18526e-01, 3.39894e-02, -5.93749e-03 }, // 82/128 - { -6.31703e-03, 3.75010e-02, -1.41727e-01, 7.77327e-01, 4.21934e-01, -1.16618e-01, 3.35046e-02, -5.85804e-03 }, // 83/128 - { -6.25277e-03, 3.71596e-02, -1.40794e-01, 7.85244e-01, 4.11823e-01, -1.14659e-01, 3.30027e-02, -5.77544e-03 }, // 84/128 - { -6.18454e-03, 3.67941e-02, -1.39767e-01, 7.93055e-01, 4.01710e-01, -1.12650e-01, 3.24843e-02, -5.68976e-03 }, // 85/128 - { -6.11236e-03, 3.64044e-02, -1.38644e-01, 8.00757e-01, 3.91596e-01, -1.10593e-01, 3.19495e-02, -5.60103e-03 }, // 86/128 - { -6.03624e-03, 3.59905e-02, -1.37426e-01, 8.08348e-01, 3.81484e-01, -1.08490e-01, 3.13987e-02, -5.50931e-03 }, // 87/128 - { -5.95620e-03, 3.55525e-02, -1.36111e-01, 8.15826e-01, 3.71376e-01, -1.06342e-01, 3.08323e-02, -5.41467e-03 }, // 88/128 - { -5.87227e-03, 3.50903e-02, -1.34699e-01, 8.23188e-01, 3.61276e-01, -1.04150e-01, 3.02507e-02, -5.31716e-03 }, // 89/128 - { -5.78446e-03, 3.46042e-02, -1.33189e-01, 8.30432e-01, 3.51186e-01, -1.01915e-01, 2.96543e-02, -5.21683e-03 }, // 90/128 - { -5.69280e-03, 3.40940e-02, -1.31581e-01, 8.37557e-01, 3.41109e-01, -9.96402e-02, 2.90433e-02, -5.11376e-03 }, // 91/128 - { -5.59731e-03, 3.35600e-02, -1.29874e-01, 8.44559e-01, 3.31048e-01, -9.73254e-02, 2.84182e-02, -5.00800e-03 }, // 92/128 - { -5.49804e-03, 3.30021e-02, -1.28068e-01, 8.51437e-01, 3.21004e-01, -9.49727e-02, 2.77794e-02, -4.89961e-03 }, // 93/128 - { -5.39500e-03, 3.24205e-02, -1.26161e-01, 8.58189e-01, 3.10980e-01, -9.25834e-02, 2.71272e-02, -4.78866e-03 }, // 94/128 - { -5.28823e-03, 3.18153e-02, -1.24154e-01, 8.64812e-01, 3.00980e-01, -9.01591e-02, 2.64621e-02, -4.67520e-03 }, // 95/128 - { -5.17776e-03, 3.11866e-02, -1.22047e-01, 8.71305e-01, 2.91006e-01, -8.77011e-02, 2.57844e-02, -4.55932e-03 }, // 96/128 - { -5.06363e-03, 3.05345e-02, -1.19837e-01, 8.77666e-01, 2.81060e-01, -8.52109e-02, 2.50946e-02, -4.44107e-03 }, // 97/128 - { -4.94589e-03, 2.98593e-02, -1.17526e-01, 8.83893e-01, 2.71144e-01, -8.26900e-02, 2.43930e-02, -4.32052e-03 }, // 98/128 - { -4.82456e-03, 2.91609e-02, -1.15113e-01, 8.89984e-01, 2.61263e-01, -8.01399e-02, 2.36801e-02, -4.19774e-03 }, // 99/128 - { -4.69970e-03, 2.84397e-02, -1.12597e-01, 8.95936e-01, 2.51417e-01, -7.75620e-02, 2.29562e-02, -4.07279e-03 }, // 100/128 - { -4.57135e-03, 2.76957e-02, -1.09978e-01, 9.01749e-01, 2.41609e-01, -7.49577e-02, 2.22218e-02, -3.94576e-03 }, // 101/128 - { -4.43955e-03, 2.69293e-02, -1.07256e-01, 9.07420e-01, 2.31843e-01, -7.23286e-02, 2.14774e-02, -3.81671e-03 }, // 102/128 - { -4.30435e-03, 2.61404e-02, -1.04430e-01, 9.12947e-01, 2.22120e-01, -6.96762e-02, 2.07233e-02, -3.68570e-03 }, // 103/128 - { -4.16581e-03, 2.53295e-02, -1.01501e-01, 9.18329e-01, 2.12443e-01, -6.70018e-02, 1.99599e-02, -3.55283e-03 }, // 104/128 - { -4.02397e-03, 2.44967e-02, -9.84679e-02, 9.23564e-01, 2.02814e-01, -6.43069e-02, 1.91877e-02, -3.41815e-03 }, // 105/128 - { -3.87888e-03, 2.36423e-02, -9.53307e-02, 9.28650e-01, 1.93236e-01, -6.15931e-02, 1.84071e-02, -3.28174e-03 }, // 106/128 - { -3.73062e-03, 2.27664e-02, -9.20893e-02, 9.33586e-01, 1.83711e-01, -5.88617e-02, 1.76185e-02, -3.14367e-03 }, // 107/128 - { -3.57923e-03, 2.18695e-02, -8.87435e-02, 9.38371e-01, 1.74242e-01, -5.61142e-02, 1.68225e-02, -3.00403e-03 }, // 108/128 - { -3.42477e-03, 2.09516e-02, -8.52933e-02, 9.43001e-01, 1.64831e-01, -5.33522e-02, 1.60193e-02, -2.86289e-03 }, // 109/128 - { -3.26730e-03, 2.00132e-02, -8.17385e-02, 9.47477e-01, 1.55480e-01, -5.05770e-02, 1.52095e-02, -2.72032e-03 }, // 110/128 - { -3.10689e-03, 1.90545e-02, -7.80792e-02, 9.51795e-01, 1.46192e-01, -4.77900e-02, 1.43934e-02, -2.57640e-03 }, // 111/128 - { -2.94361e-03, 1.80759e-02, -7.43154e-02, 9.55956e-01, 1.36968e-01, -4.49929e-02, 1.35716e-02, -2.43121e-03 }, // 112/128 - { -2.77751e-03, 1.70776e-02, -7.04471e-02, 9.59958e-01, 1.27812e-01, -4.21869e-02, 1.27445e-02, -2.28483e-03 }, // 113/128 - { -2.60868e-03, 1.60599e-02, -6.64743e-02, 9.63798e-01, 1.18725e-01, -3.93735e-02, 1.19125e-02, -2.13733e-03 }, // 114/128 - { -2.43718e-03, 1.50233e-02, -6.23972e-02, 9.67477e-01, 1.09710e-01, -3.65541e-02, 1.10760e-02, -1.98880e-03 }, // 115/128 - { -2.26307e-03, 1.39681e-02, -5.82159e-02, 9.70992e-01, 1.00769e-01, -3.37303e-02, 1.02356e-02, -1.83931e-03 }, // 116/128 - { -2.08645e-03, 1.28947e-02, -5.39305e-02, 9.74342e-01, 9.19033e-02, -3.09033e-02, 9.39154e-03, -1.68894e-03 }, // 117/128 - { -1.90738e-03, 1.18034e-02, -4.95412e-02, 9.77526e-01, 8.31162e-02, -2.80746e-02, 8.54441e-03, -1.53777e-03 }, // 118/128 - { -1.72594e-03, 1.06946e-02, -4.50483e-02, 9.80543e-01, 7.44095e-02, -2.52457e-02, 7.69462e-03, -1.38589e-03 }, // 119/128 - { -1.54221e-03, 9.56876e-03, -4.04519e-02, 9.83392e-01, 6.57852e-02, -2.24178e-02, 6.84261e-03, -1.23337e-03 }, // 120/128 - { -1.35627e-03, 8.42626e-03, -3.57525e-02, 9.86071e-01, 5.72454e-02, -1.95925e-02, 5.98883e-03, -1.08030e-03 }, // 121/128 - { -1.16820e-03, 7.26755e-03, -3.09503e-02, 9.88580e-01, 4.87921e-02, -1.67710e-02, 5.13372e-03, -9.26747e-04 }, // 122/128 - { -9.78093e-04, 6.09305e-03, -2.60456e-02, 9.90917e-01, 4.04274e-02, -1.39548e-02, 4.27773e-03, -7.72802e-04 }, // 123/128 - { -7.86031e-04, 4.90322e-03, -2.10389e-02, 9.93082e-01, 3.21531e-02, -1.11453e-02, 3.42130e-03, -6.18544e-04 }, // 124/128 - { -5.92100e-04, 3.69852e-03, -1.59305e-02, 9.95074e-01, 2.39714e-02, -8.34364e-03, 2.56486e-03, -4.64053e-04 }, // 125/128 - { -3.96391e-04, 2.47942e-03, -1.07209e-02, 9.96891e-01, 1.58840e-02, -5.55134e-03, 1.70888e-03, -3.09412e-04 }, // 126/128 - { -1.98993e-04, 1.24642e-03, -5.41054e-03, 9.98534e-01, 7.89295e-03, -2.76968e-03, 8.53777e-04, -1.54700e-04 }, // 127/128 - { 0.00000e+00, 0.00000e+00, 0.00000e+00, 1.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00 }, // 128/128 -}; - diff --git a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc deleted file mode 100644 index 0d7b878da5..0000000000 --- a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.cc +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <cppunit/TestAssert.h> -#include <qa_ccomplex_dotprod_x86.h> -#include <ccomplex_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - -/// Macro for primitive value comparisons -#define assertcomplexEqual(expected0,expected1,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected0, actual[0], delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected1, actual[1], delta); - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 - -#define ERR_DELTA (1e-6) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32767); -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -void -ref_ccomplex_dotprod (const float *input, - const float *taps, unsigned n_2_ccomplex_blocks, - float *result) -{ - float sum0[2] = {0,0}; - float sum1[2] = {0,0}; - - do { - - sum0[0] += input[0] * taps[0] - input[1] * taps[1]; - sum0[1] += input[0] * taps[1] + input[1] * taps[0]; - sum1[0] += input[2] * taps[2] - input[3] * taps[3]; - sum1[1] += input[2] * taps[3] + input[3] * taps[2]; - - input += 4; - taps += 4; - - } while (--n_2_ccomplex_blocks != 0); - - - result[0] = sum0[0] + sum1[0]; - result[1] = sum0[1] + sum1[1]; -} - -void -qa_ccomplex_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_ccomplex_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_ccomplex_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_floats (input, MAX_BLKS * FLOATS_PER_BLK); -} - -// -// t1 -// - -void -qa_ccomplex_dotprod_x86::t1_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - float result[2]; - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.0, 0.0, result, ERR_DELTA); - - // vary each input - - zb (); - input[0] = 1.0; taps[0] = 1.0; taps[1] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - //cerr << result[0] << " " << result[1] << "\n"; - assertcomplexEqual (1.0, -1.0, result, ERR_DELTA); - - zb (); - input[1] = 2.0; taps[0] = 1.0; taps[1] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, 2.0, result, ERR_DELTA); - - zb (); - input[2] = 3.0; taps[2] = 1.0; taps[3] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[3] = 4.0; taps[2] = 1.0; taps[3] = -1.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, 4.0, result, ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1.0; taps[0] = 0.5; taps[1] = -0.5; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.5, -0.5, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 2.0; taps[1] = -2.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 3.0; taps[1] = -3.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 4.0; taps[1] = -4.0; - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); -} - -// -// t2 -// -void -qa_ccomplex_dotprod_x86::t2_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - float result[2]; - - zb (); - input[0] = 1.0; input[1] = 3.0; taps[0] = 5.0; taps[1] = -2.0; - - //1*5-3*-2 =11, 1*-2+3*5=13 - - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (11.0, 13.0, result, ERR_DELTA); - - //7*5-13*-5 =100, 7*-5+13*5=30 - - input[2] = 7.0; input[3] = 13.0; taps[2] = 5.0; taps[3] = -5.0; - - ccomplex_dotprod (input, taps, 1, result); - assertcomplexEqual (111.0, 43.0, result, ERR_DELTA); - - input[4] = 19; input[5] = -19; taps[4] = 23.0; taps[5] = -23.0; - - //19*23--19*-23 =0, 19*-23+-19*23=-874 - - ccomplex_dotprod (input, taps, 2, result); - assertcomplexEqual (111.0, -831.0, result, ERR_DELTA); - -} - -// -// t3 -// -void -qa_ccomplex_dotprod_x86::t3_base (ccomplex_dotprod_t ccomplex_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_floats (input, MAX_BLKS * FLOATS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref[2]; - ref_ccomplex_dotprod (input, taps, MAX_BLKS, ref); - float calc[2]; - ccomplex_dotprod (input, taps, MAX_BLKS, calc); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[0], - calc[0], - fabs (ref[0]) * 1e-4); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[1], - calc[1], - fabs (ref[1]) * 1e-4); - } -} - -void -qa_ccomplex_dotprod_x86::t1_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t2_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t3_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_3dnowext); -} - -void -qa_ccomplex_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_3dnow); -} - -void -qa_ccomplex_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (ccomplex_dotprod_sse); -} - -void -qa_ccomplex_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (ccomplex_dotprod_sse); -} - -void -qa_ccomplex_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (ccomplex_dotprod_sse); -} - diff --git a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h deleted file mode 100644 index d24561c72b..0000000000 --- a/gnuradio-core/src/lib/filter/qa_ccomplex_dotprod_x86.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_CCOMPLEX_DOTPROD_X86_H_ -#define _QA_CCOMPLEX_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_ccomplex_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_ccomplex_dotprod_x86); - CPPUNIT_TEST (t1_3dnowext); - CPPUNIT_TEST (t2_3dnowext); - CPPUNIT_TEST (t3_3dnowext); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnowext (); - void t2_3dnowext (); - void t3_3dnowext (); - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef void (*ccomplex_dotprod_t)(const float *input, - const float *taps, - unsigned n_2_ccomplex_blocks, - float *result); - - void t1_base (ccomplex_dotprod_t); - void t2_base (ccomplex_dotprod_t); - void t3_base (ccomplex_dotprod_t); - - void zb (); - - float *taps; // 16-byte aligned - float *input; // 16-byte aligned -}; - - -#endif /* _QA_CCOMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc deleted file mode 100644 index a21b95f633..0000000000 --- a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.cc +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <cppunit/TestAssert.h> -#include <qa_complex_dotprod_x86.h> -#include <complex_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - -/// Macro for primitive value comparisons -#define assertcomplexEqual(expected0,expected1,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected0, actual[0], delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected1, actual[1], delta); - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 -#define SHORTS_PER_BLK 2 - -#define ERR_DELTA (1e-6) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32767); -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -static void -random_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (short) rint (uniform () * 32767); -} - -static void -zero_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0; -} - -void -ref_complex_dotprod (const short *input, - const float *taps, unsigned n_2_complex_blocks, - float *result) -{ - float sum0[2] = {0,0}; - float sum1[2] = {0,0}; - - do { - - sum0[0] += input[0] * taps[0]; - sum0[1] += input[0] * taps[1]; - sum1[0] += input[1] * taps[2]; - sum1[1] += input[1] * taps[3]; - - input += 2; - taps += 4; - - } while (--n_2_complex_blocks != 0); - - - result[0] = sum0[0] + sum1[0]; - result[1] = sum0[1] + sum1[1]; -} - -void -qa_complex_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (short *) calloc16Align (MAX_BLKS, - sizeof (short) * SHORTS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_complex_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_complex_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_shorts (input, MAX_BLKS * SHORTS_PER_BLK); -} - -// -// t1 -// - -void -qa_complex_dotprod_x86::t1_base (complex_dotprod_t complex_dotprod) -{ - float result[2]; - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.0, 0.0, result, ERR_DELTA); - - // vary each input - - zb (); - input[0] = 1; taps[0] = 1.0; taps[1] = -1.0; - complex_dotprod (input, taps, 1, result); - //cerr << result[0] << " " << result[1] << "\n"; - assertcomplexEqual (1.0, -1.0, result, ERR_DELTA); - - zb (); - input[1] = 2; taps[2] = 1.0; taps[3] = -1.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[2] = 3; taps[4] = 1.0; taps[5] = -1.0; - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[3] = 4; taps[6] = 1.0; taps[7] = -1.0; - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1; taps[0] = 0.5; taps[1] = -0.5; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (0.5, -0.5, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 2.0; taps[1] = -2.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (2.0, -2.0, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 3.0; taps[1] = -3.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (3.0, -3.0, result, ERR_DELTA); - - zb (); - input[0] = 1; taps[0] = 4.0; taps[1] = -4.0; - complex_dotprod (input, taps, 1, result); - assertcomplexEqual (4.0, -4.0, result, ERR_DELTA); -} - -// -// t2 -// -void -qa_complex_dotprod_x86::t2_base (complex_dotprod_t complex_dotprod) -{ - float result[2]; - - zb (); - input[0] = 1; taps[0] = 2.0; taps[1] = -2.0; - input[1] = 3; taps[2] = 5.0; taps[3] = -5.0; - input[2] = 7; taps[4] = 11.0; taps[5] = -11.0; - input[3] = 13; taps[6] = 17.0; taps[7] = -17.0; - - complex_dotprod (input, taps, 2, result); - assertcomplexEqual (315.0, -315.0, result, ERR_DELTA); - - input[4] = 19; taps[8] = 23.0; taps[9] = -23.0; - complex_dotprod (input, taps, 3, result); - assertcomplexEqual (752.0, -752.0, result, ERR_DELTA); - -} - -// -// t3 -// -void -qa_complex_dotprod_x86::t3_base (complex_dotprod_t complex_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_shorts (input, MAX_BLKS * SHORTS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref[2]; - ref_complex_dotprod (input, taps, MAX_BLKS, ref); - float calc[2]; - complex_dotprod (input, taps, MAX_BLKS, calc); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[0], - calc[0], - fabs (ref[0]) * 1e-4); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref[1], - calc[1], - fabs (ref[1]) * 1e-4); - } -} - -void -qa_complex_dotprod_x86::t1_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t1_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t2_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t2_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t3_3dnowext () -{ - if (!gr_cpu::has_3dnowext ()){ - cerr << "No 3DNow!Ext support; not tested\n"; - } - else - t3_base (complex_dotprod_3dnowext); -} - -void -qa_complex_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (complex_dotprod_3dnow); -} - -void -qa_complex_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (complex_dotprod_sse); -} - -void -qa_complex_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (complex_dotprod_sse); -} - -void -qa_complex_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (complex_dotprod_sse); -} - diff --git a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h deleted file mode 100644 index 9f9b460399..0000000000 --- a/gnuradio-core/src/lib/filter/qa_complex_dotprod_x86.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_COMPLEX_DOTPROD_X86_H_ -#define _QA_COMPLEX_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_complex_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_complex_dotprod_x86); - CPPUNIT_TEST (t1_3dnowext); - CPPUNIT_TEST (t2_3dnowext); - CPPUNIT_TEST (t3_3dnowext); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnowext (); - void t2_3dnowext (); - void t3_3dnowext (); - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef void (*complex_dotprod_t)(const short *input, - const float *taps, - unsigned n_2_complex_blocks, - float *result); - - void t1_base (complex_dotprod_t); - void t2_base (complex_dotprod_t); - void t3_base (complex_dotprod_t); - - void zb (); - - float *taps; // 16-byte aligned - short *input; // 16-byte aligned -}; - - -#endif /* _QA_COMPLEX_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_dotprod.h b/gnuradio-core/src/lib/filter/qa_dotprod.h deleted file mode 100644 index bd5ba8f3ae..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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 _QA_DOTPROD_H_ -#define _QA_DOTPROD_H_ - -#include <cppunit/TestSuite.h> - -CppUnit::TestSuite *qa_dotprod_suite (); - -#endif // _QA_DOTPROD_H_ - diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc b/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc deleted file mode 100644 index 1e1ded7ea1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_armv7_a.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2009 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. - */ -#include "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc b/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc deleted file mode 100644 index 2c49d1d28f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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. - */ -#include "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc b/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc deleted file mode 100644 index 2c49d1d28f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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. - */ -#include "qa_dotprod.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - // empty test suite - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc deleted file mode 100644 index ec5625f10c..0000000000 --- a/gnuradio-core/src/lib/filter/qa_dotprod_x86.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 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. - */ -#include "qa_dotprod.h" -#include "qa_float_dotprod_x86.h" -#include "qa_complex_dotprod_x86.h" -#include "qa_ccomplex_dotprod_x86.h" - -CppUnit::TestSuite * -qa_dotprod_suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod"); - - s->addTest (qa_float_dotprod_x86::suite ()); - s->addTest (qa_complex_dotprod_x86::suite ()); - s->addTest (qa_ccomplex_dotprod_x86::suite ()); - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_filter.cc b/gnuradio-core/src/lib/filter/qa_filter.cc deleted file mode 100644 index 6296350845..0000000000 --- a/gnuradio-core/src/lib/filter/qa_filter.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2002,2007 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. - */ - -/* - * This class gathers together all the test cases for the gr - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#include <qa_filter.h> -#include <qa_gr_fir_ccf.h> -#include <qa_gr_fir_fff.h> -#include <qa_gr_fir_ccc.h> -#include <qa_gr_fir_fcc.h> -#include <qa_gr_fir_scc.h> -#include <qa_gr_firdes.h> -#include <qa_dotprod.h> -#include <qa_gri_mmse_fir_interpolator.h> -#include <qa_gri_mmse_fir_interpolator_cc.h> -#include <qa_gr_rotator.h> -#include <qa_gri_fir_filter_with_buffer_ccf.h> -#include <qa_gri_fir_filter_with_buffer_ccc.h> -#include <qa_gri_fir_filter_with_buffer_fcc.h> -#include <qa_gri_fir_filter_with_buffer_fff.h> -#include <qa_gri_fir_filter_with_buffer_fsf.h> -#include <qa_gri_fir_filter_with_buffer_scc.h> - -CppUnit::TestSuite * -qa_filter::suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("filter"); - - s->addTest (qa_dotprod_suite ()); - s->addTest (qa_gr_fir_fff::suite ()); - s->addTest (qa_gr_fir_ccc::suite ()); - s->addTest (qa_gr_fir_fcc::suite ()); - s->addTest (qa_gr_fir_scc::suite ()); - s->addTest (qa_gr_fir_ccf::suite ()); - s->addTest (qa_gri_mmse_fir_interpolator::suite ()); - s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ()); - s->addTest (qa_gr_rotator::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_ccf::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_ccc::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fcc::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fff::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_fsf::suite ()); - s->addTest (qa_gri_fir_filter_with_buffer_scc::suite ()); - - return s; -} diff --git a/gnuradio-core/src/lib/filter/qa_filter.h b/gnuradio-core/src/lib/filter/qa_filter.h deleted file mode 100644 index 740d05ce40..0000000000 --- a/gnuradio-core/src/lib/filter/qa_filter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_FILTER_H_ -#define _QA_FILTER_H_ - -#include <gruel/attributes.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the gr directory - -class __GR_ATTR_EXPORT qa_filter { - public: - //! return suite of tests for all of gr directory - static CppUnit::TestSuite *suite (); -}; - - -#endif /* _QA_FILTER_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc b/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc deleted file mode 100644 index f8752d0716..0000000000 --- a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.cc +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <cppunit/TestAssert.h> -#include <qa_float_dotprod_x86.h> -#include <float_dotprod_x86.h> -#include <string.h> -#include <iostream> -#include <malloc16.h> -#include <sse_debug.h> -#include <cmath> -#include <gr_cpu.h> -#include <random.h> - -using std::cerr; - - -#define MAX_BLKS 10 -#define FLOATS_PER_BLK 4 - -#define ERR_DELTA (1e-6) - - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = random () - RANDOM_MAX/2; -} - -static void -zero_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = 0.0; -} - -float -ref_float_dotprod (const float *input, - const float *taps, unsigned n_4_float_blocks) -{ - float sum0 = 0; - float sum1 = 0; - float sum2 = 0; - float sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_float_blocks != 0); - - - return sum0 + sum1 + sum2 + sum3; -} - -void -qa_float_dotprod_x86::setUp () -{ - taps = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - input = (float *) calloc16Align (MAX_BLKS, - sizeof (float) * FLOATS_PER_BLK); - - if (taps == 0 || input == 0) - abort (); -} - -void -qa_float_dotprod_x86::tearDown () -{ - free16Align (taps); - free16Align (input); - taps = 0; - input = 0; -} - - -void -qa_float_dotprod_x86::zb () // "zero both" -{ - zero_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - zero_floats (input, MAX_BLKS * FLOATS_PER_BLK); -} - -// -// t1 -// - -void -qa_float_dotprod_x86::t1_base (float_dotprod_t float_dotprod) -{ - - // cerr << "Testing dump_xmm_regs\n"; - // dump_xmm_regs (); - - // test basic cases, 1 block - - zb (); - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, float_dotprod (input, taps, 1), ERR_DELTA); - - // vary each input - - zb (); - input[0] = 0.5; taps[0] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.5, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[1] = 2.0; taps[1] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (2.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[2] = 3.0; taps[2] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[3] = 4.0; taps[3] = 1.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, float_dotprod (input, taps, 1), ERR_DELTA); - - // vary each tap - - zb (); - input[0] = 1.0; taps[0] = 0.5; - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.5, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 2.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (2.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 3.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, float_dotprod (input, taps, 1), ERR_DELTA); - - zb (); - input[0] = 1.0; taps[0] = 4.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, float_dotprod (input, taps, 1), ERR_DELTA); -} - -// -// t2 -// -void -qa_float_dotprod_x86::t2_base (float_dotprod_t float_dotprod) -{ - zb (); - input[0] = 1.0; taps[0] = 2.0; - input[1] = 3.0; taps[1] = 5.0; - input[2] = 7.0; taps[2] = 11.0; - input[3] = 13.0; taps[3] = 17.0; - - CPPUNIT_ASSERT_DOUBLES_EQUAL (315.0, float_dotprod (input, taps, 1), ERR_DELTA); - - input[4] = 19.0; taps[4] = 23.0; - CPPUNIT_ASSERT_DOUBLES_EQUAL (752.0, float_dotprod (input, taps, 2), ERR_DELTA); - -} - -// -// t3 -// -void -qa_float_dotprod_x86::t3_base (float_dotprod_t float_dotprod) -{ - srandom (0); // we want reproducibility - - for (unsigned int i = 0; i < 10; i++){ - random_floats (input, MAX_BLKS * FLOATS_PER_BLK); - random_floats (taps, MAX_BLKS * FLOATS_PER_BLK); - - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - float ref = ref_float_dotprod (input, taps, MAX_BLKS); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref, - float_dotprod (input, taps, MAX_BLKS), - fabs (ref) * 1e-4); - } -} - -void -qa_float_dotprod_x86::t1_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t1_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t2_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t2_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t3_3dnow () -{ - if (!gr_cpu::has_3dnow ()){ - cerr << "No 3DNow! support; not tested\n"; - } - else - t3_base (float_dotprod_3dnow); -} - -void -qa_float_dotprod_x86::t1_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t1_base (float_dotprod_sse); -} - -void -qa_float_dotprod_x86::t2_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t2_base (float_dotprod_sse); -} - -void -qa_float_dotprod_x86::t3_sse () -{ - if (!gr_cpu::has_sse ()){ - cerr << "No SSE support; not tested\n"; - } - else - t3_base (float_dotprod_sse); -} diff --git a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h b/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h deleted file mode 100644 index 38d6104fab..0000000000 --- a/gnuradio-core/src/lib/filter/qa_float_dotprod_x86.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_FLOAT_DOTPROD_X86_H_ -#define _QA_FLOAT_DOTPROD_X86_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_float_dotprod_x86 : public CppUnit::TestCase { - public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_float_dotprod_x86); - CPPUNIT_TEST (t1_3dnow); - CPPUNIT_TEST (t2_3dnow); - CPPUNIT_TEST (t3_3dnow); - CPPUNIT_TEST (t1_sse); - CPPUNIT_TEST (t2_sse); - CPPUNIT_TEST (t3_sse); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1_3dnow (); - void t2_3dnow (); - void t3_3dnow (); - void t1_sse (); - void t2_sse (); - void t3_sse (); - - - typedef float (*float_dotprod_t)(const float *input, - const float *taps, - unsigned n_4_float_blocks); - - void t1_base (float_dotprod_t); - void t2_base (float_dotprod_t); - void t3_base (float_dotprod_t); - - - void zb (); - - float *taps; // 16-byte aligned - float *input; // 16-byte aligned - -}; - - -#endif /* _QA_FLOAT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc deleted file mode 100644 index 7474b76e25..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_ccc.h> -#include <gr_fir_ccc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_ccc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Our SIMD ccc kernel requires that the complex input be 64-bit (8-byte) aligned. - // i_type input[INPUT_LEN]; - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_ccc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } - free16Align(input); -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_ccc_info> info; - gr_fir_util::get_gr_fir_ccc_info (&info); // get all known ccc implementations - - for (std::vector<gr_fir_ccc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_ccc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.h b/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.h deleted file mode 100644 index 0535e66528..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GR_FIR_CCC_H_ -#define _QA_GR_FIR_CCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_ccc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_ccc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - - -#endif /* _QA_GR_FIR_CCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc deleted file mode 100644 index 84cb924aea..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef float tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_ccf* (*fir_maker_t)(const std::vector<tap_type> &taps); - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Our SIMD ccc kernel requires that the complex input be 64-bit (8-byte) aligned. - //i_type input[INPUT_LEN]; - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_ccf *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } - free16Align(input); -} - - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_ccf_info> info; - gr_fir_util::get_gr_fir_ccf_info (&info); // get all known ccf implementations - - for (std::vector<gr_fir_ccf_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - - -void -qa_gr_fir_ccf::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h b/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h deleted file mode 100644 index bda79cc2fa..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_ccf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GR_FIR_CCF_H_ -#define _QA_GR_FIR_CCF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_ccf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_ccf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); - // void t2 (); - // void t3 (); - -}; - - -#endif /* _QA_GR_FIR_CCF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc deleted file mode 100644 index 4c77a5e5c0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef float i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_fcc.h> -#include <gr_fir_fcc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <string.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_fcc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_fcc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_fcc_info> info; - gr_fir_util::get_gr_fir_fcc_info (&info); // get all known fcc implementations - - for (std::vector<gr_fir_fcc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_fcc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h b/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h deleted file mode 100644 index 23706fd9c1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fcc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GR_FIR_FCC_H_ -#define _QA_GR_FIR_FCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_fcc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_fcc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); -}; - - -#endif /* _QA_GR_FIR_FCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc deleted file mode 100644 index 80ed674658..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <qa_gr_fir_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <string.h> - -using std::vector; - -typedef float i_type; -typedef float o_type; -typedef float tap_type; -typedef float acc_type; - -#define ERR_DELTA (1e-6) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_fff* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -// ---------------------------------------------------------------- - -const static i_type input_1[] = { - 234, -4, 23, -56, 45, 98, -23, -7 -}; - -const static tap_type taps_1a[] = { - -3 -}; - -const static o_type expected_1a[] = { - -702, 12, -69, 168, -135, -294, 69, 21 -}; - -const static tap_type taps_1b[] = { - -4, 5 -}; - -const static o_type expected_1b[] = { - 1186, -112, 339, -460, -167, 582, -87 -}; - -// ---------------------------------------------------------------- - -static void -test_known_io (fir_maker_t maker) -{ - vector<tap_type> t1a (&taps_1a[0], &taps_1a[NELEM (taps_1a)]); - vector<tap_type> t1b (&taps_1b[0], &taps_1b[NELEM (taps_1b)]); - - gr_fir_fff *f1 = maker (t1a); // create filter - CPPUNIT_ASSERT_EQUAL ((unsigned) 1, f1->ntaps ()); // check ntaps - - // check filter output - int n = NELEM (input_1) - f1->ntaps () + 1; - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1a[i], f1->filter (&input_1[i]), ERR_DELTA); - - f1->set_taps (t1b); // set new taps - CPPUNIT_ASSERT_EQUAL ((unsigned) 2, f1->ntaps ()); // check ntaps - - // check filter output - n = NELEM (input_1) - f1->ntaps () + 1; - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1b[i], f1->filter (&input_1[i]), ERR_DELTA); - - // test filterN interface - - o_type output[NELEM (expected_1b)]; - memset (output, 0, sizeof (output)); - - f1->filterN (output, input_1, n); - for (int i = 0; i < n; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_1b[i], output[i], ERR_DELTA); - - delete f1; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = rint (uniform () * 32768); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += input[i] * taps[ntaps - i - 1]; - - return sum; -} - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 32; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_fff *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_output[o], actual_output[o], - fabs (expected_output[o]) * 9e-3); - } - - delete f1; - } - } -} - - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_fff_info> info; - gr_fir_util::get_gr_fir_fff_info (&info); // get all known fff implementations - - for (std::vector<gr_fir_fff_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_fff::t1 () -{ - for_each (test_known_io); -} - -void -qa_gr_fir_fff::t2 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h b/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h deleted file mode 100644 index c896728960..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_fff.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GR_FIR_FFF_H_ -#define _QA_GR_FIR_FFF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_fff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_fff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t1 (); - void t2 (); - -}; - - -#endif /* _QA_GR_FIR_FFF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc b/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc deleted file mode 100644 index 3f4a7be2c4..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.cc +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -/* - * FIXME. This code is virtually identical to qa_gr_fir_?CC.cc - * Kludge up some kind of macro to handle the minor differences. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gr_types.h> - -typedef short i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - - -#include <qa_gr_fir_scc.h> -#include <gr_fir_scc.h> -#include <gr_fir_util.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <gr_types.h> -#include <cppunit/TestAssert.h> -#include <random.h> - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -// -// typedef for something logically "pointer to constructor". -// there may be a better way, please let me know... -// -typedef gr_fir_scc* (*fir_maker_t)(const std::vector<tap_type> &taps); - - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_input (i_type *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (i_type) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) - sum += (float) input[i] * taps[ntaps - i - 1]; - - return sum; -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// - -static void -test_random_io (fir_maker_t maker) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - i_type input[INPUT_LEN]; - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - - srandom (0); // we want reproducibility - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_input (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - for (int o = 0; o < ol; o++){ - expected_output[o] = ref_dotprod (&input[o], taps, n); - } - - // build filter - - vector<tap_type> f1_taps (&taps[0], &taps[n]); - gr_fir_scc *f1 = maker (f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < ol; o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], - actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - - delete f1; - } - } -} - -static void -for_each (void (*f)(fir_maker_t)) -{ - std::vector<gr_fir_scc_info> info; - gr_fir_util::get_gr_fir_scc_info (&info); // get all known scc implementations - - for (std::vector<gr_fir_scc_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - std::cerr << " [" << p->name << "]"; - f (p->create); - } - - std::cerr << std::endl; -} - -void -qa_gr_fir_scc::t1 () -{ - for_each (test_random_io); -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h b/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h deleted file mode 100644 index 4b5ffdae3c..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_fir_scc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GR_FIR_SCC_H_ -#define _QA_GR_FIR_SCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_fir_scc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_fir_scc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - - -#endif /* _QA_GR_FIR_SCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gr_rotator.cc b/gnuradio-core/src/lib/filter/qa_gr_rotator.cc deleted file mode 100644 index b2885a12d4..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_rotator.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_gr_rotator.h> -#include <gr_rotator.h> -#include <stdio.h> -#include <cmath> -#include <gr_expj.h> - - -// error vector magnitude -__GR_ATTR_UNUSED static float -error_vector_mag(gr_complex a, gr_complex b) -{ - return abs(a-b); -} - -void -qa_gr_rotator::t1 () -{ - static const unsigned int N = 100000; - - gr_rotator r; - - double phase_incr = 2*M_PI / 1003; - double phase = 0; - - // Old code: We increment then return the rotated value, thus we need to start one tick back - // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); - - r.set_phase(gr_complex(1,0)); - r.set_phase_incr(gr_expj(phase_incr)); - - for (unsigned i = 0; i < N; i++){ - gr_complex expected = gr_expj(phase); - gr_complex actual = r.rotate(gr_complex(1, 0)); - -#if 0 - float evm = error_vector_mag(expected, actual); - printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", - i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); -#endif - - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); - - phase += phase_incr; - if (phase >= 2*M_PI) - phase -= 2*M_PI; - } -} diff --git a/gnuradio-core/src/lib/filter/qa_gr_rotator.h b/gnuradio-core/src/lib/filter/qa_gr_rotator.h deleted file mode 100644 index 739b23f8c3..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gr_rotator.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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 _QA_GR_ROTATOR_H_ -#define _QA_GR_ROTATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_rotator : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_rotator); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - -#endif /* _QA_GR_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc deleted file mode 100644 index cfdbc53eb3..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_ccc.h> -#include <gri_fir_filter_with_buffer_ccc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define MAX_DATA (32767) -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * MAX_DATA); - float im = rint (uniform () * MAX_DATA); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_ccc::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_ccc::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_ccc::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_ccc::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_ccc *f1 = new gri_fir_filter_with_buffer_ccc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - sqrt((float)n)*0.25*MAX_DATA*MAX_DATA * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h deleted file mode 100644 index c1f2df10c0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_ccc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc deleted file mode 100644 index 9a5be03518..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_ccf.h> -#include <gri_fir_filter_with_buffer_ccf.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef gr_complex i_type; -typedef gr_complex o_type; -typedef float tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_ccf::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_ccf::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_ccf::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_ccf::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_complex (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_ccf *f1 = new gri_fir_filter_with_buffer_ccf(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h deleted file mode 100644 index 686bc85411..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_ccf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc deleted file mode 100644 index 583697165f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fcc.h> -#include <gri_fir_filter_with_buffer_fcc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_fcc::t1() -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fcc::t2() -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fcc::t3() -{ - test_decimate(5); -} - - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fcc::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fcc *f1 = new gri_fir_filter_with_buffer_fcc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h deleted file mode 100644 index 64eed25d3a..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fcc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fcc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc deleted file mode 100644 index 208ae01dbb..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fff.h> -#include <gri_fir_filter_with_buffer_fff.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef float o_type; -typedef float tap_type; -typedef float acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 32767); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - return sum; -} - -void -qa_gri_fir_filter_with_buffer_fff::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fff::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fff::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fff::test_decimate(unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fff *f1 = new gri_fir_filter_with_buffer_fff(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_output[o], actual_output[o], - fabsf (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h deleted file mode 100644 index d219ec72d9..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FFF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc deleted file mode 100644 index e2b6fb04f0..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_fsf.h> -#include <gri_fir_filter_with_buffer_fsf.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef float i_type; -typedef short o_type; -typedef float tap_type; -typedef float acc_type; - -using std::vector; - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_floats (float *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (float) rint (uniform () * 128); -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += input[i] * taps[i]; - } - return (o_type)sum; -} - -void -qa_gri_fir_filter_with_buffer_fsf::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_fsf::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_fsf::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_fsf::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_floats (input, INPUT_LEN); - random_floats (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_fsf *f1 = new gri_fir_filter_with_buffer_fsf(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_EQUAL(expected_output[o], actual_output[o]); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h deleted file mode 100644 index 70030a0721..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_fsf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fsf); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FSF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc deleted file mode 100644 index 15f8b1f95a..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 <gr_types.h> -#include <qa_gri_fir_filter_with_buffer_scc.h> -#include <gri_fir_filter_with_buffer_scc.h> -#include <string.h> -#include <iostream> -#include <cmath> -#include <cppunit/TestAssert.h> -#include <random.h> -#include <malloc16.h> -#include <string.h> - -typedef short i_type; -typedef gr_complex o_type; -typedef gr_complex tap_type; -typedef gr_complex acc_type; - -using std::vector; - -#define ERR_DELTA (1e-5) - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - -static float -uniform () -{ - return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) -} - -static void -random_shorts (short *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++) - buf[i] = (short) rint (uniform () * 16384); -} - -static void -random_complex (gr_complex *buf, unsigned n) -{ - for (unsigned i = 0; i < n; i++){ - float re = rint (uniform () * 32767); - float im = rint (uniform () * 32767); - buf[i] = gr_complex (re, im); - } -} - -static o_type -ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) -{ - acc_type sum = 0; - for (int i = 0; i < ntaps; i++) { - sum += (float)input[i] * taps[i]; - } - - return sum; -} - -void -qa_gri_fir_filter_with_buffer_scc::t1 () -{ - test_decimate(1); -} - -void -qa_gri_fir_filter_with_buffer_scc::t2 () -{ - test_decimate(2); -} - -void -qa_gri_fir_filter_with_buffer_scc::t3 () -{ - test_decimate(5); -} - -// -// Test for ntaps in [0,9], and input lengths in [0,17]. -// This ensures that we are building the shifted taps correctly, -// and exercises all corner cases on input alignment and length. -// -void -qa_gri_fir_filter_with_buffer_scc::test_decimate (unsigned int decimate) -{ - const int MAX_TAPS = 9; - const int OUTPUT_LEN = 17; - const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; - - // Mem aligned buffer not really necessary, but why not? - i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); - i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); - o_type expected_output[OUTPUT_LEN]; - o_type actual_output[OUTPUT_LEN]; - tap_type taps[MAX_TAPS]; - - srandom (0); // we want reproducibility - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - - for (int n = 0; n <= MAX_TAPS; n++){ - for (int ol = 0; ol <= OUTPUT_LEN; ol++){ - - // cerr << "@@@ n:ol " << n << ":" << ol << endl; - - // build random test case - random_shorts (input, INPUT_LEN); - random_complex (taps, MAX_TAPS); - - // compute expected output values - memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < (int)(ol/decimate); o++){ - // use an actual delay line for this test - for(int dd = 0; dd < (int)decimate; dd++) { - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[decimate*o+dd]; - } - expected_output[o] = ref_dotprod (dline, taps, n); - } - - // build filter - vector<tap_type> f1_taps(&taps[0], &taps[n]); - gri_fir_filter_with_buffer_scc *f1 = new gri_fir_filter_with_buffer_scc(f1_taps); - - // zero the output, then do the filtering - memset (actual_output, 0, sizeof (actual_output)); - f1->filterNdec (actual_output, input, ol/decimate, decimate); - - // check results - // - // we use a sloppy error margin because on the x86 architecture, - // our reference implementation is using 80 bit floating point - // arithmetic, while the SSE version is using 32 bit float point - // arithmetic. - - for (int o = 0; o < (int)(ol/decimate); o++){ - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], - abs (expected_output[o]) * ERR_DELTA); - } - delete f1; - } - } - free16Align(input); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h deleted file mode 100644 index f80056189f..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ -#define _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_fir_filter_with_buffer_scc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_scc); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_decimate(unsigned int decimate); - - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_SCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc deleted file mode 100644 index 7dca65b9a1..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <cppunit/TestAssert.h> -#include <qa_gri_mmse_fir_interpolator.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdio.h> -#include <cmath> - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -static float -test_fcn (double index) -{ - return (2 * sin (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * sin (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - - -void -qa_gri_mmse_fir_interpolator::t1 () -{ - static const unsigned N = 100; - float input[N + 10]; - - for (unsigned i = 0; i < NELEM(input); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - float expected = test_fcn ((i + 3) + imu * inv_nsteps); - float actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h deleted file mode 100644 index 3f4dec7c29..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ -#define _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_mmse_fir_interpolator : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gri_mmse_fir_interpolator); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - -}; - - -#endif /* _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc deleted file mode 100644 index 1f70d7f42d..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 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 <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_gri_mmse_fir_interpolator_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdio.h> -#include <cmath> -#include <stdexcept> -#include <unistd.h> - -#define NELEM(x) (sizeof (x) / sizeof (x[0])) - - -static float -test_fcn_sin(double index) -{ - return (2 * sin (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * sin (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - -static float -test_fcn_cos(double index) -{ - return (2 * cos (index * 0.25 * 2 * M_PI + 0.125 * M_PI) - + 3 * cos (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); -} - -static gr_complex -test_fcn(double index) -{ - return gr_complex(test_fcn_cos(index), test_fcn_sin(index)); -} - - -void -qa_gri_mmse_fir_interpolator_cc::t1() -{ - static const unsigned N = 100; - __GR_ATTR_ALIGNED(8) gr_complex input[N + 10]; - - for (unsigned i = 0; i < NELEM(input); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator_cc intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - gr_complex expected = test_fcn ((i + 3) + imu * inv_nsteps); - gr_complex actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_COMPLEXES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - - -/* - * Force bad alignment and confirm that it raises an exception - */ -void -qa_gri_mmse_fir_interpolator_cc::t2_body() -{ - static const unsigned N = 100; - float float_input[2*(N+10) + 1]; - gr_complex *input; - - // We require that gr_complex be aligned on an 8-byte boundary. - // Ensure that we ARE NOT ;) - - if (((intptr_t) float_input & 0x7) == 0) - input = reinterpret_cast<gr_complex *>(&float_input[1]); - else - input = reinterpret_cast<gr_complex *>(&float_input[0]); - - - for (unsigned i = 0; i < (N+10); i++) - input[i] = test_fcn ((double) i); - - gri_mmse_fir_interpolator_cc intr; - float inv_nsteps = 1.0 / intr.nsteps (); - - for (unsigned i = 0; i < N; i++){ - for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ - gr_complex expected = test_fcn ((i + 3) + imu * inv_nsteps); - gr_complex actual = intr.interpolate (&input[i], imu * inv_nsteps); - - CPPUNIT_ASSERT_COMPLEXES_EQUAL (expected, actual, 0.004); - // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); - } - } -} - -void -qa_gri_mmse_fir_interpolator_cc::t2() -{ - CPPUNIT_ASSERT_THROW(t2_body(), std::invalid_argument); -} diff --git a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h b/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h deleted file mode 100644 index 6be3d97433..0000000000 --- a/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator_cc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2007 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 _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ -#define _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gri_mmse_fir_interpolator_cc : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_gri_mmse_fir_interpolator_cc); - CPPUNIT_TEST(t1); - // CPPUNIT_TEST(t2); - CPPUNIT_TEST_SUITE_END(); - - private: - void t1(); - void t2(); - void t2_body(); - -}; - -#endif /* _QA_GRI_MMSE_FIR_INTERPOLATOR_CC_H_ */ diff --git a/gnuradio-core/src/lib/filter/short_dotprod_generic.c b/gnuradio-core/src/lib/filter/short_dotprod_generic.c deleted file mode 100644 index 49a9c0483c..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_generic.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2002 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. - */ - -#include "short_dotprod_generic.h" - - -int -short_dotprod_generic (const short *input, - const short *taps, unsigned n_4_short_blocks) -{ - int sum0 = 0; - int sum1 = 0; - int sum2 = 0; - int sum3 = 0; - - do { - - sum0 += input[0] * taps[0]; - sum1 += input[1] * taps[1]; - sum2 += input[2] * taps[2]; - sum3 += input[3] * taps[3]; - - input += 4; - taps += 4; - - } while (--n_4_short_blocks != 0); - - - return (sum0 + sum1 + sum2 + sum3); -} diff --git a/gnuradio-core/src/lib/filter/short_dotprod_generic.h b/gnuradio-core/src/lib/filter/short_dotprod_generic.h deleted file mode 100644 index e7d977a007..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_generic.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _SHORT_DOTPROD_GENERIC_H_ -#define _SHORT_DOTPROD_GENERIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int -short_dotprod_generic (const short *input, - const short *taps, unsigned n_4_short_blocks); - - -#ifdef __cplusplus -} -#endif - - - -#endif /* _SHORT_DOTPROD_GENERIC_H_ */ diff --git a/gnuradio-core/src/lib/filter/short_dotprod_mmx.S b/gnuradio-core/src/lib/filter/short_dotprod_mmx.S deleted file mode 100644 index 48f634a18d..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_mmx.S +++ /dev/null @@ -1,117 +0,0 @@ -# -# Copyright 2002 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. -# - -# SIMD MMX dot product -# Equivalent to the following C code: -# long dotprod(signed short *a,signed short *b,int cnt) -# { -# long sum = 0; -# cnt *= 4; -# while(cnt--) -# sum += *a++ + *b++; -# return sum; -# } -# a and b should also be 64-bit aligned, or speed will suffer greatly -# Copyright 1999, Phil Karn KA9Q -# May be used under the terms of the GNU public license - -#include "assembly.h" - - - .file "short_dotprod_mmx.S" - .version "01.01" -.text - .p2align 3 -.globl GLOB_SYMB(short_dotprod_mmx) - DEF_FUNC_HEAD(short_dotprod_mmx) -GLOB_SYMB(short_dotprod_mmx): - pushl %ebp - movl %esp,%ebp - pushl %esi - pushl %edi - pushl %ecx - pushl %ebx - movl 8(%ebp),%esi # a - movl 12(%ebp),%edi # b - movl 16(%ebp),%ecx # cnt - pxor %mm0,%mm0 # clear running sum (in two 32-bit halves) - -# MMX dot product loop unrolled 4 times, crunching 16 terms per loop - .p2align 4 -.Loop1mmx: subl $4,%ecx - jl .Loop1Done - - movq (%esi),%mm1 # mm1 = a[3],a[2],a[1],a[0] - pmaddwd (%edi),%mm1 # mm1 = b[3]*a[3]+b[2]*a[2],b[1]*a[1]+b[0]*a[0] - paddd %mm1,%mm0 - - movq 8(%esi),%mm1 - pmaddwd 8(%edi),%mm1 - paddd %mm1,%mm0 - - movq 16(%esi),%mm1 - pmaddwd 16(%edi),%mm1 - paddd %mm1,%mm0 - - movq 24(%esi),%mm1 - addl $32,%esi - pmaddwd 24(%edi),%mm1 - addl $32,%edi - paddd %mm1,%mm0 - - jmp .Loop1mmx -.Loop1Done: - - addl $4,%ecx - -# MMX dot product loop, not unrolled, crunching 4 terms per loop -# This could be redone as Duff's Device on the unrolled loop above -.Loop2: subl $1,%ecx - jl .Loop2Done - - movq (%esi),%mm1 - addl $8,%esi - pmaddwd (%edi),%mm1 - addl $8,%edi - paddd %mm1,%mm0 - jmp .Loop2 -.Loop2Done: - - movd %mm0,%ebx # right-hand word to ebx - punpckhdq %mm0,%mm0 # left-hand word to right side of %mm0 - movd %mm0,%eax - addl %ebx,%eax # running sum now in %eax - emms # done with MMX - - popl %ebx - popl %ecx - popl %edi - popl %esi - movl %ebp,%esp - popl %ebp - ret - -FUNC_TAIL(short_dotprod_mmx) - .ident "Hand coded x86 MMX assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S b/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S deleted file mode 100644 index c8c9da30a6..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_mmx64.S +++ /dev/null @@ -1,105 +0,0 @@ -# -# Copyright 2002,2005 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. -# - -# SIMD MMX dot product -# Equivalent to the following C code: -# long dotprod(signed short *a,signed short *b,int cnt) -# { -# long sum = 0; -# cnt *= 4; -# while(cnt--) -# sum += *a++ + *b++; -# return sum; -# } -# a and b should also be 64-bit aligned, or speed will suffer greatly -# Copyright 1999, Phil Karn KA9Q -# May be used under the terms of the GNU public license - -#include "assembly.h" - - - .file "short_dotprod_mmx64.S" - .version "01.01" -.text - .p2align 3 -.globl GLOB_SYMB(short_dotprod_mmx) - DEF_FUNC_HEAD(short_dotprod_mmx) -GLOB_SYMB(short_dotprod_mmx): - - # a: rdi, b: rsi, cnt: rdx - - pxor %mm0,%mm0 # clear running sum (in two 32-bit halves) - -# MMX dot product loop unrolled 4 times, crunching 16 terms per loop - .p2align 4 -.Loop1mmx: sub $4,%rdx - jl .Loop1Done - - movq (%rdi),%mm1 # mm1 = a[3],a[2],a[1],a[0] - pmaddwd (%rsi),%mm1 # mm1 = b[3]*a[3]+b[2]*a[2],b[1]*a[1]+b[0]*a[0] - paddd %mm1,%mm0 - - movq 8(%rdi),%mm1 - pmaddwd 8(%rsi),%mm1 - paddd %mm1,%mm0 - - movq 16(%rdi),%mm1 - pmaddwd 16(%rsi),%mm1 - paddd %mm1,%mm0 - - movq 24(%rdi),%mm1 - add $32,%rdi - pmaddwd 24(%rsi),%mm1 - add $32,%rsi - paddd %mm1,%mm0 - - jmp .Loop1mmx -.Loop1Done: - - add $4,%rdx - -# MMX dot product loop, not unrolled, crunching 4 terms per loop -# This could be redone as Duff's Device on the unrolled loop above -.Loop2: sub $1,%rdx - jl .Loop2Done - - movq (%rdi),%mm1 - add $8,%rdi - pmaddwd (%rsi),%mm1 - add $8,%rsi - paddd %mm1,%mm0 - jmp .Loop2 -.Loop2Done: - - movd %mm0,%edx # right-hand word to edx - punpckhdq %mm0,%mm0 # left-hand word to right side of %mm0 - movd %mm0,%eax - addl %edx,%eax # running sum now in %eax - emms # done with MMX - - retq - -FUNC_TAIL(short_dotprod_mmx) - .ident "Hand coded x86_64 MMX assembly" - -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif diff --git a/gnuradio-core/src/lib/filter/short_dotprod_x86.h b/gnuradio-core/src/lib/filter/short_dotprod_x86.h deleted file mode 100644 index 13d5ae2a3c..0000000000 --- a/gnuradio-core/src/lib/filter/short_dotprod_x86.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _SHORT_DOTPROD_X86_H_ -#define _SHORT_DOTPROD_X86_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int -short_dotprod_mmx (const short *input, - const short *taps, unsigned n_4_short_blocks); - -int -short_dotprod_sse2 (const short *input, - const short *taps, unsigned n_4_short_blocks); - -#ifdef __cplusplus -} -#endif - - - -#endif /* _SHORT_DOTPROD_X86_H_ */ diff --git a/gnuradio-core/src/lib/filter/sse_debug.c b/gnuradio-core/src/lib/filter/sse_debug.c deleted file mode 100644 index 870cc0543e..0000000000 --- a/gnuradio-core/src/lib/filter/sse_debug.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ -#include <stdio.h> -#include <sse_debug.h> -#include <string.h> - -void -format_xmm_regs (FILE *f, struct xmm_regs *r) -{ - int i; - - for (i = 0; i < 8; i++){ - union xmm_register *x = &r->xmm[i]; - fprintf (f, "xmm%d: %08lx %08lx %08lx %08lx", i, - x->ul[0], x->ul[1], x->ul[2], x->ul[3]); - fprintf (f, " %12g %12g %12g %12g\n", - x->f[0], x->f[1], x->f[2], x->f[3]); - } -} - - -void -get_xmm_regs (struct xmm_regs *x) -{ - asm ("movups %%xmm0,0x00(%0); \n" - "movups %%xmm1,0x10(%0); \n" - "movups %%xmm2,0x20(%0); \n" - "movups %%xmm3,0x30(%0); \n" - "movups %%xmm4,0x40(%0); \n" - "movups %%xmm5,0x50(%0); \n" - "movups %%xmm6,0x60(%0); \n" - "movups %%xmm7,0x70(%0); \n" : : "r" (x)); -} - -void -dump_xmm_regs (void) -{ - struct xmm_regs r; - - get_xmm_regs (&r); - format_xmm_regs (stderr, &r); -} - diff --git a/gnuradio-core/src/lib/filter/sse_debug.h b/gnuradio-core/src/lib/filter/sse_debug.h deleted file mode 100644 index b19b4e646c..0000000000 --- a/gnuradio-core/src/lib/filter/sse_debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 _SSE_DEBUG_H_ -#define _SSE_DEBUG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - union xmm_register { - unsigned long ul[4]; - float f[4]; - }; - - struct xmm_regs { - union xmm_register xmm[8]; - }; - - // callable from asm, dumps all xmm regs - void dump_xmm_regs (void); - - void get_xmm_regs (struct xmm_regs *x); - -#ifdef __cplusplus -} -#endif - -#endif // _SSE_DEBUG_H_ diff --git a/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc b/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc deleted file mode 100644 index 2c415863b5..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_armv7_a.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008,2009 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 <gr_fir_sysconfig_armv7_a.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_armv7_a (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_generic.cc b/gnuradio-core/src/lib/filter/sysconfig_generic.cc deleted file mode 100644 index 88508f62b1..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_generic.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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. - */ - -#include <gr_fir_sysconfig_generic.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_generic (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc b/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc deleted file mode 100644 index 911beae2a7..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_powerpc.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2008 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 <gr_fir_sysconfig_powerpc.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_powerpc (); - return singleton; -} diff --git a/gnuradio-core/src/lib/filter/sysconfig_x86.cc b/gnuradio-core/src/lib/filter/sysconfig_x86.cc deleted file mode 100644 index 582df0ab72..0000000000 --- a/gnuradio-core/src/lib/filter/sysconfig_x86.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <gr_fir_sysconfig_x86.h> - -gr_fir_sysconfig * -gr_fir_sysconfig_singleton () -{ - static gr_fir_sysconfig *singleton = 0; - - if (singleton) - return singleton; - - singleton = new gr_fir_sysconfig_x86 (); - return singleton; -} diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 4c44ba8812..32329a3653 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -71,7 +71,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc @@ -115,7 +114,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_count_bits.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_fft_vcc_fftw.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_vco.h @@ -202,8 +200,6 @@ set(gr_core_general_triple_threats gr_fake_channel_coder_pp gr_feedforward_agc_cc gr_feval - gr_fft_vcc - gr_fft_vfc gr_firdes gr_float_to_char gr_float_to_complex diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index b4ddee29ce..0c735b8881 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -38,8 +38,6 @@ #include <gr_vector_to_stream.h> #include <gr_keep_one_in_n.h> #include <gr_keep_m_in_n.h> -#include <gr_fft_vcc.h> -#include <gr_fft_vfc.h> #include <gr_float_to_int.h> #include <gr_float_to_short.h> #include <gr_float_to_char.h> @@ -144,8 +142,6 @@ %include "gr_vector_to_stream.i" %include "gr_keep_one_in_n.i" %include "gr_keep_m_in_n.i" -%include "gr_fft_vcc.i" -%include "gr_fft_vfc.i" %include "gr_float_to_int.i" %include "gr_float_to_short.i" %include "gr_float_to_char.i" diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc index e1ae73efb6..d3dcce73af 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_raw.cc @@ -55,7 +55,7 @@ void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val) gruel::scoped_lock l(d_mutex); gr_tag_t tag; - tag.srcid = pmt::pmt_intern(d_name); + tag.srcid = pmt::pmt_intern(name()); tag.key = key; tag.value = val; tag.offset = offset; diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.cc b/gnuradio-core/src/lib/general/gr_fft_vcc.cc deleted file mode 100644 index addcddb64a..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2012 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 <gr_fft_vcc.h> // abstract class -#include <gr_fft_vcc_fftw.h> // concrete class -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <string.h> - -gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) -{ - return gr_make_fft_vcc_fftw(fft_size, forward, - window, shift, nthreads); -} - -gr_fft_vcc::gr_fft_vcc (const std::string &name, - int fft_size, bool forward, const std::vector<float> &window, - bool shift) - : gr_sync_block (name, - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)), - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), - d_fft_size(fft_size), d_forward(forward), d_shift(shift) -{ - set_window(window); -} - -gr_fft_vcc::~gr_fft_vcc () -{ -} - -bool -gr_fft_vcc::set_window(const std::vector<float> &window) -{ - if(window.size()==0 || window.size()==d_fft_size) { - d_window=window; - return true; - } - else - return false; -} - -void -gr_fft_vcc::set_nthreads(int n) -{ - throw std::runtime_error("gr_fft_vcc::set_nthreads not implemented."); -} - -int -gr_fft_vcc::nthreads() const -{ - throw std::runtime_error("gr_fft_vcc::nthreads not implemented."); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h deleted file mode 100644 index db5690d41d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2012 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_GR_FFT_VCC_H -#define INCLUDED_GR_FFT_VCC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fft_vcc; -typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr; - -GR_CORE_API gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -/*! - * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk - * - * Abstract base class - */ -class GR_CORE_API gr_fft_vcc : public gr_sync_block -{ -protected: - friend GR_CORE_API gr_fft_vcc_sptr - gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift); - - unsigned int d_fft_size; - std::vector<float> d_window; - bool d_forward; - bool d_shift; - - gr_fft_vcc (const std::string &name, int fft_size, bool forward, - const std::vector<float> &window, bool shift); - - public: - ~gr_fft_vcc (); - - virtual void set_nthreads(int n); - virtual int nthreads() const; - - bool set_window(const std::vector<float> &window); -}; - -#endif /* INCLUDED_GR_FFT_VCC_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i deleted file mode 100644 index f9caae7d8d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2010,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr, fft_vcc) - -gr_fft_vcc_sptr -gr_make_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -class gr_fft_vcc : public gr_sync_block -{ - protected: - gr_fft_vcc (int fft_size, bool forward, - const std::vector<float> &window, - bool shift); - - public: - bool set_window(const std::vector<float> &window); - void set_nthreads(int n); - int nthreads() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc deleted file mode 100644 index 891173bcd8..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008,2010 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 <gr_fft_vcc_fftw.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <string.h> - -gr_fft_vcc_sptr -gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_vcc_fftw - (fft_size, forward, window, - shift, nthreads)); -} - -gr_fft_vcc_fftw::gr_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads) - : gr_fft_vcc("fft_vcc_fftw", fft_size, forward, window, shift) -{ - d_fft = new gri_fft_complex (d_fft_size, forward, nthreads); -} - -gr_fft_vcc_fftw::~gr_fft_vcc_fftw () -{ - delete d_fft; -} - -void -gr_fft_vcc_fftw::set_nthreads(int n) -{ - d_fft->set_nthreads(n); -} - -int -gr_fft_vcc_fftw::nthreads() const -{ - return d_fft->nthreads(); -} - -int -gr_fft_vcc_fftw::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - unsigned int input_data_size = input_signature()->sizeof_stream_item (0); - unsigned int output_data_size = output_signature()->sizeof_stream_item (0); - - int count = 0; - - while (count++ < noutput_items){ - - // copy input into optimally aligned buffer - - if (d_window.size()){ - gr_complex *dst = d_fft->get_inbuf(); - if(!d_forward && d_shift){ - unsigned int offset = (!d_forward && d_shift)?(d_fft_size/2):0; - int fft_m_offset = d_fft_size - offset; - for (unsigned int i = 0; i < offset; i++) // apply window - dst[i+fft_m_offset] = in[i] * d_window[i]; - for (unsigned int i = offset; i < d_fft_size; i++) // apply window - dst[i-offset] = in[i] * d_window[i]; - } else { - for (unsigned int i = 0; i < d_fft_size; i++) // apply window - dst[i] = in[i] * d_window[i]; - } - } - else { - if(!d_forward && d_shift) { // apply an ifft shift on the data - gr_complex *dst = d_fft->get_inbuf(); - unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half length of complex array - memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len)); - memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len); - } - else { - memcpy (d_fft->get_inbuf(), in, input_data_size); - } - } - - // compute the fft - d_fft->execute (); - - // copy result to our output - if(d_forward && d_shift) { // apply a fft shift on the data - unsigned int len = (unsigned int)(ceil(d_fft_size/2.0)); - memcpy(&out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(d_fft_size - len)); - memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len); - } - else { - memcpy (out, d_fft->get_outbuf (), output_data_size); - } - - in += d_fft_size; - out += d_fft_size; - } - - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h deleted file mode 100644 index 967ceaefb6..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2008 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_GR_FFT_VCC_FFTW_H -#define INCLUDED_GR_FFT_VCC_FFTW_H - -#include <gr_core_api.h> -#include <gr_fft_vcc.h> - -class gri_fft_complex; - -GR_CORE_API gr_fft_vcc_sptr -gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); - -/*! - * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk - * - * Concrete class that uses FFTW. - */ -class GR_CORE_API gr_fft_vcc_fftw : public gr_fft_vcc -{ - friend GR_CORE_API gr_fft_vcc_sptr - gr_make_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads); - - gri_fft_complex *d_fft; - - gr_fft_vcc_fftw (int fft_size, bool forward, - const std::vector<float> &window, - bool shift, int nthreads=1); - - public: - ~gr_fft_vcc_fftw (); - - void set_nthreads(int n); - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_FFT_VCC_FFTW_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc deleted file mode 100644 index 2396055b93..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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 <gr_fft_vfc.h> -#include <gr_io_signature.h> -#include <gri_fft.h> -#include <math.h> -#include <stdexcept> -#include <string.h> -#include <cstdio> - - -// FIXME after this is working, change to use native real to complex fft. -// It should run twice as fast. - - - - -gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads) -{ - return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, - window, nthreads)); -} - -gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads) - : gr_sync_block ("fft_vfc", - gr_make_io_signature (1, 1, fft_size * sizeof (float)), - gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), - d_fft_size(fft_size), d_window() -{ - if (!forward){ - fprintf (stderr, "fft_vfc: forward must == true\n"); - throw std::invalid_argument ("fft_vfc: forward must == true"); - } - - d_fft = new gri_fft_complex (d_fft_size, forward, nthreads); - - set_window(window); -} - -gr_fft_vfc::~gr_fft_vfc () -{ - delete d_fft; -} - -void -gr_fft_vfc::set_nthreads(int n) -{ - d_fft->set_nthreads(n); -} - -int -gr_fft_vfc::nthreads() const -{ - return d_fft->nthreads(); -} - -int -gr_fft_vfc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - unsigned int output_data_size = output_signature()->sizeof_stream_item (0); - - int count = 0; - - while (count++ < noutput_items){ - - // copy input into optimally aligned buffer - - if (d_window.size()){ - gr_complex *dst = d_fft->get_inbuf(); - for (unsigned int i = 0; i < d_fft_size; i++) // apply window - dst[i] = in[i] * d_window[i]; - } - else { - gr_complex *dst = d_fft->get_inbuf(); - for (unsigned int i = 0; i < d_fft_size; i++) // float to complex conversion - dst[i] = in[i]; - } - - // compute the fft - d_fft->execute (); - - // cpoy result to our output - memcpy (out, d_fft->get_outbuf (), output_data_size); - - in += d_fft_size; - out += d_fft_size; - } - - return noutput_items; -} - -bool -gr_fft_vfc::set_window(const std::vector<float> &window) -{ - if(window.size()==0 || window.size()==d_fft_size) { - d_window=window; - return true; - } - else - return false; -} diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h deleted file mode 100644 index 35b95313d3..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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_GR_FFT_VFC_H -#define INCLUDED_GR_FFT_VFC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gri_fft_complex; - -class gr_fft_vfc; -typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr; - -GR_CORE_API gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - -/*! - * \brief Compute forward FFT. float vector in / complex vector out. - * \ingroup dft_blk - */ - -class GR_CORE_API gr_fft_vfc : public gr_sync_block -{ - friend GR_CORE_API gr_fft_vfc_sptr - gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads); - - unsigned int d_fft_size; - std::vector<float> d_window; - gri_fft_complex *d_fft; - - gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - - public: - ~gr_fft_vfc (); - - void set_nthreads(int n); - int nthreads() const; - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - bool set_window(const std::vector<float> &window); -}; - - -#endif /* INCLUDED_GR_FFT_VFC_H */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.i b/gnuradio-core/src/lib/general/gr_fft_vfc.i deleted file mode 100644 index d387ae155d..0000000000 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr, fft_vfc) - -gr_fft_vfc_sptr -gr_make_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1) -throw(std::exception); - -class gr_fft_vfc : public gr_sync_block -{ - protected: - gr_fft_vfc (int fft_size, bool forward, - const std::vector<float> &window, - int nthreads=1); - - public: - bool set_window(const std::vector<float> &window); - void set_nthreads(int n); - int nthreads() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.cc b/gnuradio-core/src/lib/general/gr_simple_correlator.cc index 9c2ebef15a..b9209e74f0 100644 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.cc +++ b/gnuradio-core/src/lib/general/gr_simple_correlator.cc @@ -158,11 +158,13 @@ gr_simple_correlator::general_work (int noutput_items, int decision; int hamming_dist; +#ifdef DEBUG_SIMPLE_CORRELATOR struct debug_data { float raw_data; float sampled; float enter_locked; } debug_data; +#endif while (n < nin){ @@ -212,7 +214,9 @@ gr_simple_correlator::general_work (int noutput_items, else if (d_state == ST_UNDER_THRESHOLD && hamming_dist > THRESHOLD){ // no longer seeing good PN code, compute center of goodness enter_locked (); +#ifdef DEBUG_SIMPLE_CORRELATOR debug_data.enter_locked = 1.0; +#endif } break; diff --git a/gnuradio-core/src/lib/general/gri_control_loop.h b/gnuradio-core/src/lib/general/gri_control_loop.h index df260d2cf1..f10bc76be2 100644 --- a/gnuradio-core/src/lib/general/gri_control_loop.h +++ b/gnuradio-core/src/lib/general/gri_control_loop.h @@ -34,6 +34,7 @@ class GR_CORE_API gri_control_loop float d_alpha, d_beta; public: + gri_control_loop() {}; gri_control_loop(float loop_bw, float max_freq, float min_freq); virtual ~gri_control_loop(); diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t index 37963cdfee..20968afe22 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t @@ -44,7 +44,7 @@ // some sanity checks assert(offset < periodicity); assert(offset >= 0); - assert(periodicity > data.size()); + assert((size_t)periodicity > data.size()); } int diff --git a/gnuradio-core/src/lib/hier/CMakeLists.txt b/gnuradio-core/src/lib/hier/CMakeLists.txt deleted file mode 100644 index 192dd5939a..0000000000 --- a/gnuradio-core/src/lib/hier/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2010-2011 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.cc -) - -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -if(ENABLE_PYTHON) - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/hier.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" - ) -endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.cc b/gnuradio-core/src/lib/hier/gr_channel_model.cc deleted file mode 100644 index bb01972d29..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2009 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. - */ - -#include <gr_channel_model.h> -#include <gr_io_signature.h> -#include <gr_sig_source_f.h> -#include <iostream> - -// Shared pointer constructor -gr_channel_model_sptr -gr_make_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed) -{ - return gnuradio::get_initial_sptr(new gr_channel_model(noise_voltage, - frequency_offset, - epsilon, - taps, - noise_seed)); -} - -// Hierarchical block constructor -gr_channel_model::gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed) - : gr_hier_block2("gr_channel_model", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ - d_taps = taps; - while(d_taps.size() < 2) { - d_taps.push_back(0); - } - - d_timing_offset = gr_make_fractional_interpolator_cc(0, epsilon); - - d_multipath = gr_make_fir_filter_ccc(1, d_taps); - - d_noise_adder = gr_make_add_cc(); - d_noise = gr_make_noise_source_c(GR_GAUSSIAN, noise_voltage, noise_seed); - d_freq_offset = gr_make_sig_source_c(1, GR_SIN_WAVE, frequency_offset, 1.0, 0.0); - d_mixer_offset = gr_make_multiply_cc(); - - connect(self(), 0, d_timing_offset, 0); - connect(d_timing_offset, 0, d_multipath, 0); - connect(d_multipath, 0, d_mixer_offset, 0); - connect(d_freq_offset, 0, d_mixer_offset, 1); - connect(d_mixer_offset, 0, d_noise_adder, 1); - connect(d_noise, 0, d_noise_adder, 0); - connect(d_noise_adder, 0, self(), 0); -} - -void -gr_channel_model::set_noise_voltage(double noise_voltage) -{ - d_noise->set_amplitude(noise_voltage); -} - -void -gr_channel_model::set_frequency_offset(double frequency_offset) -{ - d_freq_offset->set_frequency(frequency_offset); -} - -void -gr_channel_model::set_taps(const std::vector<gr_complex> &taps) -{ - d_taps = taps; - while(d_taps.size() < 2) { - d_taps.push_back(0); - } - d_multipath->set_taps(d_taps); -} - -void -gr_channel_model::set_timing_offset(double epsilon) -{ - d_timing_offset->set_interp_ratio(epsilon); -} - - -double -gr_channel_model::noise_voltage() const -{ - return d_noise->amplitude(); -} - -double -gr_channel_model::frequency_offset() const -{ - return d_freq_offset->frequency(); -} - -std::vector<gr_complex> -gr_channel_model::taps() const -{ - return d_multipath->taps(); -} - -double -gr_channel_model::timing_offset() const -{ - return d_timing_offset->interp_ratio(); -} diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h deleted file mode 100644 index 3f289e320d..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2009 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. - */ - -#include <gr_core_api.h> -#include <gr_top_block.h> -#include <gr_fractional_interpolator_cc.h> -#include <gr_sig_source_c.h> -#include <gr_fir_filter_ccc.h> -#include <gr_add_cc.h> -#include <gr_noise_source_c.h> -#include <gr_multiply_cc.h> - -class gr_channel_model; -typedef boost::shared_ptr<gr_channel_model> gr_channel_model_sptr; - - -GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, - double frequency_offset=0.0, - double epsilon=1.0, - const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), - double noise_seed=3021); - -/*! - * \brief channel simulator - * \ingroup misc_blk - */ -class GR_CORE_API gr_channel_model : public gr_hier_block2 -{ - private: - gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - friend GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - gr_fractional_interpolator_cc_sptr d_timing_offset; - gr_sig_source_c_sptr d_freq_offset; - gr_fir_filter_ccc_sptr d_multipath; - gr_add_cc_sptr d_noise_adder; - gr_noise_source_c_sptr d_noise; - gr_multiply_cc_sptr d_mixer_offset; - - std::vector<gr_complex> d_taps; - - public: - void set_noise_voltage(double noise_voltage); - void set_frequency_offset(double frequency_offset); - void set_taps(const std::vector<gr_complex> &taps); - void set_timing_offset(double epsilon); - - double noise_voltage() const; - double frequency_offset() const; - std::vector<gr_complex> taps() const; - double timing_offset() const; -}; diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.i b/gnuradio-core/src/lib/hier/gr_channel_model.i deleted file mode 100644 index 24a9388e56..0000000000 --- a/gnuradio-core/src/lib/hier/gr_channel_model.i +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,channel_model) - -gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0, - double frequency_offset=0.0, - double epsilon=1.0, - const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1), - double noise_seed=3021); - -class gr_channel_model : public gr_hier_block2 -{ - private: - gr_channel_model(double noise_voltage, - double frequency_offset, - double epsilon, - const std::vector<gr_complex> &taps, - double noise_seed); - - public: - void set_noise_voltage(double noise_voltage); - void set_frequency_offset(double frequency_offset); - void set_taps(const std::vector<gr_complex> &taps); - void set_timing_offset(double epsilon); - - double noise_voltage() const; - double frequency_offset() const; - std::vector<gr_complex> taps() const; - double timing_offset() const; -}; diff --git a/gnuradio-core/src/lib/hier/hier.i b/gnuradio-core/src/lib/hier/hier.i deleted file mode 100644 index 82044415e1..0000000000 --- a/gnuradio-core/src/lib/hier/hier.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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 <gr_channel_model.h> -%} - -%include "gr_channel_model.i" - diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc index c0da23b4f7..c9c8407a07 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc @@ -156,7 +156,7 @@ gr_tagged_file_sink::work (int noutput_items, std::stringstream filename; filename.setf(std::ios::fixed, std::ios::floatfield); filename.precision(8); - filename << "file" << d_unique_id << "_" << d_n << "_" << d_timeval << ".dat"; + filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat"; d_n++; int fd; diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index 04d1e95e57..482a2beb1e 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -58,7 +58,7 @@ public: * allowed for any block in the flowgraph. This passes through to * the start function; see that function for more details. */ - void run(int max_noutput_items=100000); + void run(int max_noutput_items=100000000); /*! * Start the contained flowgraph. Creates one or more threads to @@ -71,7 +71,7 @@ public: * always be less than this, but this will cap it as a maximum. Use * this to adjust the maximum latency a flowgraph can exhibit. */ - void start(int max_noutput_items=100000); + void start(int max_noutput_items=100000000); /*! * Stop the running flowgraph. Notifies each thread created by the diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i index 6ae4c65a99..024582a301 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.i +++ b/gnuradio-core/src/lib/runtime/gr_top_block.i @@ -38,7 +38,7 @@ private: public: ~gr_top_block(); - void start(int max_noutput_items=100000) throw (std::runtime_error); + void start(int max_noutput_items=100000000) throw (std::runtime_error); void stop(); //void wait(); //void run() throw (std::runtime_error); diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h index f55c3f021b..c49bdabff6 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h @@ -42,7 +42,7 @@ public: ~gr_top_block_impl(); // Create and start scheduler threads - void start(int max_noutput_items=100000); + void start(int max_noutput_items=100000000); // Signal scheduler threads to stop void stop(); diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 5b740d916d..e5e4243ff9 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -45,7 +45,7 @@ set(GR_SWIG_LIBRARIES gnuradio-core) set(GR_SWIG_TARGET_DEPS general_generated gengen_generated filter_generated pmt_swig) -foreach(what runtime general gengen filter io hier) +foreach(what runtime general gengen io) SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i) SET(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../${what} ${CMAKE_CURRENT_BINARY_DIR}/../${what}) GR_SWIG_MAKE(gnuradio_core_${what} gnuradio_core_${what}.i) diff --git a/gnuradio-core/src/lib/swig/gnuradio_core.py b/gnuradio-core/src/lib/swig/gnuradio_core.py index 23de740778..1fd558a11b 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_core.py +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -23,6 +23,4 @@ from gnuradio_core_runtime import * from gnuradio_core_general import * from gnuradio_core_gengen import * -from gnuradio_core_filter import * from gnuradio_core_io import * -from gnuradio_core_hier import * diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_filter.i b/gnuradio-core/src/lib/swig/gnuradio_core_filter.i deleted file mode 100644 index e9a44e54b9..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_filter.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,2010 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "filter_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_filter -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "filter.i" diff --git a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i index 4016ae7727..6d1af6136d 100644 --- a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i +++ b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i @@ -48,3 +48,11 @@ BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), BASE_NAME = BASE_NAME.make; %} %enddef + +%define GR_SWIG_BLOCK_MAGIC_FACTORY(PKG, BASE_NAME, FACTORY) +%template(FACTORY ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## BASE_NAME>; +%pythoncode %{ +FACTORY ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id()) +FACTORY = BASE_NAME ## _make_ ## FACTORY; +%} +%enddef diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt index 61fcdda42d..b8ec6c88c4 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,17 +22,11 @@ include(GrPython) GR_PYTHON_INSTALL(FILES __init__.py am_demod.py - channel_model.py filterbank.py fm_demod.py fm_emph.py - logpwrfft.py nbfm_rx.py nbfm_tx.py - pfb_arb_resampler.py - pfb_channelizer.py - pfb_decimator.py - pfb_interpolator.py rational_resampler.py standard_squelch.py stream_to_vector_decimator.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py b/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py deleted file mode 100644 index e5cd471df5..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/channel_model.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr - -# This block is now a C++ hierarchical block, gr.channel_model -channel_model = gr.channel_model diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py deleted file mode 100644 index e83c327fc8..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, optfir - -class pfb_arb_resampler_ccf(gr.hier_block2): - ''' - Convenience wrapper for the polyphase filterbank arbitrary resampler. - - The block takes a single complex stream in and outputs a single complex - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, rate, taps=None, flt_size=32, atten=100): - gr.hier_block2.__init__(self, "pfb_arb_resampler_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._rate = rate - self._size = flt_size - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) - made = False - while not made: - try: - self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_arb_resampler_ccf(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - # Note -- set_taps not implemented in base class yet - def set_taps(self, taps): - self.pfb.set_taps(taps) - - def set_rate(self, rate): - self.pfb.set_rate(rate) - - -class pfb_arb_resampler_fff(gr.hier_block2): - ''' - Convenience wrapper for the polyphase filterbank arbitrary resampler. - - The block takes a single float stream in and outputs a single float - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, rate, taps=None, flt_size=32, atten=100): - gr.hier_block2.__init__(self, "pfb_arb_resampler_fff", - gr.io_signature(1, 1, gr.sizeof_float), # Input signature - gr.io_signature(1, 1, gr.sizeof_float)) # Output signature - - self._rate = rate - self._size = flt_size - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) - made = False - while not made: - try: - self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_arb_resampler_fff(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - # Note -- set_taps not implemented in base class yet - def set_taps(self, taps): - self.pfb.set_taps(taps) - - def set_rate(self, rate): - self.pfb.set_rate(rate) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py deleted file mode 100644 index 4bbe1bec6c..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009,2010 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. -# - -from gnuradio import gr, optfir - -class pfb_channelizer_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter channelizer (complex in, complex out, floating-point taps) - - This simplifies the interface by allowing a single input stream to connect to this block. - It will then output a stream for each channel. - ''' - def __init__(self, numchans, taps=None, oversample_rate=1, atten=100): - gr.hier_block2.__init__(self, "pfb_channelizer_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature - - self._nchans = numchans - self._oversample_rate = oversample_rate - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - made = False - while not made: - try: - self._taps = optfir.low_pass(1, self._nchans, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._nchans) - self.pfb = gr.pfb_channelizer_ccf(self._nchans, self._taps, - self._oversample_rate) - self.connect(self, self.s2ss) - - for i in xrange(self._nchans): - self.connect((self.s2ss,i), (self.pfb,i)) - self.connect((self.pfb,i), (self,i)) - - def set_channel_map(self, newmap): - self.pfb.set_channel_map(newmap) - - diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py deleted file mode 100644 index adcdfe9ba1..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, optfir - -class pfb_decimator_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter decimator (complex in, complex out, floating-point taps) - - This simplifies the interface by allowing a single input stream to connect to this block. - It will then output a stream that is the decimated output stream. - ''' - def __init__(self, decim, taps=None, channel=0, atten=100): - gr.hier_block2.__init__(self, "pfb_decimator_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._decim = decim - self._channel = channel - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.1 - made = False - while not made: - try: - self._taps = optfir.low_pass(1, self._decim, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._decim) - self.pfb = gr.pfb_decimator_ccf(self._decim, self._taps, self._channel) - - self.connect(self, self.s2ss) - - for i in xrange(self._decim): - self.connect((self.s2ss,i), (self.pfb,i)) - - self.connect(self.pfb, self) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py deleted file mode 100644 index 5492dfcac6..0000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 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. -# - -from gnuradio import gr, optfir - -class pfb_interpolator_ccf(gr.hier_block2): - ''' - Make a Polyphase Filter interpolator (complex in, complex out, floating-point taps) - - The block takes a single complex stream in and outputs a single complex - stream out. As such, it requires no extra glue to handle the input/output - streams. This block is provided to be consistent with the interface to the - other PFB block. - ''' - def __init__(self, interp, taps=None, atten=100): - gr.hier_block2.__init__(self, "pfb_interpolator_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._interp = interp - self._taps = taps - - if taps is not None: - self._taps = taps - else: - # Create a filter that covers the full bandwidth of the input signal - bw = 0.4 - tb = 0.2 - ripple = 0.99 - made = False - while not made: - try: - self._taps = optfir.low_pass(self._interp, self._interp, bw, bw+tb, ripple, atten) - made = True - except RuntimeError: - ripple += 0.01 - made = False - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) - - # Build in an exit strategy; if we've come this far, it ain't working. - if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - - self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps) - - self.connect(self, self.pfb) - self.connect(self.pfb, self) - - - - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py b/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py deleted file mode 100755 index 1757358676..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_dc_blocker.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 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. -# - -from gnuradio import gr, gr_unittest - -class test_dc_blocker(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - ''' Test impulse response - long form, cc ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.02072429656982422+0j), (-0.02081298828125+0j), - (0.979156494140625+0j), (-0.02081298828125+0j), - (-0.02072429656982422+0j)) - - src = gr.vector_source_c(src_data) - op = gr.dc_blocker_cc(32, True) - dst = gr.vector_sink_c() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around 2D-2 - result_data = dst.data()[60:65] - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - ''' Test impulse response - short form, cc ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.029296875+0j), (-0.0302734375+0j), - (0.96875+0j), (-0.0302734375+0j), - (-0.029296875+0j)) - - src = gr.vector_source_c(src_data) - op = gr.dc_blocker_cc(32, False) - dst = gr.vector_sink_c() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around D-1 - result_data = dst.data()[29:34] - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - - def test_003(self): - ''' Test impulse response - long form, ff ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.02072429656982422), (-0.02081298828125), - (0.979156494140625), (-0.02081298828125), - (-0.02072429656982422)) - - src = gr.vector_source_f(src_data) - op = gr.dc_blocker_ff(32, True) - dst = gr.vector_sink_f() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around 2D-2 - result_data = dst.data()[60:65] - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_004(self): - ''' Test impulse response - short form, ff ''' - src_data = [1,] + 100*[0,] - expected_result = ((-0.029296875), (-0.0302734375), - (0.96875), (-0.0302734375), - (-0.029296875)) - - src = gr.vector_source_f(src_data) - op = gr.dc_blocker_ff(32, False) - dst = gr.vector_sink_f() - - self.tb.connect (src, op, dst) - self.tb.run() - - # only test samples around D-1 - result_data = dst.data()[29:34] - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_dc_blocker, "test_dc_blocker.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py deleted file mode 100755 index 693d0e67c5..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008,2010 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -from gnuradio import gr, gr_unittest -import sys -import random - -primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53, - 59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131, - 137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223, - 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311) - - -class test_fft(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def assert_fft_ok2(self, expected_result, result_data): - expected_result = expected_result[:len(result_data)] - self.assertComplexTuplesAlmostEqual2 (expected_result, result_data, - abs_eps=1e-9, rel_eps=4e-4) - - def assert_fft_float_ok2(self, expected_result, result_data, abs_eps=1e-9, rel_eps=4e-4): - expected_result = expected_result[:len(result_data)] - self.assertFloatTuplesAlmostEqual2 (expected_result, result_data, - abs_eps, rel_eps) - - def test_001(self): - tb = gr.top_block() - fft_size = 32 - src_data = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - expected_result = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, True, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - self.assert_fft_ok2(expected_result, result_data) - - def test_002(self): - tb = gr.top_block() - fft_size = 32 - - tmp_data = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src_data = tuple([x/fft_size for x in tmp_data]) - - expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, False, [], False) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - self.assert_fft_ok2(expected_result, result_data) - - def test_003(self): - # Same test as above, only use 2 threads - - tb = gr.top_block() - fft_size = 32 - - tmp_data = ((4377+4516j), - (-1706.1268310546875+1638.4256591796875j), - (-915.2083740234375+660.69427490234375j), - (-660.370361328125+381.59600830078125j), - (-499.96044921875+238.41630554199219j), - (-462.26748657226562+152.88948059082031j), - (-377.98440551757812+77.5928955078125j), - (-346.85821533203125+47.152004241943359j), - (-295+20j), - (-286.33609008789062-22.257017135620117j), - (-271.52999877929688-33.081821441650391j), - (-224.6358642578125-67.019538879394531j), - (-244.24473571777344-91.524826049804688j), - (-203.09068298339844-108.54627227783203j), - (-198.45195007324219-115.90768432617188j), - (-182.97744750976562-128.12318420410156j), - (-167-180j), - (-130.33688354492188-173.83778381347656j), - (-141.19784545898438-190.28807067871094j), - (-111.09677124023438-214.48896789550781j), - (-70.039543151855469-242.41630554199219j), - (-68.960540771484375-228.30015563964844j), - (-53.049201965332031-291.47097778320312j), - (-28.695289611816406-317.64553833007812j), - (57-300j), - (45.301143646240234-335.69509887695312j), - (91.936195373535156-373.32437133789062j), - (172.09465026855469-439.275146484375j), - (242.24473571777344-504.47515869140625j), - (387.81732177734375-666.6788330078125j), - (689.48553466796875-918.2142333984375j), - (1646.539306640625-1694.1956787109375j)) - - src_data = tuple([x/fft_size for x in tmp_data]) - - expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - - nthreads = 2 - - src = gr.vector_source_c(src_data) - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size) - fft = gr.fft_vcc(fft_size, False, [], False, nthreads) - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() - tb.connect(src, s2v, fft, v2s, dst) - tb.run() - result_data = dst.data() - self.assert_fft_ok2(expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_fft, "test_fft.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py deleted file mode 100755 index c0aadc306f..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2005,2007,2010 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. -# - -from gnuradio import gr, gr_unittest -import sys -import random - -def make_random_complex_tuple(L): - result = [] - for x in range(L): - result.append(complex(random.uniform(-1000,1000), - random.uniform(-1000,1000))) - return tuple(result) - -def make_random_float_tuple(L): - result = [] - for x in range(L): - result.append(float(int(random.uniform(-1000,1000)))) - return tuple(result) - - -def reference_filter_ccc(dec, taps, input): - """ - compute result using conventional fir filter - """ - tb = gr.top_block() - #src = gr.vector_source_c(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_c(input) - op = gr.fir_filter_ccc(dec, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - return dst.data() - -def reference_filter_fff(dec, taps, input): - """ - compute result using conventional fir filter - """ - tb = gr.top_block() - #src = gr.vector_source_f(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_f(input) - op = gr.fir_filter_fff(dec, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - return dst.data() - - -def print_complex(x): - for i in x: - i = complex(i) - sys.stdout.write("(%6.3f,%6.3fj), " % (i.real, i.imag)) - sys.stdout.write('\n') - - -class test_fft_filter(gr_unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - def assert_fft_ok2(self, expected_result, result_data): - expected_result = expected_result[:len(result_data)] - self.assertComplexTuplesAlmostEqual2 (expected_result, result_data, - abs_eps=1e-9, rel_eps=4e-4) - - def assert_fft_float_ok2(self, expected_result, result_data, abs_eps=1e-9, rel_eps=4e-4): - expected_result = expected_result[:len(result_data)] - self.assertFloatTuplesAlmostEqual2 (expected_result, result_data, - abs_eps, rel_eps) - - #def test_ccc_000(self): - # self.assertRaises (RuntimeError, gr.fft_filter_ccc, 2, (1,)) - - def test_ccc_001(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (1,) - expected_result = tuple([complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_ccc_002(self): - # Test nthreads - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - nthreads = 2 - expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps, nthreads) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - def test_ccc_003(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_ccc_004(self): - random.seed(0) - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(1, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - del tb - - self.assert_fft_ok2(expected_result, result_data) - - def test_ccc_005(self): - random.seed(0) - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(dec, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(dec, taps) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - del tb - result_data = dst.data() - - self.assert_fft_ok2(expected_result, result_data) - - def test_ccc_006(self): - # Test decimating with nthreads=2 - random.seed(0) - nthreads = 2 - for i in xrange(25): - # sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_complex_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - expected_result = reference_filter_ccc(dec, taps, src_data) - - src = gr.vector_source_c(src_data) - op = gr.fft_filter_ccc(dec, taps, nthreads) - dst = gr.vector_sink_c() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - del tb - result_data = dst.data() - - self.assert_fft_ok2(expected_result, result_data) - - # ---------------------------------------------------------------- - # test _fff version - # ---------------------------------------------------------------- - - def test_fff_001(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (1,) - expected_result = tuple([float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_fff_002(self): - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - #print 'expected:', expected_result - #print 'results: ', result_data - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - def test_fff_003(self): - # Test 02 with nthreads - tb = gr.top_block() - src_data = (0,1,2,3,4,5,6,7) - taps = (2,) - nthreads = 2 - expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps, nthreads) - dst = gr.vector_sink_f() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5) - - def xtest_fff_004(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4096 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(1, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - #print "src_len =", src_len, " ntaps =", ntaps - try: - self.assert_fft_float_ok2(expected_result, result_data, abs_eps=1.0) - except: - expected = open('expected', 'w') - for x in expected_result: - expected.write(`x` + '\n') - actual = open('actual', 'w') - for x in result_data: - actual.write(`x` + '\n') - raise - - def xtest_fff_005(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 1000)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(1, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data, abs_eps=2.0) - - def xtest_fff_006(self): - random.seed(0) - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(dec, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(dec, taps) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data) - - def xtest_fff_007(self): - # test decimation with nthreads - random.seed(0) - nthreads = 2 - for i in xrange(25): - sys.stderr.write("\n>>> Loop = %d\n" % (i,)) - dec = i + 1 - src_len = 4*1024 - src_data = make_random_float_tuple(src_len) - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - expected_result = reference_filter_fff(dec, taps, src_data) - - src = gr.vector_source_f(src_data) - op = gr.fft_filter_fff(dec, taps, nthreads) - dst = gr.vector_sink_f() - tb = gr.top_block() - tb.connect(src, op, dst) - tb.run() - result_data = dst.data() - - self.assert_fft_float_ok2(expected_result, result_data) - - def test_fff_get0(self): - random.seed(0) - for i in xrange(25): - ntaps = int(random.uniform(2, 100)) - taps = make_random_float_tuple(ntaps) - - op = gr.fft_filter_fff(1, taps) - result_data = op.taps() - #print result_data - - self.assertEqual(taps, result_data) - - def test_ccc_get0(self): - random.seed(0) - for i in xrange(25): - ntaps = int(random.uniform(2, 100)) - taps = make_random_complex_tuple(ntaps) - - op = gr.fft_filter_ccc(1, taps) - result_data = op.taps() - #print result_data - - self.assertComplexTuplesAlmostEqual(taps, result_data, 4) - - -if __name__ == '__main__': - gr_unittest.run(test_fft_filter, "test_fft_filter.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py b/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py deleted file mode 100755 index 8d325fc3e6..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_filter_delay_fc (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001_filter_delay_one_input (self): - - # expected result - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - tb = self.tb - - sampling_freq = 100 - - ntaps = 51 - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - dst2 = gr.vector_sink_c () - - # calculate taps - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - tb.connect (src1, head) - tb.connect (head, hd) - tb.connect (hd,dst2) - - tb.run () - - # get output - result_data = dst2.data () - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - def test_002_filter_delay_two_inputs (self): - - # giving the same signal to both the inputs should fetch the same results - # as above - - # expected result - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - - tb = self.tb - - sampling_freq = 100 - ntaps = 51 - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - dst2 = gr.vector_sink_c () - - - # calculate taps - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - tb.connect (src1, head) - tb.connect (head, (hd,0)) - tb.connect (head, (hd,1)) - tb.connect (hd,dst2) - tb.run () - - # get output - result_data = dst2.data () - - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - - def test_003_filter_delay_two_inputs (self): - - # give two different inputs - - # expected result - expected_result = ( -0.0020331963896751404j, - -0.0016448829555884004j, - -0.0032375147566199303j, - -0.0014826074475422502j, - -0.0033034090884029865j, - -0.00051144487224519253j, - -0.0043686260469257832j, - -0.0010198024101555347j, - -0.0082517862319946289j, - -0.003456643782556057j, - -0.014193611219525337j, - -0.005875137634575367j, - -0.020293503999710083j, - -0.0067503536120057106j, - -0.026798896491527557j, - -0.0073488112539052963j, - -0.037041611969470978j, - -0.010557252913713455j, - -0.055669989436864853j, - -0.018332764506340027j, - -0.089904911816120148j, - -0.033361352980136871j, - -0.16902604699134827j, - -0.074318811297416687j, - -0.58429563045501709j, - (7.2191945754696007e-09 -0.35892376303672791j), - (0.58778399229049683 +0.63660913705825806j), - (0.95105588436126709 +0.87681591510772705j), - (0.95105588436126709 +0.98705857992172241j), - (0.5877838134765625 +0.55447429418563843j), - (5.8516356205018383e-09 +0.026006083935499191j), - (-0.5877840518951416 -0.60616838932037354j), - (-0.95105588436126709 -0.9311758279800415j), - (-0.95105588436126709 -0.96169203519821167j), - (-0.5877838134765625 -0.57292771339416504j), - (-8.7774534307527574e-09 -0.0073488391935825348j), - (0.58778399229049683 +0.59720659255981445j), - (0.95105588436126709 +0.94438445568084717j), - (0.95105588436126709 +0.95582199096679688j), - (0.5877838134765625 +0.58196049928665161j), - (1.4629089051254596e-08 +0.0026587247848510742j), - (-0.5877840518951416 -0.59129220247268677j), - (-0.95105588436126709 -0.94841635227203369j), - (-0.95105588436126709 -0.95215457677841187j), - (-0.5877838134765625 -0.58535969257354736j), - (-1.7554906861505515e-08 -0.00051158666610717773j), - (0.58778399229049683 +0.58867418766021729j), - (0.95105582475662231 +0.94965213537216187j), - (0.95105588436126709 +0.95050644874572754j), - (0.5877838134765625 +0.58619076013565063j), - (2.3406542482007353e-08 +1.1920928955078125e-07j), - (-0.5877840518951416 -0.58783555030822754j), - (-0.95105588436126709 -0.95113480091094971j), - (-0.95105588436126709 -0.95113474130630493j), - (-0.5877838134765625 -0.58783555030822754j), - (-2.6332360292258272e-08 -8.1956386566162109e-08j), - (0.58778399229049683 +0.58783555030822754j), - (0.95105582475662231 +0.95113474130630493j), - (0.95105588436126709 +0.95113474130630493j), - (0.5877838134765625 +0.58783560991287231j), - (3.218399768911695e-08 +1.1920928955078125e-07j)) - - tb = self.tb - - sampling_freq = 100 - ntaps = 51 - - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE,sampling_freq * 0.10, 1.0) - src2 = gr.sig_source_f (sampling_freq, gr.GR_COS_WAVE,sampling_freq * 0.10, 1.0) - - head1 = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - head2 = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - - taps = gr.firdes_hilbert (ntaps) - hd = gr.filter_delay_fc (taps) - - dst2 = gr.vector_sink_c () - - tb.connect (src1, head1) - tb.connect (src2, head2) - - tb.connect (head1, (hd,0)) - tb.connect (head2, (hd,1)) - tb.connect (hd, dst2) - - tb.run () - - # get output - result_data = dst2.data () - - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) - - -if __name__ == '__main__': - gr_unittest.run(test_filter_delay_fc, "test_filter_delay_fc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py b/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py deleted file mode 100755 index e19bb28f31..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_fractional_resampler (gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000_make(self): - op = gr.fractional_interpolator_ff(0.0, 1.0) - op2 = gr.fractional_interpolator_cc(0.0, 1.0) - -if __name__ == '__main__': - gr_unittest.run(test_fractional_resampler, "test_fractional_resampler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py b/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py deleted file mode 100755 index 77f1b5f897..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,2010 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. -# - -from gnuradio import gr, gr_unittest -from math import pi, cos - -class test_goertzel(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def make_tone_data(self, rate, freq): - return [cos(2*pi*x*freq/rate) for x in range(rate)] - - def transform(self, src_data, rate, freq): - src = gr.vector_source_f(src_data, False) - dft = gr.goertzel_fc(rate, rate, freq) - dst = gr.vector_sink_c() - self.tb.connect(src, dft, dst) - self.tb.run() - return dst.data() - - def test_001(self): # Measure single tone magnitude - rate = 8000 - freq = 100 - bin = freq - src_data = self.make_tone_data(rate, freq) - expected_result = 0.5 - actual_result = abs(self.transform(src_data, rate, bin)[0]) - self.assertAlmostEqual(expected_result, actual_result, places=4) - - def test_002(self): # Measure off frequency magnitude - rate = 8000 - freq = 100 - bin = freq/2 - src_data = self.make_tone_data(rate, freq) - expected_result = 0.0 - actual_result = abs(self.transform(src_data, rate, bin)[0]) - self.assertAlmostEqual(expected_result, actual_result, places=4) - -if __name__ == '__main__': - gr_unittest.run(test_goertzel, "test_goertzel.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py b/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py deleted file mode 100755 index 27d01092bb..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_hilbert (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_hilbert (self): - tb = self.tb - ntaps = 51 - sampling_freq = 100 - - expected_result = ( -1.4678005338941702e-11j, - -0.0011950774351134896j, - -0.0019336787518113852j, - -0.0034673355985432863j, - -0.0036765895783901215j, - -0.004916108213365078j, - -0.0042778430506587029j, - -0.006028641015291214j, - -0.005476709920912981j, - -0.0092810001224279404j, - -0.0095402700826525688j, - -0.016060983762145042j, - -0.016446959227323532j, - -0.02523401565849781j, - -0.024382550269365311j, - -0.035477779805660248j, - -0.033021725714206696j, - -0.048487484455108643j, - -0.04543270543217659j, - -0.069477587938308716j, - -0.066984444856643677j, - -0.10703597217798233j, - -0.10620346665382385j, - -0.1852707713842392j, - -0.19357112050056458j, - (7.2191945754696007e-09 -0.50004088878631592j), - (0.58778399229049683 -0.6155126690864563j), - (0.95105588436126709 -0.12377222627401352j), - (0.95105588436126709 +0.41524654626846313j), - (0.5877838134765625 +0.91611981391906738j), - (5.8516356205018383e-09 +1.0670661926269531j), - (-0.5877840518951416 +0.87856143712997437j), - (-0.95105588436126709 +0.35447561740875244j), - (-0.95105588436126709 -0.26055556535720825j), - (-0.5877838134765625 -0.77606213092803955j), - (-8.7774534307527574e-09 -0.96460390090942383j), - (0.58778399229049683 -0.78470128774642944j), - (0.95105588436126709 -0.28380891680717468j), - (0.95105588436126709 +0.32548999786376953j), - (0.5877838134765625 +0.82514488697052002j), - (1.4629089051254596e-08 +1.0096219778060913j), - (-0.5877840518951416 +0.81836479902267456j), - (-0.95105588436126709 +0.31451958417892456j), - (-0.95105588436126709 -0.3030143678188324j), - (-0.5877838134765625 -0.80480599403381348j), - (-1.7554906861505515e-08 -0.99516552686691284j), - (0.58778399229049683 -0.80540722608566284j), - (0.95105582475662231 -0.30557557940483093j), - (0.95105588436126709 +0.31097668409347534j), - (0.5877838134765625 +0.81027895212173462j), - (2.3406542482007353e-08 +1.0000816583633423j), - (-0.5877840518951416 +0.80908381938934326j), - (-0.95105588436126709 +0.30904293060302734j), - (-0.95105588436126709 -0.30904296040534973j), - (-0.5877838134765625 -0.80908387899398804j), - (-2.6332360292258272e-08 -1.0000815391540527j), - (0.58778399229049683 -0.80908381938934326j), - (0.95105582475662231 -0.30904299020767212j), - (0.95105588436126709 +0.30904293060302734j), - (0.5877838134765625 +0.80908381938934326j), - (3.218399768911695e-08 +1.0000815391540527j)) - - - src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, - sampling_freq * 0.10, 1.0) - - head = gr.head (gr.sizeof_float, int (ntaps + sampling_freq * 0.10)) - hilb = gr.hilbert_fc (ntaps) - dst1 = gr.vector_sink_c () - tb.connect (src1, head) - tb.connect (head, hilb) - tb.connect (hilb, dst1) - tb.run () - dst_data = dst1.data () - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) - -if __name__ == '__main__': - gr_unittest.run(test_hilbert, "test_hilbert.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_iir.py deleted file mode 100755 index 06b8d767ed..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_iir (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_iir_direct_001 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = () - fbtaps = () - expected_result = (0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_002 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2,) - fbtaps = (0,) - expected_result = (2, 4, 6, 8, 10, 12, 14, 16) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_003 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11) - fbtaps = (0, 0) - expected_result = (2, 15, 28, 41, 54, 67, 80, 93) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_004 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11) - fbtaps = (0, -1) - expected_result = (2, 13, 15, 26, 28, 39, 41, 52) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_005 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - fftaps = (2, 11, 0) - fbtaps = (0, -1, 3) - expected_result = (2, 13, 21, 59, 58, 186, 68, 583) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_006 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2, 13, 21, 59, 58, 186, 68, 583) - fftaps = (2, 1) - fbtaps = (0, -1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps = (2, 11, 0) - fbtaps = (0, -1, 3) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_007 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2,2,5,5,8,8,11,11) - fftaps = (2, 1) - fbtaps = (0, -1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps = (2,0,1) - fbtaps = (0, -1) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_iir_direct_008 (self): - src_data = (1, 2, 3, 4, 5, 6, 7, 8) - expected_result = (2,4,4,10,18,14,26,56) - fftaps = (2,) - fbtaps = (0, 1) - src = gr.vector_source_f (src_data) - op = gr.iir_filter_ffd (fftaps, fbtaps) - fftaps_data = (1) - fbtaps = (0,0, -1,3) - op.set_taps (fftaps, fbtaps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - - - -if __name__ == '__main__': - gr_unittest.run(test_iir, "test_iir.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py deleted file mode 100755 index 9bd9977c75..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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. -# - -from gnuradio import gr, gr_unittest -import math - -class test_interp_fir_filter (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_fff (self): - taps = [1, 10, 100, 1000, 10000] - src_data = (0, 2, 3, 5, 7, 11, 13, 17) - interpolation = 3 - xr = (0,0,0,0,2,20,200,2003,20030,300,3005,30050,500,5007,50070,700,7011,70110,1100,11013,110130,1300,13017,130170) - expected_result = tuple ([float (x) for x in xr]) - - src = gr.vector_source_f (src_data) - op = gr.interp_fir_filter_fff (interpolation, taps) - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - L = min(len(result_data), len(expected_result)) - self.assertEqual (expected_result[0:L], result_data[0:L]) - - -if __name__ == '__main__': - gr_unittest.run(test_interp_fir_filter, "test_interp_fir_filter.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py deleted file mode 100755 index bfe2d8fc8c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_single_pole_iir(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = src_data - src = gr.vector_source_f(src_data) - op = gr.single_pole_iir_filter_ff (1.0) - dst = gr.vector_sink_f() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = (0, 125, 359.375, 689.453125, 1103.271484, 1590.36255) - src = gr.vector_source_f(src_data) - op = gr.single_pole_iir_filter_ff (0.125) - dst = gr.vector_sink_f() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 3) - - def test_003(self): - block_size = 2 - src_data = (0, 1000, 2000, 3000, 4000, 5000) - expected_result = (0, 125, 250, 484.375, 718.75, 1048.828125) - src = gr.vector_source_f(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_float, block_size) - op = gr.single_pole_iir_filter_ff (0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_float, block_size) - dst = gr.vector_sink_f() - self.tb.connect (src, s2p, op, p2s, dst) - self.tb.run() - result_data = dst.data() - self.assertFloatTuplesAlmostEqual (expected_result, result_data, 3) - - -if __name__ == '__main__': - gr_unittest.run(test_single_pole_iir, "test_single_pole_iir.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py deleted file mode 100755 index 353df1bc0d..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007,2010 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. -# - -from gnuradio import gr, gr_unittest - -class test_single_pole_iir_cc(gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_001(self): - src_data = (0+0j, 1000+1000j, 2000+2000j, 3000+3000j, 4000+4000j, 5000+5000j) - expected_result = src_data - src = gr.vector_source_c(src_data) - op = gr.single_pole_iir_filter_cc (1.0) - dst = gr.vector_sink_c() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data) - - def test_002(self): - src_data = (complex(0,0), complex(1000,-1000), complex(2000,-2000), complex(3000,-3000), complex(4000,-4000), complex(5000,-5000)) - expected_result = (complex(0,0), complex(125,-125), complex(359.375,-359.375), complex(689.453125,-689.453125), complex(1103.271484,-1103.271484), complex(1590.36255,-1590.36255)) - src = gr.vector_source_c(src_data) - op = gr.single_pole_iir_filter_cc (0.125) - dst = gr.vector_sink_c() - self.tb.connect (src, op, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 3) - - def test_003(self): - block_size = 2 - src_data = (complex(0,0), complex(1000,-1000), complex(2000,-2000), complex(3000,-3000), complex(4000,-4000), complex(5000,-5000)) - expected_result = (complex(0,0), complex(125,-125), complex(250,-250), complex(484.375,-484.375), complex(718.75,-718.75), complex(1048.828125,-1048.828125)) - src = gr.vector_source_c(src_data) - s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, block_size) - op = gr.single_pole_iir_filter_cc (0.125, block_size) - p2s = gr.parallel_to_serial(gr.sizeof_gr_complex, block_size) - dst = gr.vector_sink_c() - self.tb.connect (src, s2p, op, p2s, dst) - self.tb.run() - result_data = dst.data() - self.assertComplexTuplesAlmostEqual (expected_result, result_data, 3) - - -if __name__ == '__main__': - gr_unittest.run(test_single_pole_iir_cc, "test_single_pole_iir_cc.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/top_block.py b/gnuradio-core/src/python/gnuradio/gr/top_block.py index c2937659f6..2d315a2780 100644 --- a/gnuradio-core/src/python/gnuradio/gr/top_block.py +++ b/gnuradio-core/src/python/gnuradio/gr/top_block.py @@ -99,13 +99,13 @@ class top_block(object): raise RuntimeError("top_block: invalid state--did you forget to call gr.top_block.__init__ in a derived class?") return getattr(self._tb, name) - def start(self, max_noutput_items=100000): + def start(self, max_noutput_items=10000000): self._tb.start(max_noutput_items) def stop(self): self._tb.stop() - def run(self, max_noutput_items=100000): + def run(self, max_noutput_items=10000000): self.start(max_noutput_items) self.wait() diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index 3c7f632b37..d752df6dc8 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -37,18 +37,10 @@ link_directories(${CPPUNIT_LIBRARY_DIRS}) # Build benchmarks and non-registered tests ######################################################################## set(tests_not_run #single source per test - benchmark_dotprod_fff.cc - benchmark_dotprod_fsf.cc - benchmark_dotprod_ccf.cc - benchmark_dotprod_fcc.cc - benchmark_dotprod_scc.cc - benchmark_dotprod_ccc.cc benchmark_nco.cc benchmark_vco.cc test_runtime.cc test_general.cc - test_filter.cc - #test_atsc.cc test_vmcircbuf.cc ) diff --git a/gnuradio-core/src/tests/benchmark_dotprod b/gnuradio-core/src/tests/benchmark_dotprod deleted file mode 100755 index 82f3b5c3fc..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# -# Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -DIR=. - -tests=" -benchmark_dotprod_fff -benchmark_dotprod_ccf -benchmark_dotprod_ccc -benchmark_dotprod_fcc -benchmark_dotprod_scc -benchmark_dotprod_fsf -" - -echo "uname -a" -uname -a - -if test -e /proc/cpuinfo -then - cat /proc/cpuinfo -fi - -for t in $tests -do - echo - echo "$t": - $DIR/$t -done diff --git a/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc b/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc deleted file mode 100644 index 8ef26a40dc..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_ccc.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_ccc.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_ccc* (*fir_maker_t)(const std::vector<gr_complex> &taps); -typedef gr_fir_ccc filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - gr_complex coeffs[NTAPS]; - //gr_complex input[BLOCK_SIZE + NTAPS]; // not always 16-bit aligned - gr_complex *input = new gr_complex[BLOCK_SIZE + NTAPS]; - long n; - gr_complex result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - - - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); - - std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start= (double) clock() / CLOCKS_PER_SEC; -#endif - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter ((gr_complex*)&input[j]); - } - } - - // get ending CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end = (double) clock() / CLOCKS_PER_SEC; - double total = clock_end - clock_start; -#endif - - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; - delete [] input; -} - -static void -do_all () -{ - std::vector<gr_fir_ccc_info> info; - gr_fir_util::get_gr_fir_ccc_info (&info); // get all known CCC implementations - - for (std::vector<gr_fir_ccc_info>::iterator p = info.begin (); - p != info.end () ; - ++p){ - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc b/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc deleted file mode 100644 index ed3c491651..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_ccf.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_ccf.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_ccf* (*fir_maker_t)(const std::vector<float> &taps); -typedef gr_fir_ccf filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - float coeffs[NTAPS]; - //gr_complex input[BLOCK_SIZE + NTAPS]; // not always 16-bit aligned - gr_complex *input = new gr_complex[BLOCK_SIZE + NTAPS]; - long n; - gr_complex result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = random() - RANDOM_MAX/2; - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); - - std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage - -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start= (double) clock() / CLOCKS_PER_SEC; -#endif - - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter (&input[j]); - } - } - - // get ending CPU usage - -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end= (double) clock() / CLOCKS_PER_SEC; - double total = clock_end - clock_start; -#endif - - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; - delete [] input; -} - -static void -do_all () -{ - std::vector<gr_fir_ccf_info> info; - gr_fir_util::get_gr_fir_ccf_info (&info); // get all known CCF implementations - - for (std::vector<gr_fir_ccf_info>::iterator p = info.begin (); - p != info.end () ; - ++p){ - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc b/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc deleted file mode 100644 index e9eeee43a1..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_fcc.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_fcc.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_fcc* (*fir_maker_t)(const std::vector<gr_complex> &taps); -typedef gr_fir_fcc filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - gr_complex coeffs[NTAPS]; - float input[BLOCK_SIZE + NTAPS]; - long n; - gr_complex result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - - - - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = random() - RANDOM_MAX/2; - - std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); -#endif - - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter (&input[j]); - } - } - - // get ending CPU usage - -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end= (double) clock() * (1000000. / CLOCKS_PER_SEC); - double total = clock_end - clock_start; -#endif - - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; -} - -static void -do_all () -{ - std::vector<gr_fir_fcc_info> info; - gr_fir_util::get_gr_fir_fcc_info (&info); // get all known FCC implementations - - for (std::vector<gr_fir_fcc_info>::iterator p = info.begin (); - p != info.end () ; - ++p){ - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fff.cc b/gnuradio-core/src/tests/benchmark_dotprod_fff.cc deleted file mode 100644 index 56e0645062..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_fff.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif - -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_fff.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_fff* (*fir_maker_t)(const std::vector<float> &taps); -typedef gr_fir_fff filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - float coeffs[NTAPS]; - float input[BLOCK_SIZE + NTAPS]; - long n; - float result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = random() - RANDOM_MAX/2; - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = random() - RANDOM_MAX/2; - - std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); -#endif - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter (&input[j]); - } - } - - // get ending CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); - double total = clock_end -clock_start; -#endif - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; -} - -static void -do_all () -{ - std::vector<gr_fir_fff_info> info; - gr_fir_util::get_gr_fir_fff_info (&info); // get all known FFF implementations - - for (std::vector<gr_fir_fff_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc b/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc deleted file mode 100644 index a254a8eab4..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_fsf.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_fsf.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_fsf* (*fir_maker_t)(const std::vector<float> &taps); -typedef gr_fir_fsf filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - float coeffs[NTAPS]; - float input[BLOCK_SIZE + NTAPS]; - long n; - short result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = random() - RANDOM_MAX/2; - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = random() - RANDOM_MAX/2; - - std::vector<float> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start= (double) clock() * (1000000. / CLOCKS_PER_SEC); -#endif - - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter (&input[j]); - } - } - - // get ending CPU usage - -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end= (double) clock() * (1000000. / CLOCKS_PER_SEC); - double total = clock_end - clock_start; -#endif - - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; -} - -static void -do_all () -{ - std::vector<gr_fir_fsf_info> info; - gr_fir_util::get_gr_fir_fsf_info (&info); // get all known FFF implementations - - for (std::vector<gr_fir_fsf_info>::iterator p = info.begin (); - p != info.end (); - ++p){ - - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/benchmark_dotprod_scc.cc b/gnuradio-core/src/tests/benchmark_dotprod_scc.cc deleted file mode 100644 index 9a65bb4c62..0000000000 --- a/gnuradio-core/src/tests/benchmark_dotprod_scc.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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 <stdio.h> -#include <sys/time.h> -#ifdef HAVE_SYS_RESOURCE_H -#include <sys/resource.h> -#endif -#include <unistd.h> -#include <gr_fir_util.h> -#include <gr_fir_scc.h> -#include <random.h> - -#define TOTAL_TEST_SIZE (40 * 1000 * 1000L) -#define NTAPS 256 -#define BLOCK_SIZE (50 * 1000) /* fits in cache */ - -#if ((TOTAL_TEST_SIZE % BLOCK_SIZE) != 0) -#error "TOTAL_TEST_SIZE % BLOCK_SIZE must equal 0" -#endif - -typedef gr_fir_scc* (*fir_maker_t)(const std::vector<gr_complex> &taps); -typedef gr_fir_scc filter_t; - - -static double -timeval_to_double (const struct timeval *tv) -{ - return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; -} - - -static void -benchmark (fir_maker_t filter_maker, const char *implementation_name) -{ - int i; - gr_complex coeffs[NTAPS]; - short input[BLOCK_SIZE + NTAPS]; - long n; - gr_complex result; -#ifdef HAVE_SYS_RESOURCE_H - struct rusage rusage_start; - struct rusage rusage_stop; -#else - double clock_start; - double clock_end; -#endif - - - // setup coefficients and input data - - for (i = 0; i < NTAPS; i++) - coeffs[i] = gr_complex(random() - RANDOM_MAX/2, random() - RANDOM_MAX/2); - - for (i = 0; i < BLOCK_SIZE + NTAPS; i++) - input[i] = random() - RANDOM_MAX/2; - - std::vector<gr_complex> taps (&coeffs[0], &coeffs[NTAPS]); - filter_t *f = filter_maker (taps); - - // get starting CPU usage - -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ - perror ("getrusage"); - exit (1); - } -#else - clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); -#endif - - // do the actual work - - for (n = 0; n < TOTAL_TEST_SIZE; n += BLOCK_SIZE){ - int j; - for (j = 0; j < BLOCK_SIZE; j++){ - result = f->filter (&input[j]); - } - } - - // get ending CPU usage -#ifdef HAVE_SYS_RESOURCE_H - if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ - perror ("getrusage"); - exit (1); - } - - // compute results - - double user = - timeval_to_double (&rusage_stop.ru_utime) - - timeval_to_double (&rusage_start.ru_utime); - - double sys = - timeval_to_double (&rusage_stop.ru_stime) - - timeval_to_double (&rusage_start.ru_stime); - - double total = user + sys; -#else - clock_end= (double) clock () * (1000000. / CLOCKS_PER_SEC); - double total = clock_end -clock_start; -#endif - - double macs = NTAPS * (double) TOTAL_TEST_SIZE; - - printf ("%10s: taps: %4d input: %4g cpu: %6.3f taps/sec: %10.4g \n", - implementation_name, NTAPS, (double) TOTAL_TEST_SIZE, total, macs / total); - - delete f; -} - -static void -do_all () -{ - std::vector<gr_fir_scc_info> info; - gr_fir_util::get_gr_fir_scc_info (&info); // get all known SCC implementations - - for (std::vector<gr_fir_scc_info>::iterator p = info.begin (); - p != info.end () ; - ++p){ - benchmark (p->create, p->name); - } -} - -int -main (int argc, char **argv) -{ - do_all (); - return 0; -} diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index 8a1423e9ea..fb45cbf8f4 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -26,8 +26,6 @@ #include <gr_unittests.h> #include <qa_runtime.h> #include <qa_general.h> -#include <qa_filter.h> -// #include <qa_atsc.h> // FIXME add atsc back in. @@ -40,8 +38,6 @@ main (int argc, char **argv) runner.addTest (qa_runtime::suite ()); runner.addTest (qa_general::suite ()); - runner.addTest (qa_filter::suite ()); - // runner.addTest (qa_atsc::suite ()); runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gnuradio-core/src/tests/test_filter.cc b/gnuradio-core/src/tests/test_filter.cc deleted file mode 100644 index 8b17034c60..0000000000 --- a/gnuradio-core/src/tests/test_filter.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2010,2011 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. - */ - -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gr_unittests.h> -#include <qa_filter.h> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gnuradio_core_filter.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest (qa_filter::suite ()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run ("", false); - - return was_successful ? 0 : 1; -} diff --git a/gr-atsc/CMakeLists.txt b/gr-atsc/CMakeLists.txt index 26f99a1573..3cb9b39de8 100644 --- a/gr-atsc/CMakeLists.txt +++ b/gr-atsc/CMakeLists.txt @@ -29,6 +29,8 @@ include(GrComponent) GR_REGISTER_COMPONENT("gr-atsc" ENABLE_GR_ATSC Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_FFT + ENABLE_GR_FILTER ) GR_SET_GLOBAL(GR_ATSC_INCLUDE_DIRS diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt index 39dbefa60f..386a8792db 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/src/lib/CMakeLists.txt @@ -22,6 +22,7 @@ ######################################################################## include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} ${GR_ATSC_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ) @@ -95,6 +96,7 @@ list(APPEND gr_atsc_sources ) list(APPEND atsc_libs + gnuradio-filter gnuradio-core ${Boost_LIBRARIES} ) diff --git a/gr-atsc/src/lib/atsci_sssr.h b/gr-atsc/src/lib/atsci_sssr.h index f3b825b3c4..1eb626eb18 100644 --- a/gr-atsc/src/lib/atsci_sssr.h +++ b/gr-atsc/src/lib/atsci_sssr.h @@ -29,8 +29,8 @@ #include <atsc_api.h> #include <atsc_consts.h> -#include <gri_mmse_fir_interpolator.h> -#include <gr_single_pole_iir.h> +#include <filter/mmse_fir_interpolator_ff.h> +#include <filter/single_pole_iir.h> #include <cstdio> /* @@ -195,8 +195,8 @@ public: */ class ATSC_API atsci_interpolator { - gri_mmse_fir_interpolator d_interp; - gr_single_pole_iir<float,float,float> d_loop; // ``VCO'' loop filter + gr::filter::mmse_fir_interpolator_ff d_interp; + gr::filter::single_pole_iir<float,float,float> d_loop; // ``VCO'' loop filter double d_nominal_ratio_of_rx_clock_to_symbol_freq; // FREQ double d_w; // ratio of PERIOD of Tx to Rx clocks double d_mu; // fractional delay [0,1] diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index eb7ed67e16..34ce8975be 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -28,11 +28,15 @@ include(GrBoost) include(GrComponent) GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL Boost_FOUND + ENABLE_VOLK ENABLE_GR_CORE + ENABLE_GR_FFT + ENABLE_GR_FILTER ) GR_SET_GLOBAL(GR_DIGITAL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include ) GR_SET_GLOBAL(GR_DIGITAL_SWIG_INCLUDE_DIRS @@ -83,7 +87,7 @@ CPACK_COMPONENT("digital_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(include) +add_subdirectory(include/digital) add_subdirectory(lib) add_subdirectory(doc) if(ENABLE_PYTHON) diff --git a/gr-digital/examples/CMakeLists.txt b/gr-digital/examples/CMakeLists.txt index 63e1eba4e4..64c4641aa5 100644 --- a/gr-digital/examples/CMakeLists.txt +++ b/gr-digital/examples/CMakeLists.txt @@ -53,7 +53,6 @@ GR_PYTHON_INSTALL(PROGRAMS ofdm/benchmark_rx.py ofdm/benchmark_tx.py ofdm/gr_plot_ofdm.py - ofdm/ofdm_mod_demod_test.py ofdm/receive_path.py ofdm/transmit_path.py ofdm/tunnel.py diff --git a/gr-digital/examples/berawgn.py b/gr-digital/examples/berawgn.py index d58dfbaaeb..2d95a1345f 100755 --- a/gr-digital/examples/berawgn.py +++ b/gr-digital/examples/berawgn.py @@ -1,4 +1,25 @@ #!/usr/bin/env python +# +# Copyright 2012 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. +# + """ BER simulation for QPSK signals, compare to theoretical values. Change the N_BITS value to simulate more bits per Eb/N0 value, @@ -14,10 +35,20 @@ magnitude below what you chose for N_BITS. import math import numpy -from scipy.special import erfc -import pylab from gnuradio import gr, digital +try: + from scipy.special import erfc +except ImportError: + print "Error: could not import scipy (http://www.scipy.org/)" + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: could not import pylab (http://matplotlib.sourceforge.net/)" + sys.exit(1) + # Best to choose powers of 10 N_BITS = 1e7 RAND_SEED = 42 @@ -59,7 +90,7 @@ class BERAWGNSimu(gr.top_block): # Source is N_BITS bits, non-repeated data = map(int, numpy.random.randint(0, self.const.arity(), N_BITS/self.const.bits_per_symbol())) src = gr.vector_source_b(data, False) - mod = gr.chunks_to_symbols_bc((self.const.points()), 1) + mod = digital.chunks_to_symbols_bc((self.const.points()), 1) add = gr.add_vcc() noise = gr.noise_source_c(gr.GR_GAUSSIAN, self.EbN0_to_noise_voltage(EbN0), diff --git a/gr-digital/examples/demod/ber_simulation.grc b/gr-digital/examples/demod/ber_simulation.grc index b7c6a624b6..f41b9cf79b 100644 --- a/gr-digital/examples/demod/ber_simulation.grc +++ b/gr-digital/examples/demod/ber_simulation.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 15:57:06 2012</timestamp> + <timestamp>Mon Jul 16 21:09:12 2012</timestamp> <block> <key>options</key> <param> @@ -92,60 +92,6 @@ </param> </block> <block> - <key>gr_add_xx</key> - <param> - <key>id</key> - <value>gr_add_xx</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>num_inputs</key> - <value>2</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(486, 151)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>digital_constellation_decoder_cb</key> - <param> - <key>id</key> - <value>digital_constellation_decoder_cb_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>constellation</key> - <value>const.base()</value> - </param> - <param> - <key>_coordinate</key> - <value>(618, 164)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>wxgui_numbersink2</key> <param> <key>id</key> @@ -443,45 +389,6 @@ </param> </block> <block> - <key>gr_chunks_to_symbols_xx</key> - <param> - <key>id</key> - <value>gr_chunks_to_symbols_xx</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>in_type</key> - <value>byte</value> - </param> - <param> - <key>out_type</key> - <value>complex</value> - </param> - <param> - <key>symbol_table</key> - <value>const.points()</value> - </param> - <param> - <key>dimension</key> - <value>1</value> - </param> - <param> - <key>num_ports</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(240, 140)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable_slider</key> <param> <key>id</key> @@ -575,6 +482,99 @@ <value>0</value> </param> </block> + <block> + <key>digital_chunks_to_symbols_xx</key> + <param> + <key>id</key> + <value>digital_chunks_to_symbols_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>in_type</key> + <value>byte</value> + </param> + <param> + <key>out_type</key> + <value>complex</value> + </param> + <param> + <key>symbol_table</key> + <value>const.points()</value> + </param> + <param> + <key>dimension</key> + <value>1</value> + </param> + <param> + <key>num_ports</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(284, 70)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_add_xx</key> + <param> + <key>id</key> + <value>gr_add_xx</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>num_inputs</key> + <value>2</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(469, 210)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_constellation_decoder_cb</key> + <param> + <key>id</key> + <value>digital_constellation_decoder_cb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>constellation</key> + <value>const.base()</value> + </param> + <param> + <key>_coordinate</key> + <value>(622, 164)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>blks2_error_rate</source_block_id> <sink_block_id>wxgui_numbersink2</sink_block_id> @@ -588,12 +588,6 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_chunks_to_symbols_xx</source_block_id> - <sink_block_id>gr_add_xx</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> <source_block_id>gr_noise_source_x</source_block_id> <sink_block_id>gr_add_xx</sink_block_id> <source_key>0</source_key> @@ -606,12 +600,6 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>random_source_x</source_block_id> - <sink_block_id>gr_chunks_to_symbols_xx</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> <source_block_id>gr_add_xx</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> @@ -629,4 +617,16 @@ <source_key>0</source_key> <sink_key>0</sink_key> </connection> + <connection> + <source_block_id>random_source_x</source_block_id> + <sink_block_id>digital_chunks_to_symbols_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> + <sink_block_id>gr_add_xx</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> </flow_graph> diff --git a/gr-digital/examples/demod/digital_freq_lock.grc b/gr-digital/examples/demod/digital_freq_lock.grc index df105dd7f5..17d3296ddb 100644 --- a/gr-digital/examples/demod/digital_freq_lock.grc +++ b/gr-digital/examples/demod/digital_freq_lock.grc @@ -1,98 +1,23 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 18:11:22 2012</timestamp> + <timestamp>Mon Jul 16 21:25:18 2012</timestamp> <block> - <key>options</key> - <param> - <key>id</key> - <value>top_block</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>wx_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(-1, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>random_source_x</key> + <key>variable</key> <param> <key>id</key> - <value>random_source_x</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>256</value> - </param> - <param> - <key>num_samps</key> - <value>10000000</value> - </param> - <param> - <key>repeat</key> - <value>True</value> + <key>value</key> + <value>4</value> </param> <param> <key>_coordinate</key> - <value>(-2, 111)</value> + <value>(166, -2)</value> </param> <param> <key>_rotation</key> @@ -100,30 +25,22 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>variable</key> <param> <key>id</key> - <value>gr_throttle_0</value> + <value>rolloff</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> + <key>value</key> + <value>0.35</value> </param> <param> <key>_coordinate</key> - <value>(456, 134)</value> + <value>(231, 0)</value> </param> <param> <key>_rotation</key> @@ -134,7 +51,7 @@ <key>variable</key> <param> <key>id</key> - <value>sps</value> + <value>samp_rate</value> </param> <param> <key>_enabled</key> @@ -142,11 +59,11 @@ </param> <param> <key>value</key> - <value>4</value> + <value>32000</value> </param> <param> <key>_coordinate</key> - <value>(166, -2)</value> + <value>(439, -1)</value> </param> <param> <key>_rotation</key> @@ -154,61 +71,54 @@ </param> </block> <block> - <key>variable</key> + <key>variable_slider</key> <param> <key>id</key> - <value>rolloff</value> + <value>noise_amp</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>0.35</value> - </param> - <param> - <key>_coordinate</key> - <value>(231, 0)</value> + <key>label</key> + <value>Channel Noise</value> </param> <param> - <key>_rotation</key> + <key>value</key> <value>0</value> </param> - </block> - <block> - <key>digital_fll_band_edge_cc</key> <param> - <key>id</key> - <value>digital_fll_band_edge_cc_0</value> + <key>min</key> + <value>0</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>max</key> + <value>1.0</value> </param> <param> - <key>type</key> - <value>cc</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>samps_per_sym</key> - <value>sps</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> </param> <param> - <key>rolloff</key> - <value>rolloff</value> + <key>converver</key> + <value>float_converter</value> </param> <param> - <key>filter_size</key> - <value>44</value> + <key>grid_pos</key> + <value></value> </param> <param> - <key>w</key> - <value>freq_bw</value> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(81, 248)</value> + <value>(553, 0)</value> </param> <param> <key>_rotation</key> @@ -219,7 +129,7 @@ <key>variable_slider</key> <param> <key>id</key> - <value>freq_bw</value> + <value>freq_offset</value> </param> <param> <key>_enabled</key> @@ -227,7 +137,7 @@ </param> <param> <key>label</key> - <value>FLL Loop Bandwidth</value> + <value>Frequency Offset</value> </param> <param> <key>value</key> @@ -235,11 +145,11 @@ </param> <param> <key>min</key> - <value>0</value> + <value>-0.5</value> </param> <param> <key>max</key> - <value>0.1</value> + <value>0.5</value> </param> <param> <key>num_steps</key> @@ -263,7 +173,7 @@ </param> <param> <key>_coordinate</key> - <value>(80, 382)</value> + <value>(673, -1)</value> </param> <param> <key>_rotation</key> @@ -271,22 +181,46 @@ </param> </block> <block> - <key>variable</key> + <key>digital_psk_mod</key> <param> <key>id</key> - <value>samp_rate</value> + <value>digital_psk_mod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>32000</value> + <key>constellation_points</key> + <value>2</value> + </param> + <param> + <key>mod_code</key> + <value>"gray"</value> + </param> + <param> + <key>differential</key> + <value>False</value> + </param> + <param> + <key>samples_per_symbol</key> + <value>sps</value> + </param> + <param> + <key>excess_bw</key> + <value>0.35</value> + </param> + <param> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(439, -1)</value> + <value>(194, 104)</value> </param> <param> <key>_rotation</key> @@ -294,42 +228,74 @@ </param> </block> <block> - <key>variable_slider</key> + <key>wxgui_fftsink2</key> <param> <key>id</key> - <value>noise_amp</value> + <value>wxgui_fftsink2_0_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Channel Noise</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>value</key> - <value>0</value> + <key>title</key> + <value>Frequency Corrected Signal</value> </param> <param> - <key>min</key> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> <value>0</value> </param> <param> - <key>max</key> - <value>1.0</value> + <key>y_per_div</key> + <value>10</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>y_divs</key> + <value>10</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>ref_level</key> + <value>10</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>30</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> </param> <param> <key>grid_pos</key> @@ -337,11 +303,15 @@ </param> <param> <key>notebook</key> - <value></value> + <value>notebook_0,0</value> + </param> + <param> + <key>freqvar</key> + <value>None</value> </param> <param> <key>_coordinate</key> - <value>(553, 0)</value> + <value>(439, 423)</value> </param> <param> <key>_rotation</key> @@ -349,54 +319,38 @@ </param> </block> <block> - <key>variable_slider</key> + <key>random_source_x</key> <param> <key>id</key> - <value>freq_offset</value> + <value>random_source_x</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Frequency Offset</value> - </param> - <param> - <key>value</key> - <value>0</value> + <key>type</key> + <value>byte</value> </param> <param> <key>min</key> - <value>-0.5</value> + <value>0</value> </param> <param> <key>max</key> - <value>0.5</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> + <value>256</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>num_samps</key> + <value>10000000</value> </param> <param> - <key>notebook</key> - <value></value> + <key>repeat</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(673, -1)</value> + <value>(0, 112)</value> </param> <param> <key>_rotation</key> @@ -404,38 +358,30 @@ </param> </block> <block> - <key>gr_channel_model</key> + <key>gr_throttle</key> <param> <key>id</key> - <value>gr_channel_model_0</value> + <value>gr_throttle_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>noise_voltage</key> - <value>noise_amp</value> - </param> - <param> - <key>freq_offset</key> - <value>freq_offset</value> - </param> - <param> - <key>epsilon</key> - <value>1.0</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>taps</key> - <value>1.0</value> + <key>samples_per_second</key> + <value>samp_rate</value> </param> <param> - <key>seed</key> - <value>42</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(649, 104)</value> + <value>(489, 179)</value> </param> <param> <key>_rotation</key> @@ -510,7 +456,7 @@ </param> <param> <key>_coordinate</key> - <value>(875, 0)</value> + <value>(990, 0)</value> </param> <param> <key>_rotation</key> @@ -601,7 +547,7 @@ </param> <param> <key>_coordinate</key> - <value>(875, 108)</value> + <value>(990, 147)</value> </param> <param> <key>_rotation</key> @@ -609,46 +555,38 @@ </param> </block> <block> - <key>digital_psk_mod</key> + <key>channel_model</key> <param> <key>id</key> - <value>digital_psk_mod_0</value> + <value>channel_model_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>constellation_points</key> - <value>2</value> - </param> - <param> - <key>mod_code</key> - <value>"gray"</value> - </param> - <param> - <key>differential</key> - <value>False</value> + <key>noise_voltage</key> + <value>noise_amp</value> </param> <param> - <key>samples_per_symbol</key> - <value>sps</value> + <key>freq_offset</key> + <value>freq_offset</value> </param> <param> - <key>excess_bw</key> - <value>0.35</value> + <key>epsilon</key> + <value>1.0</value> </param> <param> - <key>verbose</key> - <value>False</value> + <key>taps</key> + <value>1.0</value> </param> <param> - <key>log</key> - <value>False</value> + <key>seed</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(194, 104)</value> + <value>(743, 147)</value> </param> <param> <key>_rotation</key> @@ -656,54 +594,77 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>notebook</key> <param> <key>id</key> - <value>wxgui_scopesink2_0_0</value> + <value>notebook_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>style</key> + <value>wx.NB_TOP</value> </param> <param> - <key>title</key> - <value>Frequency Corrected Signal</value> + <key>labels</key> + <value>['Freq', 'Time']</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>grid_pos</key> + <value></value> </param> <param> - <key>v_scale</key> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(76, 579)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>variable_slider</key> <param> - <key>v_offset</key> + <key>id</key> + <value>freq_bw</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>FLL Loop Bandwidth</value> + </param> + <param> + <key>value</key> <value>0</value> </param> <param> - <key>t_scale</key> + <key>min</key> <value>0</value> </param> <param> - <key>ac_couple</key> - <value>False</value> + <key>max</key> + <value>0.1</value> </param> <param> - <key>xy_mode</key> - <value>False</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> </param> <param> - <key>win_size</key> - <value></value> + <key>converver</key> + <value>float_converter</value> </param> <param> <key>grid_pos</key> @@ -711,19 +672,11 @@ </param> <param> <key>notebook</key> - <value>notebook_0,1</value> - </param> - <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> - </param> - <param> - <key>y_axis_label</key> - <value>Counts</value> + <value></value> </param> <param> <key>_coordinate</key> - <value>(439, 289)</value> + <value>(77, 449)</value> </param> <param> <key>_rotation</key> @@ -731,10 +684,10 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>digital_fll_band_edge_cc</key> <param> <key>id</key> - <value>wxgui_fftsink2_0_0</value> + <value>digital_fll_band_edge_cc_0</value> </param> <param> <key>_enabled</key> @@ -742,59 +695,78 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>cc</value> </param> <param> - <key>title</key> - <value>Frequency Corrected Signal</value> + <key>samps_per_sym</key> + <value>sps</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>rolloff</key> + <value>rolloff</value> </param> <param> - <key>baseband_freq</key> + <key>filter_size</key> + <value>44</value> + </param> + <param> + <key>w</key> + <value>freq_bw</value> + </param> + <param> + <key>_coordinate</key> + <value>(78, 308)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>wxgui_scopesink2</key> <param> - <key>y_per_div</key> - <value>10</value> + <key>id</key> + <value>wxgui_scopesink2_0_0</value> </param> <param> - <key>y_divs</key> - <value>10</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>ref_level</key> - <value>10</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>ref_scale</key> - <value>2.0</value> + <key>title</key> + <value>Frequency Corrected Signal</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>fft_rate</key> - <value>30</value> + <key>v_scale</key> + <value>0</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>v_offset</key> + <value>0</value> </param> <param> - <key>average</key> + <key>t_scale</key> + <value>0</value> + </param> + <param> + <key>ac_couple</key> <value>False</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> + <key>xy_mode</key> + <value>False</value> </param> <param> - <key>win</key> - <value>None</value> + <key>num_inputs</key> + <value>1</value> </param> <param> <key>win_size</key> @@ -806,15 +778,19 @@ </param> <param> <key>notebook</key> - <value>notebook_0,0</value> + <value>notebook_0,1</value> </param> <param> - <key>freqvar</key> - <value>None</value> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> + </param> + <param> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(439, 423)</value> + <value>(439, 306)</value> </param> <param> <key>_rotation</key> @@ -822,34 +798,58 @@ </param> </block> <block> - <key>notebook</key> + <key>options</key> <param> <key>id</key> - <value>notebook_0</value> + <value>freq_lock</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>style</key> - <value>wx.NB_TOP</value> + <key>title</key> + <value></value> </param> <param> - <key>labels</key> - <value>['Freq', 'Time']</value> + <key>author</key> + <value></value> </param> <param> - <key>grid_pos</key> + <key>description</key> <value></value> </param> <param> - <key>notebook</key> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(114, 521)</value> + <value>(-1, 0)</value> </param> <param> <key>_rotation</key> @@ -857,50 +857,50 @@ </param> </block> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_block_id>random_source_x</source_block_id> + <sink_block_id>digital_psk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_block_id>digital_psk_mod_0</source_block_id> + <sink_block_id>gr_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>random_source_x</source_block_id> - <sink_block_id>digital_psk_mod_0</sink_block_id> + <source_block_id>digital_fll_band_edge_cc_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_psk_mod_0</source_block_id> - <sink_block_id>gr_throttle_0</sink_block_id> + <source_block_id>digital_fll_band_edge_cc_0</source_block_id> + <sink_block_id>wxgui_fftsink2_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>gr_channel_model_0</sink_block_id> + <sink_block_id>channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>digital_fll_band_edge_cc_0</sink_block_id> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_fll_band_edge_cc_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0_0</sink_block_id> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_fll_band_edge_cc_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0_0</sink_block_id> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>digital_fll_band_edge_cc_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/gfsk_loopback.grc b/gr-digital/examples/demod/gfsk_loopback.grc index f74a835266..364314aa9a 100644 --- a/gr-digital/examples/demod/gfsk_loopback.grc +++ b/gr-digital/examples/demod/gfsk_loopback.grc @@ -1,55 +1,59 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sun Jul 8 16:56:18 2012</timestamp> + <timestamp>Mon Aug 20 19:52:22 2012</timestamp> <block> - <key>variable_slider</key> + <key>options</key> <param> <key>id</key> - <value>freq</value> + <value>gfsk_loopback</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Frequency (Hz)</value> + <key>title</key> + <value></value> </param> <param> - <key>value</key> - <value>500</value> + <key>author</key> + <value></value> </param> <param> - <key>min</key> - <value>0</value> + <key>description</key> + <value></value> </param> <param> - <key>max</key> - <value>samp_rate/2</value> + <key>window_size</key> + <value>1280, 1024</value> </param> <param> - <key>num_steps</key> - <value>100</value> + <key>generate_options</key> + <value>qt_gui</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>category</key> + <value>Custom</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>run_options</key> + <value>prompt</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> </param> <param> - <key>notebook</key> + <key>realtime_scheduling</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(34, 241)</value> + <value>(10, 10)</value> </param> <param> <key>_rotation</key> @@ -57,10 +61,10 @@ </param> </block> <block> - <key>gr_sig_source_x</key> + <key>gr_throttle</key> <param> <key>id</key> - <value>gr_sig_source_x_0</value> + <value>gr_throttle_0_0</value> </param> <param> <key>_enabled</key> @@ -71,28 +75,39 @@ <value>float</value> </param> <param> - <key>samp_rate</key> + <key>samples_per_second</key> <value>samp_rate</value> </param> <param> - <key>waveform</key> - <value>gr.GR_COS_WAVE</value> + <key>vlen</key> + <value>1</value> </param> <param> - <key>freq</key> - <value>freq</value> + <key>_coordinate</key> + <value>(413, 50)</value> </param> <param> - <key>amp</key> - <value>1</value> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>fm_sensitivity</value> </param> <param> - <key>offset</key> - <value>0</value> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1.0</value> </param> <param> <key>_coordinate</key> - <value>(215, 26)</value> + <value>(14, 273)</value> </param> <param> <key>_rotation</key> @@ -100,30 +115,22 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>variable</key> <param> <key>id</key> - <value>gr_throttle_0_0</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> + <key>value</key> + <value>4</value> </param> <param> <key>_coordinate</key> - <value>(272.5, 142.0)</value> + <value>(15, 338)</value> </param> <param> <key>_rotation</key> @@ -131,10 +138,10 @@ </param> </block> <block> - <key>blks2_packet_encoder</key> + <key>gr_sig_source_x</key> <param> <key>id</key> - <value>blks2_packet_encoder_0</value> + <value>gr_sig_source_x_0</value> </param> <param> <key>_enabled</key> @@ -145,28 +152,28 @@ <value>float</value> </param> <param> - <key>samples_per_symbol</key> - <value>2</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>bits_per_symbol</key> - <value>1</value> + <key>waveform</key> + <value>gr.GR_COS_WAVE</value> </param> <param> - <key>access_code</key> - <value></value> + <key>freq</key> + <value>freq</value> </param> <param> - <key>pad_for_usrp</key> - <value>True</value> + <key>amp</key> + <value>1</value> </param> <param> - <key>payload_length</key> + <key>offset</key> <value>0</value> </param> <param> <key>_coordinate</key> - <value>(261, 227)</value> + <value>(215, 18)</value> </param> <param> <key>_rotation</key> @@ -185,11 +192,11 @@ </param> <param> <key>value</key> - <value>10000</value> + <value>32000</value> </param> <param> <key>_coordinate</key> - <value>(10, 170)</value> + <value>(12, 76)</value> </param> <param> <key>_rotation</key> @@ -197,50 +204,54 @@ </param> </block> <block> - <key>digital_gfsk_demod</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>digital_gfsk_demod_0</value> + <value>freq</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>samples_per_symbol</key> - <value>sps</value> + <key>label</key> + <value></value> </param> <param> - <key>sensitivity</key> - <value>fm_sensitivity</value> + <key>value</key> + <value>500</value> </param> <param> - <key>gain_mu</key> - <value>0.175</value> + <key>start</key> + <value>0</value> </param> <param> - <key>mu</key> - <value>0.5</value> + <key>stop</key> + <value>500</value> </param> <param> - <key>omega_relative_limit</key> - <value>0.005</value> + <key>step</key> + <value>1</value> </param> <param> - <key>freq_error</key> - <value>0.0</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>verbose</key> - <value>False</value> + <key>orient</key> + <value>Qt.Horizontal</value> </param> <param> - <key>log</key> - <value>False</value> + <key>min_len</key> + <value>200</value> + </param> + <param> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(669, 257)</value> + <value>(13, 152)</value> </param> <param> <key>_rotation</key> @@ -248,22 +259,42 @@ </param> </block> <block> - <key>variable</key> + <key>qtgui_time_sink_x</key> <param> <key>id</key> - <value>sps</value> + <value>qtgui_time_sink_x_1</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>8</value> + <key>type</key> + <value>float</value> + </param> + <param> + <key>name</key> + <value>QT GUI Plot</value> + </param> + <param> + <key>size</key> + <value>1024</value> + </param> + <param> + <key>bw</key> + <value>samp_rate</value> + </param> + <param> + <key>nconnections</key> + <value>1</value> + </param> + <param> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(47, 445)</value> + <value>(906, 122)</value> </param> <param> <key>_rotation</key> @@ -271,38 +302,42 @@ </param> </block> <block> - <key>digital_gfsk_mod</key> + <key>qtgui_time_sink_x</key> <param> <key>id</key> - <value>digital_gfsk_mod_0</value> + <value>qtgui_time_sink_x_1_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>samples_per_symbol</key> - <value>sps</value> + <key>type</key> + <value>float</value> </param> <param> - <key>sensitivity</key> - <value>fm_sensitivity</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>bt</key> - <value>0.35</value> + <key>size</key> + <value>1024</value> </param> <param> - <key>verbose</key> - <value>False</value> + <key>bw</key> + <value>samp_rate</value> </param> <param> - <key>log</key> - <value>False</value> + <key>nconnections</key> + <value>1</value> + </param> + <param> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(456, 277)</value> + <value>(888, 386)</value> </param> <param> <key>_rotation</key> @@ -310,22 +345,38 @@ </param> </block> <block> - <key>variable</key> + <key>digital_gfsk_mod</key> <param> <key>id</key> - <value>fm_sensitivity</value> + <value>digital_gfsk_mod_0</value> </param> <param> <key>_enabled</key> - <value>True</value> + <value>False</value> </param> <param> - <key>value</key> - <value>1.0</value> + <key>samples_per_symbol</key> + <value>sps</value> + </param> + <param> + <key>sensitivity</key> + <value>fm_sensitivity</value> + </param> + <param> + <key>bt</key> + <value>0.35</value> + </param> + <param> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(40, 366)</value> + <value>(456, 277)</value> </param> <param> <key>_rotation</key> @@ -333,53 +384,50 @@ </param> </block> <block> - <key>blks2_packet_decoder</key> + <key>digital_gfsk_demod</key> <param> <key>id</key> - <value>blks2_packet_decoder_0</value> + <value>digital_gfsk_demod_0</value> </param> <param> <key>_enabled</key> - <value>True</value> + <value>False</value> </param> <param> - <key>type</key> - <value>float</value> + <key>samples_per_symbol</key> + <value>sps</value> </param> <param> - <key>access_code</key> - <value></value> + <key>sensitivity</key> + <value>fm_sensitivity</value> </param> <param> - <key>threshold</key> - <value>-1</value> + <key>gain_mu</key> + <value>0.175</value> </param> <param> - <key>_coordinate</key> - <value>(705, 130)</value> + <key>mu</key> + <value>0.5</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>omega_relative_limit</key> + <value>0.005</value> </param> - </block> - <block> - <key>gr_quadrature_demod_cf</key> <param> - <key>id</key> - <value>gr_quadrature_demod_cf_0</value> + <key>freq_error</key> + <value>0.0</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>verbose</key> + <value>False</value> </param> <param> - <key>gain</key> - <value>1</value> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(627, 417)</value> + <value>(670, 253)</value> </param> <param> <key>_rotation</key> @@ -387,58 +435,42 @@ </param> </block> <block> - <key>options</key> + <key>blks2_packet_encoder</key> <param> <key>id</key> - <value>gfsk_loopback</value> + <value>blks2_packet_encoder_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>type</key> + <value>float</value> </param> <param> - <key>generate_options</key> - <value>wx_gui</value> + <key>samples_per_symbol</key> + <value>sps</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>bits_per_symbol</key> + <value>1</value> </param> <param> - <key>run_options</key> - <value>prompt</value> + <key>access_code</key> + <value></value> </param> <param> - <key>run</key> + <key>pad_for_usrp</key> <value>True</value> </param> <param> - <key>max_nouts</key> + <key>payload_length</key> <value>0</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(237, 261)</value> </param> <param> <key>_rotation</key> @@ -446,74 +478,57 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>digital_gmsk_mod</key> <param> <key>id</key> - <value>wxgui_scopesink2_0</value> + <value>digital_gmsk_mod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>title</key> - <value>Scope Plot</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>v_scale</key> - <value>0</value> - </param> - <param> - <key>v_offset</key> - <value>0</value> + <key>samples_per_symbol</key> + <value>2</value> </param> <param> - <key>t_scale</key> - <value>1./freq</value> + <key>bt</key> + <value>0.35</value> </param> <param> - <key>ac_couple</key> + <key>verbose</key> <value>False</value> </param> <param> - <key>xy_mode</key> + <key>log</key> <value>False</value> </param> <param> - <key>num_inputs</key> - <value>1</value> - </param> - <param> - <key>win_size</key> - <value></value> + <key>_coordinate</key> + <value>(342, 457)</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>gr_quadrature_demod_cf</key> <param> - <key>notebook</key> - <value></value> + <key>id</key> + <value>gr_quadrature_demod_cf_0</value> </param> <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>y_axis_label</key> - <value>Counts</value> + <key>gain</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(907, 59)</value> + <value>(679, 402)</value> </param> <param> <key>_rotation</key> @@ -521,10 +536,10 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>blks2_packet_decoder</key> <param> <key>id</key> - <value>wxgui_scopesink2_1</value> + <value>blks2_packet_decoder_0</value> </param> <param> <key>_enabled</key> @@ -535,60 +550,63 @@ <value>float</value> </param> <param> - <key>title</key> - <value>Scope Plot</value> + <key>access_code</key> + <value></value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>threshold</key> + <value>-1</value> </param> <param> - <key>v_scale</key> - <value>0</value> + <key>_coordinate</key> + <value>(720, 130)</value> </param> <param> - <key>v_offset</key> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>digital_gmsk_demod</key> <param> - <key>t_scale</key> - <value>0</value> + <key>id</key> + <value>digital_gmsk_demod_0</value> </param> <param> - <key>ac_couple</key> - <value>False</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>xy_mode</key> - <value>False</value> + <key>samples_per_symbol</key> + <value>2</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>gain_mu</key> + <value>0.175</value> </param> <param> - <key>win_size</key> - <value></value> + <key>mu</key> + <value>0.5</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>omega_relative_limit</key> + <value>0.005</value> </param> <param> - <key>notebook</key> - <value></value> + <key>freq_error</key> + <value>0.0</value> </param> <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <key>verbose</key> + <value>False</value> </param> <param> - <key>y_axis_label</key> - <value>Counts</value> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(853, 400)</value> + <value>(622, 498)</value> </param> <param> <key>_rotation</key> @@ -596,14 +614,14 @@ </param> </block> <connection> - <source_block_id>digital_gfsk_mod_0</source_block_id> - <sink_block_id>digital_gfsk_demod_0</sink_block_id> + <source_block_id>gr_sig_source_x_0</source_block_id> + <sink_block_id>gr_throttle_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_sig_source_x_0</source_block_id> - <sink_block_id>gr_throttle_0_0</sink_block_id> + <source_block_id>blks2_packet_encoder_0</source_block_id> + <sink_block_id>digital_gfsk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -614,8 +632,8 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_packet_encoder_0</source_block_id> - <sink_block_id>digital_gfsk_mod_0</sink_block_id> + <source_block_id>digital_gfsk_mod_0</source_block_id> + <sink_block_id>gr_quadrature_demod_cf_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -626,20 +644,44 @@ <sink_key>0</sink_key> </connection> <connection> + <source_block_id>digital_gfsk_mod_0</source_block_id> + <sink_block_id>digital_gfsk_demod_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> <source_block_id>blks2_packet_decoder_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <sink_block_id>qtgui_time_sink_x_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_gfsk_mod_0</source_block_id> + <source_block_id>gr_quadrature_demod_cf_0</source_block_id> + <sink_block_id>qtgui_time_sink_x_1_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blks2_packet_encoder_0</source_block_id> + <sink_block_id>digital_gmsk_mod_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_gmsk_mod_0</source_block_id> + <sink_block_id>digital_gmsk_demod_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_gmsk_mod_0</source_block_id> <sink_block_id>gr_quadrature_demod_cf_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_quadrature_demod_cf_0</source_block_id> - <sink_block_id>wxgui_scopesink2_1</sink_block_id> + <source_block_id>digital_gmsk_demod_0</source_block_id> + <sink_block_id>blks2_packet_decoder_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gnuradio-core/src/examples/pfb/resampler_demo.grc b/gr-digital/examples/demod/gmsk_loopback.grc index 468636a5cf..84912ac58b 100644 --- a/gnuradio-core/src/examples/pfb/resampler_demo.grc +++ b/gr-digital/examples/demod/gmsk_loopback.grc @@ -1,11 +1,11 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sun Aug 23 11:39:47 2009</timestamp> + <timestamp>Mon Aug 20 19:53:13 2012</timestamp> <block> <key>options</key> <param> <key>id</key> - <value>resampler_demo</value> + <value>gfsk_loopback</value> </param> <param> <key>_enabled</key> @@ -29,17 +29,25 @@ </param> <param> <key>generate_options</key> - <value>wx_gui</value> + <value>qt_gui</value> </param> <param> <key>category</key> <value>Custom</value> </param> <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> <key>run</key> <value>True</value> </param> <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> <key>realtime_scheduling</key> <value></value> </param> @@ -53,22 +61,30 @@ </param> </block> <block> - <key>import</key> + <key>gr_throttle</key> <param> <key>id</key> - <value>import_0</value> + <value>gr_throttle_0_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>import math</value> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(11, 59)</value> + <value>(413, 50)</value> </param> <param> <key>_rotation</key> @@ -79,7 +95,7 @@ <key>variable</key> <param> <key>id</key> - <value>rs_taps</value> + <value>fm_sensitivity</value> </param> <param> <key>_enabled</key> @@ -87,11 +103,11 @@ </param> <param> <key>value</key> - <value>firdes.low_pass(nphases, nphases, frac_bw, 0.5-frac_bw)</value> + <value>1.0</value> </param> <param> <key>_coordinate</key> - <value>(273, 154)</value> + <value>(14, 273)</value> </param> <param> <key>_rotation</key> @@ -99,30 +115,22 @@ </param> </block> <block> - <key>gr_add_const_vxx</key> + <key>variable</key> <param> <key>id</key> - <value>adder</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>const</key> - <value>-1.0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> + <key>value</key> + <value>4</value> </param> <param> <key>_coordinate</key> - <value>(227, 303)</value> + <value>(15, 338)</value> </param> <param> <key>_rotation</key> @@ -130,10 +138,10 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>gr_sig_source_x</key> <param> <key>id</key> - <value>throttle</value> + <value>gr_sig_source_x_0</value> </param> <param> <key>_enabled</key> @@ -144,16 +152,28 @@ <value>float</value> </param> <param> - <key>samples_per_second</key> + <key>samp_rate</key> <value>samp_rate</value> </param> <param> - <key>vlen</key> + <key>waveform</key> + <value>gr.GR_COS_WAVE</value> + </param> + <param> + <key>freq</key> + <value>freq</value> + </param> + <param> + <key>amp</key> <value>1</value> </param> <param> + <key>offset</key> + <value>0</value> + </param> + <param> <key>_coordinate</key> - <value>(227, 493)</value> + <value>(215, 18)</value> </param> <param> <key>_rotation</key> @@ -161,85 +181,88 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>variable</key> <param> <key>id</key> - <value>orig_fft</value> + <value>samp_rate</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>value</key> + <value>32000</value> </param> <param> - <key>title</key> - <value>Original Spectrum</value> + <key>_coordinate</key> + <value>(12, 76)</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable_qtgui_range</key> <param> - <key>baseband_freq</key> - <value>0</value> + <key>id</key> + <value>freq</value> </param> <param> - <key>y_per_div</key> - <value>10</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>y_divs</key> - <value>10</value> + <key>label</key> + <value></value> </param> <param> - <key>ref_level</key> - <value>30</value> + <key>value</key> + <value>500</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>start</key> + <value>0</value> </param> <param> - <key>fft_rate</key> - <value>30</value> + <key>stop</key> + <value>500</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>step</key> + <value>1</value> </param> <param> - <key>average</key> - <value>False</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> + <key>orient</key> + <value>Qt.Horizontal</value> </param> <param> - <key>grid_pos</key> - <value>1, 0, 1, 3</value> + <key>min_len</key> + <value>200</value> </param> <param> - <key>notebook</key> + <key>gui_hint</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(409, 289)</value> + <value>(13, 152)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>qtgui_time_sink_x</key> <param> <key>id</key> - <value>resamp_fft</value> + <value>qtgui_time_sink_x_1</value> </param> <param> <key>_enabled</key> @@ -247,74 +270,42 @@ </param> <param> <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>Resampled Spectrum</value> - </param> - <param> - <key>samp_rate</key> - <value>new_rate</value> - </param> - <param> - <key>baseband_freq</key> - <value>0</value> - </param> - <param> - <key>y_per_div</key> - <value>10</value> - </param> - <param> - <key>y_divs</key> - <value>10</value> + <value>float</value> </param> <param> - <key>ref_level</key> - <value>30</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>fft_size</key> + <key>size</key> <value>1024</value> </param> <param> - <key>fft_rate</key> - <value>30</value> - </param> - <param> - <key>peak_hold</key> - <value>True</value> - </param> - <param> - <key>average</key> - <value>False</value> - </param> - <param> - <key>avg_alpha</key> - <value>0</value> + <key>bw</key> + <value>samp_rate</value> </param> <param> - <key>grid_pos</key> - <value>2, 0, 1, 3</value> + <key>nconnections</key> + <value>1</value> </param> <param> - <key>notebook</key> + <key>gui_hint</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(640, 256)</value> + <value>(906, 122)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>gr_sig_source_x</key> + <key>qtgui_time_sink_x</key> <param> <key>id</key> - <value>tri_source</value> + <value>qtgui_time_sink_x_1_0</value> </param> <param> <key>_enabled</key> @@ -325,28 +316,28 @@ <value>float</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>waveform</key> - <value>gr.GR_TRI_WAVE</value> + <key>size</key> + <value>1024</value> </param> <param> - <key>freq</key> - <value>0.05</value> + <key>bw</key> + <value>samp_rate</value> </param> <param> - <key>amp</key> - <value>2.0</value> + <key>nconnections</key> + <value>1</value> </param> <param> - <key>offset</key> - <value>0</value> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(21, 271)</value> + <value>(888, 386)</value> </param> <param> <key>_rotation</key> @@ -354,53 +345,42 @@ </param> </block> <block> - <key>gr_frequency_modulator_fc</key> + <key>blks2_packet_encoder</key> <param> <key>id</key> - <value>fm_mod</value> + <value>blks2_packet_encoder_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>sensitivity</key> - <value>math.pi</value> + <key>type</key> + <value>float</value> </param> <param> - <key>_coordinate</key> - <value>(411, 493)</value> + <key>samples_per_symbol</key> + <value>sps</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>bits_per_symbol</key> + <value>1</value> </param> - </block> - <block> - <key>blks2_pfb_arb_resampler_ccf</key> <param> - <key>id</key> - <value>resampler</value> + <key>access_code</key> + <value></value> </param> <param> - <key>_enabled</key> + <key>pad_for_usrp</key> <value>True</value> </param> <param> - <key>rate</key> - <value>float(new_rate)/samp_rate</value> - </param> - <param> - <key>taps</key> - <value>rs_taps</value> - </param> - <param> - <key>size</key> - <value>nphases</value> + <key>payload_length</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(641, 477)</value> + <value>(237, 261)</value> </param> <param> <key>_rotation</key> @@ -408,22 +388,22 @@ </param> </block> <block> - <key>variable</key> + <key>gr_quadrature_demod_cf</key> <param> <key>id</key> - <value>nphases</value> + <value>gr_quadrature_demod_cf_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>32</value> + <key>gain</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(185, 153)</value> + <value>(679, 402)</value> </param> <param> <key>_rotation</key> @@ -431,42 +411,30 @@ </param> </block> <block> - <key>variable_static_text</key> + <key>blks2_packet_decoder</key> <param> <key>id</key> - <value>samp_rate</value> + <value>blks2_packet_decoder_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Sample Rate</value> - </param> - <param> - <key>value</key> - <value>44100</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>formatter</key> - <value>None</value> + <key>type</key> + <value>float</value> </param> <param> - <key>grid_pos</key> - <value>0, 0, 1, 1</value> + <key>access_code</key> + <value></value> </param> <param> - <key>notebook</key> - <value></value> + <key>threshold</key> + <value>-1</value> </param> <param> <key>_coordinate</key> - <value>(179, 14)</value> + <value>(720, 130)</value> </param> <param> <key>_rotation</key> @@ -474,42 +442,34 @@ </param> </block> <block> - <key>variable_static_text</key> + <key>digital_gmsk_mod</key> <param> <key>id</key> - <value>new_rate</value> + <value>digital_gmsk_mod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Resampled Rate</value> - </param> - <param> - <key>value</key> - <value>48000</value> + <key>samples_per_symbol</key> + <value>2</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>bt</key> + <value>0.35</value> </param> <param> - <key>formatter</key> - <value>None</value> - </param> - <param> - <key>grid_pos</key> - <value>0, 1, 1, 1</value> + <key>verbose</key> + <value>False</value> </param> <param> - <key>notebook</key> - <value></value> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(328, 15)</value> + <value>(446, 285)</value> </param> <param> <key>_rotation</key> @@ -517,42 +477,46 @@ </param> </block> <block> - <key>variable_static_text</key> + <key>digital_gmsk_demod</key> <param> <key>id</key> - <value>frac_bw</value> + <value>digital_gmsk_demod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Fractional Bandwidth</value> + <key>samples_per_symbol</key> + <value>2</value> </param> <param> - <key>value</key> - <value>0.45</value> + <key>gain_mu</key> + <value>0.175</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>mu</key> + <value>0.5</value> </param> <param> - <key>formatter</key> - <value>lambda x: "%0.2f"%x</value> + <key>omega_relative_limit</key> + <value>0.005</value> </param> <param> - <key>grid_pos</key> - <value>0,2,1,1</value> + <key>freq_error</key> + <value>0.0</value> </param> <param> - <key>notebook</key> - <value></value> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(473, 14)</value> + <value>(666, 261)</value> </param> <param> <key>_rotation</key> @@ -560,38 +524,50 @@ </param> </block> <connection> - <source_block_id>tri_source</source_block_id> - <sink_block_id>adder</sink_block_id> + <source_block_id>gr_sig_source_x_0</source_block_id> + <sink_block_id>gr_throttle_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_throttle_0_0</source_block_id> + <sink_block_id>blks2_packet_encoder_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blks2_packet_decoder_0</source_block_id> + <sink_block_id>qtgui_time_sink_x_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>adder</source_block_id> - <sink_block_id>throttle</sink_block_id> + <source_block_id>gr_quadrature_demod_cf_0</source_block_id> + <sink_block_id>qtgui_time_sink_x_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>resampler</source_block_id> - <sink_block_id>resamp_fft</sink_block_id> + <source_block_id>blks2_packet_encoder_0</source_block_id> + <sink_block_id>digital_gmsk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>fm_mod</source_block_id> - <sink_block_id>resampler</sink_block_id> + <source_block_id>digital_gmsk_mod_0</source_block_id> + <sink_block_id>digital_gmsk_demod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>fm_mod</source_block_id> - <sink_block_id>orig_fft</sink_block_id> + <source_block_id>digital_gmsk_mod_0</source_block_id> + <sink_block_id>gr_quadrature_demod_cf_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>throttle</source_block_id> - <sink_block_id>fm_mod</sink_block_id> + <source_block_id>digital_gmsk_demod_0</source_block_id> + <sink_block_id>blks2_packet_decoder_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/mpsk_demod.grc b/gr-digital/examples/demod/mpsk_demod.grc index b718fb68af..61391de545 100644 --- a/gr-digital/examples/demod/mpsk_demod.grc +++ b/gr-digital/examples/demod/mpsk_demod.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 16:28:45 2012</timestamp> + <timestamp>Mon Aug 20 19:51:38 2012</timestamp> <block> <key>options</key> <param> @@ -29,7 +29,7 @@ </param> <param> <key>generate_options</key> - <value>wx_gui</value> + <value>qt_gui</value> </param> <param> <key>category</key> @@ -84,45 +84,18 @@ </param> </block> <block> - <key>variable</key> - <param> - <key>id</key> - <value>samps_per_sym</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>4</value> - </param> - <param> - <key>_coordinate</key> - <value>(7, 89)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_slider</key> + <key>random_source_x</key> <param> <key>id</key> - <value>noise</value> + <value>random_source_x_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Noise</value> - </param> - <param> - <key>value</key> - <value>.1</value> + <key>type</key> + <value>byte</value> </param> <param> <key>min</key> @@ -130,31 +103,19 @@ </param> <param> <key>max</key> - <value>1</value> - </param> - <param> - <key>num_steps</key> - <value>100</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> + <value>2**8</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>num_samps</key> + <value>10000</value> </param> <param> - <key>notebook</key> - <value></value> + <key>repeat</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(259, 353)</value> + <value>(161, 119)</value> </param> <param> <key>_rotation</key> @@ -162,54 +123,42 @@ </param> </block> <block> - <key>variable_slider</key> + <key>digital_dxpsk_mod</key> <param> <key>id</key> - <value>freq_off</value> + <value>digital_dxpsk_mod_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Freq Offset</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>-.5</value> - </param> - <param> - <key>max</key> - <value>.5</value> + <key>type</key> + <value>dqpsk</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>samples_per_symbol</key> + <value>samps_per_sym</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>excess_bw</key> + <value>0.35</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>mod_code</key> + <value>"gray"</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>verbose</key> + <value>False</value> </param> <param> - <key>notebook</key> - <value></value> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(126, 345)</value> + <value>(361, 119)</value> </param> <param> <key>_rotation</key> @@ -217,34 +166,22 @@ </param> </block> <block> - <key>notebook</key> + <key>variable</key> <param> <key>id</key> - <value>notebook</value> + <value>samps_per_sym</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>style</key> - <value>wx.NB_TOP</value> - </param> - <param> - <key>labels</key> - <value>['Constellation', 'Spectrum']</value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> + <key>value</key> + <value>4</value> </param> <param> <key>_coordinate</key> - <value>(520, 407)</value> + <value>(12, 99)</value> </param> <param> <key>_rotation</key> @@ -252,78 +189,54 @@ </param> </block> <block> - <key>wxgui_constellationsink2</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>wxgui_constellationsink2_0</value> + <value>freq_off</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value>Constellation Plot</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>frame_rate</key> - <value>5</value> - </param> - <param> - <key>const_size</key> - <value>2048</value> - </param> - <param> - <key>M</key> - <value>4</value> + <key>label</key> + <value>Freq. Offset</value> </param> <param> - <key>theta</key> + <key>value</key> <value>0</value> </param> <param> - <key>loop_bw</key> - <value>6.28/100.0</value> - </param> - <param> - <key>fmax</key> - <value>0.06</value> + <key>start</key> + <value>-0.5</value> </param> <param> - <key>mu</key> + <key>stop</key> <value>0.5</value> </param> <param> - <key>gain_mu</key> - <value>0.005</value> + <key>step</key> + <value>0.01</value> </param> <param> - <key>symbol_rate</key> - <value>samp_rate/4.</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>omega_limit</key> - <value>0.005</value> + <key>orient</key> + <value>Qt.Horizontal</value> </param> <param> - <key>win_size</key> - <value></value> + <key>min_len</key> + <value>200</value> </param> <param> - <key>grid_pos</key> + <key>gui_hint</key> <value></value> </param> <param> - <key>notebook</key> - <value>notebook, 0</value> - </param> - <param> <key>_coordinate</key> - <value>(824, 212)</value> + <value>(17, 260)</value> </param> <param> <key>_rotation</key> @@ -331,90 +244,101 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>wxgui_fftsink2_0</value> + <value>noise</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>label</key> + <value>Noise</value> </param> <param> - <key>title</key> - <value>FFT Plot</value> + <key>value</key> + <value>0.1</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>start</key> + <value>0</value> </param> <param> - <key>baseband_freq</key> - <value>0</value> + <key>stop</key> + <value>1</value> </param> <param> - <key>y_per_div</key> - <value>10</value> + <key>step</key> + <value>0.01</value> </param> <param> - <key>y_divs</key> - <value>10</value> + <key>widget</key> + <value>counter_slider</value> </param> <param> - <key>ref_level</key> - <value>50</value> + <key>orient</key> + <value>Qt.Horizontal</value> </param> <param> - <key>ref_scale</key> - <value>2.0</value> + <key>min_len</key> + <value>200</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>gui_hint</key> + <value></value> </param> <param> - <key>fft_rate</key> - <value>30</value> + <key>_coordinate</key> + <value>(146, 262)</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>qtgui_tab_widget</key> <param> - <key>average</key> - <value>False</value> + <key>id</key> + <value>notebook</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>win</key> - <value>None</value> + <key>num_tabs</key> + <value>2</value> </param> <param> - <key>win_size</key> - <value></value> + <key>label0</key> + <value>Constellation</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>label1</key> + <value>Spectrum</value> + </param> + <param> + <key>label2</key> + <value>Tab 2</value> + </param> + <param> + <key>label3</key> + <value>Tab 3</value> </param> <param> - <key>notebook</key> - <value>notebook, 1</value> + <key>label4</key> + <value>Tab 4</value> </param> <param> - <key>freqvar</key> - <value>None</value> + <key>gui_hint</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(847, 10)</value> + <value>(21, 394)</value> </param> <param> <key>_rotation</key> @@ -422,10 +346,10 @@ </param> </block> <block> - <key>gr_channel_model</key> + <key>channel_model</key> <param> <key>id</key> - <value>gr_channel_model_0</value> + <value>channel_model_0</value> </param> <param> <key>_enabled</key> @@ -449,11 +373,11 @@ </param> <param> <key>seed</key> - <value>42</value> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(487, 282)</value> + <value>(369, 264)</value> </param> <param> <key>_rotation</key> @@ -484,7 +408,7 @@ </param> <param> <key>_coordinate</key> - <value>(633, 82)</value> + <value>(597, 142)</value> </param> <param> <key>_rotation</key> @@ -492,10 +416,10 @@ </param> </block> <block> - <key>random_source_x</key> + <key>qtgui_const_sink_x</key> <param> <key>id</key> - <value>random_source_x_0</value> + <value>qtgui_const_sink_x_0</value> </param> <param> <key>_enabled</key> @@ -503,27 +427,27 @@ </param> <param> <key>type</key> - <value>byte</value> + <value>complex</value> </param> <param> - <key>min</key> - <value>0</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>max</key> - <value>2**8</value> + <key>size</key> + <value>1024</value> </param> <param> - <key>num_samps</key> - <value>10000</value> + <key>nconnections</key> + <value>1</value> </param> <param> - <key>repeat</key> - <value>True</value> + <key>gui_hint</key> + <value>notebook@0</value> </param> <param> <key>_coordinate</key> - <value>(161, 119)</value> + <value>(810, 184)</value> </param> <param> <key>_rotation</key> @@ -531,10 +455,10 @@ </param> </block> <block> - <key>digital_dxpsk_mod</key> + <key>qtgui_freq_sink_x</key> <param> <key>id</key> - <value>digital_dxpsk_mod_0</value> + <value>qtgui_freq_sink_x_0</value> </param> <param> <key>_enabled</key> @@ -542,31 +466,43 @@ </param> <param> <key>type</key> - <value>dqpsk</value> + <value>complex</value> </param> <param> - <key>samples_per_symbol</key> - <value>samps_per_sym</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>excess_bw</key> - <value>0.35</value> + <key>fftsize</key> + <value>1024</value> </param> <param> - <key>gray_coded</key> - <value>True</value> + <key>wintype</key> + <value>firdes.WIN_BLACKMAN_hARRIS</value> </param> <param> - <key>verbose</key> - <value>False</value> + <key>fc</key> + <value>0</value> </param> <param> - <key>log</key> - <value>False</value> + <key>bw</key> + <value>samp_rate</value> + </param> + <param> + <key>rate</key> + <value>10</value> + </param> + <param> + <key>nconnections</key> + <value>1</value> + </param> + <param> + <key>gui_hint</key> + <value>notebook@1</value> </param> <param> <key>_coordinate</key> - <value>(361, 119)</value> + <value>(810, 65)</value> </param> <param> <key>_rotation</key> @@ -574,32 +510,32 @@ </param> </block> <connection> - <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>wxgui_constellationsink2_0</sink_block_id> + <source_block_id>random_source_x_0</source_block_id> + <sink_block_id>digital_dxpsk_mod_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_block_id>digital_dxpsk_mod_0</source_block_id> + <sink_block_id>channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_channel_model_0</source_block_id> + <source_block_id>channel_model_0</source_block_id> <sink_block_id>gr_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_dxpsk_mod_0</source_block_id> - <sink_block_id>gr_channel_model_0</sink_block_id> + <source_block_id>gr_throttle_0</source_block_id> + <sink_block_id>qtgui_freq_sink_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>random_source_x_0</source_block_id> - <sink_block_id>digital_dxpsk_mod_0</sink_block_id> + <source_block_id>gr_throttle_0</source_block_id> + <sink_block_id>qtgui_const_sink_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/pam_sync.grc b/gr-digital/examples/demod/pam_sync.grc index f870a0b067..9c73777585 100644 --- a/gr-digital/examples/demod/pam_sync.grc +++ b/gr-digital/examples/demod/pam_sync.grc @@ -1,59 +1,69 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 17:54:54 2012</timestamp> + <timestamp>Mon Jul 16 21:25:28 2012</timestamp> <block> - <key>options</key> + <key>variable</key> <param> <key>id</key> - <value>top_block</value> + <value>const</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> + <key>value</key> + <value>digital.qpsk_constellation()</value> </param> <param> - <key>author</key> - <value></value> + <key>_coordinate</key> + <value>(336, -2)</value> </param> <param> - <key>description</key> - <value></value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>id</key> + <value>rrctaps</value> </param> <param> - <key>generate_options</key> - <value>wx_gui</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>value</key> + <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), rolloff, int(11*spb*nfilts))</value> </param> <param> - <key>run_options</key> - <value>prompt</value> + <key>_coordinate</key> + <value>(686, -1)</value> </param> <param> - <key>run</key> - <value>True</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>max_nouts</key> - <value>0</value> + <key>id</key> + <value>rolloff</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.35</value> </param> <param> <key>_coordinate</key> - <value>(-1, 0)</value> + <value>(607, -1)</value> </param> <param> <key>_rotation</key> @@ -64,7 +74,7 @@ <key>variable</key> <param> <key>id</key> - <value>const</value> + <value>spb</value> </param> <param> <key>_enabled</key> @@ -72,11 +82,11 @@ </param> <param> <key>value</key> - <value>digital.qpsk_constellation()</value> + <value>4.0</value> </param> <param> <key>_coordinate</key> - <value>(336, -2)</value> + <value>(542, -1)</value> </param> <param> <key>_rotation</key> @@ -87,7 +97,7 @@ <key>variable</key> <param> <key>id</key> - <value>rrctaps</value> + <value>sig_amp</value> </param> <param> <key>_enabled</key> @@ -95,11 +105,11 @@ </param> <param> <key>value</key> - <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), rolloff, int(11*spb*nfilts))</value> + <value>1.0</value> </param> <param> <key>_coordinate</key> - <value>(686, -1)</value> + <value>(861, 0)</value> </param> <param> <key>_rotation</key> @@ -110,7 +120,7 @@ <key>variable</key> <param> <key>id</key> - <value>rolloff</value> + <value>nfilts</value> </param> <param> <key>_enabled</key> @@ -118,11 +128,11 @@ </param> <param> <key>value</key> - <value>0.35</value> + <value>32</value> </param> <param> <key>_coordinate</key> - <value>(607, -1)</value> + <value>(598, 186)</value> </param> <param> <key>_rotation</key> @@ -133,7 +143,7 @@ <key>variable</key> <param> <key>id</key> - <value>spb</value> + <value>samp_rate</value> </param> <param> <key>_enabled</key> @@ -141,11 +151,11 @@ </param> <param> <key>value</key> - <value>4.0</value> + <value>128000</value> </param> <param> <key>_coordinate</key> - <value>(542, -1)</value> + <value>(193, -1)</value> </param> <param> <key>_rotation</key> @@ -153,22 +163,22 @@ </param> </block> <block> - <key>variable</key> + <key>virtual_source</key> <param> <key>id</key> - <value>sig_amp</value> + <value>virtual_source_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>1.0</value> + <key>stream_id</key> + <value>input_signal_probe</value> </param> <param> <key>_coordinate</key> - <value>(861, 0)</value> + <value>(835, 562)</value> </param> <param> <key>_rotation</key> @@ -176,22 +186,38 @@ </param> </block> <block> - <key>virtual_sink</key> + <key>random_source_x</key> <param> <key>id</key> - <value>virtual_sink_0</value> + <value>random_source_x</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>stream_id</key> - <value>input_signal_probe</value> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>const.arity()</value> + </param> + <param> + <key>num_samps</key> + <value>10000000</value> + </param> + <param> + <key>repeat</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(330, 183)</value> + <value>(0, 72)</value> </param> <param> <key>_rotation</key> @@ -199,10 +225,37 @@ </param> </block> <block> - <key>gr_pfb_clock_sync_xxx</key> + <key>digital_costas_loop_cc</key> <param> <key>id</key> - <value>gr_pfb_clock_sync_xxx_0</value> + <value>digital_costas_loop_cc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>w</key> + <value>phase_bw</value> + </param> + <param> + <key>order</key> + <value>4</value> + </param> + <param> + <key>_coordinate</key> + <value>(866, 246)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_pfb_clock_sync_xxx</key> + <param> + <key>id</key> + <value>digital_pfb_clock_sync_xxx_0</value> </param> <param> <key>_enabled</key> @@ -234,7 +287,7 @@ </param> <param> <key>init_phase</key> - <value>16</value> + <value>nfilts/2</value> </param> <param> <key>max_dev</key> @@ -246,7 +299,7 @@ </param> <param> <key>_coordinate</key> - <value>(598, 241)</value> + <value>(601, 254)</value> </param> <param> <key>_rotation</key> @@ -254,10 +307,10 @@ </param> </block> <block> - <key>digital_fll_band_edge_cc</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>digital_fll_band_edge_cc_0</value> + <value>wxgui_scopesink2_0</value> </param> <param> <key>_enabled</key> @@ -265,73 +318,63 @@ </param> <param> <key>type</key> - <value>cc</value> - </param> - <param> - <key>samps_per_sym</key> - <value>spb</value> + <value>complex</value> </param> <param> - <key>rolloff</key> - <value>rolloff</value> + <key>title</key> + <value>Post-sync Signal</value> </param> <param> - <key>filter_size</key> - <value>44</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>w</key> - <value>freq_bw</value> + <key>v_scale</key> + <value>0</value> </param> <param> - <key>_coordinate</key> - <value>(331, 239)</value> + <key>v_offset</key> + <value>0</value> </param> <param> - <key>_rotation</key> + <key>t_scale</key> <value>0</value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>nfilts</value> + <key>ac_couple</key> + <value>False</value> </param> <param> - <key>_enabled</key> + <key>xy_mode</key> <value>True</value> </param> <param> - <key>value</key> - <value>32</value> + <key>num_inputs</key> + <value>1</value> </param> <param> - <key>_coordinate</key> - <value>(598, 186)</value> + <key>win_size</key> + <value></value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>grid_pos</key> + <value></value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>samp_rate</value> + <key>notebook</key> + <value>notebook_0,0</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> </param> <param> - <key>value</key> - <value>128000</value> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(193, -1)</value> + <value>(1094, 202)</value> </param> <param> <key>_rotation</key> @@ -339,18 +382,22 @@ </param> </block> <block> - <key>random_source_x</key> + <key>variable_slider</key> <param> <key>id</key> - <value>random_source_x</value> + <value>noise_amp</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> + <key>label</key> + <value>Channel Noise</value> + </param> + <param> + <key>value</key> + <value>0</value> </param> <param> <key>min</key> @@ -358,19 +405,31 @@ </param> <param> <key>max</key> - <value>const.arity()</value> + <value>1.0</value> </param> <param> - <key>num_samps</key> - <value>10000000</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>repeat</key> - <value>True</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>(1,2,1,1)</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(0, 72)</value> + <value>(152, 373)</value> </param> <param> <key>_rotation</key> @@ -378,69 +437,89 @@ </param> </block> <block> - <key>gr_chunks_to_symbols_xx</key> + <key>variable_slider</key> <param> <key>id</key> - <value>gr_chunks_to_symbols_xx</value> + <value>interpratio</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>in_type</key> - <value>byte</value> + <key>label</key> + <value>Timing Offset</value> </param> <param> - <key>out_type</key> - <value>complex</value> + <key>value</key> + <value>1.00</value> </param> <param> - <key>symbol_table</key> - <value>const.points()</value> + <key>min</key> + <value>0.99</value> </param> <param> - <key>dimension</key> - <value>1</value> + <key>max</key> + <value>1.01</value> </param> <param> - <key>num_ports</key> - <value>1</value> + <key>num_steps</key> + <value>1000</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>(3,2,1,1)</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(196, 87)</value> + <value>(11, 517)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>blks2_pfb_arb_resampler_ccf</key> + <key>notebook</key> <param> <key>id</key> - <value>blks2_pfb_arb_resampler_ccf_0</value> + <value>notebook_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>rate</key> - <value>spb</value> + <key>style</key> + <value>wx.NB_TOP</value> </param> <param> - <key>taps</key> - <value>firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32)</value> + <key>labels</key> + <value>['Synched Signal', 'Received Signal']</value> </param> <param> - <key>size</key> - <value>32</value> + <key>grid_pos</key> + <value>(1,1,8,1)</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(435, 80)</value> + <value>(9, 664)</value> </param> <param> <key>_rotation</key> @@ -448,38 +527,54 @@ </param> </block> <block> - <key>gr_channel_model</key> + <key>variable_slider</key> <param> <key>id</key> - <value>gr_channel_model_0</value> + <value>freq_offset</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>noise_voltage</key> - <value>noise_amp</value> + <key>label</key> + <value>Frequency Offset</value> </param> <param> - <key>freq_offset</key> - <value>freq_offset</value> + <key>value</key> + <value>0</value> </param> <param> - <key>epsilon</key> - <value>interpratio</value> + <key>min</key> + <value>-0.5</value> </param> <param> - <key>taps</key> - <value>1.0</value> + <key>max</key> + <value>0.5</value> </param> <param> - <key>seed</key> - <value>42</value> + <key>num_steps</key> + <value>1000</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value>(2,2,1,1)</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(46, 183)</value> + <value>(13, 372)</value> </param> <param> <key>_rotation</key> @@ -487,30 +582,22 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>virtual_sink</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>virtual_sink_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>const</key> - <value>sig_amp</value> - </param> - <param> - <key>vlen</key> - <value>1</value> + <key>stream_id</key> + <value>input_signal_probe</value> </param> <param> <key>_coordinate</key> - <value>(659, 95)</value> + <value>(330, 183)</value> </param> <param> <key>_rotation</key> @@ -518,10 +605,10 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>digital_fll_band_edge_cc</key> <param> <key>id</key> - <value>gr_throttle_0</value> + <value>digital_fll_band_edge_cc_0</value> </param> <param> <key>_enabled</key> @@ -529,19 +616,27 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>cc</value> </param> <param> - <key>samples_per_second</key> - <value>samp_rate</value> + <key>samps_per_sym</key> + <value>spb</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>rolloff</key> + <value>rolloff</value> + </param> + <param> + <key>filter_size</key> + <value>44</value> + </param> + <param> + <key>w</key> + <value>freq_bw</value> </param> <param> <key>_coordinate</key> - <value>(857, 95)</value> + <value>(331, 239)</value> </param> <param> <key>_rotation</key> @@ -549,49 +644,38 @@ </param> </block> <block> - <key>virtual_source</key> + <key>channel_model</key> <param> <key>id</key> - <value>virtual_source_0</value> + <value>channel_model_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>stream_id</key> - <value>input_signal_probe</value> - </param> - <param> - <key>_coordinate</key> - <value>(835, 562)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> + <key>noise_voltage</key> + <value>noise_amp</value> </param> - </block> - <block> - <key>digital_costas_loop_cc</key> <param> - <key>id</key> - <value>digital_costas_loop_cc_0</value> + <key>freq_offset</key> + <value>freq_offset</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>epsilon</key> + <value>interpratio</value> </param> <param> - <key>w</key> - <value>phase_bw</value> + <key>taps</key> + <value>1.0</value> </param> <param> - <key>order</key> - <value>4</value> + <key>seed</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(866, 246)</value> + <value>(77, 183)</value> </param> <param> <key>_rotation</key> @@ -599,74 +683,54 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>variable_slider</key> <param> <key>id</key> - <value>wxgui_scopesink2_0_0_1</value> + <value>phase_bw</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>Pre-sync Signal</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>v_scale</key> - <value>.5</value> + <key>label</key> + <value>Costas Loop (Phase) Bandwidth</value> </param> <param> - <key>v_offset</key> + <key>value</key> <value>0</value> </param> <param> - <key>t_scale</key> + <key>min</key> <value>0</value> </param> <param> - <key>ac_couple</key> - <value>False</value> + <key>max</key> + <value>0.1</value> </param> <param> - <key>xy_mode</key> - <value>False</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> </param> <param> - <key>win_size</key> - <value></value> + <key>converver</key> + <value>float_converter</value> </param> <param> <key>grid_pos</key> - <value></value> + <value>(7,2,1,1)</value> </param> <param> <key>notebook</key> - <value>notebook_0,1</value> - </param> - <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> - </param> - <param> - <key>y_axis_label</key> - <value>Counts</value> + <value></value> </param> <param> <key>_coordinate</key> - <value>(1081, 439)</value> + <value>(866, 318)</value> </param> <param> <key>_rotation</key> @@ -674,10 +738,10 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>wxgui_fftsink2_0</value> + <value>wxgui_scopesink2_0_0_1</value> </param> <param> <key>_enabled</key> @@ -689,55 +753,35 @@ </param> <param> <key>title</key> - <value>Received spectrum</value> + <value>Pre-sync Signal</value> </param> <param> <key>samp_rate</key> <value>samp_rate</value> </param> <param> - <key>baseband_freq</key> - <value>0</value> - </param> - <param> - <key>y_per_div</key> - <value>10</value> - </param> - <param> - <key>y_divs</key> - <value>10</value> - </param> - <param> - <key>ref_level</key> - <value>10</value> - </param> - <param> - <key>ref_scale</key> - <value>2.0</value> + <key>v_scale</key> + <value>.5</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>v_offset</key> + <value>0</value> </param> <param> - <key>fft_rate</key> - <value>30</value> + <key>t_scale</key> + <value>0</value> </param> <param> - <key>peak_hold</key> + <key>ac_couple</key> <value>False</value> </param> <param> - <key>average</key> + <key>xy_mode</key> <value>False</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> - </param> - <param> - <key>win</key> - <value>None</value> + <key>num_inputs</key> + <value>1</value> </param> <param> <key>win_size</key> @@ -752,12 +796,16 @@ <value>notebook_0,1</value> </param> <param> - <key>freqvar</key> - <value>None</value> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> + </param> + <param> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(1081, 563)</value> + <value>(1086, 441)</value> </param> <param> <key>_rotation</key> @@ -768,7 +816,7 @@ <key>wxgui_fftsink2</key> <param> <key>id</key> - <value>wxgui_fftsink2_0_0</value> + <value>wxgui_fftsink2_0</value> </param> <param> <key>_enabled</key> @@ -780,7 +828,7 @@ </param> <param> <key>title</key> - <value>Post-sync spectrum</value> + <value>Received spectrum</value> </param> <param> <key>samp_rate</key> @@ -840,7 +888,7 @@ </param> <param> <key>notebook</key> - <value>notebook_0,0</value> + <value>notebook_0,1</value> </param> <param> <key>freqvar</key> @@ -848,82 +896,62 @@ </param> <param> <key>_coordinate</key> - <value>(347, 516)</value> + <value>(1086, 565)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>variable_slider</key> <param> <key>id</key> - <value>wxgui_scopesink2_0</value> + <value>time_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>Post-sync Signal</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>v_scale</key> - <value>0</value> + <key>label</key> + <value>Timing Alpha</value> </param> <param> - <key>v_offset</key> + <key>value</key> <value>0</value> </param> <param> - <key>t_scale</key> + <key>min</key> <value>0</value> </param> <param> - <key>ac_couple</key> - <value>False</value> + <key>max</key> + <value>1</value> </param> <param> - <key>xy_mode</key> - <value>True</value> + <key>num_steps</key> + <value>1000</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> </param> <param> - <key>win_size</key> - <value></value> + <key>converver</key> + <value>float_converter</value> </param> <param> <key>grid_pos</key> - <value></value> + <value>(5,2,1,1)</value> </param> <param> <key>notebook</key> - <value>notebook_0,0</value> - </param> - <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> - </param> - <param> - <key>y_axis_label</key> - <value>Counts</value> + <value></value> </param> <param> <key>_coordinate</key> - <value>(1085, 213)</value> + <value>(557, 431)</value> </param> <param> <key>_rotation</key> @@ -934,7 +962,7 @@ <key>variable_slider</key> <param> <key>id</key> - <value>freq_bw</value> + <value>time_beta</value> </param> <param> <key>_enabled</key> @@ -942,7 +970,7 @@ </param> <param> <key>label</key> - <value>FLL Bandwidth</value> + <value>Timing Beta</value> </param> <param> <key>value</key> @@ -954,7 +982,7 @@ </param> <param> <key>max</key> - <value>0.05</value> + <value>0.1</value> </param> <param> <key>num_steps</key> @@ -970,7 +998,7 @@ </param> <param> <key>grid_pos</key> - <value>(4,2,1,1)</value> + <value>(6,2,1,1)</value> </param> <param> <key>notebook</key> @@ -978,7 +1006,7 @@ </param> <param> <key>_coordinate</key> - <value>(341, 373)</value> + <value>(694, 430)</value> </param> <param> <key>_rotation</key> @@ -989,7 +1017,7 @@ <key>variable_slider</key> <param> <key>id</key> - <value>time_alpha</value> + <value>freq_bw</value> </param> <param> <key>_enabled</key> @@ -997,7 +1025,7 @@ </param> <param> <key>label</key> - <value>Timing Alpha</value> + <value>FLL Bandwidth</value> </param> <param> <key>value</key> @@ -1005,11 +1033,11 @@ </param> <param> <key>min</key> - <value>0</value> + <value>0.0</value> </param> <param> <key>max</key> - <value>1</value> + <value>0.05</value> </param> <param> <key>num_steps</key> @@ -1025,7 +1053,7 @@ </param> <param> <key>grid_pos</key> - <value>(5,2,1,1)</value> + <value>(4,2,1,1)</value> </param> <param> <key>notebook</key> @@ -1033,152 +1061,129 @@ </param> <param> <key>_coordinate</key> - <value>(598, 388)</value> + <value>(154, 517)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>variable_slider</key> + <key>wxgui_fftsink2</key> <param> <key>id</key> - <value>time_beta</value> + <value>wxgui_fftsink2_0_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Timing Beta</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0.0</value> - </param> - <param> - <key>max</key> - <value>0.1</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>title</key> + <value>Post-sync spectrum</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>baseband_freq</key> + <value>0</value> </param> <param> - <key>grid_pos</key> - <value>(6,2,1,1)</value> + <key>y_per_div</key> + <value>10</value> </param> <param> - <key>notebook</key> - <value></value> + <key>y_divs</key> + <value>10</value> </param> <param> - <key>_coordinate</key> - <value>(708, 388)</value> + <key>ref_level</key> + <value>10</value> </param> <param> - <key>_rotation</key> - <value>180</value> + <key>ref_scale</key> + <value>2.0</value> </param> - </block> - <block> - <key>variable_slider</key> <param> - <key>id</key> - <value>phase_bw</value> + <key>fft_size</key> + <value>1024</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>fft_rate</key> + <value>30</value> </param> <param> - <key>label</key> - <value>Costas Loop (Phase) Bandwidth</value> + <key>peak_hold</key> + <value>False</value> </param> <param> - <key>value</key> - <value>0</value> + <key>average</key> + <value>False</value> </param> <param> - <key>min</key> + <key>avg_alpha</key> <value>0</value> </param> <param> - <key>max</key> - <value>0.1</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>win</key> + <value>None</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>win_size</key> + <value></value> </param> <param> <key>grid_pos</key> - <value>(7,2,1,1)</value> + <value></value> </param> <param> <key>notebook</key> - <value></value> + <value>notebook_0,0</value> + </param> + <param> + <key>freqvar</key> + <value>None</value> </param> <param> <key>_coordinate</key> - <value>(866, 313)</value> + <value>(349, 422)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>notebook</key> + <key>gr_multiply_const_vxx</key> <param> <key>id</key> - <value>notebook_0</value> + <value>gr_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>style</key> - <value>wx.NB_TOP</value> - </param> - <param> - <key>labels</key> - <value>['Synched Signal', 'Received Signal']</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>grid_pos</key> - <value>(1,1,8,1)</value> + <key>const</key> + <value>sig_amp</value> </param> <param> - <key>notebook</key> - <value></value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(9, 601)</value> + <value>(763, 96)</value> </param> <param> <key>_rotation</key> @@ -1186,109 +1191,104 @@ </param> </block> <block> - <key>variable_slider</key> + <key>gr_throttle</key> <param> <key>id</key> - <value>interpratio</value> + <value>gr_throttle_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Timing Offset</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>value</key> - <value>1.00</value> + <key>samples_per_second</key> + <value>samp_rate</value> </param> <param> - <key>min</key> - <value>0.99</value> + <key>vlen</key> + <value>1</value> </param> <param> - <key>max</key> - <value>1.01</value> + <key>_coordinate</key> + <value>(961, 96)</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>pfb_arb_resampler_xxx</key> + <param> + <key>id</key> + <value>pfb_arb_resampler_xxx_0</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>type</key> + <value>ccf</value> </param> <param> - <key>grid_pos</key> - <value>(3,2,1,1)</value> + <key>rrate</key> + <value>spb</value> </param> <param> - <key>notebook</key> - <value></value> + <key>taps</key> + <value>firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32)</value> + </param> + <param> + <key>nfilts</key> + <value>32</value> </param> <param> <key>_coordinate</key> - <value>(60, 407)</value> + <value>(468, 72)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>variable_slider</key> + <key>digital_chunks_to_symbols_xx</key> <param> <key>id</key> - <value>noise_amp</value> + <value>digital_chunks_to_symbols_xx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Channel Noise</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0</value> - </param> - <param> - <key>max</key> - <value>1.0</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> + <key>in_type</key> + <value>byte</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>out_type</key> + <value>complex</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>symbol_table</key> + <value>const.points()</value> </param> <param> - <key>grid_pos</key> - <value>(1,2,1,1)</value> + <key>dimension</key> + <value>1</value> </param> <param> - <key>notebook</key> - <value></value> + <key>num_ports</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(125, 284)</value> + <value>(217, 88)</value> </param> <param> <key>_rotation</key> @@ -1296,54 +1296,58 @@ </param> </block> <block> - <key>variable_slider</key> + <key>options</key> <param> <key>id</key> - <value>freq_offset</value> + <value>pam_sync</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Frequency Offset</value> + <key>title</key> + <value></value> </param> <param> - <key>value</key> - <value>0</value> + <key>author</key> + <value></value> </param> <param> - <key>min</key> - <value>-0.5</value> + <key>description</key> + <value></value> </param> <param> - <key>max</key> - <value>0.5</value> + <key>window_size</key> + <value>1280, 1024</value> </param> <param> - <key>num_steps</key> - <value>1000</value> + <key>generate_options</key> + <value>wx_gui</value> </param> <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> + <key>category</key> + <value>Custom</value> </param> <param> - <key>converver</key> - <value>float_converter</value> + <key>run_options</key> + <value>prompt</value> </param> <param> - <key>grid_pos</key> - <value>(2,2,1,1)</value> + <key>run</key> + <value>True</value> </param> <param> - <key>notebook</key> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> <value></value> </param> <param> <key>_coordinate</key> - <value>(6, 284)</value> + <value>(-1, 0)</value> </param> <param> <key>_rotation</key> @@ -1351,80 +1355,80 @@ </param> </block> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>virtual_sink_0</sink_block_id> + <source_block_id>digital_costas_loop_cc_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>digital_fll_band_edge_cc_0</source_block_id> - <sink_block_id>gr_pfb_clock_sync_xxx_0</sink_block_id> + <sink_block_id>wxgui_fftsink2_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>digital_costas_loop_cc_0</sink_block_id> + <source_block_id>virtual_source_0</source_block_id> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_block_id>virtual_source_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0_0_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_pfb_arb_resampler_ccf_0</source_block_id> - <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> + <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <sink_block_id>gr_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_chunks_to_symbols_xx</source_block_id> - <sink_block_id>blks2_pfb_arb_resampler_ccf_0</sink_block_id> + <source_block_id>random_source_x</source_block_id> + <sink_block_id>digital_chunks_to_symbols_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>digital_fll_band_edge_cc_0</sink_block_id> + <source_block_id>digital_fll_band_edge_cc_0</source_block_id> + <sink_block_id>digital_pfb_clock_sync_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_fll_band_edge_cc_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0_0</sink_block_id> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> + <sink_block_id>digital_costas_loop_cc_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>virtual_source_0</source_block_id> - <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>virtual_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>virtual_source_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0_0_1</sink_block_id> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>digital_fll_band_edge_cc_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>random_source_x</source_block_id> - <sink_block_id>gr_chunks_to_symbols_xx</sink_block_id> + <source_block_id>gr_throttle_0</source_block_id> + <sink_block_id>channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>gr_channel_model_0</sink_block_id> + <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> + <sink_block_id>pfb_arb_resampler_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> - <sink_block_id>gr_throttle_0</sink_block_id> + <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> + <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/pam_timing.grc b/gr-digital/examples/demod/pam_timing.grc index 14a7d403e3..17ab0fb8ca 100644 --- a/gr-digital/examples/demod/pam_timing.grc +++ b/gr-digital/examples/demod/pam_timing.grc @@ -1,65 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Jul 5 17:55:51 2012</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>top_block</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>wx_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> + <timestamp>Mon Jul 16 21:25:37 2012</timestamp> <block> <key>gr_uchar_to_float</key> <param> @@ -99,29 +40,6 @@ </param> </block> <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32000</value> - </param> - <param> - <key>_coordinate</key> - <value>(128, 9)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable_slider</key> <param> <key>id</key> @@ -542,61 +460,6 @@ <key>variable_slider</key> <param> <key>id</key> - <value>beta</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Timing Beta</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>min</key> - <value>0.0</value> - </param> - <param> - <key>max</key> - <value>0.1</value> - </param> - <param> - <key>num_steps</key> - <value>1000</value> - </param> - <param> - <key>style</key> - <value>wx.SL_HORIZONTAL</value> - </param> - <param> - <key>converver</key> - <value>float_converter</value> - </param> - <param> - <key>grid_pos</key> - <value></value> - </param> - <param> - <key>notebook</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(668, 5)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>variable_slider</key> - <param> - <key>id</key> <value>alpha</value> </param> <param> @@ -652,7 +515,7 @@ <key>variable</key> <param> <key>id</key> - <value>pam_amp</value> + <value>rrctaps</value> </param> <param> <key>_enabled</key> @@ -660,11 +523,11 @@ </param> <param> <key>value</key> - <value>2</value> + <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, int(11*spb*nfilts))</value> </param> <param> <key>_coordinate</key> - <value>(223, 9)</value> + <value>(513, 679)</value> </param> <param> <key>_rotation</key> @@ -675,7 +538,7 @@ <key>variable</key> <param> <key>id</key> - <value>sig_amp</value> + <value>spb</value> </param> <param> <key>_enabled</key> @@ -683,11 +546,11 @@ </param> <param> <key>value</key> - <value>1</value> + <value>4.2563</value> </param> <param> <key>_coordinate</key> - <value>(315, 9)</value> + <value>(42, 840)</value> </param> <param> <key>_rotation</key> @@ -770,6 +633,61 @@ </param> </block> <block> + <key>digital_pfb_clock_sync_xxx</key> + <param> + <key>id</key> + <value>digital_pfb_clock_sync_xxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>ccf</value> + </param> + <param> + <key>sps</key> + <value>spb</value> + </param> + <param> + <key>alpha</key> + <value>alpha</value> + </param> + <param> + <key>beta</key> + <value>beta</value> + </param> + <param> + <key>taps</key> + <value>rrctaps</value> + </param> + <param> + <key>filter_size</key> + <value>nfilts</value> + </param> + <param> + <key>init_phase</key> + <value>nfilts/2</value> + </param> + <param> + <key>max_dev</key> + <value>1.5</value> + </param> + <param> + <key>osps</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(492, 519)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> <key>gr_throttle</key> <param> <key>id</key> @@ -801,74 +719,96 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>channel_model</key> <param> <key>id</key> - <value>wxgui_scopesink2_0_0_0</value> + <value>channel_model_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> + <key>noise_voltage</key> + <value>noise_amp</value> </param> <param> - <key>title</key> - <value>Scope Plot</value> + <key>freq_offset</key> + <value>freq_offset</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>epsilon</key> + <value>interpratio</value> </param> <param> - <key>v_scale</key> - <value>9</value> + <key>taps</key> + <value>1.0</value> </param> <param> - <key>v_offset</key> + <key>seed</key> <value>0</value> </param> <param> - <key>t_scale</key> + <key>_coordinate</key> + <value>(76, 543)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>gr_float_to_complex</key> <param> - <key>ac_couple</key> - <value>False</value> + <key>id</key> + <value>gr_float_to_complex_0</value> </param> <param> - <key>xy_mode</key> - <value>False</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>num_inputs</key> + <key>vlen</key> <value>1</value> </param> <param> - <key>win_size</key> - <value></value> + <key>_coordinate</key> + <value>(590, 184)</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>pfb_arb_resampler_xxx</key> <param> - <key>notebook</key> - <value>notebook_0,1</value> + <key>id</key> + <value>pfb_arb_resampler_xxx_0</value> </param> <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>y_axis_label</key> - <value>Counts</value> + <key>type</key> + <value>ccf</value> + </param> + <param> + <key>rrate</key> + <value>spb</value> + </param> + <param> + <key>taps</key> + <value>firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32)</value> + </param> + <param> + <key>nfilts</key> + <value>32</value> </param> <param> <key>_coordinate</key> - <value>(1112, 881)</value> + <value>(788, 173)</value> </param> <param> <key>_rotation</key> @@ -876,22 +816,30 @@ </param> </block> <block> - <key>variable</key> + <key>gr_multiply_const_vxx</key> <param> <key>id</key> - <value>rrctaps</value> + <value>gr_multiply_const_vxx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>firdes.root_raised_cosine(nfilts,1.0,1.0/(spb*nfilts), .35, int(11*spb*nfilts))</value> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>const</key> + <value>sig_amp</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(513, 679)</value> + <value>(714, 382)</value> </param> <param> <key>_rotation</key> @@ -914,7 +862,7 @@ </param> <param> <key>title</key> - <value>Error</value> + <value>Transmitted Signal</value> </param> <param> <key>samp_rate</key> @@ -966,7 +914,7 @@ </param> <param> <key>_coordinate</key> - <value>(1115, 358)</value> + <value>(1114, 342)</value> </param> <param> <key>_rotation</key> @@ -974,92 +922,74 @@ </param> </block> <block> - <key>gr_float_to_complex</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>gr_float_to_complex_0</value> + <value>wxgui_scopesink2_0_0_0_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(590, 184)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blks2_pfb_arb_resampler_ccf</key> - <param> - <key>id</key> - <value>blks2_pfb_arb_resampler_ccf_0</value> + <key>type</key> + <value>float</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>title</key> + <value>PFB Rate</value> </param> <param> - <key>rate</key> - <value>spb</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>taps</key> - <value>firdes.root_raised_cosine(32, 32, 1.0, 0.35, 44*32)</value> + <key>v_scale</key> + <value>1.25</value> </param> <param> - <key>size</key> - <value>32</value> + <key>v_offset</key> + <value>0</value> </param> <param> - <key>_coordinate</key> - <value>(816, 181)</value> + <key>t_scale</key> + <value>0</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>ac_couple</key> + <value>False</value> </param> - </block> - <block> - <key>gr_channel_model</key> <param> - <key>id</key> - <value>gr_channel_model_0</value> + <key>xy_mode</key> + <value>False</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>num_inputs</key> + <value>1</value> </param> <param> - <key>noise_voltage</key> - <value>noise_amp</value> + <key>win_size</key> + <value></value> </param> <param> - <key>freq_offset</key> - <value>freq_offset</value> + <key>grid_pos</key> + <value></value> </param> <param> - <key>epsilon</key> - <value>interpratio</value> + <key>notebook</key> + <value>notebook_0,2</value> </param> <param> - <key>taps</key> - <value>1.0</value> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> </param> <param> - <key>seed</key> - <value>42</value> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(59, 543)</value> + <value>(1080, 751)</value> </param> <param> <key>_rotation</key> @@ -1067,10 +997,10 @@ </param> </block> <block> - <key>gr_multiply_const_vxx</key> + <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>gr_multiply_const_vxx_0</value> + <value>wxgui_scopesink2_0_0</value> </param> <param> <key>_enabled</key> @@ -1078,97 +1008,63 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>float</value> </param> <param> - <key>const</key> - <value>sig_amp</value> + <key>title</key> + <value>PFB Error</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>_coordinate</key> - <value>(714, 382)</value> + <key>v_scale</key> + <value>3</value> </param> <param> - <key>_rotation</key> + <key>v_offset</key> <value>0</value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>spb</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>4.2563</value> - </param> - <param> - <key>_coordinate</key> - <value>(42, 840)</value> - </param> - <param> - <key>_rotation</key> + <key>t_scale</key> <value>0</value> </param> - </block> - <block> - <key>gr_pfb_clock_sync_xxx</key> - <param> - <key>id</key> - <value>gr_pfb_clock_sync_xxx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>ccf</value> - </param> <param> - <key>sps</key> - <value>spb</value> + <key>ac_couple</key> + <value>False</value> </param> <param> - <key>alpha</key> - <value>alpha</value> + <key>xy_mode</key> + <value>False</value> </param> <param> - <key>beta</key> - <value>beta</value> + <key>num_inputs</key> + <value>1</value> </param> <param> - <key>taps</key> - <value>rrctaps</value> + <key>win_size</key> + <value></value> </param> <param> - <key>filter_size</key> - <value>nfilts</value> + <key>grid_pos</key> + <value></value> </param> <param> - <key>init_phase</key> - <value>16</value> + <key>notebook</key> + <value>notebook_0,0</value> </param> <param> - <key>max_dev</key> - <value>1.5</value> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> </param> <param> - <key>osps</key> - <value>1</value> + <key>y_axis_label</key> + <value>Counts</value> </param> <param> <key>_coordinate</key> - <value>(512, 527)</value> + <value>(1114, 615)</value> </param> <param> <key>_rotation</key> @@ -1179,7 +1075,7 @@ <key>wxgui_scopesink2</key> <param> <key>id</key> - <value>wxgui_scopesink2_0_0</value> + <value>wxgui_scopesink2_0_0_0</value> </param> <param> <key>_enabled</key> @@ -1191,7 +1087,7 @@ </param> <param> <key>title</key> - <value>Error</value> + <value>PFB Phase</value> </param> <param> <key>samp_rate</key> @@ -1199,7 +1095,7 @@ </param> <param> <key>v_scale</key> - <value>3</value> + <value>9</value> </param> <param> <key>v_offset</key> @@ -1231,7 +1127,7 @@ </param> <param> <key>notebook</key> - <value>notebook_0,0</value> + <value>notebook_0,1</value> </param> <param> <key>trig_mode</key> @@ -1243,7 +1139,7 @@ </param> <param> <key>_coordinate</key> - <value>(1114, 615)</value> + <value>(1112, 881)</value> </param> <param> <key>_rotation</key> @@ -1251,74 +1147,182 @@ </param> </block> <block> - <key>wxgui_scopesink2</key> + <key>variable_slider</key> <param> <key>id</key> - <value>wxgui_scopesink2_0_0_0_0</value> + <value>beta</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> + <key>label</key> + <value>Timing Beta</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>min</key> + <value>0.0</value> + </param> + <param> + <key>max</key> + <value>0.1</value> + </param> + <param> + <key>num_steps</key> + <value>1000</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(673, 5)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>options</key> + <param> + <key>id</key> + <value>pam_timing</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> </param> <param> <key>title</key> - <value>Scope Plot</value> + <value></value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>author</key> + <value></value> </param> <param> - <key>v_scale</key> - <value>1.25</value> + <key>description</key> + <value></value> </param> <param> - <key>v_offset</key> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> <value>0</value> </param> <param> - <key>t_scale</key> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>ac_couple</key> - <value>False</value> + <key>id</key> + <value>pam_amp</value> </param> <param> - <key>xy_mode</key> - <value>False</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>num_inputs</key> - <value>1</value> + <key>value</key> + <value>2</value> </param> <param> - <key>win_size</key> - <value></value> + <key>_coordinate</key> + <value>(277, 12)</value> </param> <param> - <key>grid_pos</key> - <value></value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>notebook</key> - <value>notebook_0,2</value> + <key>id</key> + <value>samp_rate</value> </param> <param> - <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>y_axis_label</key> - <value>Counts</value> + <key>value</key> + <value>32000</value> </param> <param> <key>_coordinate</key> - <value>(1080, 751)</value> + <value>(182, 12)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sig_amp</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(369, 12)</value> </param> <param> <key>_rotation</key> @@ -1362,12 +1366,6 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_channel_model_0</source_block_id> - <sink_block_id>gr_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> <source_block_id>gr_add_xx_0</source_block_id> <sink_block_id>gr_float_to_complex_0</sink_block_id> <source_key>0</source_key> @@ -1380,57 +1378,63 @@ <sink_key>1</sink_key> </connection> <connection> - <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_block_id>gr_multiply_const_vxx_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0_0_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>gr_throttle_0</source_block_id> - <sink_block_id>gr_pfb_clock_sync_xxx_0</sink_block_id> + <sink_block_id>digital_pfb_clock_sync_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> <sink_block_id>wxgui_scopesink2_0_0</sink_block_id> <source_key>1</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0_0_0_0</sink_block_id> + <source_key>2</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_pfb_clock_sync_xxx_0</source_block_id> <sink_block_id>wxgui_scopesink2_0_0_0</sink_block_id> <source_key>3</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_pfb_clock_sync_xxx_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0_0_0_0</sink_block_id> - <source_key>2</source_key> + <source_block_id>channel_model_0</source_block_id> + <sink_block_id>gr_throttle_0</sink_block_id> + <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>gr_multiply_const_vxx_0</source_block_id> - <sink_block_id>wxgui_scopesink2_0_0_1</sink_block_id> + <sink_block_id>channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>gr_float_to_complex_0</source_block_id> - <sink_block_id>blks2_pfb_arb_resampler_ccf_0</sink_block_id> + <sink_block_id>pfb_arb_resampler_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_pfb_arb_resampler_ccf_0</source_block_id> + <source_block_id>pfb_arb_resampler_xxx_0</source_block_id> <sink_block_id>gr_multiply_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> - <connection> - <source_block_id>gr_multiply_const_vxx_0</source_block_id> - <sink_block_id>gr_channel_model_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> </flow_graph> diff --git a/gr-digital/examples/example_costas.py b/gr-digital/examples/example_costas.py index aef0196cc0..afb9657798 100755 --- a/gr-digital/examples/example_costas.py +++ b/gr-digital/examples/example_costas.py @@ -1,6 +1,26 @@ #!/usr/bin/env python - -from gnuradio import gr, digital +# +# Copyright 2011,2012 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. +# + +from gnuradio import gr, digital, filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -28,8 +48,8 @@ class example_costas(gr.top_block): data = scipy.exp(1j*poffset) * data self.src = gr.vector_source_c(data.tolist(), False) - self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = gr.channel_model(noise, foffset, toffset) + self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) + self.chn = filter.channel_model(noise, foffset, toffset) self.cst = digital.costas_loop_cc(bw, 2) self.vsnk_src = gr.vector_sink_c() diff --git a/gr-digital/examples/example_fll.py b/gr-digital/examples/example_fll.py index 3b75b5a758..bcd2ee032b 100755 --- a/gr-digital/examples/example_fll.py +++ b/gr-digital/examples/example_fll.py @@ -1,6 +1,26 @@ #!/usr/bin/env python - -from gnuradio import gr, digital +# +# Copyright 2011,2012 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. +# + +from gnuradio import gr, digital, filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -28,8 +48,8 @@ class example_fll(gr.top_block): data = scipy.exp(1j*poffset) * data self.src = gr.vector_source_c(data.tolist(), False) - self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = gr.channel_model(noise, foffset, toffset) + self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) + self.chn = filter.channel_model(noise, foffset, toffset) self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) self.vsnk_src = gr.vector_sink_c() diff --git a/gr-digital/examples/example_timing.py b/gr-digital/examples/example_timing.py index fd86acfb16..7274773a0f 100755 --- a/gr-digital/examples/example_timing.py +++ b/gr-digital/examples/example_timing.py @@ -1,6 +1,26 @@ #!/usr/bin/env python - -from gnuradio import gr, digital +# +# Copyright 2011,2012 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. +# + +from gnuradio import gr, digital, filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -36,15 +56,15 @@ class example_timing(gr.top_block): data = scipy.exp(1j*poffset) * data self.src = gr.vector_source_c(data.tolist(), False) - self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = gr.channel_model(noise, foffset, toffset) - self.off = gr.fractional_interpolator_cc(0.20, 1.0) + self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) + self.chn = filter.channel_model(noise, foffset, toffset) + self.off = filter.fractional_interpolator_cc(0.20, 1.0) if mode == 0: - self.clk = gr.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx, - nfilts, nfilts//2, 3.5) - self.taps = self.clk.get_taps() - self.dtaps = self.clk.get_diff_taps() + self.clk = digital.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx, + nfilts, nfilts//2, 3.5) + self.taps = self.clk.taps() + self.dtaps = self.clk.diff_taps() self.vsnk_err = gr.vector_sink_f() self.vsnk_rat = gr.vector_sink_f() @@ -164,6 +184,7 @@ def main(): for i,d in enumerate(diff_taps): D = 20.0*scipy.log10(abs(fftpack.fftshift(fftpack.fft(d, 10000)))) + #D = 20.0*scipy.log10(abs(scipy.fft(d, 10000))) s31.plot(t[i::nfilts].real, d, "-o") s32.plot(D) diff --git a/gr-digital/examples/gen_whitener.py b/gr-digital/examples/gen_whitener.py index 9a81e4eaa3..0b1591c3ab 100755 --- a/gr-digital/examples/gen_whitener.py +++ b/gr-digital/examples/gen_whitener.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2011 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. +# from gnuradio import gr, gru from gnuradio.eng_option import eng_option diff --git a/gr-digital/examples/narrowband/benchmark_add_channel.py b/gr-digital/examples/narrowband/benchmark_add_channel.py index 841833a08f..8f2e544fdb 100755 --- a/gr-digital/examples/narrowband/benchmark_add_channel.py +++ b/gr-digital/examples/narrowband/benchmark_add_channel.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -43,8 +43,8 @@ class my_top_block(gr.top_block): self.src = gr.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) - self.channel = gr.channel_model(noise_voltage, frequency_offset, - time_offset, noise_seed=random.randint(0,100000)) + self.channel = filter.channel_model(noise_voltage, frequency_offset, + time_offset, noise_seed=random.randint(0,100000)) self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) diff --git a/gr-digital/examples/narrowband/digital_bert_rx.py b/gr-digital/examples/narrowband/digital_bert_rx.py index daefc5116d..c044b25858 100755 --- a/gr-digital/examples/narrowband/digital_bert_rx.py +++ b/gr-digital/examples/narrowband/digital_bert_rx.py @@ -65,8 +65,9 @@ class bert_receiver(gr.hier_block2): self._bitrate = bitrate - self._demod = digital.generic_demod(constellation, samples_per_symbol, - differential, excess_bw, gray_coded, + self._demod = digital.generic_demod(constellation, differential, + samples_per_symbol, + gray_coded, excess_bw, freq_bw, timing_bw, phase_bw, verbose, log) @@ -74,7 +75,8 @@ class bert_receiver(gr.hier_block2): self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation - self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, alpha=10.0/self._symbol_rate) + self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, 1000, + alpha=10.0/self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits @@ -89,7 +91,7 @@ class bert_receiver(gr.hier_block2): return self._demod.freq_recov.get_frequency()*self._sample_rate/(2*math.pi) def timing_offset(self): - return self._demod.time_recov.get_clock_rate() + return self._demod.time_recov.clock_rate() def snr(self): return self._snr_probe.snr() diff --git a/gr-digital/examples/narrowband/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index 7caccdf42b..ff8bf9f104 100755 --- a/gr-digital/examples/narrowband/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -45,8 +45,9 @@ class bert_transmit(gr.hier_block2): self._bits = gr.vector_source_b([1,], True) # Infinite stream of ones self._scrambler = digital.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler - self._mod = digital.generic_mod(constellation, samples_per_symbol, - differential, excess_bw, gray_coded, + self._mod = digital.generic_mod(constellation, differential, + samples_per_symbol, + gray_coded, excess_bw, verbose, log) self._pack = gr.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST) diff --git a/gr-digital/examples/narrowband/receive_path.py b/gr-digital/examples/narrowband/receive_path.py index 363cb1e240..308f955645 100644 --- a/gr-digital/examples/narrowband/receive_path.py +++ b/gr-digital/examples/narrowband/receive_path.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru +from gnuradio import gr, gru, filter from gnuradio import eng_notation from gnuradio import digital @@ -61,12 +61,12 @@ class receive_path(gr.hier_block2): # Design filter to get actual channel we want sw_decim = 1 - chan_coeffs = gr.firdes.low_pass (1.0, # gain - sw_decim * self.samples_per_symbol(), # sampling rate - self._chbw_factor, # midpoint of trans. band - 0.5, # width of trans. band - gr.firdes.WIN_HANN) # filter type - self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs) + chan_coeffs = filter.firdes.low_pass(1.0, # gain + sw_decim * self.samples_per_symbol(), # sampling rate + self._chbw_factor, # midpoint of trans. band + 0.5, # width of trans. band + gr.firdes.WIN_HANN) # filter type + self.channel_filter = filter.fft_filter_ccc(sw_decim, chan_coeffs) # receiver self.packet_receiver = \ diff --git a/gr-digital/examples/narrowband/tx_voice.py b/gr-digital/examples/narrowband/tx_voice.py index 3d767a0770..1f968fa8a3 100755 --- a/gr-digital/examples/narrowband/tx_voice.py +++ b/gr-digital/examples/narrowband/tx_voice.py @@ -20,11 +20,12 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2, audio, uhd +from gnuradio import gr, audio, uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser +from gnuradio import filter from gnuradio import digital from gnuradio import vocoder @@ -84,7 +85,7 @@ class my_top_block(gr.top_block): self.sink = gr.null_sink(gr.sizeof_gr_complex) rrate = 1 - self.resampler = blks2.pfb_arb_resampler_ccf(rrate) + self.resampler = filter.pfb.arb_resampler_ccf(rrate) self.connect(self.audio_rx) self.connect(self.txpath, self.resampler, self.sink) diff --git a/gr-digital/examples/ofdm/benchmark_add_channel.py b/gr-digital/examples/ofdm/benchmark_add_channel.py index 01776d2093..77862e753f 100755 --- a/gr-digital/examples/ofdm/benchmark_add_channel.py +++ b/gr-digital/examples/ofdm/benchmark_add_channel.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, filter from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -45,7 +45,7 @@ class my_top_block(gr.top_block): self.src = gr.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) - self.channel = gr.channel_model(noise_voltage, frequency_offset, + self.channel = filter.channel_model(noise_voltage, frequency_offset, time_offset, noise_seed=random.randint(0,100000)) self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset), math.sin(phase_offset))) diff --git a/gr-digital/examples/ofdm/benchmark_rx.py b/gr-digital/examples/ofdm/benchmark_rx.py index 57817c5018..f1b65276d0 100755 --- a/gr-digital/examples/ofdm/benchmark_rx.py +++ b/gr-digital/examples/ofdm/benchmark_rx.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2 +from gnuradio import gr from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser diff --git a/gr-digital/examples/ofdm/ofdm_mod_demod_test.py b/gr-digital/examples/ofdm/ofdm_mod_demod_test.py deleted file mode 100755 index b1521da6d7..0000000000 --- a/gr-digital/examples/ofdm/ofdm_mod_demod_test.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2008 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. -# - -from gnuradio import gr, ofdm_packet_utils -import gnuradio.gr.gr_threading as _threading -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import random, time, struct, sys, math, os - -class my_top_block(gr.top_block): - def __init__(self, callback, options): - gr.top_block.__init__(self) - - # hard-coded known symbol - ks1 = known_symbols_4512_1[0:options.occupied_tones] - ks2 = known_symbols_4512_2[0:options.occupied_tones] - - self._rcvd_pktq = gr.msg_queue() - - # accepts messages from the outside world - self.ofdm_mapper = gr.ofdm_bpsk_mapper(4, options.occupied_tones, options.fft_length, ks1, ks2) - self.ofdm_corr = gr.ofdm_correlator(options.occupied_tones, options.fft_length, 0, ks1, ks2) - self.ofdm_framer = gr.ofdm_frame_sink(self._rcvd_pktq, options.occupied_tones) - - if 0: # set to 1 to put the correlator in the path to take over the signalling - self.connect((self.ofdm_mapper, 0), (self.ofdm_corr, 0)) - self.connect((self.ofdm_corr, 0), (self.ofdm_framer, 0)) - self.connect((self.ofdm_corr, 1), (self.ofdm_framer, 1)) - - self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) - self.connect((self.ofdm_corr,0), gr.file_sink(gr.sizeof_gr_complex*options.occupied_tones, "ofdm_corr.dat")) - self.connect((self.ofdm_corr,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) - - else: - self.connect((self.ofdm_mapper, 0), (self.ofdm_framer, 0)) - self.connect((self.ofdm_mapper, 1), (self.ofdm_framer, 1)) - - self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) - self.connect((self.ofdm_mapper,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) - - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) - - def send_pkt(self, payload='', eof=False): - if eof: - msg = gr.message(1) - else: - pkt = ofdm_packet_utils.make_packet(payload, 1, 1, False, whiten=False) - msg = gr.message_from_string(pkt) - self.ofdm_mapper.msgq().insert_tail(msg) - -class _queue_watcher_thread(_threading.Thread): - def __init__(self, rcvd_pktq, callback): - _threading.Thread.__init__(self) - self.setDaemon(1) - self.rcvd_pktq = rcvd_pktq - self.callback = callback - self.keep_running = True - self.start() - - def run(self): - while self.keep_running: - msg = self.rcvd_pktq.delete_head() - ok, payload = ofdm_packet_utils.unmake_packet(msg.to_string(), whiten=False) - if self.callback: - self.callback(ok, payload) - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - ''' Use this program to tie the OFDM modulators straight into the frame sink, with or without - the correlator in between. This is for testing of the modulators and demodulators only without - receiver and sync functionality.''' - - global n_rcvd, n_right - - n_rcvd = 0 - n_right = 0 - - def send_pkt(payload='', eof=False): - return fg.send_pkt(payload, eof) - - def rx_callback(ok, payload): - global n_rcvd, n_right - n_rcvd += 1 - (pktno,) = struct.unpack('!H', payload[0:2]) - if ok: - n_right += 1 - print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) - - printlst = list() - for x in payload[2:]: - t = hex(ord(x)).replace('0x', '') - if(len(t) == 1): - t = '0' + t - printlst.append(t) - printable = ''.join(printlst) - - print printable - print "\n" - - parser = OptionParser(option_class=eng_option, conflict_handler="resolve") - expert = parser.add_option_group("Expert") - parser.add_option("-s", "--size", type="eng_float", default=1450, - help="set packet size [default=%default]") - parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, - help="set megabytes to transmit [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - - (options, args) = parser.parse_args () - - # build the graph - tb = my_top_block(rx_callback, options) - - tb.start() # start flow graph - - # generate and send packets - nbytes = int(1e6 * options.megabytes) - n = 0 - pktno = 0 - pkt_size = int(options.size) - - while n < nbytes: - #r = ''.join([chr(random.randint(0,255)) for i in range(pkt_size-2)]) - #pkt_contents = struct.pack('!H', pktno) + r - - pkt_contents = struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff) - - send_pkt(pkt_contents) - n += pkt_size - pktno += 1 - - send_pkt(eof=True) - tb.wait() # wait for it to finish - -known_symbols_4512_1 = [-1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1] - -known_symbols_4512_2 = [1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1] - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gr-digital/examples/snr_estimators.py b/gr-digital/examples/snr_estimators.py index 432abd4553..e310ec2937 100755 --- a/gr-digital/examples/snr_estimators.py +++ b/gr-digital/examples/snr_estimators.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# Copyright 2011,2012 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. +# import sys @@ -15,7 +35,7 @@ except ImportError: print "Error: Program requires Matplotlib (matplotlib.sourceforge.net)." sys.exit(1) -from gnuradio import gr, digital +from gnuradio import gr, digital, filter from optparse import OptionParser from gnuradio.eng_option import eng_option @@ -147,7 +167,7 @@ def main(): gr_src = gr.vector_source_c(bits.tolist(), False) gr_snr = digital.mpsk_snr_est_cc(gr_est, ntag, 0.001) - gr_chn = gr.channel_model(1.0/scale) + gr_chn = filter.channel_model(1.0/scale) gr_snk = gr.null_sink(gr.sizeof_gr_complex) tb = gr.top_block() tb.connect(gr_src, gr_chn, gr_snr, gr_snk) diff --git a/gr-digital/grc/digital_additive_scrambler_bb.xml b/gr-digital/grc/digital_additive_scrambler_bb.xml index 5ae5ba06f0..2d2fdab355 100644 --- a/gr-digital/grc/digital_additive_scrambler_bb.xml +++ b/gr-digital/grc/digital_additive_scrambler_bb.xml @@ -6,7 +6,7 @@ --> <block> <name>Additive Scrambler</name> - <key>digital_additive_scrambler_bb</key> + <key>additive_scrambler_bb</key> <import>from gnuradio import digital</import> <make>digital.additive_scrambler_bb($mask, $seed, $len, $count)</make> <param> diff --git a/gr-digital/grc/digital_binary_slicer_fb.xml b/gr-digital/grc/digital_binary_slicer_fb.xml index 3187d13f92..8190e02350 100644 --- a/gr-digital/grc/digital_binary_slicer_fb.xml +++ b/gr-digital/grc/digital_binary_slicer_fb.xml @@ -6,7 +6,7 @@ --> <block> <name>Binary Slicer</name> - <key>digital_binary_slicer_fb</key> + <key>binary_slicer_fb</key> <import>from gnuradio import digital</import> <make>digital.binary_slicer_fb()</make> <sink> diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml index 9efa0d3fb5..f8bb3871d6 100644 --- a/gr-digital/grc/digital_block_tree.xml +++ b/gr-digital/grc/digital_block_tree.xml @@ -29,36 +29,53 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Digital</name> + <name>Coding</name> <block>digital_additive_scrambler_bb</block> + <block>digital_descrambler_bb</block> + <block>digital_scrambler_bb</block> + </cat> + <cat> + <name>Converters</name> <block>digital_binary_slicer_fb</block> - <block>digital_bytes_to_syms</block> <block>digital_chunks_to_symbols_xx</block> - <block>digital_clock_recovery_mm_xx</block> - <block>digital_cma_equalizer_cc</block> + <block>digital_diff_decoder_bb</block> + <block>digital_diff_encoder_bb</block> + <block>digital_diff_phasor_cc</block> + <block>digital_map_bb</block> + </cat> + <cat> + <name>Digital</name> <block>digital_constellation_decoder_cb</block> <block>digital_constellation_receiver_cb</block> <block>digital_correlate_access_code_bb</block> - <block>digital_costas_loop_cc</block> - <block>digital_descrambler_bb</block> - <block>digital_fll_band_edge_cc</block> - <block>digital_glfsr_source_x</block> - <block>digital_kurtotic_equalizer_cc</block> - <block>digital_lms_dd_equalizer_cc</block> - <block>digital_map_bb</block> - <block>digital_mpsk_receiver_cc</block> + <block>digital_correlate_access_code_tag_bb</block> + <block>digital_framer_sink_1</block> <block>digital_mpsk_snr_est_cc</block> - <block>digital_pfb_clock_sync_xxx</block> + <block>digital_mpsk_receiver_cc</block> + <block>digital_packet_sink</block> <block>digital_pn_correlator_cc</block> + <block>digital_simple_framer</block> + </cat> + <cat> + <name>Probes</name> <block>digital_probe_density_b</block> <block>digital_probe_mpsk_snr_est_c</block> - <block>digital_scrambler_bb</block> - <block>digital_diff_decoder_bb</block> - <block>digital_diff_encoder_bb</block> - <block>digital_diff_phasor_cc</block> - <block>digital_framer_sink_1</block> - <block>digital_packet_sink</block> - <block>digital_simple_framer</block> + </cat> + <cat> + <name>Sources</name> + <block>digital_glfsr_source_x</block> + </cat> + <cat> + <name>Synchronizers</name> + <block>digital_clock_recovery_mm_xx</block> + <block>digital_costas_loop_cc</block> + <block>digital_fll_band_edge_cc</block> + <block>digital_pfb_clock_sync_xxx</block> + </cat> + <cat> + <name>Equalizers</name> + <block>digital_cma_equalizer_cc</block> + <block>digital_lms_dd_equalizer_cc</block> </cat> <cat> <name>Digital Modulators</name> @@ -79,6 +96,7 @@ <block>digital_ofdm_demod</block> <block>digital_ofdm_cyclic_prefixer</block> <block>digital_ofdm_frame_acquisition</block> + <block>digital_ofdm_frame_sink</block> <block>digital_ofdm_insert_preamble</block> <block>digital_ofdm_sampler</block> <block>digital_ofdm_sync_pn</block> diff --git a/gr-digital/grc/digital_correlate_access_code_tag_bb.xml b/gr-digital/grc/digital_correlate_access_code_tag_bb.xml new file mode 100644 index 0000000000..7d43f1b3f1 --- /dev/null +++ b/gr-digital/grc/digital_correlate_access_code_tag_bb.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Correlate Access Code +################################################### + --> +<block> + <name>Correlate Access Code - Tag</name> + <key>digital_correlate_access_code_tag_bb</key> + <import>from gnuradio import digital</import> + <make>digital.correlate_access_code_tag_bb($access_code, $threshold, $tagname)</make> + <param> + <name>Access Code</name> + <key>access_code</key> + <value>101010</value> + <type>string</type> + </param> + <param> + <name>Threshold</name> + <key>threshold</key> + <type>int</type> + </param> + <param> + <name>Tag Name</name> + <key>tagname</key> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_gmskmod_bc.xml b/gr-digital/grc/digital_gmskmod_bc.xml index a44afe798f..6cda687f76 100644 --- a/gr-digital/grc/digital_gmskmod_bc.xml +++ b/gr-digital/grc/digital_gmskmod_bc.xml @@ -8,7 +8,7 @@ <name>GMSK Modulator</name> <key>digital_gmskmod_bc</key> <import>from gnuradio import digital</import> - <make>digital.gmskmod_bc($samples_per_symbol, $bt, $L)</make> + <make>digital.gmskmod_bc($samples_per_symbol, $L, $bt)</make> <param> <name>Samples/Symbol</name> <key>samples_per_symbol</key> diff --git a/gr-digital/grc/digital_mpsk_receiver_cc.xml b/gr-digital/grc/digital_mpsk_receiver_cc.xml index bd738fccc3..a9b66b7a19 100644 --- a/gr-digital/grc/digital_mpsk_receiver_cc.xml +++ b/gr-digital/grc/digital_mpsk_receiver_cc.xml @@ -17,61 +17,61 @@ <param> <name>M</name> <key>M</key> - <value>4</value> + <value>4</value> <type>int</type> </param> <param> <name>Theta</name> <key>theta</key> - <value>0</value> + <value>0</value> <type>real</type> </param> <param> <name>Loop Bandwidth</name> <key>w</key> - <value>cmath.pi/100.0</value> + <value>cmath.pi/100.0</value> <type>real</type> </param> <param> <name>Min Freq</name> <key>fmin</key> - <value>-0.5</value> + <value>-0.5</value> <type>real</type> </param> <param> <name>Max Freq</name> <key>fmax</key> - <value>0.5</value> + <value>0.5</value> <type>real</type> </param> <param> <name>Mu</name> <key>mu</key> - <value>0.25</value> + <value>0.25</value> <type>real</type> </param> <param> <name>Gain Mu</name> <key>gain_mu</key> - <value>0.01</value> + <value>0.01</value> <type>real</type> </param> <param> <name>Omega</name> <key>omega</key> - <value>2</value> + <value>2</value> <type>real</type> </param> <param> <name>Gain Omega</name> <key>gain_omega</key> - <value>0.001</value> + <value>0.001</value> <type>real</type> </param> <param> <name>Omega Relative Limit</name> <key>omega_relative_limit</key> - <value>0.001</value> + <value>0.001</value> <type>real</type> </param> <sink> diff --git a/gr-digital/grc/digital_ofdm_frame_sink.xml b/gr-digital/grc/digital_ofdm_frame_sink.xml new file mode 100644 index 0000000000..64c69ec0ad --- /dev/null +++ b/gr-digital/grc/digital_ofdm_frame_sink.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<!-- + Copyright 2012 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. +--> + +<!-- +################################################### +##OFDM Frame Sink +################################################### + --> +<block> + <name>OFDM Frame Sink</name> + <key>digital_ofdm_frame_sink</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_frame_sink($syms, $vals, $queue, $occ_tones, $ph_gain, $frq_gain)</make> + <param> + <name>Symbol Points</name> + <key>syms</key> + <type>complex_vector</type> + </param> + <param> + <name>Symbol Values</name> + <key>vals</key> + <type>int_vector</type> + </param> + <param> + <name>Message Queue</name> + <key>queue</key> + <type>raw</type> + </param> + <param> + <name>Occupied Tones</name> + <key>occ_tones</key> + <type>int</type> + </param> + <param> + <name>Phase Gain</name> + <key>ph_gain</key> + <value>0.25</value> + <type>real</type> + </param> + <param> + <name>Freq. Gain</name> + <key>frq_gain</key> + <value>0.015625</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$occ_tones</vlen> + </sink> + <sink> + <name>flag</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$occ_tones</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_packet_sink.xml b/gr-digital/grc/digital_packet_sink.xml index e9231bd059..2c6653d7ec 100644 --- a/gr-digital/grc/digital_packet_sink.xml +++ b/gr-digital/grc/digital_packet_sink.xml @@ -22,6 +22,7 @@ <param> <name>Threshold</name> <key>threshold</key> + <value>-1</value> <type>int</type> </param> <sink> diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt index f863b28757..d8e17546ed 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -17,7 +17,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. - ######################################################################## # generate helper scripts to expand templated files ######################################################################## @@ -36,7 +35,7 @@ if __name__ == '__main__': root, inp = sys.argv[1:3] for sig in sys.argv[3:]: name = re.sub ('X+', sig, root) - d = build_utils.standard_dict(name, sig, 'digital') + d = build_utils.standard_dict2(name, sig, 'digital') build_utils.expand_template(d, inp) ") @@ -64,8 +63,8 @@ endmacro(expand_h) ######################################################################## # Invoke macro to generate various sources -######################################################################## -expand_h(digital_chunks_to_symbols_XX bf bc sf sc if ic) +####################################################################### +expand_h(chunks_to_symbols_XX bf bc sf sc if ic) add_custom_target(digital_generated_includes DEPENDS ${generated_includes} @@ -75,55 +74,53 @@ add_custom_target(digital_generated_includes DEPENDS # Install header files ######################################################################## install(FILES - ${generated_includes} - digital_api.h - digital_impl_glfsr.h - digital_impl_mpsk_snr_est.h - digital_additive_scrambler_bb.h - digital_binary_slicer_fb.h - digital_bytes_to_syms.h - digital_clock_recovery_mm_cc.h - digital_clock_recovery_mm_ff.h - digital_cma_equalizer_cc.h - digital_cpmmod_bc.h - digital_constellation.h - digital_constellation_receiver_cb.h - digital_constellation_decoder_cb.h - digital_correlate_access_code_bb.h - digital_correlate_access_code_tag_bb.h - digital_costas_loop_cc.h - digital_crc32.h - digital_descrambler_bb.h - digital_diff_decoder_bb.h - digital_diff_encoder_bb.h - digital_diff_phasor_cc.h - digital_framer_sink_1.h - digital_fll_band_edge_cc.h - digital_glfsr_source_b.h - digital_glfsr_source_f.h - digital_gmskmod_bc.h - digital_lms_dd_equalizer_cc.h - digital_kurtotic_equalizer_cc.h - digital_map_bb.h - digital_metric_type.h - digital_mpsk_receiver_cc.h - digital_mpsk_snr_est_cc.h - digital_ofdm_cyclic_prefixer.h - digital_ofdm_frame_acquisition.h - digital_ofdm_frame_sink.h - digital_ofdm_insert_preamble.h - digital_ofdm_mapper_bcv.h - digital_ofdm_sampler.h - digital_packet_sink.h - digital_pfb_clock_sync_ccf.h - digital_pfb_clock_sync_fff.h - digital_pn_correlator_cc.h - digital_probe_density_b.h - digital_probe_mpsk_snr_est_c.h - digital_scrambler_bb.h - digital_simple_framer.h - digital_simple_framer_sync.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio + ${digital_generated_includes} + api.h + constellation.h + crc32.h + glfsr.h + mpsk_snr_est.h + simple_framer_sync.h + additive_scrambler_bb.h + binary_slicer_fb.h + clock_recovery_mm_cc.h + clock_recovery_mm_ff.h + cma_equalizer_cc.h + cpmmod_bc.h + constellation_receiver_cb.h + constellation_decoder_cb.h + correlate_access_code_bb.h + correlate_access_code_tag_bb.h + costas_loop_cc.h + descrambler_bb.h + diff_decoder_bb.h + diff_encoder_bb.h + diff_phasor_cc.h + framer_sink_1.h + fll_band_edge_cc.h + glfsr_source_b.h + glfsr_source_f.h + kurtotic_equalizer_cc.h + lms_dd_equalizer_cc.h + map_bb.h + metric_type.h + mpsk_receiver_cc.h + mpsk_snr_est_cc.h + ofdm_cyclic_prefixer.h + ofdm_frame_acquisition.h + ofdm_frame_sink.h + ofdm_insert_preamble.h + ofdm_mapper_bcv.h + ofdm_sampler.h + packet_sink.h + pfb_clock_sync_ccf.h + pfb_clock_sync_fff.h + pn_correlator_cc.h + probe_density_b.h + probe_mpsk_snr_est_c.h + scrambler_bb.h + simple_framer.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital COMPONENT "digital_devel" ) diff --git a/gr-digital/include/digital/additive_scrambler_bb.h b/gr-digital/include/digital/additive_scrambler_bb.h new file mode 100644 index 0000000000..345bd45dc8 --- /dev/null +++ b/gr-digital/include/digital/additive_scrambler_bb.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 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_ADDITIVE_SCRAMBLER_BB_H +#define INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_BB_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \ingroup coding_blk + * + * Scramble an input stream using an LFSR. This block works on the + * LSB only of the input data stream, i.e., on an "unpacked + * binary" stream, and produces the same format on its output. + */ + class DIGITAL_API additive_scrambler_bb : virtual public gr_sync_block + { + public: + // gr::digital::additive_scrambler_bb::sptr + typedef boost::shared_ptr<additive_scrambler_bb> sptr; + + /*! + * \brief Create additive scrambler. + * + * Scramble an input stream using an LFSR. This block works on + * the LSB only of the input data stream, i.e., on an "unpacked + * binary" stream, and produces the same format on its output. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + * \param count Number of bits after which shift register is reset, 0=never + * + * The scrambler works by XORing the incoming bit stream by the + * output of the LFSR. Optionally, after 'count' bits have been + * processed, the shift register is reset to the seed value. + * This allows processing fixed length vectors of samples. + */ + static sptr make(int mask, int seed, int len, int count=0); + + virtual int mask() const = 0; + virtual int seed() const = 0; + virtual int len() const = 0; + virtual int count() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_api.h b/gr-digital/include/digital/api.h index d45ace13f2..d45ace13f2 100644 --- a/gr-digital/include/digital_api.h +++ b/gr-digital/include/digital/api.h diff --git a/gr-digital/include/digital_binary_slicer_fb.h b/gr-digital/include/digital/binary_slicer_fb.h index 35a7380fb9..f56b48a633 100644 --- a/gr-digital/include/digital_binary_slicer_fb.h +++ b/gr-digital/include/digital/binary_slicer_fb.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2011 Free Software Foundation, Inc. + * Copyright 2006,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,31 +23,33 @@ #ifndef INCLUDED_DIGITAL_BINARY_SLICER_FB_H #define INCLUDED_DIGITAL_BINARY_SLICER_FB_H -#include <digital_api.h> +#include <digital/api.h> #include <gr_sync_block.h> -class digital_binary_slicer_fb; -typedef boost::shared_ptr<digital_binary_slicer_fb> digital_binary_slicer_fb_sptr; +namespace gr { + namespace digital { + + /*! + * \brief slice float binary symbol outputting 1 bit output + * \ingroup converter_blk + * \ingroup digital + * + * x < 0 --> 0 + * x >= 0 --> 1 + */ + class DIGITAL_API binary_slicer_fb : virtual public gr_sync_block + { + public: + // gr::digital::binary_slicer_fb::sptr + typedef boost::shared_ptr<binary_slicer_fb> sptr; -DIGITAL_API digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb (); + /*! + * \brief Make binary symbol slicer block. + */ + static sptr make(); + }; -/*! - * \brief slice float binary symbol outputting 1 bit output - * \ingroup converter_blk - * \ingroup digital - * - * x < 0 --> 0 - * x >= 0 --> 1 - */ -class DIGITAL_API digital_binary_slicer_fb : public gr_sync_block -{ - friend DIGITAL_API digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb (); - digital_binary_slicer_fb (); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; + } /* namespace digital */ +} /* namespace gr */ -#endif +#endif /* INCLUDED_DIGITAL_BINARY_SLICER_FB_H */ diff --git a/gr-digital/include/digital/chunks_to_symbols_XX.h.t b/gr-digital/include/digital/chunks_to_symbols_XX.h.t new file mode 100644 index 0000000000..341afabbab --- /dev/null +++ b/gr-digital/include/digital/chunks_to_symbols_XX.h.t @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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. + */ + +/* @WARNING@ */ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <digital/api.h> +#include <gr_sync_interpolator.h> + +namespace gr { + namespace digital { + + /*! + * \brief Map a stream of symbol indexes (unpacked bytes or + * shorts) to stream of float or complex constellation points in D + * dimensions (D = 1 by default) + * \ingroup converter_blk + * + * input: stream of @I_TYPE@; output: stream of @O_TYPE@ + * + * out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1 + * + * The combination of gr_packed_to_unpacked_XX followed by + * digital_chunks_to_symbols_XY handles the general case of mapping + * from a stream of bytes or shorts into arbitrary float + * or complex symbols. + * + * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, + * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, + * \sa digital_chunks_to_symbols_bf, digital_chunks_to_symbols_bc. + * \sa digital_chunks_to_symbols_sf, digital_chunks_to_symbols_sc. + */ + + class DIGITAL_API @NAME@ : virtual public gr_sync_interpolator + { + public: + // gr::digital::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + /*! + * Make a chunks-to-symbols block. + * + * \param symbol_table: list that maps chunks to symbols. + * \param D: dimension of table. + */ + static sptr make(const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + + virtual int D() const = 0; + virtual std::vector<@O_TYPE@> symbol_table() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-digital/include/digital/clock_recovery_mm_cc.h b/gr-digital/include/digital/clock_recovery_mm_cc.h new file mode 100644 index 0000000000..ec121c0fdf --- /dev/null +++ b/gr-digital/include/digital/clock_recovery_mm_cc.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2011,2012 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_CLOCK_RECOVERY_MM_CC_H +#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Mueller and Müller (M&M) based clock recovery block with complex input, complex output. + * \ingroup sync_blk + * \ingroup digital + * + * This implements the Mueller and Müller (M&M) discrete-time + * error-tracking synchronizer. + * + * The complex version here is based on: Modified Mueller and + * Muller clock recovery circuit: + * + * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller + * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 + * June 1995, pp. 1032 - 1033. + */ + class DIGITAL_API clock_recovery_mm_cc : virtual public gr_block + { + public: + // gr::digital::clock_recovery_mm_cc::sptr + typedef boost::shared_ptr<clock_recovery_mm_cc> sptr; + + /*! + * Make a M&M clock recovery block. + * + * \param omega Initial estimate of samples per symbol + * \param gain_omega Gain setting for omega update loop + * \param mu Initial estimate of phase of sample + * \param gain_mu Gain setting for mu update loop + * \param omega_relative_limit limit on omega + */ + static sptr make(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit); + + virtual float mu() const = 0; + virtual float omega() const = 0; + virtual float gain_mu() const = 0; + virtual float gain_omega() const = 0; + + virtual void set_verbose(bool verbose) = 0; + virtual void set_gain_mu (float gain_mu) = 0; + virtual void set_gain_omega (float gain_omega) = 0; + virtual void set_mu (float mu) = 0; + virtual void set_omega (float omega) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_H */ diff --git a/gr-digital/include/digital/clock_recovery_mm_ff.h b/gr-digital/include/digital/clock_recovery_mm_ff.h new file mode 100644 index 0000000000..556fe0a876 --- /dev/null +++ b/gr-digital/include/digital/clock_recovery_mm_ff.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2011,2012 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_CLOCK_RECOVERY_MM_FF_H +#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output. + * \ingroup sync_blk + * \ingroup digital + * + * This implements the Mueller and Müller (M&M) discrete-time + * error-tracking synchronizer. + * + * See "Digital Communication Receivers: Synchronization, Channel + * Estimation and Signal Processing" by Heinrich Meyr, Marc + * Moeneclaey, & Stefan Fechtel. ISBN 0-471-50275-8. + */ + class DIGITAL_API clock_recovery_mm_ff : virtual public gr_block + { + public: + // gr::digital::clock_recovery_mm_ff::sptr + typedef boost::shared_ptr<clock_recovery_mm_ff> sptr; + + /*! + * Make a M&M clock recovery block. + * + * \param omega Initial estimate of samples per symbol + * \param gain_omega Gain setting for omega update loop + * \param mu Initial estimate of phase of sample + * \param gain_mu Gain setting for mu update loop + * \param omega_relative_limit limit on omega + */ + static sptr make(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit); + + virtual float mu() const = 0; + virtual float omega() const = 0; + virtual float gain_mu() const = 0; + virtual float gain_omega() const = 0; + + virtual void set_verbose(bool verbose) = 0; + virtual void set_gain_mu (float gain_mu) = 0; + virtual void set_gain_omega (float gain_omega) = 0; + virtual void set_mu (float mu) = 0; + virtual void set_omega (float omega) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_H */ diff --git a/gr-digital/include/digital/cma_equalizer_cc.h b/gr-digital/include/digital/cma_equalizer_cc.h new file mode 100644 index 0000000000..f2ec636577 --- /dev/null +++ b/gr-digital/include/digital/cma_equalizer_cc.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CMA_EQUALIZER_CC_H +#define INCLUDED_DIGITAL_CMA_EQUALIZER_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace digital { + + /*! + * \brief Implements constant modulus adaptive filter on complex stream + * \ingroup eq_blk + * \ingroup digital + * + * The error value and tap update equations (for p=2) can be found in: + * + * D. Godard, "Self-Recovering Equalization and Carrier Tracking + * in Two-Dimensional Data Communication Systems," IEEE + * Transactions on Communications, Vol. 28, No. 11, pp. 1867 - + * 1875, 1980. + */ + class DIGITAL_API cma_equalizer_cc: virtual public gr_sync_decimator + { + protected: + virtual gr_complex error(const gr_complex &out) = 0; + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + public: + // gr::digital::cma_equalizer_cc::sptr + typedef boost::shared_ptr<cma_equalizer_cc> sptr; + + /*! + * Make a CMA Equalizer block + * + * \param num_taps Numer of taps in the equalizer (channel size) + * \param modulus Modulus of the modulated signals + * \param mu Gain of the update loop + * \param sps Number of samples per symbol of the input signal + */ + static sptr make(int num_taps, float modulus, float mu, int sps); + + virtual float gain() const = 0; + virtual void set_gain(float mu) = 0; + virtual float modulus() const = 0; + virtual void set_modulus(float mod) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CMA_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital/constellation.h b/gr-digital/include/digital/constellation.h new file mode 100644 index 0000000000..4e0bff2fb3 --- /dev/null +++ b/gr-digital/include/digital/constellation.h @@ -0,0 +1,420 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010-2012 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_CONSTELLATION_H +#define INCLUDED_DIGITAL_CONSTELLATION_H + +#include <digital/api.h> +#include <digital/metric_type.h> +#include <boost/enable_shared_from_this.hpp> +#include <gr_complex.h> +#include <vector> + +namespace gr { + namespace digital { + + /************************************************************/ + /* constellation */ + /* */ + /* Base class defining interface. */ + /************************************************************/ + + class constellation; + typedef boost::shared_ptr<constellation> constellation_sptr; + + /*! + * \brief An abstracted constellation object + * \ingroup digital + * + * The constellation objects hold the necessary information to pass + * around constellation information for modulators and + * demodulators. These objects contain the mapping between the bits + * and the constellation points used to represent them as well as + * methods for slicing the symbol space. Various implementations are + * possible for efficiency and ease of use. + * + * Standard constellations (BPSK, QPSK, QAM, etc) can be inherited + * from this class and overloaded to perform optimized slicing and + * constellation mappings. + */ + class DIGITAL_API constellation + : public boost::enable_shared_from_this<constellation> + { + public: + constellation(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality); + constellation(); + ~constellation(); + + //! Returns the constellation points for a symbol value + void map_to_points(unsigned int value, gr_complex *points); + std::vector<gr_complex> map_to_points_v(unsigned int value); + + //! Returns the constellation point that matches best. + virtual unsigned int decision_maker(const gr_complex *sample) = 0; + //! Takes a vector rather than a pointer. Better for SWIG wrapping. + unsigned int decision_maker_v(std::vector<gr_complex> sample); + //! Also calculates the phase error. + unsigned int decision_maker_pe(const gr_complex *sample, float *phase_error); + //! Calculates distance. + //unsigned int decision_maker_e(const gr_complex *sample, float *error); + + //! Calculates metrics for all points in the constellation. + //! For use with the viterbi algorithm. + virtual void calc_metric(const gr_complex *sample, float *metric, trellis_metric_type_t type); + virtual void calc_euclidean_metric(const gr_complex *sample, float *metric); + virtual void calc_hard_symbol_metric(const gr_complex *sample, float *metric); + + //! Returns the set of points in this constellation. + std::vector<gr_complex> points() { return d_constellation;} + //! Returns the vector of points in this constellation. + //! Raise error if dimensionality is not one. + std::vector<gr_complex> s_points(); + //! Returns a vector of vectors of points. + std::vector<std::vector<gr_complex> > v_points(); + //! Whether to apply an encoding before doing differential encoding. (e.g. gray coding) + bool apply_pre_diff_code() { return d_apply_pre_diff_code;} + //! Whether to apply an encoding before doing differential encoding. (e.g. gray coding) + void set_pre_diff_code(bool a) { d_apply_pre_diff_code = a;} + //! Returns the encoding to apply before differential encoding. + std::vector<int> pre_diff_code() { return d_pre_diff_code;} + //! Returns the order of rotational symmetry. + unsigned int rotational_symmetry() { return d_rotational_symmetry;} + //! Returns the number of complex numbers in a single symbol. + unsigned int dimensionality() {return d_dimensionality;} + + unsigned int bits_per_symbol() + { + return floor(log(double(d_constellation.size()))/d_dimensionality/log(2.0)); + } + + unsigned int arity() + { + return d_arity; + } + + constellation_sptr base() + { + return shared_from_this(); + } + + protected: + std::vector<gr_complex> d_constellation; + std::vector<int> d_pre_diff_code; + bool d_apply_pre_diff_code; + unsigned int d_rotational_symmetry; + unsigned int d_dimensionality; + unsigned int d_arity; + + float get_distance(unsigned int index, const gr_complex *sample); + unsigned int get_closest_point(const gr_complex *sample); + void calc_arity(); + }; + + /************************************************************/ + /* constellation_calcdist */ + /* */ + /************************************************************/ + + /*! \brief Calculate Euclidian distance for any constellation + * \ingroup digital + * + * Constellation which calculates the distance to each point in the + * constellation for decision making. Inefficient for large + * constellations. + */ + class DIGITAL_API constellation_calcdist + : public constellation + { + public: + typedef boost::shared_ptr<constellation_calcdist> sptr; + + // public constructor + static sptr make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality); + + unsigned int decision_maker(const gr_complex *sample); + // void calc_metric(gr_complex *sample, float *metric, trellis_metric_type_t type); + // void calc_euclidean_metric(gr_complex *sample, float *metric); + // void calc_hard_symbol_metric(gr_complex *sample, float *metric); + + private: + constellation_calcdist(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality); + }; + + + /************************************************************/ + /*! constellation_sector */ + /************************************************************/ + + /*! + * \brief Sectorized digital constellation + * \ingroup digital + * + * Constellation space is divided into sectors. Each sector is + * associated with the nearest constellation point. + * + */ + class DIGITAL_API constellation_sector : public constellation + { + public: + + constellation_sector(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality, + unsigned int n_sectors); + + ~constellation_sector(); + + unsigned int decision_maker(const gr_complex *sample); + + protected: + virtual unsigned int get_sector(const gr_complex *sample) = 0; + virtual unsigned int calc_sector_value(unsigned int sector) = 0; + void find_sector_values(); + + unsigned int n_sectors; + + private: + std::vector<int> sector_values; + }; + + /************************************************************/ + /* constellation_rect */ + /************************************************************/ + + /*! + * \brief Rectangular digital constellation + * \ingroup digital + * + * Only implemented for 1-(complex)dimensional constellation. + * + * Constellation space is divided into rectangular sectors. Each + * sector is associated with the nearest constellation point. + * + * Works well for square QAM. + * + * Works for any generic constellation provided sectors are not + * too large. + */ + + + class DIGITAL_API constellation_rect + : public constellation_sector + { + public: + typedef boost::shared_ptr<constellation_rect> sptr; + + // public constructor + static constellation_rect::sptr make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors); + ~constellation_rect(); + + protected: + unsigned int get_sector(const gr_complex *sample); + + unsigned int calc_sector_value(unsigned int sector); + + private: + unsigned int n_real_sectors; + unsigned int n_imag_sectors; + float d_width_real_sectors; + float d_width_imag_sectors; + + constellation_rect(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors); + }; + + + /************************************************************/ + /* constellation_psk */ + /************************************************************/ + + /*! + * \brief constellation_psk + * \ingroup digital + * + * Constellation space is divided into pie slices sectors. + * + * Each slice is associated with the nearest constellation point. + * + * Works well for PSK but nothing else. + * + * Assumes that there is a constellation point at 1.x + */ + class DIGITAL_API constellation_psk : public constellation_sector + { + public: + typedef boost::shared_ptr<constellation_psk> sptr; + + // public constructor + static sptr make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int n_sectors); + + ~constellation_psk(); + + protected: + unsigned int get_sector(const gr_complex *sample); + + unsigned int calc_sector_value(unsigned int sector); + + private: + constellation_psk(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int n_sectors); + }; + + + /************************************************************/ + /* constellation_bpsk */ + /* */ + /* Only works for BPSK. */ + /* */ + /************************************************************/ + + /*! + * \brief Digital constellation for BPSK + * \ingroup digital + */ + class DIGITAL_API constellation_bpsk : public constellation + { + public: + typedef boost::shared_ptr<constellation_bpsk> sptr; + + // public constructor + static sptr make(); + + ~constellation_bpsk(); + + unsigned int decision_maker(const gr_complex *sample); + + private: + constellation_bpsk(); + }; + + + /************************************************************/ + /* constellation_qpsk */ + /* */ + /* Only works for QPSK. */ + /* */ + /************************************************************/ + + /*! + * \brief Digital constellation for QPSK + * \ingroup digital + */ + class DIGITAL_API constellation_qpsk : public constellation + { + public: + typedef boost::shared_ptr<constellation_qpsk> sptr; + + // public constructor + static sptr make(); + + ~constellation_qpsk(); + + unsigned int decision_maker(const gr_complex *sample); + + private: + constellation_qpsk(); + }; + + + /************************************************************/ + /* constellation_dqpsk */ + /* */ + /* Works with differential encoding; slower decisions. */ + /* */ + /************************************************************/ + + /*! + * \brief Digital constellation for DQPSK + * \ingroup digital + */ + class DIGITAL_API constellation_dqpsk : public constellation + { + public: + typedef boost::shared_ptr<constellation_dqpsk> sptr; + + // public constructor + static sptr make(); + + ~constellation_dqpsk(); + + unsigned int decision_maker(const gr_complex *sample); + + private: + constellation_dqpsk(); + }; + + + /************************************************************/ + /* constellation_8psk */ + /* */ + /* Only works for 8PSK. */ + /* */ + /************************************************************/ + + /*! + * \brief Digital constellation for 8PSK + * \ingroup digital + */ + class DIGITAL_API constellation_8psk : public constellation + { + public: + typedef boost::shared_ptr<constellation_8psk> sptr; + + // public constructor + static sptr make(); + + ~constellation_8psk(); + + unsigned int decision_maker(const gr_complex *sample); + + private: + constellation_8psk(); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CONSTELLATION_H */ diff --git a/gr-digital/include/digital/constellation_decoder_cb.h b/gr-digital/include/digital/constellation_decoder_cb.h new file mode 100644 index 0000000000..01b35db905 --- /dev/null +++ b/gr-digital/include/digital/constellation_decoder_cb.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CONSTELLATION_DECODER_CB_H +#define INCLUDED_DIGITAL_CONSTELLATION_DECODER_CB_H + +#include <digital/api.h> +#include <digital/constellation.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Constellation Decoder + * \ingroup coding_blk + * \ingroup digital + * + * Decode a constellation's points from a complex space to + * (unpacked) bits based on the map of the \p consetllation + * object. + */ + class DIGITAL_API constellation_decoder_cb + : virtual public gr_block + { + public: + // gr::digital::constellation_decoder_cb::sptr + typedef boost::shared_ptr<constellation_decoder_cb> sptr; + + /*! + * \brief Make constellation decoder block. + * + * \param constellation A constellation derived from class + * 'constellation'. Use base() method to get a shared pointer to + * this base class type. + */ + static sptr make(constellation_sptr constellation); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CONSTELLATION_DECODER_CB_H */ diff --git a/gr-digital/include/digital/constellation_receiver_cb.h b/gr-digital/include/digital/constellation_receiver_cb.h new file mode 100644 index 0000000000..b1c415ea09 --- /dev/null +++ b/gr-digital/include/digital/constellation_receiver_cb.h @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CONSTELLATION_RECEIVER_CB_H +#define INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_H + +#include <digital/api.h> +#include <digital/constellation.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief This block takes care of receiving generic modulated signals + * through phase, frequency, and symbol synchronization. + * \ingroup sync_blk + * \ingroup demod_blk + * \ingroup digital + * + * This block takes care of receiving generic modulated signals + * through phase, frequency, and symbol synchronization. It + * performs carrier frequency and phase locking as well as symbol + * timing recovery. + * + * The phase and frequency synchronization are based on a Costas + * loop that finds the error of the incoming signal point compared + * to its nearest constellation point. The frequency and phase of + * the NCO are updated according to this error. + * + * The symbol synchronization is done using a modified Mueller and + * Muller circuit from the paper: + * + * "G. R. Danesfahani, T.G. Jeans, "Optimisation of modified + * Mueller and Muller algorithm," Electronics Letters, Vol. 31, + * no. 13, 22 June 1995, pp. 1032 - 1033." + * + * This circuit interpolates the downconverted sample (using the + * NCO developed by the Costas loop) every mu samples, then it + * finds the sampling error based on this and the past symbols and + * the decision made on the samples. Like the phase error + * detector, there are optimized decision algorithms for BPSK and + * QPKS, but 8PSK uses another brute force computation against all + * possible symbols. The modifications to the M&M used here reduce + * self-noise. + */ + class DIGITAL_API constellation_receiver_cb + : virtual public gr_block + { + public: + // gr::digital::constellation_receiver_cb::sptr + typedef boost::shared_ptr<constellation_receiver_cb> sptr; + + /*! + * \brief Constructor to synchronize incoming M-PSK symbols + * + * \param constellation constellation of points for generic modulation + * \param loop_bw Loop bandwidth of the Costas Loop (~ 2pi/100) + * \param fmin minimum normalized frequency value the loop can achieve + * \param fmax maximum normalized frequency value the loop can achieve + * + * The constructor chooses which phase detector and decision + * maker to use in the work loop based on the value of M. + */ + static sptr make(constellation_sptr constellation, + float loop_bw, float fmin, float fmax); + + virtual void phase_error_tracking(float phase_error) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_H */ diff --git a/gr-digital/include/digital/correlate_access_code_bb.h b/gr-digital/include/digital/correlate_access_code_bb.h new file mode 100644 index 0000000000..c2ef788a37 --- /dev/null +++ b/gr-digital/include/digital/correlate_access_code_bb.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011,2012 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_ACCESS_CODE_BB_H +#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <string> + +namespace gr { + namespace digital { + + /*! + * \brief Examine input for specified access code, one bit at a time. + * \ingroup sync_blk + * \ingroup digital + * + * input: stream of bits, 1 bit per input byte (data in LSB) + * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) + * + * Each output byte contains two valid bits, the data bit, and the + * flag bit. The LSB (bit 0) is the data bit, and is the original + * input data, delayed 64 bits. Bit 1 is the flag bit and is 1 if + * the corresponding data bit is the first data bit following the + * access code. Otherwise the flag bit is 0. + */ + class DIGITAL_API correlate_access_code_bb : virtual public gr_sync_block + { + public: + // gr::digital::correlate_access_code_bb::sptr + typedef boost::shared_ptr<correlate_access_code_bb> sptr; + + /*! + * Make a correlate_access_code block. + * + * \param access_code is represented with 1 byte per bit, + * e.g., "010101010111000100" + * \param threshold maximum number of bits that may be wrong + */ + static sptr make(const std::string &access_code, int threshold); + + /*! + * Set a new access code. + * + * \param access_code is represented with 1 byte per bit, + * e.g., "010101010111000100" + */ + virtual bool set_access_code(const std::string &access_code) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H */ diff --git a/gr-digital/include/digital/correlate_access_code_tag_bb.h b/gr-digital/include/digital/correlate_access_code_tag_bb.h new file mode 100644 index 0000000000..0c51f3aead --- /dev/null +++ b/gr-digital/include/digital/correlate_access_code_tag_bb.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011,2012 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_ACCESS_CODE_TAG_BB_H +#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_BB_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <string> + +namespace gr { + namespace digital { + + /*! + * \brief Examine input for specified access code, one bit at a time. + * \ingroup sync_blk + * + * input: stream of bits, 1 bit per input byte (data in LSB) + * output: unaltered stream of bits (plus tags) + * + * This block annotates the input stream with tags. The tags have + * key name [tag_name], specified in the constructor. Used for + * searching an input data stream for preambles, etc. + */ + class DIGITAL_API correlate_access_code_tag_bb : virtual public gr_sync_block + { + public: + // gr::digital::correlate_access_code_tag_bb::sptr + typedef boost::shared_ptr<correlate_access_code_tag_bb> sptr; + + /*! + * \param access_code is represented with 1 byte per bit, + * e.g., "010101010111000100" + * \param threshold maximum number of bits that may be wrong + * \param tag_name key of the tag inserted into the tag stream + */ + static sptr make(const std::string &access_code, + int threshold, + const std::string &tag_name); + + /*! + * \param access_code is represented with 1 byte per bit, + * e.g., "010101010111000100" + */ + virtual bool set_access_code(const std::string &access_code) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_BB_H */ diff --git a/gr-digital/include/digital/costas_loop_cc.h b/gr-digital/include/digital/costas_loop_cc.h new file mode 100644 index 0000000000..bad6de9363 --- /dev/null +++ b/gr-digital/include/digital/costas_loop_cc.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2011,2012 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_COSTAS_LOOP_CC_H +#define INCLUDED_DIGITAL_COSTAS_LOOP_CC_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief A Costas loop carrier recovery module. + * \ingroup sync_blk + * \ingroup digital + * + * The Costas loop locks to the center frequency of a signal and + * downconverts it to baseband. The second (order=2) order loop + * is used for BPSK where the real part of the output signal is + * the baseband BPSK signal and the imaginary part is the error + * signal. When order=4, it can be used for quadrature + * modulations where both I and Q (real and imaginary) are + * outputted. + * + * More details can be found online: + * + * J. Feigin, "Practical Costas loop design: Designing a simple + * and inexpensive BPSK Costas loop carrier recovery circuit," RF + * signal processing, pp. 20-36, 2002. + * + * http://rfdesign.com/images/archive/0102Feigin20.pdf + * + * The Costas loop can have two output streams: + * stream 1 is the baseband I and Q; + * stream 2 is the normalized frequency of the loop + */ + class DIGITAL_API costas_loop_cc : virtual public gr_sync_block + { + public: + // gr::digital::costas_loop_cc::sptr + typedef boost::shared_ptr<costas_loop_cc> sptr; + + /*! + * Make a Costas loop carrier recovery block. + * + * \param loop_bw internal 2nd order loop bandwidth (~ 2pi/100) + * \param order the loop order, either 2, 4, or 8 + */ + static sptr make(float loop_bw, int order); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_COSTAS_LOOP_CC_H */ diff --git a/gr-digital/include/digital/cpmmod_bc.h b/gr-digital/include/digital/cpmmod_bc.h new file mode 100644 index 0000000000..f65ca8059f --- /dev/null +++ b/gr-digital/include/digital/cpmmod_bc.h @@ -0,0 +1,118 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2012 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_CPMMOD_BC_H +#define INCLUDED_DIGITAL_CPMMOD_BC_H + +#include <digital/api.h> +#include <gr_hier_block2.h> +#include <gr_cpm.h> + +namespace gr { + namespace digital { + + /*! + * \brief Generic CPM modulator + * + * \ingroup modulation_blk + * \ingroup digital + * + * Examples: + * - Setting h = 0.5, L = 1, type = LREC yields MSK. + * - Setting h = 0.5, type = GAUSSIAN and beta = 0.3 yields GMSK + * as used in GSM. + * + * The input of this block are symbols from an M-ary alphabet + * +/-1, +/-3, ..., +/-(M-1). Usually, M = 2 and therefore, the + * valid inputs are +/-1. + * The modulator will silently accept any other inputs, though. + * The output is the phase-modulated signal. + */ + class DIGITAL_API cpmmod_bc : virtual public gr_hier_block2 + { + public: + // gr::digital::cpmmod_bc::sptr + typedef boost::shared_ptr<cpmmod_bc> sptr; + + /*! + * Make CPM modulator block. + * + * \param type The modulation type. Can be one of LREC, LRC, LSRC, TFM + * or GAUSSIAN. See gr_cpm::phase_response() for a + * detailed description. + * \param h The modulation index. \f$ h \cdot \pi\f$ is the maximum + * phase change that can occur between two symbols, i.e., if + * you only send ones, the phase will increase by \f$ h \cdot + * \pi\f$ every \p samples_per_sym samples. Set this to 0.5 + * for Minimum Shift Keying variants. + * \param samples_per_sym Samples per symbol. + * \param L The length of the phase duration in symbols. For L=1, this + * yields full- response CPM symbols, for L > 1, + * partial-response. + * \param beta For LSRC, this is the rolloff factor. For Gaussian + * pulses, this is the 3 dB time-bandwidth product. + */ + static sptr make(gr_cpm::cpm_type type, float h, + int samples_per_sym, + int L, double beta=0.3); + + /*! + * Make GMSK modulator block. + * + * The type is GAUSSIAN and the modulation index for GMSK is + * 0.5. This are populated automatically by this factory + * function. + * + * \param samples_per_sym Samples per symbol. + * \param L The length of the phase duration in symbols. For L=1, this + * yields full- response CPM symbols, for L > 1, + * partial-response. + * \param beta For LSRC, this is the rolloff factor. For Gaussian + * pulses, this is the 3 dB time-bandwidth product. + */ + static sptr make_gmskmod_bc(int samples_per_sym=2, + int L=4, double beta=0.3); + + //! Return the phase response FIR taps + virtual std::vector<float> taps() const = 0; + + //! Return the type of CPM modulator + virtual int type() const = 0; + + //! Return the modulation index of the modulator. + virtual float index() const = 0; + + //! Return the number of samples per symbol + virtual int samples_per_sym() const = 0; + + //! Return the length of the phase duration (in symbols) + virtual int length() const = 0; + + //! Return the value of beta for the modulator + virtual double beta() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CPMMOD_BC_H */ + diff --git a/gr-digital/include/digital_crc32.h b/gr-digital/include/digital/crc32.h index ec4a0df5b0..b84dd6832d 100644 --- a/gr-digital/include/digital_crc32.h +++ b/gr-digital/include/digital/crc32.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2011 Free Software Foundation, Inc. + * Copyright 2005,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,29 +23,35 @@ #ifndef INCLUDED_DIGITAL_CRC32_H #define INCLUDED_DIGITAL_CRC32_H -#include <digital_api.h> +#include <digital/api.h> #include <string> #include <gr_types.h> -/*! - * \brief update running CRC-32 - * \ingroup digital - * - * Update a running CRC with the bytes buf[0..len-1] The CRC should be - * initialized to all 1's, and the transmitted value is the 1's - * complement of the final running CRC. The resulting CRC should be - * transmitted in big endian order. - */ -DIGITAL_API unsigned int -digital_update_crc32(unsigned int crc, const unsigned char *buf, size_t len); +namespace gr { + namespace digital { + + /*! + * \brief update running CRC-32 + * \ingroup digital + * + * Update a running CRC with the bytes buf[0..len-1] The CRC + * should be initialized to all 1's, and the transmitted value is + * the 1's complement of the final running CRC. The resulting CRC + * should be transmitted in big endian order. + */ + DIGITAL_API unsigned int + update_crc32(unsigned int crc, const unsigned char *buf, size_t len); + + DIGITAL_API unsigned int + update_crc32(unsigned int crc, const std::string buf); -DIGITAL_API unsigned int -digital_update_crc32(unsigned int crc, const std::string buf); + DIGITAL_API unsigned int + crc32(const unsigned char *buf, size_t len); -DIGITAL_API unsigned int -digital_crc32(const unsigned char *buf, size_t len); + DIGITAL_API unsigned int + crc32(const std::string buf); -DIGITAL_API unsigned int -digital_crc32(const std::string buf); + } /* namespace digital */ +} /* namespace gr */ #endif /* INCLUDED_CRC32_H */ diff --git a/gr-digital/include/digital/descrambler_bb.h b/gr-digital/include/digital/descrambler_bb.h new file mode 100644 index 0000000000..512efc503a --- /dev/null +++ b/gr-digital/include/digital/descrambler_bb.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 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_GR_DESCRAMBLER_BB_H +#define INCLUDED_GR_DESCRAMBLER_BB_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Descramber an input stream using an LFSR. + * \ingroup coding_blk + * + * Descramble an input stream using an LFSR. This block works on + * the LSB only of the input data stream, i.e., on an "unpacked + * binary" stream, and produces the same format on its output. + */ + class DIGITAL_API descrambler_bb : virtual public gr_sync_block + { + public: + // gr::digital::descrambler_bb::sptr + typedef boost::shared_ptr<descrambler_bb> sptr; + + /*! + * Descramble an input stream using an LFSR. This block works on + * the LSB only of the input data stream, i.e., on an "unpacked + * binary" stream, and produces the same format on its output. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + */ + static sptr make(int mask, int seed, int len); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DESCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_diff_decoder_bb.h b/gr-digital/include/digital/diff_decoder_bb.h index 928035d0e7..88b9f754ef 100644 --- a/gr-digital/include/digital_diff_decoder_bb.h +++ b/gr-digital/include/digital/diff_decoder_bb.h @@ -23,34 +23,34 @@ #ifndef INCLUDED_GR_DIFF_DECODER_BB_H #define INCLUDED_GR_DIFF_DECODER_BB_H -#include <digital_api.h> +#include <digital/api.h> #include <gr_sync_block.h> -class digital_diff_decoder_bb; -typedef boost::shared_ptr<digital_diff_decoder_bb> digital_diff_decoder_bb_sptr; - -DIGITAL_API digital_diff_decoder_bb_sptr -digital_make_diff_decoder_bb(unsigned int modulus); - -/*! - * \brief y[0] = (x[0] - x[-1]) % M - * \ingroup coding_blk - * - * Uses current and previous symbols and the alphabet modulus to - * perform differential decoding. - */ -class DIGITAL_API digital_diff_decoder_bb : public gr_sync_block -{ - friend DIGITAL_API digital_diff_decoder_bb_sptr - digital_make_diff_decoder_bb(unsigned int modulus); - digital_diff_decoder_bb(unsigned int modulus); - - unsigned int d_modulus; - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif +namespace gr { + namespace digital { + + /*! + * \brief Differential encoder: y[0] = (x[0] - x[-1]) % M + * \ingroup coding_blk + * + * Uses current and previous symbols and the alphabet modulus to + * perform differential decoding. + */ + class DIGITAL_API diff_decoder_bb : virtual public gr_sync_block + { + public: + // gr::digital::diff_decoder_bb::sptr + typedef boost::shared_ptr<diff_decoder_bb> sptr; + + /*! + * Make a differntial decoder block. + * + * \param modulus Modulus of code's alphabet + */ + static sptr make(unsigned int modulus); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_DECODER_BB_H */ diff --git a/gr-digital/include/digital_diff_encoder_bb.h b/gr-digital/include/digital/diff_encoder_bb.h index d4be69cadd..08fc6bef8c 100644 --- a/gr-digital/include/digital_diff_encoder_bb.h +++ b/gr-digital/include/digital/diff_encoder_bb.h @@ -23,35 +23,34 @@ #ifndef INCLUDED_GR_DIFF_ENCODER_BB_H #define INCLUDED_GR_DIFF_ENCODER_BB_H -#include <digital_api.h> +#include <digital/api.h> #include <gr_sync_block.h> -class digital_diff_encoder_bb; -typedef boost::shared_ptr<digital_diff_encoder_bb> digital_diff_encoder_bb_sptr; - -DIGITAL_API digital_diff_encoder_bb_sptr -digital_make_diff_encoder_bb(unsigned int modulus); - -/*! - * \brief y[0] = (x[0] + y[-1]) % M - * \ingroup coding_blk - * - * Uses current and previous symbols and the alphabet modulus to - * perform differential encoding. - */ -class DIGITAL_API digital_diff_encoder_bb : public gr_sync_block -{ - friend DIGITAL_API digital_diff_encoder_bb_sptr - digital_make_diff_encoder_bb(unsigned int modulus); - digital_diff_encoder_bb(unsigned int modulus); - - unsigned int d_last_out; - unsigned int d_modulus; - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif +namespace gr { + namespace digital { + + /*! + * \brief Differential decoder: y[0] = (x[0] + y[-1]) % M + * \ingroup coding_blk + * + * Uses current and previous symbols and the alphabet modulus to + * perform differential encoding. + */ + class DIGITAL_API diff_encoder_bb : virtual public gr_sync_block + { + public: + // gr::digital::diff_encoder_bb::sptr + typedef boost::shared_ptr<diff_encoder_bb> sptr; + + /*! + * Make a differntial encoder block. + * + * \param modulus Modulus of code's alphabet + */ + static sptr make(unsigned int modulus); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_ENCODER_BB_H */ diff --git a/gr-digital/include/digital_diff_phasor_cc.h b/gr-digital/include/digital/diff_phasor_cc.h index 32a2464b28..bf5a0a6326 100644 --- a/gr-digital/include/digital_diff_phasor_cc.h +++ b/gr-digital/include/digital/diff_phasor_cc.h @@ -23,37 +23,34 @@ #ifndef INCLUDED_GR_DIFF_PHASOR_CC_H #define INCLUDED_GR_DIFF_PHASOR_CC_H -#include <digital_api.h> +#include <digital/api.h> #include <gr_sync_block.h> -/*! - * \brief Differential decoding based on phase change. - * \ingroup coding_blk - * - * Uses the phase difference between two symbols to determine the - * output symbol: - * - * out[i] = in[i] * conj(in[i-1]); - */ -class digital_diff_phasor_cc; -typedef boost::shared_ptr<digital_diff_phasor_cc> digital_diff_phasor_cc_sptr; - -DIGITAL_API digital_diff_phasor_cc_sptr digital_make_diff_phasor_cc(); - - -class DIGITAL_API digital_diff_phasor_cc : public gr_sync_block -{ - friend DIGITAL_API digital_diff_phasor_cc_sptr - digital_make_diff_phasor_cc(); - - digital_diff_phasor_cc(); //constructor - - public: - ~digital_diff_phasor_cc(); //destructor - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif +namespace gr { + namespace digital { + + /*! + * \brief Differential decoding based on phase change. + * \ingroup coding_blk + * + * Uses the phase difference between two symbols to determine the + * output symbol: + * + * out[i] = in[i] * conj(in[i-1]); + */ + class DIGITAL_API diff_phasor_cc : virtual public gr_sync_block + { + public: + // gr::digital::diff_phasor_cc::sptr + typedef boost::shared_ptr<diff_phasor_cc> sptr; + + /*! + * Make a differential phasor decoding block. + */ + static sptr make(); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_PHASOR_CC_H */ diff --git a/gr-digital/include/digital/fll_band_edge_cc.h b/gr-digital/include/digital/fll_band_edge_cc.h new file mode 100644 index 0000000000..1a9fd0bf88 --- /dev/null +++ b/gr-digital/include/digital/fll_band_edge_cc.h @@ -0,0 +1,181 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2011,2012 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_FLL_BAND_EDGE_CC_H +#define INCLUDED_DIGITAL_FLL_BAND_EDGE_CC_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gri_control_loop.h> + +namespace gr { + namespace digital { + + /*! + * \class digital_fll_band_edge_cc + * \brief Frequency Lock Loop using band-edge filters + * + * \ingroup general + * \ingroup digital + * + * The frequency lock loop derives a band-edge filter that covers + * the upper and lower bandwidths of a digitally-modulated + * signal. The bandwidth range is determined by the excess + * bandwidth (e.g., rolloff factor) of the modulated signal. The + * placement in frequency of the band-edges is determined by the + * oversampling ratio (number of samples per symbol) and the + * excess bandwidth. The size of the filters should be fairly + * large so as to average over a number of symbols. + * + * The FLL works by filtering the upper and lower band edges into + * x_u(t) and x_l(t), respectively. These are combined to form + * cc(t) = x_u(t) + x_l(t) and ss(t) = x_u(t) - x_l(t). Combining + * these to form the signal e(t) = Re{cc(t) \\times ss(t)^*} + * (where ^* is the complex conjugate) provides an error signal at + * the DC term that is directly proportional to the carrier + * frequency. We then make a second-order loop using the error + * signal that is the running average of e(t). + * + * In practice, the above equation can be simplified by just + * comparing the absolute value squared of the output of both + * filters: abs(x_l(t))^2 - abs(x_u(t))^2 = norm(x_l(t)) - + * norm(x_u(t)). + * + * In theory, the band-edge filter is the derivative of the + * matched filter in frequency, (H_be(f) = frac{H(f)}{df}). In + * practice, this comes down to a quarter sine wave at the point + * of the matched filter's rolloff (if it's a raised-cosine, the + * derivative of a cosine is a sine). Extend this sine by another + * quarter wave to make a half wave around the band-edges is + * equivalent in time to the sum of two sinc functions. The + * baseband filter fot the band edges is therefore derived from + * this sum of sincs. The band edge filters are then just the + * baseband signal modulated to the correct place in + * frequency. All of these calculations are done in the + * 'design_filter' function. + * + * Note: We use FIR filters here because the filters have to have + * a flat phase response over the entire frequency range to allow + * their comparisons to be valid. + * + * It is very important that the band edge filters be the + * derivatives of the pulse shaping filter, and that they be + * linear phase. Otherwise, the variance of the error will be very + * large. + */ + class DIGITAL_API fll_band_edge_cc + : virtual public gr_sync_block, + virtual public gri_control_loop + { + public: + // gr::digital::fll_band_edge_cc::sptr + typedef boost::shared_ptr<fll_band_edge_cc> sptr; + + /*! + * Make an FLL block. + * + * \param samps_per_sym (float) number of samples per symbol + * \param rolloff (float) Rolloff (excess bandwidth) of signal filter + * \param filter_size (int) number of filter taps to generate + * \param bandwidth (float) Loop bandwidth + */ + static sptr make(float samps_per_sym, float rolloff, + int filter_size, float bandwidth); + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Set the number of samples per symbol + * + * Set's the number of samples per symbol the system should + * use. This value is uesd to calculate the filter taps and will + * force a recalculation. + * + * \param sps (float) new samples per symbol + */ + virtual void set_samples_per_symbol(float sps) = 0; + + /*! + * \brief Set the rolloff factor of the shaping filter + * + * This sets the rolloff factor that is used in the pulse + * shaping filter and is used to calculate the filter + * taps. Changing this will force a recalculation of the filter + * taps. + * + * This should be the same value that is used in the + * transmitter's pulse shaping filter. It must be between 0 and + * 1 and is usually between 0.2 and 0.5 (where 0.22 and 0.35 are + * commonly used values). + * + * \param rolloff (float) new shaping filter rolloff factor [0,1] + */ + virtual void set_rolloff(float rolloff) = 0; + + /*! + * \brief Set the number of taps in the filter + * + * This sets the number of taps in the band-edge + * filters. Setting this will force a recalculation of the + * filter taps. + * + * This should be about the same number of taps used in the + * transmitter's shaping filter and also not very large. A large + * number of taps will result in a large delay between input and + * frequency estimation, and so will not be as accurate. Between + * 30 and 70 taps is usual. + * + * \param filter_size (float) number of taps in the filters + */ + virtual void set_filter_size(int filter_size) = 0; + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the number of sampler per symbol used for the filter + */ + virtual float samples_per_symbol() const = 0; + + /*! + * \brief Returns the rolloff factor used for the filter + */ + virtual float rolloff() const = 0; + + /*! + * \brief Returns the number of taps of the filter + */ + virtual int filter_size() const = 0; + + /*! + * Print the taps to screen. + */ + virtual void print_taps() = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_FLL_BAND_EDGE_CC_H */ diff --git a/gr-digital/include/digital/framer_sink_1.h b/gr-digital/include/digital/framer_sink_1.h new file mode 100644 index 0000000000..13e649b1f2 --- /dev/null +++ b/gr-digital/include/digital/framer_sink_1.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2012 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_GR_FRAMER_SINK_1_H +#define INCLUDED_GR_FRAMER_SINK_1_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace digital { + + /*! + * \brief Given a stream of bits and access_code flags, assemble packets. + * \ingroup sink_blk + * + * input: stream of bytes from digital_correlate_access_code_bb + * output: none. Pushes assembled packet into target queue + * + * The framer expects a fixed length header of 2 16-bit shorts + * containing the payload length, followed by the payload. If the + * 2 16-bit shorts are not identical, this packet is + * ignored. Better algs are welcome. + * + * The input data consists of bytes that have two bits used. Bit + * 0, the LSB, contains the data bit. Bit 1 if set, indicates that + * the corresponding bit is the the first bit of the packet. That + * is, this bit is the first one after the access code. + */ + class DIGITAL_API framer_sink_1 : virtual public gr_sync_block + { + public: + // gr::digital::framer_sink_1::sptr + typedef boost::shared_ptr<framer_sink_1> sptr; + + /*! + * Make a framer_sink_1 block. + * + * \param target_queue The message queue where frames go. + */ + static sptr make(gr_msg_queue_sptr target_queue); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gr-digital/include/digital/glfsr.h b/gr-digital/include/digital/glfsr.h new file mode 100644 index 0000000000..211956e842 --- /dev/null +++ b/gr-digital/include/digital/glfsr.h @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 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_GLFSR_H +#define INCLUDED_DIGITAL_GLFSR_H + +#include <digital/api.h> + +namespace gr { + namespace digital { + + /*! + * \brief Galois Linear Feedback Shift Register using specified polynomial mask + * \ingroup misc + * + * Generates a maximal length pseudo-random sequence of length 2^degree-1 + */ + + class DIGITAL_API glfsr + { + private: + int d_shift_register; + int d_mask; + + public: + glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; } + ~glfsr(); + + static int glfsr_mask(int degree); + + unsigned char next_bit() + { + unsigned char bit = d_shift_register & 1; + d_shift_register >>= 1; + if(bit) + d_shift_register ^= d_mask; + return bit; + } + + int mask() const { return d_mask; } + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_GLFSR_H */ diff --git a/gr-digital/include/digital/glfsr_source_b.h b/gr-digital/include/digital/glfsr_source_b.h new file mode 100644 index 0000000000..9e245875d4 --- /dev/null +++ b/gr-digital/include/digital/glfsr_source_b.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 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_GR_GLFSR_SOURCE_B_H +#define INCLUDED_GR_GLFSR_SOURCE_B_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Galois LFSR pseudo-random source + * \ingroup source_blk + */ + class DIGITAL_API glfsr_source_b : virtual public gr_sync_block + { + public: + // gr::digital::glfsr_source_b::sptr + typedef boost::shared_ptr<glfsr_source_b> sptr; + + /*! + * Make a Galois LFSR pseudo-random source block. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ + static sptr make(int degree, bool repeat=true, + int mask=0, int seed=1); + + virtual unsigned int period() const = 0; + virtual int mask() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_GLFSR_SOURCE_B_H */ diff --git a/gr-digital/include/digital/glfsr_source_f.h b/gr-digital/include/digital/glfsr_source_f.h new file mode 100644 index 0000000000..4feb3562b3 --- /dev/null +++ b/gr-digital/include/digital/glfsr_source_f.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 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_GR_GLFSR_SOURCE_F_H +#define INCLUDED_GR_GLFSR_SOURCE_F_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0. + * \ingroup source_blk + */ + class DIGITAL_API glfsr_source_f : virtual public gr_sync_block + { + public: + // gr::digital::glfsr_source_f::sptr + typedef boost::shared_ptr<glfsr_source_f> sptr; + + /*! + * Make a Galois LFSR pseudo-random source block. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ + static sptr make(int degree, bool repeat=true, + int mask=0, int seed=1); + + virtual unsigned int period() const = 0; + virtual int mask() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_GLFSR_SOURCE_F_H */ diff --git a/gr-digital/include/digital/kurtotic_equalizer_cc.h b/gr-digital/include/digital/kurtotic_equalizer_cc.h new file mode 100644 index 0000000000..2753cb3cce --- /dev/null +++ b/gr-digital/include/digital/kurtotic_equalizer_cc.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_KURTOTIC_EQUALIZER_CC_H +#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace digital { + + /*! + * \brief Implements a kurtosis-based adaptive equalizer on complex stream + * \ingroup eq_blk + * \ingroup digital + * + * WARNING: This block does not yet work. + * + * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind + * equalization algorithm," IEEE Conf. on Control, Automation, + * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." + */ + class DIGITAL_API kurtotic_equalizer_cc : + virtual public gr_sync_decimator + { + protected: + virtual gr_complex error(const gr_complex &out) = 0; + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + public: + // gr::digital::kurtotic_equalizer_cc::sptr + typedef boost::shared_ptr<kurtotic_equalizer_cc> sptr; + + static sptr make(int num_taps, float mu); + + virtual float gain() const = 0; + virtual void set_gain(float mu) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital/lms_dd_equalizer_cc.h b/gr-digital/include/digital/lms_dd_equalizer_cc.h new file mode 100644 index 0000000000..ecac9ac476 --- /dev/null +++ b/gr-digital/include/digital/lms_dd_equalizer_cc.h @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_LMS_DD_EQUALIZER_CC_H +#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> +#include <digital/constellation.h> + +namespace gr { + namespace digital { + + /*! + * \brief Least-Mean-Square Decision Directed Equalizer (complex in/out) + * \ingroup eq_blk + * \ingroup digital + * + * This block implements an LMS-based decision-directed equalizer. + * It uses a set of weights, w, to correlate against the inputs, + * u, and a decisions is then made from this output. The error in + * the decision is used to update teh weight vector. + * + * y[n] = conj(w[n]) u[n] + * d[n] = decision(y[n]) + * e[n] = d[n] - y[n] + * w[n+1] = w[n] + mu u[n] conj(e[n]) + * + * Where mu is a gain value (between 0 and 1 and usualy small, + * around 0.001 - 0.01. + * + * This block uses the digital_constellation object for making the + * decision from y[n]. Create the constellation object for + * whatever constellation is to be used and pass in the object. + * In Python, you can use something like: + * + * self.constellation = digital.constellation_qpsk() + * + * To create a QPSK constellation (see the digital_constellation + * block for more details as to what constellations are available + * or how to create your own). You then pass the object to this + * block as an sptr, or using "self.constellation.base()". + * + * The theory for this algorithm can be found in Chapter 9 of: + * S. Haykin, Adaptive Filter Theory, Upper Saddle River, NJ: + * Prentice Hall, 1996. + */ + class DIGITAL_API lms_dd_equalizer_cc : + virtual public gr_sync_decimator + { + protected: + virtual gr_complex error(const gr_complex &out) = 0; + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + public: + // gr::digital::lms_dd_equalizer_cc::sptr + typedef boost::shared_ptr<lms_dd_equalizer_cc> sptr; + + /*! + * Make an LMS decision-directed equalizer + * + * \param num_taps Numer of taps in the equalizer (channel size) + * \param mu Gain of the update loop + * \param sps Number of samples per symbol of the input signal + * \param cnst A constellation derived from class + * 'constellation'. Use base() method to get a shared pointer to + * this base class type. + */ + static sptr make(int num_taps, + float mu, int sps, + constellation_sptr cnst); + + virtual float gain() const = 0; + virtual void set_gain(float mu) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H */ diff --git a/gr-digital/include/digital_map_bb.h b/gr-digital/include/digital/map_bb.h index 4aca66fbe1..6a380e2cc1 100644 --- a/gr-digital/include/digital_map_bb.h +++ b/gr-digital/include/digital/map_bb.h @@ -19,44 +19,44 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_GR_MAP_BB_H #define INCLUDED_GR_MAP_BB_H -#include <digital_api.h> +#include <digital/api.h> #include <gr_sync_block.h> -class digital_map_bb; -typedef boost::shared_ptr<digital_map_bb> digital_map_bb_sptr; - -DIGITAL_API digital_map_bb_sptr -digital_make_map_bb(const std::vector<int> &map); - -/*! - * \brief output[i] = map[input[i]] - * \ingroup coding_blk - * - * This block maps an incoming signal to the value in the map. - * The block expects that the incoming signal has a maximum - * value of len(map)-1. - * - * -> output[i] = map[input[i]] - * - * \param map a vector of integers. - */ - -class DIGITAL_API digital_map_bb : public gr_sync_block -{ - friend DIGITAL_API digital_map_bb_sptr - digital_make_map_bb(const std::vector<int> &map); - - unsigned char d_map[0x100]; - - digital_map_bb(const std::vector<int> &map); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; +namespace gr { + namespace digital { + + /*! + * \brief output[i] = map[input[i]] + * \ingroup coding_blk + * + * This block maps an incoming signal to the value in the map. + * The block expects that the incoming signal has a maximum + * value of len(map)-1. + * + * -> output[i] = map[input[i]] + */ + class DIGITAL_API map_bb : virtual public gr_sync_block + { + public: + // gr::digital::map_bb::sptr + typedef boost::shared_ptr<map_bb> sptr; + + /*! + * Make a map block. + * + * \param map a vector of integers that maps x to map[x]. + */ + static sptr make(const std::vector<int> &map); + + virtual void set_map(const std::vector<int> &map) = 0; + virtual std::vector<int> map() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ #endif /* INCLUDED_GR_MAP_BB_H */ diff --git a/gr-digital/include/digital_metric_type.h b/gr-digital/include/digital/metric_type.h index 83de166f09..c277f01d27 100644 --- a/gr-digital/include/digital_metric_type.h +++ b/gr-digital/include/digital/metric_type.h @@ -23,9 +23,15 @@ #ifndef INCLUDED_DIGITAL_METRIC_TYPE_H #define INCLUDED_DIGITAL_METRIC_TYPE_H -typedef enum { - TRELLIS_EUCLIDEAN = 200, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT -} trellis_metric_type_t; +namespace gr { + namespace digital { -#endif + typedef enum { + TRELLIS_EUCLIDEAN = 200, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT + } trellis_metric_type_t; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_METRIC_TYPE_H */ diff --git a/gr-digital/include/digital/mpsk_receiver_cc.h b/gr-digital/include/digital/mpsk_receiver_cc.h new file mode 100644 index 0000000000..14094e25b7 --- /dev/null +++ b/gr-digital/include/digital/mpsk_receiver_cc.h @@ -0,0 +1,147 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2011,2012 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_MPSK_RECEIVER_CC_H +#define INCLUDED_DIGITAL_MPSK_RECEIVER_CC_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief This block takes care of receiving M-PSK modulated + * signals through phase, frequency, and symbol synchronization. + * \ingroup sync_blk + * \ingroup demod_blk + * \ingroup digital + * + * This block takes care of receiving M-PSK modulated signals + * through phase, frequency, and symbol synchronization. It + * performs carrier frequency and phase locking as well as symbol + * timing recovery. It works with (D)BPSK, (D)QPSK, and (D)8PSK + * as tested currently. It should also work for OQPSK and PI/4 + * DQPSK. + * + * The phase and frequency synchronization are based on a Costas + * loop that finds the error of the incoming signal point compared + * to its nearest constellation point. The frequency and phase of + * the NCO are updated according to this error. There are + * optimized phase error detectors for BPSK and QPSK, but 8PSK is + * done using a brute-force computation of the constellation + * points to find the minimum. + * + * The symbol synchronization is done using a modified Mueller and + * Muller circuit from the paper: + * + * "G. R. Danesfahani, T. G. Jeans, "Optimisation of modified Mueller + * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 + * June 1995, pp. 1032 - 1033." + * + * This circuit interpolates the downconverted sample (using the + * NCO developed by the Costas loop) every mu samples, then it + * finds the sampling error based on this and the past symbols and + * the decision made on the samples. Like the phase error + * detector, there are optimized decision algorithms for BPSK and + * QPKS, but 8PSK uses another brute force computation against all + * possible symbols. The modifications to the M&M used here reduce + * self-noise. + * + */ + class DIGITAL_API mpsk_receiver_cc : virtual public gr_block + { + public: + // gr::digital::mpsk_receiver_cc::sptr + typedef boost::shared_ptr<mpsk_receiver_cc> sptr; + + /*! + * \brief Buil M-PSK receiver block. + * + * \param M modulation order of the M-PSK modulation + * \param theta any constant phase rotation from the real axis of the constellation + * \param loop_bw Loop bandwidth to set gains of phase/freq tracking loop + * \param fmin minimum normalized frequency value the loop can achieve + * \param fmax maximum normalized frequency value the loop can achieve + * \param mu initial parameter for the interpolator [0,1] + * \param gain_mu gain parameter of the M&M error signal to adjust mu (~0.05) + * \param omega initial value for the number of symbols between samples (~number of samples/symbol) + * \param gain_omega gain parameter to adjust omega based on the error (~omega^2/4) + * \param omega_rel sets the maximum (omega*(1+omega_rel)) and minimum (omega*(1+omega_rel)) omega (~0.005) + * + * The constructor also chooses which phase detector and + * decision maker to use in the work loop based on the value of + * M. + */ + static sptr make(unsigned int M, float theta, + float loop_bw, + float fmin, float fmax, + float mu, float gain_mu, + float omega, float gain_omega, float omega_rel); + + //! Returns the modulation order (M) currently set + virtual float modulation_order() const = 0; + + //! Returns current value of theta + virtual float theta() const = 0; + + //! Returns current value of mu + virtual float mu() const = 0; + + //! Returns current value of omega + virtual float omega() const = 0; + + //! Returns mu gain factor + virtual float gain_mu() const = 0; + + //! Returns omega gain factor + virtual float gain_omega() const = 0; + + //! Returns the relative omega limit + virtual float gain_omega_rel() const = 0; + + //! Sets the modulation order (M) currently + virtual void set_modulation_order(unsigned int M) = 0; + + //! Sets value of theta + virtual void set_theta(float theta) = 0; + + //! Sets value of mu + virtual void set_mu(float mu) = 0; + + //! Sets value of omega and its min and max values + virtual void set_omega(float omega) = 0; + + //! Sets value for mu gain factor + virtual void set_gain_mu(float gain_mu) = 0; + + //! Sets value for omega gain factor + virtual void set_gain_omega(float gain_omega) = 0; + + //! Sets the relative omega limit and resets omega min/max values + virtual void set_gain_omega_rel(float omega_rel) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_RECEIVER_CC_H */ diff --git a/gr-digital/include/digital/mpsk_snr_est.h b/gr-digital/include/digital/mpsk_snr_est.h new file mode 100644 index 0000000000..69c03430d3 --- /dev/null +++ b/gr-digital/include/digital/mpsk_snr_est.h @@ -0,0 +1,287 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_MPSK_SNR_EST_H +#define INCLUDED_DIGITAL_MPSK_SNR_EST_H + +#include <digital/api.h> +#include <gr_complex.h> + +namespace gr { + namespace digital { + + //! Enum for the type of SNR estimator to select + /*! \ingroup snr_blk + * \anchor ref_snr_est_types + * + * Below are some ROUGH estimates of what values of SNR each of + * these types of estimators is good for. In general, these offer + * a trade-off between accuracy and performance. + * + * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB) + * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB) + * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB) + * \li SNR_EST_SVR: SVR-based est (>= 0dB) + */ + typedef enum { + SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) + SNR_EST_SKEW, // Skewness-base est (>= 5 dB) + SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) + SNR_EST_SVR // SVR-based est (>= 0dB) + } snr_est_type_t; + + /*! \brief A parent class for SNR estimators, specifically for + * M-PSK signals in AWGN channels. + * \ingroup snr_blk + */ + class DIGITAL_API mpsk_snr_est + { + protected: + double d_alpha, d_beta; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est(double alpha); + virtual ~mpsk_snr_est(); + + //! Get the running-average coefficient + double alpha() const; + + //! Set the running-average coefficient + void set_alpha(double alpha); + + //! Update the current registers + virtual int update(int noutput_items, + const gr_complex *input); + + //! Use the register values to compute a new estimate + virtual double snr(); + }; + + + //! \brief SNR Estimator using simple mean/variance estimates. + /*! \ingroup snr_blk + * + * A very simple SNR estimator that just uses mean and variance + * estimates of an M-PSK constellation. This esimator is quick + * and cheap and accurate for high SNR (above 7 dB or so) but + * quickly starts to overestimate the SNR at low SNR. + */ + class DIGITAL_API mpsk_snr_est_simple : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_simple(double alpha); + ~mpsk_snr_est_simple() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using skewness correction. + /*! \ingroup snr_blk + * + * This is an estimator that came from a discussion between Tom + * Rondeau and fred harris with no known paper reference. The + * idea is that at low SNR, the variance estimations will be + * affected because of fold-over around the decision boundaries, + * which results in a skewness to the samples. We estimate the + * skewness and use this as a correcting term. + */ + class DIGITAL_API mpsk_snr_est_skew : + public mpsk_snr_est + { + private: + double d_y1, d_y2, d_y3; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_skew(double alpha); + ~mpsk_snr_est_skew() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using 2nd and 4th-order moments. + /*! \ingroup snr_blk + * + * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th + * (M4) order moments. This estimator uses knowledge of the + * kurtosis of the signal (k_a) and noise (k_w) to make its + * estimation. We use Beaulieu's approximations here to M-PSK + * signals and AWGN channels such that k_a=1 and k_w=2. These + * approximations significantly reduce the complexity of the + * calculations (and computations) required. + * + * Reference: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API mpsk_snr_est_m2m4 : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_m2m4(double alpha); + ~mpsk_snr_est_m2m4() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using 2nd and 4th-order moments. + /*! \ingroup snr_blk + * + * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th + * (M4) order moments. This estimator uses knowledge of the + * kurtosis of the signal (k_a) and noise (k_w) to make its + * estimation. In this case, you can set your own estimations for + * k_a and k_w, the kurtosis of the signal and noise, to fit this + * estimation better to your signal and channel conditions. + * + * A word of warning: this estimator has not been fully tested or + * proved with any amount of rigor. The estimation for M4 in + * particular might be ignoring effectf of when k_a and k_w are + * different. Use this estimator with caution and a copy of the + * reference on hand. + * + * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify + * the computations for M-PSK and AWGN channels. Use that + * estimator unless you have a way to guess or estimate these + * values here. + * + * Original paper: + * R. Matzner, "An SNR estimation algorithm for complex baseband + * signal using higher order statistics," Facta Universitatis + * (Nis), no. 6, pp. 41-52, 1993. + * + * Reference used in derivation: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API snr_est_m2m4 : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + double d_ka, d_kw; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + * \param ka: estimate of the signal kurtosis (1 for PSK) + * \param kw: estimate of the channel noise kurtosis (2 for AWGN) + */ + snr_est_m2m4(double alpha, double ka, double kw); + ~snr_est_m2m4() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief Signal-to-Variation Ratio SNR Estimator. + /*! \ingroup snr_blk + * + * This estimator actually comes from an SNR estimator for M-PSK + * signals in fading channels, but this implementation is + * specifically for AWGN channels. The math was simplified to + * assume a signal and noise kurtosis (k_a and k_w) for M-PSK + * signals in AWGN. These approximations significantly reduce the + * complexity of the calculations (and computations) required. + * + * Original paper: + * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service + * monitoring of multipath delay and cochannel interference for + * indoor mobile communication systems," Proc. IEEE + * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994. + * + * Reference: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API mpsk_snr_est_svr : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_svr(double alpha); + ~mpsk_snr_est_svr() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_H */ diff --git a/gr-digital/include/digital/mpsk_snr_est_cc.h b/gr-digital/include/digital/mpsk_snr_est_cc.h new file mode 100644 index 0000000000..c2d1fd43d2 --- /dev/null +++ b/gr-digital/include/digital/mpsk_snr_est_cc.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_MPSK_SNR_EST_CC_H +#define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H + +#include <digital/api.h> +#include <digital/mpsk_snr_est.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + //! \brief A block for computing SNR of a signal. + /*! \ingroup snr_blk + * + * This block can be used to monitor and retrieve estimations of + * the signal SNR. It is designed to work in a flowgraph and + * passes all incoming data along to its output. + * + * The block is designed for use with M-PSK signals + * especially. The type of estimator is specified as the \p type + * parameter in the constructor. The estimators tend to trade off + * performance for accuracy, although experimentation should be + * done to figure out the right approach for a given + * implementation. Further, the current set of estimators are + * designed and proven theoretically under AWGN conditions; some + * amount of error should be assumed and/or estimated for real + * channel conditions. + */ + class DIGITAL_API mpsk_snr_est_cc : virtual public gr_sync_block + { + public: + // gr::digital::mpsk_snr_est_cc::sptr + typedef boost::shared_ptr<mpsk_snr_est_cc> sptr; + + /*! Factory function returning shared pointer of this class + * + * Parameters: + * + * \param type: the type of estimator to use \ref ref_snr_est_types + * "snr_est_type_t" for details about the available types + * \param tag_nsamples: after this many samples, a tag containing + * the SNR (key='snr') will be sent + * \param alpha: the update rate of internal running average + * calculations + */ + static sptr make(snr_est_type_t type, + int tag_nsamples=10000, + double alpha=0.001); + + //! Return the estimated signal-to-noise ratio in decibels + virtual double snr() = 0; + + //! Return the type of estimator in use + virtual snr_est_type_t type() const = 0; + + //! Return how many samples between SNR tags + virtual int tag_nsample() const = 0; + + //! Get the running-average coefficient + virtual double alpha() const = 0; + + //! Set type of estimator to use + virtual void set_type(snr_est_type_t t) = 0; + + //! Set the number of samples between SNR tags + virtual void set_tag_nsample(int n) = 0; + + //! Set the running-average coefficient + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H */ diff --git a/gr-digital/include/digital/ofdm_cyclic_prefixer.h b/gr-digital/include/digital/ofdm_cyclic_prefixer.h new file mode 100644 index 0000000000..551d1ee834 --- /dev/null +++ b/gr-digital/include/digital/ofdm_cyclic_prefixer.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004-2006,2011,2012 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_OFDM_CYCLIC_PREFIXER_H +#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H + +#include <digital/api.h> +#include <gr_sync_interpolator.h> + +namespace gr { + namespace digital { + + /*! + * \brief adds a cyclic prefix vector to an input size long ofdm + * symbol(vector) and converts vector to a stream output_size + * long. + * \ingroup ofdm_blk + */ + class DIGITAL_API ofdm_cyclic_prefixer : virtual public gr_sync_interpolator + { + public: + // gr::digital::ofdm_cyclic_prefixer::sptr + typedef boost::shared_ptr<ofdm_cyclic_prefixer> sptr; + + /*! + * Make an OFDM cyclic prefix adder block. + * + * \param input_size size of the input symbol + * \param output_size output of the symbol + * (CP len = output_size - input_size) + */ + static sptr make(size_t input_size, size_t output_size); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ diff --git a/gr-digital/include/digital/ofdm_frame_acquisition.h b/gr-digital/include/digital/ofdm_frame_acquisition.h new file mode 100644 index 0000000000..ec49b47f97 --- /dev/null +++ b/gr-digital/include/digital/ofdm_frame_acquisition.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2011,2012 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_OFDM_FRAME_ACQUISITION_H +#define INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H + +#include <digital/api.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace digital { + + /*! + * \brief take a vector of complex constellation points in from an + * FFT and performs a correlation and equalization. + * \ingroup demodulation_blk + * \ingroup ofdm_blk + * + * This block takes the output of an FFT of a received OFDM symbol + * and finds the start of a frame based on two known symbols. It + * also looks at the surrounding bins in the FFT output for the + * correlation in case there is a large frequency shift in the + * data. This block assumes that the fine frequency shift has + * already been corrected and that the samples fall in the middle + * of one FFT bin. + * + * It then uses one of those known symbols to estimate the channel + * response over all subcarriers and does a simple 1-tap + * equalization on all subcarriers. This corrects for the phase + * and amplitude distortion caused by the channel. + */ + class DIGITAL_API ofdm_frame_acquisition : virtual public gr_block + { + public: + // gr::digital::ofdm_frame_acquisition::sptr + typedef boost::shared_ptr<ofdm_frame_acquisition> sptr; + + /*! + * Make an OFDM correlator and equalizer. + * + * \param occupied_carriers The number of subcarriers with data in the received symbol + * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers) + * \param cplen The length of the cycle prefix + * \param known_symbol A vector of complex numbers representing a known symbol at the + * start of a frame (usually a BPSK PN sequence) + * \param max_fft_shift_len Set's the maximum distance you can look between bins for correlation + */ + static sptr make(unsigned int occupied_carriers, unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len=4); + + /*! + * \brief Return an estimate of the SNR of the channel + */ + virtual float snr() = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H */ diff --git a/gr-digital/include/digital/ofdm_frame_sink.h b/gr-digital/include/digital/ofdm_frame_sink.h new file mode 100644 index 0000000000..427d6eb460 --- /dev/null +++ b/gr-digital/include/digital/ofdm_frame_sink.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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_OFDM_FRAME_SINK_H +#define INCLUDED_DIGITAL_OFDM_FRAME_SINK_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace digital { + + /*! + * \brief Takes an OFDM symbol in, demaps it into bits of 0's and + * 1's, packs them into packets, and sends to to a message queue + * sink. + * \ingroup sink_blk + * \ingroup ofdm_blk + * + * NOTE: The mod input parameter simply chooses a pre-defined + * demapper/slicer. Eventually, we want to be able to pass in a + * reference to an object to do the demapping and slicing for a + * given modulation type. + */ + class DIGITAL_API ofdm_frame_sink : virtual public gr_sync_block + { + public: + // gr::digital::ofdm_frame_sink::sptr + typedef boost::shared_ptr<ofdm_frame_sink> sptr; + + /*! + * Make an OFDM frame sink block. + * + * \param sym_position vector of OFDM carrier symbols in complex space + * \param sym_value_out vector of bit mapped from the complex symbol space + * \param target_queue message queue for the packets to go into + * \param occupied_tones The number of subcarriers with data in the received symbol + * \param phase_gain gain of the phase tracking loop + * \param freq_gain gain of the frequency tracking loop + */ + static sptr make(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out, + gr_msg_queue_sptr target_queue, + int occupied_tones, + float phase_gain=0.25, float freq_gain=0.25*0.25/4); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_OFDM_FRAME_SINK_H */ diff --git a/gr-digital/include/digital/ofdm_insert_preamble.h b/gr-digital/include/digital/ofdm_insert_preamble.h new file mode 100644 index 0000000000..27db837e42 --- /dev/null +++ b/gr-digital/include/digital/ofdm_insert_preamble.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H +#define INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H + +#include <digital/api.h> +#include <gr_block.h> +#include <vector> + +namespace gr { + namespace digital { + + /*! + * \brief insert "pre-modulated" preamble symbols before each payload. + * \ingroup sync_blk + * \ingroup ofdm_blk + * + * <pre> + * input 1: stream of vectors of gr_complex [fft_length] + * These are the modulated symbols of the payload. + * + * input 2: stream of char. The LSB indicates whether the corresponding + * symbol on input 1 is the first symbol of the payload or not. + * It's a 1 if the corresponding symbol is the first symbol, + * otherwise 0. + * + * N.B., this implies that there must be at least 1 symbol in the payload. + * + * + * output 1: stream of vectors of gr_complex [fft_length] + * These include the preamble symbols and the payload symbols. + * + * output 2: stream of char. The LSB indicates whether the corresponding + * symbol on input 1 is the first symbol of a packet (i.e., the + * first symbol of the preamble.) It's a 1 if the corresponding + * symbol is the first symbol, otherwise 0. + * </pre> + * + * \param fft_length length of each symbol in samples. + * \param preamble vector of symbols that represent the pre-modulated preamble. + */ + class DIGITAL_API ofdm_insert_preamble : virtual public gr_block + { + public: + // gr::digital::ofdm_insert_preamble::sptr + typedef boost::shared_ptr<ofdm_insert_preamble> sptr; + + /*! + * Make an OFDM preamble inserter block. + * + * \param fft_length length of each symbol in samples. + * \param preamble vector of symbols that represent the pre-modulated preamble. + */ + static sptr make(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); + + virtual void enter_preamble() = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H */ diff --git a/gr-digital/include/digital/ofdm_mapper_bcv.h b/gr-digital/include/digital/ofdm_mapper_bcv.h new file mode 100644 index 0000000000..1e541d2edb --- /dev/null +++ b/gr-digital/include/digital/ofdm_mapper_bcv.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2011,2012 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_OFDM_MAPPER_BCV_H +#define INCLUDED_DIGITAL_OFDM_MAPPER_BCV_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace digital { + + /*! + * \brief take a stream of bytes in and map to a vector of complex + * constellation points suitable for IFFT input to be used in an + * ofdm modulator. + * \ingroup modulation_blk + * \ingroup ofdm_blk + * + * Abstract class must be subclassed with specific mapping. + */ + class DIGITAL_API ofdm_mapper_bcv : virtual public gr_sync_block + { + public: + // gr::digital::ofdm_mapper_bcv::sptr + typedef boost::shared_ptr<ofdm_mapper_bcv> sptr; + + /*! + * Make an OFDM mapper block. + * + * \param constellation vector of OFDM carrier symbols in complex space + * \param msgq_limit limit on number of messages the queue can store + * \param occupied_carriers The number of subcarriers with data in the received symbol + * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers) + */ + static sptr make(const std::vector<gr_complex> &constellation, + unsigned msgq_limit, + unsigned occupied_carriers, + unsigned int fft_length); + + virtual gr_msg_queue_sptr msgq() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_MAPPER_BCV_H */ diff --git a/gr-digital/include/digital/ofdm_sampler.h b/gr-digital/include/digital/ofdm_sampler.h new file mode 100644 index 0000000000..5df16be3e4 --- /dev/null +++ b/gr-digital/include/digital/ofdm_sampler.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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_OFDM_SAMPLER_H +#define INCLUDED_DIGITAL_OFDM_SAMPLER_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief does the rest of the OFDM stuff + * \ingroup ofdm_blk + */ + class DIGITAL_API ofdm_sampler : virtual public gr_block + { + public: + // gr::digital::ofdm_sampler::sptr + typedef boost::shared_ptr<ofdm_sampler> sptr; + + /*! + * Make an OFDM sampler block. + * + * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers) + * \param symbol_length Length of the full symbol (fft_length + CP length) + * \param timeout timeout in samples when we stop looking for a symbol after initial ack. + */ + static sptr make(unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout=1000); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_SAMPLER_H */ diff --git a/gr-digital/include/digital/packet_sink.h b/gr-digital/include/digital/packet_sink.h new file mode 100644 index 0000000000..cca3d49cec --- /dev/null +++ b/gr-digital/include/digital/packet_sink.h @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012 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_GR_PACKET_SINK_H +#define INCLUDED_GR_PACKET_SINK_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace digital { + + /*! + * \brief process received bits looking for packet sync, header, + * and process bits into packet + * \ingroup sink_blk + * + * input: stream of symbols to be sliced. + * + * output: none. Pushes assembled packet into target queue + * + * The packet sink takes in a stream of binary symbols that are + * sliced around 0. The bits are then checked for the \p + * sync_vector to determine find and decode the packet. It then + * expects a fixed length header of 2 16-bit shorts containing the + * payload length, followed by the payload. If the 2 16-bit shorts + * are not identical, this packet is ignored. Better algs are + * welcome. + * + * This block is not very useful anymore as it only works with + * 2-level modulations such as BPSK or GMSK. The block can + * generally be replaced with a correlate access code and frame + * sink blocks. + */ + class DIGITAL_API packet_sink : virtual public gr_sync_block + { + public: + // gr::digital::packet_sink::sptr + typedef boost::shared_ptr<packet_sink> sptr; + + /*! + * Make a packet_sink block. + * + * \param sync_vector The synchronization vector as a vector of 1's and 0's. + * \param target_queue The message queue that packets are sent to. + * \param threshold Number of bits that can be incorrect in the \p sync_vector. + */ + static sptr make(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold=-1); + + //! return true if we detect carrier + virtual bool carrier_sensed() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACKET_SINK_H */ diff --git a/gr-digital/include/digital/pfb_clock_sync_ccf.h b/gr-digital/include/digital/pfb_clock_sync_ccf.h new file mode 100644 index 0000000000..901858c180 --- /dev/null +++ b/gr-digital/include/digital/pfb_clock_sync_ccf.h @@ -0,0 +1,318 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_CCF_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_H + +#include <digital/api.h> +#include <filter/fir_filter.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \class digital_pfb_clock_sync_ccf + * + * \brief Timing synchronizer using polyphase filterbanks + * + * \ingroup filter_blk + * \ingroup pfb_blk + * + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. + * + * This approach works by setting up two filterbanks; one + * filterbank contains the signal's pulse shaping matched filter + * (such as a root raised cosine filter), where each branch of the + * filterbank contains a different phase of the filter. The + * second filterbank contains the derivatives of the filters in + * the first filterbank. Thinking of this in the time domain, the + * first filterbank contains filters that have a sinc shape to + * them. We want to align the output signal to be sampled at + * exactly the peak of the sinc shape. The derivative of the sinc + * contains a zero at the maximum point of the sinc (sinc(0) = 1, + * sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. + * + * If the signal out of the derivative filters is d_i[n] for the + * ith filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error + * in the real and imaginary parts. There are two reasons we + * multiply by the signal itself. First, if the symbol could be + * positive or negative going, but we want the error term to + * always tell us to go in the same direction depending on which + * side of the zero point we are on. The sign of x_i[n] adjusts + * the error term to do this. Second, the magnitude of x_i[n] + * scales the error term depending on the symbol's amplitude, so + * larger signals give us a stronger error term because we have + * more confidence in that symbol's value. Using the magnitude of + * x_i[n] instead of just the sign is especially good for signals + * with low SNR. + * + * The error signal, e[n], gives us a value proportional to how + * far away from the zero point we are in the derivative + * signal. We want to drive this value to zero, so we set up a + * second order loop. We have two variables for this loop; d_k is + * the filter number in the filterbank we are on and d_rate is the + * rate which we travel through the filters in the steady + * state. That is, due to the natural clock differences between + * the transmitter and receiver, d_rate represents that difference + * and would traverse the filter phase paths to keep the receiver + * locked. Thinking of this as a second-order PLL, the d_rate is + * the frequency and d_k is the phase. So we update d_rate and d_k + * using the standard loop equations based on two error signals, + * d_alpha and d_beta. We have these two values set based on each + * other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while + * d_beta is equal to (gain^2)/4. + * + * The block's parameters are: + * + * \li \p sps: The clock sync block needs to know the number of + * samples per symbol, because it defaults to return a single + * point representing the symbol. The sps can be any positive real + * number and does not need to be an integer. + * + * \li \p loop_bw: The loop bandwidth is used to set the gain of + * the inner control loop (see: + * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). + * This should be set small (a value of around 2pi/100 is + * suggested in that blog post as the step size for the number of + * radians around the unit circle to move relative to the error). + * + * \li \p taps: One of the most important parameters for this + * block is the taps of the filter. One of the benefits of this + * algorithm is that you can put the matched filter in here as the + * taps, so you get both the matched filter and sample timing + * correction in one go. So create your normal matched filter. For + * a typical digital modulation, this is a root raised cosine + * filter. The number of taps of this filter is based on how long + * you expect the channel to be; that is, how many symbols do you + * want to combine to get the current symbols energy back (there's + * probably a better way of stating that). It's usually 5 to 10 or + * so. That gives you your filter, but now we need to think about + * it as a filter with different phase profiles in each filter. So + * take this number of taps and multiply it by the number of + * filters. This is the number you would use to create your + * prototype filter. When you use this in the PFB filerbank, it + * segments these taps into the filterbanks in such a way that + * each bank now represents the filter at different phases, + * equally spaced at 2pi/N, where N is the number of filters. + * + * \li \p filter_size (default=32): The number of filters can also + * be set and defaults to 32. With 32 filters, you get a good + * enough resolution in the phase to produce very small, almost + * unnoticeable, ISI. Going to 64 filters can reduce this more, + * but after that there is very little gained for the extra + * complexity. + * + * \li \p init_phase (default=0): The initial phase is another + * settable parameter and refers to the filter path the algorithm + * initially looks at (i.e., d_k starts at init_phase). This value + * defaults to zero, but it might be useful to start at a + * different phase offset, such as the mid-point of the filters. + * + * \li \p max_rate_deviation (default=1.5): The next parameter is + * the max_rate_devitation, which defaults to 1.5. This is how far + * we allow d_rate to swing, positive or negative, from + * 0. Constraining the rate can help keep the algorithm from + * walking too far away to lock during times when there is no + * signal. + * + * \li \p osps (default=1): The osps is the number of output + * samples per symbol. By default, the algorithm produces 1 sample + * per symbol, sampled at the exact sample value. This osps value + * was added to better work with equalizers, which do a better job + * of modeling the channel if they have 2 samps/sym. + */ + class DIGITAL_API pfb_clock_sync_ccf : virtual public gr_block + { + public: + // gr::digital::pfb_clock_sync_ccf::sptr + typedef boost::shared_ptr<pfb_clock_sync_ccf> sptr; + + /*! + * Build the polyphase filterbank timing synchronizer. + * \param sps (double) The number of samples per symbol in the incoming signal + * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. + * \param taps (vector<int>) The filter taps. + * \param filter_size (uint) The number of filters in the filterbank (default = 32). + * \param init_phase (float) The initial phase to look at, or which filter to start + * with (default = 0). + * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). + * \param osps (int) The number of output samples per symbol (default=1). + */ + static sptr make(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + virtual void update_gains() = 0; + + /*! + * Resets the filterbank's filter taps with the new prototype filter + */ + virtual void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr::filter::kernel::fir_filter_ccf*> &ourfilter) = 0; + + /*! + * Returns all of the taps of the matched filter + */ + virtual std::vector< std::vector<float> > taps() const = 0; + + /*! + * Returns all of the taps of the derivative filter + */ + virtual std::vector< std::vector<float> > diff_taps() const = 0; + + /*! + * Returns the taps of the matched filter for a particular channel + */ + virtual std::vector<float> channel_taps(int channel) const = 0; + + /*! + * Returns the taps in the derivative filter for a particular channel + */ + virtual std::vector<float> diff_channel_taps(int channel) const = 0; + + /*! + * Return the taps as a formatted string for printing + */ + virtual std::string taps_as_string() const = 0; + + /*! + * Return the derivative filter taps as a formatted string for printing + */ + virtual std::string diff_taps_as_string() const = 0; + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be + * between 2*pi/200 and 2*pi/100 (in rads/samp). It must also be + * a positive number. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + */ + virtual void set_loop_bandwidth(float bw) = 0; + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping + * factor should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are + * doing. It must be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + */ + virtual void set_damping_factor(float df) = 0; + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param alpha (float) new alpha gain + */ + virtual void set_alpha(float alpha) = 0; + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param beta (float) new beta gain + */ + virtual void set_beta(float beta) = 0; + + /*! + * Set the maximum deviation from 0 d_rate can have + */ + virtual void set_max_rate_deviation(float m) = 0; + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + virtual float loop_bandwidth() const = 0; + + /*! + * \brief Returns the loop damping factor + */ + virtual float damping_factor() const = 0; + + /*! + * \brief Returns the loop gain alpha + */ + virtual float alpha() const = 0; + + /*! + * \brief Returns the loop gain beta + */ + virtual float beta() const = 0; + + /*! + * \brief Returns the current clock rate + */ + virtual float clock_rate() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_H */ diff --git a/gr-digital/include/digital/pfb_clock_sync_fff.h b/gr-digital/include/digital/pfb_clock_sync_fff.h new file mode 100644 index 0000000000..5bc04e07d4 --- /dev/null +++ b/gr-digital/include/digital/pfb_clock_sync_fff.h @@ -0,0 +1,319 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_FFF_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_H + +#include <digital/api.h> +#include <filter/fir_filter.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \class digital_pfb_clock_sync_fff + * + * \brief Timing synchronizer using polyphase filterbanks + * + * \ingroup filter_blk + * \ingroup pfb_blk + * + * This block performs timing synchronization for PAM signals by + * minimizing the derivative of the filtered signal, which in turn + * maximizes the SNR and minimizes ISI. + * + * This approach works by setting up two filterbanks; one + * filterbank contains the signal's pulse shaping matched filter + * (such as a root raised cosine filter), where each branch of the + * filterbank contains a different phase of the filter. The + * second filterbank contains the derivatives of the filters in + * the first filterbank. Thinking of this in the time domain, the + * first filterbank contains filters that have a sinc shape to + * them. We want to align the output signal to be sampled at + * exactly the peak of the sinc shape. The derivative of the sinc + * contains a zero at the maximum point of the sinc (sinc(0) = 1, + * sinc(0)' = 0). Furthermore, the region around the zero point + * is relatively linear. We make use of this fact to generate the + * error signal. + * + * If the signal out of the derivative filters is d_i[n] for the + * ith filter, and the output of the matched filter is x_i[n], we + * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + + * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error + * in the real and imaginary parts. There are two reasons we + * multiply by the signal itself. First, if the symbol could be + * positive or negative going, but we want the error term to + * always tell us to go in the same direction depending on which + * side of the zero point we are on. The sign of x_i[n] adjusts + * the error term to do this. Second, the magnitude of x_i[n] + * scales the error term depending on the symbol's amplitude, so + * larger signals give us a stronger error term because we have + * more confidence in that symbol's value. Using the magnitude of + * x_i[n] instead of just the sign is especially good for signals + * with low SNR. + * + * The error signal, e[n], gives us a value proportional to how + * far away from the zero point we are in the derivative + * signal. We want to drive this value to zero, so we set up a + * second order loop. We have two variables for this loop; d_k is + * the filter number in the filterbank we are on and d_rate is the + * rate which we travel through the filters in the steady + * state. That is, due to the natural clock differences between + * the transmitter and receiver, d_rate represents that difference + * and would traverse the filter phase paths to keep the receiver + * locked. Thinking of this as a second-order PLL, the d_rate is + * the frequency and d_k is the phase. So we update d_rate and d_k + * using the standard loop equations based on two error signals, + * d_alpha and d_beta. We have these two values set based on each + * other for a critically damped system, so in the block + * constructor, we just ask for "gain," which is d_alpha while + * d_beta is equal to (gain^2)/4. + * + * The block's parameters are: + * + * \li \p sps: The clock sync block needs to know the number of + * samples per symbol, because it defaults to return a single + * point representing the symbol. The sps can be any positive real + * number and does not need to be an integer. + * + * \li \p loop_bw: The loop bandwidth is used to set the gain of + * the inner control loop (see: + * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). + * This should be set small (a value of around 2pi/100 is + * suggested in that blog post as the step size for the number of + * radians around the unit circle to move relative to the error). + * + * \li \p taps: One of the most important parameters for this + * block is the taps of the filter. One of the benefits of this + * algorithm is that you can put the matched filter in here as the + * taps, so you get both the matched filter and sample timing + * correction in one go. So create your normal matched filter. For + * a typical digital modulation, this is a root raised cosine + * filter. The number of taps of this filter is based on how long + * you expect the channel to be; that is, how many symbols do you + * want to combine to get the current symbols energy back (there's + * probably a better way of stating that). It's usually 5 to 10 or + * so. That gives you your filter, but now we need to think about + * it as a filter with different phase profiles in each filter. So + * take this number of taps and multiply it by the number of + * filters. This is the number you would use to create your + * prototype filter. When you use this in the PFB filerbank, it + * segments these taps into the filterbanks in such a way that + * each bank now represents the filter at different phases, + * equally spaced at 2pi/N, where N is the number of filters. + * + * \li \p filter_size (default=32): The number of filters can also + * be set and defaults to 32. With 32 filters, you get a good + * enough resolution in the phase to produce very small, almost + * unnoticeable, ISI. Going to 64 filters can reduce this more, + * but after that there is very little gained for the extra + * complexity. + * + * \li \p init_phase (default=0): The initial phase is another + * settable parameter and refers to the filter path the algorithm + * initially looks at (i.e., d_k starts at init_phase). This value + * defaults to zero, but it might be useful to start at a + * different phase offset, such as the mid-point of the filters. + * + * \li \p max_rate_deviation (default=1.5): The next parameter is + * the max_rate_devitation, which defaults to 1.5. This is how far + * we allow d_rate to swing, positive or negative, from + * 0. Constraining the rate can help keep the algorithm from + * walking too far away to lock during times when there is no + * signal. + * + * \li \p osps (default=1): The osps is the number of output + * samples per symbol. By default, the algorithm produces 1 sample + * per symbol, sampled at the exact sample value. This osps value + * was added to better work with equalizers, which do a better job + * of modeling the channel if they have 2 samps/sym. + */ + class DIGITAL_API pfb_clock_sync_fff : virtual public gr_block + { + public: + // gr::digital::pfb_clock_sync_fff::sptr + typedef boost::shared_ptr<pfb_clock_sync_fff> sptr; + + /*! + * Build the polyphase filterbank timing synchronizer. + * \param sps (double) The number of samples per second in the incoming signal + * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. + * \param taps (vector<int>) The filter taps. + * \param filter_size (uint) The number of filters in the filterbank (default = 32). + * \param init_phase (float) The initial phase to look at, or which filter to start + * with (default = 0). + * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). + * \param osps (int) The number of output samples per symbol (default=1). + * + */ + static sptr make(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + + /*! \brief update the system gains from omega and eta + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. + * These two factors can be set separately through their own + * set functions. + */ + virtual void update_gains() = 0; + + /*! + * Resets the filterbank's filter taps with the new prototype filter + */ + virtual void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<gr::filter::kernel::fir_filter_fff*> &ourfilter) = 0; + + /*! + * Returns all of the taps of the matched filter + */ + virtual std::vector< std::vector<float> > taps() const = 0; + + /*! + * Returns all of the taps of the derivative filter + */ + virtual std::vector< std::vector<float> > diff_taps() const = 0; + + /*! + * Returns the taps of the matched filter for a particular channel + */ + virtual std::vector<float> channel_taps(int channel) const = 0; + + /*! + * Returns the taps in the derivative filter for a particular channel + */ + virtual std::vector<float> diff_channel_taps(int channel) const = 0; + + /*! + * Return the taps as a formatted string for printing + */ + virtual std::string taps_as_string() const = 0; + + /*! + * Return the derivative filter taps as a formatted string for printing + */ + virtual std::string diff_taps_as_string() const = 0; + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be + * between 2*pi/200 and 2*pi/100 (in rads/samp). It must also be + * a positive number. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + */ + virtual void set_loop_bandwidth(float bw) = 0; + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping + * factor should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are + * doing. It must be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + */ + virtual void set_damping_factor(float df) = 0; + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param alpha (float) new alpha gain + */ + virtual void set_alpha(float alpha) = 0; + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param beta (float) new beta gain + */ + virtual void set_beta(float beta) = 0; + + /*! + * Set the maximum deviation from 0 d_rate can have + */ + virtual void set_max_rate_deviation(float m) = 0; + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + virtual float loop_bandwidth() const = 0; + + /*! + * \brief Returns the loop damping factor + */ + virtual float damping_factor() const = 0; + + /*! + * \brief Returns the loop gain alpha + */ + virtual float alpha() const = 0; + + /*! + * \brief Returns the loop gain beta + */ + virtual float beta() const = 0; + + /*! + * \brief Returns the current clock rate + */ + virtual float clock_rate() const = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_H */ diff --git a/gr-digital/include/digital/pn_correlator_cc.h b/gr-digital/include/digital/pn_correlator_cc.h new file mode 100644 index 0000000000..257cbbfe01 --- /dev/null +++ b/gr-digital/include/digital/pn_correlator_cc.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 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_GR_PN_CORRELATOR_CC_H +#define INCLUDED_GR_PN_CORRELATOR_CC_H + +#include <digital/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace digital { + + /*! + * \brief PN code sequential search correlator + * + * \ingroup sync_blk + * + * Receives complex baseband signal, outputs complex correlation + * against reference PN code, one sample per PN code period. The + * PN sequence is generated using a GLFSR. + */ + class DIGITAL_API pn_correlator_cc : virtual public gr_sync_decimator + { + public: + // gr::digital::pn_correlator_cc::sptr + typedef boost::shared_ptr<pn_correlator_cc> sptr; + + /*! + * \brief Make PN code sequential search correlator block. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ + static sptr make(int degree, int mask=0, int seed=1); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PN_CORRELATOR_CC_H */ diff --git a/gr-digital/include/digital/probe_density_b.h b/gr-digital/include/digital/probe_density_b.h new file mode 100644 index 0000000000..a81daf3f03 --- /dev/null +++ b/gr-digital/include/digital/probe_density_b.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * 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_GR_PROBE_DENSITY_B_H +#define INCLUDED_GR_PROBE_DENSITY_B_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * This block maintains a running average of the input stream and + * makes it available as an accessor function. The input stream + * is type unsigned char. + * + * If you send this block a stream of unpacked bytes, it will tell + * you what the bit density is. + */ + class DIGITAL_API probe_density_b : virtual public gr_sync_block + { + public: + // gr::digital::probe_density_b::sptr + typedef boost::shared_ptr<probe_density_b> sptr; + + /*! + * Make a density probe block. + * + * \param alpha Average filter constant + * + */ + static sptr make(double alpha); + + /*! + * \brief Returns the current density value + */ + virtual double density() const = 0; + + /*! + * \brief Set the average filter constant + */ + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gr-digital/include/digital/probe_mpsk_snr_est_c.h b/gr-digital/include/digital/probe_mpsk_snr_est_c.h new file mode 100644 index 0000000000..b58f1ab864 --- /dev/null +++ b/gr-digital/include/digital/probe_mpsk_snr_est_c.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_PROBE_MPSK_SNR_EST_C_H +#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H + +#include <digital/api.h> +#include <digital/mpsk_snr_est.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + //! \brief A probe for computing SNR of a signal. + /*! \ingroup snr_blk + * + * This is a probe block (a sink) that can be used to monitor and + * retrieve estimations of the signal SNR. This probe is designed + * for use with M-PSK signals especially. The type of estimator + * is specified as the \p type parameter in the constructor. The + * estimators tend to trade off performance for accuracy, + * although experimentation should be done to figure out the + * right approach for a given implementation. Further, the + * current set of estimators are designed and proven + * theoretically under AWGN conditions; some amount of error + * should be assumed and/or estimated for real channel + * conditions. + */ + class DIGITAL_API probe_mpsk_snr_est_c : virtual public gr_sync_block + { + public: + // gr::digital::probe_mpsk_snr_est_c::sptr + typedef boost::shared_ptr<probe_mpsk_snr_est_c> sptr; + + /*! Make an MPSK SNR probe. + * + * Parameters: + * + * \param type: the type of estimator to use \ref ref_snr_est_types + * "snr_est_type_t" for details about the available types. + * \param msg_nsamples: [not implemented yet] after this many + * samples, a message containing the SNR (key='snr') will be sent + * \param alpha: the update rate of internal running average + * calculations. + */ + static sptr make(snr_est_type_t type, + int msg_nsamples=10000, + double alpha=0.001); + + //! Return the estimated signal-to-noise ratio in decibels + virtual double snr() = 0; + + //! Return the type of estimator in use + virtual snr_est_type_t type() const = 0; + + //! Return how many samples between SNR messages + virtual int msg_nsample() const = 0; + + //! Get the running-average coefficient + virtual double alpha() const = 0; + + //! Set type of estimator to use + virtual void set_type(snr_est_type_t t) = 0; + + //! Set the number of samples between SNR messages + virtual void set_msg_nsample(int n) = 0; + + //! Set the running-average coefficient + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */ diff --git a/gr-digital/include/digital/scrambler_bb.h b/gr-digital/include/digital/scrambler_bb.h new file mode 100644 index 0000000000..95fce6dad7 --- /dev/null +++ b/gr-digital/include/digital/scrambler_bb.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 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_GR_SCRAMBLER_BB_H +#define INCLUDED_GR_SCRAMBLER_BB_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Scramble an input stream using an LFSR. + * \ingroup coding_blk + * + * This block works on the LSB only of the input data stream, + * i.e., on an "unpacked binary" stream, and produces the same + * format on its output. + */ + class DIGITAL_API scrambler_bb : virtual public gr_sync_block + { + public: + // gr::digital::scrambler_bb::sptr + typedef boost::shared_ptr<scrambler_bb> sptr; + + /*! + * Make a scramber block. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + */ + static sptr make(int mask, int seed, int len); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital/simple_framer.h b/gr-digital/include/digital/simple_framer.h new file mode 100644 index 0000000000..593328b9b3 --- /dev/null +++ b/gr-digital/include/digital/simple_framer.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_GR_SIMPLE_FRAMER_H +#define INCLUDED_GR_SIMPLE_FRAMER_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief add sync field, seq number and command field to payload + * \ingroup sync_blk + * + * Takes in enough samples to create a full output frame. The + * frame is prepended with the GRSF_SYNC (defind in + * digital_simple_framer_sync.h) and an 8-bit sequence number. + */ + class DIGITAL_API simple_framer : virtual public gr_block + { + public: + // gr::digital::simple_framer::sptr + typedef boost::shared_ptr<simple_framer> sptr; + + /*! + * Make a simple_framer block. + * + * \param payload_bytesize The size of the payload in bytes. + */ + static sptr make(int payload_bytesize); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gr-digital/include/digital/simple_framer_sync.h b/gr-digital/include/digital/simple_framer_sync.h new file mode 100644 index 0000000000..5dd2b82c3c --- /dev/null +++ b/gr-digital/include/digital/simple_framer_sync.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005,2012 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_GR_SIMPLE_FRAMER_SYNC_H +#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H + +namespace gr { + namespace digital { + + /*! + * \brief Here are a couple of maximum length sequences + * (m-sequences) that were generated by the the "mseq" + * matlab/octave code downloaded from: <a + * href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> + * + * <pre> + * 31-bit m-sequence: + * 0110100100001010111011000111110 + * 0x690AEC76 (padded on right with a zero) + * + * 63-bit m-sequence: + * 101011001101110110100100111000101111001010001100001000001111110 + * 0xACDDA4E2F28C20FC (padded on right with a zero) + * </pre> + */ + + static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; + + static const int GRSF_BITS_PER_BYTE = 8; + static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); + static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno + static const int GRSF_TAIL_PAD = 1; // one byte trailing padding + static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ diff --git a/gr-digital/include/digital_additive_scrambler_bb.h b/gr-digital/include/digital_additive_scrambler_bb.h deleted file mode 100644 index d4bd7d4ae8..0000000000 --- a/gr-digital/include/digital_additive_scrambler_bb.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 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_GR_ADDITIVE_SCRAMBLER_BB_H -#define INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr.h> - -class digital_additive_scrambler_bb; -typedef boost::shared_ptr<digital_additive_scrambler_bb> digital_additive_scrambler_bb_sptr; - -DIGITAL_API digital_additive_scrambler_bb_sptr -digital_make_additive_scrambler_bb(int mask, int seed, - int len, int count=0); - -/*! - * Scramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * \param count Number of bits after which shift register is reset, 0=never - * - * The scrambler works by XORing the incoming bit stream by the output of - * the LFSR. Optionally, after 'count' bits have been processed, the shift - * register is reset to the seed value. This allows processing fixed length - * vectors of samples. - * - * \ingroup coding_blk - */ - -class DIGITAL_API digital_additive_scrambler_bb : public gr_sync_block -{ - friend DIGITAL_API digital_additive_scrambler_bb_sptr - digital_make_additive_scrambler_bb(int mask, int seed, - int len, int count); - - gri_lfsr d_lfsr; - int d_count; - int d_bits; - - digital_additive_scrambler_bb(int mask, int seed, - int len, int count); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_ADDITIVE_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_bytes_to_syms.h b/gr-digital/include/digital_bytes_to_syms.h deleted file mode 100644 index c1857c8cf2..0000000000 --- a/gr-digital/include/digital_bytes_to_syms.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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_GR_BYTES_TO_SYMS_H -#define INCLUDED_GR_BYTES_TO_SYMS_H - -#include <digital_api.h> -#include <gr_sync_interpolator.h> - -class digital_bytes_to_syms; -typedef boost::shared_ptr<digital_bytes_to_syms> digital_bytes_to_syms_sptr; - -DIGITAL_API digital_bytes_to_syms_sptr digital_make_bytes_to_syms(); - -/*! - * \brief Convert stream of bytes to stream of +/- 1 symbols - * \ingroup converter_blk - * - * input: stream of bytes; output: stream of float - * - * This block is deprecated. - * - * The combination of gr_packed_to_unpacked_bb followed by - * digital_chunks_to_symbols_bf or digital_chunks_to_symbols_bc handles the - * general case of mapping from a stream of bytes into arbitrary float - * or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa digital_chunks_to_symbols_bf, digital_chunks_to_symbols_bc. - */ -class DIGITAL_API digital_bytes_to_syms : public gr_sync_interpolator -{ - friend DIGITAL_API digital_bytes_to_syms_sptr - digital_make_bytes_to_syms(); - - digital_bytes_to_syms(); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_BYTES_TO_SYMS_H */ diff --git a/gr-digital/include/digital_chunks_to_symbols_XX.h.t b/gr-digital/include/digital_chunks_to_symbols_XX.h.t deleted file mode 100644 index 3a82c68070..0000000000 --- a/gr-digital/include/digital_chunks_to_symbols_XX.h.t +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <digital_api.h> -#include <gr_sync_interpolator.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -DIGITAL_API @SPTR_NAME@ -digital_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - -/*! - * \brief Map a stream of symbol indexes (unpacked bytes or shorts) to stream of float or complex constellation points in D dimensions (D = 1 by default) - * \ingroup converter_blk - * - * input: stream of @I_TYPE@; output: stream of @O_TYPE@ - * - * out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1 - * - * The combination of gr_packed_to_unpacked_XX followed by - * digital_chunks_to_symbols_XY handles the general case of mapping - * from a stream of bytes or shorts into arbitrary float - * or complex symbols. - * - * \sa gr_packed_to_unpacked_bb, gr_unpacked_to_packed_bb, - * \sa gr_packed_to_unpacked_ss, gr_unpacked_to_packed_ss, - * \sa digital_chunks_to_symbols_bf, digital_chunks_to_symbols_bc. - * \sa digital_chunks_to_symbols_sf, digital_chunks_to_symbols_sc. - */ - -class DIGITAL_API @NAME@ : public gr_sync_interpolator -{ - friend DIGITAL_API @SPTR_NAME@ digital_make_@BASE_NAME@ - (const std::vector<@O_TYPE@> &symbol_table, const int D); - - int d_D; - std::vector<@O_TYPE@> d_symbol_table; - @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); - - public: - int D () const { return d_D; } - std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } -}; - -#endif diff --git a/gr-digital/include/digital_clock_recovery_mm_cc.h b/gr-digital/include/digital_clock_recovery_mm_cc.h deleted file mode 100644 index a2577d5378..0000000000 --- a/gr-digital/include/digital_clock_recovery_mm_cc.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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_CLOCK_RECOVERY_MM_CC_H -#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_H - -#include <digital_api.h> -#include <gr_block.h> -#include <gr_complex.h> -#include <gr_math.h> - -class gri_mmse_fir_interpolator_cc; - -class digital_clock_recovery_mm_cc; -typedef boost::shared_ptr<digital_clock_recovery_mm_cc> digital_clock_recovery_mm_cc_sptr; - -// public constructor -DIGITAL_API digital_clock_recovery_mm_cc_sptr -digital_make_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit=0.001); - -/*! - * \brief Mueller and Müller (M&M) based clock recovery block with complex input, complex output. - * \ingroup sync_blk - * \ingroup digital - * - * This implements the Mueller and Müller (M&M) discrete-time - * error-tracking synchronizer. - * - * The complex version here is based on: - * Modified Mueller and Muller clock recovery circuit - * Based: - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller - * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 - * June 1995, pp. 1032 - 1033. - */ -class DIGITAL_API digital_clock_recovery_mm_cc : public gr_block -{ - public: - ~digital_clock_recovery_mm_cc (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - void set_verbose (bool verbose) { d_verbose = verbose; } - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - -protected: - digital_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limi); - - private: - float d_mu; - float d_omega; - float d_gain_omega; - float d_min_omega; // minimum allowed omega - float d_max_omega; // maximum allowed omeg - float d_omega_relative_limit; // used to compute min and max omega - float d_omega_mid; - float d_gain_mu; - gr_complex d_last_sample; - gri_mmse_fir_interpolator_cc *d_interp; - bool d_verbose; - - gr_complex d_p_2T; - gr_complex d_p_1T; - gr_complex d_p_0T; - - gr_complex d_c_2T; - gr_complex d_c_1T; - gr_complex d_c_0T; - - gr_complex slicer_0deg (gr_complex sample); - gr_complex slicer_45deg (gr_complex sample); - - friend DIGITAL_API digital_clock_recovery_mm_cc_sptr - digital_make_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit); -}; - -#endif diff --git a/gr-digital/include/digital_clock_recovery_mm_ff.h b/gr-digital/include/digital_clock_recovery_mm_ff.h deleted file mode 100644 index 36749553fb..0000000000 --- a/gr-digital/include/digital_clock_recovery_mm_ff.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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_CLOCK_RECOVERY_MM_FF_H -#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_H - -#include <digital_api.h> -#include <gr_block.h> -#include <gr_math.h> -#include <stdio.h> - -class gri_mmse_fir_interpolator; - -class digital_clock_recovery_mm_ff; -typedef boost::shared_ptr<digital_clock_recovery_mm_ff> digital_clock_recovery_mm_ff_sptr; - -// public constructor -DIGITAL_API digital_clock_recovery_mm_ff_sptr -digital_make_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit=0.001); - -/*! - * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output. - * \ingroup sync_blk - * \ingroup digital - * - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. - * - * See "Digital Communication Receivers: Synchronization, Channel - * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel. - * ISBN 0-471-50275-8. - */ -class DIGITAL_API digital_clock_recovery_mm_ff : public gr_block -{ - public: - ~digital_clock_recovery_mm_ff (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega){ - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - -protected: - digital_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu, - float omega_relative_limit); - - private: - float d_mu; // fractional sample position [0.0, 1.0] - float d_omega; // nominal frequency - float d_min_omega; // minimum allowed omega - float d_omega_mid; // average omega - float d_max_omega; // maximum allowed omega - float d_gain_omega; // gain for adjusting omega - float d_gain_mu; // gain for adjusting mu - float d_last_sample; - gri_mmse_fir_interpolator *d_interp; - FILE *d_logfile; - float d_omega_relative_limit; // used to compute min and max omega - - friend DIGITAL_API digital_clock_recovery_mm_ff_sptr - digital_make_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit); -}; - -#endif diff --git a/gr-digital/include/digital_cma_equalizer_cc.h b/gr-digital/include/digital_cma_equalizer_cc.h deleted file mode 100644 index 79e84ca4b3..0000000000 --- a/gr-digital/include/digital_cma_equalizer_cc.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_CMA_EQUALIZER_CC_H -#define INCLUDED_DIGITAL_CMA_EQUALIZER_CC_H - -#include <digital_api.h> -#include <gr_adaptive_fir_ccc.h> -#include <gr_math.h> -#include <iostream> - -class digital_cma_equalizer_cc; -typedef boost::shared_ptr<digital_cma_equalizer_cc> digital_cma_equalizer_cc_sptr; - -DIGITAL_API digital_cma_equalizer_cc_sptr -digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu, int sps); - -/*! - * \brief Implements constant modulus adaptive filter on complex stream - * \ingroup eq_blk - * \ingroup digital - * - * The error value and tap update equations (for p=2) can be found in: - * - * "D. Godard, "Self-Recovering Equalization and Carrier Tracking in - * Two-Dimensional Data Communication Systems," IEEE Transactions on - * Communications, Vol. 28, No. 11, pp. 1867 - 1875, 1980." - */ -class DIGITAL_API digital_cma_equalizer_cc : public gr_adaptive_fir_ccc -{ -private: - float d_modulus; - float d_mu; - - friend DIGITAL_API digital_cma_equalizer_cc_sptr digital_make_cma_equalizer_cc(int num_taps, - float modulus, - float mu, - int sps); - digital_cma_equalizer_cc(int num_taps, float modulus, float mu, int sps); - -protected: - - virtual gr_complex error(const gr_complex &out) - { - gr_complex error = out*(norm(out) - d_modulus); - float re = gr_clip(error.real(), 1.0); - float im = gr_clip(error.imag(), 1.0); - return gr_complex(re, im); - } - - virtual void update_tap(gr_complex &tap, const gr_complex &in) - { - // Hn+1 = Hn - mu*conj(Xn)*zn*(|zn|^2 - 1) - tap -= d_mu*conj(in)*d_error; - } - -public: - float get_gain() - { - return d_mu; - } - - void set_gain(float mu) - { - if(mu < 0.0f || mu > 1.0f) { - throw std::out_of_range("digital_cma_equalizer::set_gain: Gain value must be in [0,1]"); - } - d_mu = mu; - } - - float get_modulus() - { - return d_modulus; - } - - void set_modulus(float mod) - { - if(mod < 0) - throw std::out_of_range("digital_cma_equalizer::set_modulus: Modulus value must be >= 0"); - d_modulus = mod; - } -}; - -#endif diff --git a/gr-digital/include/digital_constellation.h b/gr-digital/include/digital_constellation.h deleted file mode 100644 index 09a1e5fad4..0000000000 --- a/gr-digital/include/digital_constellation.h +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010, 2011 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_CONSTELLATION_H -#define INCLUDED_DIGITAL_CONSTELLATION_H - -#include <digital_api.h> -#include <vector> -#include <math.h> -#include <gr_complex.h> -#include <boost/enable_shared_from_this.hpp> -#include <digital_metric_type.h> - -/************************************************************/ -/* digital_constellation */ -/* */ -/* Base class defining interface. */ -/************************************************************/ - -class digital_constellation; -typedef boost::shared_ptr<digital_constellation> digital_constellation_sptr; - -/*! - * \brief An abstracted constellation object - * \ingroup digital - * - * The constellation objects hold the necessary information to pass - * around constellation information for modulators and - * demodulators. These objects contain the mapping between the bits - * and the constellation points used to represent them as well as - * methods for slicing the symbol space. Various implementations are - * possible for efficiency and ease of use. - * - * Standard constellations (BPSK, QPSK, QAM, etc) can be inherited - * from this class and overloaded to perform optimized slicing and - * constellation mappings. - */ -class DIGITAL_API digital_constellation : public boost::enable_shared_from_this<digital_constellation> -{ -public: - digital_constellation (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); - digital_constellation (); - - //! Returns the constellation points for a symbol value - void map_to_points(unsigned int value, gr_complex *points); - std::vector<gr_complex> map_to_points_v(unsigned int value); - - //! Returns the constellation point that matches best. - virtual unsigned int decision_maker (const gr_complex *sample) = 0; - //! Takes a vector rather than a pointer. Better for SWIG wrapping. - unsigned int decision_maker_v (std::vector<gr_complex> sample); - //! Also calculates the phase error. - unsigned int decision_maker_pe (const gr_complex *sample, float *phase_error); - //! Calculates distance. - unsigned int decision_maker_e (const gr_complex *sample, float *error); - - //! Calculates metrics for all points in the constellation. - //! For use with the viterbi algorithm. - virtual void calc_metric(const gr_complex *sample, float *metric, trellis_metric_type_t type); - virtual void calc_euclidean_metric(const gr_complex *sample, float *metric); - virtual void calc_hard_symbol_metric(const gr_complex *sample, float *metric); - - //! Returns the set of points in this constellation. - std::vector<gr_complex> points() { return d_constellation;} - //! Returns the vector of points in this constellation. - //! Raise error if dimensionality is not one. - std::vector<gr_complex> s_points(); - //! Returns a vector of vectors of points. - std::vector<std::vector<gr_complex> > v_points(); - //! Whether to apply an encoding before doing differential encoding. (e.g. gray coding) - bool apply_pre_diff_code() { return d_apply_pre_diff_code;} - //! Whether to apply an encoding before doing differential encoding. (e.g. gray coding) - void set_pre_diff_code(bool a) { d_apply_pre_diff_code = a;} - //! Returns the encoding to apply before differential encoding. - std::vector<unsigned int> pre_diff_code() { return d_pre_diff_code;} - //! Returns the order of rotational symmetry. - unsigned int rotational_symmetry() { return d_rotational_symmetry;} - //! Returns the number of complex numbers in a single symbol. - unsigned int dimensionality() {return d_dimensionality;} - - unsigned int bits_per_symbol () { - return floor(log(double(d_constellation.size()))/d_dimensionality/log(2.0)); - } - - unsigned int arity () { - return d_arity; - } - - digital_constellation_sptr base() { - return shared_from_this(); - } - - protected: - - std::vector<gr_complex> d_constellation; - std::vector<unsigned int> d_pre_diff_code; - bool d_apply_pre_diff_code; - unsigned int d_rotational_symmetry; - unsigned int d_dimensionality; - unsigned int d_arity; - - float get_distance(unsigned int index, const gr_complex *sample); - unsigned int get_closest_point(const gr_complex *sample); - void calc_arity (); -}; - -/************************************************************/ -/* digital_constellation_calcdist */ -/* */ -/************************************************************/ - -class digital_constellation_calcdist; -typedef boost::shared_ptr<digital_constellation_calcdist> digital_constellation_calcdist_sptr; - -// public constructor -DIGITAL_API digital_constellation_calcdist_sptr -digital_make_constellation_calcdist (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); - - -/*! \brief Calculate Euclidian distance for any constellation - * \ingroup digital - * - * Constellation which calculates the distance to each point in the - * constellation for decision making. Inefficient for large - * constellations. - */ -class DIGITAL_API digital_constellation_calcdist : public digital_constellation -{ - public: - digital_constellation_calcdist (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); - unsigned int decision_maker (const gr_complex *sample); - // void calc_metric(gr_complex *sample, float *metric, trellis_metric_type_t type); - // void calc_euclidean_metric(gr_complex *sample, float *metric); - // void calc_hard_symbol_metric(gr_complex *sample, float *metric); - - private: - friend DIGITAL_API digital_constellation_calcdist_sptr - digital_make_constellation_calcdist (std::vector<gr_complex> constellation); -}; - - -/************************************************************/ -/*! digital_constellation_sector */ -/************************************************************/ - -/*! - * \brief Sectorized digital constellation - * \ingroup digital - * - * Constellation space is divided into sectors. Each sector is - * associated with the nearest constellation point. - * - */ -class DIGITAL_API digital_constellation_sector : public digital_constellation -{ - public: - - digital_constellation_sector (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality, - unsigned int n_sectors); - - unsigned int decision_maker (const gr_complex *sample); - - protected: - - virtual unsigned int get_sector (const gr_complex *sample) = 0; - virtual unsigned int calc_sector_value (unsigned int sector) = 0; - void find_sector_values (); - - unsigned int n_sectors; - - private: - - std::vector<unsigned int> sector_values; - -}; - -/************************************************************/ -/* digital_constellation_rect */ -/************************************************************/ - -class digital_constellation_rect; -typedef boost::shared_ptr<digital_constellation_rect> digital_constellation_rect_sptr; - -// public constructor -DIGITAL_API digital_constellation_rect_sptr -digital_make_constellation_rect (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, - unsigned int imag_sectors, - float width_real_sectors, - float width_imag_sectors); - -/*! - * \brief Rectangular digital constellation - * \ingroup digital - * - * Only implemented for 1-(complex)dimensional constellation. - * - * Constellation space is divided into rectangular sectors. Each - * sector is associated with the nearest constellation point. - * - * Works well for square QAM. - * - * Works for any generic constellation provided sectors are not too - * large. - */ -class DIGITAL_API digital_constellation_rect : public digital_constellation_sector -{ - public: - - digital_constellation_rect (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, - unsigned int imag_sectors, - float width_real_sectors, - float width_imag_sectors); - - protected: - - unsigned int get_sector (const gr_complex *sample); - - unsigned int calc_sector_value (unsigned int sector); - - private: - - unsigned int n_real_sectors; - unsigned int n_imag_sectors; - float d_width_real_sectors; - float d_width_imag_sectors; - - friend DIGITAL_API digital_constellation_rect_sptr - digital_make_constellation_rect (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, - unsigned int imag_sectors, - float width_real_sectors, - float width_imag_sectors); - -}; - - -/************************************************************/ -/* digital_constellation_psk */ -/************************************************************/ - -class digital_constellation_psk; -typedef boost::shared_ptr<digital_constellation_psk> digital_constellation_psk_sptr; - -// public constructor -DIGITAL_API digital_constellation_psk_sptr -digital_make_constellation_psk (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors); - -/*! - * \brief Digital Constellation for PSK. - * \ingroup digital - * - * Constellation space is divided into pie slices sectors. - * - * Each slice is associated with the nearest constellation point. - * - * Works well for PSK but nothing else. - * - * Assumes that there is a constellation point at 1.x - */ -class DIGITAL_API digital_constellation_psk : public digital_constellation_sector -{ - public: - - digital_constellation_psk (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors); - - protected: - - unsigned int get_sector (const gr_complex *sample); - - unsigned int calc_sector_value (unsigned int sector); - - private: - - friend DIGITAL_API digital_constellation_psk_sptr - digital_make_constellation_psk (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors); - -}; - - -/************************************************************/ -/* digital_constellation_bpsk */ -/* */ -/* Only works for BPSK. */ -/* */ -/************************************************************/ - -class digital_constellation_bpsk; -typedef boost::shared_ptr<digital_constellation_bpsk> digital_constellation_bpsk_sptr; - -// public constructor -DIGITAL_API digital_constellation_bpsk_sptr -digital_make_constellation_bpsk (); - -/*! - * \brief Digital constellation for BPSK - * \ingroup digital - */ -class DIGITAL_API digital_constellation_bpsk : public digital_constellation -{ - public: - - digital_constellation_bpsk (); - unsigned int decision_maker (const gr_complex *sample); - - friend DIGITAL_API digital_constellation_bpsk_sptr - digital_make_constellation_bpsk (); - -}; - - -/************************************************************/ -/* digital_constellation_qpsk */ -/* */ -/* Only works for QPSK. */ -/* */ -/************************************************************/ - -class digital_constellation_qpsk; -typedef boost::shared_ptr<digital_constellation_qpsk> digital_constellation_qpsk_sptr; - -// public constructor -DIGITAL_API digital_constellation_qpsk_sptr -digital_make_constellation_qpsk (); - -/*! - * \brief Digital constellation for QPSK - * \ingroup digital - */ -class DIGITAL_API digital_constellation_qpsk : public digital_constellation -{ - public: - - digital_constellation_qpsk (); - unsigned int decision_maker (const gr_complex *sample); - - friend DIGITAL_API digital_constellation_qpsk_sptr - digital_make_constellation_qpsk (); - -}; - - -/************************************************************/ -/* digital_constellation_dqpsk */ -/* */ -/* Works with differential encoding; slower decisions. */ -/* */ -/************************************************************/ - -class digital_constellation_dqpsk; -typedef boost::shared_ptr<digital_constellation_dqpsk> digital_constellation_dqpsk_sptr; - -// public constructor -DIGITAL_API digital_constellation_dqpsk_sptr -digital_make_constellation_dqpsk (); - -/*! - * \brief Digital constellation for DQPSK - * \ingroup digital - */ -class DIGITAL_API digital_constellation_dqpsk : public digital_constellation -{ - public: - - digital_constellation_dqpsk (); - unsigned int decision_maker (const gr_complex *sample); - - friend DIGITAL_API digital_constellation_dqpsk_sptr - digital_make_constellation_dqpsk (); - -}; - - -/************************************************************/ -/* digital_constellation_8psk */ -/* */ -/* Only works for 8PSK. */ -/* */ -/************************************************************/ - -class digital_constellation_8psk; -typedef boost::shared_ptr<digital_constellation_8psk> digital_constellation_8psk_sptr; - -// public constructor -DIGITAL_API digital_constellation_8psk_sptr -digital_make_constellation_8psk (); - -/*! - * \brief Digital constellation for 8PSK - * \ingroup digital - */ -class DIGITAL_API digital_constellation_8psk : public digital_constellation -{ - public: - - digital_constellation_8psk (); - unsigned int decision_maker (const gr_complex *sample); - - friend DIGITAL_API digital_constellation_8psk_sptr - digital_make_constellation_8psk (); - -}; - -#endif diff --git a/gr-digital/include/digital_constellation_decoder_cb.h b/gr-digital/include/digital_constellation_decoder_cb.h deleted file mode 100644 index cce3a564f3..0000000000 --- a/gr-digital/include/digital_constellation_decoder_cb.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_CONSTELLATION_DECODER_CB_H -#define INCLUDED_DIGITAL_CONSTELLATION_DECODER_CB_H - -#include <digital_api.h> -#include <gr_block.h> -#include <digital_constellation.h> -#include <vector> - -class digital_constellation_decoder_cb; -typedef boost::shared_ptr<digital_constellation_decoder_cb>digital_constellation_decoder_cb_sptr; - -DIGITAL_API digital_constellation_decoder_cb_sptr -digital_make_constellation_decoder_cb (digital_constellation_sptr constellation); - -/*! - * \brief Constellation Decoder - * \ingroup coding_blk - * \ingroup digital - * - */ -class DIGITAL_API digital_constellation_decoder_cb : public gr_block -{ - - private: - digital_constellation_sptr d_constellation; - unsigned int d_dim; - - friend DIGITAL_API digital_constellation_decoder_cb_sptr - digital_make_constellation_decoder_cb (digital_constellation_sptr constellation); - - digital_constellation_decoder_cb (digital_constellation_sptr constellation); - - public: - - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_constellation_receiver_cb.h b/gr-digital/include/digital_constellation_receiver_cb.h deleted file mode 100644 index 3a14bb5dee..0000000000 --- a/gr-digital/include/digital_constellation_receiver_cb.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_CONSTELLATION_RECEIVER_CB_H -#define INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_H - -#include <digital_api.h> -#include <gr_block.h> -#include <digital_constellation.h> -#include <gruel/attributes.h> -#include <gri_control_loop.h> -#include <gr_complex.h> -#include <math.h> -#include <fstream> - -class digital_constellation_receiver_cb; -typedef boost::shared_ptr<digital_constellation_receiver_cb> digital_constellation_receiver_cb_sptr; - -// public constructor -DIGITAL_API digital_constellation_receiver_cb_sptr -digital_make_constellation_receiver_cb (digital_constellation_sptr constellation, - float loop_bw, float fmin, float fmax); - -/*! - * \brief This block takes care of receiving generic modulated signals - * through phase, frequency, and symbol synchronization. - * \ingroup sync_blk - * \ingroup demod_blk - * \ingroup digital - * - * This block takes care of receiving generic modulated signals - * through phase, frequency, and symbol synchronization. It performs - * carrier frequency and phase locking as well as symbol timing - * recovery. - * - * The phase and frequency synchronization are based on a Costas loop - * that finds the error of the incoming signal point compared to its - * nearest constellation point. The frequency and phase of the NCO are - * updated according to this error. - * - * The symbol synchronization is done using a modified Mueller and - * Muller circuit from the paper: - * - * "G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller - * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 - * June 1995, pp. 1032 - 1033." - * - * This circuit interpolates the downconverted sample (using the NCO - * developed by the Costas loop) every mu samples, then it finds the - * sampling error based on this and the past symbols and the decision - * made on the samples. Like the phase error detector, there are - * optimized decision algorithms for BPSK and QPKS, but 8PSK uses - * another brute force computation against all possible symbols. The - * modifications to the M&M used here reduce self-noise. - * - */ - -class DIGITAL_API digital_constellation_receiver_cb : public gr_block, public gri_control_loop -{ -public: - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -protected: - - /*! - * \brief Constructor to synchronize incoming M-PSK symbols - * - * \param constellation constellation of points for generic modulation - * \param loop_bw Loop bandwidth of the Costas Loop (~ 2pi/100) - * \param fmin minimum normalized frequency value the loop can achieve - * \param fmax maximum normalized frequency value the loop can achieve - * - * The constructor also chooses which phase detector and decision maker to use in the - * work loop based on the value of M. - */ - digital_constellation_receiver_cb (digital_constellation_sptr constellation, - float loop_bw, float fmin, float fmax); - - void phase_error_tracking(float phase_error); - -private: - unsigned int d_M; - - digital_constellation_sptr d_constellation; - unsigned int d_current_const_point; - - //! delay line length. - static const unsigned int DLLEN = 8; - - //! delay line plus some length for overflow protection - __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; - - //! index to delay line - unsigned int d_dl_idx; - - friend DIGITAL_API digital_constellation_receiver_cb_sptr - digital_make_constellation_receiver_cb (digital_constellation_sptr constell, - float loop_bw, float fmin, float fmax); -}; - -#endif diff --git a/gr-digital/include/digital_correlate_access_code_bb.h b/gr-digital/include/digital_correlate_access_code_bb.h deleted file mode 100644 index 8095dd4090..0000000000 --- a/gr-digital/include/digital_correlate_access_code_bb.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2011 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_ACCESS_CODE_BB_H -#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <string> - -class digital_correlate_access_code_bb; -typedef boost::shared_ptr<digital_correlate_access_code_bb> digital_correlate_access_code_bb_sptr; - -/*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - * \param threshold maximum number of bits that may be wrong - */ -DIGITAL_API digital_correlate_access_code_bb_sptr -digital_make_correlate_access_code_bb (const std::string &access_code, int threshold); - -/*! - * \brief Examine input for specified access code, one bit at a time. - * \ingroup sync_blk - * \ingroup digital - * - * input: stream of bits, 1 bit per input byte (data in LSB) - * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) - * - * Each output byte contains two valid bits, the data bit, and the - * flag bit. The LSB (bit 0) is the data bit, and is the original - * input data, delayed 64 bits. Bit 1 is the - * flag bit and is 1 if the corresponding data bit is the first data - * bit following the access code. Otherwise the flag bit is 0. - */ -class DIGITAL_API digital_correlate_access_code_bb : public gr_sync_block -{ - friend DIGITAL_API digital_correlate_access_code_bb_sptr - digital_make_correlate_access_code_bb (const std::string &access_code, int threshold); - private: - unsigned long long d_access_code; // access code to locate start of packet - // access code is left justified in the word - unsigned long long d_data_reg; // used to look for access_code - unsigned long long d_flag_reg; // keep track of decisions - unsigned long long d_flag_bit; // mask containing 1 bit which is location of new flag - unsigned long long d_mask; // masks access_code bits (top N bits are set where - // N is the number of bits in the access code) - unsigned int d_threshold; // how many bits may be wrong in sync vector - - protected: - digital_correlate_access_code_bb(const std::string &access_code, int threshold); - - public: - ~digital_correlate_access_code_bb(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - - /*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - */ - bool set_access_code (const std::string &access_code); -}; - -#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_H */ diff --git a/gr-digital/include/digital_correlate_access_code_tag_bb.h b/gr-digital/include/digital_correlate_access_code_tag_bb.h deleted file mode 100644 index b4a12108f4..0000000000 --- a/gr-digital/include/digital_correlate_access_code_tag_bb.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2011,2012 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_access_code_tag_bb_H -#define INCLUDED_digital_correlate_access_code_tag_bb_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <string> - -class digital_correlate_access_code_tag_bb; -typedef boost::shared_ptr<digital_correlate_access_code_tag_bb> digital_correlate_access_code_tag_bb_sptr; - -/*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - * \param threshold maximum number of bits that may be wrong - * \param tag_name key of the tag inserted into the tag stream - */ -DIGITAL_API digital_correlate_access_code_tag_bb_sptr -digital_make_correlate_access_code_tag_bb(const std::string &access_code, - int threshold, - const std::string &tag_name); - -/*! - * \brief Examine input for specified access code, one bit at a time. - * \ingroup sync_blk - * - * input: stream of bits, 1 bit per input byte (data in LSB) - * output: unaltered stream of bits (plus tags) - * - * This block annotates the input stream with tags. The tags have key - * name [tag_name], specified in the constructor. Used for searching - * an input data stream for preambles, etc. - */ -class DIGITAL_API digital_correlate_access_code_tag_bb : public gr_sync_block -{ - friend DIGITAL_API digital_correlate_access_code_tag_bb_sptr - digital_make_correlate_access_code_tag_bb(const std::string &access_code, - int threshold, - const std::string &tag_name); - private: - unsigned long long d_access_code; // access code to locate start of packet - // access code is left justified in the word - unsigned long long d_data_reg; // used to look for access_code - unsigned long long d_mask; // masks access_code bits (top N bits are set where - // N is the number of bits in the access code) - unsigned int d_threshold; // how many bits may be wrong in sync vector - unsigned int d_len; // the length of the access code - - pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID - - protected: - digital_correlate_access_code_tag_bb(const std::string &access_code, - int threshold, - const std::string &tag_name); - - public: - ~digital_correlate_access_code_tag_bb(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - */ - bool set_access_code(const std::string &access_code); -}; - -#endif /* INCLUDED_digital_correlate_access_code_tag_bb_H */ diff --git a/gr-digital/include/digital_costas_loop_cc.h b/gr-digital/include/digital_costas_loop_cc.h deleted file mode 100644 index 4aab22fb45..0000000000 --- a/gr-digital/include/digital_costas_loop_cc.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 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_COSTAS_LOOP_CC_H -#define INCLUDED_DIGITAL_COSTAS_LOOP_CC_H - -#include <gr_sync_block.h> -#include <gri_control_loop.h> -#include <stdexcept> -#include <fstream> - - -/*! - * \brief A Costas loop carrier recovery module. - * \ingroup sync_blk - * \ingroup digital - * - * The Costas loop locks to the center frequency of a signal and - * downconverts it to baseband. The second (order=2) order loop is - * used for BPSK where the real part of the output signal is the - * baseband BPSK signal and the imaginary part is the error - * signal. When order=4, it can be used for quadrature modulations - * where both I and Q (real and imaginary) are outputted. - * - * More details can be found online: - * - * J. Feigin, "Practical Costas loop design: Designing a simple and - * inexpensive BPSK Costas loop carrier recovery circuit," RF signal - * processing, pp. 20-36, 2002. - * - * http://rfdesign.com/images/archive/0102Feigin20.pdf - * - * \param loop_bw internal 2nd order loop bandwidth (~ 2pi/100) - * \param order the loop order, either 2, 4, or 8 - */ - -#include <digital_api.h> - -class digital_costas_loop_cc; -typedef boost::shared_ptr<digital_costas_loop_cc> digital_costas_loop_cc_sptr; - - -DIGITAL_API digital_costas_loop_cc_sptr -digital_make_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument); - - -/*! - * \brief Carrier tracking PLL for QPSK - * \ingroup sync_blk - * input: complex; output: complex - * <br>The Costas loop can have two output streams: - * stream 1 is the baseband I and Q; - * stream 2 is the normalized frequency of the loop - * - * \p order must be 2, 4, or 8. - */ -class DIGITAL_API digital_costas_loop_cc : public gr_sync_block, public gri_control_loop -{ - friend DIGITAL_API digital_costas_loop_cc_sptr - digital_make_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument); - - int d_order; - - digital_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument); - - /*! \brief the phase detector circuit for 8th-order PSK loops - * \param sample complex sample - * \return the phase error - */ - float phase_detector_8(gr_complex sample) const; // for 8PSK - - /*! \brief the phase detector circuit for fourth-order loops - * \param sample complex sample - * \return the phase error - */ - float phase_detector_4(gr_complex sample) const; // for QPSK - - /*! \brief the phase detector circuit for second-order loops - * \param sample a complex sample - * \return the phase error - */ - float phase_detector_2(gr_complex sample) const; // for BPSK - - - float (digital_costas_loop_cc::*d_phase_detector)(gr_complex sample) const; - -public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_cpmmod_bc.h b/gr-digital/include/digital_cpmmod_bc.h deleted file mode 100644 index f0f11ee30e..0000000000 --- a/gr-digital/include/digital_cpmmod_bc.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_CPMMOD_BC_H -#define INCLUDED_DIGITAL_CPMMOD_BC_H - -#include <digital_api.h> -#include <gr_hier_block2.h> -#include <gr_char_to_float.h> -#include <gr_interp_fir_filter_fff.h> -#include <gr_frequency_modulator_fc.h> -#include <gr_cpm.h> - - -class digital_cpmmod_bc; -typedef boost::shared_ptr<digital_cpmmod_bc> digital_cpmmod_bc_sptr; - - -DIGITAL_API digital_cpmmod_bc_sptr -digital_make_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta=0.3); - -/*! - * \brief Generic CPM modulator - * - * \ingroup modulation_blk - * \ingroup digital - * - * \param type The modulation type. Can be one of LREC, LRC, LSRC, TFM - * or GAUSSIAN. See gr_cpm::phase_response() for a - * detailed description. - * \param h The modulation index. \f$ h \cdot \pi\f$ is the maximum - * phase change that can occur between two symbols, i.e., if - * you only send ones, the phase will increase by \f$ h \cdot - * \pi\f$ every \p samples_per_sym samples. Set this to 0.5 - * for Minimum Shift Keying variants. - * \param samples_per_sym Samples per symbol. - * \param L The length of the phase duration in symbols. For L=1, this - * yields full- response CPM symbols, for L > 1, - * partial-response. - * \param beta For LSRC, this is the rolloff factor. For Gaussian - * pulses, this is the 3 dB time-bandwidth product. - * - * Examples: - * - Setting h = 0.5, L = 1, type = LREC yields MSK. - * - Setting h = 0.5, type = GAUSSIAN and beta = 0.3 yields GMSK - * as used in GSM. - * - * The input of this block are symbols from an M-ary alphabet - * +/-1, +/-3, ..., +/-(M-1). Usually, M = 2 and therefore, the - * valid inputs are +/-1. - * The modulator will silently accept any other inputs, though. - * The output is the phase-modulated signal. - */ -class DIGITAL_API digital_cpmmod_bc : public gr_hier_block2 -{ - friend DIGITAL_API digital_cpmmod_bc_sptr - digital_make_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta); - - std::vector<float> d_taps; - gr_char_to_float_sptr d_char_to_float; - gr_interp_fir_filter_fff_sptr d_pulse_shaper; - gr_frequency_modulator_fc_sptr d_fm; - -protected: - digital_cpmmod_bc(gr_cpm::cpm_type type, float h, - unsigned samples_per_sym, - unsigned L, double beta); - -public: - //! Return the phase response FIR taps - std::vector<float> get_taps() { return d_taps; }; -}; - -#endif /* INCLUDED_DIGITAL_CPMMOD_BC_H */ - diff --git a/gr-digital/include/digital_descrambler_bb.h b/gr-digital/include/digital_descrambler_bb.h deleted file mode 100644 index b719803f33..0000000000 --- a/gr-digital/include/digital_descrambler_bb.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2012 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_GR_DESCRAMBLER_BB_H -#define INCLUDED_GR_DESCRAMBLER_BB_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include "gri_lfsr.h" - -class digital_descrambler_bb; -typedef boost::shared_ptr<digital_descrambler_bb> digital_descrambler_bb_sptr; - -DIGITAL_API digital_descrambler_bb_sptr -digital_make_descrambler_bb(int mask, int seed, int len); - -/*! - * Descramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk - */ - -class DIGITAL_API digital_descrambler_bb : public gr_sync_block -{ - friend DIGITAL_API digital_descrambler_bb_sptr - digital_make_descrambler_bb(int mask, int seed, int len); - - gri_lfsr d_lfsr; - - digital_descrambler_bb(int mask, int seed, int len); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_DESCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_fll_band_edge_cc.h b/gr-digital/include/digital_fll_band_edge_cc.h deleted file mode 100644 index 68083bbaeb..0000000000 --- a/gr-digital/include/digital_fll_band_edge_cc.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2011,2012 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_FLL_BAND_EDGE_CC_H -#define INCLUDED_DIGITAL_FLL_BAND_EDGE_CC_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gri_control_loop.h> -#include <gr_fir_util.h> -#include <gr_fir_ccc.h> - -typedef gr_fir_ccc* (*fir_maker_t)(const std::vector<gr_complex> &taps); -typedef gr_fir_ccc filter_t; - -class digital_fll_band_edge_cc; -typedef boost::shared_ptr<digital_fll_band_edge_cc> digital_fll_band_edge_cc_sptr; -DIGITAL_API digital_fll_band_edge_cc_sptr -digital_make_fll_band_edge_cc(float samps_per_sym, - float rolloff, - int filter_size, - float bandwidth); - -/*! - * \class digital_fll_band_edge_cc - * \brief Frequency Lock Loop using band-edge filters - * - * \ingroup general - * \ingroup digital - * - * The frequency lock loop derives a band-edge filter that covers the - * upper and lower bandwidths of a digitally-modulated signal. The - * bandwidth range is determined by the excess bandwidth (e.g., - * rolloff factor) of the modulated signal. The placement in frequency - * of the band-edges is determined by the oversampling ratio (number - * of samples per symbol) and the excess bandwidth. The size of the - * filters should be fairly large so as to average over a number of - * symbols. - * - * The FLL works by filtering the upper and lower band edges into - * x_u(t) and x_l(t), respectively. These are combined to form cc(t) - * = x_u(t) + x_l(t) and ss(t) = x_u(t) - x_l(t). Combining these to - * form the signal e(t) = Re{cc(t) \\times ss(t)^*} (where ^* is the - * complex conjugate) provides an error signal at the DC term that is - * directly proportional to the carrier frequency. We then make a - * second-order loop using the error signal that is the running - * average of e(t). - * - * In practice, the above equation can be simplified by just comparing - * the absolute value squared of the output of both filters: - * abs(x_l(t))^2 - abs(x_u(t))^2 = norm(x_l(t)) - norm(x_u(t)). - * - * In theory, the band-edge filter is the derivative of the matched - * filter in frequency, (H_be(f) = frac{H(f)}{df}). In practice, - * this comes down to a quarter sine wave at the point of the matched - * filter's rolloff (if it's a raised-cosine, the derivative of a - * cosine is a sine). Extend this sine by another quarter wave to - * make a half wave around the band-edges is equivalent in time to the - * sum of two sinc functions. The baseband filter fot the band edges - * is therefore derived from this sum of sincs. The band edge filters - * are then just the baseband signal modulated to the correct place in - * frequency. All of these calculations are done in the - * 'design_filter' function. - * - * Note: We use FIR filters here because the filters have to have a - * flat phase response over the entire frequency range to allow their - * comparisons to be valid. - * - * It is very important that the band edge filters be the derivatives - * of the pulse shaping filter, and that they be linear - * phase. Otherwise, the variance of the error will be very large. - * - */ - -class DIGITAL_API digital_fll_band_edge_cc : - public gr_sync_block, public gri_control_loop -{ - private: - /*! - * Build the FLL - * \param samps_per_sym (float) Number of samples per symbol of signal - * \param rolloff (float) Rolloff factor of signal - * \param filter_size (int) Size (in taps) of the filter - * \param bandwidth (float) Loop bandwidth - */ - friend DIGITAL_API digital_fll_band_edge_cc_sptr - digital_make_fll_band_edge_cc(float samps_per_sym, - float rolloff, - int filter_size, - float bandwidth); - - float d_sps; - float d_rolloff; - int d_filter_size; - - std::vector<gr_complex> d_taps_lower; - std::vector<gr_complex> d_taps_upper; - bool d_updated; - filter_t* d_filter_lower; - filter_t* d_filter_upper; - std::vector<gr_complex> d_output_hist; - std::vector<gr_complex> d_fllbuffer; - - /*! - * Build the FLL - * \param samps_per_sym (float) number of samples per symbol - * \param rolloff (float) Rolloff (excess bandwidth) of signal filter - * \param filter_size (int) number of filter taps to generate - * \param bandwidth (float) Loop bandwidth - */ - digital_fll_band_edge_cc(float samps_per_sym, float rolloff, - int filter_size, float bandwidth); - - /*! - * Design the band-edge filter based on the number of samples per symbol, - * filter rolloff factor, and the filter size - * - * \param samps_per_sym (float) Number of samples per symbol of signal - * \param rolloff (float) Rolloff factor of signal - * \param filter_size (int) Size (in taps) of the filter - */ - void design_filter(float samps_per_sym, float rolloff, int filter_size); - -public: - ~digital_fll_band_edge_cc(); - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Set the number of samples per symbol - * - * Set's the number of samples per symbol the system should - * use. This value is uesd to calculate the filter taps and will - * force a recalculation. - * - * \param sps (float) new samples per symbol - * - */ - void set_samples_per_symbol(float sps); - - /*! - * \brief Set the rolloff factor of the shaping filter - * - * This sets the rolloff factor that is used in the pulse shaping - * filter and is used to calculate the filter taps. Changing this - * will force a recalculation of the filter taps. - * - * This should be the same value that is used in the transmitter's - * pulse shaping filter. It must be between 0 and 1 and is usually - * between 0.2 and 0.5 (where 0.22 and 0.35 are commonly used - * values). - * - * \param rolloff (float) new shaping filter rolloff factor [0,1] - * - */ - void set_rolloff(float rolloff); - - /*! - * \brief Set the number of taps in the filter - * - * This sets the number of taps in the band-edge filters. Setting - * this will force a recalculation of the filter taps. - * - * This should be about the same number of taps used in the - * transmitter's shaping filter and also not very large. A large - * number of taps will result in a large delay between input and - * frequency estimation, and so will not be as accurate. Between 30 - * and 70 taps is usual. - * - * \param filter_size (float) number of taps in the filters - * - */ - void set_filter_size(int filter_size); - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the number of sampler per symbol used for the filter - */ - float get_samples_per_symbol() const; - - /*! - * \brief Returns the rolloff factor used for the filter - */ - float get_rolloff() const; - - /*! - * \brief Returns the number of taps of the filter - */ - int get_filter_size() const; - - /*! - * Print the taps to screen. - */ - void print_taps(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_framer_sink_1.h b/gr-digital/include/digital_framer_sink_1.h deleted file mode 100644 index 51d872d874..0000000000 --- a/gr-digital/include/digital_framer_sink_1.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2012 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_GR_FRAMER_SINK_1_H -#define INCLUDED_GR_FRAMER_SINK_1_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class digital_framer_sink_1; -typedef boost::shared_ptr<digital_framer_sink_1> digital_framer_sink_1_sptr; - -DIGITAL_API digital_framer_sink_1_sptr -digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); - -/*! - * \brief Given a stream of bits and access_code flags, assemble packets. - * \ingroup sink_blk - * - * input: stream of bytes from digital_correlate_access_code_bb - * output: none. Pushes assembled packet into target queue - * - * The framer expects a fixed length header of 2 16-bit shorts - * containing the payload length, followed by the payload. If the - * 2 16-bit shorts are not identical, this packet is ignored. Better - * algs are welcome. - * - * The input data consists of bytes that have two bits used. - * Bit 0, the LSB, contains the data bit. - * Bit 1 if set, indicates that the corresponding bit is the - * the first bit of the packet. That is, this bit is the first - * one after the access code. - */ -class DIGITAL_API digital_framer_sink_1 : public gr_sync_block -{ - friend DIGITAL_API digital_framer_sink_1_sptr - digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBITLEN = 32; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbitlen_cnt; // how many so far - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - unsigned char d_packet_byte; // byte being assembled - int d_packet_byte_index; // which bit of d_packet_byte we're working on - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - protected: - digital_framer_sink_1(gr_msg_queue_sptr target_queue); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(int payload_len, int whitener_offset); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - void header_payload(int *len, int *offset) - { - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - *len = (d_header >> 16) & 0x0fff; - *offset = (d_header >> 28) & 0x000f; - } - - public: - ~digital_framer_sink_1(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gr-digital/include/digital_glfsr_source_b.h b/gr-digital/include/digital_glfsr_source_b.h deleted file mode 100644 index 151e5a296c..0000000000 --- a/gr-digital/include/digital_glfsr_source_b.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 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_GR_GLFSR_SOURCE_B_H -#define INCLUDED_GR_GLFSR_SOURCE_B_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -class digital_impl_glfsr; - -class digital_glfsr_source_b; -typedef boost::shared_ptr<digital_glfsr_source_b> digital_glfsr_source_b_sptr; - -DIGITAL_API digital_glfsr_source_b_sptr -digital_make_glfsr_source_b(int degree, bool repeat=true, - int mask=0, int seed=1); - -/*! - * \brief Galois LFSR pseudo-random source - * \ingroup source_blk - * - * \param degree Degree of shift register must be in [1, 32]. If mask - * is 0, the degree determines a default mask (see - * digital_impl_glfsr.cc for the mapping). - * \param repeat Set to repeat sequence. - * \param mask Allows a user-defined bit mask for indexes of the shift - * register to feed back. - * \param seed Initial setting for values in shift register. - */ -class DIGITAL_API digital_glfsr_source_b : public gr_sync_block -{ - private: - friend DIGITAL_API digital_glfsr_source_b_sptr - digital_make_glfsr_source_b(int degree, bool repeat, - int mask, int seed); - - digital_impl_glfsr *d_glfsr; - - bool d_repeat; - unsigned int d_index; - unsigned int d_length; - - digital_glfsr_source_b(int degree, bool repeat, - int mask, int seed); - - public: - - ~digital_glfsr_source_b(); - - 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; -}; - -#endif /* INCLUDED_GR_GLFSR_SOURCE_B_H */ diff --git a/gr-digital/include/digital_glfsr_source_f.h b/gr-digital/include/digital_glfsr_source_f.h deleted file mode 100644 index fb5b064e4f..0000000000 --- a/gr-digital/include/digital_glfsr_source_f.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 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_GR_GLFSR_SOURCE_F_H -#define INCLUDED_GR_GLFSR_SOURCE_F_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -class digital_impl_glfsr; - -class digital_glfsr_source_f; -typedef boost::shared_ptr<digital_glfsr_source_f> digital_glfsr_source_f_sptr; - -DIGITAL_API digital_glfsr_source_f_sptr -digital_make_glfsr_source_f(int degree, bool repeat=true, - int mask=0, int seed=1); - -/*! - * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0. - * \ingroup source_blk - * - * \param degree Degree of shift register must be in [1, 32]. If mask - * is 0, the degree determines a default mask (see - * digital_impl_glfsr.cc for the mapping). - * \param repeat Set to repeat sequence. - * \param mask Allows a user-defined bit mask for indexes of the shift - * register to feed back. - * \param seed Initial setting for values in shift register. - */ -class DIGITAL_API digital_glfsr_source_f : public gr_sync_block -{ - private: - friend DIGITAL_API digital_glfsr_source_f_sptr - digital_make_glfsr_source_f(int degree, bool repeat, - int mask, int seed); - - digital_impl_glfsr *d_glfsr; - - bool d_repeat; - unsigned int d_index; - unsigned int d_length; - - digital_glfsr_source_f(int degree, bool repeat, - int mask, int seed); - - public: - - ~digital_glfsr_source_f(); - - 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; -}; - -#endif /* INCLUDED_GR_GLFSR_SOURCE_F_H */ diff --git a/gr-digital/include/digital_gmskmod_bc.h b/gr-digital/include/digital_gmskmod_bc.h deleted file mode 100644 index 9f378c8a70..0000000000 --- a/gr-digital/include/digital_gmskmod_bc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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_GMSKMOD_BC_H -#define INCLUDED_DIGITAL_GMSKMOD_BC_H - -#include <digital_api.h> -#include <digital_cpmmod_bc.h> - -class digital_gmskmod_bc; -typedef boost::shared_ptr<digital_gmskmod_bc> digital_gmskmod_bc_sptr; - - -DIGITAL_API digital_gmskmod_bc_sptr -digital_make_gmskmod_bc(unsigned samples_per_sym=2, - double bt=0.3, unsigned L=4); - -/*! - * \brief GMSK modulator - * - * \ingroup modulation_blk - * \ingroup digital - * - * \param samples_per_sym Samples per symbol. - * \param bt The 3 dB time-bandwidth product. - * \param L The length of the phase duration in symbols. The Gaussian - * pulse is truncated after L symbols. - * - * The input of this block are symbols from an M-ary alphabet - * +/-1, +/-3, ..., +/-(M-1). Usually, M = 2 and therefore, the - * valid inputs are +/-1. - * The modulator will silently accept any other inputs, though. - * The output is the phase-modulated signal. - */ -class DIGITAL_API digital_gmskmod_bc : public digital_cpmmod_bc -{ - friend DIGITAL_API digital_gmskmod_bc_sptr digital_make_gmskmod_bc(unsigned samples_per_sym, - double bt, unsigned L); - digital_gmskmod_bc(unsigned samples_per_sym, - double bt, unsigned L); -}; - -#endif /* INCLUDED_DIGITAL_GMSKMOD_BC_H */ - diff --git a/gr-digital/include/digital_impl_mpsk_snr_est.h b/gr-digital/include/digital_impl_mpsk_snr_est.h deleted file mode 100644 index df7dbadec1..0000000000 --- a/gr-digital/include/digital_impl_mpsk_snr_est.h +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_IMPL_MPSK_SNR_EST_H -#define INCLUDED_DIGITAL_IMPL_MPSK_SNR_EST_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -//! Enum for the type of SNR estimator to select -/*! \ingroup snr_blk - * \anchor ref_snr_est_types - * - * Below are some ROUGH estimates of what values of SNR each of these - * types of estimators is good for. In general, these offer a - * trade-off between accuracy and performance. - * - * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB) - * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB) - * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB) - * \li SNR_EST_SVR: SVR-based est (>= 0dB) -*/ -enum snr_est_type_t { - SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) - SNR_EST_SKEW, // Skewness-base est (>= 5 dB) - SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) - SNR_EST_SVR // SVR-based est (>= 0dB) -}; - -/*! \brief A parent class for SNR estimators, specifically for M-PSK - * signals in AWGN channels. - * \ingroup snr_blk - */ -class DIGITAL_API digital_impl_mpsk_snr_est -{ - protected: - double d_alpha, d_beta; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est(double alpha); - virtual ~digital_impl_mpsk_snr_est(); - - //! Get the running-average coefficient - double alpha() const; - - //! Set the running-average coefficient - void set_alpha(double alpha); - - //! Update the current registers - virtual int update(int noutput_items, - const gr_complex *in); - - //! Use the register values to compute a new estimate - virtual double snr(); -}; - - -//! \brief SNR Estimator using simple mean/variance estimates. -/*! \ingroup snr_blk - * - * A very simple SNR estimator that just uses mean and variance - * estimates of an M-PSK constellation. This esimator is quick and - * cheap and accurate for high SNR (above 7 dB or so) but quickly - * starts to overestimate the SNR at low SNR. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_simple : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_simple(double alpha); - ~digital_impl_mpsk_snr_est_simple() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using skewness correction. -/*! \ingroup snr_blk - * - * This is an estimator that came from a discussion between Tom - * Rondeau and fred harris with no known paper reference. The idea is - * that at low SNR, the variance estimations will be affected because - * of fold-over around the decision boundaries, which results in a - * skewness to the samples. We estimate the skewness and use this as - * a correcting term. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_skew : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2, d_y3; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_skew(double alpha); - ~digital_impl_mpsk_snr_est_skew() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using 2nd and 4th-order moments. -/*! \ingroup snr_blk - * - * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th (M4) - * order moments. This estimator uses knowledge of the kurtosis of - * the signal (k_a) and noise (k_w) to make its estimation. We use - * Beaulieu's approximations here to M-PSK signals and AWGN channels - * such that k_a=1 and k_w=2. These approximations significantly - * reduce the complexity of the calculations (and computations) - * required. - * - * Reference: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_m2m4 : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_m2m4(double alpha); - ~digital_impl_mpsk_snr_est_m2m4() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using 2nd and 4th-order moments. -/*! \ingroup snr_blk - * - * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th (M4) - * order moments. This estimator uses knowledge of the kurtosis of - * the signal (k_a) and noise (k_w) to make its estimation. In this - * case, you can set your own estimations for k_a and k_w, the - * kurtosis of the signal and noise, to fit this estimation better to - * your signal and channel conditions. - * - * A word of warning: this estimator has not been fully tested or - * proved with any amount of rigor. The estimation for M4 in - * particular might be ignoring effectf of when k_a and k_w are - * different. Use this estimator with caution and a copy of the - * reference on hand. - * - * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify the - * computations for M-PSK and AWGN channels. Use that estimator - * unless you have a way to guess or estimate these values here. - * - * Original paper: - * R. Matzner, "An SNR estimation algorithm for complex baseband - * signal using higher order statistics," Facta Universitatis - * (Nis), no. 6, pp. 41-52, 1993. - * - * Reference used in derivation: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_snr_est_m2m4 : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - double d_ka, d_kw; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - * \param ka: estimate of the signal kurtosis (1 for PSK) - * \param kw: estimate of the channel noise kurtosis (2 for AWGN) - */ - digital_impl_snr_est_m2m4(double alpha, double ka, double kw); - ~digital_impl_snr_est_m2m4() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief Signal-to-Variation Ratio SNR Estimator. -/*! \ingroup snr_blk - * - * This estimator actually comes from an SNR estimator for M-PSK - * signals in fading channels, but this implementation is - * specifically for AWGN channels. The math was simplified to assume - * a signal and noise kurtosis (k_a and k_w) for M-PSK signals in - * AWGN. These approximations significantly reduce the complexity of - * the calculations (and computations) required. - * - * Original paper: - * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service - * monitoring of multipath delay and cochannel interference for - * indoor mobile communication systems," Proc. IEEE - * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994. - * - * Reference: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_svr : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_svr(double alpha); - ~digital_impl_mpsk_snr_est_svr() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - -#endif /* INCLUDED_DIGITAL_IMPL_MPSK_SNR_EST_H */ diff --git a/gr-digital/include/digital_kurtotic_equalizer_cc.h b/gr-digital/include/digital_kurtotic_equalizer_cc.h deleted file mode 100644 index fed88c3741..0000000000 --- a/gr-digital/include/digital_kurtotic_equalizer_cc.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_KURTOTIC_EQUALIZER_CC_H -#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H - -#include <digital_api.h> -#include <gr_adaptive_fir_ccc.h> -#include <gr_math.h> -#include <iostream> - -class digital_kurtotic_equalizer_cc; -typedef boost::shared_ptr<digital_kurtotic_equalizer_cc> digital_kurtotic_equalizer_cc_sptr; - -DIGITAL_API digital_kurtotic_equalizer_cc_sptr -digital_make_kurtotic_equalizer_cc(int num_taps, float mu); - -/*! - * \brief Implements a kurtosis-based adaptive equalizer on complex stream - * \ingroup eq_blk - * \ingroup digital - * - * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind - * equalization algorithm," IEEE Conf. on Control, Automation, - * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." - */ -class DIGITAL_API digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc -{ -private: - float d_mu; - float d_p, d_m; - gr_complex d_q, d_u; - float d_alpha_p, d_alpha_q, d_alpha_m; - - friend DIGITAL_API digital_kurtotic_equalizer_cc_sptr digital_make_kurtotic_equalizer_cc(int num_taps, - float mu); - digital_kurtotic_equalizer_cc(int num_taps, float mu); - - gr_complex sign(gr_complex x) - { - float re = (float)(x.real() >= 0.0f); - float im = (float)(x.imag() >= 0.0f); - return gr_complex(re, im); - } - -protected: - - virtual gr_complex error(const gr_complex &out) - { - - // p = E[|z|^2] - // q = E[z^2] - // m = E[|z|^4] - // u = E[kurtosis(z)] - - float nrm = norm(out); - gr_complex cnj = conj(out); - float epsilon_f = 1e-12; - gr_complex epsilon_c = gr_complex(1e-12, 1e-12); - - - d_p = (1-d_alpha_p)*d_p + (d_alpha_p)*nrm + epsilon_f; - d_q = (1-d_alpha_q)*d_q + (d_alpha_q)*out*out + epsilon_c; - d_m = (1-d_alpha_m)*d_m + (d_alpha_m)*nrm*nrm + epsilon_f; - d_u = d_m - 2.0f*(d_p*d_p) - d_q*d_q; - - gr_complex F = (1.0f / (d_p*d_p*d_p)) * - (sign(d_u) * (nrm*cnj - 2.0f*d_p*cnj - conj(d_q)*out) - - abs(d_u)*cnj); - - //std::cout << "out: " << out << " p: " << d_p << " q: " << d_q; - //std::cout << " m: " << d_m << " u: " << d_u << std::endl; - //std::cout << "error: " << F << std::endl; - - float re = gr_clip(F.real(), 1.0); - float im = gr_clip(F.imag(), 1.0); - return gr_complex(re, im); - } - - virtual void update_tap(gr_complex &tap, const gr_complex &in) - { - tap += d_mu*in*d_error; - } - -public: - void set_gain(float mu) - { - if(mu < 0) - throw std::out_of_range("digital_kurtotic_equalizer::set_gain: Gain value must be >= 0"); - d_mu = mu; - } -}; - -#endif diff --git a/gr-digital/include/digital_lms_dd_equalizer_cc.h b/gr-digital/include/digital_lms_dd_equalizer_cc.h deleted file mode 100644 index 56871fa678..0000000000 --- a/gr-digital/include/digital_lms_dd_equalizer_cc.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_LMS_DD_EQUALIZER_CC_H -#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_H - -#include <digital_api.h> -#include <gr_adaptive_fir_ccc.h> -#include <digital_constellation.h> - -class digital_lms_dd_equalizer_cc; -typedef boost::shared_ptr<digital_lms_dd_equalizer_cc> digital_lms_dd_equalizer_cc_sptr; - -DIGITAL_API digital_lms_dd_equalizer_cc_sptr digital_make_lms_dd_equalizer_cc (int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - -/*! - * \brief Least-Mean-Square Decision Directed Equalizer (complex in/out) - * \ingroup eq_blk - * \ingroup digital - * - * This block implements an LMS-based decision-directed equalizer. - * It uses a set of weights, w, to correlate against the inputs, u, - * and a decisions is then made from this output. The error - * in the decision is used to update teh weight vector. - * - * y[n] = conj(w[n]) u[n] - * d[n] = decision(y[n]) - * e[n] = d[n] - y[n] - * w[n+1] = w[n] + mu u[n] conj(e[n]) - * - * Where mu is a gain value (between 0 and 1 and usualy small, - * around 0.001 - 0.01. - * - * This block uses the digital_constellation object for making - * the decision from y[n]. Create the constellation object for - * whatever constellation is to be used and pass in the object. - * In Python, you can use something like: - * self.constellation = digital.constellation_qpsk() - * To create a QPSK constellation (see the digital_constellation - * block for more details as to what constellations are available - * or how to create your own). You then pass the object to this - * block as an sptr, or using "self.constellation.base()". - * - * The theory for this algorithm can be found in Chapter 9 of: - * S. Haykin, Adaptive Filter Theory, Upper Saddle River, NJ: - * Prentice Hall, 1996. - * - */ -class DIGITAL_API digital_lms_dd_equalizer_cc : public gr_adaptive_fir_ccc -{ -private: - friend DIGITAL_API digital_lms_dd_equalizer_cc_sptr digital_make_lms_dd_equalizer_cc (int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - - float d_mu; - std::vector<gr_complex> d_taps; - digital_constellation_sptr d_cnst; - - digital_lms_dd_equalizer_cc (int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - -protected: - - virtual gr_complex error(const gr_complex &out) - { - gr_complex decision, error; - d_cnst->map_to_points(d_cnst->decision_maker(&out), &decision); - error = decision - out; - return error; - } - - virtual void update_tap(gr_complex &tap, const gr_complex &in) - { - tap += d_mu*conj(in)*d_error; - } - -public: - float get_gain() - { - return d_mu; - } - - void set_gain(float mu) - { - if(mu < 0.0f || mu > 1.0f) { - throw std::out_of_range("digital_lms_dd_equalizer::set_mu: Gain value must in [0, 1]"); - } - else { - d_mu = mu; - } - } - -}; - -#endif diff --git a/gr-digital/include/digital_mpsk_receiver_cc.h b/gr-digital/include/digital_mpsk_receiver_cc.h deleted file mode 100644 index 1f11a26b64..0000000000 --- a/gr-digital/include/digital_mpsk_receiver_cc.h +++ /dev/null @@ -1,320 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007,2011 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_MPSK_RECEIVER_CC_H -#define INCLUDED_DIGITAL_MPSK_RECEIVER_CC_H - -#include <digital_api.h> -#include <gruel/attributes.h> -#include <gri_control_loop.h> -#include <gr_block.h> -#include <gr_complex.h> -#include <fstream> - -class gri_mmse_fir_interpolator_cc; - -class digital_mpsk_receiver_cc; -typedef boost::shared_ptr<digital_mpsk_receiver_cc> digital_mpsk_receiver_cc_sptr; - -// public constructor -DIGITAL_API digital_mpsk_receiver_cc_sptr -digital_make_mpsk_receiver_cc (unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); - -/*! - * \brief This block takes care of receiving M-PSK modulated signals - * through phase, frequency, and symbol synchronization. - * \ingroup sync_blk - * \ingroup demod_blk - * \ingroup digital - * - * This block takes care of receiving M-PSK modulated signals through - * phase, frequency, and symbol synchronization. It performs carrier - * frequency and phase locking as well as symbol timing recovery. It - * works with (D)BPSK, (D)QPSK, and (D)8PSK as tested currently. It - * should also work for OQPSK and PI/4 DQPSK. - * - * The phase and frequency synchronization are based on a Costas loop - * that finds the error of the incoming signal point compared to its - * nearest constellation point. The frequency and phase of the NCO are - * updated according to this error. There are optimized phase error - * detectors for BPSK and QPSK, but 8PSK is done using a brute-force - * computation of the constellation points to find the minimum. - * - * The symbol synchronization is done using a modified Mueller and - * Muller circuit from the paper: - * - * "G. R. Danesfahani, T. G. Jeans, "Optimisation of modified Mueller - * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 - * June 1995, pp. 1032 - 1033." - * - * This circuit interpolates the downconverted sample (using the NCO - * developed by the Costas loop) every mu samples, then it finds the - * sampling error based on this and the past symbols and the decision - * made on the samples. Like the phase error detector, there are - * optimized decision algorithms for BPSK and QPKS, but 8PSK uses - * another brute force computation against all possible symbols. The - * modifications to the M&M used here reduce self-noise. - * - */ - -class DIGITAL_API digital_mpsk_receiver_cc : public gr_block, public gri_control_loop -{ - public: - ~digital_mpsk_receiver_cc (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - - //! Returns the modulation order (M) currently set - float modulation_order() const { return d_M; } - - //! Returns current value of theta - float theta() const { return d_theta; } - - //! Returns current value of mu - float mu() const { return d_mu; } - - //! Returns current value of omega - float omega() const { return d_omega; } - - //! Returns mu gain factor - float gain_mu() const { return d_gain_mu; } - - //! Returns omega gain factor - float gain_omega() const { return d_gain_omega; } - - //! Returns the relative omega limit - float gain_omega_rel() const {return d_omega_rel; } - - //! Sets the modulation order (M) currently - void set_modulation_order(unsigned int M); - - //! Sets value of theta - void set_theta(float theta) { d_theta = theta; } - - //! Sets value of mu - void set_mu (float mu) { d_mu = mu; } - - //! Sets value of omega and its min and max values - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_rel); - d_max_omega = omega*(1.0 + d_omega_rel); - d_omega_mid = 0.5*(d_min_omega+d_max_omega); - } - - //! Sets value for mu gain factor - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - - //! Sets value for omega gain factor - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - - //! Sets the relative omega limit and resets omega min/max values - void set_gain_omega_rel(float omega_rel); - -protected: - - /*! - * \brief Constructor to synchronize incoming M-PSK symbols - * - * \param M modulation order of the M-PSK modulation - * \param theta any constant phase rotation from the real axis of the constellation - * \param loop_bw Loop bandwidth to set gains of phase/freq tracking loop - * \param fmin minimum normalized frequency value the loop can achieve - * \param fmax maximum normalized frequency value the loop can achieve - * \param mu initial parameter for the interpolator [0,1] - * \param gain_mu gain parameter of the M&M error signal to adjust mu (~0.05) - * \param omega initial value for the number of symbols between samples (~number of samples/symbol) - * \param gain_omega gain parameter to adjust omega based on the error (~omega^2/4) - * \param omega_rel sets the maximum (omega*(1+omega_rel)) and minimum (omega*(1+omega_rel)) omega (~0.005) - * - * The constructor also chooses which phase detector and decision maker to use in the work loop based on the - * value of M. - */ - digital_mpsk_receiver_cc (unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); - - void make_constellation(); - void mm_sampler(const gr_complex symbol); - void mm_error_tracking(gr_complex sample); - void phase_error_tracking(gr_complex sample); - - - /*! - * \brief Phase error detector for MPSK modulations. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error for any MPSK signal by - * creating a set of PSK constellation points and doing a - * brute-force search to see which point minimizes the Euclidean - * distance. This point is then used to derotate the sample to the - * real-axis and a atan (using the fast approximation function) to - * determine the phase difference between the incoming sample and - * the real constellation point - * - * This should be cleaned up and made more efficient. - * - * \returns the approximated phase error. - */ - float phase_error_detector_generic(gr_complex sample) const; // generic for M but more costly - - /*! - * \brief Phase error detector for BPSK modulation. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error using a simple BPSK - * phase error detector by multiplying the real and imaginary (the - * error signal) components together. As the imaginary part goes to - * 0, so does this error. - * - * \returns the approximated phase error. - */ - float phase_error_detector_bpsk(gr_complex sample) const; // optimized for BPSK - - /*! - * \brief Phase error detector for QPSK modulation. - * - * \param sample the I&Q sample from which to determine the phase error - * - * This function determines the phase error using the limiter - * approach in a standard 4th order Costas loop - * - * \returns the approximated phase error. - */ - float phase_error_detector_qpsk(gr_complex sample) const; - - - - /*! - * \brief Decision maker for a generic MPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a generic implementation that does a - * brute-force search for the constellation point that minimizes the - * error between it and the incoming signal. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_generic(gr_complex sample) const; - - - /*! - * \brief Decision maker for BPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a simple slicer function that makes a - * decision on the symbol based on its placement on the real axis of - * greater than 0 or less than 0; the quadrature component is always - * 0. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_bpsk(gr_complex sample) const; - - - /*! - * \brief Decision maker for QPSK constellation. - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This decision maker is a simple slicer function that makes a - * decision on the symbol based on its placement versus both axes - * and returns which quadrant the symbol is in. - * - * \returns the index to d_constellation that minimizes the error/ - */ - unsigned int decision_qpsk(gr_complex sample) const; - -private: - unsigned int d_M; - float d_theta; - - /*! - * \brief Decision maker function pointer - * - * \param sample the baseband I&Q sample from which to make the decision - * - * This is a function pointer that is set in the constructor to - * point to the proper decision function for the specified - * constellation order. - * - * \return index into d_constellation point that is the closest to the recieved sample - */ - unsigned int (digital_mpsk_receiver_cc::*d_decision)(gr_complex sample) const; // pointer to decision function - - - std::vector<gr_complex> d_constellation; - unsigned int d_current_const_point; - - // Members related to symbol timing - float d_mu, d_gain_mu; - float d_omega, d_gain_omega, d_omega_rel, d_max_omega, d_min_omega, d_omega_mid; - gr_complex d_p_2T, d_p_1T, d_p_0T; - gr_complex d_c_2T, d_c_1T, d_c_0T; - - /*! - * \brief Phase error detector function pointer - * - * \param sample the I&Q sample from which to determine the phase error - * - * This is a function pointer that is set in the constructor to - * point to the proper phase error detector function for the - * specified constellation order. - */ - float (digital_mpsk_receiver_cc::*d_phase_error_detector)(gr_complex sample) const; - - - //! get interpolated value - gri_mmse_fir_interpolator_cc *d_interp; - - //! delay line length. - static const unsigned int DLLEN = 8; - - //! delay line plus some length for overflow protection - __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; - - //! index to delay line - unsigned int d_dl_idx; - - friend DIGITAL_API digital_mpsk_receiver_cc_sptr - digital_make_mpsk_receiver_cc (unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); -}; - -#endif diff --git a/gr-digital/include/digital_mpsk_snr_est_cc.h b/gr-digital/include/digital_mpsk_snr_est_cc.h deleted file mode 100644 index 2cbd98bab8..0000000000 --- a/gr-digital/include/digital_mpsk_snr_est_cc.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_MPSK_SNR_EST_CC_H -#define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <digital_impl_mpsk_snr_est.h> - -class digital_mpsk_snr_est_cc; -typedef boost::shared_ptr<digital_mpsk_snr_est_cc> digital_mpsk_snr_est_cc_sptr; - -DIGITAL_API digital_mpsk_snr_est_cc_sptr -digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples=10000, - double alpha=0.001); - -//! \brief A block for computing SNR of a signal. -/*! \ingroup snr_blk - * - * This block can be used to monitor and retrieve estimations of the - * signal SNR. It is designed to work in a flowgraph and passes all - * incoming data along to its output. - * - * The block is designed for use with M-PSK signals especially. The - * type of estimator is specified as the \p type parameter in the - * constructor. The estimators tend to trade off performance for - * accuracy, although experimentation should be done to figure out - * the right approach for a given implementation. Further, the - * current set of estimators are designed and proven theoretically - * under AWGN conditions; some amount of error should be assumed - * and/or estimated for real channel conditions. - */ -class DIGITAL_API digital_mpsk_snr_est_cc : public gr_sync_block -{ - private: - snr_est_type_t d_type; - int d_nsamples, d_count; - double d_alpha; - digital_impl_mpsk_snr_est *d_snr_est; - - //d_key is the tag name, 'snr', d_me is the block name + unique ID - pmt::pmt_t d_key, d_me; - - /*! Factory function returning shared pointer of this class - * - * Parameters: - * - * \param type: the type of estimator to use \ref ref_snr_est_types - * "snr_est_type_t" for details about the available types. - * \param tag_nsamples: after this many samples, a tag containing - * the SNR (key='snr') will be sent - * \param alpha: the update rate of internal running average - * calculations. - */ - friend DIGITAL_API digital_mpsk_snr_est_cc_sptr - digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha); - - // Private constructor - digital_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha); - -public: - - ~digital_mpsk_snr_est_cc(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - //! Return the estimated signal-to-noise ratio in decibels - double snr(); - - //! Return the type of estimator in use - snr_est_type_t type() const; - - //! Return how many samples between SNR tags - int tag_nsample() const; - - //! Get the running-average coefficient - double alpha() const; - - //! Set type of estimator to use - void set_type(snr_est_type_t t); - - //! Set the number of samples between SNR tags - void set_tag_nsample(int n); - - //! Set the running-average coefficient - void set_alpha(double alpha); -}; - -#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H */ diff --git a/gr-digital/include/digital_ofdm_cyclic_prefixer.h b/gr-digital/include/digital_ofdm_cyclic_prefixer.h deleted file mode 100644 index 1b9682bb35..0000000000 --- a/gr-digital/include/digital_ofdm_cyclic_prefixer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004-2006,2011 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_OFDM_CYCLIC_PREFIXER_H -#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H - -#include <digital_api.h> -#include <gr_sync_interpolator.h> -#include <stdio.h> - -class digital_ofdm_cyclic_prefixer; -typedef boost::shared_ptr<digital_ofdm_cyclic_prefixer> digital_ofdm_cyclic_prefixer_sptr; - -DIGITAL_API digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - -/*! - * \brief adds a cyclic prefix vector to an input size long ofdm - * symbol(vector) and converts vector to a stream output_size long. - * \ingroup ofdm_blk - */ -class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_sync_interpolator -{ - friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr - digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - protected: - digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - private: - size_t d_input_size; - size_t d_output_size; -}; - -#endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ diff --git a/gr-digital/include/digital_ofdm_frame_acquisition.h b/gr-digital/include/digital_ofdm_frame_acquisition.h deleted file mode 100644 index 9c2f602334..0000000000 --- a/gr-digital/include/digital_ofdm_frame_acquisition.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2011 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_OFDM_FRAME_ACQUISITION_H -#define INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H - -#include <digital_api.h> -#include <gr_block.h> -#include <vector> - -class digital_ofdm_frame_acquisition; -typedef boost::shared_ptr<digital_ofdm_frame_acquisition> digital_ofdm_frame_acquisition_sptr; - -digital_ofdm_frame_acquisition_sptr -DIGITAL_API digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len=10); - -/*! - * \brief take a vector of complex constellation points in from an FFT - * and performs a correlation and equalization. - * \ingroup demodulation_blk - * \ingroup ofdm_blk - * - * This block takes the output of an FFT of a received OFDM symbol and finds the - * start of a frame based on two known symbols. It also looks at the surrounding - * bins in the FFT output for the correlation in case there is a large frequency - * shift in the data. This block assumes that the fine frequency shift has already - * been corrected and that the samples fall in the middle of one FFT bin. - * - * It then uses one of those known - * symbols to estimate the channel response over all subcarriers and does a simple - * 1-tap equalization on all subcarriers. This corrects for the phase and amplitude - * distortion caused by the channel. - */ - -class DIGITAL_API digital_ofdm_frame_acquisition : public gr_block -{ - /*! - * \brief Build an OFDM correlator and equalizer. - * \param occupied_carriers The number of subcarriers with data in the received symbol - * \param fft_length The size of the FFT vector (occupied_carriers + unused carriers) - * \param cplen The length of the cycle prefix - * \param known_symbol A vector of complex numbers representing a known symbol at the - * start of a frame (usually a BPSK PN sequence) - * \param max_fft_shift_len Set's the maximum distance you can look between bins for correlation - */ - friend DIGITAL_API digital_ofdm_frame_acquisition_sptr - digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - -protected: - digital_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - - private: - unsigned char slicer(gr_complex x); - void correlate(const gr_complex *symbol, int zeros_on_left); - void calculate_equalizer(const gr_complex *symbol, int zeros_on_left); - gr_complex coarse_freq_comp(int freq_delta, int count); - - unsigned int d_occupied_carriers; // !< \brief number of subcarriers with data - unsigned int d_fft_length; // !< \brief length of FFT vector - unsigned int d_cplen; // !< \brief length of cyclic prefix in samples - unsigned int d_freq_shift_len; // !< \brief number of surrounding bins to look at for correlation - std::vector<gr_complex> d_known_symbol; // !< \brief known symbols at start of frame - std::vector<float> d_known_phase_diff; // !< \brief factor used in correlation from known symbol - std::vector<float> d_symbol_phase_diff; // !< \brief factor used in correlation from received symbol - std::vector<gr_complex> d_hestimate; // !< channel estimate - int d_coarse_freq; // !< \brief search distance in number of bins - unsigned int d_phase_count; // !< \brief accumulator for coarse freq correction - float d_snr_est; // !< an estimation of the signal to noise ratio - - gr_complex *d_phase_lut; // !< look-up table for coarse frequency compensation - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - public: - /*! - * \brief Return an estimate of the SNR of the channel - */ - float snr() { return d_snr_est; } - - ~digital_ofdm_frame_acquisition(void); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gr-digital/include/digital_ofdm_frame_sink.h b/gr-digital/include/digital_ofdm_frame_sink.h deleted file mode 100644 index 5785d4be7b..0000000000 --- a/gr-digital/include/digital_ofdm_frame_sink.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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_OFDM_FRAME_SINK_H -#define INCLUDED_DIGITAL_OFDM_FRAME_SINK_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class digital_ofdm_frame_sink; -typedef boost::shared_ptr<digital_ofdm_frame_sink> digital_ofdm_frame_sink_sptr; - -DIGITAL_API digital_ofdm_frame_sink_sptr -digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); - -/*! - * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs - * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk - * \ingroup ofdm_blk - * - * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, - * we want to be able to pass in a reference to an object to do the demapping and slicing - * for a given modulation type. - */ -class DIGITAL_API digital_ofdm_frame_sink : public gr_sync_block -{ - friend DIGITAL_API digital_ofdm_frame_sink_sptr - digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBYTELEN = 4; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbytelen_cnt; // how many so far - - unsigned char *d_bytes_out; // hold the current bytes produced by the demapper - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned int d_partial_byte; - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out - - std::vector<gr_complex> d_sym_position; - std::vector<unsigned char> d_sym_value_out; - std::vector<gr_complex> d_dfe; - unsigned int d_nbits; - - unsigned char d_resid; - unsigned int d_nresid; - float d_phase; - float d_freq; - float d_phase_gain; - float d_freq_gain; - float d_eq_gain; - - std::vector<int> d_subcarrier_map; - - protected: - digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - unsigned char slicer(const gr_complex x); - unsigned int demapper(const gr_complex *in, - unsigned char *out); - - bool set_sym_value_out(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out); - - public: - ~digital_ofdm_frame_sink(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_OFDM_FRAME_SINK_H */ diff --git a/gr-digital/include/digital_ofdm_insert_preamble.h b/gr-digital/include/digital_ofdm_insert_preamble.h deleted file mode 100644 index fa44558add..0000000000 --- a/gr-digital/include/digital_ofdm_insert_preamble.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H -#define INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H - -#include <digital_api.h> -#include <gr_block.h> -#include <vector> - -class digital_ofdm_insert_preamble; -typedef boost::shared_ptr<digital_ofdm_insert_preamble> digital_ofdm_insert_preamble_sptr; - -DIGITAL_API digital_ofdm_insert_preamble_sptr -digital_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -/*! - * \brief insert "pre-modulated" preamble symbols before each payload. - * \ingroup sync_blk - * \ingroup ofdm_blk - * - * <pre> - * input 1: stream of vectors of gr_complex [fft_length] - * These are the modulated symbols of the payload. - * - * input 2: stream of char. The LSB indicates whether the corresponding - * symbol on input 1 is the first symbol of the payload or not. - * It's a 1 if the corresponding symbol is the first symbol, - * otherwise 0. - * - * N.B., this implies that there must be at least 1 symbol in the payload. - * - * - * output 1: stream of vectors of gr_complex [fft_length] - * These include the preamble symbols and the payload symbols. - * - * output 2: stream of char. The LSB indicates whether the corresponding - * symbol on input 1 is the first symbol of a packet (i.e., the - * first symbol of the preamble.) It's a 1 if the corresponding - * symbol is the first symbol, otherwise 0. - * </pre> - * - * \param fft_length length of each symbol in samples. - * \param preamble vector of symbols that represent the pre-modulated preamble. - */ - -class DIGITAL_API digital_ofdm_insert_preamble : public gr_block -{ - friend DIGITAL_API digital_ofdm_insert_preamble_sptr - digital_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -protected: - digital_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - -private: - enum state_t { - ST_IDLE, - ST_PREAMBLE, - ST_FIRST_PAYLOAD, - ST_PAYLOAD - }; - - int d_fft_length; - const std::vector<std::vector<gr_complex> > d_preamble; - state_t d_state; - int d_nsymbols_output; - int d_pending_flag; - - void enter_idle(); - void enter_first_payload(); - void enter_payload(); - - -public: - ~digital_ofdm_insert_preamble(); - void enter_preamble(); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - -}; - -#endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H */ diff --git a/gr-digital/include/digital_ofdm_mapper_bcv.h b/gr-digital/include/digital_ofdm_mapper_bcv.h deleted file mode 100644 index daed1eab29..0000000000 --- a/gr-digital/include/digital_ofdm_mapper_bcv.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2011 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_OFDM_MAPPER_BCV_H -#define INCLUDED_DIGITAL_OFDM_MAPPER_BCV_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class digital_ofdm_mapper_bcv; -typedef boost::shared_ptr<digital_ofdm_mapper_bcv> digital_ofdm_mapper_bcv_sptr; - -DIGITAL_API digital_ofdm_mapper_bcv_sptr -digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - -/*! - * \brief take a stream of bytes in and map to a vector of complex - * constellation points suitable for IFFT input to be used in an ofdm - * modulator. Abstract class must be subclassed with specific mapping. - * \ingroup modulation_blk - * \ingroup ofdm_blk - */ - -class DIGITAL_API digital_ofdm_mapper_bcv : public gr_sync_block -{ - friend DIGITAL_API digital_ofdm_mapper_bcv_sptr - digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); -protected: - digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - - private: - std::vector<gr_complex> d_constellation; - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - unsigned int d_occupied_carriers; - unsigned int d_fft_length; - unsigned int d_bit_offset; - int d_pending_flag; - - unsigned long d_nbits; - unsigned char d_msgbytes; - - unsigned char d_resid; - unsigned int d_nresid; - - std::vector<int> d_subcarrier_map; - - int randsym(); - - public: - ~digital_ofdm_mapper_bcv(void); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif diff --git a/gr-digital/include/digital_ofdm_sampler.h b/gr-digital/include/digital_ofdm_sampler.h deleted file mode 100644 index 9c54e4e776..0000000000 --- a/gr-digital/include/digital_ofdm_sampler.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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_OFDM_SAMPLER_H -#define INCLUDED_DIGITAL_OFDM_SAMPLER_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -class digital_ofdm_sampler; -typedef boost::shared_ptr<digital_ofdm_sampler> digital_ofdm_sampler_sptr; - -DIGITAL_API digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); - -/*! - * \brief does the rest of the OFDM stuff - * \ingroup ofdm_blk - */ -class DIGITAL_API digital_ofdm_sampler : public gr_block -{ - friend DIGITAL_API digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); - - digital_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); - - private: - enum state_t {STATE_NO_SIG, STATE_PREAMBLE, STATE_FRAME}; - - state_t d_state; - unsigned int d_timeout_max; - unsigned int d_timeout; - unsigned int d_fft_length; - unsigned int d_symbol_length; - - public: - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_packet_sink.h b/gr-digital/include/digital_packet_sink.h deleted file mode 100644 index 7ab41c0ef7..0000000000 --- a/gr-digital/include/digital_packet_sink.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2012 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_GR_PACKET_SINK_H -#define INCLUDED_GR_PACKET_SINK_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class digital_packet_sink; -typedef boost::shared_ptr<digital_packet_sink> digital_packet_sink_sptr; - -DIGITAL_API digital_packet_sink_sptr -digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold = -1); // -1 -> use default - -/*! - * \brief process received bits looking for packet sync, header, and process bits into packet - * \ingroup sink_blk - * - * input: stream of symbols to be sliced. - * - * output: none. Pushes assembled packet into target queue - * - * The packet sink takes in a stream of binary symbols that are sliced - * around 0. The bits are then checked for the \p sync_vector to - * determine find and decode the packet. It then expects a fixed - * length header of 2 16-bit shorts containing the payload length, - * followed by the payload. If the 2 16-bit shorts are not identical, - * this packet is ignored. Better algs are welcome. - * - * This block is not very useful anymore as it only works with 2-level - * modulations such as BPSK or GMSK. The block can generally be - * replaced with a correlate access code and frame sink blocks. - * - * \param sync_vector The synchronization vector as a vector of 1's and 0's. - * \param target_queue The message queue that packets are sent to. - * \param threshold Number of bits that can be incorrect in the \p sync_vector. - */ -class DIGITAL_API digital_packet_sink : public gr_sync_block -{ - friend DIGITAL_API digital_packet_sink_sptr - digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBITLEN = 32; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - unsigned long long d_sync_vector; // access code to locate start of packet - unsigned int d_threshold; // how many bits may be wrong in sync vector - - state_t d_state; - - unsigned long long d_shift_reg; // used to look for sync_vector - - unsigned int d_header; // header bits - int d_headerbitlen_cnt; // how many so far - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - unsigned char d_packet_byte; // byte being assembled - int d_packet_byte_index; // which bit of d_packet_byte we're working on - int d_packetlen; // length of packet - int d_packetlen_cnt; // how many so far - - protected: - digital_packet_sink(const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(int payload_len); - - int slice(float x) { return x > 0 ? 1 : 0; } - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - int header_payload_len() - { - // header consists of two 16-bit shorts in network byte order - int t = (d_header >> 16) & 0xffff; - return t; - } - - public: - ~digital_packet_sink(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - - //! return true if we detect carrier - bool carrier_sensed() const - { - return d_state != STATE_SYNC_SEARCH; - } - -}; - -#endif /* INCLUDED_GR_PACKET_SINK_H */ diff --git a/gr-digital/include/digital_pfb_clock_sync_ccf.h b/gr-digital/include/digital_pfb_clock_sync_ccf.h deleted file mode 100644 index 1b403ab253..0000000000 --- a/gr-digital/include/digital_pfb_clock_sync_ccf.h +++ /dev/null @@ -1,376 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_CCF_H -#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_H - -#include <digital_api.h> -#include <gr_block.h> - -class digital_pfb_clock_sync_ccf; -typedef boost::shared_ptr<digital_pfb_clock_sync_ccf> digital_pfb_clock_sync_ccf_sptr; -DIGITAL_API digital_pfb_clock_sync_ccf_sptr -digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_fir_ccf; - -/*! - * \class digital_pfb_clock_sync_ccf - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps (default=1): The osps is the number of output samples per symbol. By default, - * the algorithm produces 1 sample per symbol, sampled at the exact - * sample value. This osps value was added to better work with - * equalizers, which do a better job of modeling the channel if they - * have 2 samps/sym. - */ - -class DIGITAL_API digital_pfb_clock_sync_ccf : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per symbol in the incoming signal - * \param loop_bw (float) The bandwidth of the control loop; set's alpha and beta. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * \param osps (int) The number of output samples per symbol (default=1). - * - */ - friend DIGITAL_API digital_pfb_clock_sync_ccf_sptr - digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_loop_bw; - float d_damping; - float d_alpha; - float d_beta; - - int d_nfilters; - int d_taps_per_filter; - std::vector<gr_fir_ccf*> d_filters; - std::vector<gr_fir_ccf*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_osps; - float d_error; - int d_out_idx; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - digital_pfb_clock_sync_ccf(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~digital_pfb_clock_sync_ccf(); - - /*! \brief update the system gains from omega and eta - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void update_gains(); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps(const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - /*! - * Returns all of the taps of the matched filter - */ - std::vector< std::vector<float> > get_taps(); - - /*! - * Returns all of the taps of the derivative filter - */ - std::vector< std::vector<float> > get_diff_taps(); - - /*! - * Returns the taps of the matched filter for a particular channel - */ - std::vector<float> get_channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter for a particular channel - */ - std::vector<float> get_diff_channel_taps(int channel); - - /*! - * Return the taps as a formatted string for printing - */ - std::string get_taps_as_string(); - - /*! - * Return the derivative filter taps as a formatted string for printing - */ - std::string get_diff_taps_as_string(); - - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - - /*! - * \brief Set the loop bandwidth - * - * Set the loop filter's bandwidth to \p bw. This should be between - * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive - * number. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param bw (float) new bandwidth - * - */ - void set_loop_bandwidth(float bw); - - /*! - * \brief Set the loop damping factor - * - * Set the loop filter's damping factor to \p df. The damping factor - * should be sqrt(2)/2.0 for critically damped systems. - * Set it to anything else only if you know what you are doing. It must - * be a number between 0 and 1. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param df (float) new damping factor - * - */ - void set_damping_factor(float df); - - /*! - * \brief Set the loop gain alpha - * - * Set's the loop filter's alpha gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param alpha (float) new alpha gain - * - */ - void set_alpha(float alpha); - - /*! - * \brief Set the loop gain beta - * - * Set's the loop filter's beta gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param beta (float) new beta gain - * - */ - void set_beta(float beta); - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the loop bandwidth - */ - float get_loop_bandwidth() const; - - /*! - * \brief Returns the loop damping factor - */ - float get_damping_factor() const; - - /*! - * \brief Returns the loop gain alpha - */ - float get_alpha() const; - - /*! - * \brief Returns the loop gain beta - */ - float get_beta() const; - - /*! - * \brief Returns the current clock rate - */ - float get_clock_rate() const; - - /******************************************************************* - *******************************************************************/ - - bool check_topology(int ninputs, int noutputs); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_pfb_clock_sync_fff.h b/gr-digital/include/digital_pfb_clock_sync_fff.h deleted file mode 100644 index c7e8babd69..0000000000 --- a/gr-digital/include/digital_pfb_clock_sync_fff.h +++ /dev/null @@ -1,376 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_FFF_H -#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_H - -#include <digital_api.h> -#include <gr_block.h> - -class digital_pfb_clock_sync_fff; -typedef boost::shared_ptr<digital_pfb_clock_sync_fff> digital_pfb_clock_sync_fff_sptr; -DIGITAL_API digital_pfb_clock_sync_fff_sptr -digital_make_pfb_clock_sync_fff(double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class gr_fir_fff; - -/*! - * \class digital_pfb_clock_sync_fff - * - * \brief Timing synchronizer using polyphase filterbanks - * - * \ingroup filter_blk - * \ingroup pfb_blk - * - * This block performs timing synchronization for PAM signals by - * minimizing the derivative of the filtered signal, which in turn - * maximizes the SNR and minimizes ISI. - * - * This approach works by setting up two filterbanks; one filterbank - * contains the signal's pulse shaping matched filter (such as a root - * raised cosine filter), where each branch of the filterbank contains - * a different phase of the filter. The second filterbank contains - * the derivatives of the filters in the first filterbank. Thinking of - * this in the time domain, the first filterbank contains filters that - * have a sinc shape to them. We want to align the output signal to be - * sampled at exactly the peak of the sinc shape. The derivative of - * the sinc contains a zero at the maximum point of the sinc (sinc(0) - * = 1, sinc(0)' = 0). Furthermore, the region around the zero point - * is relatively linear. We make use of this fact to generate the - * error signal. - * - * If the signal out of the derivative filters is d_i[n] for the ith - * filter, and the output of the matched filter is x_i[n], we - * calculate the error as: e[n] = (Re{x_i[n]} * Re{d_i[n]} + - * Im{x_i[n]} * Im{d_i[n]}) / 2.0 This equation averages the error in - * the real and imaginary parts. There are two reasons we multiply by - * the signal itself. First, if the symbol could be positive or - * negative going, but we want the error term to always tell us to go - * in the same direction depending on which side of the zero point we - * are on. The sign of x_i[n] adjusts the error term to do - * this. Second, the magnitude of x_i[n] scales the error term - * depending on the symbol's amplitude, so larger signals give us a - * stronger error term because we have more confidence in that - * symbol's value. Using the magnitude of x_i[n] instead of just the - * sign is especially good for signals with low SNR. - * - * The error signal, e[n], gives us a value proportional to how far - * away from the zero point we are in the derivative signal. We want - * to drive this value to zero, so we set up a second order loop. We - * have two variables for this loop; d_k is the filter number in the - * filterbank we are on and d_rate is the rate which we travel through - * the filters in the steady state. That is, due to the natural clock - * differences between the transmitter and receiver, d_rate represents - * that difference and would traverse the filter phase paths to keep - * the receiver locked. Thinking of this as a second-order PLL, the - * d_rate is the frequency and d_k is the phase. So we update d_rate - * and d_k using the standard loop equations based on two error - * signals, d_alpha and d_beta. We have these two values set based on - * each other for a critically damped system, so in the block - * constructor, we just ask for "gain," which is d_alpha while d_beta - * is equal to (gain^2)/4. - * - * The block's parameters are: - * - * \li \p sps: The clock sync block needs to know the number of samples per - * symbol, because it defaults to return a single point representing - * the symbol. The sps can be any positive real number and does not - * need to be an integer. - * - * \li \p loop_bw: The loop bandwidth is used to set the gain of the - * inner control loop (see: - * http://gnuradio.squarespace.com/blog/2011/8/13/control-loop-gain-values.html). - * This should be set small (a value of around 2pi/100 is suggested in - * that blog post as the step size for the number of radians around - * the unit circle to move relative to the error). - * - * \li \p taps: One of the most important parameters for this block is - * the taps of the filter. One of the benefits of this algorithm is - * that you can put the matched filter in here as the taps, so you get - * both the matched filter and sample timing correction in one go. So - * create your normal matched filter. For a typical digital - * modulation, this is a root raised cosine filter. The number of taps - * of this filter is based on how long you expect the channel to be; - * that is, how many symbols do you want to combine to get the current - * symbols energy back (there's probably a better way of stating - * that). It's usually 5 to 10 or so. That gives you your filter, but - * now we need to think about it as a filter with different phase - * profiles in each filter. So take this number of taps and multiply - * it by the number of filters. This is the number you would use to - * create your prototype filter. When you use this in the PFB - * filerbank, it segments these taps into the filterbanks in such a - * way that each bank now represents the filter at different phases, - * equally spaced at 2pi/N, where N is the number of filters. - * - * \li \p filter_size (default=32): The number of filters can also be - * set and defaults to 32. With 32 filters, you get a good enough - * resolution in the phase to produce very small, almost unnoticeable, - * ISI. Going to 64 filters can reduce this more, but after that - * there is very little gained for the extra complexity. - * - * \li \p init_phase (default=0): The initial phase is another - * settable parameter and refers to the filter path the algorithm - * initially looks at (i.e., d_k starts at init_phase). This value - * defaults to zero, but it might be useful to start at a different - * phase offset, such as the mid-point of the filters. - * - * \li \p max_rate_deviation (default=1.5): The next parameter is the - * max_rate_devitation, which defaults to 1.5. This is how far we - * allow d_rate to swing, positive or negative, from 0. Constraining - * the rate can help keep the algorithm from walking too far away to - * lock during times when there is no signal. - * - * \li \p osps (default=1): The osps is the number of output samples - * per symbol. By default, the algorithm produces 1 sample per symbol, - * sampled at the exact sample value. This osps value was added to - * better work with equalizers, which do a better job of modeling the - * channel if they have 2 samps/sym. - */ - -class DIGITAL_API digital_pfb_clock_sync_fff : public gr_block -{ - private: - /*! - * Build the polyphase filterbank timing synchronizer. - * \param sps (double) The number of samples per second in the incoming signal - * \param gain (float) The alpha gain of the control loop; beta = (gain^2)/4 by default. - * \param taps (vector<int>) The filter taps. - * \param filter_size (uint) The number of filters in the filterbank (default = 32). - * \param init_phase (float) The initial phase to look at, or which filter to start - * with (default = 0). - * \param max_rate_deviation (float) Distance from 0 d_rate can get (default = 1.5). - * \param osps (int) The number of output samples per symbol (default=1). - * - */ - friend DIGITAL_API digital_pfb_clock_sync_fff_sptr - digital_make_pfb_clock_sync_fff(double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - bool d_updated; - double d_sps; - double d_sample_num; - float d_loop_bw; - float d_damping; - float d_alpha; - float d_beta; - - int d_nfilters; - int d_taps_per_filter; - std::vector<gr_fir_fff*> d_filters; - std::vector<gr_fir_fff*> d_diff_filters; - std::vector< std::vector<float> > d_taps; - std::vector< std::vector<float> > d_dtaps; - - float d_k; - float d_rate; - float d_rate_i; - float d_rate_f; - float d_max_dev; - int d_filtnum; - int d_osps; - float d_error; - int d_out_idx; - - /*! - * Build the polyphase filterbank timing synchronizer. - */ - digital_pfb_clock_sync_fff(double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps); - - void create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps); - -public: - ~digital_pfb_clock_sync_fff (); - - /*! \brief update the system gains from omega and eta - * - * This function updates the system gains based on the loop - * bandwidth and damping factor of the system. - * These two factors can be set separately through their own - * set functions. - */ - void update_gains(); - - /*! - * Resets the filterbank's filter taps with the new prototype filter - */ - void set_taps(const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - /*! - * Returns all of the taps of the matched filter - */ - std::vector< std::vector<float> > get_taps(); - - /*! - * Returns all of the taps of the derivative filter - */ - std::vector< std::vector<float> > get_diff_taps(); - - /*! - * Returns the taps of the matched filter for a particular channel - */ - std::vector<float> get_channel_taps(int channel); - - /*! - * Returns the taps in the derivative filter for a particular channel - */ - std::vector<float> get_diff_channel_taps(int channel); - - /*! - * Return the taps as a formatted string for printing - */ - std::string get_taps_as_string(); - - /*! - * Return the derivative filter taps as a formatted string for printing - */ - std::string get_diff_taps_as_string(); - - - /******************************************************************* - SET FUNCTIONS - *******************************************************************/ - - - /*! - * \brief Set the loop bandwidth - * - * Set the loop filter's bandwidth to \p bw. This should be between - * 2*pi/200 and 2*pi/100 (in rads/samp). It must also be a positive - * number. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param bw (float) new bandwidth - * - */ - void set_loop_bandwidth(float bw); - - /*! - * \brief Set the loop damping factor - * - * Set the loop filter's damping factor to \p df. The damping factor - * should be sqrt(2)/2.0 for critically damped systems. - * Set it to anything else only if you know what you are doing. It must - * be a number between 0 and 1. - * - * When a new damping factor is set, the gains, alpha and beta, of the loop - * are recalculated by a call to update_gains(). - * - * \param df (float) new damping factor - * - */ - void set_damping_factor(float df); - - /*! - * \brief Set the loop gain alpha - * - * Set's the loop filter's alpha gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param alpha (float) new alpha gain - * - */ - void set_alpha(float alpha); - - /*! - * \brief Set the loop gain beta - * - * Set's the loop filter's beta gain parameter. - * - * This value should really only be set by adjusting the loop bandwidth - * and damping factor. - * - * \param beta (float) new beta gain - * - */ - void set_beta(float beta); - - /*! - * Set the maximum deviation from 0 d_rate can have - */ - void set_max_rate_deviation(float m) - { - d_max_dev = m; - } - - /******************************************************************* - GET FUNCTIONS - *******************************************************************/ - - /*! - * \brief Returns the loop bandwidth - */ - float get_loop_bandwidth() const; - - /*! - * \brief Returns the loop damping factor - */ - float get_damping_factor() const; - - /*! - * \brief Returns the loop gain alpha - */ - float get_alpha() const; - - /*! - * \brief Returns the loop gain beta - */ - float get_beta() const; - - /*! - * \brief Returns the current clock rate - */ - float get_clock_rate() const; - - /******************************************************************* - *******************************************************************/ - - bool check_topology(int ninputs, int noutputs); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gr-digital/include/digital_pn_correlator_cc.h b/gr-digital/include/digital_pn_correlator_cc.h deleted file mode 100644 index 407cc1e67b..0000000000 --- a/gr-digital/include/digital_pn_correlator_cc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 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_GR_PN_CORRELATOR_CC_H -#define INCLUDED_GR_PN_CORRELATOR_CC_H - -#include <digital_api.h> -#include <gr_sync_decimator.h> -#include <digital_impl_glfsr.h> - -class digital_pn_correlator_cc; -typedef boost::shared_ptr<digital_pn_correlator_cc> digital_pn_correlator_cc_sptr; - -DIGITAL_API digital_pn_correlator_cc_sptr -digital_make_pn_correlator_cc(int degree, int mask=0, int seed=1); -/*! - * \brief PN code sequential search correlator - * - * \ingroup sync_blk - * - * Receives complex baseband signal, outputs complex correlation - * against reference PN code, one sample per PN code period. The PN - * sequence is generated using a GLFSR. - * - * \param degree Degree of shift register must be in [1, 32]. If mask - * is 0, the degree determines a default mask (see - * digital_impl_glfsr.cc for the mapping). - * \param repeat Set to repeat sequence. - * \param mask Allows a user-defined bit mask for indexes of the shift - * register to feed back. - * \param seed Initial setting for values in shift register. - */ -class DIGITAL_API digital_pn_correlator_cc : public gr_sync_decimator -{ - friend DIGITAL_API digital_pn_correlator_cc_sptr - digital_make_pn_correlator_cc(int degree, int mask, int seed); - - int d_len; - float d_pn; - digital_impl_glfsr *d_reference; - - protected: - digital_pn_correlator_cc(int degree, int mask, int seed); - - public: - virtual int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - ~digital_pn_correlator_cc(); -}; - -#endif /* INCLUDED_GR_PN_CORRELATOR_CC_H */ diff --git a/gr-digital/include/digital_probe_density_b.h b/gr-digital/include/digital_probe_density_b.h deleted file mode 100644 index 271ad2a072..0000000000 --- a/gr-digital/include/digital_probe_density_b.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2012 Free Software Foundation, Inc. - * - * 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_GR_PROBE_DENSITY_B_H -#define INCLUDED_GR_PROBE_DENSITY_B_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -class digital_probe_density_b; - -typedef boost::shared_ptr<digital_probe_density_b> digital_probe_density_b_sptr; - -DIGITAL_API digital_probe_density_b_sptr -digital_make_probe_density_b(double alpha); - -/*! - * This block maintains a running average of the input stream and - * makes it available as an accessor function. The input stream - * is type unsigned char. - * - * If you send this block a stream of unpacked bytes, it will tell - * you what the bit density is. - * - * \param alpha Average filter constant - * - */ - -class DIGITAL_API digital_probe_density_b : public gr_sync_block -{ -private: - friend DIGITAL_API digital_probe_density_b_sptr - digital_make_probe_density_b(double alpha); - - double d_alpha; - double d_beta; - double d_density; - - digital_probe_density_b(double alpha); - -public: - ~digital_probe_density_b(); - - /*! - * \brief Returns the current density value - */ - double density() const { return d_density; } - - /*! - * \brief Set the average filter constant - */ - void set_alpha(double alpha); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gr-digital/include/digital_probe_mpsk_snr_est_c.h b/gr-digital/include/digital_probe_mpsk_snr_est_c.h deleted file mode 100644 index a78e904124..0000000000 --- a/gr-digital/include/digital_probe_mpsk_snr_est_c.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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_PROBE_MPSK_SNR_EST_C_H -#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <digital_impl_mpsk_snr_est.h> - -class digital_probe_mpsk_snr_est_c; -typedef boost::shared_ptr<digital_probe_mpsk_snr_est_c> digital_probe_mpsk_snr_est_c_sptr; - -DIGITAL_API digital_probe_mpsk_snr_est_c_sptr -digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples=10000, - double alpha=0.001); - -//! \brief A probe for computing SNR of a signal. -/*! \ingroup snr_blk - * - * This is a probe block (a sink) that can be used to monitor and - * retrieve estimations of the signal SNR. This probe is designed for - * use with M-PSK signals especially. The type of estimator is - * specified as the \p type parameter in the constructor. The - * estimators tend to trade off performance for accuracy, although - * experimentation should be done to figure out the right approach - * for a given implementation. Further, the current set of estimators - * are designed and proven theoretically under AWGN conditions; some - * amount of error should be assumed and/or estimated for real - * channel conditions. - */ -class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block -{ - private: - snr_est_type_t d_type; - int d_nsamples, d_count; - double d_alpha; - digital_impl_mpsk_snr_est *d_snr_est; - - //d_key is the message name, 'snr' - pmt::pmt_t d_key; - - /*! Factory function returning shared pointer of this class - * - * Parameters: - * - * \param type: the type of estimator to use \ref ref_snr_est_types - * "snr_est_type_t" for details about the available types. - * \param msg_nsamples: [not implemented yet] after this many - * samples, a message containing the SNR (key='snr') will be sent - * \param alpha: the update rate of internal running average - * calculations. - */ - friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr - digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha); - - //! Private constructor - digital_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha); - -public: - - ~digital_probe_mpsk_snr_est_c(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - //! Return the estimated signal-to-noise ratio in decibels - double snr(); - - //! Return the type of estimator in use - snr_est_type_t type() const; - - //! Return how many samples between SNR messages - int msg_nsample() const; - - //! Get the running-average coefficient - double alpha() const; - - //! Set type of estimator to use - void set_type(snr_est_type_t t); - - //! Set the number of samples between SNR messages - void set_msg_nsample(int n); - - //! Set the running-average coefficient - void set_alpha(double alpha); -}; - -#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */ diff --git a/gr-digital/include/digital_scrambler_bb.h b/gr-digital/include/digital_scrambler_bb.h deleted file mode 100644 index d6f08dcc83..0000000000 --- a/gr-digital/include/digital_scrambler_bb.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2012 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_GR_SCRAMBLER_BB_H -#define INCLUDED_GR_SCRAMBLER_BB_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include "gri_lfsr.h" - -class digital_scrambler_bb; -typedef boost::shared_ptr<digital_scrambler_bb> digital_scrambler_bb_sptr; - -DIGITAL_API digital_scrambler_bb_sptr -digital_make_scrambler_bb(int mask, int seed, int len); - -/*! - * Scramble an input stream using an LFSR. This block works on the LSB only - * of the input data stream, i.e., on an "unpacked binary" stream, and - * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk - */ - -class DIGITAL_API digital_scrambler_bb : public gr_sync_block -{ - friend DIGITAL_API digital_scrambler_bb_sptr - digital_make_scrambler_bb(int mask, int seed, int len); - - gri_lfsr d_lfsr; - - digital_scrambler_bb(int mask, int seed, int len); - -public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SCRAMBLER_BB_H */ diff --git a/gr-digital/include/digital_simple_framer.h b/gr-digital/include/digital_simple_framer.h deleted file mode 100644 index b622ae5dd4..0000000000 --- a/gr-digital/include/digital_simple_framer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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_GR_SIMPLE_FRAMER_H -#define INCLUDED_GR_SIMPLE_FRAMER_H - -#include <digital_api.h> -#include <gr_block.h> - -class digital_simple_framer; -typedef boost::shared_ptr<digital_simple_framer> digital_simple_framer_sptr; - -DIGITAL_API digital_simple_framer_sptr digital_make_simple_framer(int payload_bytesize); - -/*! - * \brief add sync field, seq number and command field to payload - * \ingroup sync_blk - * - * Takes in enough samples to create a full output frame. The frame is - * prepended with the GRSF_SYNC (defind in - * digital_simple_framer_sync.h) and an 8-bit sequence number. - * - * \param payload_bytesize The size of the payload in bytes. - */ -class DIGITAL_API digital_simple_framer : public gr_block -{ - int d_seqno; - int d_payload_bytesize; - int d_input_block_size; // bytes - int d_output_block_size; // bytes - - friend DIGITAL_API digital_simple_framer_sptr - digital_make_simple_framer(int payload_bytesize); - digital_simple_framer(int payload_bytesize); - - public: - void forecast(int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gr-digital/include/digital_simple_framer_sync.h b/gr-digital/include/digital_simple_framer_sync.h deleted file mode 100644 index 4120035827..0000000000 --- a/gr-digital/include/digital_simple_framer_sync.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2012 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_GR_SIMPLE_FRAMER_SYNC_H -#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H - -/*! - * \brief Here are a couple of maximum length sequences (m-sequences) - * that were generated by the the "mseq" matlab/octave code downloaded - * from: <a href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> - * - * <pre> - * 31-bit m-sequence: - * 0110100100001010111011000111110 - * 0x690AEC76 (padded on right with a zero) - * - * 63-bit m-sequence: - * 101011001101110110100100111000101111001010001100001000001111110 - * 0xACDDA4E2F28C20FC (padded on right with a zero) - * </pre> - */ - -static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; - -static const int GRSF_BITS_PER_BYTE = 8; -static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); -static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno -static const int GRSF_TAIL_PAD = 1; // one byte trailing padding -static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index bd4f1a5004..c95f78000d 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -21,15 +21,17 @@ # Setup the include and linker paths ######################################################################## include_directories( + ${VOLK_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GR_DIGITAL_INCLUDE_DIRS} + ${GR_FFT_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/../include ) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) - ######################################################################## # generate helper scripts to expand templated files ######################################################################## @@ -48,9 +50,8 @@ if __name__ == '__main__': root, inp = sys.argv[1:3] for sig in sys.argv[3:]: name = re.sub ('X+', sig, root) - d = build_utils.standard_dict(name, sig, 'digital') + d = build_utils.standard_impl_dict2(name, sig, 'digital') build_utils.expand_template(d, inp) - ") macro(expand_cc root) @@ -60,10 +61,10 @@ macro(expand_cc root) foreach(sig ${ARGN}) string(REGEX REPLACE "X+" ${sig} name ${root}) list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc) - list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/../include/${name}.h) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) endforeach(sig) - #create a command to generate the files + #create a command to generate the source files add_custom_command( OUTPUT ${expanded_files_cc} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t @@ -71,6 +72,15 @@ macro(expand_cc root) ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py ${root} ${root}.cc.t ${ARGN} ) + + #create a command to generate the header file + add_custom_command( + OUTPUT ${expanded_files_h} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.h.t ${ARGN} + ) #make source files depends on headers to force generation set_source_files_properties(${expanded_files_cc} @@ -79,71 +89,72 @@ macro(expand_cc root) #install rules for the generated cc files list(APPEND generated_sources ${expanded_files_cc}) + list(APPEND generated_headers ${expanded_files_h}) endmacro(expand_cc) + ######################################################################## # Invoke macro to generate various sources ######################################################################## -expand_cc(digital_chunks_to_symbols_XX bf bc sf sc if ic) +expand_cc(chunks_to_symbols_XX_impl bf bc sf sc if ic) ######################################################################## # Setup library ######################################################################## -list(APPEND gr_digital_sources +list(APPEND digital_sources ${generated_sources} - digital_impl_glfsr.cc - digital_impl_mpsk_snr_est.cc - digital_additive_scrambler_bb.cc - digital_binary_slicer_fb.cc - digital_bytes_to_syms.cc - digital_clock_recovery_mm_cc.cc - digital_clock_recovery_mm_ff.cc - digital_cma_equalizer_cc.cc - digital_constellation.cc - digital_constellation_receiver_cb.cc - digital_constellation_decoder_cb.cc - digital_correlate_access_code_bb.cc - digital_correlate_access_code_tag_bb.cc - digital_costas_loop_cc.cc - digital_cpmmod_bc.cc - digital_crc32.cc - digital_descrambler_bb.cc - digital_diff_decoder_bb.cc - digital_diff_encoder_bb.cc - digital_diff_phasor_cc.cc - digital_fll_band_edge_cc.cc - digital_framer_sink_1.cc - digital_glfsr_source_b.cc - digital_glfsr_source_f.cc - digital_gmskmod_bc.cc - digital_lms_dd_equalizer_cc.cc - digital_kurtotic_equalizer_cc.cc - digital_map_bb.cc - digital_mpsk_receiver_cc.cc - digital_mpsk_snr_est_cc.cc - digital_ofdm_cyclic_prefixer.cc - digital_ofdm_frame_acquisition.cc - digital_ofdm_frame_sink.cc - digital_ofdm_insert_preamble.cc - digital_ofdm_mapper_bcv.cc - digital_ofdm_sampler.cc - digital_packet_sink.cc - digital_pfb_clock_sync_ccf.cc - digital_pfb_clock_sync_fff.cc - digital_pn_correlator_cc.cc - digital_probe_density_b.cc - digital_probe_mpsk_snr_est_c.cc - digital_scrambler_bb.cc - digital_simple_framer.cc + constellation.cc + crc32.cc + glfsr.cc + mpsk_snr_est.cc + additive_scrambler_bb_impl.cc + binary_slicer_fb_impl.cc + clock_recovery_mm_cc_impl.cc + clock_recovery_mm_ff_impl.cc + cma_equalizer_cc_impl.cc + constellation_receiver_cb_impl.cc + constellation_decoder_cb_impl.cc + correlate_access_code_bb_impl.cc + correlate_access_code_tag_bb_impl.cc + costas_loop_cc_impl.cc + cpmmod_bc_impl.cc + descrambler_bb_impl.cc + diff_decoder_bb_impl.cc + diff_encoder_bb_impl.cc + diff_phasor_cc_impl.cc + fll_band_edge_cc_impl.cc + framer_sink_1_impl.cc + glfsr_source_b_impl.cc + glfsr_source_f_impl.cc + kurtotic_equalizer_cc_impl.cc + lms_dd_equalizer_cc_impl.cc + map_bb_impl.cc + mpsk_receiver_cc_impl.cc + mpsk_snr_est_cc_impl.cc + ofdm_cyclic_prefixer_impl.cc + ofdm_frame_acquisition_impl.cc + ofdm_frame_sink_impl.cc + ofdm_insert_preamble_impl.cc + ofdm_mapper_bcv_impl.cc + ofdm_sampler_impl.cc + packet_sink_impl.cc + pfb_clock_sync_ccf_impl.cc + pfb_clock_sync_fff_impl.cc + pn_correlator_cc_impl.cc + probe_density_b_impl.cc + probe_mpsk_snr_est_c_impl.cc + scrambler_bb_impl.cc + simple_framer_impl.cc ) list(APPEND digital_libs + volk gnuradio-core + gnuradio-filter ${Boost_LIBRARIES} ) -add_library(gnuradio-digital SHARED ${gr_digital_sources}) +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") - -add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs) +add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs gnuradio-filter) diff --git a/gr-digital/lib/additive_scrambler_bb_impl.cc b/gr-digital/lib/additive_scrambler_bb_impl.cc new file mode 100644 index 0000000000..8238f2d988 --- /dev/null +++ b/gr-digital/lib/additive_scrambler_bb_impl.cc @@ -0,0 +1,104 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 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 "additive_scrambler_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + additive_scrambler_bb::sptr + additive_scrambler_bb::make(int mask, int seed, int len, int count) + { + return gnuradio::get_initial_sptr(new additive_scrambler_bb_impl + (mask, seed, len, count)); + } + + additive_scrambler_bb_impl::additive_scrambler_bb_impl(int mask, + int seed, + int len, + int count) + : gr_sync_block("additive_scrambler_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_lfsr(mask, seed, len), + d_count(count), + d_bits(0), d_len(len), d_seed(seed) + { + } + + additive_scrambler_bb_impl::~additive_scrambler_bb_impl() + { + } + + int + additive_scrambler_bb_impl::mask() const + { + return d_lfsr.mask(); + } + + int + additive_scrambler_bb_impl::seed() const + { + return d_seed; + } + + int + additive_scrambler_bb_impl::len() const + { + return d_len; + } + + int + additive_scrambler_bb_impl::count() const + { + return d_count; + } + + int + additive_scrambler_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = in[i]^d_lfsr.next_bit(); + if(d_count > 0) { + if(++d_bits == d_count) { + d_lfsr.reset(); + d_bits = 0; + } + } + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/additive_scrambler_bb_impl.h b/gr-digital/lib/additive_scrambler_bb_impl.h new file mode 100644 index 0000000000..e2dfbc342b --- /dev/null +++ b/gr-digital/lib/additive_scrambler_bb_impl.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 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_ADDITIVE_SCRAMBLER_BB_IMPL_H +#define INCLUDED_DIGITAL_ADDITIVE_SCRAMBLER_BB_IMPL_H + +#include <digital/additive_scrambler_bb.h> +#include <gri_lfsr.h> + +namespace gr { + namespace digital { + + class additive_scrambler_bb_impl + : public additive_scrambler_bb + { + private: + gri_lfsr d_lfsr; + int d_count; + int d_bits; + int d_len; + int d_seed; + + public: + additive_scrambler_bb_impl(int mask, int seed, + int len, int count=0); + ~additive_scrambler_bb_impl(); + + int mask() const; + int seed() const; + int len() const; + int count() const; + + 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_ADDITIVE_SCRAMBLER_BB_IMPL_H */ diff --git a/gr-digital/lib/digital_binary_slicer_fb.cc b/gr-digital/lib/binary_slicer_fb_impl.cc index fcdb4291fb..f8a9cf22de 100644 --- a/gr-digital/lib/digital_binary_slicer_fb.cc +++ b/gr-digital/lib/binary_slicer_fb_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2010,2011 Free Software Foundation, Inc. + * Copyright 2006,2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,36 +24,43 @@ #include "config.h" #endif -#include <digital_binary_slicer_fb.h> +#include "binary_slicer_fb_impl.h" #include <gr_io_signature.h> #include <gr_math.h> -#include <stdexcept> - -digital_binary_slicer_fb_sptr -digital_make_binary_slicer_fb () -{ - return gnuradio::get_initial_sptr(new digital_binary_slicer_fb ()); -} - -digital_binary_slicer_fb::digital_binary_slicer_fb () - : gr_sync_block ("binary_slicer_fb", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ -} - -int -digital_binary_slicer_fb::work (int noutput_items, + +namespace gr { + namespace digital { + + binary_slicer_fb::sptr binary_slicer_fb::make() + { + return gnuradio::get_initial_sptr(new binary_slicer_fb_impl()); + } + + binary_slicer_fb_impl::binary_slicer_fb_impl() + : gr_sync_block("binary_slicer_fb", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + } + + binary_slicer_fb_impl::~binary_slicer_fb_impl() + { + } + + int + binary_slicer_fb_impl::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - + { + const float *in = (const float *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; - for (int i = 0; i < noutput_items; i++){ - out[i] = gr_binary_slicer(in[i]); - } + for(int i = 0; i < noutput_items; i++) { + out[i] = gr_binary_slicer(in[i]); + } - return noutput_items; -} + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_kurtotic_equalizer_cc.i b/gr-digital/lib/binary_slicer_fb_impl.h index 67a9dc6fdc..7416d9cd52 100644 --- a/gr-digital/swig/digital_kurtotic_equalizer_cc.i +++ b/gr-digital/lib/binary_slicer_fb_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2006,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,21 +20,26 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,kurtotic_equalizer_cc) +#ifndef INCLUDED_DIGITAL_BINARY_SLICER_FB_IMPL_H +#define INCLUDED_DIGITAL_BINARY_SLICER_FB_IMPL_H -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_adaptive_fir_ccc.i" +#include <digital/binary_slicer_fb.h> -digital_kurtotic_equalizer_cc_sptr -digital_make_kurtotic_equalizer_cc(int num_taps, - float mu); +namespace gr { + namespace digital { -class digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc -{ -private: - digital_kurtotic_equalizer_cc(int num_taps, float mu); + class binary_slicer_fb_impl : public binary_slicer_fb + { + public: + binary_slicer_fb_impl(); + ~binary_slicer_fb_impl(); -public: - void set_gain(float mu); -}; + 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_BINARY_SLICER_FB_IMPL_H */ diff --git a/gr-digital/lib/chunks_to_symbols_XX_impl.cc.t b/gr-digital/lib/chunks_to_symbols_XX_impl.cc.t new file mode 100644 index 0000000000..39eca32db6 --- /dev/null +++ b/gr-digital/lib/chunks_to_symbols_XX_impl.cc.t @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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. + */ + +/* @WARNING@ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "@NAME@.h" +#include <gr_io_signature.h> +#include <assert.h> + +namespace gr { + namespace digital { + + @BASE_NAME@::sptr + @BASE_NAME@::make(const std::vector<@O_TYPE@> &symbol_table, const int D) + { + return gnuradio::get_initial_sptr + (new @IMPL_NAME@(symbol_table, D)); + } + + @IMPL_NAME@::@IMPL_NAME@(const std::vector<@O_TYPE@> &symbol_table, const int D) + : gr_sync_interpolator("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, -1, sizeof(@O_TYPE@)), + D), + d_D(D), d_symbol_table(symbol_table) + { + } + + @IMPL_NAME@::~@IMPL_NAME@() + { + } + + int + @IMPL_NAME@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + assert(noutput_items % d_D == 0); + assert(input_items.size() == output_items.size()); + int nstreams = input_items.size(); + + for(int m = 0; m < nstreams; m++) { + const @I_TYPE@ *in = (@I_TYPE@*)input_items[m]; + @O_TYPE@ *out = (@O_TYPE@*)output_items[m]; + + // per stream processing + for(int i = 0; i < noutput_items / d_D; i++) { + assert(((unsigned int)in[i]*d_D+d_D) <= d_symbol_table.size()); + memcpy(out, &d_symbol_table[(unsigned int)in[i]*d_D], d_D*sizeof(@O_TYPE@)); + out+=d_D; + } + } + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_chunks_to_symbols_XX.i.t b/gr-digital/lib/chunks_to_symbols_XX_impl.h.t index a80ba2af11..ea44c71ad4 100644 --- a/gr-digital/swig/digital_chunks_to_symbols_XX.i.t +++ b/gr-digital/lib/chunks_to_symbols_XX_impl.h.t @@ -20,19 +20,38 @@ * Boston, MA 02110-1301, USA. */ -// @WARNING@ +/* @WARNING@ */ -GR_SWIG_BLOCK_MAGIC(digital,@BASE_NAME@); +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ -@SPTR_NAME@ digital_make_@BASE_NAME@ -(const std::vector<@O_TYPE@> &symbol_table, const int D = 1); +#include <digital/@BASE_NAME@.h> -class @NAME@ : public gr_sync_interpolator -{ -private: - @NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D = 1); +namespace gr { + namespace digital { -public: - int D () const { return d_D; } - std::vector<@O_TYPE@> symbol_table () const { return d_symbol_table; } -}; + class @IMPL_NAME@ : public @BASE_NAME@ + { + private: + int d_D; + std::vector<@O_TYPE@> d_symbol_table; + + public: + @IMPL_NAME@(const std::vector<@O_TYPE@> &symbol_table, const int D = 1); + + ~@IMPL_NAME@(); + + int D() const { return d_D; } + std::vector<@O_TYPE@> symbol_table() const { return d_symbol_table; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; } + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-digital/lib/clock_recovery_mm_cc_impl.cc b/gr-digital/lib/clock_recovery_mm_cc_impl.cc new file mode 100644 index 0000000000..168d9f7772 --- /dev/null +++ b/gr-digital/lib/clock_recovery_mm_cc_impl.cc @@ -0,0 +1,214 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2010-2012 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 "clock_recovery_mm_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_prefs.h> +#include <gr_math.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace digital { + + static const int FUDGE = 16; + + clock_recovery_mm_cc::sptr + clock_recovery_mm_cc::make(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit) + { + return gnuradio::get_initial_sptr + (new clock_recovery_mm_cc_impl(omega, gain_omega, + mu, gain_mu, + omega_relative_limit)); + } + + clock_recovery_mm_cc_impl::clock_recovery_mm_cc_impl(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit) + : gr_block("clock_recovery_mm_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature2(1, 2, sizeof(gr_complex), sizeof(float))), + d_mu(mu), d_omega(omega), d_gain_omega(gain_omega), + d_omega_relative_limit(omega_relative_limit), + d_gain_mu(gain_mu), d_last_sample(0), d_interp(new filter::mmse_fir_interpolator_cc()), + d_verbose(gr_prefs::singleton()->get_bool("clock_recovery_mm_cc", "verbose", false)), + d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) + { + if(omega <= 0.0) + throw std::out_of_range("clock rate must be > 0"); + if(gain_mu < 0 || gain_omega < 0) + throw std::out_of_range("Gains must be non-negative"); + + set_omega(omega); // also sets min and max omega + set_relative_rate(1.0 / omega); + set_history(3); // ensure 2 extra input samples are available + } + + clock_recovery_mm_cc_impl::~clock_recovery_mm_cc_impl() + { + delete d_interp; + } + + void + clock_recovery_mm_cc_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i=0; i < ninputs; i++) + ninput_items_required[i] = + (int)ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE; + } + + gr_complex + clock_recovery_mm_cc_impl::slicer_0deg(gr_complex sample) + { + float real=0, imag=0; + + if(sample.real() > 0) + real = 1; + if(sample.imag() > 0) + imag = 1; + return gr_complex(real,imag); + } + + gr_complex + clock_recovery_mm_cc_impl::slicer_45deg(gr_complex sample) + { + float real= -1, imag = -1; + if(sample.real() > 0) + real=1; + if(sample.imag() > 0) + imag = 1; + return gr_complex(real,imag); + } + + int + clock_recovery_mm_cc_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + float *foptr = (float *)output_items[1]; + + bool write_foptr = output_items.size() >= 2; + + int ii = 0; // input index + int oo = 0; // output index + int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more input than this + + assert(d_mu >= 0.0); + assert(d_mu <= 1.0); + + float mm_val = 0; + gr_complex u, x, y; + + // This loop writes the error to the second output, if it exists + if(write_foptr) { + while(oo < noutput_items && ii < ni) { + d_p_2T = d_p_1T; + d_p_1T = d_p_0T; + d_p_0T = d_interp->interpolate(&in[ii], d_mu); + + d_c_2T = d_c_1T; + d_c_1T = d_c_0T; + d_c_0T = slicer_0deg(d_p_0T); + + x = (d_c_0T - d_c_2T) * conj(d_p_1T); + y = (d_p_0T - d_p_2T) * conj(d_c_1T); + u = y - x; + mm_val = u.real(); + out[oo++] = d_p_0T; + + // limit mm_val + mm_val = gr_branchless_clip(mm_val,4.0); + d_omega = d_omega + d_gain_omega * mm_val; + d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); + + d_mu = d_mu + d_omega + d_gain_mu * mm_val; + ii += (int)floor(d_mu); + d_mu -= floor(d_mu); + + // write the error signal to the second output + foptr[oo-1] = mm_val; + + if(ii < 0) // clamp it. This should only happen with bogus input + ii = 0; + } + } + // This loop does not write to the second output (ugly, but faster) + else { + while(oo < noutput_items && ii < ni) { + d_p_2T = d_p_1T; + d_p_1T = d_p_0T; + d_p_0T = d_interp->interpolate(&in[ii], d_mu); + + d_c_2T = d_c_1T; + d_c_1T = d_c_0T; + d_c_0T = slicer_0deg(d_p_0T); + + x = (d_c_0T - d_c_2T) * conj(d_p_1T); + y = (d_p_0T - d_p_2T) * conj(d_c_1T); + u = y - x; + mm_val = u.real(); + out[oo++] = d_p_0T; + + // limit mm_val + mm_val = gr_branchless_clip(mm_val,1.0); + + d_omega = d_omega + d_gain_omega * mm_val; + d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); + + d_mu = d_mu + d_omega + d_gain_mu * mm_val; + ii += (int)floor(d_mu); + d_mu -= floor(d_mu); + + if(d_verbose) { + std::cout << d_omega << "\t" << d_mu << std::endl; + } + + if(ii < 0) // clamp it. This should only happen with bogus input + ii = 0; + } + } + + if(ii > 0) { + if(ii > ninput_items[0]) { + std::cerr << "clock_recovery_mm_cc: ii > ninput_items[0] (" + << ii << " > " << ninput_items[0] << std::endl; + assert(0); + } + consume_each(ii); + } + + return oo; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/clock_recovery_mm_cc_impl.h b/gr-digital/lib/clock_recovery_mm_cc_impl.h new file mode 100644 index 0000000000..fa62bd127f --- /dev/null +++ b/gr-digital/lib/clock_recovery_mm_cc_impl.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2011,2012 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_CLOCK_RECOVERY_MM_CC_IMPL_H +#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_IMPL_H + +#include <digital/clock_recovery_mm_cc.h> +#include <filter/mmse_fir_interpolator_cc.h> + +namespace gr { + namespace digital { + + class clock_recovery_mm_cc_impl : public clock_recovery_mm_cc + { + public: + clock_recovery_mm_cc_impl(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limi); + ~clock_recovery_mm_cc_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + float mu() const { return d_mu;} + float omega() const { return d_omega;} + float gain_mu() const { return d_gain_mu;} + float gain_omega() const { return d_gain_omega;} + + void set_verbose (bool verbose) { d_verbose = verbose; } + void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } + void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } + void set_mu (float mu) { d_mu = mu; } + void set_omega (float omega) { + d_omega = omega; + d_min_omega = omega*(1.0 - d_omega_relative_limit); + d_max_omega = omega*(1.0 + d_omega_relative_limit); + d_omega_mid = 0.5*(d_min_omega+d_max_omega); + } + + private: + float d_mu; // fractional sample position [0.0, 1.0] + float d_omega; // nominal frequency + float d_gain_omega; // gain for adjusting omega + float d_min_omega; // minimum allowed omega + float d_max_omega; // maximum allowed omeg + float d_omega_relative_limit; // used to compute min and max omega + float d_omega_mid; // average omega + float d_gain_mu; // gain for adjusting mu + + gr_complex d_last_sample; + filter::mmse_fir_interpolator_cc *d_interp; + + bool d_verbose; + + gr_complex d_p_2T, d_p_1T, d_p_0T; + gr_complex d_c_2T, d_c_1T, d_c_0T; + + gr_complex slicer_0deg(gr_complex sample); + gr_complex slicer_45deg(gr_complex sample); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_CC_IMPL_H */ diff --git a/gr-digital/lib/clock_recovery_mm_ff_impl.cc b/gr-digital/lib/clock_recovery_mm_ff_impl.cc new file mode 100644 index 0000000000..4ac3e40c5d --- /dev/null +++ b/gr-digital/lib/clock_recovery_mm_ff_impl.cc @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010-2012 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 "clock_recovery_mm_ff_impl.h" +#include <gr_io_signature.h> +#include <gr_math.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + clock_recovery_mm_ff::sptr + clock_recovery_mm_ff::make(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit) + { + return gnuradio::get_initial_sptr + (new clock_recovery_mm_ff_impl(omega, gain_omega, + mu, gain_mu, + omega_relative_limit)); + } + + clock_recovery_mm_ff_impl::clock_recovery_mm_ff_impl(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limit) + : gr_block("clock_recovery_mm_ff", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(float))), + d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega), + d_omega_relative_limit(omega_relative_limit), + d_last_sample(0), d_interp(new filter::mmse_fir_interpolator_ff()) + { + if(omega < 1) + throw std::out_of_range("clock rate must be > 0"); + if(gain_mu < 0 || gain_omega < 0) + throw std::out_of_range("Gains must be non-negative"); + + set_omega(omega); // also sets min and max omega + set_relative_rate (1.0 / omega); + } + + clock_recovery_mm_ff_impl::~clock_recovery_mm_ff_impl() + { + delete d_interp; + } + + void + clock_recovery_mm_ff_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i=0; i < ninputs; i++) + ninput_items_required[i] = + (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); + } + + static inline float + slice(float x) + { + return x < 0 ? -1.0F : 1.0F; + } + + int + clock_recovery_mm_ff_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *)input_items[0]; + float *out = (float *)output_items[0]; + + int ii = 0; // input index + int oo = 0; // output index + int ni = ninput_items[0] - d_interp->ntaps(); // don't use more input than this + float mm_val; + + while(oo < noutput_items && ii < ni ) { + // produce output sample + out[oo] = d_interp->interpolate(&in[ii], d_mu); + mm_val = slice(d_last_sample) * out[oo] - slice(out[oo]) * d_last_sample; + d_last_sample = out[oo]; + + d_omega = d_omega + d_gain_omega * mm_val; + d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); + d_mu = d_mu + d_omega + d_gain_mu * mm_val; + + ii += (int)floor(d_mu); + d_mu = d_mu - floor(d_mu); + oo++; + } + + consume_each(ii); + return oo; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/clock_recovery_mm_ff_impl.h b/gr-digital/lib/clock_recovery_mm_ff_impl.h new file mode 100644 index 0000000000..920a05a496 --- /dev/null +++ b/gr-digital/lib/clock_recovery_mm_ff_impl.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2011,2012 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_CLOCK_RECOVERY_MM_FF_IMPL_H +#define INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_IMPL_H + +#include <digital/clock_recovery_mm_ff.h> +#include <filter/mmse_fir_interpolator_ff.h> + +namespace gr { + namespace digital { + + class clock_recovery_mm_ff_impl : public clock_recovery_mm_ff + { + public: + clock_recovery_mm_ff_impl(float omega, float gain_omega, + float mu, float gain_mu, + float omega_relative_limi); + ~clock_recovery_mm_ff_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + float mu() const { return d_mu;} + float omega() const { return d_omega;} + float gain_mu() const { return d_gain_mu;} + float gain_omega() const { return d_gain_omega;} + + void set_verbose (bool verbose) { d_verbose = verbose; } + void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } + void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } + void set_mu (float mu) { d_mu = mu; } + void set_omega (float omega){ + d_omega = omega; + d_min_omega = omega*(1.0 - d_omega_relative_limit); + d_max_omega = omega*(1.0 + d_omega_relative_limit); + d_omega_mid = 0.5*(d_min_omega+d_max_omega); + } + + private: + float d_mu; // fractional sample position [0.0, 1.0] + float d_gain_mu; // gain for adjusting mu + float d_omega; // nominal frequency + float d_gain_omega; // gain for adjusting omega + float d_min_omega; // minimum allowed omega + float d_max_omega; // maximum allowed omeg + float d_omega_relative_limit; // used to compute min and max omega + float d_omega_mid; // average omega + + float d_last_sample; + filter::mmse_fir_interpolator_ff *d_interp; + + bool d_verbose; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CLOCK_RECOVERY_MM_FF_IMPL_H */ diff --git a/gr-digital/lib/cma_equalizer_cc_impl.cc b/gr-digital/lib/cma_equalizer_cc_impl.cc new file mode 100644 index 0000000000..fca7c0c6e5 --- /dev/null +++ b/gr-digital/lib/cma_equalizer_cc_impl.cc @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "cma_equalizer_cc_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + cma_equalizer_cc::sptr + cma_equalizer_cc::make(int num_taps, float modulus, float mu, int sps) + { + return gnuradio::get_initial_sptr + (new cma_equalizer_cc_impl(num_taps, modulus, mu, sps)); + } + + cma_equalizer_cc_impl::cma_equalizer_cc_impl(int num_taps, float modulus, + float mu, int sps) + : gr_sync_decimator("cma_equalizer_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + sps), + filter::kernel::fir_filter_ccc(sps, std::vector<gr_complex>(num_taps, gr_complex(0,0))), + d_updated(false), d_error(gr_complex(0,0)) + { + set_modulus(modulus); + set_gain(mu); + if(num_taps > 0) + d_taps[0] = 1.0; + set_taps(d_taps); + + set_history(num_taps+1); + } + + cma_equalizer_cc_impl::~cma_equalizer_cc_impl() + { + } + + int + cma_equalizer_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + int j = 0, k, l = d_taps.size(); + for(int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + // Adjust taps + d_error = error(out[i]); + for (k = 0; k < l; k++) { + update_tap(d_taps[l-k-1], in[j+k]); + } + + j += decimation(); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/cma_equalizer_cc_impl.h b/gr-digital/lib/cma_equalizer_cc_impl.h new file mode 100644 index 0000000000..9e95d46f02 --- /dev/null +++ b/gr-digital/lib/cma_equalizer_cc_impl.h @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CMA_EQUALIZER_CC_IMPL_H +#define INCLUDED_DIGITAL_CMA_EQUALIZER_CC_IMPL_H + +#include <digital/cma_equalizer_cc.h> +#include <filter/fir_filter.h> +#include <gr_math.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + class cma_equalizer_cc_impl + : public cma_equalizer_cc, filter::kernel::fir_filter_ccc + { + private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + gr_complex d_error; + + float d_modulus; + float d_mu; + + protected: + gr_complex error(const gr_complex &out) + { + gr_complex error = out*(norm(out) - d_modulus); + float re = gr_clip(error.real(), 1.0); + float im = gr_clip(error.imag(), 1.0); + return gr_complex(re, im); + } + + void update_tap(gr_complex &tap, const gr_complex &in) + { + // Hn+1 = Hn - mu*conj(Xn)*zn*(|zn|^2 - 1) + tap -= d_mu*conj(in)*d_error; + } + + public: + cma_equalizer_cc_impl(int num_taps, float modulus, float mu, int sps); + ~cma_equalizer_cc_impl(); + + float gain() const + { + return d_mu; + } + + void set_gain(float mu) + { + if(mu < 0.0f || mu > 1.0f) { + throw std::out_of_range("cma_equalizer::set_gain: Gain value must be in [0,1]"); + } + d_mu = mu; + } + + float modulus() const + { + return d_modulus; + } + + void set_modulus(float mod) + { + if(mod < 0) + throw std::out_of_range("cma_equalizer::set_modulus: Modulus value must be >= 0"); + d_modulus = mod; + } + + 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_CMA_EQUALIZER_CC_IMPL_H */ diff --git a/gr-digital/lib/constellation.cc b/gr-digital/lib/constellation.cc new file mode 100644 index 0000000000..e73b2c8a43 --- /dev/null +++ b/gr-digital/lib/constellation.cc @@ -0,0 +1,617 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010-2012 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 <gr_io_signature.h> +#include <digital/constellation.h> +#include <gr_math.h> +#include <gr_complex.h> +#include <math.h> +#include <iostream> +#include <stdlib.h> +#include <float.h> +#include <stdexcept> + +namespace gr { + namespace digital { + +#define M_TWOPI (2*M_PI) +#define SQRT_TWO 0.707107 + + // Base Constellation Class + constellation::constellation(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality) : + d_constellation(constell), + d_pre_diff_code(pre_diff_code), + d_rotational_symmetry(rotational_symmetry), + d_dimensionality(dimensionality) + { + if(pre_diff_code.size() == 0) + d_apply_pre_diff_code = false; + else if(pre_diff_code.size() != constell.size()) + throw std::runtime_error("The constellation and pre-diff code must be of the same length."); + else + d_apply_pre_diff_code = true; + calc_arity(); + } + + constellation::constellation() : + d_apply_pre_diff_code(false), + d_rotational_symmetry(0), + d_dimensionality(1) + { + calc_arity(); + } + + constellation::~constellation() + { + } + + //! Returns the constellation points for a symbol value + void + constellation::map_to_points(unsigned int value, gr_complex *points) + { + for(unsigned int i=0; i<d_dimensionality; i++) + points[i] = d_constellation[value*d_dimensionality + i]; + } + + std::vector<gr_complex> + constellation::map_to_points_v(unsigned int value) + { + std::vector<gr_complex> points_v; + points_v.resize(d_dimensionality); + map_to_points(value, &(points_v[0])); + return points_v; + } + + float + constellation::get_distance(unsigned int index, const gr_complex *sample) + { + float dist = 0; + for(unsigned int i=0; i<d_dimensionality; i++) { + dist += norm(sample[i] - d_constellation[index*d_dimensionality + i]); + } + return dist; + } + + unsigned int + constellation::get_closest_point(const gr_complex *sample) + { + unsigned int min_index = 0; + float min_euclid_dist; + float euclid_dist; + + min_euclid_dist = get_distance(0, sample); + min_index = 0; + for(unsigned int j = 1; j < d_arity; j++){ + euclid_dist = get_distance(j, sample); + if(euclid_dist < min_euclid_dist){ + min_euclid_dist = euclid_dist; + min_index = j; + } + } + return min_index; + } + + unsigned int + constellation::decision_maker_pe(const gr_complex *sample, float *phase_error) + { + unsigned int index = decision_maker(sample); + *phase_error = 0; + for(unsigned int d=0; d<d_dimensionality; d++) + *phase_error += -arg(sample[d]*conj(d_constellation[index+d])); + return index; + } + + /* + unsigned int constellation::decision_maker_e(const gr_complex *sample, float *error) + { + unsigned int index = decision_maker(sample); + *error = 0; + for(unsigned int d=0; d<d_dimensionality; d++) + *error += sample[d]*conj(d_constellation[index+d]); + return index; + } + */ + + std::vector<gr_complex> constellation::s_points() + { + if(d_dimensionality != 1) + throw std::runtime_error("s_points only works for dimensionality 1 constellations."); + else + return d_constellation; + } + + std::vector<std::vector<gr_complex> > + constellation::v_points() + { + std::vector<std::vector<gr_complex> > vv_const; + vv_const.resize(d_arity); + for(unsigned int p=0; p<d_arity; p++) { + std::vector<gr_complex> v_const; + v_const.resize(d_dimensionality); + for(unsigned int d=0; d<d_dimensionality; d++) { + v_const[d] = d_constellation[p*d_dimensionality+d]; + } + vv_const[p] = v_const; + } + return vv_const; + } + + void + constellation::calc_metric(const gr_complex *sample, float *metric, + trellis_metric_type_t type) + { + switch(type){ + case TRELLIS_EUCLIDEAN: + calc_euclidean_metric(sample, metric); + break; + case TRELLIS_HARD_SYMBOL: + calc_hard_symbol_metric(sample, metric); + break; + case TRELLIS_HARD_BIT: + throw std::runtime_error("Invalid metric type (not yet implemented)."); + break; + default: + throw std::runtime_error("Invalid metric type."); + } + } + + void + constellation::calc_euclidean_metric(const gr_complex *sample, float *metric) + { + for(unsigned int o=0; o<d_arity; o++) { + metric[o] = get_distance(o, sample); + } + } + + void + constellation::calc_hard_symbol_metric(const gr_complex *sample, float *metric) + { + float minm = FLT_MAX; + unsigned int minmi = 0; + for(unsigned int o=0; o<d_arity; o++) { + float dist = get_distance(o, sample); + if(dist < minm) { + minm = dist; + minmi = o; + } + } + for(unsigned int o=0; o<d_arity; o++) { + metric[o] = (o==minmi?0.0:1.0); + } + } + + void + constellation::calc_arity() + { + if(d_constellation.size() % d_dimensionality != 0) + throw std::runtime_error("Constellation vector size must be a multiple of the dimensionality."); + d_arity = d_constellation.size()/d_dimensionality; + } + + unsigned int + constellation::decision_maker_v(std::vector<gr_complex> sample) + { + assert(sample.size() == d_dimensionality); + return decision_maker(&(sample[0])); + } + + + /********************************************************************/ + + + constellation_calcdist::sptr + constellation_calcdist::make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality) + { + return constellation_calcdist::sptr(new constellation_calcdist + (constell, pre_diff_code, + rotational_symmetry, dimensionality)); + } + + constellation_calcdist::constellation_calcdist(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality) + : constellation(constell, pre_diff_code, rotational_symmetry, dimensionality) + {} + + // Chooses points base on shortest distance. + // Inefficient. + unsigned int + constellation_calcdist::decision_maker(const gr_complex *sample) + { + return get_closest_point(sample); + } + + + /********************************************************************/ + + + constellation_sector::constellation_sector(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int dimensionality, + unsigned int n_sectors) : + constellation(constell, pre_diff_code, rotational_symmetry, dimensionality), + n_sectors(n_sectors) + { + } + + constellation_sector::~constellation_sector() + { + } + + unsigned int + constellation_sector::decision_maker(const gr_complex *sample) + { + unsigned int sector; + sector = get_sector(sample); + return sector_values[sector]; + } + + void + constellation_sector::find_sector_values() + { + unsigned int i; + sector_values.clear(); + for(i=0; i<n_sectors; i++) { + sector_values.push_back(calc_sector_value(i)); + } + } + + + /********************************************************************/ + + + constellation_rect::sptr + constellation_rect::make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors) + { + return constellation_rect::sptr(new constellation_rect + (constell, pre_diff_code, + rotational_symmetry, + real_sectors, imag_sectors, + width_real_sectors, + width_imag_sectors)); + } + + constellation_rect::constellation_rect(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors) : + constellation_sector(constell, pre_diff_code, rotational_symmetry, + 1, real_sectors * imag_sectors), + n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), + d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) + { + find_sector_values(); + } + + constellation_rect::~constellation_rect() + { + } + + unsigned int + constellation_rect::get_sector(const gr_complex *sample) + { + int real_sector, imag_sector; + unsigned int sector; + + real_sector = int(real(*sample)/d_width_real_sectors + n_real_sectors/2.0); + if(real_sector < 0) + real_sector = 0; + if(real_sector >= (int)n_real_sectors) + real_sector = n_real_sectors-1; + + imag_sector = int(imag(*sample)/d_width_imag_sectors + n_imag_sectors/2.0); + if(imag_sector < 0) + imag_sector = 0; + if(imag_sector >= (int)n_imag_sectors) + imag_sector = n_imag_sectors-1; + + sector = real_sector * n_imag_sectors + imag_sector; + return sector; + } + + unsigned int + constellation_rect::calc_sector_value(unsigned int sector) + { + unsigned int real_sector, imag_sector; + gr_complex sector_center; + unsigned int closest_point; + real_sector = float(sector)/n_imag_sectors; + imag_sector = sector - real_sector * n_imag_sectors; + sector_center = gr_complex((real_sector + 0.5 - n_real_sectors/2.0) * d_width_real_sectors, + (imag_sector + 0.5 - n_imag_sectors/2.0) * d_width_imag_sectors); + closest_point = get_closest_point(§or_center); + return closest_point; + } + + + /********************************************************************/ + + + constellation_psk::sptr + constellation_psk::make(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int n_sectors) + { + return constellation_psk::sptr(new constellation_psk + (constell, pre_diff_code, + n_sectors)); + } + + constellation_psk::constellation_psk(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int n_sectors) : + constellation_sector(constell, pre_diff_code, constell.size(), 1, n_sectors) + { + find_sector_values(); + } + + constellation_psk::~constellation_psk() + { + } + + unsigned int + constellation_psk::get_sector(const gr_complex *sample) + { + float phase = arg(*sample); + float width = M_TWOPI / n_sectors; + int sector = floor(phase/width + 0.5); + if(sector < 0) + sector += n_sectors; + return sector; + } + + unsigned int + constellation_psk::calc_sector_value(unsigned int sector) + { + float phase = sector * M_TWOPI / n_sectors; + gr_complex sector_center = gr_complex(cos(phase), sin(phase)); + unsigned int closest_point = get_closest_point(§or_center); + return closest_point; + } + + + /********************************************************************/ + + + constellation_bpsk::sptr + constellation_bpsk::make() + { + return constellation_bpsk::sptr(new constellation_bpsk()); + } + + constellation_bpsk::constellation_bpsk() + { + d_constellation.resize(2); + d_constellation[0] = gr_complex(-1, 0); + d_constellation[1] = gr_complex(1, 0); + d_rotational_symmetry = 2; + d_dimensionality = 1; + calc_arity(); + } + + constellation_bpsk::~constellation_bpsk() + { + } + + unsigned int + constellation_bpsk::decision_maker(const gr_complex *sample) + { + return (real(*sample) > 0); + } + + + /********************************************************************/ + + + constellation_qpsk::sptr + constellation_qpsk::make() + { + return constellation_qpsk::sptr(new constellation_qpsk()); + } + + constellation_qpsk::constellation_qpsk() + { + d_constellation.resize(4); + // Gray-coded + d_constellation[0] = gr_complex(-SQRT_TWO, -SQRT_TWO); + d_constellation[1] = gr_complex(SQRT_TWO, -SQRT_TWO); + d_constellation[2] = gr_complex(-SQRT_TWO, SQRT_TWO); + d_constellation[3] = gr_complex(SQRT_TWO, SQRT_TWO); + + /* + d_constellation[0] = gr_complex(SQRT_TWO, SQRT_TWO); + d_constellation[1] = gr_complex(-SQRT_TWO, SQRT_TWO); + d_constellation[2] = gr_complex(SQRT_TWO, -SQRT_TWO); + d_constellation[3] = gr_complex(SQRT_TWO, -SQRT_TWO); + */ + + d_pre_diff_code.resize(4); + d_pre_diff_code[0] = 0x0; + d_pre_diff_code[1] = 0x2; + d_pre_diff_code[2] = 0x3; + d_pre_diff_code[3] = 0x1; + + d_rotational_symmetry = 4; + d_dimensionality = 1; + calc_arity(); + } + + constellation_qpsk::~constellation_qpsk() + { + } + + unsigned int + constellation_qpsk::decision_maker(const gr_complex *sample) + { + // Real component determines small bit. + // Imag component determines big bit. + return 2*(imag(*sample)>0) + (real(*sample)>0); + + /* + bool a = real(*sample) > 0; + bool b = imag(*sample) > 0; + if(a) { + if(b) + return 0x0; + else + return 0x1; + } + else { + if(b) + return 0x2; + else + return 0x3; + } + */ + } + + + /********************************************************************/ + + + constellation_dqpsk::sptr + constellation_dqpsk::make() + { + return constellation_dqpsk::sptr(new constellation_dqpsk()); + } + + constellation_dqpsk::constellation_dqpsk() + { + // This constellation is not gray coded, which allows + // us to use differential encodings (through diff_encode and + // diff_decode) on the symbols. + d_constellation.resize(4); + d_constellation[0] = gr_complex(+SQRT_TWO, +SQRT_TWO); + d_constellation[1] = gr_complex(-SQRT_TWO, +SQRT_TWO); + d_constellation[2] = gr_complex(-SQRT_TWO, -SQRT_TWO); + d_constellation[3] = gr_complex(+SQRT_TWO, -SQRT_TWO); + + // Use this mapping to convert to gray code before diff enc. + d_pre_diff_code.resize(4); + d_pre_diff_code[0] = 0x0; + d_pre_diff_code[1] = 0x1; + d_pre_diff_code[2] = 0x3; + d_pre_diff_code[3] = 0x2; + d_apply_pre_diff_code = true; + + d_rotational_symmetry = 4; + d_dimensionality = 1; + calc_arity(); + } + + constellation_dqpsk::~constellation_dqpsk() + { + } + + unsigned int + constellation_dqpsk::decision_maker(const gr_complex *sample) + { + // Slower deicison maker as we can't slice along one axis. + // Maybe there's a better way to do this, still. + + bool a = real(*sample) > 0; + bool b = imag(*sample) > 0; + if(a) { + if(b) + return 0x0; + else + return 0x3; + } + else { + if(b) + return 0x1; + else + return 0x2; + } + } + + + /********************************************************************/ + + + constellation_8psk::sptr + constellation_8psk::make() + { + return constellation_8psk::sptr(new constellation_8psk()); + } + + constellation_8psk::constellation_8psk() + { + float angle = M_PI/8.0; + d_constellation.resize(8); + // Gray-coded + d_constellation[0] = gr_complex(cos( 1*angle), sin( 1*angle)); + d_constellation[1] = gr_complex(cos( 7*angle), sin( 7*angle)); + d_constellation[2] = gr_complex(cos(15*angle), sin(15*angle)); + d_constellation[3] = gr_complex(cos( 9*angle), sin( 9*angle)); + d_constellation[4] = gr_complex(cos( 3*angle), sin( 3*angle)); + d_constellation[5] = gr_complex(cos( 5*angle), sin( 5*angle)); + d_constellation[6] = gr_complex(cos(13*angle), sin(13*angle)); + d_constellation[7] = gr_complex(cos(11*angle), sin(11*angle)); + d_rotational_symmetry = 8; + d_dimensionality = 1; + calc_arity(); + } + + constellation_8psk::~constellation_8psk() + { + } + + unsigned int + constellation_8psk::decision_maker(const gr_complex *sample) + { + unsigned int ret = 0; + + float re = sample->real(); + float im = sample->imag(); + + if(fabsf(re) <= fabsf(im)) + ret = 4; + if(re <= 0) + ret |= 1; + if(im <= 0) + ret |= 2; + + return ret; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/constellation_decoder_cb_impl.cc b/gr-digital/lib/constellation_decoder_cb_impl.cc new file mode 100644 index 0000000000..e764ccc629 --- /dev/null +++ b/gr-digital/lib/constellation_decoder_cb_impl.cc @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "constellation_decoder_cb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + constellation_decoder_cb::sptr + constellation_decoder_cb::make(constellation_sptr constellation) + { + return gnuradio::get_initial_sptr + (new constellation_decoder_cb_impl(constellation)); + } + + constellation_decoder_cb_impl:: + constellation_decoder_cb_impl(constellation_sptr constellation) + : gr_block("constellation_decoder_cb", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_constellation(constellation), + d_dim(constellation->dimensionality()) + { + set_relative_rate(1.0 / ((double)d_dim)); + } + + constellation_decoder_cb_impl::~constellation_decoder_cb_impl() + { + } + + void + constellation_decoder_cb_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + unsigned int input_required = noutput_items * d_dim; + + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; + } + + int + constellation_decoder_cb_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex const *in = (const gr_complex*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = d_constellation->decision_maker(&(in[i*d_dim])); + } + + consume_each(noutput_items * d_dim); + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/constellation_decoder_cb_impl.h b/gr-digital/lib/constellation_decoder_cb_impl.h new file mode 100644 index 0000000000..5972760507 --- /dev/null +++ b/gr-digital/lib/constellation_decoder_cb_impl.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CONSTELLATION_DECODER_CB_IMPL_H +#define INCLUDED_DIGITAL_CONSTELLATION_DECODER_CB_IMPL_H + +#include <digital/constellation_decoder_cb.h> + +namespace gr { + namespace digital { + + class constellation_decoder_cb_impl : public constellation_decoder_cb + { + private: + constellation_sptr d_constellation; + unsigned int d_dim; + + public: + constellation_decoder_cb_impl(constellation_sptr constellation); + ~constellation_decoder_cb_impl(); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CONSTELLATION_DECODER_CB_IMPL_H */ diff --git a/gr-digital/lib/constellation_receiver_cb_impl.cc b/gr-digital/lib/constellation_receiver_cb_impl.cc new file mode 100644 index 0000000000..f01e15ea8b --- /dev/null +++ b/gr-digital/lib/constellation_receiver_cb_impl.cc @@ -0,0 +1,130 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "constellation_receiver_cb_impl.h" +#include <gr_io_signature.h> +#include <gr_prefs.h> +#include <gr_math.h> +#include <gr_expj.h> +#include <stdexcept> + +namespace gr { + namespace digital { + +#define M_TWOPI (2*M_PI) +#define VERBOSE_MM 0 // Used for debugging symbol timing loop +#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking + + constellation_receiver_cb::sptr + constellation_receiver_cb::make(constellation_sptr constell, + float loop_bw, float fmin, float fmax) + { + return gnuradio::get_initial_sptr + (new constellation_receiver_cb_impl(constell, loop_bw, + fmin, fmax)); + } + + static int ios[] = {sizeof(char), sizeof(float), sizeof(float), sizeof(float)}; + static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); + constellation_receiver_cb_impl::constellation_receiver_cb_impl(constellation_sptr constellation, + float loop_bw, float fmin, float fmax) + : gr_block("constellation_receiver_cb", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signaturev(1, 4, iosig)), + gri_control_loop(loop_bw, fmax, fmin), + d_constellation(constellation), + d_current_const_point(0) + { + if(d_constellation->dimensionality() != 1) + throw std::runtime_error("This receiver only works with constellations of dimension 1."); + } + + constellation_receiver_cb_impl::~constellation_receiver_cb_impl() + { + } + + void + constellation_receiver_cb_impl::phase_error_tracking(float phase_error) + { + advance_loop(phase_error); + phase_wrap(); + frequency_limit(); + +#if VERBOSE_COSTAS + printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", + phase_error, d_phase, d_freq, sample.real(), sample.imag(), + d_constellation->points()[d_current_const_point].real(), + d_constellation->points()[d_current_const_point].imag()); +#endif + } + + int + constellation_receiver_cb_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + int i=0; + + float phase_error; + unsigned int sym_value; + gr_complex sample, nco; + + float *out_err = 0, *out_phase = 0, *out_freq = 0; + if(output_items.size() == 4) { + out_err = (float*)output_items[1]; + out_phase = (float*)output_items[2]; + out_freq = (float*)output_items[3]; + } + + while((i < noutput_items) && (i < ninput_items[0])) { + sample = in[i]; + nco = gr_expj(d_phase); // get the NCO value for derotating the current sample + sample = nco*sample; // get the downconverted symbol + + sym_value = d_constellation->decision_maker_pe(&sample, &phase_error); + phase_error_tracking(phase_error); // corrects phase and frequency offsets + + out[i] = sym_value; + + if(output_items.size() == 4) { + out_err[i] = phase_error; + out_phase[i] = d_phase; + out_freq[i] = d_freq; + } + i++; + } + + consume_each(i); + return i; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/constellation_receiver_cb_impl.h b/gr-digital/lib/constellation_receiver_cb_impl.h new file mode 100644 index 0000000000..50946840ae --- /dev/null +++ b/gr-digital/lib/constellation_receiver_cb_impl.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_CONSTELLATION_RECEIVER_CB_IMPL_H +#define INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_IMPL_H + +#include <digital/constellation_receiver_cb.h> +#include <gruel/attributes.h> +#include <gr_complex.h> +#include <gri_control_loop.h> + +namespace gr { + namespace digital { + + class constellation_receiver_cb_impl + : public constellation_receiver_cb, gri_control_loop + { + public: + constellation_receiver_cb_impl(constellation_sptr constell, + float loop_bw, float fmin, float fmax); + + ~constellation_receiver_cb_impl(); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + protected: + void phase_error_tracking(float phase_error); + + private: + unsigned int d_M; + + constellation_sptr d_constellation; + unsigned int d_current_const_point; + + //! delay line length. + static const unsigned int DLLEN = 8; + + //! delay line plus some length for overflow protection + __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; + + //! index to delay line + unsigned int d_dl_idx; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_IMPL_H */ diff --git a/gr-digital/lib/correlate_access_code_bb_impl.cc b/gr-digital/lib/correlate_access_code_bb_impl.cc new file mode 100644 index 0000000000..4e1131afda --- /dev/null +++ b/gr-digital/lib/correlate_access_code_bb_impl.cc @@ -0,0 +1,133 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010-2012 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 "correlate_access_code_bb_impl.h" +#include <gr_io_signature.h> +#include <gr_count_bits.h> +#include <stdexcept> +#include <cstdio> + +namespace gr { + namespace digital { + +#define VERBOSE 0 + + correlate_access_code_bb::sptr + correlate_access_code_bb::make(const std::string &access_code, int threshold) + { + return gnuradio::get_initial_sptr + (new correlate_access_code_bb_impl(access_code, threshold)); + } + + correlate_access_code_bb_impl::correlate_access_code_bb_impl( + const std::string &access_code, int threshold) + : gr_sync_block("correlate_access_code_bb", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(1, 1, sizeof(char))), + d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0), + d_threshold(threshold) + { + if(!set_access_code(access_code)) { + throw std::out_of_range ("access_code is > 64 bits"); + } + } + + correlate_access_code_bb_impl::~correlate_access_code_bb_impl() + { + } + + bool + correlate_access_code_bb_impl::set_access_code( + const std::string &access_code) + { + unsigned len = access_code.length(); // # of bytes in string + if(len > 64) + return false; + + // set len top bits to 1. + d_mask = ((~0ULL) >> (64 - len)) << (64 - len); + + d_flag_bit = 1LL << (64 - len); // Where we or-in new flag values. + // new data always goes in 0x0000000000000001 + d_access_code = 0; + for(unsigned i=0; i < 64; i++){ + d_access_code <<= 1; + if(i < len) + d_access_code |= access_code[i] & 1; // look at LSB only + } + + return true; + } + + int + correlate_access_code_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + // compute output value + unsigned int t = 0; + + t |= ((d_data_reg >> 63) & 0x1) << 0; + t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit + out[i] = t; + + // compute hamming distance between desired access code and current data + unsigned long long wrong_bits = 0; + unsigned int nwrong = d_threshold+1; + int new_flag = 0; + + wrong_bits = (d_data_reg ^ d_access_code) & d_mask; + nwrong = gr_count_bits64(wrong_bits); + + // test for access code with up to threshold errors + new_flag = (nwrong <= d_threshold); + +#if VERBOSE + if(new_flag) { + fprintf(stderr, "access code found: %llx\n", d_access_code); + } + else { + fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg); + } +#endif + + // shift in new data and new flag + d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); + d_flag_reg = (d_flag_reg << 1); + if(new_flag) { + d_flag_reg |= d_flag_bit; + } + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/correlate_access_code_bb_impl.h b/gr-digital/lib/correlate_access_code_bb_impl.h new file mode 100644 index 0000000000..ad44b36400 --- /dev/null +++ b/gr-digital/lib/correlate_access_code_bb_impl.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011,2012 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_ACCESS_CODE_BB_IMPL_H +#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_IMPL_H + +#include <digital/correlate_access_code_bb.h> + +namespace gr { + namespace digital { + + class correlate_access_code_bb_impl : + public correlate_access_code_bb + { + private: + unsigned long long d_access_code; // access code to locate start of packet + // access code is left justified in the word + unsigned long long d_data_reg; // used to look for access_code + unsigned long long d_flag_reg; // keep track of decisions + unsigned long long d_flag_bit; // mask containing 1 bit which is location of new flag + unsigned long long d_mask; // masks access_code bits (top N bits are set where + // N is the number of bits in the access code) + unsigned int d_threshold; // how many bits may be wrong in sync vector + + public: + correlate_access_code_bb_impl(const std::string &access_code, + int threshold); + ~correlate_access_code_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + bool set_access_code(const std::string &access_code); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_BB_IMPL_H */ diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc new file mode 100644 index 0000000000..d375daf95c --- /dev/null +++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010-2012 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 "correlate_access_code_tag_bb_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <gr_count_bits.h> +#include <cstdio> +#include <iostream> + +namespace gr { + namespace digital { + +#define VERBOSE 0 + + correlate_access_code_tag_bb::sptr + correlate_access_code_tag_bb::make(const std::string &access_code, + int threshold, + const std::string &tag_name) + { + return gnuradio::get_initial_sptr + (new correlate_access_code_tag_bb_impl(access_code, + threshold, tag_name)); + } + + + correlate_access_code_tag_bb_impl::correlate_access_code_tag_bb_impl( + const std::string &access_code, int threshold, const std::string &tag_name) + : gr_sync_block("correlate_access_code_tag_bb", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(1, 1, sizeof(char))), + d_data_reg(0), d_mask(0), + d_threshold(threshold), d_len(0) + { + if(!set_access_code(access_code)) { + throw std::out_of_range ("access_code is > 64 bits"); + } + + std::stringstream str; + str << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(str.str()); + d_key = pmt::pmt_string_to_symbol(tag_name); + } + + correlate_access_code_tag_bb_impl::~correlate_access_code_tag_bb_impl() + { + } + + bool + correlate_access_code_tag_bb_impl::set_access_code( + const std::string &access_code) + { + d_len = access_code.length(); // # of bytes in string + if(d_len > 64) + return false; + + // set len top bits to 1. + d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len); + + d_access_code = 0; + for(unsigned i=0; i < 64; i++){ + d_access_code <<= 1; + if(i < d_len) + d_access_code |= access_code[i] & 1; // look at LSB only + } + + return true; + } + + int + correlate_access_code_tag_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + uint64_t abs_out_sample_cnt = nitems_written(0); + + for(int i = 0; i < noutput_items; i++) { + out[i] = in[i]; + + // compute hamming distance between desired access code and current data + unsigned long long wrong_bits = 0; + unsigned int nwrong = d_threshold+1; + int new_flag = 0; + + wrong_bits = (d_data_reg ^ d_access_code) & d_mask; + nwrong = gr_count_bits64(wrong_bits); + + // test for access code with up to threshold errors + new_flag = (nwrong <= d_threshold); + + // shift in new data and new flag + d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); + if(new_flag) { + if(VERBOSE) + std::cerr << "writing tag at sample " << abs_out_sample_cnt + i << std::endl; + add_item_tag(0, //stream ID + abs_out_sample_cnt + i - 64 + d_len, //sample + d_key, //frame info + pmt::pmt_t(), //data (unused) + d_me //block src id + ); + } + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.h b/gr-digital/lib/correlate_access_code_tag_bb_impl.h new file mode 100644 index 0000000000..17a016fc9c --- /dev/null +++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2011,2012 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_ACCESS_CODE_TAG_BB_IMPL_H +#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_BB_IMPL_H + +#include <digital/correlate_access_code_tag_bb.h> + +namespace gr { + namespace digital { + + class correlate_access_code_tag_bb_impl : + public correlate_access_code_tag_bb + { + private: + unsigned long long d_access_code; // access code to locate start of packet + // access code is left justified in the word + unsigned long long d_data_reg; // used to look for access_code + unsigned long long d_mask; // masks access_code bits (top N bits are set where + // N is the number of bits in the access code) + unsigned int d_threshold; // how many bits may be wrong in sync vector + unsigned int d_len; // the length of the access code + + pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID + + public: + correlate_access_code_tag_bb_impl(const std::string &access_code, + int threshold, + const std::string &tag_name); + ~correlate_access_code_tag_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + bool set_access_code(const std::string &access_code); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_BB_IMPL_H */ diff --git a/gr-digital/lib/costas_loop_cc_impl.cc b/gr-digital/lib/costas_loop_cc_impl.cc new file mode 100644 index 0000000000..5afabf4294 --- /dev/null +++ b/gr-digital/lib/costas_loop_cc_impl.cc @@ -0,0 +1,161 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010-2012 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 "costas_loop_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <gr_sincos.h> +#include <gr_math.h> + +namespace gr { + namespace digital { + + costas_loop_cc::sptr + costas_loop_cc::make(float loop_bw, int order) + { + return gnuradio::get_initial_sptr + (new costas_loop_cc_impl(loop_bw, order)); + } + + costas_loop_cc_impl::costas_loop_cc_impl(float loop_bw, int order) + : gr_sync_block("costas_loop_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature2(1, 2, sizeof(gr_complex), sizeof(float))), + gri_control_loop(loop_bw, 1.0, -1.0), + d_order(order), d_phase_detector(NULL) + { + // Set up the phase detector to use based on the constellation order + switch(d_order) { + case 2: + d_phase_detector = &costas_loop_cc_impl::phase_detector_2; + break; + + case 4: + d_phase_detector = &costas_loop_cc_impl::phase_detector_4; + break; + + case 8: + d_phase_detector = &costas_loop_cc_impl::phase_detector_8; + break; + + default: + throw std::invalid_argument("order must be 2, 4, or 8"); + break; + } + } + + costas_loop_cc_impl::~costas_loop_cc_impl() + { + } + + float + costas_loop_cc_impl::phase_detector_8(gr_complex sample) const + { + /* This technique splits the 8PSK constellation into 2 squashed + QPSK constellations, one when I is larger than Q and one + where Q is larger than I. The error is then calculated + proportionally to these squashed constellations by the const + K = sqrt(2)-1. + + The signal magnitude must be > 1 or K will incorrectly bias + the error value. + + Ref: Z. Huang, Z. Yi, M. Zhang, K. Wang, "8PSK demodulation for + new generation DVB-S2", IEEE Proc. Int. Conf. Communications, + Circuits and Systems, Vol. 2, pp. 1447 - 1450, 2004. + */ + + float K = (sqrt(2.0) - 1); + if(fabsf(sample.real()) >= fabsf(sample.imag())) { + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real() * K); + } + else { + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() * K - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); + } + } + + float + costas_loop_cc_impl::phase_detector_4(gr_complex sample) const + { + return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - + (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); + } + + float + costas_loop_cc_impl::phase_detector_2(gr_complex sample) const + { + return (sample.real()*sample.imag()); + } + + int + costas_loop_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *iptr = (gr_complex *) input_items[0]; + gr_complex *optr = (gr_complex *) output_items[0]; + float *foptr = (float *) output_items[1]; + + bool write_foptr = output_items.size() >= 2; + + float error; + gr_complex nco_out; + + if(write_foptr) { + for(int i = 0; i < noutput_items; i++) { + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + error = gr_branchless_clip(error, 1.0); + + advance_loop(error); + phase_wrap(); + frequency_limit(); + + foptr[i] = d_freq; + } + } + else { + for(int i = 0; i < noutput_items; i++) { + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + error = gr_branchless_clip(error, 1.0); + + advance_loop(error); + phase_wrap(); + frequency_limit(); + } + } + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/costas_loop_cc_impl.h b/gr-digital/lib/costas_loop_cc_impl.h new file mode 100644 index 0000000000..9310368b4d --- /dev/null +++ b/gr-digital/lib/costas_loop_cc_impl.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2011,2012 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_COSTAS_LOOP_CC_IMPL_H +#define INCLUDED_DIGITAL_COSTAS_LOOP_CC_IMPL_H + +#include <digital/costas_loop_cc.h> +#include <gri_control_loop.h> + +namespace gr { + namespace digital { + + class costas_loop_cc_impl : public costas_loop_cc, gri_control_loop + { + private: + int d_order; + + /*! \brief the phase detector circuit for 8th-order PSK loops + * \param sample complex sample + * \return the phase error + */ + float phase_detector_8(gr_complex sample) const; // for 8PSK + + /*! \brief the phase detector circuit for fourth-order loops + * \param sample complex sample + * \return the phase error + */ + float phase_detector_4(gr_complex sample) const; // for QPSK + + /*! \brief the phase detector circuit for second-order loops + * \param sample a complex sample + * \return the phase error + */ + float phase_detector_2(gr_complex sample) const; // for BPSK + + float (costas_loop_cc_impl::*d_phase_detector)(gr_complex sample) const; + + public: + costas_loop_cc_impl(float loop_bw, int order); + ~costas_loop_cc_impl(); + + 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_COSTAS_LOOP_CC_IMPL_H */ diff --git a/gr-digital/lib/cpmmod_bc_impl.cc b/gr-digital/lib/cpmmod_bc_impl.cc new file mode 100644 index 0000000000..044090d59a --- /dev/null +++ b/gr-digital/lib/cpmmod_bc_impl.cc @@ -0,0 +1,125 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2012 Free Software Foundation, Inc. + * + * 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 "cpmmod_bc_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + cpmmod_bc::sptr + cpmmod_bc::make(gr_cpm::cpm_type type, float h, + int samples_per_sym, + int L, double beta) + { + return gnuradio::get_initial_sptr + (new cpmmod_bc_impl("cpmmod_bc", + (gr_cpm::cpm_type)type, + h, samples_per_sym, + L, beta)); + } + + cpmmod_bc::sptr + cpmmod_bc::make_gmskmod_bc(int samples_per_sym, + int L, double beta) + { + return gnuradio::get_initial_sptr + (new cpmmod_bc_impl("gmskmod_bc", + gr_cpm::GAUSSIAN, 0.5, + samples_per_sym, + L, beta)); + } + + cpmmod_bc_impl::cpmmod_bc_impl(const std::string &name, + gr_cpm::cpm_type type, float h, + int samples_per_sym, + int L, double beta) + : gr_hier_block2(name, + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature2(1, 1, sizeof(gr_complex), sizeof(float))), + d_type(type), d_index(h), d_sps(samples_per_sym), d_length(L), d_beta(beta), + d_taps(gr_cpm::phase_response(type, samples_per_sym, L, beta)), + d_char_to_float(gr_make_char_to_float()), + d_pulse_shaper(gr::filter::interp_fir_filter_fff::make(samples_per_sym, d_taps)), + d_fm(gr_make_frequency_modulator_fc(M_PI * h)) + { + switch(type) { + case gr_cpm::LRC: + case gr_cpm::LSRC: + case gr_cpm::LREC: + case gr_cpm::TFM: + case gr_cpm::GAUSSIAN: + break; + + default: + throw std::invalid_argument("cpmmod_bc_impl: invalid CPM type"); + } + + connect(self(), 0, d_char_to_float, 0); + connect(d_char_to_float, 0, d_pulse_shaper, 0); + connect(d_pulse_shaper, 0, d_fm, 0); + connect(d_fm, 0, self(), 0); + } + + cpmmod_bc_impl::~cpmmod_bc_impl() + { + } + + std::vector<float> + cpmmod_bc_impl::taps() const + { + return d_taps; + } + + int + cpmmod_bc_impl::type() const + { + return d_type; + } + + float + cpmmod_bc_impl::index() const + { + return d_index; + } + + int + cpmmod_bc_impl::samples_per_sym() const + { + return d_sps; + } + + int + cpmmod_bc_impl::length() const + { + return d_length; + } + + double cpmmod_bc_impl::beta() const + { + return d_beta; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/cpmmod_bc_impl.h b/gr-digital/lib/cpmmod_bc_impl.h new file mode 100644 index 0000000000..d27853e301 --- /dev/null +++ b/gr-digital/lib/cpmmod_bc_impl.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2012 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_CPMMOD_BC_IMPL_H +#define INCLUDED_DIGITAL_CPMMOD_BC_IMPL_H + +#include <digital/cpmmod_bc.h> +#include <gr_char_to_float.h> +#include <gr_frequency_modulator_fc.h> +#include <gr_cpm.h> +#include <filter/interp_fir_filter_fff.h> + +namespace gr { + namespace digital { + + class cpmmod_bc_impl : public cpmmod_bc + { + private: + int d_type; + float d_index; + int d_sps; + int d_length; + double d_beta; + + protected: + std::vector<float> d_taps; + gr_char_to_float_sptr d_char_to_float; + gr::filter::interp_fir_filter_fff::sptr d_pulse_shaper; + gr_frequency_modulator_fc_sptr d_fm; + + public: + cpmmod_bc_impl(const std::string &name, + gr_cpm::cpm_type type, float h, + int samples_per_sym, + int L, double beta=0.3); + ~cpmmod_bc_impl(); + + std::vector<float> taps() const; + int type() const; + float index() const; + int samples_per_sym() const; + int length() const; + double beta() const; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_CPMMOD_BC_IMPL_H */ + diff --git a/gr-digital/lib/crc32.cc b/gr-digital/lib/crc32.cc new file mode 100644 index 0000000000..b203727114 --- /dev/null +++ b/gr-digital/lib/crc32.cc @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2011,2012 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. + */ + +/* + * See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital/crc32.h> + +namespace gr { + namespace digital { + + // Automatically generated CRC function + // polynomial: 0x104C11DB7 + unsigned int + update_crc32(unsigned int crc, const unsigned char *data, size_t len) + { + static const unsigned int table[256] = { + 0x00000000U,0x04C11DB7U,0x09823B6EU,0x0D4326D9U, + 0x130476DCU,0x17C56B6BU,0x1A864DB2U,0x1E475005U, + 0x2608EDB8U,0x22C9F00FU,0x2F8AD6D6U,0x2B4BCB61U, + 0x350C9B64U,0x31CD86D3U,0x3C8EA00AU,0x384FBDBDU, + 0x4C11DB70U,0x48D0C6C7U,0x4593E01EU,0x4152FDA9U, + 0x5F15ADACU,0x5BD4B01BU,0x569796C2U,0x52568B75U, + 0x6A1936C8U,0x6ED82B7FU,0x639B0DA6U,0x675A1011U, + 0x791D4014U,0x7DDC5DA3U,0x709F7B7AU,0x745E66CDU, + 0x9823B6E0U,0x9CE2AB57U,0x91A18D8EU,0x95609039U, + 0x8B27C03CU,0x8FE6DD8BU,0x82A5FB52U,0x8664E6E5U, + 0xBE2B5B58U,0xBAEA46EFU,0xB7A96036U,0xB3687D81U, + 0xAD2F2D84U,0xA9EE3033U,0xA4AD16EAU,0xA06C0B5DU, + 0xD4326D90U,0xD0F37027U,0xDDB056FEU,0xD9714B49U, + 0xC7361B4CU,0xC3F706FBU,0xCEB42022U,0xCA753D95U, + 0xF23A8028U,0xF6FB9D9FU,0xFBB8BB46U,0xFF79A6F1U, + 0xE13EF6F4U,0xE5FFEB43U,0xE8BCCD9AU,0xEC7DD02DU, + 0x34867077U,0x30476DC0U,0x3D044B19U,0x39C556AEU, + 0x278206ABU,0x23431B1CU,0x2E003DC5U,0x2AC12072U, + 0x128E9DCFU,0x164F8078U,0x1B0CA6A1U,0x1FCDBB16U, + 0x018AEB13U,0x054BF6A4U,0x0808D07DU,0x0CC9CDCAU, + 0x7897AB07U,0x7C56B6B0U,0x71159069U,0x75D48DDEU, + 0x6B93DDDBU,0x6F52C06CU,0x6211E6B5U,0x66D0FB02U, + 0x5E9F46BFU,0x5A5E5B08U,0x571D7DD1U,0x53DC6066U, + 0x4D9B3063U,0x495A2DD4U,0x44190B0DU,0x40D816BAU, + 0xACA5C697U,0xA864DB20U,0xA527FDF9U,0xA1E6E04EU, + 0xBFA1B04BU,0xBB60ADFCU,0xB6238B25U,0xB2E29692U, + 0x8AAD2B2FU,0x8E6C3698U,0x832F1041U,0x87EE0DF6U, + 0x99A95DF3U,0x9D684044U,0x902B669DU,0x94EA7B2AU, + 0xE0B41DE7U,0xE4750050U,0xE9362689U,0xEDF73B3EU, + 0xF3B06B3BU,0xF771768CU,0xFA325055U,0xFEF34DE2U, + 0xC6BCF05FU,0xC27DEDE8U,0xCF3ECB31U,0xCBFFD686U, + 0xD5B88683U,0xD1799B34U,0xDC3ABDEDU,0xD8FBA05AU, + 0x690CE0EEU,0x6DCDFD59U,0x608EDB80U,0x644FC637U, + 0x7A089632U,0x7EC98B85U,0x738AAD5CU,0x774BB0EBU, + 0x4F040D56U,0x4BC510E1U,0x46863638U,0x42472B8FU, + 0x5C007B8AU,0x58C1663DU,0x558240E4U,0x51435D53U, + 0x251D3B9EU,0x21DC2629U,0x2C9F00F0U,0x285E1D47U, + 0x36194D42U,0x32D850F5U,0x3F9B762CU,0x3B5A6B9BU, + 0x0315D626U,0x07D4CB91U,0x0A97ED48U,0x0E56F0FFU, + 0x1011A0FAU,0x14D0BD4DU,0x19939B94U,0x1D528623U, + 0xF12F560EU,0xF5EE4BB9U,0xF8AD6D60U,0xFC6C70D7U, + 0xE22B20D2U,0xE6EA3D65U,0xEBA91BBCU,0xEF68060BU, + 0xD727BBB6U,0xD3E6A601U,0xDEA580D8U,0xDA649D6FU, + 0xC423CD6AU,0xC0E2D0DDU,0xCDA1F604U,0xC960EBB3U, + 0xBD3E8D7EU,0xB9FF90C9U,0xB4BCB610U,0xB07DABA7U, + 0xAE3AFBA2U,0xAAFBE615U,0xA7B8C0CCU,0xA379DD7BU, + 0x9B3660C6U,0x9FF77D71U,0x92B45BA8U,0x9675461FU, + 0x8832161AU,0x8CF30BADU,0x81B02D74U,0x857130C3U, + 0x5D8A9099U,0x594B8D2EU,0x5408ABF7U,0x50C9B640U, + 0x4E8EE645U,0x4A4FFBF2U,0x470CDD2BU,0x43CDC09CU, + 0x7B827D21U,0x7F436096U,0x7200464FU,0x76C15BF8U, + 0x68860BFDU,0x6C47164AU,0x61043093U,0x65C52D24U, + 0x119B4BE9U,0x155A565EU,0x18197087U,0x1CD86D30U, + 0x029F3D35U,0x065E2082U,0x0B1D065BU,0x0FDC1BECU, + 0x3793A651U,0x3352BBE6U,0x3E119D3FU,0x3AD08088U, + 0x2497D08DU,0x2056CD3AU,0x2D15EBE3U,0x29D4F654U, + 0xC5A92679U,0xC1683BCEU,0xCC2B1D17U,0xC8EA00A0U, + 0xD6AD50A5U,0xD26C4D12U,0xDF2F6BCBU,0xDBEE767CU, + 0xE3A1CBC1U,0xE760D676U,0xEA23F0AFU,0xEEE2ED18U, + 0xF0A5BD1DU,0xF464A0AAU,0xF9278673U,0xFDE69BC4U, + 0x89B8FD09U,0x8D79E0BEU,0x803AC667U,0x84FBDBD0U, + 0x9ABC8BD5U,0x9E7D9662U,0x933EB0BBU,0x97FFAD0CU, + 0xAFB010B1U,0xAB710D06U,0xA6322BDFU,0xA2F33668U, + 0xBCB4666DU,0xB8757BDAU,0xB5365D03U,0xB1F740B4U, + }; + + while(len > 0) + { + crc = table[*data ^ ((crc >> 24) & 0xff)] ^ (crc << 8); + data++; + len--; + } + return crc; + } + + unsigned int + update_crc32(unsigned int crc, const std::string s) + { + return update_crc32(crc, (const unsigned char *)s.data(), s.size()); + } + + unsigned int + crc32(const unsigned char *buf, size_t len) + { + return update_crc32(0xffffffff, buf, len) ^ 0xffffffff; + } + + unsigned int + crc32(const std::string s) + { + return crc32((const unsigned char *) s.data(), s.size()); + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/descrambler_bb_impl.cc b/gr-digital/lib/descrambler_bb_impl.cc new file mode 100644 index 0000000000..8124df37ef --- /dev/null +++ b/gr-digital/lib/descrambler_bb_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 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 "descrambler_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + descrambler_bb::sptr + descrambler_bb::make(int mask, int seed, int len) + { + return gnuradio::get_initial_sptr + (new descrambler_bb_impl(mask, seed, len)); + } + + descrambler_bb_impl::descrambler_bb_impl(int mask, int seed, int len) + : gr_sync_block("descrambler_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_lfsr(mask, seed, len) + { + } + + descrambler_bb_impl::~descrambler_bb_impl() + { + } + + int + descrambler_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = d_lfsr.next_bit_descramble(in[i]); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_descrambler_bb.i b/gr-digital/lib/descrambler_bb_impl.h index 59de806fba..920182304a 100644 --- a/gr-digital/swig/digital_descrambler_bb.i +++ b/gr-digital/lib/descrambler_bb_impl.h @@ -20,11 +20,30 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,descrambler_bb); +#ifndef INCLUDED_GR_DESCRAMBLER_BB_IMPL_H +#define INCLUDED_GR_DESCRAMBLER_BB_IMPL_H -digital_descrambler_bb_sptr -digital_make_descrambler_bb(int mask, int seed, int len); +#include <digital/descrambler_bb.h> +#include <gri_lfsr.h> -class digital_descrambler_bb : public gr_sync_block -{ -}; +namespace gr { + namespace digital { + + class descrambler_bb_impl : public descrambler_bb + { + private: + gri_lfsr d_lfsr; + + public: + descrambler_bb_impl(int mask, int seed, int len); + ~descrambler_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DESCRAMBLER_BB_IMPL_H */ diff --git a/gr-digital/lib/diff_decoder_bb_impl.cc b/gr-digital/lib/diff_decoder_bb_impl.cc new file mode 100644 index 0000000000..74c247a830 --- /dev/null +++ b/gr-digital/lib/diff_decoder_bb_impl.cc @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 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 "diff_decoder_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + diff_decoder_bb::sptr + diff_decoder_bb::make(unsigned int modulus) + { + return gnuradio::get_initial_sptr + (new diff_decoder_bb_impl(modulus)); + } + + diff_decoder_bb_impl::diff_decoder_bb_impl(unsigned int modulus) + : gr_sync_block("diff_decoder_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_modulus(modulus) + { + set_history(2); // need to look at two inputs + } + + diff_decoder_bb_impl::~diff_decoder_bb_impl() + { + } + + int + diff_decoder_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + in += 1; // ensure that in[-1] is valid + + unsigned modulus = d_modulus; + + for(int i = 0; i < noutput_items; i++) { + out[i] = (in[i] - in[i-1]) % modulus; + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_diff_decoder_bb.i b/gr-digital/lib/diff_decoder_bb_impl.h index f9741c771f..56a15ba128 100644 --- a/gr-digital/swig/digital_diff_decoder_bb.i +++ b/gr-digital/lib/diff_decoder_bb_impl.h @@ -20,11 +20,30 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,diff_decoder_bb) +#ifndef INCLUDED_GR_DIFF_DECODER_BB_IMPL_H +#define INCLUDED_GR_DIFF_DECODER_BB_IMPL_H -digital_diff_decoder_bb_sptr -digital_make_diff_decoder_bb(unsigned int modulus); +#include <digital/diff_decoder_bb.h> +#include <gr_sync_block.h> -class digital_diff_decoder_bb : public gr_sync_block -{ -}; +namespace gr { + namespace digital { + + class diff_decoder_bb_impl : public diff_decoder_bb + { + public: + diff_decoder_bb_impl(unsigned int modulus); + ~diff_decoder_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + private: + unsigned int d_modulus; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_DECODER_BB_IMPL_H */ diff --git a/gr-digital/lib/diff_encoder_bb_impl.cc b/gr-digital/lib/diff_encoder_bb_impl.cc new file mode 100644 index 0000000000..411efe006c --- /dev/null +++ b/gr-digital/lib/diff_encoder_bb_impl.cc @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,2012 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 "diff_encoder_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + diff_encoder_bb::sptr + diff_encoder_bb::make(unsigned int modulus) + { + return gnuradio::get_initial_sptr + (new diff_encoder_bb_impl(modulus)); + } + + diff_encoder_bb_impl::diff_encoder_bb_impl(unsigned int modulus) + : gr_sync_block("diff_encoder_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_last_out(0), d_modulus(modulus) + { + } + + diff_encoder_bb_impl::~diff_encoder_bb_impl() + { + } + + int + diff_encoder_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + unsigned last_out = d_last_out; + unsigned modulus = d_modulus; + + for(int i = 0; i < noutput_items; i++) { + out[i] = (in[i] + last_out) % modulus; + last_out = out[i]; + } + + d_last_out = last_out; + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_diff_encoder_bb.i b/gr-digital/lib/diff_encoder_bb_impl.h index 45a4589bf1..e088d79f86 100644 --- a/gr-digital/swig/digital_diff_encoder_bb.i +++ b/gr-digital/lib/diff_encoder_bb_impl.h @@ -20,11 +20,30 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,diff_encoder_bb) +#ifndef INCLUDED_GR_DIFF_ENCODER_BB_IMPL_H +#define INCLUDED_GR_DIFF_ENCODER_BB_IMPL_H -digital_diff_encoder_bb_sptr -digital_make_diff_encoder_bb(unsigned int modulus); +#include <digital/diff_encoder_bb.h> -class digital_diff_encoder_bb : public gr_sync_block -{ -}; +namespace gr { + namespace digital { + + class diff_encoder_bb_impl : public diff_encoder_bb + { + public: + diff_encoder_bb_impl(unsigned int modulus); + ~diff_encoder_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + private: + unsigned int d_last_out; + unsigned int d_modulus; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_ENCODER_BB_IMPL_H */ diff --git a/gr-digital/lib/digital_diff_phasor_cc.cc b/gr-digital/lib/diff_phasor_cc_impl.cc index 8313a4de89..0e7a108121 100644 --- a/gr-digital/lib/digital_diff_phasor_cc.cc +++ b/gr-digital/lib/diff_phasor_cc_impl.cc @@ -24,38 +24,46 @@ #include "config.h" #endif -#include <digital_diff_phasor_cc.h> +#include "diff_phasor_cc_impl.h" #include <gr_io_signature.h> -digital_diff_phasor_cc_sptr -digital_make_diff_phasor_cc () -{ - return gnuradio::get_initial_sptr(new digital_diff_phasor_cc()); -} +namespace gr { + namespace digital { -digital_diff_phasor_cc::digital_diff_phasor_cc () - : gr_sync_block ("diff_phasor_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))) -{ - set_history(2); -} + diff_phasor_cc::sptr + diff_phasor_cc::make() + { + return gnuradio::get_initial_sptr + (new diff_phasor_cc_impl()); + } + diff_phasor_cc_impl::diff_phasor_cc_impl() + : gr_sync_block("diff_phasor_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))) + { + set_history(2); + } -digital_diff_phasor_cc::~digital_diff_phasor_cc(){} + diff_phasor_cc_impl::~diff_phasor_cc_impl() + { + } -int -digital_diff_phasor_cc::work (int noutput_items, + int + diff_phasor_cc_impl::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - gr_complex const *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - in += 1; // ensure that i - 1 is valid. + { + gr_complex const *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + in += 1; // ensure that i - 1 is valid. - for(int i = 0; i < noutput_items; i++) { - out[i] = in[i] * conj(in[i-1]); - } + for(int i = 0; i < noutput_items; i++) { + out[i] = in[i] * conj(in[i-1]); + } - return noutput_items; -} + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_map_bb.i b/gr-digital/lib/diff_phasor_cc_impl.h index 50117d4f58..844fc826d8 100644 --- a/gr-digital/swig/digital_map_bb.i +++ b/gr-digital/lib/diff_phasor_cc_impl.h @@ -20,12 +20,27 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,map_bb); +#ifndef INCLUDED_GR_DIFF_PHASOR_CC_IMPL_H +#define INCLUDED_GR_DIFF_PHASOR_CC_IMPL_H -digital_map_bb_sptr -digital_make_map_bb(const std::vector<int> &map); +#include <digital/diff_phasor_cc.h> +#include <gr_sync_block.h> -class digital_map_bb : public gr_sync_block -{ -}; +namespace gr { + namespace digital { + class diff_phasor_cc_impl : public diff_phasor_cc + { + public: + diff_phasor_cc_impl(); + ~diff_phasor_cc_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_DIFF_PHASOR_CC_IMPL_H */ diff --git a/gr-digital/lib/digital_additive_scrambler_bb.cc b/gr-digital/lib/digital_additive_scrambler_bb.cc deleted file mode 100644 index a8affaa78f..0000000000 --- a/gr-digital/lib/digital_additive_scrambler_bb.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 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 <digital_additive_scrambler_bb.h> -#include <gr_io_signature.h> - -digital_additive_scrambler_bb_sptr -digital_make_additive_scrambler_bb(int mask, int seed, int len, int count) -{ - return gnuradio::get_initial_sptr(new digital_additive_scrambler_bb - (mask, seed, len, count)); -} - -digital_additive_scrambler_bb::digital_additive_scrambler_bb(int mask, - int seed, - int len, - int count) - : gr_sync_block("additive_scrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len), - d_count(count), - d_bits(0) -{ -} - -int -digital_additive_scrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) { - out[i] = in[i]^d_lfsr.next_bit(); - if (d_count > 0) { - if (++d_bits == d_count) { - d_lfsr.reset(); - d_bits = 0; - } - } - } - - return noutput_items; -} diff --git a/gr-digital/lib/digital_bytes_to_syms.cc b/gr-digital/lib/digital_bytes_to_syms.cc deleted file mode 100644 index f8bd82d5b8..0000000000 --- a/gr-digital/lib/digital_bytes_to_syms.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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 <digital_bytes_to_syms.h> -#include <gr_io_signature.h> -#include <assert.h> - -static const int BITS_PER_BYTE = 8; - -digital_bytes_to_syms_sptr -digital_make_bytes_to_syms () -{ - return gnuradio::get_initial_sptr(new digital_bytes_to_syms ()); -} - -digital_bytes_to_syms::digital_bytes_to_syms () - : gr_sync_interpolator ("bytes_to_syms", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (float)), - BITS_PER_BYTE) -{ -} - -int -digital_bytes_to_syms::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (unsigned char *) input_items[0]; - float *out = (float *) output_items[0]; - - assert (noutput_items % BITS_PER_BYTE == 0); - - for (int i = 0; i < noutput_items / BITS_PER_BYTE; i++) { - int x = in[i]; - - *out++ = (((x >> 7) & 0x1) << 1) - 1; - *out++ = (((x >> 6) & 0x1) << 1) - 1; - *out++ = (((x >> 5) & 0x1) << 1) - 1; - *out++ = (((x >> 4) & 0x1) << 1) - 1; - *out++ = (((x >> 3) & 0x1) << 1) - 1; - *out++ = (((x >> 2) & 0x1) << 1) - 1; - *out++ = (((x >> 1) & 0x1) << 1) - 1; - *out++ = (((x >> 0) & 0x1) << 1) - 1; - } - - return noutput_items; -} - - - diff --git a/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t b/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t deleted file mode 100644 index 399a474a62..0000000000 --- a/gr-digital/lib/digital_chunks_to_symbols_XX.cc.t +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <iostream> -#include <string.h> - -@SPTR_NAME@ -digital_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) -{ - return gnuradio::get_initial_sptr (new @NAME@ (symbol_table,D)); -} - -@NAME@::@NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) - : gr_sync_interpolator ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@)), - D), - d_D (D), - d_symbol_table (symbol_table) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - assert (noutput_items % d_D == 0); - assert (input_items.size() == output_items.size()); - int nstreams = input_items.size(); - - for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - @O_TYPE@ *out = (@O_TYPE@ *) output_items[m]; - - // per stream processing - for (int i = 0; i < noutput_items / d_D; i++){ - assert (((unsigned int)in[i]*d_D+d_D) <= d_symbol_table.size()); - memcpy(out, &d_symbol_table[(unsigned int)in[i]*d_D], d_D*sizeof(@O_TYPE@)); - out+=d_D; - } - // end of per stream processing - - } - return noutput_items; -} diff --git a/gr-digital/lib/digital_clock_recovery_mm_cc.cc b/gr-digital/lib/digital_clock_recovery_mm_cc.cc deleted file mode 100644 index 198eb4b890..0000000000 --- a/gr-digital/lib/digital_clock_recovery_mm_cc.cc +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2010,2011 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 <gr_io_signature.h> -#include <gr_prefs.h> -#include <digital_clock_recovery_mm_cc.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <stdexcept> -#include <cstdio> - - -// Public constructor -static const int FUDGE = 16; - -digital_clock_recovery_mm_cc_sptr -digital_make_clock_recovery_mm_cc(float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) -{ - return gnuradio::get_initial_sptr(new digital_clock_recovery_mm_cc (omega, - gain_omega, - mu, - gain_mu, - omega_relative_limit)); -} - -digital_clock_recovery_mm_cc::digital_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) - : gr_block ("clock_recovery_mm_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature2 (1, 2, sizeof (gr_complex), sizeof(float))), - d_mu (mu), d_omega(omega), d_gain_omega(gain_omega), - d_omega_relative_limit(omega_relative_limit), - d_gain_mu(gain_mu), d_last_sample(0), d_interp(new gri_mmse_fir_interpolator_cc()), - d_verbose(gr_prefs::singleton()->get_bool("clock_recovery_mm_cc", "verbose", false)), - d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) -{ - if (omega <= 0.0) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - set_omega(omega); // also sets min and max omega - set_relative_rate (1.0 / omega); - set_history(3); // ensure 2 extra input sample is available -} - -digital_clock_recovery_mm_cc::~digital_clock_recovery_mm_cc () -{ - delete d_interp; -} - -void -digital_clock_recovery_mm_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = - (int) ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE; -} - -gr_complex -digital_clock_recovery_mm_cc::slicer_0deg (gr_complex sample) -{ - float real=0, imag=0; - - if(sample.real() > 0) - real = 1; - if(sample.imag() > 0) - imag = 1; - return gr_complex(real,imag); -} - -gr_complex -digital_clock_recovery_mm_cc::slicer_45deg (gr_complex sample) -{ - float real= -1, imag = -1; - if(sample.real() > 0) - real=1; - if(sample.imag() > 0) - imag = 1; - return gr_complex(real,imag); -} - -/* - Modified Mueller and Muller clock recovery circuit - Based: - G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller - algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033. -*/ - -int -digital_clock_recovery_mm_cc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - float *foptr = (float *) output_items[1]; - - bool write_foptr = output_items.size() >= 2; - - int ii = 0; // input index - int oo = 0; // output index - int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more input than this - - assert(d_mu >= 0.0); - assert(d_mu <= 1.0); - - float mm_val=0; - gr_complex u, x, y; - - // This loop writes the error to the second output, if it exists - if (write_foptr) { - while(oo < noutput_items && ii < ni) { - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = d_interp->interpolate (&in[ii], d_mu); - - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - d_c_0T = slicer_0deg(d_p_0T); - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_val = u.real(); - out[oo++] = d_p_0T; - - // limit mm_val - mm_val = gr_branchless_clip(mm_val,4.0); - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - ii += (int)floor(d_mu); - d_mu -= floor(d_mu); - - // write the error signal to the second output - foptr[oo-1] = mm_val; - - if (ii < 0) // clamp it. This should only happen with bogus input - ii = 0; - } - } - // This loop does not write to the second output (ugly, but faster) - else { - while(oo < noutput_items && ii < ni) { - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = d_interp->interpolate (&in[ii], d_mu); - - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - d_c_0T = slicer_0deg(d_p_0T); - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_val = u.real(); - out[oo++] = d_p_0T; - - // limit mm_val - mm_val = gr_branchless_clip(mm_val,1.0); - - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - ii += (int)floor(d_mu); - d_mu -= floor(d_mu); - - if(d_verbose) { - printf("%f\t%f\n", d_omega, d_mu); - } - - if (ii < 0) // clamp it. This should only happen with bogus input - ii = 0; - } - } - - if (ii > 0){ - if (ii > ninput_items[0]){ - fprintf(stderr, "gr_clock_recovery_mm_cc: ii > ninput_items[0] (%d > %d)\n", - ii, ninput_items[0]); - assert(0); - } - consume_each (ii); - } - - return oo; -} diff --git a/gr-digital/lib/digital_clock_recovery_mm_ff.cc b/gr-digital/lib/digital_clock_recovery_mm_ff.cc deleted file mode 100644 index 04057f0e94..0000000000 --- a/gr-digital/lib/digital_clock_recovery_mm_ff.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2011 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 <gr_io_signature.h> -#include <digital_clock_recovery_mm_ff.h> -#include <gri_mmse_fir_interpolator.h> -#include <stdexcept> - -#define DEBUG_CR_MM_FF 0 // must be defined as 0 or 1 - -// Public constructor - -digital_clock_recovery_mm_ff_sptr -digital_make_clock_recovery_mm_ff(float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) -{ - return gnuradio::get_initial_sptr(new digital_clock_recovery_mm_ff (omega, - gain_omega, - mu, - gain_mu, - omega_relative_limit)); -} - -digital_clock_recovery_mm_ff::digital_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) - : gr_block ("clock_recovery_mm_ff", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (float))), - d_mu (mu), d_gain_omega(gain_omega), d_gain_mu(gain_mu), - d_last_sample(0), d_interp(new gri_mmse_fir_interpolator()), - d_logfile(0), d_omega_relative_limit(omega_relative_limit) -{ - if (omega < 1) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - set_omega(omega); // also sets min and max omega - set_relative_rate (1.0 / omega); - - if (DEBUG_CR_MM_FF) - d_logfile = fopen("cr_mm_ff.dat", "wb"); -} - -digital_clock_recovery_mm_ff::~digital_clock_recovery_mm_ff () -{ - delete d_interp; - - if (DEBUG_CR_MM_FF && d_logfile){ - fclose(d_logfile); - d_logfile = 0; - } -} - -void -digital_clock_recovery_mm_ff::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = - (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} - -static inline float -slice(float x) -{ - return x < 0 ? -1.0F : 1.0F; -} - -/* - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. - * - * See "Digital Communication Receivers: Synchronization, Channel - * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel. - * ISBN 0-471-50275-8. - */ -int -digital_clock_recovery_mm_ff::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int ii = 0; // input index - int oo = 0; // output index - int ni = ninput_items[0] - d_interp->ntaps(); // don't use more input than this - float mm_val; - - while (oo < noutput_items && ii < ni ){ - - // produce output sample - out[oo] = d_interp->interpolate (&in[ii], d_mu); - mm_val = slice(d_last_sample) * out[oo] - slice(out[oo]) * d_last_sample; - d_last_sample = out[oo]; - - d_omega = d_omega + d_gain_omega * mm_val; - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit); // make sure we don't walk away - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - - ii += (int) floor(d_mu); - d_mu = d_mu - floor(d_mu); - oo++; - - if (DEBUG_CR_MM_FF && d_logfile){ - fwrite(&d_omega, sizeof(d_omega), 1, d_logfile); - } - } - - consume_each (ii); - - return oo; -} diff --git a/gr-digital/lib/digital_cma_equalizer_cc.cc b/gr-digital/lib/digital_cma_equalizer_cc.cc deleted file mode 100644 index c6c46c2d8c..0000000000 --- a/gr-digital/lib/digital_cma_equalizer_cc.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_cma_equalizer_cc.h> -#include <cstdio> - -digital_cma_equalizer_cc_sptr -digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu, int sps) -{ - return gnuradio::get_initial_sptr(new digital_cma_equalizer_cc(num_taps, modulus, - mu, sps)); -} - -digital_cma_equalizer_cc::digital_cma_equalizer_cc(int num_taps, float modulus, - float mu, int sps) - : gr_adaptive_fir_ccc("cma_equalizer_cc", sps, - std::vector<gr_complex>(num_taps, gr_complex(0,0))) -{ - set_modulus(modulus); - set_gain(mu); - if (num_taps > 0) - d_taps[0] = 1.0; -} diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc deleted file mode 100644 index 383c73c30d..0000000000 --- a/gr-digital/lib/digital_constellation.cc +++ /dev/null @@ -1,552 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010, 2011 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 <gr_io_signature.h> -#include <digital_constellation.h> -#include <digital_metric_type.h> -#include <gr_math.h> -#include <gr_complex.h> -#include <math.h> -#include <iostream> -#include <stdlib.h> -#include <float.h> -#include <stdexcept> - -#define M_TWOPI (2*M_PI) -#define SQRT_TWO 0.707107 - -// Base Constellation Class - -digital_constellation::digital_constellation (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality) : - d_constellation(constellation), - d_pre_diff_code(pre_diff_code), - d_rotational_symmetry(rotational_symmetry), - d_dimensionality(dimensionality) -{ - if (pre_diff_code.size() == 0) - d_apply_pre_diff_code = false; - else if (pre_diff_code.size() != constellation.size()) - throw std::runtime_error ("The constellation and pre-diff code must be of the same length."); - else - d_apply_pre_diff_code = true; - calc_arity(); -} - -digital_constellation::digital_constellation () : - d_apply_pre_diff_code(false), - d_rotational_symmetry(0), - d_dimensionality(1) -{ - calc_arity(); -} - -//! Returns the constellation points for a symbol value -void -digital_constellation::map_to_points(unsigned int value, gr_complex *points) -{ - for (unsigned int i=0; i<d_dimensionality; i++) - points[i] = d_constellation[value*d_dimensionality + i]; -} - -std::vector<gr_complex> -digital_constellation::map_to_points_v(unsigned int value) -{ - std::vector<gr_complex> points_v; - points_v.resize(d_dimensionality); - map_to_points(value, &(points_v[0])); - return points_v; -} - -float -digital_constellation::get_distance(unsigned int index, const gr_complex *sample) -{ - float dist = 0; - for (unsigned int i=0; i<d_dimensionality; i++) { - dist += norm(sample[i] - d_constellation[index*d_dimensionality + i]); - } - return dist; -} - -unsigned int -digital_constellation::get_closest_point(const gr_complex *sample) -{ - unsigned int min_index = 0; - float min_euclid_dist; - float euclid_dist; - - min_euclid_dist = get_distance(0, sample); - min_index = 0; - for (unsigned int j = 1; j < d_arity; j++){ - euclid_dist = get_distance(j, sample); - if (euclid_dist < min_euclid_dist){ - min_euclid_dist = euclid_dist; - min_index = j; - } - } - return min_index; -} - -unsigned int -digital_constellation::decision_maker_pe(const gr_complex *sample, float *phase_error) -{ - unsigned int index = decision_maker(sample); - *phase_error = 0; - for (unsigned int d=0; d<d_dimensionality; d++) - *phase_error += -arg(sample[d]*conj(d_constellation[index+d])); - return index; -} - -/* -unsigned int digital_constellation::decision_maker_e(const gr_complex *sample, float *error) -{ - unsigned int index = decision_maker(sample); - *error = 0; - for (unsigned int d=0; d<d_dimensionality; d++) - *error += sample[d]*conj(d_constellation[index+d]); - return index; -} -*/ - -std::vector<gr_complex> digital_constellation::s_points () { - if (d_dimensionality != 1) - throw std::runtime_error ("s_points only works for dimensionality 1 constellations."); - else - return d_constellation; -} - -std::vector<std::vector<gr_complex> > -digital_constellation::v_points () -{ - std::vector<std::vector<gr_complex> > vv_const; - vv_const.resize(d_arity); - for (unsigned int p=0; p<d_arity; p++) { - std::vector<gr_complex> v_const; - v_const.resize(d_dimensionality); - for (unsigned int d=0; d<d_dimensionality; d++) { - v_const[d] = d_constellation[p*d_dimensionality+d]; - } - vv_const[p] = v_const; - } - return vv_const; -} - -void -digital_constellation::calc_metric(const gr_complex *sample, float *metric, - trellis_metric_type_t type) -{ - switch (type){ - case TRELLIS_EUCLIDEAN: - calc_euclidean_metric(sample, metric); - break; - case TRELLIS_HARD_SYMBOL: - calc_hard_symbol_metric(sample, metric); - break; - case TRELLIS_HARD_BIT: - throw std::runtime_error ("Invalid metric type (not yet implemented)."); - break; - default: - throw std::runtime_error ("Invalid metric type."); - } -} - -void -digital_constellation::calc_euclidean_metric(const gr_complex *sample, float *metric) -{ - for (unsigned int o=0; o<d_arity; o++) { - metric[o] = get_distance(o, sample); - } -} - -void -digital_constellation::calc_hard_symbol_metric(const gr_complex *sample, float *metric) -{ - float minm = FLT_MAX; - unsigned int minmi = 0; - for (unsigned int o=0; o<d_arity; o++) { - float dist = get_distance(o, sample); - if (dist < minm) { - minm = dist; - minmi = o; - } - } - for(unsigned int o=0; o<d_arity; o++) { - metric[o] = (o==minmi?0.0:1.0); - } -} - -void -digital_constellation::calc_arity () -{ - if (d_constellation.size() % d_dimensionality != 0) - throw std::runtime_error ("Constellation vector size must be a multiple of the dimensionality."); - d_arity = d_constellation.size()/d_dimensionality; -} - -unsigned int -digital_constellation::decision_maker_v (std::vector<gr_complex> sample) -{ - assert(sample.size() == d_dimensionality); - return decision_maker (&(sample[0])); -} - -digital_constellation_calcdist_sptr -digital_make_constellation_calcdist(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality) -{ - return digital_constellation_calcdist_sptr(new digital_constellation_calcdist - (constellation, pre_diff_code, - rotational_symmetry, dimensionality)); -} - -digital_constellation_calcdist::digital_constellation_calcdist(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality) : - digital_constellation(constellation, pre_diff_code, rotational_symmetry, dimensionality) -{} - -// Chooses points base on shortest distance. -// Inefficient. -unsigned int -digital_constellation_calcdist::decision_maker(const gr_complex *sample) -{ - return get_closest_point(sample); -} - -digital_constellation_sector::digital_constellation_sector (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality, - unsigned int n_sectors) : - digital_constellation(constellation, pre_diff_code, rotational_symmetry, dimensionality), - n_sectors(n_sectors) -{ -} - -unsigned int -digital_constellation_sector::decision_maker (const gr_complex *sample) -{ - unsigned int sector; - sector = get_sector(sample); - return sector_values[sector]; -} - -void -digital_constellation_sector::find_sector_values () -{ - unsigned int i; - sector_values.clear(); - for (i=0; i<n_sectors; i++) { - sector_values.push_back(calc_sector_value(i)); - } -} - -digital_constellation_rect_sptr -digital_make_constellation_rect(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, unsigned int imag_sectors, - float width_real_sectors, float width_imag_sectors) -{ - return digital_constellation_rect_sptr(new digital_constellation_rect - (constellation, pre_diff_code, - rotational_symmetry, - real_sectors, imag_sectors, - width_real_sectors, - width_imag_sectors)); - } - -digital_constellation_rect::digital_constellation_rect (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, unsigned int imag_sectors, - float width_real_sectors, float width_imag_sectors) : - digital_constellation_sector(constellation, pre_diff_code, rotational_symmetry, 1, real_sectors * imag_sectors), - n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), - d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) -{ - find_sector_values(); -} - -unsigned int -digital_constellation_rect::get_sector (const gr_complex *sample) -{ - int real_sector, imag_sector; - unsigned int sector; - - real_sector = int(real(*sample)/d_width_real_sectors + n_real_sectors/2.0); - if(real_sector < 0) - real_sector = 0; - if(real_sector >= (int)n_real_sectors) - real_sector = n_real_sectors-1; - - imag_sector = int(imag(*sample)/d_width_imag_sectors + n_imag_sectors/2.0); - if(imag_sector < 0) - imag_sector = 0; - if(imag_sector >= (int)n_imag_sectors) - imag_sector = n_imag_sectors-1; - - sector = real_sector * n_imag_sectors + imag_sector; - return sector; -} - -unsigned int -digital_constellation_rect::calc_sector_value (unsigned int sector) -{ - unsigned int real_sector, imag_sector; - gr_complex sector_center; - unsigned int closest_point; - real_sector = float(sector)/n_imag_sectors; - imag_sector = sector - real_sector * n_imag_sectors; - sector_center = gr_complex((real_sector + 0.5 - n_real_sectors/2.0) * d_width_real_sectors, - (imag_sector + 0.5 - n_imag_sectors/2.0) * d_width_imag_sectors); - closest_point = get_closest_point(§or_center); - return closest_point; -} - - -digital_constellation_psk_sptr -digital_make_constellation_psk(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors) -{ - return digital_constellation_psk_sptr(new digital_constellation_psk - (constellation, pre_diff_code, - n_sectors)); -} - -digital_constellation_psk::digital_constellation_psk (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors) : - digital_constellation_sector(constellation, pre_diff_code, constellation.size(), 1, n_sectors) -{ - find_sector_values(); -} - -unsigned int -digital_constellation_psk::get_sector (const gr_complex *sample) -{ - float phase = arg(*sample); - float width = M_TWOPI / n_sectors; - int sector = floor(phase/width + 0.5); - if (sector < 0) - sector += n_sectors; - return sector; -} - -unsigned int -digital_constellation_psk::calc_sector_value (unsigned int sector) -{ - float phase = sector * M_TWOPI / n_sectors; - gr_complex sector_center = gr_complex(cos(phase), sin(phase)); - unsigned int closest_point = get_closest_point(§or_center); - return closest_point; -} - - -digital_constellation_bpsk_sptr -digital_make_constellation_bpsk() -{ - return digital_constellation_bpsk_sptr(new digital_constellation_bpsk ()); -} - -digital_constellation_bpsk::digital_constellation_bpsk () -{ - d_constellation.resize(2); - d_constellation[0] = gr_complex(-1, 0); - d_constellation[1] = gr_complex(1, 0); - d_rotational_symmetry = 2; - d_dimensionality = 1; - calc_arity(); -} - -unsigned int -digital_constellation_bpsk::decision_maker(const gr_complex *sample) -{ - return (real(*sample) > 0); -} - - -digital_constellation_qpsk_sptr -digital_make_constellation_qpsk() -{ - return digital_constellation_qpsk_sptr(new digital_constellation_qpsk ()); -} - -digital_constellation_qpsk::digital_constellation_qpsk () -{ - d_constellation.resize(4); - // Gray-coded - d_constellation[0] = gr_complex(-SQRT_TWO, -SQRT_TWO); - d_constellation[1] = gr_complex(SQRT_TWO, -SQRT_TWO); - d_constellation[2] = gr_complex(-SQRT_TWO, SQRT_TWO); - d_constellation[3] = gr_complex(SQRT_TWO, SQRT_TWO); - - /* - d_constellation[0] = gr_complex(SQRT_TWO, SQRT_TWO); - d_constellation[1] = gr_complex(-SQRT_TWO, SQRT_TWO); - d_constellation[2] = gr_complex(SQRT_TWO, -SQRT_TWO); - d_constellation[3] = gr_complex(SQRT_TWO, -SQRT_TWO); - */ - - d_pre_diff_code.resize(4); - d_pre_diff_code[0] = 0x0; - d_pre_diff_code[1] = 0x2; - d_pre_diff_code[2] = 0x3; - d_pre_diff_code[3] = 0x1; - - d_rotational_symmetry = 4; - d_dimensionality = 1; - calc_arity(); -} - -unsigned int -digital_constellation_qpsk::decision_maker(const gr_complex *sample) -{ - // Real component determines small bit. - // Imag component determines big bit. - return 2*(imag(*sample)>0) + (real(*sample)>0); - - /* - bool a = real(*sample) > 0; - bool b = imag(*sample) > 0; - if(a) { - if(b) - return 0x0; - else - return 0x1; - } - else { - if(b) - return 0x2; - else - return 0x3; - } - */ -} - - -/********************************************************************/ - - -digital_constellation_dqpsk_sptr -digital_make_constellation_dqpsk() -{ - return digital_constellation_dqpsk_sptr(new digital_constellation_dqpsk ()); -} - -digital_constellation_dqpsk::digital_constellation_dqpsk () -{ - // This constellation is not gray coded, which allows - // us to use differential encodings (through digital_diff_encode and - // digital_diff_decode) on the symbols. - d_constellation.resize(4); - d_constellation[0] = gr_complex(+SQRT_TWO, +SQRT_TWO); - d_constellation[1] = gr_complex(-SQRT_TWO, +SQRT_TWO); - d_constellation[2] = gr_complex(-SQRT_TWO, -SQRT_TWO); - d_constellation[3] = gr_complex(+SQRT_TWO, -SQRT_TWO); - - // Use this mapping to convert to gray code before diff enc. - d_pre_diff_code.resize(4); - d_pre_diff_code[0] = 0x0; - d_pre_diff_code[1] = 0x1; - d_pre_diff_code[2] = 0x3; - d_pre_diff_code[3] = 0x2; - d_apply_pre_diff_code = true; - - d_rotational_symmetry = 4; - d_dimensionality = 1; - calc_arity(); -} - -unsigned int -digital_constellation_dqpsk::decision_maker(const gr_complex *sample) -{ - // Slower deicison maker as we can't slice along one axis. - // Maybe there's a better way to do this, still. - - bool a = real(*sample) > 0; - bool b = imag(*sample) > 0; - if(a) { - if(b) - return 0x0; - else - return 0x3; - } - else { - if(b) - return 0x1; - else - return 0x2; - } -} - -digital_constellation_8psk_sptr -digital_make_constellation_8psk() -{ - return digital_constellation_8psk_sptr(new digital_constellation_8psk ()); -} - -digital_constellation_8psk::digital_constellation_8psk () -{ - float angle = M_PI/8.0; - d_constellation.resize(8); - // Gray-coded - d_constellation[0] = gr_complex(cos( 1*angle), sin( 1*angle)); - d_constellation[1] = gr_complex(cos( 7*angle), sin( 7*angle)); - d_constellation[2] = gr_complex(cos(15*angle), sin(15*angle)); - d_constellation[3] = gr_complex(cos( 9*angle), sin( 9*angle)); - d_constellation[4] = gr_complex(cos( 3*angle), sin( 3*angle)); - d_constellation[5] = gr_complex(cos( 5*angle), sin( 5*angle)); - d_constellation[6] = gr_complex(cos(13*angle), sin(13*angle)); - d_constellation[7] = gr_complex(cos(11*angle), sin(11*angle)); - d_rotational_symmetry = 8; - d_dimensionality = 1; - calc_arity(); -} - -unsigned int -digital_constellation_8psk::decision_maker(const gr_complex *sample) -{ - unsigned int ret = 0; - - float re = sample->real(); - float im = sample->imag(); - - if(fabsf(re) <= fabsf(im)) - ret = 4; - if(re <= 0) - ret |= 1; - if(im <= 0) - ret |= 2; - - return ret; -} diff --git a/gr-digital/lib/digital_constellation_decoder_cb.cc b/gr-digital/lib/digital_constellation_decoder_cb.cc deleted file mode 100644 index 4638790f61..0000000000 --- a/gr-digital/lib/digital_constellation_decoder_cb.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_constellation_decoder_cb.h> -#include <digital_constellation.h> -#include <gr_io_signature.h> -#include <iostream> - -digital_constellation_decoder_cb_sptr -digital_make_constellation_decoder_cb (digital_constellation_sptr constellation) -{ - return gnuradio::get_initial_sptr - (new digital_constellation_decoder_cb(constellation)); -} - -digital_constellation_decoder_cb:: -digital_constellation_decoder_cb (digital_constellation_sptr constellation) - : gr_block ("constellation_decoder_cb", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_constellation(constellation), - d_dim(constellation->dimensionality()) -{ - set_relative_rate (1.0 / ((double) d_dim)); -} - -void -digital_constellation_decoder_cb::forecast (int noutput_items, - gr_vector_int &ninput_items_required) -{ - unsigned int input_required = noutput_items * d_dim; - - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = input_required; -} - - -int -digital_constellation_decoder_cb::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex const *in = (const gr_complex *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for(int i = 0; i < noutput_items; i++){ - out[i] = d_constellation->decision_maker(&(in[i*d_dim])); - } - - consume_each (noutput_items * d_dim); - return noutput_items; -} diff --git a/gr-digital/lib/digital_constellation_receiver_cb.cc b/gr-digital/lib/digital_constellation_receiver_cb.cc deleted file mode 100644 index b9239962a7..0000000000 --- a/gr-digital/lib/digital_constellation_receiver_cb.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <gr_io_signature.h> -#include <gr_prefs.h> -#include <digital_constellation_receiver_cb.h> -#include <stdexcept> -#include <gr_math.h> -#include <gr_expj.h> - - -#define M_TWOPI (2*M_PI) -#define VERBOSE_MM 0 // Used for debugging symbol timing loop -#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking - -// Public constructor - -digital_constellation_receiver_cb_sptr -digital_make_constellation_receiver_cb(digital_constellation_sptr constell, - float loop_bw, float fmin, float fmax) -{ - return gnuradio::get_initial_sptr(new digital_constellation_receiver_cb (constell, - loop_bw, - fmin, fmax)); -} - -static int ios[] = {sizeof(char), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -digital_constellation_receiver_cb::digital_constellation_receiver_cb (digital_constellation_sptr constellation, - float loop_bw, float fmin, float fmax) - : gr_block ("constellation_receiver_cb", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), - gri_control_loop(loop_bw, fmax, fmin), - d_constellation(constellation), - d_current_const_point(0) -{ - if (d_constellation->dimensionality() != 1) - throw std::runtime_error ("This receiver only works with constellations of dimension 1."); -} - -void -digital_constellation_receiver_cb::phase_error_tracking(float phase_error) -{ - advance_loop(phase_error); - phase_wrap(); - frequency_limit(); - -#if VERBOSE_COSTAS - printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", - phase_error, d_phase, d_freq, sample.real(), sample.imag(), - d_constellation->points()[d_current_const_point].real(), - d_constellation->points()[d_current_const_point].imag()); -#endif -} - -int -digital_constellation_receiver_cb::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - int i=0; - - float phase_error; - unsigned int sym_value; - gr_complex sample, nco; - - float *out_err = 0, *out_phase = 0, *out_freq = 0; - if(output_items.size() == 4) { - out_err = (float *) output_items[1]; - out_phase = (float *) output_items[2]; - out_freq = (float *) output_items[3]; - } - - while((i < noutput_items) && (i < ninput_items[0])) { - sample = in[i]; - nco = gr_expj(d_phase); // get the NCO value for derotating the current sample - sample = nco*sample; // get the downconverted symbol - - sym_value = d_constellation->decision_maker_pe(&sample, &phase_error); - phase_error_tracking(phase_error); // corrects phase and frequency offsets - - out[i] = sym_value; - - if(output_items.size() == 4) { - out_err[i] = phase_error; - out_phase[i] = d_phase; - out_freq[i] = d_freq; - } - i++; - } - - consume_each(i); - return i; -} - diff --git a/gr-digital/lib/digital_correlate_access_code_bb.cc b/gr-digital/lib/digital_correlate_access_code_bb.cc deleted file mode 100644 index f21b57d92c..0000000000 --- a/gr-digital/lib/digital_correlate_access_code_bb.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010,2011 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 <digital_correlate_access_code_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <cstdio> - - -#define VERBOSE 0 - - -digital_correlate_access_code_bb_sptr -digital_make_correlate_access_code_bb (const std::string &access_code, int threshold) -{ - return gnuradio::get_initial_sptr(new digital_correlate_access_code_bb - (access_code, threshold)); -} - - -digital_correlate_access_code_bb::digital_correlate_access_code_bb ( - const std::string &access_code, int threshold) - : gr_sync_block ("correlate_access_code_bb", - gr_make_io_signature (1, 1, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(char))), - d_data_reg(0), d_flag_reg(0), d_flag_bit(0), d_mask(0), - d_threshold(threshold) - -{ - if (!set_access_code(access_code)){ - fprintf(stderr, "digital_correlate_access_code_bb: access_code is > 64 bits\n"); - throw std::out_of_range ("access_code is > 64 bits"); - } -} - -digital_correlate_access_code_bb::~digital_correlate_access_code_bb () -{ -} - -bool -digital_correlate_access_code_bb::set_access_code( - const std::string &access_code) -{ - unsigned len = access_code.length(); // # of bytes in string - if (len > 64) - return false; - - // set len top bits to 1. - d_mask = ((~0ULL) >> (64 - len)) << (64 - len); - - d_flag_bit = 1LL << (64 - len); // Where we or-in new flag values. - // new data always goes in 0x0000000000000001 - d_access_code = 0; - for (unsigned i=0; i < 64; i++){ - d_access_code <<= 1; - if (i < len) - d_access_code |= access_code[i] & 1; // look at LSB only - } - - return true; -} - -int -digital_correlate_access_code_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - - // compute output value - unsigned int t = 0; - - t |= ((d_data_reg >> 63) & 0x1) << 0; - t |= ((d_flag_reg >> 63) & 0x1) << 1; // flag bit - out[i] = t; - - // compute hamming distance between desired access code and current data - unsigned long long wrong_bits = 0; - unsigned int nwrong = d_threshold+1; - int new_flag = 0; - - wrong_bits = (d_data_reg ^ d_access_code) & d_mask; - nwrong = gr_count_bits64(wrong_bits); - - // test for access code with up to threshold errors - new_flag = (nwrong <= d_threshold); - -#if VERBOSE - if(new_flag) { - fprintf(stderr, "access code found: %llx\n", d_access_code); - } - else { - fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg); - } -#endif - - // shift in new data and new flag - d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); - d_flag_reg = (d_flag_reg << 1); - if (new_flag) { - d_flag_reg |= d_flag_bit; - } - } - - return noutput_items; -} - diff --git a/gr-digital/lib/digital_correlate_access_code_tag_bb.cc b/gr-digital/lib/digital_correlate_access_code_tag_bb.cc deleted file mode 100644 index 95f06534e3..0000000000 --- a/gr-digital/lib/digital_correlate_access_code_tag_bb.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010-2012 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 <digital_correlate_access_code_tag_bb.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <cstdio> -#include <iostream> - -#define VERBOSE 0 - - -digital_correlate_access_code_tag_bb_sptr -digital_make_correlate_access_code_tag_bb (const std::string &access_code, - int threshold, - const std::string &tag_name) -{ - return gnuradio::get_initial_sptr(new digital_correlate_access_code_tag_bb - (access_code, threshold, tag_name)); -} - - -digital_correlate_access_code_tag_bb::digital_correlate_access_code_tag_bb ( - const std::string &access_code, int threshold, const std::string &tag_name) - : gr_sync_block ("correlate_access_code_tag_bb", - gr_make_io_signature (1, 1, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(char))), - d_data_reg(0), d_mask(0), - d_threshold(threshold), d_len(0) -{ - if (!set_access_code(access_code)) { - fprintf(stderr, "digital_correlate_access_code_tag_bb: access_code is > 64 bits\n"); - throw std::out_of_range ("access_code is > 64 bits"); - } - - std::stringstream str; - str << name() << unique_id(); - d_me = pmt::pmt_string_to_symbol(str.str()); - d_key = pmt::pmt_string_to_symbol(tag_name); -} - -digital_correlate_access_code_tag_bb::~digital_correlate_access_code_tag_bb () -{ -} - -bool -digital_correlate_access_code_tag_bb::set_access_code( - const std::string &access_code) -{ - d_len = access_code.length(); // # of bytes in string - if (d_len > 64) - return false; - - // set len top bits to 1. - d_mask = ((~0ULL) >> (64 - d_len)) << (64 - d_len); - - d_access_code = 0; - for (unsigned i=0; i < 64; i++){ - d_access_code <<= 1; - if (i < d_len) - d_access_code |= access_code[i] & 1; // look at LSB only - } - - return true; -} - -int -digital_correlate_access_code_tag_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - uint64_t abs_out_sample_cnt = nitems_written(0); - - for (int i = 0; i < noutput_items; i++){ - - out[i] = in[i]; - - // compute hamming distance between desired access code and current data - unsigned long long wrong_bits = 0; - unsigned int nwrong = d_threshold+1; - int new_flag = 0; - - wrong_bits = (d_data_reg ^ d_access_code) & d_mask; - nwrong = gr_count_bits64(wrong_bits); - - // test for access code with up to threshold errors - new_flag = (nwrong <= d_threshold); - - // shift in new data and new flag - d_data_reg = (d_data_reg << 1) | (in[i] & 0x1); - if (new_flag) { - if(VERBOSE) std::cout << "writing tag at sample " << abs_out_sample_cnt + i << std::endl; - add_item_tag(0, //stream ID - abs_out_sample_cnt + i - 64 + d_len, //sample - d_key, //frame info - pmt::pmt_t(), //data (unused) - d_me //block src id - ); - } - } - - return noutput_items; -} - diff --git a/gr-digital/lib/digital_costas_loop_cc.cc b/gr-digital/lib/digital_costas_loop_cc.cc deleted file mode 100644 index 370dc7e5c1..0000000000 --- a/gr-digital/lib/digital_costas_loop_cc.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010,2011 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 <digital_costas_loop_cc.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_sincos.h> -#include <gr_math.h> - -digital_costas_loop_cc_sptr -digital_make_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument) -{ - return gnuradio::get_initial_sptr(new digital_costas_loop_cc - (loop_bw, order)); -} - -digital_costas_loop_cc::digital_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument) - : gr_sync_block ("costas_loop_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature2 (1, 2, sizeof (gr_complex), sizeof(float))), - gri_control_loop(loop_bw, 1.0, -1.0), - d_order(order), d_phase_detector(NULL) -{ - // Set up the phase detector to use based on the constellation order - switch(d_order) { - case 2: - d_phase_detector = &digital_costas_loop_cc::phase_detector_2; - break; - - case 4: - d_phase_detector = &digital_costas_loop_cc::phase_detector_4; - break; - - case 8: - d_phase_detector = &digital_costas_loop_cc::phase_detector_8; - break; - - default: - throw std::invalid_argument("order must be 2, 4, or 8"); - break; - } -} - -float -digital_costas_loop_cc::phase_detector_8(gr_complex sample) const -{ - /* This technique splits the 8PSK constellation into 2 squashed - QPSK constellations, one when I is larger than Q and one where - Q is larger than I. The error is then calculated proportionally - to these squashed constellations by the const K = sqrt(2)-1. - - The signal magnitude must be > 1 or K will incorrectly bias - the error value. - - Ref: Z. Huang, Z. Yi, M. Zhang, K. Wang, "8PSK demodulation for - new generation DVB-S2", IEEE Proc. Int. Conf. Communications, - Circuits and Systems, Vol. 2, pp. 1447 - 1450, 2004. - */ - - float K = (sqrt(2.0) - 1); - if(fabsf(sample.real()) >= fabsf(sample.imag())) { - return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - - (sample.imag()>0 ? 1.0 : -1.0) * sample.real() * K); - } - else { - return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() * K - - (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); - } -} - -float -digital_costas_loop_cc::phase_detector_4(gr_complex sample) const -{ - - return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - - (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); -} - -float -digital_costas_loop_cc::phase_detector_2(gr_complex sample) const -{ - return (sample.real()*sample.imag()); -} - -int -digital_costas_loop_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - gr_complex *optr = (gr_complex *) output_items[0]; - float *foptr = (float *) output_items[1]; - - bool write_foptr = output_items.size() >= 2; - - float error; - gr_complex nco_out; - - if (write_foptr) { - - for (int i = 0; i < noutput_items; i++){ - nco_out = gr_expj(-d_phase); - optr[i] = iptr[i] * nco_out; - - error = (*this.*d_phase_detector)(optr[i]); - error = gr_branchless_clip(error, 1.0); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - - foptr[i] = d_freq; - } - } else { - for (int i = 0; i < noutput_items; i++){ - nco_out = gr_expj(-d_phase); - optr[i] = iptr[i] * nco_out; - - error = (*this.*d_phase_detector)(optr[i]); - error = gr_branchless_clip(error, 1.0); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - } - } - return noutput_items; -} diff --git a/gr-digital/lib/digital_cpmmod_bc.cc b/gr-digital/lib/digital_cpmmod_bc.cc deleted file mode 100644 index a95b604d14..0000000000 --- a/gr-digital/lib/digital_cpmmod_bc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * 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 <digital_cpmmod_bc.h> -#include <gr_io_signature.h> - - -// Shared pointer constructor -digital_cpmmod_bc_sptr -digital_make_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta) -{ - return gnuradio::get_initial_sptr(new digital_cpmmod_bc((gr_cpm::cpm_type)type, - h, samples_per_sym, - L, beta)); -} - - -digital_cpmmod_bc::digital_cpmmod_bc(gr_cpm::cpm_type type, float h, - unsigned samples_per_sym, - unsigned L, double beta) - : gr_hier_block2("digital_cpmmod_bc", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature2(1, 1, sizeof(gr_complex), sizeof(float))), - d_taps(gr_cpm::phase_response(type, samples_per_sym, L, beta)), - d_char_to_float(gr_make_char_to_float()), - d_pulse_shaper(gr_make_interp_fir_filter_fff(samples_per_sym, d_taps)), - d_fm(gr_make_frequency_modulator_fc(M_PI * h)) -{ - switch (type) { - case gr_cpm::LRC: - case gr_cpm::LSRC: - case gr_cpm::LREC: - case gr_cpm::TFM: - case gr_cpm::GAUSSIAN: - break; - - default: - throw std::invalid_argument("invalid CPM type"); - } - - connect(self(), 0, d_char_to_float, 0); - connect(d_char_to_float, 0, d_pulse_shaper, 0); - connect(d_pulse_shaper, 0, d_fm, 0); - connect(d_fm, 0, self(), 0); -} - diff --git a/gr-digital/lib/digital_crc32.cc b/gr-digital/lib/digital_crc32.cc deleted file mode 100644 index 8806d6e9c7..0000000000 --- a/gr-digital/lib/digital_crc32.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2011 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. - */ - -/* - * See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <digital_crc32.h> - - -// Automatically generated CRC function -// polynomial: 0x104C11DB7 -unsigned int -digital_update_crc32(unsigned int crc, const unsigned char *data, size_t len) -{ - static const unsigned int table[256] = { - 0x00000000U,0x04C11DB7U,0x09823B6EU,0x0D4326D9U, - 0x130476DCU,0x17C56B6BU,0x1A864DB2U,0x1E475005U, - 0x2608EDB8U,0x22C9F00FU,0x2F8AD6D6U,0x2B4BCB61U, - 0x350C9B64U,0x31CD86D3U,0x3C8EA00AU,0x384FBDBDU, - 0x4C11DB70U,0x48D0C6C7U,0x4593E01EU,0x4152FDA9U, - 0x5F15ADACU,0x5BD4B01BU,0x569796C2U,0x52568B75U, - 0x6A1936C8U,0x6ED82B7FU,0x639B0DA6U,0x675A1011U, - 0x791D4014U,0x7DDC5DA3U,0x709F7B7AU,0x745E66CDU, - 0x9823B6E0U,0x9CE2AB57U,0x91A18D8EU,0x95609039U, - 0x8B27C03CU,0x8FE6DD8BU,0x82A5FB52U,0x8664E6E5U, - 0xBE2B5B58U,0xBAEA46EFU,0xB7A96036U,0xB3687D81U, - 0xAD2F2D84U,0xA9EE3033U,0xA4AD16EAU,0xA06C0B5DU, - 0xD4326D90U,0xD0F37027U,0xDDB056FEU,0xD9714B49U, - 0xC7361B4CU,0xC3F706FBU,0xCEB42022U,0xCA753D95U, - 0xF23A8028U,0xF6FB9D9FU,0xFBB8BB46U,0xFF79A6F1U, - 0xE13EF6F4U,0xE5FFEB43U,0xE8BCCD9AU,0xEC7DD02DU, - 0x34867077U,0x30476DC0U,0x3D044B19U,0x39C556AEU, - 0x278206ABU,0x23431B1CU,0x2E003DC5U,0x2AC12072U, - 0x128E9DCFU,0x164F8078U,0x1B0CA6A1U,0x1FCDBB16U, - 0x018AEB13U,0x054BF6A4U,0x0808D07DU,0x0CC9CDCAU, - 0x7897AB07U,0x7C56B6B0U,0x71159069U,0x75D48DDEU, - 0x6B93DDDBU,0x6F52C06CU,0x6211E6B5U,0x66D0FB02U, - 0x5E9F46BFU,0x5A5E5B08U,0x571D7DD1U,0x53DC6066U, - 0x4D9B3063U,0x495A2DD4U,0x44190B0DU,0x40D816BAU, - 0xACA5C697U,0xA864DB20U,0xA527FDF9U,0xA1E6E04EU, - 0xBFA1B04BU,0xBB60ADFCU,0xB6238B25U,0xB2E29692U, - 0x8AAD2B2FU,0x8E6C3698U,0x832F1041U,0x87EE0DF6U, - 0x99A95DF3U,0x9D684044U,0x902B669DU,0x94EA7B2AU, - 0xE0B41DE7U,0xE4750050U,0xE9362689U,0xEDF73B3EU, - 0xF3B06B3BU,0xF771768CU,0xFA325055U,0xFEF34DE2U, - 0xC6BCF05FU,0xC27DEDE8U,0xCF3ECB31U,0xCBFFD686U, - 0xD5B88683U,0xD1799B34U,0xDC3ABDEDU,0xD8FBA05AU, - 0x690CE0EEU,0x6DCDFD59U,0x608EDB80U,0x644FC637U, - 0x7A089632U,0x7EC98B85U,0x738AAD5CU,0x774BB0EBU, - 0x4F040D56U,0x4BC510E1U,0x46863638U,0x42472B8FU, - 0x5C007B8AU,0x58C1663DU,0x558240E4U,0x51435D53U, - 0x251D3B9EU,0x21DC2629U,0x2C9F00F0U,0x285E1D47U, - 0x36194D42U,0x32D850F5U,0x3F9B762CU,0x3B5A6B9BU, - 0x0315D626U,0x07D4CB91U,0x0A97ED48U,0x0E56F0FFU, - 0x1011A0FAU,0x14D0BD4DU,0x19939B94U,0x1D528623U, - 0xF12F560EU,0xF5EE4BB9U,0xF8AD6D60U,0xFC6C70D7U, - 0xE22B20D2U,0xE6EA3D65U,0xEBA91BBCU,0xEF68060BU, - 0xD727BBB6U,0xD3E6A601U,0xDEA580D8U,0xDA649D6FU, - 0xC423CD6AU,0xC0E2D0DDU,0xCDA1F604U,0xC960EBB3U, - 0xBD3E8D7EU,0xB9FF90C9U,0xB4BCB610U,0xB07DABA7U, - 0xAE3AFBA2U,0xAAFBE615U,0xA7B8C0CCU,0xA379DD7BU, - 0x9B3660C6U,0x9FF77D71U,0x92B45BA8U,0x9675461FU, - 0x8832161AU,0x8CF30BADU,0x81B02D74U,0x857130C3U, - 0x5D8A9099U,0x594B8D2EU,0x5408ABF7U,0x50C9B640U, - 0x4E8EE645U,0x4A4FFBF2U,0x470CDD2BU,0x43CDC09CU, - 0x7B827D21U,0x7F436096U,0x7200464FU,0x76C15BF8U, - 0x68860BFDU,0x6C47164AU,0x61043093U,0x65C52D24U, - 0x119B4BE9U,0x155A565EU,0x18197087U,0x1CD86D30U, - 0x029F3D35U,0x065E2082U,0x0B1D065BU,0x0FDC1BECU, - 0x3793A651U,0x3352BBE6U,0x3E119D3FU,0x3AD08088U, - 0x2497D08DU,0x2056CD3AU,0x2D15EBE3U,0x29D4F654U, - 0xC5A92679U,0xC1683BCEU,0xCC2B1D17U,0xC8EA00A0U, - 0xD6AD50A5U,0xD26C4D12U,0xDF2F6BCBU,0xDBEE767CU, - 0xE3A1CBC1U,0xE760D676U,0xEA23F0AFU,0xEEE2ED18U, - 0xF0A5BD1DU,0xF464A0AAU,0xF9278673U,0xFDE69BC4U, - 0x89B8FD09U,0x8D79E0BEU,0x803AC667U,0x84FBDBD0U, - 0x9ABC8BD5U,0x9E7D9662U,0x933EB0BBU,0x97FFAD0CU, - 0xAFB010B1U,0xAB710D06U,0xA6322BDFU,0xA2F33668U, - 0xBCB4666DU,0xB8757BDAU,0xB5365D03U,0xB1F740B4U, - }; - - while (len > 0) - { - crc = table[*data ^ ((crc >> 24) & 0xff)] ^ (crc << 8); - data++; - len--; - } - return crc; -} - -unsigned int -digital_update_crc32(unsigned int crc, const std::string s) -{ - return digital_update_crc32(crc, (const unsigned char *) s.data(), s.size()); -} - -unsigned int -digital_crc32(const unsigned char *buf, size_t len) -{ - return digital_update_crc32(0xffffffff, buf, len) ^ 0xffffffff; -} - -unsigned int -digital_crc32(const std::string s) -{ - return digital_crc32((const unsigned char *) s.data(), s.size()); -} diff --git a/gr-digital/lib/digital_descrambler_bb.cc b/gr-digital/lib/digital_descrambler_bb.cc deleted file mode 100644 index 68cba7145e..0000000000 --- a/gr-digital/lib/digital_descrambler_bb.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 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 <digital_descrambler_bb.h> -#include <gr_io_signature.h> - -digital_descrambler_bb_sptr -digital_make_descrambler_bb(int mask, int seed, int len) -{ - return gnuradio::get_initial_sptr(new digital_descrambler_bb(mask, seed, len)); -} - -digital_descrambler_bb::digital_descrambler_bb(int mask, int seed, int len) - : gr_sync_block("descrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len) -{ -} - -int -digital_descrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_lfsr.next_bit_descramble(in[i]); - - return noutput_items; -} diff --git a/gr-digital/lib/digital_diff_decoder_bb.cc b/gr-digital/lib/digital_diff_decoder_bb.cc deleted file mode 100644 index 7b8e8726ac..0000000000 --- a/gr-digital/lib/digital_diff_decoder_bb.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010,2012 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 <digital_diff_decoder_bb.h> -#include <gr_io_signature.h> - -digital_diff_decoder_bb_sptr -digital_make_diff_decoder_bb (unsigned int modulus) -{ - return gnuradio::get_initial_sptr(new digital_diff_decoder_bb(modulus)); -} - -digital_diff_decoder_bb::digital_diff_decoder_bb (unsigned int modulus) - : gr_sync_block ("diff_decoder_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_modulus(modulus) -{ - set_history(2); // need to look at two inputs -} - -int -digital_diff_decoder_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - in += 1; // ensure that in[-1] is valid - - unsigned modulus = d_modulus; - - for (int i = 0; i < noutput_items; i++) { - out[i] = (in[i] - in[i-1]) % modulus; - } - - return noutput_items; -} diff --git a/gr-digital/lib/digital_diff_encoder_bb.cc b/gr-digital/lib/digital_diff_encoder_bb.cc deleted file mode 100644 index bfbaba98fb..0000000000 --- a/gr-digital/lib/digital_diff_encoder_bb.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010,2012 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 <digital_diff_encoder_bb.h> -#include <gr_io_signature.h> - -digital_diff_encoder_bb_sptr -digital_make_diff_encoder_bb (unsigned int modulus) -{ - return gnuradio::get_initial_sptr(new digital_diff_encoder_bb(modulus)); -} - -digital_diff_encoder_bb::digital_diff_encoder_bb (unsigned int modulus) - : gr_sync_block ("diff_encoder_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_last_out(0), d_modulus(modulus) -{ -} - -int -digital_diff_encoder_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - unsigned last_out = d_last_out; - unsigned modulus = d_modulus; - - for (int i = 0; i < noutput_items; i++) { - out[i] = (in[i] + last_out) % modulus; - last_out = out[i]; - } - - d_last_out = last_out; - return noutput_items; -} diff --git a/gr-digital/lib/digital_fll_band_edge_cc.cc b/gr-digital/lib/digital_fll_band_edge_cc.cc deleted file mode 100644 index f2cfb1020a..0000000000 --- a/gr-digital/lib/digital_fll_band_edge_cc.cc +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-2012 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 <digital_fll_band_edge_cc.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <cstdio> - -#define M_TWOPI (2*M_PI) - -float sinc(float x) -{ - if(x == 0) - return 1; - else - return sin(M_PI*x)/(M_PI*x); -} - -digital_fll_band_edge_cc_sptr -digital_make_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float bandwidth) -{ - return gnuradio::get_initial_sptr(new digital_fll_band_edge_cc (samps_per_sym, rolloff, - filter_size, bandwidth)); -} - - -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -digital_fll_band_edge_cc::digital_fll_band_edge_cc(float samps_per_sym, float rolloff, - int filter_size, float bandwidth) - : gr_sync_block("fll_band_edge_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signaturev(1, 4, iosig)), - gri_control_loop(bandwidth, M_TWOPI*(2.0/samps_per_sym), -M_TWOPI*(2.0/samps_per_sym)), - d_updated(false) -{ - // Initialize samples per symbol - if(samps_per_sym <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); - } - d_sps = samps_per_sym; - - // Initialize rolloff factor - if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); - } - d_rolloff = rolloff; - - // Initialize filter length - if(filter_size <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); - } - d_filter_size = filter_size; - - // Build the band edge filters - design_filter(d_sps, d_rolloff, d_filter_size); - d_output_hist.resize(filter_size,0); -} - -digital_fll_band_edge_cc::~digital_fll_band_edge_cc() -{ -} - - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - -void -digital_fll_band_edge_cc::set_samples_per_symbol(float sps) -{ - if(sps <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); - } - d_sps = sps; - design_filter(d_sps, d_rolloff, d_filter_size); -} - -void -digital_fll_band_edge_cc::set_rolloff(float rolloff) -{ - if(rolloff < 0 || rolloff > 1.0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); - } - d_rolloff = rolloff; - design_filter(d_sps, d_rolloff, d_filter_size); -} - -void -digital_fll_band_edge_cc::set_filter_size(int filter_size) -{ - if(filter_size <= 0) { - throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); - } - d_filter_size = filter_size; - design_filter(d_sps, d_rolloff, d_filter_size); -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - -float -digital_fll_band_edge_cc::get_samples_per_symbol() const -{ - return d_sps; -} - -float -digital_fll_band_edge_cc::get_rolloff() const -{ - return d_rolloff; -} - -int -digital_fll_band_edge_cc:: get_filter_size() const -{ - return d_filter_size; -} - - -/******************************************************************* -*******************************************************************/ - -void -digital_fll_band_edge_cc::design_filter(float samps_per_sym, - float rolloff, int filter_size) -{ - int M = rint(filter_size / samps_per_sym); - float power = 0; - - // Create the baseband filter by adding two sincs together - std::vector<float> bb_taps; - for(int i = 0; i < filter_size; i++) { - float k = -M + i*2.0/samps_per_sym; - float tap = sinc(rolloff*k - 0.5) + sinc(rolloff*k + 0.5); - power += tap; - - bb_taps.push_back(tap); - } - - d_taps_lower.resize(filter_size); - d_taps_upper.resize(filter_size); - - // Create the band edge filters by spinning the baseband - // filter up and down to the right places in frequency. - // Also, normalize the power in the filters - int N = (bb_taps.size() - 1.0)/2.0; - for(int i = 0; i < filter_size; i++) { - float tap = bb_taps[i] / power; - - float k = (-N + (int)i)/(2.0*samps_per_sym); - - gr_complex t1 = tap * gr_expj(-M_TWOPI*(1+rolloff)*k); - gr_complex t2 = tap * gr_expj(M_TWOPI*(1+rolloff)*k); - - d_taps_lower[filter_size-i-1] = t1; - d_taps_upper[filter_size-i-1] = t2; - } - - d_updated = true; - - // Set the history to ensure enough input items for each filter - set_history(filter_size+1); - d_filter_upper = gr_fir_util::create_gr_fir_ccc(d_taps_upper); - d_filter_lower = gr_fir_util::create_gr_fir_ccc(d_taps_lower); -} - -void -digital_fll_band_edge_cc::print_taps() -{ - unsigned int i; - - printf("Upper Band-edge: ["); - for(i = 0; i < d_taps_upper.size(); i++) { - printf(" %.4e + %.4ej,", d_taps_upper[i].real(), d_taps_upper[i].imag()); - } - printf("]\n\n"); - - printf("Lower Band-edge: ["); - for(i = 0; i < d_taps_lower.size(); i++) { - printf(" %.4e + %.4ej,", d_taps_lower[i].real(), d_taps_lower[i].imag()); - } - printf("]\n\n"); -} - -int -digital_fll_band_edge_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - gr_complex *out = (gr_complex*)output_items[0]; - - d_fllbuffer.reserve(d_filter_size+noutput_items); - - float *frq = NULL; - float *phs = NULL; - float *err = NULL; - if(output_items.size() == 4) { - frq = (float*)output_items[1]; - phs = (float*)output_items[2]; - err = (float*)output_items[3]; - } - - if(d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - int i; - float error; - gr_complex nco_out; - gr_complex out_upper, out_lower; - gr_complex out_uppersse, out_lowersse; - copy( d_output_hist.begin(), d_output_hist.end(), d_fllbuffer.begin()); - - for(i = 0; i < noutput_items; i++) { - nco_out = gr_expj(d_phase); - d_fllbuffer[i+d_filter_size] = in[i] * nco_out; - // Perform the dot product of the output with the filters - out_upper = 0; - out_lower = 0; - - out_upper = d_filter_lower->filter(&d_fllbuffer[i]); - out_lower = d_filter_upper->filter(&d_fllbuffer[i]); - - error = norm(out_lower) - norm(out_upper); - - advance_loop(error); - phase_wrap(); - frequency_limit(); - - if(output_items.size() == 4) { - frq[i] = d_freq; - phs[i] = d_phase; - err[i] = error; - } - } - - copy(d_fllbuffer.begin(), d_fllbuffer.begin()+noutput_items, out); - copy(d_fllbuffer.begin()+noutput_items, - d_fllbuffer.begin()+noutput_items+d_filter_size, - d_output_hist.begin()); - - return noutput_items; -} diff --git a/gr-digital/lib/digital_framer_sink_1.cc b/gr-digital/lib/digital_framer_sink_1.cc deleted file mode 100644 index ba1c5bd50e..0000000000 --- a/gr-digital/lib/digital_framer_sink_1.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010,2012 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 <digital_framer_sink_1.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <stdexcept> -#include <string.h> - -#define VERBOSE 0 - -inline void -digital_framer_sink_1::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; -} - -inline void -digital_framer_sink_1::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - d_header = 0; - d_headerbitlen_cnt = 0; -} - -inline void -digital_framer_sink_1::enter_have_header(int payload_len, - int whitener_offset) -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", - payload_len, whitener_offset); - - d_state = STATE_HAVE_HEADER; - d_packetlen = payload_len; - d_packet_whitener_offset = whitener_offset; - d_packetlen_cnt = 0; - d_packet_byte = 0; - d_packet_byte_index = 0; -} - -digital_framer_sink_1_sptr -digital_make_framer_sink_1(gr_msg_queue_sptr target_queue) -{ - return gnuradio::get_initial_sptr(new digital_framer_sink_1(target_queue)); -} - - -digital_framer_sink_1::digital_framer_sink_1(gr_msg_queue_sptr target_queue) - : gr_sync_block ("framer_sink_1", - gr_make_io_signature (1, 1, sizeof(unsigned char)), - gr_make_io_signature (0, 0, 0)), - d_target_queue(target_queue) -{ - enter_search(); -} - -digital_framer_sink_1::~digital_framer_sink_1 () -{ -} - -int -digital_framer_sink_1::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - int count=0; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - while (count < noutput_items){ - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); - - while (count < noutput_items) { - if (in[count] & 0x2){ // Found it, set up for header decode - enter_have_sync(); - break; - } - count++; - } - break; - - case STATE_HAVE_SYNC: - if (VERBOSE) - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbitlen_cnt, d_header); - - while (count < noutput_items) { // Shift bits one at a time into header - d_header = (d_header << 1) | (in[count++] & 0x1); - if (++d_headerbitlen_cnt == HEADERBITLEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - int payload_len; - int whitener_offset; - header_payload(&payload_len, &whitener_offset); - enter_have_header(payload_len, whitener_offset); - - if (d_packetlen == 0){ // check for zero-length payload - // build a zero-length message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, 0); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else - enter_search(); // bad header - break; // we're in a new state - } - } - break; - - case STATE_HAVE_HEADER: - if (VERBOSE) - fprintf(stderr,"Packet Build\n"); - - while (count < noutput_items) { // shift bits into bytes of packet one at a time - d_packet_byte = (d_packet_byte << 1) | (in[count++] & 0x1); - if (d_packet_byte_index++ == 7) { // byte is full so move to next byte - d_packet[d_packetlen_cnt++] = d_packet_byte; - d_packet_byte_index = 0; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - - // build a message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - } - break; - - default: - assert(0); - - } // switch - - } // while - - return noutput_items; -} diff --git a/gr-digital/lib/digital_glfsr_source_b.cc b/gr-digital/lib/digital_glfsr_source_b.cc deleted file mode 100644 index 63a5ffdb0a..0000000000 --- a/gr-digital/lib/digital_glfsr_source_b.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010,2012 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 <digital_glfsr_source_b.h> -#include <digital_impl_glfsr.h> -#include <gr_io_signature.h> -#include <stdexcept> - -digital_glfsr_source_b_sptr -digital_make_glfsr_source_b(int degree, bool repeat, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new digital_glfsr_source_b - (degree, repeat, mask, seed)); -} - -digital_glfsr_source_b::digital_glfsr_source_b(int degree, bool repeat, - int mask, int seed) - : gr_sync_block ("glfsr_source_b", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof(unsigned char))), - d_repeat(repeat), - d_index(0) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("digital_glfsr_source_b: degree must be between 1 and 32 inclusive"); - d_length = (unsigned int)((1ULL << degree)-1); - - if (mask == 0) - mask = digital_impl_glfsr::glfsr_mask(degree); - d_glfsr = new digital_impl_glfsr(mask, seed); -} - -digital_glfsr_source_b::~digital_glfsr_source_b() -{ - delete d_glfsr; -} - -int -digital_glfsr_source_b::work(int noutput_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 */ - - 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; - } - - return i; -} - -int -digital_glfsr_source_b::mask() const -{ - return d_glfsr->mask(); -} diff --git a/gr-digital/lib/digital_glfsr_source_f.cc b/gr-digital/lib/digital_glfsr_source_f.cc deleted file mode 100644 index 6ae84d5679..0000000000 --- a/gr-digital/lib/digital_glfsr_source_f.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010,2012 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 <digital_glfsr_source_f.h> -#include <digital_impl_glfsr.h> -#include <gr_io_signature.h> -#include <stdexcept> - -digital_glfsr_source_f_sptr -digital_make_glfsr_source_f(int degree, bool repeat, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new digital_glfsr_source_f - (degree, repeat, mask, seed)); -} - -digital_glfsr_source_f::digital_glfsr_source_f(int degree, bool repeat, - int mask, int seed) - : gr_sync_block ("glfsr_source_f", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof(float))), - d_repeat(repeat), - d_index(0) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("digital_glfsr_source_f: degree must be between 1 and 32 inclusive"); - d_length = (unsigned int)((1ULL << degree)-1); - - if (mask == 0) - mask = digital_impl_glfsr::glfsr_mask(degree); - d_glfsr = new digital_impl_glfsr(mask, seed); -} - -digital_glfsr_source_f::~digital_glfsr_source_f() -{ - delete d_glfsr; -} - -int -digital_glfsr_source_f::work(int noutput_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 */ - - 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; - } - - return i; -} - -int -digital_glfsr_source_f::mask() const -{ - return d_glfsr->mask(); -} diff --git a/gr-digital/lib/digital_impl_glfsr.cc b/gr-digital/lib/digital_impl_glfsr.cc deleted file mode 100644 index 342980e535..0000000000 --- a/gr-digital/lib/digital_impl_glfsr.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 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. - */ - -#include <digital_impl_glfsr.h> -#include <stdexcept> - -static int s_polynomial_masks[] = { - 0x00000000, - 0x00000001, // x^1 + 1 - 0x00000003, // x^2 + x^1 + 1 - 0x00000005, // x^3 + x^1 + 1 - 0x00000009, // x^4 + x^1 + 1 - 0x00000012, // x^5 + x^2 + 1 - 0x00000021, // x^6 + x^1 + 1 - 0x00000041, // x^7 + x^1 + 1 - 0x0000008E, // x^8 + x^4 + x^3 + x^2 + 1 - 0x00000108, // x^9 + x^4 + 1 - 0x00000204, // x^10 + x^4 + 1 - 0x00000402, // x^11 + x^2 + 1 - 0x00000829, // x^12 + x^6 + x^4 + x^1 + 1 - 0x0000100D, // x^13 + x^4 + x^3 + x^1 + 1 - 0x00002015, // x^14 + x^5 + x^3 + x^1 + 1 - 0x00004001, // x^15 + x^1 + 1 - 0x00008016, // x^16 + x^5 + x^3 + x^2 + 1 - 0x00010004, // x^17 + x^3 + 1 - 0x00020013, // x^18 + x^5 + x^2 + x^1 + 1 - 0x00040013, // x^19 + x^5 + x^2 + x^1 + 1 - 0x00080004, // x^20 + x^3 + 1 - 0x00100002, // x^21 + x^2 + 1 - 0x00200001, // x^22 + x^1 + 1 - 0x00400010, // x^23 + x^5 + 1 - 0x0080000D, // x^24 + x^4 + x^3 + x^1 + 1 - 0x01000004, // x^25 + x^3 + 1 - 0x02000023, // x^26 + x^6 + x^2 + x^1 + 1 - 0x04000013, // x^27 + x^5 + x^2 + x^1 + 1 - 0x08000004, // x^28 + x^3 + 1 - 0x10000002, // x^29 + x^2 + 1 - 0x20000029, // x^30 + x^4 + x^1 + 1 - 0x40000004, // x^31 + x^3 + 1 - 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1 -}; - -int digital_impl_glfsr::glfsr_mask(int degree) -{ - if (degree < 1 || degree > 32) - throw std::runtime_error("digital_impl_glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive"); - return s_polynomial_masks[degree]; -} diff --git a/gr-digital/lib/digital_impl_mpsk_snr_est.cc b/gr-digital/lib/digital_impl_mpsk_snr_est.cc deleted file mode 100644 index 38177083fc..0000000000 --- a/gr-digital/lib/digital_impl_mpsk_snr_est.cc +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_impl_mpsk_snr_est.h> -#include <cstdio> - -digital_impl_mpsk_snr_est::digital_impl_mpsk_snr_est(double alpha) -{ - set_alpha(alpha); -} - -digital_impl_mpsk_snr_est::~digital_impl_mpsk_snr_est() -{} - -void -digital_impl_mpsk_snr_est::set_alpha(double alpha) -{ - d_alpha = alpha; - d_beta = 1.0-alpha; -} - -double -digital_impl_mpsk_snr_est::alpha() const -{ - return d_alpha; -} - -int -digital_impl_mpsk_snr_est::update(int noutput_items, - const gr_complex *in) -{ - throw std::runtime_error("digital_impl_mpsk_snr_est: Unimplemented"); -} - -double -digital_impl_mpsk_snr_est::snr() -{ - throw std::runtime_error("digital_impl_mpsk_snr_est: Unimplemented"); -} - - -/********************************************************************/ - - -digital_impl_mpsk_snr_est_simple::digital_impl_mpsk_snr_est_simple( - double alpha) : - digital_impl_mpsk_snr_est(alpha) -{ - d_y1 = 0; - d_y2 = 0; -} - -int -digital_impl_mpsk_snr_est_simple::update( - int noutput_items, - const gr_complex *in) -{ - for (int i = 0; i < noutput_items; i++){ - double y1 = abs(in[i]); - d_y1 = d_alpha*y1 + d_beta*d_y1; - - double y2 = real(in[i]*in[i]); - d_y2 = d_alpha*y2 + d_beta*d_y2; - } - return noutput_items; -} - -double -digital_impl_mpsk_snr_est_simple::snr() -{ - double y1_2 = d_y1*d_y1; - double y3 = y1_2 - d_y2 + 1e-20; - return 10.0*log10(y1_2/y3); -} - - -/********************************************************************/ - - -digital_impl_mpsk_snr_est_skew::digital_impl_mpsk_snr_est_skew( - double alpha) : - digital_impl_mpsk_snr_est(alpha) -{ - d_y1 = 0; - d_y2 = 0; - d_y3 = 0; -} - - -int -digital_impl_mpsk_snr_est_skew::update( - int noutput_items, - const gr_complex *in) -{ - for (int i = 0; i < noutput_items; i++){ - double y1 = abs(in[i]); - d_y1 = d_alpha*y1 + d_beta*d_y1; - - double y2 = real(in[i]*in[i]); - d_y2 = d_alpha*y2 + d_beta*d_y2; - - // online algorithm for calculating skewness - // See: - // http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Higher-order_statistics - double d = abs(in[i]) - d_y1; - double d_i = d / (i+1); - double y3 = (d*d_i*i)*d_i*(i-1) - 3.0*d_i*d_y2; - d_y3 = d_alpha*y3 + d_beta*d_y3; - } - return noutput_items; -} - -double -digital_impl_mpsk_snr_est_skew::snr() -{ - double y3 = d_y3*d_y3 / (d_y2*d_y2*d_y2); - double y1_2 = d_y1*d_y1; - double x = y1_2 - d_y2; - return 10.0*log10(y1_2 / (x + y3*y1_2)); -} - - -/********************************************************************/ - - -digital_impl_mpsk_snr_est_m2m4::digital_impl_mpsk_snr_est_m2m4( - double alpha) : - digital_impl_mpsk_snr_est(alpha) -{ - d_y1 = 0; - d_y2 = 0; -} - -int -digital_impl_mpsk_snr_est_m2m4::update( - int noutput_items, - const gr_complex *in) -{ - for (int i = 0; i < noutput_items; i++){ - double y1 = abs(in[i])*abs(in[i]); - d_y1 = d_alpha*y1 + d_beta*d_y1; - - double y2 = abs(in[i])*abs(in[i])*abs(in[i])*abs(in[i]); - d_y2 = d_alpha*y2 + d_beta*d_y2; - } - return noutput_items; -} - -double -digital_impl_mpsk_snr_est_m2m4::snr() -{ - double y1_2 = d_y1*d_y1; - return 10.0*log10(2.0*sqrt(2*y1_2 - d_y2) / - (d_y1 - sqrt(2*y1_2 - d_y2))); -} - - -/********************************************************************/ - - -digital_impl_snr_est_m2m4::digital_impl_snr_est_m2m4( - double alpha, double ka, double kw) : - digital_impl_mpsk_snr_est(alpha) -{ - d_y1 = 0; - d_y2 = 0; - d_ka = ka; - d_kw = kw; -} - -int -digital_impl_snr_est_m2m4::update( - int noutput_items, - const gr_complex *in) -{ - for (int i = 0; i < noutput_items; i++) { - double y1 = abs(in[i])*abs(in[i]); - d_y1 = d_alpha*y1 + d_beta*d_y1; - - double y2 = abs(in[i])*abs(in[i])*abs(in[i])*abs(in[i]); - d_y2 = d_alpha*y2 + d_beta*d_y2; - } - return noutput_items; -} - -double -digital_impl_snr_est_m2m4::snr() -{ - double M2 = d_y1; - double M4 = d_y2; - double s = M2*(d_kw - 2) + - sqrt((4.0-d_ka*d_kw)*M2*M2 + M4*(d_ka+d_kw-4.0)) / - (d_ka + d_kw - 4.0); - double n = M2 - s; - - return 10.0*log10(s / n); -} - - -/********************************************************************/ - - -digital_impl_mpsk_snr_est_svr::digital_impl_mpsk_snr_est_svr( - double alpha) : - digital_impl_mpsk_snr_est(alpha) -{ - d_y1 = 0; - d_y2 = 0; -} - -int -digital_impl_mpsk_snr_est_svr::update( - int noutput_items, - const gr_complex *in) -{ - for (int i = 0; i < noutput_items; i++){ - double x = abs(in[i]); - double x1 = abs(in[i-1]); - double y1 = (x*x)*(x1*x1); - d_y1 = d_alpha*y1 + d_beta*d_y1; - - double y2 = x*x*x*x; - d_y2 = d_alpha*y2 + d_beta*d_y2; - } - return noutput_items; -} - -double -digital_impl_mpsk_snr_est_svr::snr() -{ - double x = d_y1 / (d_y2 - d_y1); - return 10.0*log10(2.*((x-1) + sqrt(x*(x-1)))); -} diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc deleted file mode 100644 index c95b560216..0000000000 --- a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_kurtotic_equalizer_cc.h> - -digital_kurtotic_equalizer_cc_sptr -digital_make_kurtotic_equalizer_cc(int num_taps, float mu) -{ - return gnuradio::get_initial_sptr(new digital_kurtotic_equalizer_cc(num_taps, mu)); -} - -digital_kurtotic_equalizer_cc::digital_kurtotic_equalizer_cc(int num_taps, float mu) - : gr_adaptive_fir_ccc("kurtotic_equalizer_cc", 1, std::vector<gr_complex>(num_taps)) -{ - set_gain(mu); - if (num_taps > 0) - d_taps[0] = 1.0; - - d_alpha_p = 0.01; - d_alpha_q = 0.01; - d_alpha_m = 0.01; - - d_p = 0.0f; - d_m = 0.0f; - d_q = gr_complex(0,0); - d_u = gr_complex(0,0); -} - diff --git a/gr-digital/lib/digital_lms_dd_equalizer_cc.cc b/gr-digital/lib/digital_lms_dd_equalizer_cc.cc deleted file mode 100644 index e2c2f16f28..0000000000 --- a/gr-digital/lib/digital_lms_dd_equalizer_cc.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_lms_dd_equalizer_cc.h> -#include <gr_io_signature.h> -#include <gr_misc.h> -#include <iostream> - -digital_lms_dd_equalizer_cc_sptr -digital_make_lms_dd_equalizer_cc(int num_taps, float mu, int sps, - digital_constellation_sptr cnst) -{ - return gnuradio::get_initial_sptr(new digital_lms_dd_equalizer_cc(num_taps, mu, - sps, cnst)); -} - -digital_lms_dd_equalizer_cc::digital_lms_dd_equalizer_cc(int num_taps, float mu, - int sps, - digital_constellation_sptr cnst) - : gr_adaptive_fir_ccc("lms_dd_equalizer_cc", sps, - std::vector<gr_complex>(num_taps, gr_complex(0,0))), - d_taps(num_taps), d_cnst(cnst) -{ - set_gain(mu); - if (num_taps > 0) - d_taps[num_taps/2] = 1.0; -} - - - - -/* -int -digital_lms_dd_equalizer_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - gr_complex acc, decision, error; - - for(int i = 0; i < noutput_items; i++) { - acc = 0; - - // Compute output - for (size_t j=0; j < d_taps.size(); j++) - acc += in[i+j] * conj(d_taps[j]); - - d_cnst->map_to_points(d_cnst->decision_maker(&acc), &decision); - error = decision - acc; - - // Update taps - for (size_t j=0; j < d_taps.size(); j++) - d_taps[j] += d_mu * conj(error) * in[i+j]; - - out[i] = acc; - } - - return noutput_items; -} -*/ diff --git a/gr-digital/lib/digital_map_bb.cc b/gr-digital/lib/digital_map_bb.cc deleted file mode 100644 index 1d8444a405..0000000000 --- a/gr-digital/lib/digital_map_bb.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2010,2012 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 <digital_map_bb.h> -#include <gr_io_signature.h> - -digital_map_bb_sptr -digital_make_map_bb (const std::vector<int> &map) -{ - return gnuradio::get_initial_sptr(new digital_map_bb (map)); -} - -digital_map_bb::digital_map_bb (const std::vector<int> &map) - : gr_sync_block ("map_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - for (int i = 0; i < 0x100; i++) - d_map[i] = i; - - unsigned int size = std::min((size_t) 0x100, map.size()); - for (unsigned int i = 0; i < size; i++) - d_map[i] = map[i]; -} - -int -digital_map_bb::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_map[in[i]]; - - return noutput_items; -} diff --git a/gr-digital/lib/digital_mpsk_receiver_cc.cc b/gr-digital/lib/digital_mpsk_receiver_cc.cc deleted file mode 100644 index 6d2bab8a4e..0000000000 --- a/gr-digital/lib/digital_mpsk_receiver_cc.cc +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2007,2010,2011 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 <gr_io_signature.h> -#include <gr_prefs.h> -#include <digital_mpsk_receiver_cc.h> -#include <stdexcept> -#include <gr_math.h> -#include <gr_expj.h> -#include <gri_mmse_fir_interpolator_cc.h> - - -#define M_TWOPI (2*M_PI) -#define VERBOSE_MM 0 // Used for debugging symbol timing loop -#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking - -// Public constructor - -digital_mpsk_receiver_cc_sptr -digital_make_mpsk_receiver_cc(unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel) -{ - return gnuradio::get_initial_sptr(new digital_mpsk_receiver_cc (M, theta, - loop_bw, - fmin, fmax, - mu, gain_mu, - omega, gain_omega, - omega_rel)); -} - -digital_mpsk_receiver_cc::digital_mpsk_receiver_cc (unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, - float omega_rel) - : gr_block ("mpsk_receiver_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - gri_control_loop(loop_bw, fmax, fmin), - d_M(M), d_theta(theta), - d_current_const_point(0), - d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega), - d_omega_rel(omega_rel), d_max_omega(0), d_min_omega(0), - d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) -{ - d_interp = new gri_mmse_fir_interpolator_cc(); - d_dl_idx = 0; - - set_omega(omega); - - if (omega <= 0.0) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - assert(d_interp->ntaps() <= DLLEN); - - // zero double length delay line. - for (unsigned int i = 0; i < 2 * DLLEN; i++) - d_dl[i] = gr_complex(0.0,0.0); - - set_modulation_order(d_M); -} - -digital_mpsk_receiver_cc::~digital_mpsk_receiver_cc () -{ - delete d_interp; -} - -void -digital_mpsk_receiver_cc::set_modulation_order(unsigned int M) -{ - // build the constellation vector from M - make_constellation(); - - // Select a phase detector and a decision maker for the modulation order - switch(d_M) { - case 2: // optimized algorithms for BPSK - d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_bpsk; //bpsk; - d_decision = &digital_mpsk_receiver_cc::decision_bpsk; - break; - - case 4: // optimized algorithms for QPSK - d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_qpsk; //qpsk; - d_decision = &digital_mpsk_receiver_cc::decision_qpsk; - break; - - default: // generic algorithms for any M (power of 2?) but not pretty - d_phase_error_detector = &digital_mpsk_receiver_cc::phase_error_detector_generic; - d_decision = &digital_mpsk_receiver_cc::decision_generic; - break; - } -} - -void -digital_mpsk_receiver_cc::set_gain_omega_rel(float omega_rel) -{ - d_omega_rel = omega_rel; - set_omega(d_omega); -} - -void -digital_mpsk_receiver_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} - -// FIXME add these back in an test difference in performance -float -digital_mpsk_receiver_cc::phase_error_detector_qpsk(gr_complex sample) const -{ - float phase_error = 0; - if(fabsf(sample.real()) > fabsf(sample.imag())) { - if(sample.real() > 0) - phase_error = -sample.imag(); - else - phase_error = sample.imag(); - } - else { - if(sample.imag() > 0) - phase_error = sample.real(); - else - phase_error = -sample.real(); - } - - return phase_error; -} - -float -digital_mpsk_receiver_cc::phase_error_detector_bpsk(gr_complex sample) const -{ - return -(sample.real()*sample.imag()); -} - -float digital_mpsk_receiver_cc::phase_error_detector_generic(gr_complex sample) const -{ - //return gr_fast_atan2f(sample*conj(d_constellation[d_current_const_point])); - return -arg(sample*conj(d_constellation[d_current_const_point])); -} - -unsigned int -digital_mpsk_receiver_cc::decision_bpsk(gr_complex sample) const -{ - return (gr_branchless_binary_slicer(sample.real()) ^ 1); - //return gr_binary_slicer(sample.real()) ^ 1; -} - -unsigned int -digital_mpsk_receiver_cc::decision_qpsk(gr_complex sample) const -{ - unsigned int index; - - //index = gr_branchless_quad_0deg_slicer(sample); - index = gr_quad_0deg_slicer(sample); - return index; -} - -unsigned int -digital_mpsk_receiver_cc::decision_generic(gr_complex sample) const -{ - unsigned int min_m = 0; - float min_s = 65535; - - // Develop all possible constellation points and find the one that minimizes - // the Euclidean distance (error) with the sample - for(unsigned int m=0; m < d_M; m++) { - gr_complex diff = norm(d_constellation[m] - sample); - - if(fabs(diff.real()) < min_s) { - min_s = fabs(diff.real()); - min_m = m; - } - } - // Return the index of the constellation point that minimizes the error - return min_m; -} - - -void -digital_mpsk_receiver_cc::make_constellation() -{ - for(unsigned int m=0; m < d_M; m++) { - d_constellation.push_back(gr_expj((M_TWOPI/d_M)*m)); - } -} - -void -digital_mpsk_receiver_cc::mm_sampler(const gr_complex symbol) -{ - gr_complex sample, nco; - - d_mu--; // skip a number of symbols between sampling - d_phase += d_freq; // increment the phase based on the frequency of the rotation - - // Keep phase clamped and not walk to infinity - while(d_phase > M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase < -M_TWOPI) - d_phase += M_TWOPI; - - nco = gr_expj(d_phase+d_theta); // get the NCO value for derotating the current sample - sample = nco*symbol; // get the downconverted symbol - - // Fill up the delay line for the interpolator - d_dl[d_dl_idx] = sample; - d_dl[(d_dl_idx + DLLEN)] = sample; // put this in the second half of the buffer for overflows - d_dl_idx = (d_dl_idx+1) % DLLEN; // Keep the delay line index in bounds -} - -void -digital_mpsk_receiver_cc::mm_error_tracking(gr_complex sample) -{ - gr_complex u, x, y; - float mm_error = 0; - - // Make sample timing corrections - - // set the delayed samples - d_p_2T = d_p_1T; - d_p_1T = d_p_0T; - d_p_0T = sample; - d_c_2T = d_c_1T; - d_c_1T = d_c_0T; - - d_current_const_point = (*this.*d_decision)(d_p_0T); // make a decision on the sample value - d_c_0T = d_constellation[d_current_const_point]; - - x = (d_c_0T - d_c_2T) * conj(d_p_1T); - y = (d_p_0T - d_p_2T) * conj(d_c_1T); - u = y - x; - mm_error = u.real(); // the error signal is in the real part - mm_error = gr_branchless_clip(mm_error, 1.0); // limit mm_val - - d_omega = d_omega + d_gain_omega * mm_error; // update omega based on loop error - d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_rel); // make sure we don't walk away - - d_mu += d_omega + d_gain_mu * mm_error; // update mu based on loop error - -#if VERBOSE_MM - printf("mm: mu: %f omega: %f mm_error: %f sample: %f+j%f constellation: %f+j%f\n", - d_mu, d_omega, mm_error, sample.real(), sample.imag(), - d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); -#endif -} - - -void -digital_mpsk_receiver_cc::phase_error_tracking(gr_complex sample) -{ - float phase_error = 0; - - // Make phase and frequency corrections based on sampled value - phase_error = (*this.*d_phase_error_detector)(sample); - - advance_loop(phase_error); - phase_wrap(); - frequency_limit(); - -#if VERBOSE_COSTAS - printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", - phase_error, d_phase, d_freq, sample.real(), sample.imag(), - d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); -#endif -} - -int -digital_mpsk_receiver_cc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int i=0, o=0; - - while((o < noutput_items) && (i < ninput_items[0])) { - while((d_mu > 1) && (i < ninput_items[0])) { - mm_sampler(in[i]); // puts symbols into a buffer and adjusts d_mu - i++; - } - - if(i < ninput_items[0]) { - gr_complex interp_sample = d_interp->interpolate(&d_dl[d_dl_idx], d_mu); - - mm_error_tracking(interp_sample); // corrects M&M sample time - phase_error_tracking(interp_sample); // corrects phase and frequency offsets - - out[o++] = interp_sample; - } - } - - #if 0 - printf("ninput_items: %d noutput_items: %d consuming: %d returning: %d\n", - ninput_items[0], noutput_items, i, o); - #endif - - consume_each(i); - return o; -} diff --git a/gr-digital/lib/digital_mpsk_snr_est_cc.cc b/gr-digital/lib/digital_mpsk_snr_est_cc.cc deleted file mode 100644 index b5a60f0d38..0000000000 --- a/gr-digital/lib/digital_mpsk_snr_est_cc.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_mpsk_snr_est_cc.h> -#include <gr_io_signature.h> -#include <cstdio> - -digital_mpsk_snr_est_cc_sptr -digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha) -{ - return gnuradio::get_initial_sptr(new digital_mpsk_snr_est_cc( - type, tag_nsamples, alpha)); -} - -digital_mpsk_snr_est_cc::digital_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha) - : gr_sync_block ("mpsk_snr_est_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ - d_snr_est = NULL; - - d_type = type; - d_nsamples = tag_nsamples; - d_count = 0; - set_alpha(alpha); - - set_type(type); - - // at least 1 estimator has to look back - set_history(2); - - std::stringstream str; - str << name() << unique_id(); - d_me = pmt::pmt_string_to_symbol(str.str()); - d_key = pmt::pmt_string_to_symbol("snr"); -} - -digital_mpsk_snr_est_cc::~digital_mpsk_snr_est_cc() -{ - if(d_snr_est) - delete d_snr_est; -} - -int -digital_mpsk_snr_est_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // This is a pass-through block; copy input to output - memcpy(output_items[0], input_items[0], - noutput_items * sizeof(gr_complex)); - - const gr_complex *in = (const gr_complex*)input_items[0]; - - // Update, calculate, and issue an SNR tag every d_nsamples - int index = 0, x = 0; - int64_t nwritten = nitems_written(0); - while(index + (d_nsamples-d_count) <= noutput_items) { - x = d_nsamples - d_count; - nwritten += x; - - // Update the SNR estimate registers from the current input - d_snr_est->update(x, &in[index]); - - // Issue a tag with the SNR data - pmt::pmt_t pmt_snr = pmt::pmt_from_double(d_snr_est->snr()); - add_item_tag(0, // stream ID - nwritten, // tag's sample number - d_key, // snr key - pmt_snr, // SNR - d_me); // block src id - - index += x; - d_count = 0; - } - - // Keep track of remaining items and update estimators - x = noutput_items - index; - d_count += x; - d_snr_est->update(x, &in[index]); - - return noutput_items; -} - -double -digital_mpsk_snr_est_cc::snr() -{ - if(d_snr_est) - return d_snr_est->snr(); - else - throw std::runtime_error("digital_mpsk_snr_est_cc:: No SNR estimator defined.\n"); -} - -snr_est_type_t -digital_mpsk_snr_est_cc::type() const -{ - return d_type; -} - -int -digital_mpsk_snr_est_cc::tag_nsample() const -{ - return d_nsamples; -} - -double -digital_mpsk_snr_est_cc::alpha() const -{ - return d_alpha; -} - -void -digital_mpsk_snr_est_cc::set_type(snr_est_type_t t) -{ - d_type = t; - - if(d_snr_est) - delete d_snr_est; - - switch (d_type) { - case(SNR_EST_SIMPLE): - d_snr_est = new digital_impl_mpsk_snr_est_simple(d_alpha); - break; - case(SNR_EST_SKEW): - d_snr_est = new digital_impl_mpsk_snr_est_skew(d_alpha); - break; - case(SNR_EST_M2M4): - d_snr_est = new digital_impl_mpsk_snr_est_m2m4(d_alpha); - break; - case(SNR_EST_SVR): - d_snr_est = new digital_impl_mpsk_snr_est_svr(d_alpha); - break; - default: - throw std::invalid_argument("digital_mpsk_snr_est_cc: unknown type specified.\n"); - } -} - -void -digital_mpsk_snr_est_cc::set_tag_nsample(int n) -{ - if(n > 0) { - d_nsamples = n; - d_count = 0; // reset state - } - else - throw std::invalid_argument("digital_mpsk_snr_est_cc: tag_nsamples can't be <= 0\n"); -} - -void -digital_mpsk_snr_est_cc::set_alpha(double alpha) -{ - if((alpha >= 0) && (alpha <= 1.0)) { - d_alpha = alpha; - if(d_snr_est) - d_snr_est->set_alpha(d_alpha); - } - else - throw std::invalid_argument("digital_mpsk_snr_est_cc: alpha must be in [0,1]\n"); -} diff --git a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc deleted file mode 100644 index 192af2591d..0000000000 --- a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010,2011 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 <digital_ofdm_cyclic_prefixer.h> -#include <gr_io_signature.h> - -digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size, - output_size)); -} - -digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size) - : gr_sync_interpolator ("ofdm_cyclic_prefixer", - gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - output_size), - d_input_size(input_size), - d_output_size(output_size) - -{ -} - -int -digital_ofdm_cyclic_prefixer::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - size_t cp_size = d_output_size - d_input_size; - unsigned int i=0, j=0; - - j = cp_size; - for(i=0; i < d_input_size; i++,j++) { - out[j] = in[i]; - } - - j = d_input_size - cp_size; - for(i=0; i < cp_size; i++, j++) { - out[i] = in[j]; - } - - return d_output_size; -} diff --git a/gr-digital/lib/digital_ofdm_frame_acquisition.cc b/gr-digital/lib/digital_ofdm_frame_acquisition.cc deleted file mode 100644 index 93b58aeca5..0000000000 --- a/gr-digital/lib/digital_ofdm_frame_acquisition.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006-2008,2010,2011 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 <digital_ofdm_frame_acquisition.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <cstdio> - -#define VERBOSE 0 -#define M_TWOPI (2*M_PI) -#define MAX_NUM_SYMBOLS 1000 - -digital_ofdm_frame_acquisition_sptr -digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, - known_symbol, max_fft_shift_len)); -} - -digital_ofdm_frame_acquisition::digital_ofdm_frame_acquisition (unsigned occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) - : gr_block ("ofdm_frame_acquisition", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*fft_length, sizeof(char)*fft_length), - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char))), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_cplen(cplen), - d_freq_shift_len(max_fft_shift_len), - d_known_symbol(known_symbol), - d_coarse_freq(0), - d_phase_count(0) -{ - d_symbol_phase_diff.resize(d_fft_length); - d_known_phase_diff.resize(d_occupied_carriers); - d_hestimate.resize(d_occupied_carriers); - - unsigned int i = 0, j = 0; - - std::fill(d_known_phase_diff.begin(), d_known_phase_diff.end(), 0); - for(i = 0; i < d_known_symbol.size()-2; i+=2) { - d_known_phase_diff[i] = norm(d_known_symbol[i] - d_known_symbol[i+2]); - } - - d_phase_lut = new gr_complex[(2*d_freq_shift_len+1) * MAX_NUM_SYMBOLS]; - for(i = 0; i <= 2*d_freq_shift_len; i++) { - for(j = 0; j < MAX_NUM_SYMBOLS; j++) { - d_phase_lut[j + i*MAX_NUM_SYMBOLS] = gr_expj(-M_TWOPI*d_cplen/d_fft_length*(i-d_freq_shift_len)*j); - } - } -} - -digital_ofdm_frame_acquisition::~digital_ofdm_frame_acquisition(void) -{ - delete [] d_phase_lut; -} - -void -digital_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = 1; -} - -gr_complex -digital_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count) -{ - // return gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count), - // sin(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count)); - - return gr_expj(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count); - - //return d_phase_lut[MAX_NUM_SYMBOLS * (d_freq_shift_len + freq_delta) + symbol_count]; -} - -void -digital_ofdm_frame_acquisition::correlate(const gr_complex *symbol, int zeros_on_left) -{ - unsigned int i,j; - - std::fill(d_symbol_phase_diff.begin(), d_symbol_phase_diff.end(), 0); - for(i = 0; i < d_fft_length-2; i++) { - d_symbol_phase_diff[i] = norm(symbol[i] - symbol[i+2]); - } - - // sweep through all possible/allowed frequency offsets and select the best - int index = 0; - float max = 0, sum=0; - for(i = zeros_on_left - d_freq_shift_len; i < zeros_on_left + d_freq_shift_len; i++) { - sum = 0; - for(j = 0; j < d_occupied_carriers; j++) { - sum += (d_known_phase_diff[j] * d_symbol_phase_diff[i+j]); - } - if(sum > max) { - max = sum; - index = i; - } - } - - // set the coarse frequency offset relative to the edge of the occupied tones - d_coarse_freq = index - zeros_on_left; -} - -void -digital_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *symbol, int zeros_on_left) -{ - unsigned int i=0; - - // Set first tap of equalizer - d_hestimate[0] = d_known_symbol[0] / - (coarse_freq_comp(d_coarse_freq,1)*symbol[zeros_on_left+d_coarse_freq]); - - // set every even tap based on known symbol - // linearly interpolate between set carriers to set zero-filled carriers - // FIXME: is this the best way to set this? - for(i = 2; i < d_occupied_carriers; i+=2) { - d_hestimate[i] = d_known_symbol[i] / - (coarse_freq_comp(d_coarse_freq,1)*(symbol[i+zeros_on_left+d_coarse_freq])); - d_hestimate[i-1] = (d_hestimate[i] + d_hestimate[i-2]) / gr_complex(2.0, 0.0); - } - - // with even number of carriers; last equalizer tap is wrong - if(!(d_occupied_carriers & 1)) { - d_hestimate[d_occupied_carriers-1] = d_hestimate[d_occupied_carriers-2]; - } - - if(VERBOSE) { - fprintf(stderr, "Equalizer setting:\n"); - for(i = 0; i < d_occupied_carriers; i++) { - gr_complex sym = coarse_freq_comp(d_coarse_freq,1)*symbol[i+zeros_on_left+d_coarse_freq]; - gr_complex output = sym * d_hestimate[i]; - fprintf(stderr, "sym: %+.4f + j%+.4f ks: %+.4f + j%+.4f eq: %+.4f + j%+.4f ==> %+.4f + j%+.4f\n", - sym .real(), sym.imag(), - d_known_symbol[i].real(), d_known_symbol[i].imag(), - d_hestimate[i].real(), d_hestimate[i].imag(), - output.real(), output.imag()); - } - fprintf(stderr, "\n"); - } -} - -int -digital_ofdm_frame_acquisition::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *symbol = (const gr_complex *)input_items[0]; - const char *signal_in = (const char *)input_items[1]; - - gr_complex *out = (gr_complex *) output_items[0]; - char *signal_out = (char *) output_items[1]; - - int unoccupied_carriers = d_fft_length - d_occupied_carriers; - int zeros_on_left = (int)ceil(unoccupied_carriers/2.0); - - if(signal_in[0]) { - d_phase_count = 1; - correlate(symbol, zeros_on_left); - calculate_equalizer(symbol, zeros_on_left); - signal_out[0] = 1; - } - else { - signal_out[0] = 0; - } - - for(unsigned int i = 0; i < d_occupied_carriers; i++) { - out[i] = d_hestimate[i]*coarse_freq_comp(d_coarse_freq,d_phase_count) - *symbol[i+zeros_on_left+d_coarse_freq]; - } - - d_phase_count++; - if(d_phase_count == MAX_NUM_SYMBOLS) { - d_phase_count = 1; - } - - consume_each(1); - return 1; -} diff --git a/gr-digital/lib/digital_ofdm_frame_sink.cc b/gr-digital/lib/digital_ofdm_frame_sink.cc deleted file mode 100644 index f8fb1bbb1d..0000000000 --- a/gr-digital/lib/digital_ofdm_frame_sink.cc +++ /dev/null @@ -1,405 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2010,2011 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 <digital_ofdm_frame_sink.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <math.h> -#include <cstdio> -#include <stdexcept> -#include <iostream> -#include <string.h> - -#define VERBOSE 0 - -inline void -digital_ofdm_frame_sink::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - -} - -inline void -digital_ofdm_frame_sink::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - - // clear state of demapper - d_byte_offset = 0; - d_partial_byte = 0; - - d_header = 0; - d_headerbytelen_cnt = 0; - - // Resetting PLL - d_freq = 0.0; - d_phase = 0.0; - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); -} - -inline void -digital_ofdm_frame_sink::enter_have_header() -{ - d_state = STATE_HAVE_HEADER; - - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - d_packetlen = (d_header >> 16) & 0x0fff; - d_packet_whitener_offset = (d_header >> 28) & 0x000f; - d_packetlen_cnt = 0; - - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", - d_packetlen, d_packet_whitener_offset); -} - - -unsigned char digital_ofdm_frame_sink::slicer(const gr_complex x) -{ - unsigned int table_size = d_sym_value_out.size(); - unsigned int min_index = 0; - float min_euclid_dist = norm(x - d_sym_position[0]); - float euclid_dist = 0; - - for (unsigned int j = 1; j < table_size; j++){ - euclid_dist = norm(x - d_sym_position[j]); - if (euclid_dist < min_euclid_dist){ - min_euclid_dist = euclid_dist; - min_index = j; - } - } - return d_sym_value_out[min_index]; -} - -unsigned int digital_ofdm_frame_sink::demapper(const gr_complex *in, - unsigned char *out) -{ - unsigned int i=0, bytes_produced=0; - gr_complex carrier; - - carrier=gr_expj(d_phase); - - gr_complex accum_error = 0.0; - //while(i < d_occupied_carriers) { - while(i < d_subcarrier_map.size()) { - if(d_nresid > 0) { - d_partial_byte |= d_resid; - d_byte_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - } - - //while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) { - //gr_complex sigrot = in[i]*carrier*d_dfe[i]; - gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i]; - - if(d_derotated_output != NULL){ - d_derotated_output[i] = sigrot; - } - - unsigned char bits = slicer(sigrot); - - gr_complex closest_sym = d_sym_position[bits]; - - accum_error += sigrot * conj(closest_sym); - - // FIX THE FOLLOWING STATEMENT - if (norm(sigrot)> 0.001) d_dfe[i] += d_eq_gain*(closest_sym/sigrot-d_dfe[i]); - - i++; - - if((8 - d_byte_offset) >= d_nbits) { - d_partial_byte |= bits << (d_byte_offset); - d_byte_offset += d_nbits; - } - else { - d_nresid = d_nbits-(8-d_byte_offset); - int mask = ((1<<(8-d_byte_offset))-1); - d_partial_byte |= (bits & mask) << d_byte_offset; - d_resid = bits >> (8-d_byte_offset); - d_byte_offset += (d_nbits - d_nresid); - } - //printf("demod symbol: %.4f + j%.4f bits: %x partial_byte: %x byte_offset: %d resid: %x nresid: %d\n", - // in[i-1].real(), in[i-1].imag(), bits, d_partial_byte, d_byte_offset, d_resid, d_nresid); - } - - if(d_byte_offset == 8) { - //printf("demod byte: %x \n\n", d_partial_byte); - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - //std::cerr << "accum_error " << accum_error << std::endl; - - float angle = arg(accum_error); - - d_freq = d_freq - d_freq_gain*angle; - d_phase = d_phase + d_freq - d_phase_gain*angle; - if (d_phase >= 2*M_PI) d_phase -= 2*M_PI; - if (d_phase <0) d_phase += 2*M_PI; - - //if(VERBOSE) - // std::cerr << angle << "\t" << d_freq << "\t" << d_phase << "\t" << std::endl; - - return bytes_produced; -} - - -digital_ofdm_frame_sink_sptr -digital_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_frame_sink(sym_position, sym_value_out, - target_queue, occupied_carriers, - phase_gain, freq_gain)); -} - - -digital_ofdm_frame_sink::digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) - : gr_sync_block ("ofdm_frame_sink", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), - d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0), - d_resid(0), d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain), - d_eq_gain(0.05) -{ - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // It seemed like such a good idea at the time... - // because we are only dealing with the occupied_carriers - // at this point, the diff_left in the following compensates - // for any offset from the 0th carrier introduced - unsigned int i,j,k; - for(i = 0; i < (d_occupied_carriers/4)+diff_left; i++) { - char c = carriers[i]; - for(j = 0; j < 4; j++) { - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; - if(k) { - d_subcarrier_map.push_back(4*i + j - diff_left); - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("digital_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_bytes_out = new unsigned char[d_occupied_carriers]; - d_dfe.resize(occupied_carriers); - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); - - set_sym_value_out(sym_position, sym_value_out); - - enter_search(); -} - -digital_ofdm_frame_sink::~digital_ofdm_frame_sink () -{ - delete [] d_bytes_out; -} - -bool -digital_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) -{ - if (sym_position.size() != sym_value_out.size()) - return false; - - if (sym_position.size()<1) - return false; - - d_sym_position = sym_position; - d_sym_value_out = sym_value_out; - d_nbits = (unsigned long)ceil(log10(float(d_sym_value_out.size())) / log10(2.0)); - - return true; -} - - -int -digital_ofdm_frame_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - const char *sig = (const char *) input_items[1]; - unsigned int j = 0; - unsigned int bytes=0; - - // If the output is connected, send it the derotated symbols - if(output_items.size() >= 1) - d_derotated_output = (gr_complex *)output_items[0]; - else - d_derotated_output = NULL; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); - - if (sig[0]) { // Found it, set up for header decode - enter_have_sync(); - } - break; - - case STATE_HAVE_SYNC: - // only demod after getting the preamble signal; otherwise, the - // equalizer taps will screw with the PLL performance - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_SYNC\n"); - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbytelen_cnt, d_header); - } - - j = 0; - while(j < bytes) { - d_header = (d_header << 8) | (d_bytes_out[j] & 0xFF); - j++; - - if (++d_headerbytelen_cnt == HEADERBYTELEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - enter_have_header(); - - if (VERBOSE) - printf("\nPacket Length: %d\n", d_packetlen); - - while((j < bytes) && (d_packetlen_cnt < d_packetlen)) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - } - - if(d_packetlen_cnt == d_packetlen) { - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else { - enter_search(); // bad header - } - } - } - break; - - case STATE_HAVE_HEADER: - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_HEADER at %d, length of %d\n", d_packetlen_cnt, d_packetlen); - fprintf(stderr,"Packet Build\n"); - } - - j = 0; - while(j < bytes) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - // build a message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - break; - - default: - assert(0); - - } // switch - - return 1; -} diff --git a/gr-digital/lib/digital_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc deleted file mode 100644 index 72b9e82a82..0000000000 --- a/gr-digital/lib/digital_ofdm_insert_preamble.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010-2012 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <digital_ofdm_insert_preamble.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> -#include <string.h> - -digital_ofdm_insert_preamble_sptr -digital_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_insert_preamble(fft_length, - preamble)); -} - -digital_ofdm_insert_preamble::digital_ofdm_insert_preamble - (int fft_length, - const std::vector<std::vector<gr_complex> > &preamble) - : gr_block("ofdm_insert_preamble", - gr_make_io_signature2(1, 2, - sizeof(gr_complex)*fft_length, - sizeof(char)), - gr_make_io_signature2(1, 2, - sizeof(gr_complex)*fft_length, - sizeof(char))), - d_fft_length(fft_length), - d_preamble(preamble), - d_state(ST_IDLE), - d_nsymbols_output(0), - d_pending_flag(0) -{ - // sanity check preamble symbols - for(size_t i = 0; i < d_preamble.size(); i++) { - if(d_preamble[i].size() != (size_t) d_fft_length) - throw std::invalid_argument("digital_ofdm_insert_preamble: invalid length for preamble symbol"); - } - - enter_idle(); -} - - -digital_ofdm_insert_preamble::~digital_ofdm_insert_preamble() -{ -} - -void digital_ofdm_insert_preamble::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - ninput_items_required[0] = noutput_items; -} - -int -digital_ofdm_insert_preamble::general_work(int noutput_items, - gr_vector_int &ninput_items_v, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ninput_items = ninput_items_v.size()==2?std::min(ninput_items_v[0], ninput_items_v[1]):ninput_items_v[0]; - const gr_complex *in_sym = (const gr_complex *) input_items[0]; - const unsigned char *in_flag = 0; - if (input_items.size() == 2) - in_flag = (const unsigned char *) input_items[1]; - - gr_complex *out_sym = (gr_complex *) output_items[0]; - unsigned char *out_flag = 0; - if (output_items.size() == 2) - out_flag = (unsigned char *) output_items[1]; - - - int no = 0; // number items output - int ni = 0; // number items read from input - - -#define write_out_flag() \ - do { if (out_flag) \ - out_flag[no] = d_pending_flag; \ - d_pending_flag = 0; \ - } while(0) - - - while (no < noutput_items && ni < ninput_items){ - switch(d_state){ - case ST_IDLE: - if (in_flag && in_flag[ni] & 0x1) // this is first symbol of new payload - enter_preamble(); - else - ni++; // eat one input symbol - break; - - case ST_PREAMBLE: - assert(!in_flag || in_flag[ni] & 0x1); - if (d_nsymbols_output >= (int) d_preamble.size()){ - // we've output all the preamble - enter_first_payload(); - } - else { - memcpy(&out_sym[no * d_fft_length], - &d_preamble[d_nsymbols_output][0], - d_fft_length*sizeof(gr_complex)); - - write_out_flag(); - no++; - d_nsymbols_output++; - } - break; - - case ST_FIRST_PAYLOAD: - // copy first payload symbol from input to output - memcpy(&out_sym[no * d_fft_length], - &in_sym[ni * d_fft_length], - d_fft_length * sizeof(gr_complex)); - - write_out_flag(); - no++; - ni++; - enter_payload(); - break; - - case ST_PAYLOAD: - if (in_flag && in_flag[ni] & 0x1){ // this is first symbol of a new payload - enter_preamble(); - break; - } - - // copy a symbol from input to output - memcpy(&out_sym[no * d_fft_length], - &in_sym[ni * d_fft_length], - d_fft_length * sizeof(gr_complex)); - - write_out_flag(); - no++; - ni++; - break; - - default: - std::cerr << "digital_ofdm_insert_preamble: (can't happen) invalid state, resetting\n"; - enter_idle(); - } - } - - consume_each(ni); - return no; -} - -void -digital_ofdm_insert_preamble::enter_idle() -{ - d_state = ST_IDLE; - d_nsymbols_output = 0; - d_pending_flag = 0; -} - -void -digital_ofdm_insert_preamble::enter_preamble() -{ - d_state = ST_PREAMBLE; - d_nsymbols_output = 0; - d_pending_flag = 1; -} - -void -digital_ofdm_insert_preamble::enter_first_payload() -{ - d_state = ST_FIRST_PAYLOAD; -} - -void -digital_ofdm_insert_preamble::enter_payload() -{ - d_state = ST_PAYLOAD; -} diff --git a/gr-digital/lib/digital_ofdm_mapper_bcv.cc b/gr-digital/lib/digital_ofdm_mapper_bcv.cc deleted file mode 100644 index cf3d08703a..0000000000 --- a/gr-digital/lib/digital_ofdm_mapper_bcv.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006-2008,2010,2011 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 <digital_ofdm_mapper_bcv.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <string.h> - -digital_ofdm_mapper_bcv_sptr -digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_mapper_bcv (constellation, msgq_limit, - occupied_carriers, fft_length)); -} - -// Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -digital_ofdm_mapper_bcv::digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) - : gr_sync_block ("ofdm_mapper_bcv", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), - d_constellation(constellation), - d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_bit_offset(0), - d_pending_flag(0), - d_resid(0), - d_nresid(0) -{ - if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("digital_ofdm_mapper_bcv: occupied carriers must be <= fft_length"); - - // this is not the final form of this solution since we still use the occupied_tones concept, - // which would get us into trouble if the number of carriers we seek is greater than the occupied carriers. - // Eventually, we will get rid of the occupied_carriers concept. - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // find out how many zeros to pad on the sides; the difference between the fft length and the subcarrier - // mapping size in chunks of four. This is the number to pack on the left and this number plus any - // residual nulls (if odd) will be packed on the right. - diff = (d_fft_length/4 - carriers.length())/2; - - unsigned int i,j,k; - for(i = 0; i < carriers.length(); i++) { - char c = carriers[i]; // get the current hex character from the string - for(j = 0; j < 4; j++) { // walk through all four bits - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; // convert to int and extract next bit - if(k) { // if bit is a 1, - d_subcarrier_map.push_back(4*(i+diff) + j); // use this subcarrier - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("digital_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0)); -} - -digital_ofdm_mapper_bcv::~digital_ofdm_mapper_bcv(void) -{ -} - -int digital_ofdm_mapper_bcv::randsym() -{ - return (rand() % d_constellation.size()); -} - -int -digital_ofdm_mapper_bcv::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - unsigned int i=0; - - //printf("OFDM BPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); - - if(d_eof) { - return -1; - } - - if(!d_msg) { - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - d_bit_offset = 0; - d_pending_flag = 1; // new packet, write start of packet flag - - if((d_msg->length() == 0) && (d_msg->type() == 1)) { - d_msg.reset(); - return -1; // We're done; no more messages coming. - } - } - - char *out_flag = 0; - if(output_items.size() == 2) - out_flag = (char *) output_items[1]; - - - // Build a single symbol: - // Initialize all bins to 0 to set unused carriers - memset(out, 0, d_fft_length*sizeof(gr_complex)); - - i = 0; - unsigned char bits = 0; - //while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { - while((d_msg_offset < d_msg->length()) && (i < d_subcarrier_map.size())) { - - // need new data to process - if(d_bit_offset == 0) { - d_msgbytes = d_msg->msg()[d_msg_offset]; - //printf("mod message byte: %x\n", d_msgbytes); - } - - if(d_nresid > 0) { - // take the residual bits, fill out nbits with info from the new byte, and put them in the symbol - d_resid |= (((1 << d_nresid)-1) & d_msgbytes) << (d_nbits - d_nresid); - bits = d_resid; - - out[d_subcarrier_map[i]] = d_constellation[bits]; - i++; - - d_bit_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - //printf("mod bit(r): %x resid: %x nresid: %d bit_offset: %d\n", - // bits, d_resid, d_nresid, d_bit_offset); - } - else { - if((8 - d_bit_offset) >= d_nbits) { // test to make sure we can fit nbits - // take the nbits number of bits at a time from the byte to add to the symbol - bits = ((1 << d_nbits)-1) & (d_msgbytes >> d_bit_offset); - d_bit_offset += d_nbits; - - out[d_subcarrier_map[i]] = d_constellation[bits]; - i++; - } - else { // if we can't fit nbits, store them for the next - // saves d_nresid bits of this message where d_nresid < d_nbits - unsigned int extra = 8-d_bit_offset; - d_resid = ((1 << extra)-1) & (d_msgbytes >> d_bit_offset); - d_bit_offset += extra; - d_nresid = d_nbits - extra; - } - - } - - if(d_bit_offset == 8) { - d_bit_offset = 0; - d_msg_offset++; - } - } - - // Ran out of data to put in symbol - if (d_msg_offset == d_msg->length()) { - if(d_nresid > 0) { - d_resid |= 0x00; - bits = d_resid; - d_nresid = 0; - d_resid = 0; - } - - //while(i < d_occupied_carriers) { // finish filling out the symbol - while(i < d_subcarrier_map.size()) { // finish filling out the symbol - out[d_subcarrier_map[i]] = d_constellation[randsym()]; - - i++; - } - - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); // finished packet, free message - assert(d_bit_offset == 0); - } - - if (out_flag) - out_flag[0] = d_pending_flag; - d_pending_flag = 0; - - return 1; // produced symbol -} diff --git a/gr-digital/lib/digital_ofdm_sampler.cc b/gr-digital/lib/digital_ofdm_sampler.cc deleted file mode 100644 index cab8c2ba93..0000000000 --- a/gr-digital/lib/digital_ofdm_sampler.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2010,2011 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 <digital_ofdm_sampler.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <cstdio> - -digital_ofdm_sampler_sptr -digital_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_sampler (fft_length, symbol_length, timeout)); -} - -digital_ofdm_sampler::digital_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) - : gr_block ("ofdm_sampler", - gr_make_io_signature2 (2, 2, sizeof (gr_complex), sizeof(char)), - gr_make_io_signature2 (2, 2, sizeof (gr_complex)*fft_length, sizeof(char)*fft_length)), - d_state(STATE_NO_SIG), d_timeout_max(timeout), d_fft_length(fft_length), d_symbol_length(symbol_length) -{ - set_relative_rate(1.0/(double) fft_length); // buffer allocator hint -} - -void -digital_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - // FIXME do we need more - //int nreqd = (noutput_items-1) * d_symbol_length + d_fft_length; - int nreqd = d_symbol_length + d_fft_length; - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = nreqd; -} - - -int -digital_ofdm_sampler::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (const gr_complex *) input_items[0]; - const char *trigger = (const char *) input_items[1]; - - gr_complex *optr = (gr_complex *) output_items[0]; - char *outsig = (char *) output_items[1]; - - //FIXME: we only process a single OFDM symbol at a time; after the preamble, we can - // process a few at a time as long as we always look out for the next preamble. - - unsigned int index=d_fft_length; // start one fft length into the input so we can always look back this far - - outsig[0] = 0; // set output to no signal by default - - // Search for a preamble trigger signal during the next symbol length - while((d_state != STATE_PREAMBLE) && (index <= (d_symbol_length+d_fft_length))) { - if(trigger[index]) { - outsig[0] = 1; // tell the next block there is a preamble coming - d_state = STATE_PREAMBLE; - } - else - index++; - } - - unsigned int i, pos, ret; - switch(d_state) { - case(STATE_PREAMBLE): - // When we found a preamble trigger, get it and set the symbol boundary here - for(i = (index - d_fft_length + 1); i <= index; i++) { - *optr++ = iptr[i]; - } - - d_timeout = d_timeout_max; // tell the system to expect at least this many symbols for a frame - d_state = STATE_FRAME; - consume_each(index - d_fft_length + 1); // consume up to one fft_length away to keep the history - ret = 1; - break; - - case(STATE_FRAME): - // use this state when we have processed a preamble and are getting the rest of the frames - //FIXME: we could also have a power squelch system here to enter STATE_NO_SIG if no power is received - - // skip over fft length history and cyclic prefix - pos = d_symbol_length; // keeps track of where we are in the input buffer - while(pos < d_symbol_length + d_fft_length) { - *optr++ = iptr[pos++]; - } - - if(d_timeout-- == 0) { - printf("TIMEOUT\n"); - d_state = STATE_NO_SIG; - } - - consume_each(d_symbol_length); // jump up by 1 fft length and the cyclic prefix length - ret = 1; - break; - - case(STATE_NO_SIG): - default: - consume_each(index-d_fft_length); // consume everything we've gone through so far leaving the fft length history - ret = 0; - break; - } - - return ret; -} diff --git a/gr-digital/lib/digital_packet_sink.cc b/gr-digital/lib/digital_packet_sink.cc deleted file mode 100644 index 92521376fd..0000000000 --- a/gr-digital/lib/digital_packet_sink.cc +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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 <digital_packet_sink.h> -#include <gr_io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <gr_count_bits.h> -#include <string.h> - -#define VERBOSE 0 - -static const int DEFAULT_THRESHOLD = 12; // detect access code with up to DEFAULT_THRESHOLD bits wrong - -inline void -digital_packet_sink::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - d_shift_reg = 0; -} - -inline void -digital_packet_sink::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - d_header = 0; - d_headerbitlen_cnt = 0; -} - -inline void -digital_packet_sink::enter_have_header(int payload_len) -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d)\n", payload_len); - - d_state = STATE_HAVE_HEADER; - d_packetlen = payload_len; - d_packetlen_cnt = 0; - d_packet_byte = 0; - d_packet_byte_index = 0; -} - -digital_packet_sink_sptr -digital_make_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, int threshold) -{ - return gnuradio::get_initial_sptr(new digital_packet_sink (sync_vector, target_queue, threshold)); -} - - -digital_packet_sink::digital_packet_sink (const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, int threshold) - : gr_sync_block ("packet_sink", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signature (0, 0, 0)), - d_target_queue(target_queue), d_threshold(threshold == -1 ? DEFAULT_THRESHOLD : threshold) -{ - d_sync_vector = 0; - for(int i=0;i<8;i++){ - d_sync_vector <<= 8; - d_sync_vector |= sync_vector[i]; - } - - enter_search(); -} - -digital_packet_sink::~digital_packet_sink () -{ -} - -int -digital_packet_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *inbuf = (float *) input_items[0]; - int count=0; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"),fflush(stderr); - - while (count<noutput_items) { - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for sync vector - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n",noutput_items),fflush(stderr); - - while (count < noutput_items) { - if(slice(inbuf[count++])) - d_shift_reg = (d_shift_reg << 1) | 1; - else - d_shift_reg = d_shift_reg << 1; - - // Compute popcnt of putative sync vector - if(gr_count_bits64 (d_shift_reg ^ d_sync_vector) <= d_threshold) { - // Found it, set up for header decode - enter_have_sync(); - break; - } - } - break; - - case STATE_HAVE_SYNC: - if (VERBOSE) - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", d_headerbitlen_cnt, d_header), - fflush(stderr); - - while (count < noutput_items) { // Shift bits one at a time into header - if(slice(inbuf[count++])) - d_header = (d_header << 1) | 1; - else - d_header = d_header << 1; - - if (++d_headerbitlen_cnt == HEADERBITLEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - int payload_len = header_payload_len(); - if (payload_len <= MAX_PKT_LEN) // reasonable? - enter_have_header(payload_len); // yes. - else - enter_search(); // no. - } - else - enter_search(); // no. - break; // we're in a new state - } - } - break; - - case STATE_HAVE_HEADER: - if (VERBOSE) - fprintf(stderr,"Packet Build\n"),fflush(stderr); - - while (count < noutput_items) { // shift bits into bytes of packet one at a time - if(slice(inbuf[count++])) - d_packet_byte = (d_packet_byte << 1) | 1; - else - d_packet_byte = d_packet_byte << 1; - - if (d_packet_byte_index++ == 7) { // byte is full so move to next byte - d_packet[d_packetlen_cnt++] = d_packet_byte; - d_packet_byte_index = 0; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - - // build a message - gr_message_sptr msg = gr_make_message(0, 0, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - } - break; - - default: - assert(0); - - } // switch - - } // while - - return noutput_items; -} - diff --git a/gr-digital/lib/digital_pfb_clock_sync_ccf.cc b/gr-digital/lib/digital_pfb_clock_sync_ccf.cc deleted file mode 100644 index 1a2d5970ba..0000000000 --- a/gr-digital/lib/digital_pfb_clock_sync_ccf.cc +++ /dev/null @@ -1,440 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009-2012 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 <cstdio> -#include <cmath> - -#include <digital_pfb_clock_sync_ccf.h> -#include <gr_fir_ccf.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -digital_pfb_clock_sync_ccf_sptr -digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) -{ - return gnuradio::get_initial_sptr(new digital_pfb_clock_sync_ccf - (sps, loop_bw, taps, - filter_size, - init_phase, - max_rate_deviation, - osps)); -} - -static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -digital_pfb_clock_sync_ccf::digital_pfb_clock_sync_ccf (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) - : gr_block ("pfb_clock_sync_ccf", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation), - d_osps(osps), d_error(0), d_out_idx(0) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Set the damping factor for a critically damped system - d_damping = sqrtf(2.0f)/2.0f; - - // Set the bandwidth, which will then call update_gains() - set_loop_bandwidth(loop_bw); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_ccf*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_ccf*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -digital_pfb_clock_sync_ccf::~digital_pfb_clock_sync_ccf () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -digital_pfb_clock_sync_ccf::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - - - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - - -void -digital_pfb_clock_sync_ccf::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -digital_pfb_clock_sync_ccf::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -digital_pfb_clock_sync_ccf::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -digital_pfb_clock_sync_ccf::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_cc: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -digital_pfb_clock_sync_ccf::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -digital_pfb_clock_sync_ccf::get_damping_factor() const -{ - return d_damping; -} - -float -digital_pfb_clock_sync_ccf::get_alpha() const -{ - return d_alpha; -} - -float -digital_pfb_clock_sync_ccf::get_beta() const -{ - return d_beta; -} - -float -digital_pfb_clock_sync_ccf::get_clock_rate() const -{ - return d_rate_f; -} - -/******************************************************************* -*******************************************************************/ - -void -digital_pfb_clock_sync_ccf::update_gains() -{ - float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); - d_alpha = (4*d_damping*d_loop_bw) / denom; - d_beta = (4*d_loop_bw*d_loop_bw) / denom; -} - - -void -digital_pfb_clock_sync_ccf::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - // Make sure there is enough output space for d_osps outputs/input. - set_output_multiple(d_osps); - - d_updated = true; -} - -void -digital_pfb_clock_sync_ccf::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - std::vector<float> diff_filter(3); - diff_filter[0] = -1; - diff_filter[1] = 0; - diff_filter[2] = 1; - - float pwr = 0; - difftaps.push_back(0); - for(unsigned int i = 0; i < newtaps.size()-2; i++) { - float tap = 0; - for(int j = 0; j < 3; j++) { - tap += diff_filter[j]*newtaps[i+j]; - pwr += fabsf(tap); - } - difftaps.push_back(tap); - } - difftaps.push_back(0); - - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] *= pwr; - } -} - -std::string -digital_pfb_clock_sync_ccf::get_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_taps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_taps[i][j] << ", "; - } - str << d_taps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::string -digital_pfb_clock_sync_ccf::get_diff_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_dtaps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_dtaps[i][j] << ", "; - } - str << d_dtaps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::vector< std::vector<float> > -digital_pfb_clock_sync_ccf::get_taps() -{ - return d_taps; -} - -std::vector< std::vector<float> > -digital_pfb_clock_sync_ccf::get_diff_taps() -{ - return d_dtaps; -} - -std::vector<float> -digital_pfb_clock_sync_ccf::get_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -digital_pfb_clock_sync_ccf::get_diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - - -int -digital_pfb_clock_sync_ccf::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - float *err = NULL, *outrate = NULL, *outk = NULL; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; - - int i = 0, count = 0; - float error_r, error_i; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - while(d_out_idx < d_osps) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); - d_k = d_k + d_rate_i + d_rate_f; // update phase - d_out_idx++; - - if(output_items.size() == 4) { - err[i] = d_error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - - // We've run out of output items we can create; return now. - if(i+d_out_idx >= noutput_items) { - consume_each(count); - return i; - } - } - - // reset here; if we didn't complete a full osps samples last time, - // the early return would take care of it. - d_out_idx = 0; - - // Update the phase and rate estimates for this symbol - gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); - error_r = out[i].real() * diff.real(); - error_i = out[i].imag() * diff.imag(); - d_error = (error_i + error_r) / 2.0; // average error from I&Q channel - - // Run the control loop to update the current phase (k) and - // tracking rate estimates based on the error value - d_rate_f = d_rate_f + d_beta*d_error; - d_k = d_k + d_alpha*d_error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i+=d_osps; - count += (int)floor(d_sps); - } - - consume_each(count); - return i; -} diff --git a/gr-digital/lib/digital_pfb_clock_sync_fff.cc b/gr-digital/lib/digital_pfb_clock_sync_fff.cc deleted file mode 100644 index 0e7d2a52da..0000000000 --- a/gr-digital/lib/digital_pfb_clock_sync_fff.cc +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010,2012 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 <cstdio> -#include <cmath> - -#include <digital_pfb_clock_sync_fff.h> -#include <gr_fir_fff.h> -#include <gr_fir_util.h> -#include <gr_io_signature.h> -#include <gr_math.h> - -digital_pfb_clock_sync_fff_sptr -digital_make_pfb_clock_sync_fff(double sps, float gain, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) -{ - return gnuradio::get_initial_sptr(new digital_pfb_clock_sync_fff - (sps, gain, taps, - filter_size, - init_phase, - max_rate_deviation, - osps)); -} - -static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)}; -static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -digital_pfb_clock_sync_fff::digital_pfb_clock_sync_fff (double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size, - float init_phase, - float max_rate_deviation, - int osps) - : gr_block ("pfb_clock_sync_fff", - gr_make_io_signature (1, 1, sizeof(float)), - gr_make_io_signaturev (1, 4, iosig)), - d_updated (false), d_nfilters(filter_size), - d_max_dev(max_rate_deviation), - d_osps(osps), d_error(0), d_out_idx(0) -{ - d_nfilters = filter_size; - d_sps = floor(sps); - - // Set the damping factor for a critically damped system - d_damping = sqrtf(2.0f)/2.0f; - - // Set the bandwidth, which will then call update_gains() - set_loop_bandwidth(loop_bw); - - // Store the last filter between calls to work - // The accumulator keeps track of overflow to increment the stride correctly. - // set it here to the fractional difference based on the initial phaes - d_k = init_phase; - d_rate = (sps-floor(sps))*(double)d_nfilters; - d_rate_i = (int)floor(d_rate); - d_rate_f = d_rate - (float)d_rate_i; - d_filtnum = (int)floor(d_k); - - d_filters = std::vector<gr_fir_fff*>(d_nfilters); - d_diff_filters = std::vector<gr_fir_fff*>(d_nfilters); - - // Create an FIR filter for each channel and zero out the taps - std::vector<float> vtaps(0, d_nfilters); - for(int i = 0; i < d_nfilters; i++) { - d_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - d_diff_filters[i] = gr_fir_util::create_gr_fir_fff(vtaps); - } - - // Now, actually set the filters' taps - std::vector<float> dtaps; - create_diff_taps(taps, dtaps); - set_taps(taps, d_taps, d_filters); - set_taps(dtaps, d_dtaps, d_diff_filters); -} - -digital_pfb_clock_sync_fff::~digital_pfb_clock_sync_fff () -{ - for(int i = 0; i < d_nfilters; i++) { - delete d_filters[i]; - delete d_diff_filters[i]; - } -} - -bool -digital_pfb_clock_sync_fff::check_topology(int ninputs, int noutputs) -{ - return noutputs == 1 || noutputs == 4; -} - -/******************************************************************* - SET FUNCTIONS -*******************************************************************/ - - -void -digital_pfb_clock_sync_fff::set_loop_bandwidth(float bw) -{ - if(bw < 0) { - throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid bandwidth. Must be >= 0."); - } - - d_loop_bw = bw; - update_gains(); -} - -void -digital_pfb_clock_sync_fff::set_damping_factor(float df) -{ - if(df < 0 || df > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid damping factor. Must be in [0,1]."); - } - - d_damping = df; - update_gains(); -} - -void -digital_pfb_clock_sync_fff::set_alpha(float alpha) -{ - if(alpha < 0 || alpha > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid alpha. Must be in [0,1]."); - } - d_alpha = alpha; -} - -void -digital_pfb_clock_sync_fff::set_beta(float beta) -{ - if(beta < 0 || beta > 1.0) { - throw std::out_of_range ("digital_pfb_clock_sync_fff: invalid beta. Must be in [0,1]."); - } - d_beta = beta; -} - -/******************************************************************* - GET FUNCTIONS -*******************************************************************/ - - -float -digital_pfb_clock_sync_fff::get_loop_bandwidth() const -{ - return d_loop_bw; -} - -float -digital_pfb_clock_sync_fff::get_damping_factor() const -{ - return d_damping; -} - -float -digital_pfb_clock_sync_fff::get_alpha() const -{ - return d_alpha; -} - -float -digital_pfb_clock_sync_fff::get_beta() const -{ - return d_beta; -} - -float -digital_pfb_clock_sync_fff::get_clock_rate() const -{ - return d_rate_f; -} - -/******************************************************************* -*******************************************************************/ - -void -digital_pfb_clock_sync_fff::update_gains() -{ - float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); - d_alpha = (4*d_damping*d_loop_bw) / denom; - d_beta = (4*d_loop_bw*d_loop_bw) / denom; -} - - -void -digital_pfb_clock_sync_fff::set_taps (const std::vector<float> &newtaps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter) -{ - int i,j; - - unsigned int ntaps = newtaps.size(); - d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); - - // Create d_numchan vectors to store each channel's taps - ourtaps.resize(d_nfilters); - - // Make a vector of the taps plus fill it out with 0's to fill - // each polyphase filter with exactly d_taps_per_filter - std::vector<float> tmp_taps; - tmp_taps = newtaps; - while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { - tmp_taps.push_back(0.0); - } - - // Partition the filter - for(i = 0; i < d_nfilters; i++) { - // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out - ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { - ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; - } - - // Build a filter for each channel and add it's taps to it - ourfilter[i]->set_taps(ourtaps[i]); - } - - // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter + d_sps); - - // Make sure there is enough output space for d_osps outputs/input. - set_output_multiple(d_osps); - - d_updated = true; -} - -void -digital_pfb_clock_sync_fff::create_diff_taps(const std::vector<float> &newtaps, - std::vector<float> &difftaps) -{ - std::vector<float> diff_filter(3); - diff_filter[0] = -1; - diff_filter[1] = 0; - diff_filter[2] = 1; - - float pwr = 0; - difftaps.push_back(0); - for(unsigned int i = 0; i < newtaps.size()-2; i++) { - float tap = 0; - for(int j = 0; j < 3; j++) { - tap += diff_filter[j]*newtaps[i+j]; - pwr += fabsf(tap); - } - difftaps.push_back(tap); - } - difftaps.push_back(0); - - for(unsigned int i = 0; i < difftaps.size(); i++) { - difftaps[i] *= pwr; - } -} - -std::string -digital_pfb_clock_sync_fff::get_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_taps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_taps[i][j] << ", "; - } - str << d_taps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::string -digital_pfb_clock_sync_fff::get_diff_taps_as_string() -{ - int i, j; - std::stringstream str; - str.precision(4); - str.setf(std::ios::scientific); - - str << "[ "; - for(i = 0; i < d_nfilters; i++) { - str << "[" << d_dtaps[i][0] << ", "; - for(j = 1; j < d_taps_per_filter-1; j++) { - str << d_dtaps[i][j] << ", "; - } - str << d_dtaps[i][j] << "],"; - } - str << " ]" << std::endl; - - return str.str(); -} - -std::vector< std::vector<float> > -digital_pfb_clock_sync_fff::get_taps() -{ - return d_taps; -} - -std::vector< std::vector<float> > -digital_pfb_clock_sync_fff::get_diff_taps() -{ - return d_dtaps; -} - -std::vector<float> -digital_pfb_clock_sync_fff::get_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_taps[channel][i]); - } - return taps; -} - -std::vector<float> -digital_pfb_clock_sync_fff::get_diff_channel_taps(int channel) -{ - std::vector<float> taps; - for(int i = 0; i < d_taps_per_filter; i++) { - taps.push_back(d_dtaps[channel][i]); - } - return taps; -} - -int -digital_pfb_clock_sync_fff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - float *in = (float *) input_items[0]; - float *out = (float *) output_items[0]; - - float *err = NULL, *outrate = NULL, *outk = NULL; - if(output_items.size() == 4) { - err = (float *) output_items[1]; - outrate = (float*)output_items[2]; - outk = (float*)output_items[3]; - } - - if (d_updated) { - d_updated = false; - return 0; // history requirements may have changed. - } - - // We need this many to process one output - int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; - - int i = 0, count = 0; - - // produce output as long as we can and there are enough input samples - while((i < noutput_items) && (count < nrequired)) { - while(d_out_idx < d_osps) { - d_filtnum = (int)floor(d_k); - - // Keep the current filter number in [0, d_nfilters] - // If we've run beyond the last filter, wrap around and go to next sample - // If we've go below 0, wrap around and go to previous sample - while(d_filtnum >= d_nfilters) { - d_k -= d_nfilters; - d_filtnum -= d_nfilters; - count += 1; - } - while(d_filtnum < 0) { - d_k += d_nfilters; - d_filtnum += d_nfilters; - count -= 1; - } - - out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); - d_k = d_k + d_rate_i + d_rate_f; // update phase - d_out_idx++; - - if(output_items.size() == 4) { - err[i] = d_error; - outrate[i] = d_rate_f; - outk[i] = d_k; - } - - // We've run out of output items we can create; return now. - if(i+d_out_idx >= noutput_items) { - consume_each(count); - return i; - } - } - - // reset here; if we didn't complete a full osps samples last time, - // the early return would take care of it. - d_out_idx = 0; - - // Update the phase and rate estimates for this symbol - float diff = d_diff_filters[d_filtnum]->filter(&in[count]); - d_error = out[i] * diff; - - // Run the control loop to update the current phase (k) and - // tracking rate estimates based on the error value - d_rate_f = d_rate_f + d_beta*d_error; - d_k = d_k + d_alpha*d_error; - - // Keep our rate within a good range - d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); - - i+=d_osps; - count += (int)floor(d_sps); - } - - consume_each(count); - return i; -} diff --git a/gr-digital/lib/digital_pn_correlator_cc.cc b/gr-digital/lib/digital_pn_correlator_cc.cc deleted file mode 100644 index 52e06bc2ad..0000000000 --- a/gr-digital/lib/digital_pn_correlator_cc.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2010,2012 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 <digital_pn_correlator_cc.h> -#include <gr_io_signature.h> - -digital_pn_correlator_cc_sptr -digital_make_pn_correlator_cc(int degree, int mask, int seed) -{ - return gnuradio::get_initial_sptr(new digital_pn_correlator_cc - (degree, mask, seed)); -} - -digital_pn_correlator_cc::digital_pn_correlator_cc(int degree, - int mask, - int seed) - : gr_sync_decimator ("pn_correlator_cc", - gr_make_io_signature (1, 1, sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - (unsigned int)((1ULL << degree)-1)) // PN code length -{ - d_len = (unsigned int)((1ULL << degree)-1); - if (mask == 0) - mask = digital_impl_glfsr::glfsr_mask(degree); - d_reference = new digital_impl_glfsr(mask, seed); - for (int i = 0; i < d_len; i++) // initialize to last value in sequence - d_pn = 2.0*d_reference->next_bit()-1.0; -} - -digital_pn_correlator_cc::~digital_pn_correlator_cc() -{ - delete d_reference; -} - -int -digital_pn_correlator_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - gr_complex sum; - - for (int i = 0; i < noutput_items; i++) { - sum = 0.0; - - for (int j = 0; j < d_len; j++) { - if (j != 0) // retard PN generator one sample per period - d_pn = 2.0*d_reference->next_bit()-1.0; // no conditionals - sum += *in++ * d_pn; - } - - *out++ = sum*gr_complex(1.0/d_len, 0.0); - } - - return noutput_items; -} diff --git a/gr-digital/lib/digital_probe_density_b.cc b/gr-digital/lib/digital_probe_density_b.cc deleted file mode 100644 index 6b83d2ddb7..0000000000 --- a/gr-digital/lib/digital_probe_density_b.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 Free Software Foundation, Inc. - * - * 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 <digital_probe_density_b.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <iostream> - -digital_probe_density_b_sptr -digital_make_probe_density_b(double alpha) -{ - return gnuradio::get_initial_sptr(new digital_probe_density_b(alpha)); -} - -digital_probe_density_b::digital_probe_density_b(double alpha) - : gr_sync_block("density_b", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(0, 0, 0)) -{ - set_alpha(alpha); - d_density = 1.0; -} - -digital_probe_density_b::~digital_probe_density_b() -{ -} - -int -digital_probe_density_b::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *)input_items[0]; - - for (int i = 0; i < noutput_items; i++) - d_density = d_alpha*(double)in[i] + d_beta*d_density; - - return noutput_items; -} - -void -digital_probe_density_b::set_alpha(double alpha) -{ - d_alpha = alpha; - d_beta = 1.0-d_alpha; -} - diff --git a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc deleted file mode 100644 index 5cdfea96d1..0000000000 --- a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_probe_mpsk_snr_est_c.h> -#include <gr_io_signature.h> -#include <cstdio> - -digital_probe_mpsk_snr_est_c_sptr -digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha) -{ - return gnuradio::get_initial_sptr( - new digital_probe_mpsk_snr_est_c(type, msg_nsamples, alpha)); -} - -digital_probe_mpsk_snr_est_c::digital_probe_mpsk_snr_est_c( - snr_est_type_t type, - int msg_nsamples, - double alpha) - : gr_sync_block ("probe_mpsk_snr_est_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)) -{ - d_snr_est = NULL; - - d_type = type; - d_nsamples = msg_nsamples; - d_count = 0; - set_alpha(alpha); - - set_type(type); - - // at least 1 estimator has to look back - set_history(2); - - d_key = pmt::pmt_string_to_symbol("snr"); -} - -digital_probe_mpsk_snr_est_c::~digital_probe_mpsk_snr_est_c() -{ - if(d_snr_est) - delete d_snr_est; -} - -int -digital_probe_mpsk_snr_est_c::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - return d_snr_est->update(noutput_items, in); -} - -double -digital_probe_mpsk_snr_est_c::snr() -{ - if(d_snr_est) - return d_snr_est->snr(); - else - throw std::runtime_error("digital_probe_mpsk_snr_est_c:: No SNR estimator defined.\n"); -} - -snr_est_type_t -digital_probe_mpsk_snr_est_c::type() const -{ - return d_type; -} - -int -digital_probe_mpsk_snr_est_c::msg_nsample() const -{ - return d_nsamples; -} - -double -digital_probe_mpsk_snr_est_c::alpha() const -{ - return d_alpha; -} - -void -digital_probe_mpsk_snr_est_c::set_type(snr_est_type_t t) -{ - d_type = t; - - if(d_snr_est) - delete d_snr_est; - - switch (d_type) { - case(SNR_EST_SIMPLE): - d_snr_est = new digital_impl_mpsk_snr_est_simple(d_alpha); - break; - case(SNR_EST_SKEW): - d_snr_est = new digital_impl_mpsk_snr_est_skew(d_alpha); - break; - case(SNR_EST_M2M4): - d_snr_est = new digital_impl_mpsk_snr_est_m2m4(d_alpha); - break; - case(SNR_EST_SVR): - d_snr_est = new digital_impl_mpsk_snr_est_svr(d_alpha); - break; - default: - throw std::invalid_argument("digital_probe_mpsk_snr_est_c: unknown type specified.\n"); - } -} - -void -digital_probe_mpsk_snr_est_c::set_msg_nsample(int n) -{ - if(n > 0) { - d_nsamples = n; - d_count = 0; // reset state - } - else - throw std::invalid_argument("digital_probe_mpsk_snr_est_c: msg_nsamples can't be <= 0\n"); -} - -void -digital_probe_mpsk_snr_est_c::set_alpha(double alpha) -{ - if((alpha >= 0) && (alpha <= 1.0)) { - d_alpha = alpha; - if(d_snr_est) - d_snr_est->set_alpha(d_alpha); - } - else - throw std::invalid_argument("digital_probe_mpsk_snr_est_c: alpha must be in [0,1]\n"); -} diff --git a/gr-digital/lib/digital_scrambler_bb.cc b/gr-digital/lib/digital_scrambler_bb.cc deleted file mode 100644 index c81b09d8c3..0000000000 --- a/gr-digital/lib/digital_scrambler_bb.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 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 <digital_scrambler_bb.h> -#include <gr_io_signature.h> - -digital_scrambler_bb_sptr -digital_make_scrambler_bb(int mask, int seed, int len) -{ - return gnuradio::get_initial_sptr(new digital_scrambler_bb - (mask, seed, len)); -} - -digital_scrambler_bb::digital_scrambler_bb(int mask, int seed, int len) - : gr_sync_block("scrambler_bb", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_lfsr(mask, seed, len) -{ -} - -int -digital_scrambler_bb::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++) - out[i] = d_lfsr.next_bit_scramble(in[i]); - - return noutput_items; -} diff --git a/gr-digital/lib/digital_simple_framer.cc b/gr-digital/lib/digital_simple_framer.cc deleted file mode 100644 index 5c194543ca..0000000000 --- a/gr-digital/lib/digital_simple_framer.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 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 <digital_simple_framer.h> -#include <digital_simple_framer_sync.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <string.h> - - -digital_simple_framer_sptr -digital_make_simple_framer (int payload_bytesize) -{ - return gnuradio::get_initial_sptr(new digital_simple_framer - (payload_bytesize)); -} - -digital_simple_framer::digital_simple_framer (int payload_bytesize) - : gr_block ("simple_framer", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (unsigned char))), - d_seqno (0), d_payload_bytesize (payload_bytesize), - d_input_block_size (payload_bytesize), - d_output_block_size (payload_bytesize + GRSF_OVERHEAD) -{ - set_output_multiple (d_output_block_size); -} - -void -digital_simple_framer::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - assert (noutput_items % d_output_block_size == 0); - - int nblocks = noutput_items / d_output_block_size; - int input_required = nblocks * d_input_block_size; - - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = input_required; -} - -int -digital_simple_framer::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - int n = 0; - int nblocks = 0; - - memset (out, 0x55, noutput_items); - - while (n < noutput_items) { - out[0] = (GRSF_SYNC >> 56) & 0xff; - out[1] = (GRSF_SYNC >> 48) & 0xff; - out[2] = (GRSF_SYNC >> 40) & 0xff; - out[3] = (GRSF_SYNC >> 32) & 0xff; - out[4] = (GRSF_SYNC >> 24) & 0xff; - out[5] = (GRSF_SYNC >> 16) & 0xff; - out[6] = (GRSF_SYNC >> 8) & 0xff; - out[7] = (GRSF_SYNC >> 0) & 0xff; - out[8] = d_seqno++; - - memcpy (&out[9], in, d_input_block_size); - in += d_input_block_size; - out += d_output_block_size; - n += d_output_block_size; - nblocks++; - } - - assert (n == noutput_items); - - consume_each (nblocks * d_input_block_size); - return n; -} diff --git a/gr-digital/lib/fll_band_edge_cc_impl.cc b/gr-digital/lib/fll_band_edge_cc_impl.cc new file mode 100644 index 0000000000..980d3ab464 --- /dev/null +++ b/gr-digital/lib/fll_band_edge_cc_impl.cc @@ -0,0 +1,276 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-2012 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 "fll_band_edge_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <cstdio> + +namespace gr { + namespace digital { + +#define M_TWOPI (2*M_PI) + + float sinc(float x) + { + if(x == 0) + return 1; + else + return sin(M_PI*x)/(M_PI*x); + } + + fll_band_edge_cc::sptr + fll_band_edge_cc::make(float samps_per_sym, float rolloff, + int filter_size, float bandwidth) + { + return gnuradio::get_initial_sptr + (new fll_band_edge_cc_impl(samps_per_sym, rolloff, + filter_size, bandwidth)); + } + + static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; + static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); + fll_band_edge_cc_impl::fll_band_edge_cc_impl(float samps_per_sym, float rolloff, + int filter_size, float bandwidth) + : gr_sync_block("fll_band_edge_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signaturev(1, 4, iosig)), + gri_control_loop(bandwidth, M_TWOPI*(2.0/samps_per_sym), + -M_TWOPI*(2.0/samps_per_sym)), + d_updated(false) + { + // Initialize samples per symbol + if(samps_per_sym <= 0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + } + d_sps = samps_per_sym; + + // Initialize rolloff factor + if(rolloff < 0 || rolloff > 1.0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + } + d_rolloff = rolloff; + + // Initialize filter length + if(filter_size <= 0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + } + d_filter_size = filter_size; + + // Build the band edge filters + design_filter(d_sps, d_rolloff, d_filter_size); + d_output_hist.resize(filter_size,0); + } + + fll_band_edge_cc_impl::~fll_band_edge_cc_impl() + { + } + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + void + fll_band_edge_cc_impl::set_samples_per_symbol(float sps) + { + if(sps <= 0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid number of sps. Must be > 0."); + } + d_sps = sps; + design_filter(d_sps, d_rolloff, d_filter_size); + } + + void + fll_band_edge_cc_impl::set_rolloff(float rolloff) + { + if(rolloff < 0 || rolloff > 1.0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid rolloff factor. Must be in [0,1]."); + } + d_rolloff = rolloff; + design_filter(d_sps, d_rolloff, d_filter_size); + } + + void + fll_band_edge_cc_impl::set_filter_size(int filter_size) + { + if(filter_size <= 0) { + throw std::out_of_range("digital_fll_band_edge_cc: invalid filter size. Must be > 0."); + } + d_filter_size = filter_size; + design_filter(d_sps, d_rolloff, d_filter_size); + } + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + float + fll_band_edge_cc_impl::samples_per_symbol() const + { + return d_sps; + } + + float + fll_band_edge_cc_impl::rolloff() const + { + return d_rolloff; + } + + int + fll_band_edge_cc_impl::filter_size() const + { + return d_filter_size; + } + + /******************************************************************* + *******************************************************************/ + + void + fll_band_edge_cc_impl::design_filter(float samps_per_sym, + float rolloff, int filter_size) + { + int M = rint(filter_size / samps_per_sym); + float power = 0; + + // Create the baseband filter by adding two sincs together + std::vector<float> bb_taps; + for(int i = 0; i < filter_size; i++) { + float k = -M + i*2.0/samps_per_sym; + float tap = sinc(rolloff*k - 0.5) + sinc(rolloff*k + 0.5); + power += tap; + + bb_taps.push_back(tap); + } + + d_taps_lower.resize(filter_size); + d_taps_upper.resize(filter_size); + + // Create the band edge filters by spinning the baseband + // filter up and down to the right places in frequency. + // Also, normalize the power in the filters + int N = (bb_taps.size() - 1.0)/2.0; + for(int i = 0; i < filter_size; i++) { + float tap = bb_taps[i] / power; + + float k = (-N + (int)i)/(2.0*samps_per_sym); + + gr_complex t1 = tap * gr_expj(-M_TWOPI*(1+rolloff)*k); + gr_complex t2 = tap * gr_expj(M_TWOPI*(1+rolloff)*k); + + d_taps_lower[filter_size-i-1] = t1; + d_taps_upper[filter_size-i-1] = t2; + } + + d_updated = true; + + // Set the history to ensure enough input items for each filter + set_history(filter_size+1); + d_filter_upper = new gr::filter::kernel::fir_filter_ccc(1, d_taps_upper); + d_filter_lower = new gr::filter::kernel::fir_filter_ccc(1, d_taps_lower); + } + + void + fll_band_edge_cc_impl::print_taps() + { + unsigned int i; + + printf("Upper Band-edge: ["); + for(i = 0; i < d_taps_upper.size(); i++) { + printf(" %.4e + %.4ej,", d_taps_upper[i].real(), d_taps_upper[i].imag()); + } + printf("]\n\n"); + + printf("Lower Band-edge: ["); + for(i = 0; i < d_taps_lower.size(); i++) { + printf(" %.4e + %.4ej,", d_taps_lower[i].real(), d_taps_lower[i].imag()); + } + printf("]\n\n"); + } + + int + fll_band_edge_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + + d_fllbuffer.reserve(d_filter_size+noutput_items); + + float *frq = NULL; + float *phs = NULL; + float *err = NULL; + if(output_items.size() == 4) { + frq = (float*)output_items[1]; + phs = (float*)output_items[2]; + err = (float*)output_items[3]; + } + + if(d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + int i; + float error; + gr_complex nco_out; + gr_complex out_upper, out_lower; + gr_complex out_uppersse, out_lowersse; + copy(d_output_hist.begin(), d_output_hist.end(), d_fllbuffer.begin()); + + for(i = 0; i < noutput_items; i++) { + nco_out = gr_expj(d_phase); + d_fllbuffer[i+d_filter_size] = in[i] * nco_out; + // Perform the dot product of the output with the filters + out_upper = 0; + out_lower = 0; + + out_upper = d_filter_lower->filter(&d_fllbuffer[i]); + out_lower = d_filter_upper->filter(&d_fllbuffer[i]); + + error = norm(out_lower) - norm(out_upper); + + advance_loop(error); + phase_wrap(); + frequency_limit(); + + if(output_items.size() == 4) { + frq[i] = d_freq; + phs[i] = d_phase; + err[i] = error; + } + } + + copy(d_fllbuffer.begin(), d_fllbuffer.begin()+noutput_items, out); + copy(d_fllbuffer.begin()+noutput_items, + d_fllbuffer.begin()+noutput_items+d_filter_size, + d_output_hist.begin()); + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/fll_band_edge_cc_impl.h b/gr-digital/lib/fll_band_edge_cc_impl.h new file mode 100644 index 0000000000..55e338b38c --- /dev/null +++ b/gr-digital/lib/fll_band_edge_cc_impl.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2011,2012 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_FLL_BAND_EDGE_CC_IMPL_H +#define INCLUDED_DIGITAL_FLL_BAND_EDGE_CC_IMPL_H + +#include <digital/fll_band_edge_cc.h> +#include <gri_control_loop.h> +#include <filter/fir_filter.h> + +namespace gr { + namespace digital { + + class fll_band_edge_cc_impl : + public fll_band_edge_cc + { + private: + float d_sps; + float d_rolloff; + int d_filter_size; + + std::vector<gr_complex> d_taps_lower; + std::vector<gr_complex> d_taps_upper; + bool d_updated; + std::vector<gr_complex> d_output_hist; + std::vector<gr_complex> d_fllbuffer; + gr::filter::kernel::fir_filter_ccc* d_filter_lower; + gr::filter::kernel::fir_filter_ccc* d_filter_upper; + + /*! + * Design the band-edge filter based on the number of samples + * per symbol, filter rolloff factor, and the filter size + * + * \param samps_per_sym (float) Number of samples per symbol of signal + * \param rolloff (float) Rolloff factor of signal + * \param filter_size (int) Size (in taps) of the filter + */ + void design_filter(float samps_per_sym, float rolloff, int filter_size); + + public: + fll_band_edge_cc_impl(float samps_per_sym, float rolloff, + int filter_size, float bandwidth); + ~fll_band_edge_cc_impl(); + + void set_samples_per_symbol(float sps); + void set_rolloff(float rolloff); + void set_filter_size(int filter_size); + + float samples_per_symbol() const; + float rolloff() const; + int filter_size() const; + + void print_taps(); + + 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_FLL_BAND_EDGE_CC_IMPL_H */ diff --git a/gr-digital/lib/framer_sink_1_impl.cc b/gr-digital/lib/framer_sink_1_impl.cc new file mode 100644 index 0000000000..1dda5ca50c --- /dev/null +++ b/gr-digital/lib/framer_sink_1_impl.cc @@ -0,0 +1,195 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010,2012 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 "framer_sink_1_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <string> + +namespace gr { + namespace digital { + +#define VERBOSE 0 + + inline void + framer_sink_1_impl::enter_search() + { + if(VERBOSE) + fprintf(stderr, "@ enter_search\n"); + + d_state = STATE_SYNC_SEARCH; + } + + inline void + framer_sink_1_impl::enter_have_sync() + { + if (VERBOSE) + fprintf(stderr, "@ enter_have_sync\n"); + + d_state = STATE_HAVE_SYNC; + d_header = 0; + d_headerbitlen_cnt = 0; + } + + inline void + framer_sink_1_impl::enter_have_header(int payload_len, + int whitener_offset) + { + if(VERBOSE) + fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", + payload_len, whitener_offset); + + d_state = STATE_HAVE_HEADER; + d_packetlen = payload_len; + d_packet_whitener_offset = whitener_offset; + d_packetlen_cnt = 0; + d_packet_byte = 0; + d_packet_byte_index = 0; + } + + framer_sink_1::sptr + framer_sink_1::make(gr_msg_queue_sptr target_queue) + { + return gnuradio::get_initial_sptr + (new framer_sink_1_impl(target_queue)); + } + + framer_sink_1_impl::framer_sink_1_impl(gr_msg_queue_sptr target_queue) + : gr_sync_block("framer_sink_1", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(0, 0, 0)), + d_target_queue(target_queue) + { + enter_search(); + } + + framer_sink_1_impl::~framer_sink_1_impl() + { + } + + int + framer_sink_1_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + int count=0; + + if(VERBOSE) + fprintf(stderr,">>> Entering state machine\n"); + + while(count < noutput_items){ + switch(d_state) { + + case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt + if(VERBOSE) + fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); + + while(count < noutput_items) { + if(in[count] & 0x2){ // Found it, set up for header decode + enter_have_sync(); + break; + } + count++; + } + break; + + case STATE_HAVE_SYNC: + if(VERBOSE) + fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", + d_headerbitlen_cnt, d_header); + + while(count < noutput_items) { // Shift bits one at a time into header + d_header = (d_header << 1) | (in[count++] & 0x1); + if(++d_headerbitlen_cnt == HEADERBITLEN) { + + if(VERBOSE) + fprintf(stderr, "got header: 0x%08x\n", d_header); + + // we have a full header, check to see if it has been received properly + if(header_ok()) { + int payload_len; + int whitener_offset; + header_payload(&payload_len, &whitener_offset); + enter_have_header(payload_len, whitener_offset); + + if(d_packetlen == 0) { // check for zero-length payload + // build a zero-length message + // NOTE: passing header field as arg1 is not scalable + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, 0); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + } + } + else + enter_search(); // bad header + break; // we're in a new state + } + } + break; + + case STATE_HAVE_HEADER: + if(VERBOSE) + fprintf(stderr,"Packet Build\n"); + + while(count < noutput_items) { // shift bits into bytes of packet one at a time + d_packet_byte = (d_packet_byte << 1) | (in[count++] & 0x1); + if(d_packet_byte_index++ == 7) { // byte is full so move to next byte + d_packet[d_packetlen_cnt++] = d_packet_byte; + d_packet_byte_index = 0; + + if(d_packetlen_cnt == d_packetlen) { // packet is filled + // build a message + // NOTE: passing header field as arg1 is not scalable + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + break; + } + } + } + break; + + default: + assert(0); + } // switch + + } // while + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/framer_sink_1_impl.h b/gr-digital/lib/framer_sink_1_impl.h new file mode 100644 index 0000000000..ff2839acbf --- /dev/null +++ b/gr-digital/lib/framer_sink_1_impl.h @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2012 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_GR_FRAMER_SINK_1_IMPL_H +#define INCLUDED_GR_FRAMER_SINK_1_IMPL_H + +#include <digital/framer_sink_1.h> + +namespace gr { + namespace digital { + + class framer_sink_1_impl : public framer_sink_1 + { + private: + enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; + + static const int MAX_PKT_LEN = 4096; + static const int HEADERBITLEN = 32; + + gr_msg_queue_sptr d_target_queue; // where to send the packet when received + state_t d_state; + unsigned int d_header; // header bits + int d_headerbitlen_cnt; // how many so far + + unsigned char d_packet[MAX_PKT_LEN]; // assembled payload + unsigned char d_packet_byte; // byte being assembled + int d_packet_byte_index; // which bit of d_packet_byte we're working on + int d_packetlen; // length of packet + int d_packet_whitener_offset; // offset into whitener string to use + int d_packetlen_cnt; // how many so far + + protected: + void enter_search(); + void enter_have_sync(); + void enter_have_header(int payload_len, int whitener_offset); + + bool header_ok() + { + // confirm that two copies of header info are identical + return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; + } + + void header_payload(int *len, int *offset) + { + // header consists of two 16-bit shorts in network byte order + // payload length is lower 12 bits + // whitener offset is upper 4 bits + *len = (d_header >> 16) & 0x0fff; + *offset = (d_header >> 28) & 0x000f; + } + + public: + framer_sink_1_impl(gr_msg_queue_sptr target_queue); + ~framer_sink_1_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FRAMER_SINK_1_IMPL_H */ diff --git a/gr-digital/lib/glfsr.cc b/gr-digital/lib/glfsr.cc new file mode 100644 index 0000000000..5c9d22af88 --- /dev/null +++ b/gr-digital/lib/glfsr.cc @@ -0,0 +1,77 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012 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. + */ + +#include <digital/glfsr.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + static int s_polynomial_masks[] = { + 0x00000000, + 0x00000001, // x^1 + 1 + 0x00000003, // x^2 + x^1 + 1 + 0x00000005, // x^3 + x^1 + 1 + 0x00000009, // x^4 + x^1 + 1 + 0x00000012, // x^5 + x^2 + 1 + 0x00000021, // x^6 + x^1 + 1 + 0x00000041, // x^7 + x^1 + 1 + 0x0000008E, // x^8 + x^4 + x^3 + x^2 + 1 + 0x00000108, // x^9 + x^4 + 1 + 0x00000204, // x^10 + x^4 + 1 + 0x00000402, // x^11 + x^2 + 1 + 0x00000829, // x^12 + x^6 + x^4 + x^1 + 1 + 0x0000100D, // x^13 + x^4 + x^3 + x^1 + 1 + 0x00002015, // x^14 + x^5 + x^3 + x^1 + 1 + 0x00004001, // x^15 + x^1 + 1 + 0x00008016, // x^16 + x^5 + x^3 + x^2 + 1 + 0x00010004, // x^17 + x^3 + 1 + 0x00020013, // x^18 + x^5 + x^2 + x^1 + 1 + 0x00040013, // x^19 + x^5 + x^2 + x^1 + 1 + 0x00080004, // x^20 + x^3 + 1 + 0x00100002, // x^21 + x^2 + 1 + 0x00200001, // x^22 + x^1 + 1 + 0x00400010, // x^23 + x^5 + 1 + 0x0080000D, // x^24 + x^4 + x^3 + x^1 + 1 + 0x01000004, // x^25 + x^3 + 1 + 0x02000023, // x^26 + x^6 + x^2 + x^1 + 1 + 0x04000013, // x^27 + x^5 + x^2 + x^1 + 1 + 0x08000004, // x^28 + x^3 + 1 + 0x10000002, // x^29 + x^2 + 1 + 0x20000029, // x^30 + x^4 + x^1 + 1 + 0x40000004, // x^31 + x^3 + 1 + 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1 + }; + + glfsr::~glfsr() + { + } + + int glfsr::glfsr_mask(int degree) + { + if(degree < 1 || degree > 32) + throw std::runtime_error("glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive"); + return s_polynomial_masks[degree]; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/glfsr_source_b_impl.cc b/gr-digital/lib/glfsr_source_b_impl.cc new file mode 100644 index 0000000000..e4171d80e7 --- /dev/null +++ b/gr-digital/lib/glfsr_source_b_impl.cc @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 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 "glfsr_source_b_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + glfsr_source_b::sptr + glfsr_source_b::make(int degree, bool repeat, int mask, int seed) + { + return gnuradio::get_initial_sptr + (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) + : gr_sync_block("glfsr_source_b", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_repeat(repeat), d_index(0) + { + 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); + + if(mask == 0) + mask = glfsr::glfsr_mask(degree); + d_glfsr = new glfsr(mask, seed); + } + + glfsr_source_b_impl::~glfsr_source_b_impl() + { + delete d_glfsr; + } + + int + glfsr_source_b_impl::mask() const + { + return d_glfsr->mask(); + } + + int + glfsr_source_b_impl::work(int noutput_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 */ + + 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; + } + + return i; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_pn_correlator_cc.i b/gr-digital/lib/glfsr_source_b_impl.h index 11ccf12c2f..f52cfa0f20 100644 --- a/gr-digital/swig/digital_pn_correlator_cc.i +++ b/gr-digital/lib/glfsr_source_b_impl.h @@ -20,13 +20,38 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,pn_correlator_cc) +#ifndef INCLUDED_GR_GLFSR_SOURCE_B_IMPL_H +#define INCLUDED_GR_GLFSR_SOURCE_B_IMPL_H -digital_pn_correlator_cc_sptr -digital_make_pn_correlator_cc(int degree, int mask=0, int seed=1); +#include <digital/glfsr_source_b.h> +#include <digital/glfsr.h> -class digital_pn_correlator_cc : public gr_sync_decimator -{ - protected: - digital_pn_correlator_cc(); -}; +namespace gr { + namespace digital { + + class glfsr_source_b_impl : public glfsr_source_b + { + private: + glfsr *d_glfsr; + + bool d_repeat; + unsigned int d_index; + unsigned int d_length; + + public: + glfsr_source_b_impl(int degree, bool repeat=true, + int mask=0, int seed=1); + ~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; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_GLFSR_SOURCE_B_IMPL_H */ diff --git a/gr-digital/lib/glfsr_source_f_impl.cc b/gr-digital/lib/glfsr_source_f_impl.cc new file mode 100644 index 0000000000..1e0ee2d85e --- /dev/null +++ b/gr-digital/lib/glfsr_source_f_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 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 "glfsr_source_f_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + glfsr_source_f::sptr + glfsr_source_f::make(int degree, bool repeat, int mask, int seed) + { + return gnuradio::get_initial_sptr + (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) + : gr_sync_block("glfsr_source_f", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(float))), + d_repeat(repeat), d_index(0) + { + 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); + + if(mask == 0) + mask = glfsr::glfsr_mask(degree); + d_glfsr = new glfsr(mask, seed); + } + + glfsr_source_f_impl::~glfsr_source_f_impl() + { + delete d_glfsr; + } + + int + glfsr_source_f_impl::mask() const + { + return d_glfsr->mask(); + } + + int + glfsr_source_f_impl::work(int noutput_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 */ + + 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; + } + + return i; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/include/digital_impl_glfsr.h b/gr-digital/lib/glfsr_source_f_impl.h index 3aadf7cf2f..4168016097 100644 --- a/gr-digital/include/digital_impl_glfsr.h +++ b/gr-digital/lib/glfsr_source_f_impl.h @@ -20,38 +20,38 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_DIGITAL_IMPL_GLFSR_H -#define INCLUDED_DIGITAL_IMPL_GLFSR_H +#ifndef INCLUDED_GR_GLFSR_SOURCE_F_IMPL_H +#define INCLUDED_GR_GLFSR_SOURCE_F_IMPL_H -#include <digital_api.h> +#include <digital/glfsr_source_f.h> +#include <digital/glfsr.h> -/*! - * \brief Galois Linear Feedback Shift Register using specified polynomial mask - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^degree-1 - */ +namespace gr { + namespace digital { + + class glfsr_source_f_impl : public glfsr_source_f + { + private: + glfsr *d_glfsr; -class DIGITAL_API digital_impl_glfsr -{ - private: - int d_shift_register; - int d_mask; + bool d_repeat; + unsigned int d_index; + unsigned int d_length; - public: + public: + glfsr_source_f_impl(int degree, bool repeat=true, + int mask=0, int seed=1); + ~glfsr_source_f_impl(); - digital_impl_glfsr(int mask, int seed) { d_shift_register = seed; d_mask = mask; } - static int glfsr_mask(int degree); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); - unsigned char next_bit() { - unsigned char bit = d_shift_register & 1; - d_shift_register >>= 1; - if (bit) - d_shift_register ^= d_mask; - return bit; - } + unsigned int period() const { return d_length; } + int mask() const; + }; - int mask() const { return d_mask; } -}; + } /* namespace digital */ +} /* namespace gr */ -#endif /* INCLUDED_DIGITAL_IMPL_GLFSR_H */ +#endif /* INCLUDED_GR_GLFSR_SOURCE_F_IMPL_H */ diff --git a/gr-digital/lib/kurtotic_equalizer_cc_impl.cc b/gr-digital/lib/kurtotic_equalizer_cc_impl.cc new file mode 100644 index 0000000000..c3be3b5d06 --- /dev/null +++ b/gr-digital/lib/kurtotic_equalizer_cc_impl.cc @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "kurtotic_equalizer_cc_impl.h" +#include <gr_io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace digital { + + kurtotic_equalizer_cc::sptr + kurtotic_equalizer_cc::make(int num_taps, float mu) + { + return gnuradio::get_initial_sptr + (new kurtotic_equalizer_cc_impl(num_taps, mu)); + } + + kurtotic_equalizer_cc_impl::kurtotic_equalizer_cc_impl(int num_taps, float mu) + : gr_sync_decimator("kurtotic_equalizer_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + 1), + filter::kernel::fir_filter_ccc(1, std::vector<gr_complex>(num_taps, gr_complex(0,0))) + { + set_gain(mu); + if(num_taps > 0) + d_taps[0] = 1.0; + set_taps(d_taps); + + d_alpha_p = 0.01; + d_alpha_q = 0.01; + d_alpha_m = 0.01; + + d_p = 0.0f; + d_m = 0.0f; + d_q = gr_complex(0,0); + d_u = gr_complex(0,0); + + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); + set_history(num_taps+1); + } + + kurtotic_equalizer_cc_impl::~kurtotic_equalizer_cc_impl() + { + } + + int + kurtotic_equalizer_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + int j = 0, k, l = d_taps.size(); + for(int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + // Adjust taps + d_error = error(out[i]); + for(k = 0; k < l; k++) { + update_tap(d_taps[l-k-1], in[j+k]); + } + + j += decimation(); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/kurtotic_equalizer_cc_impl.h b/gr-digital/lib/kurtotic_equalizer_cc_impl.h new file mode 100644 index 0000000000..0f2ff23808 --- /dev/null +++ b/gr-digital/lib/kurtotic_equalizer_cc_impl.h @@ -0,0 +1,108 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_KURTOTIC_EQUALIZER_CC_IMPL_H +#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_IMPL_H + +#include <digital/kurtotic_equalizer_cc.h> +#include <filter/fir_filter.h> +#include <gr_math.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + class kurtotic_equalizer_cc_impl + : public kurtotic_equalizer_cc, filter::kernel::fir_filter_ccc + { + private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + gr_complex d_error; + + float d_mu; + float d_p, d_m; + gr_complex d_q, d_u; + float d_alpha_p, d_alpha_q, d_alpha_m; + + gr_complex sign(gr_complex x) + { + float re = (float)(x.real() >= 0.0f); + float im = (float)(x.imag() >= 0.0f); + return gr_complex(re, im); + } + + protected: + virtual gr_complex error(const gr_complex &out) + { + // p = E[|z|^2] + // q = E[z^2] + // m = E[|z|^4] + // u = E[kurtosis(z)] + + float nrm = norm(out); + gr_complex cnj = conj(out); + float epsilon_f = 1e-12; + gr_complex epsilon_c = gr_complex(1e-12, 1e-12); + + d_p = (1-d_alpha_p)*d_p + (d_alpha_p)*nrm + epsilon_f; + d_q = (1-d_alpha_q)*d_q + (d_alpha_q)*out*out + epsilon_c; + d_m = (1-d_alpha_m)*d_m + (d_alpha_m)*nrm*nrm + epsilon_f; + d_u = d_m - 2.0f*(d_p*d_p) - d_q*d_q; + + gr_complex F = (1.0f / (d_p*d_p*d_p)) * + (sign(d_u) * (nrm*cnj - 2.0f*d_p*cnj - conj(d_q)*out) - + abs(d_u)*cnj); + + float re = gr_clip(F.real(), 1.0); + float im = gr_clip(F.imag(), 1.0); + return gr_complex(re, im); + } + + virtual void update_tap(gr_complex &tap, const gr_complex &in) + { + tap += d_mu*in*d_error; + } + + public: + kurtotic_equalizer_cc_impl(int num_taps, float mu); + ~kurtotic_equalizer_cc_impl(); + + float gain() const { return d_mu; } + + void set_gain(float mu) + { + if(mu < 0) + throw std::out_of_range("kurtotic_equalizer_cc_impl::set_gain: Gain value must be >= 0"); + d_mu = mu; + } + + 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_KURTOTIC_EQUALIZER_CC_IMPL_H */ + diff --git a/gr-digital/lib/lms_dd_equalizer_cc_impl.cc b/gr-digital/lib/lms_dd_equalizer_cc_impl.cc new file mode 100644 index 0000000000..6c217896c3 --- /dev/null +++ b/gr-digital/lib/lms_dd_equalizer_cc_impl.cc @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "lms_dd_equalizer_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_misc.h> +#include <volk/volk.h> + +namespace gr { + namespace digital { + + lms_dd_equalizer_cc::sptr + lms_dd_equalizer_cc::make(int num_taps, float mu, int sps, + constellation_sptr cnst) + { + return gnuradio::get_initial_sptr + (new lms_dd_equalizer_cc_impl(num_taps, mu, sps, cnst)); + } + + lms_dd_equalizer_cc_impl::lms_dd_equalizer_cc_impl(int num_taps, float mu, + int sps, + constellation_sptr cnst) + : gr_sync_decimator("lms_dd_equalizer_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + sps), + filter::kernel::fir_filter_ccc(sps, std::vector<gr_complex>(num_taps, gr_complex(0,0))), + d_cnst(cnst) + { + set_gain(mu); + if(num_taps > 0) + d_taps[0] = 1.0; + set_taps(d_taps); + + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1,alignment_multiple)); + + set_history(num_taps+1); + } + + lms_dd_equalizer_cc_impl::~lms_dd_equalizer_cc_impl() + { + } + + int + lms_dd_equalizer_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + int j = 0; + size_t l = d_taps.size(); + for(int i = 0; i < noutput_items; i++) { + out[i] = filter(&in[j]); + + d_error = error(out[i]); + for(size_t k=0; k < l; k++) { + update_tap(d_taps[k], in[i+k]); + } + + j += decimation(); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/lms_dd_equalizer_cc_impl.h b/gr-digital/lib/lms_dd_equalizer_cc_impl.h new file mode 100644 index 0000000000..aa84a71b4a --- /dev/null +++ b/gr-digital/lib/lms_dd_equalizer_cc_impl.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_LMS_DD_EQUALIZER_CC_IMPL_H +#define INCLUDED_DIGITAL_LMS_DD_EQUALIZER_CC_IMPL_H + +#include <digital/lms_dd_equalizer_cc.h> +#include <filter/fir_filter.h> +#include <stdexcept> + +namespace gr { + namespace digital { + + class lms_dd_equalizer_cc_impl + : public lms_dd_equalizer_cc, filter::kernel::fir_filter_ccc + { + private: + std::vector<gr_complex> d_new_taps; + bool d_updated; + gr_complex d_error; + + float d_mu; + constellation_sptr d_cnst; + + protected: + gr_complex error(const gr_complex &out) + { + gr_complex decision, error; + d_cnst->map_to_points(d_cnst->decision_maker(&out), &decision); + error = decision - out; + return error; + } + + void update_tap(gr_complex &tap, const gr_complex &in) + { + tap += d_mu*conj(in)*d_error; + } + + public: + lms_dd_equalizer_cc_impl(int num_taps, + float mu, int sps, + constellation_sptr cnst); + ~lms_dd_equalizer_cc_impl(); + + float gain() const + { + return d_mu; + } + + void set_gain(float mu) + { + if(mu < 0.0f || mu > 1.0f) { + throw std::out_of_range("lms_dd_equalizer_impl::set_mu: Gain value must in [0, 1]"); + } + else { + d_mu = mu; + } + } + + 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_LMS_DD_EQUALIZER_CC_IMPL_H */ diff --git a/gr-digital/lib/map_bb_impl.cc b/gr-digital/lib/map_bb_impl.cc new file mode 100644 index 0000000000..3a06394ec4 --- /dev/null +++ b/gr-digital/lib/map_bb_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2010,2012 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 "map_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + map_bb::sptr + map_bb::make(const std::vector<int> &map) + { + return gnuradio::get_initial_sptr(new map_bb_impl(map)); + } + + map_bb_impl::map_bb_impl(const std::vector<int> &map) + : gr_sync_block("map_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + set_map(map); + } + + map_bb_impl::~map_bb_impl() + { + } + + void + map_bb_impl::set_map(const std::vector<int> &map) + { + gruel::scoped_lock guard(d_mutex); + + for(int i = 0; i < 0x100; i++) + d_map[i] = i; + + unsigned int size = std::min((size_t)0x100, map.size()); + for(unsigned int i = 0; i < size; i++) + d_map[i] = map[i]; + } + + std::vector<int> + map_bb_impl::map() const + { + std::vector<int> m; + for(unsigned i = 0; i < 0x100; i++) + m[i] = d_map[i]; + return m; + } + + int + map_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock guard(d_mutex); + + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + for(int i = 0; i < noutput_items; i++) + out[i] = d_map[in[i]]; + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_diff_phasor_cc.i b/gr-digital/lib/map_bb_impl.h index b1e20eb997..bce2b9b1b3 100644 --- a/gr-digital/swig/digital_diff_phasor_cc.i +++ b/gr-digital/lib/map_bb_impl.h @@ -20,11 +20,34 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,diff_phasor_cc) +#ifndef INCLUDED_GR_MAP_BB_IMPL_H +#define INCLUDED_GR_MAP_BB_IMPL_H -digital_diff_phasor_cc_sptr -digital_make_diff_phasor_cc(); +#include <digital/map_bb.h> +#include <gruel/thread.h> -class digital_diff_phasor_cc : public gr_sync_block -{ -}; +namespace gr { + namespace digital { + + class map_bb_impl : public map_bb + { + private: + unsigned char d_map[0x100]; + gruel::mutex d_mutex; + + public: + map_bb_impl(const std::vector<int> &map); + ~map_bb_impl(); + + void set_map(const std::vector<int> &map); + std::vector<int> map() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MAP_BB_IMPL_H */ diff --git a/gr-digital/lib/mpsk_receiver_cc_impl.cc b/gr-digital/lib/mpsk_receiver_cc_impl.cc new file mode 100644 index 0000000000..31355c5653 --- /dev/null +++ b/gr-digital/lib/mpsk_receiver_cc_impl.cc @@ -0,0 +1,331 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005-2007,2010-2012 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 "mpsk_receiver_cc_impl.h" +#include <gr_io_signature.h> +#include <gr_prefs.h> +#include <gr_math.h> +#include <gr_expj.h> +#include <stdexcept> + +namespace gr { + namespace digital { + +#define M_TWOPI (2*M_PI) +#define VERBOSE_MM 0 // Used for debugging symbol timing loop +#define VERBOSE_COSTAS 0 // Used for debugging phase and frequency tracking + + mpsk_receiver_cc::sptr + mpsk_receiver_cc::make(unsigned int M, float theta, + float loop_bw, + float fmin, float fmax, + float mu, float gain_mu, + float omega, float gain_omega, float omega_rel) + { + return gnuradio::get_initial_sptr + (new mpsk_receiver_cc_impl(M, theta, + loop_bw, + fmin, fmax, + mu, gain_mu, + omega, gain_omega, + omega_rel)); + } + + mpsk_receiver_cc_impl::mpsk_receiver_cc_impl(unsigned int M, float theta, + float loop_bw, + float fmin, float fmax, + float mu, float gain_mu, + float omega, float gain_omega, + float omega_rel) + : gr_block("mpsk_receiver_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))), + gri_control_loop(loop_bw, fmax, fmin), + d_M(M), d_theta(theta), + d_current_const_point(0), + d_mu(mu), d_gain_mu(gain_mu), d_gain_omega(gain_omega), + d_omega_rel(omega_rel), d_max_omega(0), d_min_omega(0), + d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) + { + d_interp = new gr::filter::mmse_fir_interpolator_cc(); + d_dl_idx = 0; + + set_omega(omega); + + if(omega <= 0.0) + throw std::out_of_range("clock rate must be > 0"); + if(gain_mu < 0 || gain_omega < 0) + throw std::out_of_range("Gains must be non-negative"); + + assert(d_interp->ntaps() <= DLLEN); + + // zero double length delay line. + for(unsigned int i = 0; i < 2 * DLLEN; i++) + d_dl[i] = gr_complex(0.0,0.0); + + set_modulation_order(d_M); + } + + mpsk_receiver_cc_impl::~mpsk_receiver_cc_impl() + { + delete d_interp; + } + + void + mpsk_receiver_cc_impl::set_modulation_order(unsigned int M) + { + // build the constellation vector from M + make_constellation(); + + // Select a phase detector and a decision maker for the modulation order + switch(d_M) { + case 2: // optimized algorithms for BPSK + d_phase_error_detector = &mpsk_receiver_cc_impl::phase_error_detector_bpsk; //bpsk; + d_decision = &mpsk_receiver_cc_impl::decision_bpsk; + break; + + case 4: // optimized algorithms for QPSK + d_phase_error_detector = &mpsk_receiver_cc_impl::phase_error_detector_qpsk; //qpsk; + d_decision = &mpsk_receiver_cc_impl::decision_qpsk; + break; + + default: // generic algorithms for any M (power of 2?) but not pretty + d_phase_error_detector = &mpsk_receiver_cc_impl::phase_error_detector_generic; + d_decision = &mpsk_receiver_cc_impl::decision_generic; + break; + } + } + + void + mpsk_receiver_cc_impl::set_gain_omega_rel(float omega_rel) + { + d_omega_rel = omega_rel; + set_omega(d_omega); + } + + void + mpsk_receiver_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i=0; i < ninputs; i++) + ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); + } + + // FIXME add these back in an test difference in performance + float + mpsk_receiver_cc_impl::phase_error_detector_qpsk(gr_complex sample) const + { + float phase_error = 0; + if(fabsf(sample.real()) > fabsf(sample.imag())) { + if(sample.real() > 0) + phase_error = -sample.imag(); + else + phase_error = sample.imag(); + } + else { + if(sample.imag() > 0) + phase_error = sample.real(); + else + phase_error = -sample.real(); + } + + return phase_error; + } + + float + mpsk_receiver_cc_impl::phase_error_detector_bpsk(gr_complex sample) const + { + return -(sample.real()*sample.imag()); + } + + float mpsk_receiver_cc_impl::phase_error_detector_generic(gr_complex sample) const + { + //return gr_fast_atan2f(sample*conj(d_constellation[d_current_const_point])); + return -arg(sample*conj(d_constellation[d_current_const_point])); + } + + unsigned int + mpsk_receiver_cc_impl::decision_bpsk(gr_complex sample) const + { + return (gr_branchless_binary_slicer(sample.real()) ^ 1); + //return gr_binary_slicer(sample.real()) ^ 1; + } + + unsigned int + mpsk_receiver_cc_impl::decision_qpsk(gr_complex sample) const + { + unsigned int index; + + //index = gr_branchless_quad_0deg_slicer(sample); + index = gr_quad_0deg_slicer(sample); + return index; + } + + unsigned int + mpsk_receiver_cc_impl::decision_generic(gr_complex sample) const + { + unsigned int min_m = 0; + float min_s = 65535; + + // Develop all possible constellation points and find the one that minimizes + // the Euclidean distance (error) with the sample + for(unsigned int m = 0; m < d_M; m++) { + gr_complex diff = norm(d_constellation[m] - sample); + + if(fabs(diff.real()) < min_s) { + min_s = fabs(diff.real()); + min_m = m; + } + } + // Return the index of the constellation point that minimizes the error + return min_m; + } + + void + mpsk_receiver_cc_impl::make_constellation() + { + for(unsigned int m = 0; m < d_M; m++) { + d_constellation.push_back(gr_expj((M_TWOPI/d_M)*m)); + } + } + + void + mpsk_receiver_cc_impl::mm_sampler(const gr_complex symbol) + { + gr_complex sample, nco; + + d_mu--; // skip a number of symbols between sampling + d_phase += d_freq; // increment the phase based on the frequency of the rotation + + // Keep phase clamped and not walk to infinity + while(d_phase > M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase < -M_TWOPI) + d_phase += M_TWOPI; + + nco = gr_expj(d_phase+d_theta); // get the NCO value for derotating the current sample + sample = nco*symbol; // get the downconverted symbol + + // Fill up the delay line for the interpolator + d_dl[d_dl_idx] = sample; + d_dl[(d_dl_idx + DLLEN)] = sample; // put this in the second half of the buffer for overflows + d_dl_idx = (d_dl_idx+1) % DLLEN; // Keep the delay line index in bounds + } + + void + mpsk_receiver_cc_impl::mm_error_tracking(gr_complex sample) + { + gr_complex u, x, y; + float mm_error = 0; + + // Make sample timing corrections + + // set the delayed samples + d_p_2T = d_p_1T; + d_p_1T = d_p_0T; + d_p_0T = sample; + d_c_2T = d_c_1T; + d_c_1T = d_c_0T; + + d_current_const_point = (*this.*d_decision)(d_p_0T); // make a decision on the sample value + d_c_0T = d_constellation[d_current_const_point]; + + x = (d_c_0T - d_c_2T) * conj(d_p_1T); + y = (d_p_0T - d_p_2T) * conj(d_c_1T); + u = y - x; + mm_error = u.real(); // the error signal is in the real part + mm_error = gr_branchless_clip(mm_error, 1.0); // limit mm_val + + d_omega = d_omega + d_gain_omega * mm_error; // update omega based on loop error + d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_rel); // make sure we don't walk away + + d_mu += d_omega + d_gain_mu * mm_error; // update mu based on loop error + +#if VERBOSE_MM + printf("mm: mu: %f omega: %f mm_error: %f sample: %f+j%f constellation: %f+j%f\n", + d_mu, d_omega, mm_error, sample.real(), sample.imag(), + d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); +#endif + } + + + void + mpsk_receiver_cc_impl::phase_error_tracking(gr_complex sample) + { + float phase_error = 0; + + // Make phase and frequency corrections based on sampled value + phase_error = (*this.*d_phase_error_detector)(sample); + + advance_loop(phase_error); + phase_wrap(); + frequency_limit(); + +#if VERBOSE_COSTAS + printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", + phase_error, d_phase, d_freq, sample.real(), sample.imag(), + d_constellation[d_current_const_point].real(), d_constellation[d_current_const_point].imag()); +#endif +} + + int + mpsk_receiver_cc_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + + int i=0, o=0; + + while((o < noutput_items) && (i < ninput_items[0])) { + while((d_mu > 1) && (i < ninput_items[0])) { + mm_sampler(in[i]); // puts symbols into a buffer and adjusts d_mu + i++; + } + + if(i < ninput_items[0]) { + gr_complex interp_sample = d_interp->interpolate(&d_dl[d_dl_idx], d_mu); + + mm_error_tracking(interp_sample); // corrects M&M sample time + phase_error_tracking(interp_sample); // corrects phase and frequency offsets + + out[o++] = interp_sample; + } + } + +#if 0 + printf("ninput_items: %d noutput_items: %d consuming: %d returning: %d\n", + ninput_items[0], noutput_items, i, o); +#endif + + consume_each(i); + return o; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/mpsk_receiver_cc_impl.h b/gr-digital/lib/mpsk_receiver_cc_impl.h new file mode 100644 index 0000000000..3db6fa8b62 --- /dev/null +++ b/gr-digital/lib/mpsk_receiver_cc_impl.h @@ -0,0 +1,244 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2011,2012 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_MPSK_RECEIVER_CC_IMPL_H +#define INCLUDED_DIGITAL_MPSK_RECEIVER_CC_IMPL_H + +#include <digital/mpsk_receiver_cc.h> +#include <gruel/attributes.h> +#include <gri_control_loop.h> +#include <gr_complex.h> +#include <fstream> +#include <filter/mmse_fir_interpolator_cc.h> + +namespace gr { + namespace digital { + + class mpsk_receiver_cc_impl + : public mpsk_receiver_cc, public gri_control_loop + { + public: + mpsk_receiver_cc_impl(unsigned int M, float theta, + float loop_bw, + float fmin, float fmax, + float mu, float gain_mu, + float omega, float gain_omega, float omega_rel); + ~mpsk_receiver_cc_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + //! Returns the modulation order (M) currently set + float modulation_order() const { return d_M; } + + //! Returns current value of theta + float theta() const { return d_theta; } + + //! Returns current value of mu + float mu() const { return d_mu; } + + //! Returns current value of omega + float omega() const { return d_omega; } + + //! Returns mu gain factor + float gain_mu() const { return d_gain_mu; } + + //! Returns omega gain factor + float gain_omega() const { return d_gain_omega; } + + //! Returns the relative omega limit + float gain_omega_rel() const {return d_omega_rel; } + + //! Sets the modulation order (M) currently + void set_modulation_order(unsigned int M); + + //! Sets value of theta + void set_theta(float theta) { d_theta = theta; } + + //! Sets value of mu + void set_mu(float mu) { d_mu = mu; } + + //! Sets value of omega and its min and max values + void set_omega(float omega) { + d_omega = omega; + d_min_omega = omega*(1.0 - d_omega_rel); + d_max_omega = omega*(1.0 + d_omega_rel); + d_omega_mid = 0.5*(d_min_omega+d_max_omega); + } + + //! Sets value for mu gain factor + void set_gain_mu(float gain_mu) { d_gain_mu = gain_mu; } + + //! Sets value for omega gain factor + void set_gain_omega(float gain_omega) { d_gain_omega = gain_omega; } + + //! Sets the relative omega limit and resets omega min/max values + void set_gain_omega_rel(float omega_rel); + + protected: + void make_constellation(); + void mm_sampler(const gr_complex symbol); + void mm_error_tracking(gr_complex sample); + void phase_error_tracking(gr_complex sample); + + /*! + * \brief Phase error detector for MPSK modulations. + * + * \param sample the I&Q sample from which to determine the phase error + * + * This function determines the phase error for any MPSK signal + * by creating a set of PSK constellation points and doing a + * brute-force search to see which point minimizes the Euclidean + * distance. This point is then used to derotate the sample to + * the real-axis and a atan (using the fast approximation + * function) to determine the phase difference between the + * incoming sample and the real constellation point + * + * This should be cleaned up and made more efficient. + * + * \returns the approximated phase error. + */ + float phase_error_detector_generic(gr_complex sample) const; + + /*! + * \brief Phase error detector for BPSK modulation. + * + * \param sample the I&Q sample from which to determine the phase error + * + * This function determines the phase error using a simple BPSK + * phase error detector by multiplying the real and imaginary (the + * error signal) components together. As the imaginary part goes to + * 0, so does this error. + * + * \returns the approximated phase error. + */ + float phase_error_detector_bpsk(gr_complex sample) const; + + /*! + * \brief Phase error detector for QPSK modulation. + * + * \param sample the I&Q sample from which to determine the phase error + * + * This function determines the phase error using the limiter + * approach in a standard 4th order Costas loop + * + * \returns the approximated phase error. + */ + float phase_error_detector_qpsk(gr_complex sample) const; + + /*! + * \brief Decision maker for a generic MPSK constellation. + * + * \param sample the baseband I&Q sample from which to make the decision + * + * This decision maker is a generic implementation that does a + * brute-force search for the constellation point that minimizes + * the error between it and the incoming signal. + * + * \returns the index to d_constellation that minimizes the error/ + */ + unsigned int decision_generic(gr_complex sample) const; + + /*! + * \brief Decision maker for BPSK constellation. + * + * \param sample the baseband I&Q sample from which to make the decision + * + * This decision maker is a simple slicer function that makes a + * decision on the symbol based on its placement on the real + * axis of greater than 0 or less than 0; the quadrature + * component is always 0. + * + * \returns the index to d_constellation that minimizes the error/ + */ + unsigned int decision_bpsk(gr_complex sample) const; + + /*! + * \brief Decision maker for QPSK constellation. + * + * \param sample the baseband I&Q sample from which to make the decision + * + * This decision maker is a simple slicer function that makes a + * decision on the symbol based on its placement versus both + * axes and returns which quadrant the symbol is in. + * + * \returns the index to d_constellation that minimizes the error/ + */ + unsigned int decision_qpsk(gr_complex sample) const; + + private: + unsigned int d_M; + float d_theta; + + /*! + * \brief Decision maker function pointer + * + * \param sample the baseband I&Q sample from which to make the decision + * + * This is a function pointer that is set in the constructor to + * point to the proper decision function for the specified + * constellation order. + * + * \return index into d_constellation point that is the closest to the recieved sample + */ + unsigned int (mpsk_receiver_cc_impl::*d_decision)(gr_complex sample) const; + + std::vector<gr_complex> d_constellation; + unsigned int d_current_const_point; + + // Members related to symbol timing + float d_mu, d_gain_mu; + float d_omega, d_gain_omega, d_omega_rel, d_max_omega, d_min_omega, d_omega_mid; + gr_complex d_p_2T, d_p_1T, d_p_0T; + gr_complex d_c_2T, d_c_1T, d_c_0T; + + /*! + * \brief Phase error detector function pointer + * + * \param sample the I&Q sample from which to determine the phase error + * + * This is a function pointer that is set in the constructor to + * point to the proper phase error detector function for the + * specified constellation order. + */ + float (mpsk_receiver_cc_impl::*d_phase_error_detector)(gr_complex sample) const; + + //! get interpolated value + gr::filter::mmse_fir_interpolator_cc *d_interp; + + //! delay line length. + static const unsigned int DLLEN = 8; + + //! delay line plus some length for overflow protection + __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; + + //! index to delay line + unsigned int d_dl_idx; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_RECEIVER_CC_IMPL_H */ diff --git a/gr-digital/lib/mpsk_snr_est.cc b/gr-digital/lib/mpsk_snr_est.cc new file mode 100644 index 0000000000..1457a1a918 --- /dev/null +++ b/gr-digital/lib/mpsk_snr_est.cc @@ -0,0 +1,252 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 <digital/mpsk_snr_est.h> +#include <stdexcept> +#include <cstdio> + +namespace gr { + namespace digital { + + mpsk_snr_est::mpsk_snr_est(double alpha) + { + set_alpha(alpha); + } + + mpsk_snr_est::~mpsk_snr_est() + {} + + void + mpsk_snr_est::set_alpha(double alpha) + { + d_alpha = alpha; + d_beta = 1.0-alpha; + } + + double + mpsk_snr_est::alpha() const + { + return d_alpha; + } + + int + mpsk_snr_est::update(int noutput_items, + const gr_complex *input) + { + throw std::runtime_error("mpsk_snr_est: Unimplemented"); + } + + double + mpsk_snr_est::snr() + { + throw std::runtime_error("mpsk_snr_est: Unimplemented"); + } + + + /*****************************************************************/ + + + mpsk_snr_est_simple::mpsk_snr_est_simple(double alpha) : + mpsk_snr_est(alpha) + { + d_y1 = 0; + d_y2 = 0; + } + + int + mpsk_snr_est_simple::update(int noutput_items, + const gr_complex *input) + { + for(int i = 0; i < noutput_items; i++) { + double y1 = abs(input[i]); + d_y1 = d_alpha*y1 + d_beta*d_y1; + + double y2 = real(input[i]*input[i]); + d_y2 = d_alpha*y2 + d_beta*d_y2; + } + return noutput_items; + } + + double + mpsk_snr_est_simple::snr() + { + double y1_2 = d_y1*d_y1; + double y3 = y1_2 - d_y2 + 1e-20; + return 10.0*log10(y1_2/y3); + } + + + /*****************************************************************/ + + + mpsk_snr_est_skew::mpsk_snr_est_skew(double alpha) : + mpsk_snr_est(alpha) + { + d_y1 = 0; + d_y2 = 0; + d_y3 = 0; + } + + int + mpsk_snr_est_skew::update(int noutput_items, + const gr_complex *input) + { + for(int i = 0; i < noutput_items; i++) { + double y1 = abs(input[i]); + d_y1 = d_alpha*y1 + d_beta*d_y1; + + double y2 = real(input[i]*input[i]); + d_y2 = d_alpha*y2 + d_beta*d_y2; + + // online algorithm for calculating skewness + // See: + // http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Higher-order_statistics + double d = abs(input[i]) - d_y1; + double d_i = d / (i+1); + double y3 = (d*d_i*i)*d_i*(i-1) - 3.0*d_i*d_y2; + d_y3 = d_alpha*y3 + d_beta*d_y3; + } + return noutput_items; + } + + double + mpsk_snr_est_skew::snr() + { + double y3 = d_y3*d_y3 / (d_y2*d_y2*d_y2); + double y1_2 = d_y1*d_y1; + double x = y1_2 - d_y2; + return 10.0*log10(y1_2 / (x + y3*y1_2)); + } + + + /*****************************************************************/ + + + mpsk_snr_est_m2m4::mpsk_snr_est_m2m4(double alpha) : + mpsk_snr_est(alpha) + { + d_y1 = 0; + d_y2 = 0; + } + + int + mpsk_snr_est_m2m4::update(int noutput_items, + const gr_complex *input) + { + for(int i = 0; i < noutput_items; i++) { + double y1 = abs(input[i])*abs(input[i]); + d_y1 = d_alpha*y1 + d_beta*d_y1; + + double y2 = abs(input[i])*abs(input[i])*abs(input[i])*abs(input[i]); + d_y2 = d_alpha*y2 + d_beta*d_y2; + } + return noutput_items; + } + + double + mpsk_snr_est_m2m4::snr() + { + double y1_2 = d_y1*d_y1; + return 10.0*log10(2.0*sqrt(2*y1_2 - d_y2) / + (d_y1 - sqrt(2*y1_2 - d_y2))); + } + + + /*****************************************************************/ + + + snr_est_m2m4::snr_est_m2m4(double alpha, double ka, double kw) : + mpsk_snr_est(alpha) + { + d_y1 = 0; + d_y2 = 0; + d_ka = ka; + d_kw = kw; + } + + int + snr_est_m2m4::update(int noutput_items, + const gr_complex *input) + { + for(int i = 0; i < noutput_items; i++) { + double y1 = abs(input[i])*abs(input[i]); + d_y1 = d_alpha*y1 + d_beta*d_y1; + + double y2 = abs(input[i])*abs(input[i])*abs(input[i])*abs(input[i]); + d_y2 = d_alpha*y2 + d_beta*d_y2; + } + return noutput_items; + } + + double + snr_est_m2m4::snr() + { + double M2 = d_y1; + double M4 = d_y2; + double s = M2*(d_kw - 2) + + sqrt((4.0-d_ka*d_kw)*M2*M2 + M4*(d_ka+d_kw-4.0)) / + (d_ka + d_kw - 4.0); + double n = M2 - s; + + return 10.0*log10(s / n); + } + + + /*****************************************************************/ + + + mpsk_snr_est_svr::mpsk_snr_est_svr(double alpha) : + mpsk_snr_est(alpha) + { + d_y1 = 0; + d_y2 = 0; + } + + int + mpsk_snr_est_svr::update(int noutput_items, + const gr_complex *input) + { + for(int i = 0; i < noutput_items; i++) { + double x = abs(input[i]); + double x1 = abs(input[i-1]); + double y1 = (x*x)*(x1*x1); + d_y1 = d_alpha*y1 + d_beta*d_y1; + + double y2 = x*x*x*x; + d_y2 = d_alpha*y2 + d_beta*d_y2; + } + return noutput_items; + } + + double + mpsk_snr_est_svr::snr() + { + double x = d_y1 / (d_y2 - d_y1); + return 10.0*log10(2.*((x-1) + sqrt(x*(x-1)))); + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/mpsk_snr_est_cc_impl.cc b/gr-digital/lib/mpsk_snr_est_cc_impl.cc new file mode 100644 index 0000000000..efd18ea4f4 --- /dev/null +++ b/gr-digital/lib/mpsk_snr_est_cc_impl.cc @@ -0,0 +1,192 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "mpsk_snr_est_cc_impl.h" +#include <gr_io_signature.h> +#include <cstdio> + +namespace gr { + namespace digital { + + mpsk_snr_est_cc::sptr + mpsk_snr_est_cc::make(snr_est_type_t type, + int tag_nsamples, + double alpha) + { + return gnuradio::get_initial_sptr + (new mpsk_snr_est_cc_impl(type, tag_nsamples, alpha)); + } + + mpsk_snr_est_cc_impl::mpsk_snr_est_cc_impl(snr_est_type_t type, + int tag_nsamples, + double alpha) + : gr_sync_block("mpsk_snr_est_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))) + { + d_snr_est = NULL; + + d_type = type; + d_nsamples = tag_nsamples; + d_count = 0; + set_alpha(alpha); + + set_type(type); + + // at least 1 estimator has to look back + set_history(2); + + std::stringstream str; + str << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(str.str()); + d_key = pmt::pmt_string_to_symbol("snr"); + } + + mpsk_snr_est_cc_impl::~mpsk_snr_est_cc_impl() + { + if(d_snr_est) + delete d_snr_est; + } + + int + mpsk_snr_est_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + // This is a pass-through block; copy input to output + memcpy(output_items[0], input_items[0], + noutput_items * sizeof(gr_complex)); + + const gr_complex *in = (const gr_complex*)input_items[0]; + + // Update, calculate, and issue an SNR tag every d_nsamples + int index = 0, x = 0; + int64_t nwritten = nitems_written(0); + while(index + (d_nsamples-d_count) <= noutput_items) { + x = d_nsamples - d_count; + nwritten += x; + + // Update the SNR estimate registers from the current input + d_snr_est->update(x, &in[index]); + + // Issue a tag with the SNR data + pmt::pmt_t pmt_snr = pmt::pmt_from_double(d_snr_est->snr()); + add_item_tag(0, // stream ID + nwritten, // tag's sample number + d_key, // snr key + pmt_snr, // SNR + d_me); // block src id + + index += x; + d_count = 0; + } + + // Keep track of remaining items and update estimators + x = noutput_items - index; + d_count += x; + d_snr_est->update(x, &in[index]); + + return noutput_items; + } + + double + mpsk_snr_est_cc_impl::snr() + { + if(d_snr_est) + return d_snr_est->snr(); + else + throw std::runtime_error("mpsk_snr_est_cc_impl:: No SNR estimator defined.\n"); + } + + snr_est_type_t + mpsk_snr_est_cc_impl::type() const + { + return d_type; + } + + int + mpsk_snr_est_cc_impl::tag_nsample() const + { + return d_nsamples; + } + + double + mpsk_snr_est_cc_impl::alpha() const + { + return d_alpha; + } + + void + mpsk_snr_est_cc_impl::set_type(snr_est_type_t t) + { + d_type = t; + + if(d_snr_est) + delete d_snr_est; + + switch(d_type) { + case(SNR_EST_SIMPLE): + d_snr_est = new mpsk_snr_est_simple(d_alpha); + break; + case(SNR_EST_SKEW): + d_snr_est = new mpsk_snr_est_skew(d_alpha); + break; + case(SNR_EST_M2M4): + d_snr_est = new mpsk_snr_est_m2m4(d_alpha); + break; + case(SNR_EST_SVR): + d_snr_est = new mpsk_snr_est_svr(d_alpha); + break; + default: + throw std::invalid_argument("mpsk_snr_est_cc_impl: unknown type specified.\n"); + } + } + + void + mpsk_snr_est_cc_impl::set_tag_nsample(int n) + { + if(n > 0) { + d_nsamples = n; + d_count = 0; // reset state + } + else + throw std::invalid_argument("mpsk_snr_est_cc_impl: tag_nsamples can't be <= 0\n"); + } + + void + mpsk_snr_est_cc_impl::set_alpha(double alpha) + { + if((alpha >= 0) && (alpha <= 1.0)) { + d_alpha = alpha; + if(d_snr_est) + d_snr_est->set_alpha(d_alpha); + } + else + throw std::invalid_argument("mpsk_snr_est_cc_impl: alpha must be in [0,1]\n"); + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/mpsk_snr_est_cc_impl.h b/gr-digital/lib/mpsk_snr_est_cc_impl.h new file mode 100644 index 0000000000..530d223aec --- /dev/null +++ b/gr-digital/lib/mpsk_snr_est_cc_impl.h @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_MPSK_SNR_EST_CC_IMPL_H +#define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_IMPL_H + +#include <digital/api.h> +#include <digital/mpsk_snr_est_cc.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + class mpsk_snr_est_cc_impl : public mpsk_snr_est_cc + { + private: + snr_est_type_t d_type; + int d_nsamples, d_count; + double d_alpha; + mpsk_snr_est *d_snr_est; + + //d_key is the tag name, 'snr', d_me is the block name + unique ID + pmt::pmt_t d_key, d_me; + + public: + mpsk_snr_est_cc_impl(snr_est_type_t type, + int tag_nsamples=10000, + double alpha=0.001); + ~mpsk_snr_est_cc_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + //! Return the estimated signal-to-noise ratio in decibels + double snr(); + + //! Return the type of estimator in use + snr_est_type_t type() const; + + //! Return how many samples between SNR tags + int tag_nsample() const; + + //! Get the running-average coefficient + double alpha() const; + + //! Set type of estimator to use + void set_type(snr_est_type_t t); + + //! Set the number of samples between SNR tags + void set_tag_nsample(int n); + + //! Set the running-average coefficient + void set_alpha(double alpha); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_IMPL_H */ diff --git a/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc b/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc new file mode 100644 index 0000000000..67cfba615f --- /dev/null +++ b/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2010-2012 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 "ofdm_cyclic_prefixer_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + ofdm_cyclic_prefixer::sptr + ofdm_cyclic_prefixer::make(size_t input_size, size_t output_size) + { + return gnuradio::get_initial_sptr + (new ofdm_cyclic_prefixer_impl(input_size, output_size)); + } + + ofdm_cyclic_prefixer_impl::ofdm_cyclic_prefixer_impl(size_t input_size, + size_t output_size) + : gr_sync_interpolator("ofdm_cyclic_prefixer", + gr_make_io_signature(1, 1, input_size*sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + output_size), + d_input_size(input_size), + d_output_size(output_size) + { + } + + ofdm_cyclic_prefixer_impl::~ofdm_cyclic_prefixer_impl() + { + } + + int + ofdm_cyclic_prefixer_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + size_t cp_size = d_output_size - d_input_size; + unsigned int i=0, j=0; + + j = cp_size; + for(i=0; i < d_input_size; i++,j++) { + out[j] = in[i]; + } + + j = d_input_size - cp_size; + for(i=0; i < cp_size; i++, j++) { + out[i] = in[j]; + } + + return d_output_size; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i b/gr-digital/lib/ofdm_cyclic_prefixer_impl.h index 56d1629a8a..20f0489d7c 100644 --- a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i +++ b/gr-digital/lib/ofdm_cyclic_prefixer_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009,2011 Free Software Foundation, Inc. + * Copyright 2004-2006,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,15 +20,30 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer) +#ifndef INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_IMPL_H +#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_IMPL_H -digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); +#include <digital/ofdm_cyclic_prefixer.h> -class digital_ofdm_cyclic_prefixer : public gr_sync_interpolator -{ - protected: - digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); +namespace gr { + namespace digital { + + class ofdm_cyclic_prefixer_impl : public ofdm_cyclic_prefixer + { + private: + size_t d_input_size; + size_t d_output_size; - public: -}; + public: + ofdm_cyclic_prefixer_impl(size_t input_size, size_t output_size); + ~ofdm_cyclic_prefixer_impl(); + + 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_OFDM_CYCLIC_PREFIXER_IMPL_H */ diff --git a/gr-digital/lib/ofdm_frame_acquisition_impl.cc b/gr-digital/lib/ofdm_frame_acquisition_impl.cc new file mode 100644 index 0000000000..1f45338d8f --- /dev/null +++ b/gr-digital/lib/ofdm_frame_acquisition_impl.cc @@ -0,0 +1,217 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006-2008,2010,2011 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 "ofdm_frame_acquisition_impl.h" +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <gr_math.h> +#include <cstdio> + +namespace gr { + namespace digital { + +#define VERBOSE 0 +#define M_TWOPI (2*M_PI) +#define MAX_NUM_SYMBOLS 1000 + + ofdm_frame_acquisition::sptr + ofdm_frame_acquisition::make(unsigned int occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len) + { + return gnuradio::get_initial_sptr + (new ofdm_frame_acquisition_impl(occupied_carriers, fft_length, cplen, + known_symbol, max_fft_shift_len)); + } + + ofdm_frame_acquisition_impl::ofdm_frame_acquisition_impl(unsigned occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len) + : gr_block("ofdm_frame_acquisition", + gr_make_io_signature2(2, 2, sizeof(gr_complex)*fft_length, sizeof(char)*fft_length), + gr_make_io_signature2(2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char))), + d_occupied_carriers(occupied_carriers), + d_fft_length(fft_length), + d_cplen(cplen), + d_freq_shift_len(max_fft_shift_len), + d_known_symbol(known_symbol), + d_coarse_freq(0), + d_phase_count(0) + { + d_symbol_phase_diff.resize(d_fft_length); + d_known_phase_diff.resize(d_occupied_carriers); + d_hestimate.resize(d_occupied_carriers); + + unsigned int i = 0, j = 0; + + std::fill(d_known_phase_diff.begin(), d_known_phase_diff.end(), 0); + for(i = 0; i < d_known_symbol.size()-2; i+=2) { + d_known_phase_diff[i] = norm(d_known_symbol[i] - d_known_symbol[i+2]); + } + + d_phase_lut = new gr_complex[(2*d_freq_shift_len+1) * MAX_NUM_SYMBOLS]; + for(i = 0; i <= 2*d_freq_shift_len; i++) { + for(j = 0; j < MAX_NUM_SYMBOLS; j++) { + d_phase_lut[j + i*MAX_NUM_SYMBOLS] = gr_expj(-M_TWOPI*d_cplen/d_fft_length*(i-d_freq_shift_len)*j); + } + } + } + + ofdm_frame_acquisition_impl::~ofdm_frame_acquisition_impl() + { + delete [] d_phase_lut; + } + + void + ofdm_frame_acquisition_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = 1; + } + + gr_complex + ofdm_frame_acquisition_impl::coarse_freq_comp(int freq_delta, int symbol_count) + { + // return gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count), + // sin(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count)); + + return gr_expj(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count); + + //return d_phase_lut[MAX_NUM_SYMBOLS * (d_freq_shift_len + freq_delta) + symbol_count]; + } + + void + ofdm_frame_acquisition_impl::correlate(const gr_complex *symbol, int zeros_on_left) + { + unsigned int i,j; + + std::fill(d_symbol_phase_diff.begin(), d_symbol_phase_diff.end(), 0); + for(i = 0; i < d_fft_length-2; i++) { + d_symbol_phase_diff[i] = norm(symbol[i] - symbol[i+2]); + } + + // sweep through all possible/allowed frequency offsets and select the best + int index = 0; + float max = 0, sum=0; + for(i = zeros_on_left - d_freq_shift_len; i < zeros_on_left + d_freq_shift_len; i++) { + sum = 0; + for(j = 0; j < d_occupied_carriers; j++) { + sum += (d_known_phase_diff[j] * d_symbol_phase_diff[i+j]); + } + if(sum > max) { + max = sum; + index = i; + } + } + + // set the coarse frequency offset relative to the edge of the occupied tones + d_coarse_freq = index - zeros_on_left; + } + + void + ofdm_frame_acquisition_impl::calculate_equalizer(const gr_complex *symbol, int zeros_on_left) + { + unsigned int i=0; + + // Set first tap of equalizer + d_hestimate[0] = d_known_symbol[0] / + (coarse_freq_comp(d_coarse_freq,1)*symbol[zeros_on_left+d_coarse_freq]); + + // set every even tap based on known symbol + // linearly interpolate between set carriers to set zero-filled carriers + // FIXME: is this the best way to set this? + for(i = 2; i < d_occupied_carriers; i+=2) { + d_hestimate[i] = d_known_symbol[i] / + (coarse_freq_comp(d_coarse_freq,1)*(symbol[i+zeros_on_left+d_coarse_freq])); + d_hestimate[i-1] = (d_hestimate[i] + d_hestimate[i-2]) / gr_complex(2.0, 0.0); + } + + // with even number of carriers; last equalizer tap is wrong + if(!(d_occupied_carriers & 1)) { + d_hestimate[d_occupied_carriers-1] = d_hestimate[d_occupied_carriers-2]; + } + + if(VERBOSE) { + fprintf(stderr, "Equalizer setting:\n"); + for(i = 0; i < d_occupied_carriers; i++) { + gr_complex sym = coarse_freq_comp(d_coarse_freq,1)*symbol[i+zeros_on_left+d_coarse_freq]; + gr_complex output = sym * d_hestimate[i]; + fprintf(stderr, "sym: %+.4f + j%+.4f ks: %+.4f + j%+.4f eq: %+.4f + j%+.4f ==> %+.4f + j%+.4f\n", + sym .real(), sym.imag(), + d_known_symbol[i].real(), d_known_symbol[i].imag(), + d_hestimate[i].real(), d_hestimate[i].imag(), + output.real(), output.imag()); + } + fprintf(stderr, "\n"); + } + } + + int + ofdm_frame_acquisition_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *symbol = (const gr_complex *)input_items[0]; + const char *signal_in = (const char *)input_items[1]; + + gr_complex *out = (gr_complex *) output_items[0]; + char *signal_out = (char *) output_items[1]; + + int unoccupied_carriers = d_fft_length - d_occupied_carriers; + int zeros_on_left = (int)ceil(unoccupied_carriers/2.0); + + if(signal_in[0]) { + d_phase_count = 1; + correlate(symbol, zeros_on_left); + calculate_equalizer(symbol, zeros_on_left); + signal_out[0] = 1; + } + else { + signal_out[0] = 0; + } + + for(unsigned int i = 0; i < d_occupied_carriers; i++) { + out[i] = d_hestimate[i]*coarse_freq_comp(d_coarse_freq,d_phase_count) + *symbol[i+zeros_on_left+d_coarse_freq]; + } + + d_phase_count++; + if(d_phase_count == MAX_NUM_SYMBOLS) { + d_phase_count = 1; + } + + consume_each(1); + return 1; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/ofdm_frame_acquisition_impl.h b/gr-digital/lib/ofdm_frame_acquisition_impl.h new file mode 100644 index 0000000000..867d86736f --- /dev/null +++ b/gr-digital/lib/ofdm_frame_acquisition_impl.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2011,2012 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_OFDM_FRAME_ACQUISITION_IMPL_H +#define INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_IMPL_H + +#include <digital/ofdm_frame_acquisition.h> + +namespace gr { + namespace digital { + + class ofdm_frame_acquisition_impl : public ofdm_frame_acquisition + { + private: + unsigned char slicer(gr_complex x); + void correlate(const gr_complex *symbol, int zeros_on_left); + void calculate_equalizer(const gr_complex *symbol, int zeros_on_left); + gr_complex coarse_freq_comp(int freq_delta, int count); + + unsigned int d_occupied_carriers; // !< \brief number of subcarriers with data + unsigned int d_fft_length; // !< \brief length of FFT vector + unsigned int d_cplen; // !< \brief length of cyclic prefix in samples + unsigned int d_freq_shift_len; // !< \brief number of surrounding bins to look at for correlation + std::vector<gr_complex> d_known_symbol; // !< \brief known symbols at start of frame + std::vector<float> d_known_phase_diff; // !< \brief factor used in correlation from known symbol + std::vector<float> d_symbol_phase_diff; // !< \brief factor used in correlation from received symbol + std::vector<gr_complex> d_hestimate; // !< channel estimate + int d_coarse_freq; // !< \brief search distance in number of bins + unsigned int d_phase_count; // !< \brief accumulator for coarse freq correction + float d_snr_est; // !< an estimation of the signal to noise ratio + + gr_complex *d_phase_lut; // !< look-up table for coarse frequency compensation + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + public: + ofdm_frame_acquisition_impl(unsigned int occupied_carriers, unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len=4); + ~ofdm_frame_acquisition_impl(); + + /*! + * \brief Return an estimate of the SNR of the channel + */ + float snr() { return d_snr_est; } + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_IMPL_H */ diff --git a/gr-digital/lib/ofdm_frame_sink_impl.cc b/gr-digital/lib/ofdm_frame_sink_impl.cc new file mode 100644 index 0000000000..d2f00d3a45 --- /dev/null +++ b/gr-digital/lib/ofdm_frame_sink_impl.cc @@ -0,0 +1,413 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2008,2010-2012 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 "ofdm_frame_sink_impl.h" +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <gr_math.h> +#include <cmath> +#include <cstdio> +#include <stdexcept> +#include <iostream> +#include <string> + +namespace gr { + namespace digital { + +#define VERBOSE 0 + + inline void + ofdm_frame_sink_impl::enter_search() + { + if(VERBOSE) + fprintf(stderr, "@ enter_search\n"); + + d_state = STATE_SYNC_SEARCH; + } + + inline void + ofdm_frame_sink_impl::enter_have_sync() + { + if(VERBOSE) + fprintf(stderr, "@ enter_have_sync\n"); + + d_state = STATE_HAVE_SYNC; + + // clear state of demapper + d_byte_offset = 0; + d_partial_byte = 0; + + d_header = 0; + d_headerbytelen_cnt = 0; + + // Resetting PLL + d_freq = 0.0; + d_phase = 0.0; + fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); + } + + inline void + ofdm_frame_sink_impl::enter_have_header() + { + d_state = STATE_HAVE_HEADER; + + // header consists of two 16-bit shorts in network byte order + // payload length is lower 12 bits + // whitener offset is upper 4 bits + d_packetlen = (d_header >> 16) & 0x0fff; + d_packet_whitener_offset = (d_header >> 28) & 0x000f; + d_packetlen_cnt = 0; + + if(VERBOSE) + fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", + d_packetlen, d_packet_whitener_offset); + } + + char + ofdm_frame_sink_impl::slicer(const gr_complex x) + { + unsigned int table_size = d_sym_value_out.size(); + unsigned int min_index = 0; + float min_euclid_dist = norm(x - d_sym_position[0]); + float euclid_dist = 0; + + for(unsigned int j = 1; j < table_size; j++){ + euclid_dist = norm(x - d_sym_position[j]); + if(euclid_dist < min_euclid_dist){ + min_euclid_dist = euclid_dist; + min_index = j; + } + } + return d_sym_value_out[min_index]; + } + + unsigned int ofdm_frame_sink_impl::demapper(const gr_complex *in, + char *out) + { + unsigned int i=0, bytes_produced=0; + gr_complex carrier; + + carrier = gr_expj(d_phase); + + gr_complex accum_error = 0.0; + //while(i < d_occupied_carriers) { + while(i < d_subcarrier_map.size()) { + if(d_nresid > 0) { + d_partial_byte |= d_resid; + d_byte_offset += d_nresid; + d_nresid = 0; + d_resid = 0; + } + + //while((d_byte_offset < 8) && (i < d_occupied_carriers)) { + while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) { + //gr_complex sigrot = in[i]*carrier*d_dfe[i]; + gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i]; + + if(d_derotated_output != NULL){ + d_derotated_output[i] = sigrot; + } + + char bits = slicer(sigrot); + + gr_complex closest_sym = d_sym_position[bits]; + + accum_error += sigrot * conj(closest_sym); + + // FIX THE FOLLOWING STATEMENT + if(norm(sigrot)> 0.001) + d_dfe[i] += d_eq_gain*(closest_sym/sigrot-d_dfe[i]); + + i++; + + if((8 - d_byte_offset) >= d_nbits) { + d_partial_byte |= bits << (d_byte_offset); + d_byte_offset += d_nbits; + } + else { + d_nresid = d_nbits-(8-d_byte_offset); + int mask = ((1<<(8-d_byte_offset))-1); + d_partial_byte |= (bits & mask) << d_byte_offset; + d_resid = bits >> (8-d_byte_offset); + d_byte_offset += (d_nbits - d_nresid); + } + //printf("demod symbol: %.4f + j%.4f bits: %x partial_byte: %x byte_offset: %d resid: %x nresid: %d\n", + // in[i-1].real(), in[i-1].imag(), bits, d_partial_byte, d_byte_offset, d_resid, d_nresid); + } + + if(d_byte_offset == 8) { + //printf("demod byte: %x \n\n", d_partial_byte); + out[bytes_produced++] = d_partial_byte; + d_byte_offset = 0; + d_partial_byte = 0; + } + } + //std::cerr << "accum_error " << accum_error << std::endl; + + float angle = arg(accum_error); + + d_freq = d_freq - d_freq_gain*angle; + d_phase = d_phase + d_freq - d_phase_gain*angle; + if(d_phase >= 2*M_PI) + d_phase -= 2*M_PI; + if(d_phase <0) + d_phase += 2*M_PI; + + //if(VERBOSE) + // std::cerr << angle << "\t" << d_freq << "\t" << d_phase << "\t" << std::endl; + + return bytes_produced; + } + + + ofdm_frame_sink::sptr + ofdm_frame_sink::make(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out, + gr_msg_queue_sptr target_queue, + int occupied_carriers, + float phase_gain, float freq_gain) + { + return gnuradio::get_initial_sptr + (new ofdm_frame_sink_impl(sym_position, sym_value_out, + target_queue, occupied_carriers, + phase_gain, freq_gain)); + } + + ofdm_frame_sink_impl::ofdm_frame_sink_impl(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out, + gr_msg_queue_sptr target_queue, + int occupied_carriers, + float phase_gain, float freq_gain) + : gr_sync_block("ofdm_frame_sink", + gr_make_io_signature2(2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), + gr_make_io_signature(1, 1, sizeof(gr_complex)*occupied_carriers)), + d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), + d_byte_offset(0), d_partial_byte(0), + d_resid(0), d_nresid(0),d_phase(0),d_freq(0), + d_phase_gain(phase_gain),d_freq_gain(freq_gain), + d_eq_gain(0.05) + { + std::string carriers = "FE7F"; + + // A bit hacky to fill out carriers to occupied_carriers length + int diff = (d_occupied_carriers - 4*carriers.length()); + while(diff > 7) { + carriers.insert(0, "f"); + carriers.insert(carriers.length(), "f"); + diff -= 8; + } + + // if there's extras left to be processed + // divide remaining to put on either side of current map + // all of this is done to stick with the concept of a carrier map string that + // can be later passed by the user, even though it'd be cleaner to just do this + // on the carrier map itself + int diff_left=0; + int diff_right=0; + + // dictionary to convert from integers to ascii hex representation + char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + if(diff > 0) { + char c[2] = {0,0}; + + diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side + c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer + carriers.insert(0, c); + + diff_right = diff - diff_left; // number of carriers to put on the right side + c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer + carriers.insert(carriers.length(), c); + } + + // It seemed like such a good idea at the time... + // because we are only dealing with the occupied_carriers + // at this point, the diff_left in the following compensates + // for any offset from the 0th carrier introduced + int i; + unsigned int j,k; + for(i = 0; i < (d_occupied_carriers/4)+diff_left; i++) { + char c = carriers[i]; + for(j = 0; j < 4; j++) { + k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; + if(k) { + d_subcarrier_map.push_back(4*i + j - diff_left); + } + } + } + + // make sure we stay in the limit currently imposed by the occupied_carriers + if(d_subcarrier_map.size() > (size_t)d_occupied_carriers) { + throw std::invalid_argument("ofdm_frame_sink_impl: subcarriers allocated exceeds size of occupied carriers"); + } + + d_bytes_out = new char[d_occupied_carriers]; + d_dfe.resize(occupied_carriers); + fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); + + set_sym_value_out(sym_position, sym_value_out); + + enter_search(); + } + + ofdm_frame_sink_impl::~ofdm_frame_sink_impl() + { + delete [] d_bytes_out; + } + + bool + ofdm_frame_sink_impl::set_sym_value_out(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out) + { + if(sym_position.size() != sym_value_out.size()) + return false; + + if(sym_position.size()<1) + return false; + + d_sym_position = sym_position; + d_sym_value_out = sym_value_out; + d_nbits = (unsigned long)ceil(log10(float(d_sym_value_out.size())) / log10(2.0)); + + return true; + } + + int + ofdm_frame_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + const char *sig = (const char*)input_items[1]; + unsigned int j = 0; + unsigned int bytes=0; + + // If the output is connected, send it the derotated symbols + if(output_items.size() >= 1) + d_derotated_output = (gr_complex *)output_items[0]; + else + d_derotated_output = NULL; + + if(VERBOSE) + fprintf(stderr,">>> Entering state machine\n"); + + switch(d_state) { + case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt + if(VERBOSE) + fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); + + if(sig[0]) { // Found it, set up for header decode + enter_have_sync(); + } + break; + + case STATE_HAVE_SYNC: + // only demod after getting the preamble signal; otherwise, the + // equalizer taps will screw with the PLL performance + bytes = demapper(&in[0], d_bytes_out); + + if(VERBOSE) { + if(sig[0]) + printf("ERROR -- Found SYNC in HAVE_SYNC\n"); + fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", + d_headerbytelen_cnt, d_header); + } + + j = 0; + while(j < bytes) { + d_header = (d_header << 8) | (d_bytes_out[j] & 0xFF); + j++; + + if(++d_headerbytelen_cnt == HEADERBYTELEN) { + if(VERBOSE) + fprintf(stderr, "got header: 0x%08x\n", d_header); + + // we have a full header, check to see if it has been received properly + if(header_ok()) { + enter_have_header(); + + if(VERBOSE) + printf("\nPacket Length: %d\n", d_packetlen); + + while((j < bytes) && (d_packetlen_cnt < d_packetlen)) { + d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; + } + + if(d_packetlen_cnt == d_packetlen) { + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + } + } + else { + enter_search(); // bad header + } + } + } + break; + + case STATE_HAVE_HEADER: + bytes = demapper(&in[0], d_bytes_out); + + if(VERBOSE) { + if(sig[0]) + printf("ERROR -- Found SYNC in HAVE_HEADER at %d, length of %d\n", d_packetlen_cnt, d_packetlen); + fprintf(stderr,"Packet Build\n"); + } + + j = 0; + while(j < bytes) { + d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; + + if (d_packetlen_cnt == d_packetlen){ // packet is filled + // build a message + // NOTE: passing header field as arg1 is not scalable + gr_message_sptr msg = + gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + break; + } + } + break; + + default: + assert(0); + } // switch + + return 1; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/ofdm_frame_sink_impl.h b/gr-digital/lib/ofdm_frame_sink_impl.h new file mode 100644 index 0000000000..49d5d6b5c0 --- /dev/null +++ b/gr-digital/lib/ofdm_frame_sink_impl.h @@ -0,0 +1,106 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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_OFDM_FRAME_SINK_IMPL_H +#define INCLUDED_DIGITAL_OFDM_FRAME_SINK_IMPL_H + +#include <digital/ofdm_frame_sink.h> + +namespace gr { + namespace digital { + + class ofdm_frame_sink_impl : public ofdm_frame_sink + { + private: + enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; + + static const int MAX_PKT_LEN = 4096; + static const int HEADERBYTELEN = 4; + + gr_msg_queue_sptr d_target_queue; // where to send the packet when received + state_t d_state; + unsigned int d_header; // header bits + int d_headerbytelen_cnt; // how many so far + + char *d_bytes_out; // hold the current bytes produced by the demapper + + int d_occupied_carriers; + unsigned int d_byte_offset; + unsigned int d_partial_byte; + + char d_packet[MAX_PKT_LEN]; // assembled payload + int d_packetlen; // length of packet + int d_packet_whitener_offset; // offset into whitener string to use + int d_packetlen_cnt; // how many so far + + gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out + + std::vector<gr_complex> d_sym_position; + std::vector<char> d_sym_value_out; + std::vector<gr_complex> d_dfe; + unsigned int d_nbits; + + char d_resid; + unsigned int d_nresid; + float d_phase; + float d_freq; + float d_phase_gain; + float d_freq_gain; + float d_eq_gain; + + std::vector<int> d_subcarrier_map; + + protected: + void enter_search(); + void enter_have_sync(); + void enter_have_header(); + + bool header_ok() + { + // confirm that two copies of header info are identical + return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; + } + + char slicer(const gr_complex x); + unsigned int demapper(const gr_complex *in, + char *out); + + bool set_sym_value_out(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out); + + public: + ofdm_frame_sink_impl(const std::vector<gr_complex> &sym_position, + const std::vector<char> &sym_value_out, + gr_msg_queue_sptr target_queue, + int occupied_tones, + float phase_gain=0.25, float freq_gain=0.25*0.25/4); + ~ofdm_frame_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_OFDM_FRAME_SINK_IMPL_H */ diff --git a/gr-digital/lib/ofdm_insert_preamble_impl.cc b/gr-digital/lib/ofdm_insert_preamble_impl.cc new file mode 100644 index 0000000000..100e69e22c --- /dev/null +++ b/gr-digital/lib/ofdm_insert_preamble_impl.cc @@ -0,0 +1,201 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010-2012 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "ofdm_insert_preamble_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> +#include <string> + +namespace gr { + namespace digital { + + ofdm_insert_preamble::sptr + ofdm_insert_preamble::make(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble) + { + return gnuradio::get_initial_sptr + (new ofdm_insert_preamble_impl(fft_length, preamble)); + } + + ofdm_insert_preamble_impl::ofdm_insert_preamble_impl(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble) + : gr_block("ofdm_insert_preamble", + gr_make_io_signature2(1, 2, + sizeof(gr_complex)*fft_length, + sizeof(char)), + gr_make_io_signature2(1, 2, + sizeof(gr_complex)*fft_length, + sizeof(char))), + d_fft_length(fft_length), + d_state(ST_IDLE), + d_nsymbols_output(0), + d_pending_flag(0), + d_preamble(preamble) + { + // sanity check preamble symbols + for(size_t i = 0; i < d_preamble.size(); i++) { + if(d_preamble[i].size() != (size_t) d_fft_length) + throw std::invalid_argument("ofdm_insert_preamble_impl: invalid length for preamble symbol"); + } + + enter_idle(); + } + + + ofdm_insert_preamble_impl::~ofdm_insert_preamble_impl() + { + } + + void + ofdm_insert_preamble_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + ninput_items_required[0] = noutput_items; + } + + int + ofdm_insert_preamble_impl::general_work(int noutput_items, + gr_vector_int &ninput_items_v, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ninput_items = ninput_items_v.size() == 2 ? + std::min(ninput_items_v[0], ninput_items_v[1]) : ninput_items_v[0]; + + const gr_complex *in_sym = (const gr_complex *)input_items[0]; + const unsigned char *in_flag = 0; + + if(input_items.size() == 2) + in_flag = (const unsigned char*)input_items[1]; + + gr_complex *out_sym = (gr_complex*)output_items[0]; + unsigned char *out_flag = 0; + if(output_items.size() == 2) + out_flag = (unsigned char*)output_items[1]; + + int no = 0; // number items output + int ni = 0; // number items read from input + +#define write_out_flag() \ + do { \ + if(out_flag) \ + out_flag[no] = d_pending_flag; \ + d_pending_flag = 0; \ + } while(0) + + while(no < noutput_items && ni < ninput_items) { + switch(d_state) { + case ST_IDLE: + if(in_flag && in_flag[ni] & 0x1) // this is first symbol of new payload + enter_preamble(); + else + ni++; // eat one input symbol + break; + + case ST_PREAMBLE: + assert(!in_flag || in_flag[ni] & 0x1); + if(d_nsymbols_output >= (int) d_preamble.size()) { + // we've output all the preamble + enter_first_payload(); + } + else { + memcpy(&out_sym[no * d_fft_length], + &d_preamble[d_nsymbols_output][0], + d_fft_length*sizeof(gr_complex)); + + write_out_flag(); + no++; + d_nsymbols_output++; + } + break; + + case ST_FIRST_PAYLOAD: + // copy first payload symbol from input to output + memcpy(&out_sym[no * d_fft_length], + &in_sym[ni * d_fft_length], + d_fft_length * sizeof(gr_complex)); + + write_out_flag(); + no++; + ni++; + enter_payload(); + break; + + case ST_PAYLOAD: + if(in_flag && in_flag[ni] & 0x1) { // this is first symbol of a new payload + enter_preamble(); + break; + } + + // copy a symbol from input to output + memcpy(&out_sym[no * d_fft_length], + &in_sym[ni * d_fft_length], + d_fft_length * sizeof(gr_complex)); + + write_out_flag(); + no++; + ni++; + break; + + default: + std::cerr << "ofdm_insert_preamble_impl: (can't happen) invalid state, resetting\n"; + enter_idle(); + } + } + + consume_each(ni); + return no; + } + + void + ofdm_insert_preamble_impl::enter_idle() + { + d_state = ST_IDLE; + d_nsymbols_output = 0; + d_pending_flag = 0; + } + + void + ofdm_insert_preamble_impl::enter_preamble() + { + d_state = ST_PREAMBLE; + d_nsymbols_output = 0; + d_pending_flag = 1; + } + + void + ofdm_insert_preamble_impl::enter_first_payload() + { + d_state = ST_FIRST_PAYLOAD; + } + + void + ofdm_insert_preamble_impl::enter_payload() + { + d_state = ST_PAYLOAD; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/ofdm_insert_preamble_impl.h b/gr-digital/lib/ofdm_insert_preamble_impl.h new file mode 100644 index 0000000000..cd47810daf --- /dev/null +++ b/gr-digital/lib/ofdm_insert_preamble_impl.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_IMPL_H +#define INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_IMPL_H + +#include <digital/ofdm_insert_preamble.h> + +namespace gr { + namespace digital { + + class ofdm_insert_preamble_impl : public ofdm_insert_preamble + { + private: + enum state_t { + ST_IDLE, + ST_PREAMBLE, + ST_FIRST_PAYLOAD, + ST_PAYLOAD + }; + + int d_fft_length; + state_t d_state; + int d_nsymbols_output; + int d_pending_flag; + const std::vector<std::vector<gr_complex> > d_preamble; + + void enter_idle(); + void enter_first_payload(); + void enter_payload(); + + public: + ofdm_insert_preamble_impl(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); + ~ofdm_insert_preamble_impl(); + + void enter_preamble(); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_IMPL_H */ diff --git a/gr-digital/lib/ofdm_mapper_bcv_impl.cc b/gr-digital/lib/ofdm_mapper_bcv_impl.cc new file mode 100644 index 0000000000..5b5359d7b9 --- /dev/null +++ b/gr-digital/lib/ofdm_mapper_bcv_impl.cc @@ -0,0 +1,252 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006-2008,2010-2012 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 "ofdm_mapper_bcv_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <string> + +namespace gr { + namespace digital { + + ofdm_mapper_bcv::sptr + ofdm_mapper_bcv::make(const std::vector<gr_complex> &constellation, + unsigned int msgq_limit, + unsigned int occupied_carriers, + unsigned int fft_length) + { + return gnuradio::get_initial_sptr + (new ofdm_mapper_bcv_impl(constellation, msgq_limit, + occupied_carriers, fft_length)); + } + + // Consumes 1 packet and produces as many OFDM symbols of + // fft_length to hold the full packet + ofdm_mapper_bcv_impl::ofdm_mapper_bcv_impl(const std::vector<gr_complex> &constellation, + unsigned int msgq_limit, + unsigned int occupied_carriers, + unsigned int fft_length) + : gr_sync_block("ofdm_mapper_bcv", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature2(1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), + d_constellation(constellation), + d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), + d_occupied_carriers(occupied_carriers), + d_fft_length(fft_length), + d_bit_offset(0), + d_pending_flag(0), + d_resid(0), + d_nresid(0) + { + if(!(d_occupied_carriers <= d_fft_length)) + throw std::invalid_argument("ofdm_mapper_bcv_impl: occupied carriers must be <= fft_length"); + + // this is not the final form of this solution since we still + // use the occupied_tones concept, which would get us into + // trouble if the number of carriers we seek is greater than the + // occupied carriers. + // Eventually, we will get rid of the occupied_carriers concept. + std::string carriers = "FE7F"; + + // A bit hacky to fill out carriers to occupied_carriers length + int diff = (d_occupied_carriers - 4*carriers.length()); + while(diff > 7) { + carriers.insert(0, "f"); + carriers.insert(carriers.length(), "f"); + diff -= 8; + } + + // if there's extras left to be processed divide remaining to + // put on either side of current map all of this is done to + // stick with the concept of a carrier map string that can be + // later passed by the user, even though it'd be cleaner to just + // do this on the carrier map itself + int diff_left=0; + int diff_right=0; + + // dictionary to convert from integers to ascii hex representation + char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + if(diff > 0) { + char c[2] = {0,0}; + + diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side + c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer + carriers.insert(0, c); + + diff_right = diff - diff_left; // number of carriers to put on the right side + c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer + carriers.insert(carriers.length(), c); + } + + // find out how many zeros to pad on the sides; the difference between the fft length and the subcarrier + // mapping size in chunks of four. This is the number to pack on the left and this number plus any + // residual nulls (if odd) will be packed on the right. + diff = (d_fft_length/4 - carriers.length())/2; + + unsigned int i,j,k; + for(i = 0; i < carriers.length(); i++) { + char c = carriers[i]; // get the current hex character from the string + for(j = 0; j < 4; j++) { // walk through all four bits + k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; // convert to int and extract next bit + if(k) { // if bit is a 1, + d_subcarrier_map.push_back(4*(i+diff) + j); // use this subcarrier + } + } + } + + // make sure we stay in the limit currently imposed by the occupied_carriers + if(d_subcarrier_map.size() > d_occupied_carriers) { + throw std::invalid_argument("ofdm_mapper_bcv_impl: subcarriers allocated exceeds size of occupied carriers"); + } + + d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0)); + } + + ofdm_mapper_bcv_impl::~ofdm_mapper_bcv_impl() + { + } + + int ofdm_mapper_bcv_impl::randsym() + { + return (rand() % d_constellation.size()); + } + + int + ofdm_mapper_bcv_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *out = (gr_complex *)output_items[0]; + + unsigned int i=0; + + //printf("OFDM BPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); + + if(d_eof) { + return -1; + } + + if(!d_msg) { + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + d_bit_offset = 0; + d_pending_flag = 1; // new packet, write start of packet flag + + if((d_msg->length() == 0) && (d_msg->type() == 1)) { + d_msg.reset(); + return -1; // We're done; no more messages coming. + } + } + + char *out_flag = 0; + if(output_items.size() == 2) + out_flag = (char *) output_items[1]; + + + // Build a single symbol: + // Initialize all bins to 0 to set unused carriers + memset(out, 0, d_fft_length*sizeof(gr_complex)); + + i = 0; + unsigned char bits = 0; + //while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { + while((d_msg_offset < d_msg->length()) && (i < d_subcarrier_map.size())) { + + // need new data to process + if(d_bit_offset == 0) { + d_msgbytes = d_msg->msg()[d_msg_offset]; + //printf("mod message byte: %x\n", d_msgbytes); + } + + if(d_nresid > 0) { + // take the residual bits, fill out nbits with info from the new byte, and put them in the symbol + d_resid |= (((1 << d_nresid)-1) & d_msgbytes) << (d_nbits - d_nresid); + bits = d_resid; + + out[d_subcarrier_map[i]] = d_constellation[bits]; + i++; + + d_bit_offset += d_nresid; + d_nresid = 0; + d_resid = 0; + //printf("mod bit(r): %x resid: %x nresid: %d bit_offset: %d\n", + // bits, d_resid, d_nresid, d_bit_offset); + } + else { + if((8 - d_bit_offset) >= d_nbits) { // test to make sure we can fit nbits + // take the nbits number of bits at a time from the byte to add to the symbol + bits = ((1 << d_nbits)-1) & (d_msgbytes >> d_bit_offset); + d_bit_offset += d_nbits; + + out[d_subcarrier_map[i]] = d_constellation[bits]; + i++; + } + else { // if we can't fit nbits, store them for the next + // saves d_nresid bits of this message where d_nresid < d_nbits + unsigned int extra = 8-d_bit_offset; + d_resid = ((1 << extra)-1) & (d_msgbytes >> d_bit_offset); + d_bit_offset += extra; + d_nresid = d_nbits - extra; + } + } + + if(d_bit_offset == 8) { + d_bit_offset = 0; + d_msg_offset++; + } + } + + // Ran out of data to put in symbol + if (d_msg_offset == d_msg->length()) { + if(d_nresid > 0) { + d_resid |= 0x00; + bits = d_resid; + d_nresid = 0; + d_resid = 0; + } + + //while(i < d_occupied_carriers) { // finish filling out the symbol + while(i < d_subcarrier_map.size()) { // finish filling out the symbol + out[d_subcarrier_map[i]] = d_constellation[randsym()]; + i++; + } + + if(d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); // finished packet, free message + assert(d_bit_offset == 0); + } + + if(out_flag) + out_flag[0] = d_pending_flag; + d_pending_flag = 0; + + return 1; // produced symbol + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/ofdm_mapper_bcv_impl.h b/gr-digital/lib/ofdm_mapper_bcv_impl.h new file mode 100644 index 0000000000..6459ed73d8 --- /dev/null +++ b/gr-digital/lib/ofdm_mapper_bcv_impl.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2007,2011,2012 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_OFDM_MAPPER_BCV_IMPL_H +#define INCLUDED_DIGITAL_OFDM_MAPPER_BCV_IMPL_H + +#include <digital/ofdm_mapper_bcv.h> +#include <gr_message.h> +#include <vector> + +namespace gr { + namespace digital { + + class ofdm_mapper_bcv_impl : public ofdm_mapper_bcv + { + private: + std::vector<gr_complex> d_constellation; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + unsigned int d_occupied_carriers; + unsigned int d_fft_length; + unsigned int d_bit_offset; + int d_pending_flag; + + unsigned long d_nbits; + unsigned char d_msgbytes; + + unsigned char d_resid; + unsigned int d_nresid; + + std::vector<int> d_subcarrier_map; + + int randsym(); + + public: + ofdm_mapper_bcv_impl(const std::vector<gr_complex> &constellation, + unsigned msgq_limit, + unsigned occupied_carriers, + unsigned int fft_length); + ~ofdm_mapper_bcv_impl(void); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + 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_OFDM_MAPPER_BCV_IMPL_H */ diff --git a/gr-digital/lib/ofdm_sampler_impl.cc b/gr-digital/lib/ofdm_sampler_impl.cc new file mode 100644 index 0000000000..0724b7cf26 --- /dev/null +++ b/gr-digital/lib/ofdm_sampler_impl.cc @@ -0,0 +1,144 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2008,2010-2012 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 "ofdm_sampler_impl.h" +#include <gr_io_signature.h> +#include <gr_expj.h> +#include <cstdio> + +namespace gr { + namespace digital { + + ofdm_sampler::sptr + ofdm_sampler::make(unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout) + { + return gnuradio::get_initial_sptr + (new ofdm_sampler_impl(fft_length, symbol_length, timeout)); + } + + ofdm_sampler_impl::ofdm_sampler_impl(unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout) + : gr_block("ofdm_sampler", + gr_make_io_signature2(2, 2, sizeof(gr_complex), sizeof(char)), + gr_make_io_signature2(2, 2, sizeof(gr_complex)*fft_length, sizeof(char)*fft_length)), + d_state(STATE_NO_SIG), d_timeout_max(timeout), + d_fft_length(fft_length), d_symbol_length(symbol_length) + { + set_relative_rate(1.0/(double) fft_length); // buffer allocator hint + } + + ofdm_sampler_impl::~ofdm_sampler_impl() + { + } + + void + ofdm_sampler_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + // FIXME do we need more + //int nreqd = (noutput_items-1) * d_symbol_length + d_fft_length; + int nreqd = d_symbol_length + d_fft_length; + unsigned ninputs = ninput_items_required.size(); + for(unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = nreqd; + } + + int + ofdm_sampler_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *iptr = (const gr_complex*)input_items[0]; + const char *trigger = (const char*)input_items[1]; + + gr_complex *optr = (gr_complex*)output_items[0]; + char *outsig = (char*)output_items[1]; + + //FIXME: we only process a single OFDM symbol at a time; after the preamble, we can + // process a few at a time as long as we always look out for the next preamble. + + unsigned int index = d_fft_length; // start one fft length into the input so we can always look back this far + + outsig[0] = 0; // set output to no signal by default + + // Search for a preamble trigger signal during the next symbol length + while((d_state != STATE_PREAMBLE) && (index <= (d_symbol_length+d_fft_length))) { + if(trigger[index]) { + outsig[0] = 1; // tell the next block there is a preamble coming + d_state = STATE_PREAMBLE; + } + else + index++; + } + + unsigned int i, pos, ret; + switch(d_state) { + case(STATE_PREAMBLE): + // When we found a preamble trigger, get it and set the symbol boundary here + for(i = (index - d_fft_length + 1); i <= index; i++) { + *optr++ = iptr[i]; + } + + d_timeout = d_timeout_max; // tell the system to expect at least this many symbols for a frame + d_state = STATE_FRAME; + consume_each(index - d_fft_length + 1); // consume up to one fft_length away to keep the history + ret = 1; + break; + + case(STATE_FRAME): + // use this state when we have processed a preamble and are getting the rest of the frames + //FIXME: we could also have a power squelch system here to enter STATE_NO_SIG if no power is received + + // skip over fft length history and cyclic prefix + pos = d_symbol_length; // keeps track of where we are in the input buffer + while(pos < d_symbol_length + d_fft_length) { + *optr++ = iptr[pos++]; + } + + if(d_timeout-- == 0) { + printf("TIMEOUT\n"); + d_state = STATE_NO_SIG; + } + + consume_each(d_symbol_length); // jump up by 1 fft length and the cyclic prefix length + ret = 1; + break; + + case(STATE_NO_SIG): + default: + consume_each(index-d_fft_length); // consume everything we've gone through so far leaving the fft length history + ret = 0; + break; + } + + return ret; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/ofdm_sampler_impl.h b/gr-digital/lib/ofdm_sampler_impl.h new file mode 100644 index 0000000000..369447465f --- /dev/null +++ b/gr-digital/lib/ofdm_sampler_impl.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2011,2012 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_OFDM_SAMPLER_IMPL_H +#define INCLUDED_DIGITAL_OFDM_SAMPLER_IMPL_H + +#include <digital/ofdm_sampler.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + class ofdm_sampler_impl : public ofdm_sampler + { + private: + enum state_t {STATE_NO_SIG, STATE_PREAMBLE, STATE_FRAME}; + + state_t d_state; + unsigned int d_timeout_max; + unsigned int d_timeout; + unsigned int d_fft_length; + unsigned int d_symbol_length; + + public: + ofdm_sampler_impl(unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout=1000); + ~ofdm_sampler_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_SAMPLER_IMPL_H */ diff --git a/gr-digital/lib/packet_sink_impl.cc b/gr-digital/lib/packet_sink_impl.cc new file mode 100644 index 0000000000..0d1281b03b --- /dev/null +++ b/gr-digital/lib/packet_sink_impl.cc @@ -0,0 +1,209 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "packet_sink_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <gr_count_bits.h> +#include <string.h> + +namespace gr { + namespace digital { + +#define VERBOSE 0 + +// detect access code with up to DEFAULT_THRESHOLD bits wrong +static const int DEFAULT_THRESHOLD = 12; + + inline void + packet_sink_impl::enter_search() + { + if(VERBOSE) + fprintf(stderr, "@ enter_search\n"); + + d_state = STATE_SYNC_SEARCH; + d_shift_reg = 0; + } + + inline void + packet_sink_impl::enter_have_sync() + { + if(VERBOSE) + fprintf(stderr, "@ enter_have_sync\n"); + + d_state = STATE_HAVE_SYNC; + d_header = 0; + d_headerbitlen_cnt = 0; + } + + inline void + packet_sink_impl::enter_have_header(int payload_len) + { + if(VERBOSE) + fprintf(stderr, "@ enter_have_header (payload_len = %d)\n", payload_len); + + d_state = STATE_HAVE_HEADER; + d_packetlen = payload_len; + d_packetlen_cnt = 0; + d_packet_byte = 0; + d_packet_byte_index = 0; + } + + packet_sink::sptr + packet_sink::make(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, int threshold) + { + return gnuradio::get_initial_sptr + (new packet_sink_impl(sync_vector, target_queue, threshold)); + } + + packet_sink_impl::packet_sink_impl(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, int threshold) + : gr_sync_block("packet_sink", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(0, 0, 0)), + d_target_queue(target_queue), d_threshold(threshold == -1 ? DEFAULT_THRESHOLD : threshold) + { + d_sync_vector = 0; + for(int i=0;i<8;i++){ + d_sync_vector <<= 8; + d_sync_vector |= sync_vector[i]; + } + + enter_search(); + } + + packet_sink_impl::~packet_sink_impl() + { + } + + int + packet_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float *inbuf = (float*)input_items[0]; + int count=0; + + if(VERBOSE) + fprintf(stderr, ">>> Entering state machine\n"), fflush(stderr); + + while(count<noutput_items) { + switch(d_state) { + + case STATE_SYNC_SEARCH: // Look for sync vector + if(VERBOSE) + fprintf(stderr, "SYNC Search, noutput=%d\n",noutput_items), fflush(stderr); + + while(count < noutput_items) { + if(slice(inbuf[count++])) + d_shift_reg = (d_shift_reg << 1) | 1; + else + d_shift_reg = d_shift_reg << 1; + + // Compute popcnt of putative sync vector + if(gr_count_bits64(d_shift_reg ^ d_sync_vector) <= d_threshold) { + // Found it, set up for header decode + enter_have_sync(); + break; + } + } + break; + + case STATE_HAVE_SYNC: + if(VERBOSE) + fprintf(stderr, "Header Search bitcnt=%d, header=0x%08x\n", d_headerbitlen_cnt, d_header), + fflush(stderr); + + while(count < noutput_items) { // Shift bits one at a time into header + if(slice(inbuf[count++])) + d_header = (d_header << 1) | 1; + else + d_header = d_header << 1; + + if(++d_headerbitlen_cnt == HEADERBITLEN) { + if(VERBOSE) + fprintf(stderr, "got header: 0x%08x\n", d_header); + + // we have a full header, check to see if it has been received properly + if(header_ok()) { + int payload_len = header_payload_len(); + if(payload_len <= MAX_PKT_LEN) // reasonable? + enter_have_header(payload_len); // yes. + else + enter_search(); // no. + } + else + enter_search(); // no. + break; // we're in a new state + } + } + break; + + case STATE_HAVE_HEADER: + if(VERBOSE) + fprintf(stderr,"Packet Build\n"),fflush(stderr); + + while(count < noutput_items) { // shift bits into bytes of packet one at a time + if(slice(inbuf[count++])) + d_packet_byte = (d_packet_byte << 1) | 1; + else + d_packet_byte = d_packet_byte << 1; + + if(d_packet_byte_index++ == 7) { // byte is full so move to next byte + d_packet[d_packetlen_cnt++] = d_packet_byte; + d_packet_byte_index = 0; + + if(d_packetlen_cnt == d_packetlen) { // packet is filled + // build a message + gr_message_sptr msg = gr_make_message(0, 0, 0, d_packetlen_cnt); + memcpy(msg->msg(), d_packet, d_packetlen_cnt); + + d_target_queue->insert_tail(msg); // send it + msg.reset(); // free it up + + enter_search(); + break; + } + } + } + break; + + default: + assert(0); + } // switch + } // while + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/packet_sink_impl.h b/gr-digital/lib/packet_sink_impl.h new file mode 100644 index 0000000000..a63db7a142 --- /dev/null +++ b/gr-digital/lib/packet_sink_impl.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012 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_GR_PACKET_SINK_IMPL_H +#define INCLUDED_GR_PACKET_SINK_IMPL_H + +#include <digital/packet_sink.h> + +namespace gr { + namespace digital { + + class packet_sink_impl : public packet_sink + { + private: + enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; + + static const int MAX_PKT_LEN = 4096; + static const int HEADERBITLEN = 32; + + gr_msg_queue_sptr d_target_queue; // where to send the packet when received + unsigned long long d_sync_vector; // access code to locate start of packet + unsigned int d_threshold; // how many bits may be wrong in sync vector + + state_t d_state; + + unsigned long long d_shift_reg; // used to look for sync_vector + + unsigned int d_header; // header bits + int d_headerbitlen_cnt;// how many so far + + unsigned char d_packet[MAX_PKT_LEN]; // assembled payload + unsigned char d_packet_byte; // byte being assembled + int d_packet_byte_index; // which bit of d_packet_byte we're working on + int d_packetlen; // length of packet + int d_packetlen_cnt; // how many so far + + protected: + void enter_search(); + void enter_have_sync(); + void enter_have_header(int payload_len); + + int slice(float x) { return x > 0 ? 1 : 0; } + + bool header_ok() + { + // confirm that two copies of header info are identical + return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; + } + + int header_payload_len() + { + // header consists of two 16-bit shorts in network byte order + int t = (d_header >> 16) & 0xffff; + return t; + } + + public: + packet_sink_impl(const std::vector<unsigned char>& sync_vector, + gr_msg_queue_sptr target_queue, + int threshold=-1); + ~packet_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + //! return true if we detect carrier + bool carrier_sensed() const + { + return d_state != STATE_SYNC_SEARCH; + } + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACKET_SINK_IMPL_H */ diff --git a/gr-digital/lib/pfb_clock_sync_ccf_impl.cc b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc new file mode 100644 index 0000000000..8749567fa2 --- /dev/null +++ b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc @@ -0,0 +1,439 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-2012 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 <cstdio> +#include <cmath> + +#include "pfb_clock_sync_ccf_impl.h" +#include <gr_io_signature.h> +#include <gr_math.h> + +namespace gr { + namespace digital { + + pfb_clock_sync_ccf::sptr + pfb_clock_sync_ccf::make(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + { + return gnuradio::get_initial_sptr + (new pfb_clock_sync_ccf_impl(sps, loop_bw, taps, + filter_size, + init_phase, + max_rate_deviation, + osps)); + } + + static int ios[] = {sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float)}; + static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); + pfb_clock_sync_ccf_impl::pfb_clock_sync_ccf_impl(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + : gr_block("pfb_clock_sync_ccf", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signaturev(1, 4, iosig)), + d_updated(false), d_nfilters(filter_size), + d_max_dev(max_rate_deviation), + d_osps(osps), d_error(0), d_out_idx(0) + { + d_nfilters = filter_size; + d_sps = floor(sps); + + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + + // Store the last filter between calls to work + // The accumulator keeps track of overflow to increment the stride correctly. + // set it here to the fractional difference based on the initial phaes + d_k = init_phase; + d_rate = (sps-floor(sps))*(double)d_nfilters; + d_rate_i = (int)floor(d_rate); + d_rate_f = d_rate - (float)d_rate_i; + d_filtnum = (int)floor(d_k); + + d_filters = std::vector<kernel::fir_filter_ccf*>(d_nfilters); + d_diff_filters = std::vector<kernel::fir_filter_ccf*>(d_nfilters); + + // Create an FIR filter for each channel and zero out the taps + std::vector<float> vtaps(0, d_nfilters); + for(int i = 0; i < d_nfilters; i++) { + d_filters[i] = new kernel::fir_filter_ccf(1, vtaps); + d_diff_filters[i] = new kernel::fir_filter_ccf(1, vtaps); + } + + // Now, actually set the filters' taps + std::vector<float> dtaps; + create_diff_taps(taps, dtaps); + set_taps(taps, d_taps, d_filters); + set_taps(dtaps, d_dtaps, d_diff_filters); + } + + pfb_clock_sync_ccf_impl::~pfb_clock_sync_ccf_impl() + { + for(int i = 0; i < d_nfilters; i++) { + delete d_filters[i]; + delete d_diff_filters[i]; + } + } + + bool + pfb_clock_sync_ccf_impl::check_topology(int ninputs, int noutputs) + { + return noutputs == 1 || noutputs == 4; + } + + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + void + pfb_clock_sync_ccf_impl::set_loop_bandwidth(float bw) + { + if(bw < 0) { + throw std::out_of_range("pfb_clock_sync_ccf: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); + } + + void + pfb_clock_sync_ccf_impl::set_damping_factor(float df) + { + if(df < 0 || df > 1.0) { + throw std::out_of_range("pfb_clock_sync_ccf: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); + } + + void + pfb_clock_sync_ccf_impl::set_alpha(float alpha) + { + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range("pfb_clock_sync_ccf: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; + } + + void + pfb_clock_sync_ccf_impl::set_beta(float beta) + { + if(beta < 0 || beta > 1.0) { + throw std::out_of_range("pfb_clock_sync_ccf: invalid beta. Must be in [0,1]."); + } + d_beta = beta; + } + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + float + pfb_clock_sync_ccf_impl::loop_bandwidth() const + { + return d_loop_bw; + } + + float + pfb_clock_sync_ccf_impl::damping_factor() const + { + return d_damping; + } + + float + pfb_clock_sync_ccf_impl::alpha() const + { + return d_alpha; + } + + float + pfb_clock_sync_ccf_impl::beta() const + { + return d_beta; + } + + float + pfb_clock_sync_ccf_impl::clock_rate() const + { + return d_rate_f; + } + + /******************************************************************* + *******************************************************************/ + + void + pfb_clock_sync_ccf_impl::update_gains() + { + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; + } + + void + pfb_clock_sync_ccf_impl::set_taps(const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<kernel::fir_filter_ccf*> &ourfilter) + { + int i,j; + + unsigned int ntaps = newtaps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); + + // Create d_numchan vectors to store each channel's taps + ourtaps.resize(d_nfilters); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector<float> tmp_taps; + tmp_taps = newtaps; + while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(i = 0; i < d_nfilters; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); + for(j = 0; j < d_taps_per_filter; j++) { + ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; + } + + // Build a filter for each channel and add it's taps to it + ourfilter[i]->set_taps(ourtaps[i]); + } + + // Set the history to ensure enough input items for each filter + set_history(d_taps_per_filter + d_sps); + + // Make sure there is enough output space for d_osps outputs/input. + set_output_multiple(d_osps); + + d_updated = true; + } + + void + pfb_clock_sync_ccf_impl::create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps) + { + std::vector<float> diff_filter(3); + diff_filter[0] = -1; + diff_filter[1] = 0; + diff_filter[2] = 1; + + float pwr = 0; + difftaps.push_back(0); + for(unsigned int i = 0; i < newtaps.size()-2; i++) { + float tap = 0; + for(int j = 0; j < 3; j++) { + tap += diff_filter[j]*newtaps[i+j]; + pwr += fabsf(tap); + } + difftaps.push_back(tap); + } + difftaps.push_back(0); + + for(unsigned int i = 0; i < difftaps.size(); i++) { + difftaps[i] *= pwr; + } + } + + std::string + pfb_clock_sync_ccf_impl::taps_as_string() const + { + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_taps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_taps[i][j] << ", "; + } + str << d_taps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); + } + + std::string + pfb_clock_sync_ccf_impl::diff_taps_as_string() const + { + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_dtaps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_dtaps[i][j] << ", "; + } + str << d_dtaps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); + } + + std::vector< std::vector<float> > + pfb_clock_sync_ccf_impl::taps() const + { + return d_taps; + } + + std::vector< std::vector<float> > + pfb_clock_sync_ccf_impl::diff_taps() const + { + return d_dtaps; + } + + std::vector<float> + pfb_clock_sync_ccf_impl::channel_taps(int channel) const + { + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_taps[channel][i]); + } + return taps; + } + + std::vector<float> + pfb_clock_sync_ccf_impl::diff_channel_taps(int channel) const + { + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_dtaps[channel][i]); + } + return taps; + } + + int + pfb_clock_sync_ccf_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + float *err = NULL, *outrate = NULL, *outk = NULL; + if(output_items.size() == 4) { + err = (float *) output_items[1]; + outrate = (float*)output_items[2]; + outk = (float*)output_items[3]; + } + + if(d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + // We need this many to process one output + int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; + + int i = 0, count = 0; + float error_r, error_i; + + // produce output as long as we can and there are enough input samples + while((i < noutput_items) && (count < nrequired)) { + while(d_out_idx < d_osps) { + d_filtnum = (int)floor(d_k); + + // Keep the current filter number in [0, d_nfilters] + // If we've run beyond the last filter, wrap around and go to next sample + // If we've go below 0, wrap around and go to previous sample + while(d_filtnum >= d_nfilters) { + d_k -= d_nfilters; + d_filtnum -= d_nfilters; + count += 1; + } + while(d_filtnum < 0) { + d_k += d_nfilters; + d_filtnum += d_nfilters; + count -= 1; + } + + out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); + d_k = d_k + d_rate_i + d_rate_f; // update phase + d_out_idx++; + + if(output_items.size() == 4) { + err[i] = d_error; + outrate[i] = d_rate_f; + outk[i] = d_k; + } + + // We've run out of output items we can create; return now. + if(i+d_out_idx >= noutput_items) { + consume_each(count); + return i; + } + } + + // reset here; if we didn't complete a full osps samples last time, + // the early return would take care of it. + d_out_idx = 0; + + // Update the phase and rate estimates for this symbol + gr_complex diff = d_diff_filters[d_filtnum]->filter(&in[count]); + error_r = out[i].real() * diff.real(); + error_i = out[i].imag() * diff.imag(); + d_error = (error_i + error_r) / 2.0; // average error from I&Q channel + + // Run the control loop to update the current phase (k) and + // tracking rate estimates based on the error value + d_rate_f = d_rate_f + d_beta*d_error; + d_k = d_k + d_alpha*d_error; + + // Keep our rate within a good range + d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); + + i+=d_osps; + count += (int)floor(d_sps); + } + + consume_each(count); + return i; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/pfb_clock_sync_ccf_impl.h b/gr-digital/lib/pfb_clock_sync_ccf_impl.h new file mode 100644 index 0000000000..16cf80f046 --- /dev/null +++ b/gr-digital/lib/pfb_clock_sync_ccf_impl.h @@ -0,0 +1,115 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_CCF_IMPL_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_IMPL_H + +#include <digital/pfb_clock_sync_ccf.h> + +using namespace gr::filter; + +namespace gr { + namespace digital { + + class pfb_clock_sync_ccf_impl : public pfb_clock_sync_ccf + { + private: + bool d_updated; + double d_sps; + double d_sample_num; + float d_loop_bw; + float d_damping; + float d_alpha; + float d_beta; + + int d_nfilters; + int d_taps_per_filter; + std::vector<kernel::fir_filter_ccf*> d_filters; + std::vector<kernel::fir_filter_ccf*> d_diff_filters; + std::vector< std::vector<float> > d_taps; + std::vector< std::vector<float> > d_dtaps; + + float d_k; + float d_rate; + float d_rate_i; + float d_rate_f; + float d_max_dev; + int d_filtnum; + int d_osps; + float d_error; + int d_out_idx; + + void create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps); + + public: + pfb_clock_sync_ccf_impl(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + ~pfb_clock_sync_ccf_impl(); + + void update_gains(); + + void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<kernel::fir_filter_ccf*> &ourfilter); + + std::vector< std::vector<float> > taps() const; + std::vector< std::vector<float> > diff_taps() const; + std::vector<float> channel_taps(int channel) const; + std::vector<float> diff_channel_taps(int channel) const; + std::string taps_as_string() const; + std::string diff_taps_as_string() const; + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); + void set_alpha(float alpha); + void set_beta(float beta); + void set_max_rate_deviation(float m) + { + d_max_dev = m; + } + + float loop_bandwidth() const; + float damping_factor() const; + float alpha() const; + float beta() const; + float clock_rate() const; + + /******************************************************************* + *******************************************************************/ + + bool check_topology(int ninputs, int noutputs); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PFB_CLOCK_SYNC_CCF_IMPL_H */ diff --git a/gr-digital/lib/pfb_clock_sync_fff_impl.cc b/gr-digital/lib/pfb_clock_sync_fff_impl.cc new file mode 100644 index 0000000000..fb60192324 --- /dev/null +++ b/gr-digital/lib/pfb_clock_sync_fff_impl.cc @@ -0,0 +1,435 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 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 <cstdio> +#include <cmath> + +#include "pfb_clock_sync_fff_impl.h" +#include <gr_io_signature.h> +#include <gr_math.h> + +namespace gr { + namespace digital { + + pfb_clock_sync_fff::sptr + pfb_clock_sync_fff::make(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + { + return gnuradio::get_initial_sptr + (new pfb_clock_sync_fff_impl(sps, gain, taps, + filter_size, + init_phase, + max_rate_deviation, + osps)); + } + + static int ios[] = {sizeof(float), sizeof(float), sizeof(float), sizeof(float)}; + static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); + pfb_clock_sync_fff_impl::pfb_clock_sync_fff_impl(double sps, float loop_bw, + const std::vector<float> &taps, + unsigned int filter_size, + float init_phase, + float max_rate_deviation, + int osps) + : gr_block("pfb_clock_sync_fff", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signaturev(1, 4, iosig)), + d_updated(false), d_nfilters(filter_size), + d_max_dev(max_rate_deviation), + d_osps(osps), d_error(0), d_out_idx(0) + { + d_nfilters = filter_size; + d_sps = floor(sps); + + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + + // Store the last filter between calls to work + // The accumulator keeps track of overflow to increment the stride correctly. + // set it here to the fractional difference based on the initial phaes + d_k = init_phase; + d_rate = (sps-floor(sps))*(double)d_nfilters; + d_rate_i = (int)floor(d_rate); + d_rate_f = d_rate - (float)d_rate_i; + d_filtnum = (int)floor(d_k); + + d_filters = std::vector<kernel::fir_filter_fff*>(d_nfilters); + d_diff_filters = std::vector<kernel::fir_filter_fff*>(d_nfilters); + + // Create an FIR filter for each channel and zero out the taps + std::vector<float> vtaps(0, d_nfilters); + for(int i = 0; i < d_nfilters; i++) { + d_filters[i] = new kernel::fir_filter_fff(1, vtaps); + d_diff_filters[i] = new kernel::fir_filter_fff(1, vtaps); + } + + // Now, actually set the filters' taps + std::vector<float> dtaps; + create_diff_taps(taps, dtaps); + set_taps(taps, d_taps, d_filters); + set_taps(dtaps, d_dtaps, d_diff_filters); + } + + pfb_clock_sync_fff_impl::~pfb_clock_sync_fff_impl() + { + for(int i = 0; i < d_nfilters; i++) { + delete d_filters[i]; + delete d_diff_filters[i]; + } + } + + bool + pfb_clock_sync_fff_impl::check_topology(int ninputs, int noutputs) + { + return noutputs == 1 || noutputs == 4; + } + + /******************************************************************* + SET FUNCTIONS + *******************************************************************/ + + void + pfb_clock_sync_fff_impl::set_loop_bandwidth(float bw) + { + if(bw < 0) { + throw std::out_of_range("pfb_clock_sync_fff_impl: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); + } + + void + pfb_clock_sync_fff_impl::set_damping_factor(float df) + { + if(df < 0 || df > 1.0) { + throw std::out_of_range("pfb_clock_sync_fff_impl: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); + } + + void + pfb_clock_sync_fff_impl::set_alpha(float alpha) + { + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range("pfb_clock_sync_fff_impl: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; + } + + void + pfb_clock_sync_fff_impl::set_beta(float beta) + { + if(beta < 0 || beta > 1.0) { + throw std::out_of_range("pfb_clock_sync_fff_impl: invalid beta. Must be in [0,1]."); + } + d_beta = beta; + } + + /******************************************************************* + GET FUNCTIONS + *******************************************************************/ + + float + pfb_clock_sync_fff_impl::loop_bandwidth() const + { + return d_loop_bw; + } + + float + pfb_clock_sync_fff_impl::damping_factor() const + { + return d_damping; + } + + float + pfb_clock_sync_fff_impl::alpha() const + { + return d_alpha; + } + + float + pfb_clock_sync_fff_impl::beta() const + { + return d_beta; + } + + float + pfb_clock_sync_fff_impl::clock_rate() const + { + return d_rate_f; + } + + /******************************************************************* + *******************************************************************/ + + void + pfb_clock_sync_fff_impl::update_gains() + { + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; + } + + void + pfb_clock_sync_fff_impl::set_taps(const std::vector<float> &newtaps, + std::vector< std::vector<float> > &ourtaps, + std::vector<kernel::fir_filter_fff*> &ourfilter) + { + int i,j; + + unsigned int ntaps = newtaps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_nfilters); + + // Create d_numchan vectors to store each channel's taps + ourtaps.resize(d_nfilters); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector<float> tmp_taps; + tmp_taps = newtaps; + while((float)(tmp_taps.size()) < d_nfilters*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(i = 0; i < d_nfilters; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + ourtaps[i] = std::vector<float>(d_taps_per_filter, 0); + for(j = 0; j < d_taps_per_filter; j++) { + ourtaps[i][j] = tmp_taps[i + j*d_nfilters]; + } + + // Build a filter for each channel and add it's taps to it + ourfilter[i]->set_taps(ourtaps[i]); + } + + // Set the history to ensure enough input items for each filter + set_history(d_taps_per_filter + d_sps); + + // Make sure there is enough output space for d_osps outputs/input. + set_output_multiple(d_osps); + + d_updated = true; + } + + void + pfb_clock_sync_fff_impl::create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps) + { + std::vector<float> diff_filter(3); + diff_filter[0] = -1; + diff_filter[1] = 0; + diff_filter[2] = 1; + + float pwr = 0; + difftaps.push_back(0); + for(unsigned int i = 0; i < newtaps.size()-2; i++) { + float tap = 0; + for(int j = 0; j < 3; j++) { + tap += diff_filter[j]*newtaps[i+j]; + pwr += fabsf(tap); + } + difftaps.push_back(tap); + } + difftaps.push_back(0); + + for(unsigned int i = 0; i < difftaps.size(); i++) { + difftaps[i] *= pwr; + } + } + + std::string + pfb_clock_sync_fff_impl::taps_as_string() const + { + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_taps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_taps[i][j] << ", "; + } + str << d_taps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); + } + + std::string + pfb_clock_sync_fff_impl::diff_taps_as_string() const + { + int i, j; + std::stringstream str; + str.precision(4); + str.setf(std::ios::scientific); + + str << "[ "; + for(i = 0; i < d_nfilters; i++) { + str << "[" << d_dtaps[i][0] << ", "; + for(j = 1; j < d_taps_per_filter-1; j++) { + str << d_dtaps[i][j] << ", "; + } + str << d_dtaps[i][j] << "],"; + } + str << " ]" << std::endl; + + return str.str(); + } + + std::vector< std::vector<float> > + pfb_clock_sync_fff_impl::taps() const + { + return d_taps; + } + + std::vector< std::vector<float> > + pfb_clock_sync_fff_impl::diff_taps() const + { + return d_dtaps; + } + + std::vector<float> + pfb_clock_sync_fff_impl::channel_taps(int channel) const + { + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_taps[channel][i]); + } + return taps; + } + + std::vector<float> + pfb_clock_sync_fff_impl::diff_channel_taps(int channel) const + { + std::vector<float> taps; + for(int i = 0; i < d_taps_per_filter; i++) { + taps.push_back(d_dtaps[channel][i]); + } + return taps; + } + + int + pfb_clock_sync_fff_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float *in = (float *) input_items[0]; + float *out = (float *) output_items[0]; + + float *err = NULL, *outrate = NULL, *outk = NULL; + if(output_items.size() == 4) { + err = (float *) output_items[1]; + outrate = (float*)output_items[2]; + outk = (float*)output_items[3]; + } + + if(d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + // We need this many to process one output + int nrequired = ninput_items[0] - d_taps_per_filter - d_osps; + + int i = 0, count = 0; + + // produce output as long as we can and there are enough input samples + while((i < noutput_items) && (count < nrequired)) { + while(d_out_idx < d_osps) { + d_filtnum = (int)floor(d_k); + + // Keep the current filter number in [0, d_nfilters] + // If we've run beyond the last filter, wrap around and go to next sample + // If we've go below 0, wrap around and go to previous sample + while(d_filtnum >= d_nfilters) { + d_k -= d_nfilters; + d_filtnum -= d_nfilters; + count += 1; + } + while(d_filtnum < 0) { + d_k += d_nfilters; + d_filtnum += d_nfilters; + count -= 1; + } + + out[i+d_out_idx] = d_filters[d_filtnum]->filter(&in[count+d_out_idx]); + d_k = d_k + d_rate_i + d_rate_f; // update phase + d_out_idx++; + + if(output_items.size() == 4) { + err[i] = d_error; + outrate[i] = d_rate_f; + outk[i] = d_k; + } + + // We've run out of output items we can create; return now. + if(i+d_out_idx >= noutput_items) { + consume_each(count); + return i; + } + } + + // reset here; if we didn't complete a full osps samples last time, + // the early return would take care of it. + d_out_idx = 0; + + // Update the phase and rate estimates for this symbol + float diff = d_diff_filters[d_filtnum]->filter(&in[count]); + d_error = out[i] * diff; + + // Run the control loop to update the current phase (k) and + // tracking rate estimates based on the error value + d_rate_f = d_rate_f + d_beta*d_error; + d_k = d_k + d_alpha*d_error; + + // Keep our rate within a good range + d_rate_f = gr_branchless_clip(d_rate_f, d_max_dev); + + i+=d_osps; + count += (int)floor(d_sps); + } + + consume_each(count); + return i; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/pfb_clock_sync_fff_impl.h b/gr-digital/lib/pfb_clock_sync_fff_impl.h new file mode 100644 index 0000000000..2ade1e646f --- /dev/null +++ b/gr-digital/lib/pfb_clock_sync_fff_impl.h @@ -0,0 +1,112 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2010,2012 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_PFB_CLOCK_SYNC_FFF_IMPL_H +#define INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_IMPL_H + +#include <digital/pfb_clock_sync_fff.h> + +using namespace gr::filter; + +namespace gr { + namespace digital { + + class pfb_clock_sync_fff_impl : public pfb_clock_sync_fff + { + private: + bool d_updated; + double d_sps; + double d_sample_num; + float d_loop_bw; + float d_damping; + float d_alpha; + float d_beta; + + int d_nfilters; + int d_taps_per_filter; + std::vector<kernel::fir_filter_fff*> d_filters; + std::vector<kernel::fir_filter_fff*> d_diff_filters; + std::vector< std::vector<float> > d_taps; + std::vector< std::vector<float> > d_dtaps; + + float d_k; + float d_rate; + float d_rate_i; + float d_rate_f; + float d_max_dev; + int d_filtnum; + int d_osps; + float d_error; + int d_out_idx; + + void create_diff_taps(const std::vector<float> &newtaps, + std::vector<float> &difftaps); + + public: + pfb_clock_sync_fff_impl(double sps, float gain, + const std::vector<float> &taps, + unsigned int filter_size=32, + float init_phase=0, + float max_rate_deviation=1.5, + int osps=1); + ~pfb_clock_sync_fff_impl(); + + void update_gains(); + + void set_taps(const std::vector<float> &taps, + std::vector< std::vector<float> > &ourtaps, + std::vector<kernel::fir_filter_fff*> &ourfilter); + + std::vector< std::vector<float> > taps() const; + std::vector< std::vector<float> > diff_taps() const; + std::vector<float> channel_taps(int channel) const; + std::vector<float> diff_channel_taps(int channel) const; + std::string taps_as_string() const; + std::string diff_taps_as_string() const; + + void set_loop_bandwidth(float bw); + void set_damping_factor(float df); + void set_alpha(float alpha); + void set_beta(float beta); + void set_max_rate_deviation(float m) + { + d_max_dev = m; + } + + float loop_bandwidth() const; + float damping_factor() const; + float alpha() const; + float beta() const; + float clock_rate() const; + + bool check_topology(int ninputs, int noutputs); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PFB_CLOCK_SYNC_FFF_IMPL_H */ diff --git a/gr-digital/lib/pn_correlator_cc_impl.cc b/gr-digital/lib/pn_correlator_cc_impl.cc new file mode 100644 index 0000000000..da0bdbefe9 --- /dev/null +++ b/gr-digital/lib/pn_correlator_cc_impl.cc @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,2012 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 "pn_correlator_cc_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + pn_correlator_cc::sptr + pn_correlator_cc::make(int degree, int mask, int seed) + { + return gnuradio::get_initial_sptr + (new pn_correlator_cc_impl(degree, mask, seed)); + } + + pn_correlator_cc_impl::pn_correlator_cc_impl(int degree, + int mask, + int seed) + : gr_sync_decimator("pn_correlator_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + (unsigned int)((1ULL << degree)-1)) // PN code length + { + d_len = (unsigned int)((1ULL << degree)-1); + if(mask == 0) + mask = glfsr::glfsr_mask(degree); + d_reference = new glfsr(mask, seed); + for(int i = 0; i < d_len; i++) // initialize to last value in sequence + d_pn = 2.0*d_reference->next_bit()-1.0; + } + + pn_correlator_cc_impl::~pn_correlator_cc_impl() + { + delete d_reference; + } + + int + pn_correlator_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + gr_complex sum; + + for(int i = 0; i < noutput_items; i++) { + sum = 0.0; + + for(int j = 0; j < d_len; j++) { + if(j != 0) // retard PN generator one sample per period + d_pn = 2.0*d_reference->next_bit()-1.0; // no conditionals + sum += *in++ * d_pn; + } + + *out++ = sum*gr_complex(1.0/d_len, 0.0); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_glfsr_source_b.i b/gr-digital/lib/pn_correlator_cc_impl.h index b1c487209e..bea9a30505 100644 --- a/gr-digital/swig/digital_glfsr_source_b.i +++ b/gr-digital/lib/pn_correlator_cc_impl.h @@ -20,16 +20,32 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,glfsr_source_b); +#ifndef INCLUDED_GR_PN_CORRELATOR_CC_IMPL_H +#define INCLUDED_GR_PN_CORRELATOR_CC_IMPL_H -digital_glfsr_source_b_sptr -digital_make_glfsr_source_b(int degree, bool repeat=true, - int mask=0, int seed=1) - throw (std::runtime_error); +#include <digital/pn_correlator_cc.h> +#include <digital/glfsr.h> -class digital_glfsr_source_b : public gr_sync_block -{ -public: - unsigned int period() const; - int mask() const; -}; +namespace gr { + namespace digital { + + class pn_correlator_cc_impl : public pn_correlator_cc + { + private: + int d_len; + float d_pn; + glfsr *d_reference; + + public: + pn_correlator_cc_impl(int degree, int mask=0, int seed=1); + ~pn_correlator_cc_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PN_CORRELATOR_CC_IMPL_H */ diff --git a/gr-digital/lib/probe_density_b_impl.cc b/gr-digital/lib/probe_density_b_impl.cc new file mode 100644 index 0000000000..532930ad1b --- /dev/null +++ b/gr-digital/lib/probe_density_b_impl.cc @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 Free Software Foundation, Inc. + * + * 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 "probe_density_b_impl.h" +#include <gr_io_signature.h> +#include <iostream> + +namespace gr { + namespace digital { + + probe_density_b::sptr + probe_density_b::make(double alpha) + { + return gnuradio::get_initial_sptr + (new probe_density_b_impl(alpha)); + } + + probe_density_b_impl::probe_density_b_impl(double alpha) + : gr_sync_block("density_b", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(0, 0, 0)) + { + set_alpha(alpha); + d_density = 1.0; + } + + probe_density_b_impl::~probe_density_b_impl() + { + } + + void + probe_density_b_impl::set_alpha(double alpha) + { + d_alpha = alpha; + d_beta = 1.0-d_alpha; + } + + int + probe_density_b_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char *)input_items[0]; + + for(int i = 0; i < noutput_items; i++) + d_density = d_alpha*(double)in[i] + d_beta*d_density; + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/probe_density_b_impl.h b/gr-digital/lib/probe_density_b_impl.h new file mode 100644 index 0000000000..e792403dc5 --- /dev/null +++ b/gr-digital/lib/probe_density_b_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * 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_GR_PROBE_DENSITY_B_IMPL_H +#define INCLUDED_GR_PROBE_DENSITY_B_IMPL_H + +#include <digital/probe_density_b.h> + +namespace gr { + namespace digital { + + class probe_density_b_impl : public probe_density_b + { + private: + double d_alpha; + double d_beta; + double d_density; + + public: + probe_density_b_impl(double alpha); + ~probe_density_b_impl(); + + /*! + * \brief Returns the current density value + */ + double density() const { return d_density; } + + /*! + * \brief Set the average filter constant + */ + void set_alpha(double alpha); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PROBE_DENSITY_B_IMPL_H */ diff --git a/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc b/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc new file mode 100644 index 0000000000..31de586e05 --- /dev/null +++ b/gr-digital/lib/probe_mpsk_snr_est_c_impl.cc @@ -0,0 +1,157 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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 "probe_mpsk_snr_est_c_impl.h" +#include <gr_io_signature.h> +#include <cstdio> + +namespace gr { + namespace digital { + + probe_mpsk_snr_est_c::sptr + probe_mpsk_snr_est_c::make(snr_est_type_t type, + int msg_nsamples, + double alpha) + { + return gnuradio::get_initial_sptr + (new probe_mpsk_snr_est_c_impl(type, msg_nsamples, alpha)); + } + + probe_mpsk_snr_est_c_impl::probe_mpsk_snr_est_c_impl(snr_est_type_t type, + int msg_nsamples, + double alpha) + : gr_sync_block("probe_mpsk_snr_est_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)) + { + d_snr_est = NULL; + + d_type = type; + d_nsamples = msg_nsamples; + d_count = 0; + set_alpha(alpha); + + set_type(type); + + // at least 1 estimator has to look back + set_history(2); + + d_key = pmt::pmt_string_to_symbol("snr"); + } + + probe_mpsk_snr_est_c_impl::~probe_mpsk_snr_est_c_impl() + { + if(d_snr_est) + delete d_snr_est; + } + + int + probe_mpsk_snr_est_c_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + return d_snr_est->update(noutput_items, in); + } + + double + probe_mpsk_snr_est_c_impl::snr() + { + if(d_snr_est) + return d_snr_est->snr(); + else + throw std::runtime_error("probe_mpsk_snr_est_c_impl:: No SNR estimator defined.\n"); + } + + snr_est_type_t + probe_mpsk_snr_est_c_impl::type() const + { + return d_type; + } + + int + probe_mpsk_snr_est_c_impl::msg_nsample() const + { + return d_nsamples; + } + + double + probe_mpsk_snr_est_c_impl::alpha() const + { + return d_alpha; + } + + void + probe_mpsk_snr_est_c_impl::set_type(snr_est_type_t t) + { + d_type = t; + + if(d_snr_est) + delete d_snr_est; + + switch (d_type) { + case(SNR_EST_SIMPLE): + d_snr_est = new mpsk_snr_est_simple(d_alpha); + break; + case(SNR_EST_SKEW): + d_snr_est = new mpsk_snr_est_skew(d_alpha); + break; + case(SNR_EST_M2M4): + d_snr_est = new mpsk_snr_est_m2m4(d_alpha); + break; + case(SNR_EST_SVR): + d_snr_est = new mpsk_snr_est_svr(d_alpha); + break; + default: + throw std::invalid_argument("probe_mpsk_snr_est_c_impl: unknown type specified.\n"); + } + } + + void + probe_mpsk_snr_est_c_impl::set_msg_nsample(int n) + { + if(n > 0) { + d_nsamples = n; + d_count = 0; // reset state + } + else + throw std::invalid_argument("probe_mpsk_snr_est_c_impl: msg_nsamples can't be <= 0\n"); + } + + void + probe_mpsk_snr_est_c_impl::set_alpha(double alpha) + { + if((alpha >= 0) && (alpha <= 1.0)) { + d_alpha = alpha; + if(d_snr_est) + d_snr_est->set_alpha(d_alpha); + } + else + throw std::invalid_argument("probe_mpsk_snr_est_c_impl: alpha must be in [0,1]\n"); + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/lib/probe_mpsk_snr_est_c_impl.h b/gr-digital/lib/probe_mpsk_snr_est_c_impl.h new file mode 100644 index 0000000000..90da85d21b --- /dev/null +++ b/gr-digital/lib/probe_mpsk_snr_est_c_impl.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_PROBE_MPSK_SNR_EST_C_IMPL_H +#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_IMPL_H + +#include <digital/probe_mpsk_snr_est_c.h> + +namespace gr { + namespace digital { + + class probe_mpsk_snr_est_c_impl : public probe_mpsk_snr_est_c + { + private: + snr_est_type_t d_type; + int d_nsamples, d_count; + double d_alpha; + mpsk_snr_est *d_snr_est; + + //d_key is the message name, 'snr' + pmt::pmt_t d_key; + + public: + probe_mpsk_snr_est_c_impl(snr_est_type_t type, + int msg_nsamples=10000, + double alpha=0.001); + + ~probe_mpsk_snr_est_c_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + //! Return the estimated signal-to-noise ratio in decibels + double snr(); + + //! Return the type of estimator in use + snr_est_type_t type() const; + + //! Return how many samples between SNR messages + int msg_nsample() const; + + //! Get the running-average coefficient + double alpha() const; + + //! Set type of estimator to use + void set_type(snr_est_type_t t); + + //! Set the number of samples between SNR messages + void set_msg_nsample(int n); + + //! Set the running-average coefficient + void set_alpha(double alpha); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_IMPL_H */ diff --git a/gr-digital/lib/scrambler_bb_impl.cc b/gr-digital/lib/scrambler_bb_impl.cc new file mode 100644 index 0000000000..d656fe2430 --- /dev/null +++ b/gr-digital/lib/scrambler_bb_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,2012 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 "scrambler_bb_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace digital { + + scrambler_bb::sptr + scrambler_bb::make(int mask, int seed, int len) + { + return gnuradio::get_initial_sptr + (new scrambler_bb_impl(mask, seed, len)); + } + + scrambler_bb_impl::scrambler_bb_impl(int mask, int seed, int len) + : gr_sync_block("scrambler_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_lfsr(mask, seed, len) + { + } + + scrambler_bb_impl::~scrambler_bb_impl() + { + } + + int + scrambler_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = d_lfsr.next_bit_scramble(in[i]); + } + + return noutput_items; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_probe_density_b.i b/gr-digital/lib/scrambler_bb_impl.h index b0c8a119ad..4a93901c92 100644 --- a/gr-digital/swig/digital_probe_density_b.i +++ b/gr-digital/lib/scrambler_bb_impl.h @@ -20,14 +20,31 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,probe_density_b); +#ifndef INCLUDED_GR_SCRAMBLER_BB_IMPL_H +#define INCLUDED_GR_SCRAMBLER_BB_IMPL_H -digital_probe_density_b_sptr -digital_make_probe_density_b(double alpha); +#include <digital/scrambler_bb.h> +#include <gr_sync_block.h> +#include <gri_lfsr.h> -class digital_probe_density_b : public gr_sync_block -{ -public: - double density() const; - void set_alpha(double alpha); -}; +namespace gr { + namespace digital { + + class scrambler_bb_impl : public scrambler_bb + { + private: + gri_lfsr d_lfsr; + + public: + scrambler_bb_impl(int mask, int seed, int len); + ~scrambler_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SCRAMBLER_BB_IMPL_H */ diff --git a/gr-digital/lib/simple_framer_impl.cc b/gr-digital/lib/simple_framer_impl.cc new file mode 100644 index 0000000000..ff7e3ab614 --- /dev/null +++ b/gr-digital/lib/simple_framer_impl.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "simple_framer_impl.h" +#include <digital/simple_framer_sync.h> +#include <gr_io_signature.h> +#include <assert.h> +#include <string> + +namespace gr { + namespace digital { + + simple_framer::sptr + simple_framer::make(int payload_bytesize) + { + return gnuradio::get_initial_sptr + (new simple_framer_impl(payload_bytesize)); + } + + simple_framer_impl::simple_framer_impl(int payload_bytesize) + : gr_block("simple_framer", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char))), + d_seqno (0), d_payload_bytesize (payload_bytesize), + d_input_block_size (payload_bytesize), + d_output_block_size (payload_bytesize + GRSF_OVERHEAD) + { + set_output_multiple(d_output_block_size); + } + + simple_framer_impl::~simple_framer_impl() + { + } + + void + simple_framer_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + assert(noutput_items % d_output_block_size == 0); + + int nblocks = noutput_items / d_output_block_size; + int input_required = nblocks * d_input_block_size; + + unsigned ninputs = ninput_items_required.size(); + for(unsigned int i = 0; i < ninputs; i++) + ninput_items_required[i] = input_required; + } + + int + simple_framer_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char*)input_items[0]; + unsigned char *out = (unsigned char*)output_items[0]; + + int n = 0; + int nblocks = 0; + + memset(out, 0x55, noutput_items); + + while(n < noutput_items) { + out[0] = (GRSF_SYNC >> 56) & 0xff; + out[1] = (GRSF_SYNC >> 48) & 0xff; + out[2] = (GRSF_SYNC >> 40) & 0xff; + out[3] = (GRSF_SYNC >> 32) & 0xff; + out[4] = (GRSF_SYNC >> 24) & 0xff; + out[5] = (GRSF_SYNC >> 16) & 0xff; + out[6] = (GRSF_SYNC >> 8) & 0xff; + out[7] = (GRSF_SYNC >> 0) & 0xff; + out[8] = d_seqno++; + + memcpy(&out[9], in, d_input_block_size); + in += d_input_block_size; + out += d_output_block_size; + n += d_output_block_size; + nblocks++; + } + + assert(n == noutput_items); + + consume_each(nblocks * d_input_block_size); + return n; + } + + } /* namespace digital */ +} /* namespace gr */ diff --git a/gr-digital/swig/digital_simple_framer.i b/gr-digital/lib/simple_framer_impl.h index a376317c5c..fe967eb26a 100644 --- a/gr-digital/swig/digital_simple_framer.i +++ b/gr-digital/lib/simple_framer_impl.h @@ -20,11 +20,36 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,simple_framer); +#ifndef INCLUDED_GR_SIMPLE_FRAMER_IMPL_H +#define INCLUDED_GR_SIMPLE_FRAMER_IMPL_H -digital_simple_framer_sptr -digital_make_simple_framer(int payload_bytesize); +#include <digital/simple_framer.h> -class digital_simple_framer : public gr_block -{ -}; +namespace gr { + namespace digital { + + class simple_framer_impl : public simple_framer + { + private: + int d_seqno; + int d_payload_bytesize; + int d_input_block_size; // bytes + int d_output_block_size; // bytes + + public: + simple_framer_impl(int payload_bytesize); + ~simple_framer_impl(); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_IMPL_H */ diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 6a9f102955..fdb5acd819 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -71,6 +71,8 @@ foreach(py_qa_test_file ${py_qa_test_files}) ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig ${CMAKE_BINARY_DIR}/gr-digital/python ${CMAKE_BINARY_DIR}/gr-digital/swig + ${CMAKE_BINARY_DIR}/gr-filter/python + ${CMAKE_BINARY_DIR}/gr-filter/swig ) set(GR_TEST_TARGET_DEPS volk gruel gnuradio-core gnuradio-digital) GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py index bee6cb0034..57cf2534f4 100644 --- a/gr-digital/python/bpsk.py +++ b/gr-digital/python/bpsk.py @@ -116,9 +116,8 @@ class dbpsk_mod(bpsk_mod): __doc__ += shared_mod_args def __init__(self, mod_code=None, *args, **kwargs): - super(dbpsk_mod, self).__init__(differential=True, - *args, **kwargs) -#dbpsk_mod.__doc__ += shared_mod_args + + super(dbpsk_mod, self).__init__(*args, **kwargs) # ///////////////////////////////////////////////////////////////////////////// # DBPSK demodulator @@ -139,9 +138,8 @@ class dbpsk_demod(bpsk_demod): __doc__ += shared_demod_args def __init__(self, mod_code=None, *args, **kwargs): - super(dbpsk_demod, self).__init__(differential=True, - *args, **kwargs) -#dbpsk_demod.__doc__ += shared_demod_args + + super(dbpsk_demod, self).__init__(*args, **kwargs) # # Add these to the mod/demod registry diff --git a/gr-digital/python/cpm.py b/gr-digital/python/cpm.py index 194eb71a81..a2c9f2f0e0 100644 --- a/gr-digital/python/cpm.py +++ b/gr-digital/python/cpm.py @@ -24,7 +24,7 @@ # See gnuradio-examples/python/digital for examples -from gnuradio import gr, blks2 +from gnuradio import gr, filter from math import pi import numpy @@ -142,7 +142,7 @@ class cpm_mod(gr.hier_block2): else: raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,)) - self.filter = blks2.pfb_arb_resampler_fff(samples_per_symbol, self.taps) + self.filter = filter.pfb.arb_resampler_fff(samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) diff --git a/gr-digital/python/crc.py b/gr-digital/python/crc.py index 198ab059f5..e228faaa98 100644 --- a/gr-digital/python/crc.py +++ b/gr-digital/python/crc.py @@ -20,11 +20,11 @@ # from gnuradio import gru -import digital_swig +import digital_swig as digital import struct def gen_and_append_crc32(s): - crc = digital_swig.crc32(s) + crc = digital.crc32(s) return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF) def check_crc32(s): @@ -32,7 +32,7 @@ def check_crc32(s): return (False, '') msg = s[:-4] #print "msg = '%s'" % (msg,) - actual = digital_swig.crc32(msg) + actual = digital.crc32(msg) (expected,) = struct.unpack(">I", s[-4:]) # print "actual =", hex(actual), "expected =", hex(expected) return (actual == expected, msg) diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index 6f27092429..855249dc63 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -31,6 +31,11 @@ from utils import mod_codes import digital_swig as digital import math +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + # default values (used in __init__ and add_options) _def_samples_per_symbol = 2 _def_excess_bw = 0.35 @@ -102,7 +107,7 @@ class generic_mod(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - self._constellation = constellation.base() + self._constellation = constellation self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._differential = differential @@ -135,8 +140,8 @@ class generic_mod(gr.hier_block2): 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) - self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol, - self.rrc_taps) + self.rrc_filter = filter.pfb_arb_resampler_ccf(self._samples_per_symbol, + self.rrc_taps) # Connect blocks = [self, self.bytes2chunks] @@ -238,7 +243,7 @@ class generic_demod(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - self._constellation = constellation.base() + self._constellation = constellation self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw @@ -276,7 +281,7 @@ class generic_demod(gr.hier_block2): fmin = -0.25 fmax = 0.25 self.receiver = digital.constellation_receiver_cb( - self._constellation, self._phase_bw, + self._constellation.base(), self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py index aa602d8b8d..09f12ebc30 100644 --- a/gr-digital/python/gfsk.py +++ b/gr-digital/python/gfsk.py @@ -32,6 +32,11 @@ import numpy from pprint import pprint import inspect +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + # default values (used in __init__ and add_options) _def_samples_per_symbol = 2 _def_sensitivity = 1 @@ -91,7 +96,9 @@ class gfsk_mod(gr.hier_block2): #sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 # Turn it into NRZ data. - self.nrz = gr.bytes_to_syms() + #self.nrz = digital.bytes_to_syms() + self.unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) + self.nrz = digital.chunks_to_symbols_bf([-1, 1]) # Form Gaussian filter # Generate Gaussian response (Needs to be convolved with window below). @@ -104,7 +111,7 @@ class gfsk_mod(gr.hier_block2): self.sqwave = (1,) * samples_per_symbol # rectangular window self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) - self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) + self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) @@ -119,7 +126,7 @@ class gfsk_mod(gr.hier_block2): self._setup_logging() # Connect & Initialize base class - self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self.amp, self) + self.connect(self, self.unpack, self.nrz, self.gaussian_filter, self.fmmod, self.amp, self) def samples_per_symbol(self): return self._samples_per_symbol diff --git a/gr-digital/python/gmsk.py b/gr-digital/python/gmsk.py index d7b547d012..e7853dd0af 100644 --- a/gr-digital/python/gmsk.py +++ b/gr-digital/python/gmsk.py @@ -32,6 +32,12 @@ import numpy from pprint import pprint import inspect +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + + # default values (used in __init__ and add_options) _def_samples_per_symbol = 2 _def_bt = 0.35 @@ -89,7 +95,9 @@ class gmsk_mod(gr.hier_block2): sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 # Turn it into NRZ data. - self.nrz = gr.bytes_to_syms() + #self.nrz = digital.bytes_to_syms() + self.unpack = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) + self.nrz = digital.chunks_to_symbols_bf([-1, 1], 1) # Form Gaussian filter # Generate Gaussian response (Needs to be convolved with window below). @@ -102,7 +110,7 @@ class gmsk_mod(gr.hier_block2): self.sqwave = (1,) * samples_per_symbol # rectangular window self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) - self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) + self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) @@ -114,7 +122,7 @@ class gmsk_mod(gr.hier_block2): self._setup_logging() # Connect & Initialize base class - self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self) + self.connect(self, self.unpack, self.nrz, self.gaussian_filter, self.fmmod, self) def samples_per_symbol(self): return self._samples_per_symbol diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index 4c53ad0108..4113a552eb 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -21,8 +21,8 @@ # import math -from gnuradio import gr -import digital_swig +from gnuradio import gr, fft +import digital_swig as digital import ofdm_packet_utils from ofdm_receiver import ofdm_receiver import gnuradio.gr.gr_threading as _threading @@ -97,16 +97,16 @@ class ofdm_mod(gr.hier_block2): constel = qam.qam_constellation(arity) rotated_const = map(lambda pt: pt * rot, constel.points()) #print rotated_const - self._pkt_input = digital_swig.ofdm_mapper_bcv(rotated_const, - msgq_limit, - options.occupied_tones, - options.fft_length) + self._pkt_input = digital.ofdm_mapper_bcv(rotated_const, + msgq_limit, + options.occupied_tones, + options.fft_length) - self.preambles = digital_swig.ofdm_insert_preamble(self._fft_length, - padded_preambles) - self.ifft = gr.fft_vcc(self._fft_length, False, win, True) - self.cp_adder = digital_swig.ofdm_cyclic_prefixer(self._fft_length, - symbol_length) + self.preambles = digital.ofdm_insert_preamble(self._fft_length, + padded_preambles) + self.ifft = fft.fft_vcc(self._fft_length, False, win, True) + self.cp_adder = digital.ofdm_cyclic_prefixer(self._fft_length, + symbol_length) self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) self.connect((self._pkt_input, 0), (self.preambles, 0)) @@ -240,10 +240,10 @@ class ofdm_demod(gr.hier_block2): phgain = 0.25 frgain = phgain*phgain / 4.0 - self.ofdm_demod = digital_swig.ofdm_frame_sink(rotated_const, range(arity), - self._rcvd_pktq, - self._occupied_tones, - phgain, frgain) + self.ofdm_demod = digital.ofdm_frame_sink(rotated_const, range(arity), + self._rcvd_pktq, + self._occupied_tones, + phgain, frgain) self.connect(self, self.ofdm_recv) self.connect((self.ofdm_recv, 0), (self.ofdm_demod, 0)) diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index 33d9b66268..1dc3cdf7cd 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -24,12 +24,17 @@ import math from numpy import fft from gnuradio import gr -import digital_swig +import digital_swig as digital from ofdm_sync_pn import ofdm_sync_pn from ofdm_sync_fixed import ofdm_sync_fixed from ofdm_sync_pnac import ofdm_sync_pnac from ofdm_sync_ml import ofdm_sync_ml +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + class ofdm_receiver(gr.hier_block2): """ Performs receiver synchronization on OFDM symbols. @@ -67,7 +72,7 @@ class ofdm_receiver(gr.hier_block2): bw+tb, # midpoint of trans. band tb, # width of trans. band gr.firdes.WIN_HAMMING) # filter type - self.chan_filt = gr.fft_filter_ccc(1, chan_coeffs) + self.chan_filt = filter.fft_filter_ccc(1, chan_coeffs) win = [1 for i in range(fft_length)] @@ -116,9 +121,9 @@ class ofdm_receiver(gr.hier_block2): self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block self.sigmix = gr.multiply_cc() - self.sampler = digital_swig.ofdm_sampler(fft_length, fft_length+cp_length) + self.sampler = digital.ofdm_sampler(fft_length, fft_length+cp_length) self.fft_demod = gr.fft_vcc(fft_length, True, win, True) - self.ofdm_frame_acq = digital_swig.ofdm_frame_acquisition(occupied_tones, + self.ofdm_frame_acq = digital.ofdm_frame_acquisition(occupied_tones, fft_length, cp_length, ks[0]) diff --git a/gr-digital/python/ofdm_sync_ml.py b/gr-digital/python/ofdm_sync_ml.py index 7c75d7f1d4..f732fdf29a 100644 --- a/gr-digital/python/ofdm_sync_ml.py +++ b/gr-digital/python/ofdm_sync_ml.py @@ -23,6 +23,11 @@ import math from gnuradio import gr +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + class ofdm_sync_ml(gr.hier_block2): def __init__(self, fft_length, cp_length, snr, kstime, logging): ''' Maximum Likelihood OFDM synchronizer: @@ -57,7 +62,7 @@ class ofdm_sync_ml(gr.hier_block2): self.adder = gr.add_ff() moving_sum_taps = [rho/2 for i in range(cp_length)] - self.moving_sum_filter = gr.fir_filter_fff(1,moving_sum_taps) + self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps) self.connect(self.input,self.magsqrd1) self.connect(self.delay,self.magsqrd2) @@ -71,7 +76,7 @@ class ofdm_sync_ml(gr.hier_block2): self.mixer = gr.multiply_cc(); movingsum2_taps = [1.0 for i in range(cp_length)] - self.movingsum2 = gr.fir_filter_ccf(1,movingsum2_taps) + self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps) # Correlator data handler self.c2mag = gr.complex_to_mag() @@ -115,7 +120,7 @@ class ofdm_sync_ml(gr.hier_block2): # to readjust the timing in the middle of the packet or we ruin the equalizer settings. kstime = [k.conjugate() for k in kstime] kstime.reverse() - self.kscorr = gr.fir_filter_ccc(1, kstime) + self.kscorr = filter.fir_filter_ccc(1, kstime) self.corrmag = gr.complex_to_mag_squared() self.div = gr.divide_ff() diff --git a/gr-digital/python/ofdm_sync_pn.py b/gr-digital/python/ofdm_sync_pn.py index 05b1de2e19..8307a8ee14 100644 --- a/gr-digital/python/ofdm_sync_pn.py +++ b/gr-digital/python/ofdm_sync_pn.py @@ -24,6 +24,11 @@ import math from numpy import fft from gnuradio import gr +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + class ofdm_sync_pn(gr.hier_block2): def __init__(self, fft_length, cp_length, logging=False): """ @@ -51,19 +56,19 @@ class ofdm_sync_pn(gr.hier_block2): # Create a moving sum filter for the corr output if 1: moving_sum_taps = [1.0 for i in range(fft_length//2)] - self.moving_sum_filter = gr.fir_filter_ccf(1,moving_sum_taps) + self.moving_sum_filter = filter.fir_filter_ccf(1,moving_sum_taps) else: moving_sum_taps = [complex(1.0,0.0) for i in range(fft_length//2)] - self.moving_sum_filter = gr.fft_filter_ccc(1,moving_sum_taps) + self.moving_sum_filter = filter.fft_filter_ccc(1,moving_sum_taps) # Create a moving sum filter for the input self.inputmag2 = gr.complex_to_mag_squared() movingsum2_taps = [1.0 for i in range(fft_length//2)] if 1: - self.inputmovingsum = gr.fir_filter_fff(1,movingsum2_taps) + self.inputmovingsum = filter.fir_filter_fff(1,movingsum2_taps) else: - self.inputmovingsum = gr.fft_filter_fff(1,movingsum2_taps) + self.inputmovingsum = filter.fft_filter_fff(1,movingsum2_taps) self.square = gr.multiply_ff() self.normalize = gr.divide_ff() @@ -100,7 +105,7 @@ class ofdm_sync_pn(gr.hier_block2): # Create a moving sum filter for the corr output matched_filter_taps = [1.0/cp_length for i in range(cp_length)] - self.matched_filter = gr.fir_filter_fff(1,matched_filter_taps) + self.matched_filter = filter.fir_filter_fff(1,matched_filter_taps) self.connect(self.normalize, self.matched_filter) self.connect(self.matched_filter, self.sub1, self.pk_detect) diff --git a/gr-digital/python/ofdm_sync_pnac.py b/gr-digital/python/ofdm_sync_pnac.py index 10a1259641..a5edc272a8 100644 --- a/gr-digital/python/ofdm_sync_pnac.py +++ b/gr-digital/python/ofdm_sync_pnac.py @@ -24,6 +24,11 @@ import math from numpy import fft from gnuradio import gr +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + class ofdm_sync_pnac(gr.hier_block2): def __init__(self, fft_length, cp_length, kstime, logging=False): """ @@ -59,7 +64,7 @@ class ofdm_sync_pnac(gr.hier_block2): # cross-correlate with the known symbol kstime = [k.conjugate() for k in kstime[0:fft_length//2]] kstime.reverse() - self.crosscorr_filter = gr.fir_filter_ccc(1, kstime) + self.crosscorr_filter = filter.fir_filter_ccc(1, kstime) # Create a delay line self.delay = gr.delay(gr.sizeof_gr_complex, fft_length/2) @@ -71,7 +76,7 @@ class ofdm_sync_pnac(gr.hier_block2): # Create a moving sum filter for the input self.mag = gr.complex_to_mag_squared() movingsum_taps = (fft_length//1)*[1.0,] - self.power = gr.fir_filter_fff(1,movingsum_taps) + self.power = filter.fir_filter_fff(1,movingsum_taps) # Get magnitude (peaks) and angle (phase/freq error) self.c2mag = gr.complex_to_mag_squared() diff --git a/gr-digital/python/pkt.py b/gr-digital/python/pkt.py index 283a150d2c..d084c3ff0f 100644 --- a/gr-digital/python/pkt.py +++ b/gr-digital/python/pkt.py @@ -23,7 +23,7 @@ from math import pi from gnuradio import gr import gnuradio.gr.gr_threading as _threading import packet_utils -import digital_swig +import digital_swig as digital # ///////////////////////////////////////////////////////////////////////////// @@ -136,7 +136,7 @@ class demod_pkts(gr.hier_block2): threshold = 12 # FIXME raise exception self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY - self.correlator = digital_swig.correlate_access_code_bb(access_code, threshold) + self.correlator = digital.correlate_access_code_bb(access_code, threshold) self.framer_sink = digital.framer_sink_1(self._rcvd_pktq) self.connect(self, self._demodulator, self.correlator, self.framer_sink) diff --git a/gr-digital/python/qa_binary_slicer_fb.py b/gr-digital/python/qa_binary_slicer_fb.py index 60d92c5d19..22f7da73ff 100755 --- a/gr-digital/python/qa_binary_slicer_fb.py +++ b/gr-digital/python/qa_binary_slicer_fb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,33 +21,33 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import math, random -class test_binary_slicer_fb (gr_unittest.TestCase): +class test_binary_slicer_fb(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_binary_slicer_fb (self): + def test_binary_slicer_fb(self): expected_result = ( 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1) src_data = (-1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1) src_data = [s + (1 - random.random()) for s in src_data] # add some noise - src = gr.vector_source_f (src_data) - op = digital_swig.binary_slicer_fb () - dst = gr.vector_sink_b () + src = gr.vector_source_f(src_data) + op = digital.binary_slicer_fb() + dst = gr.vector_sink_b() - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink + actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result) if __name__ == '__main__': diff --git a/gr-digital/python/qa_bytes_to_syms.py b/gr-digital/python/qa_bytes_to_syms.py deleted file mode 100755 index 75475a95b2..0000000000 --- a/gr-digital/python/qa_bytes_to_syms.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010,2012 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. -# - -from gnuradio import gr, gr_unittest -import digital_swig as digital -import math - -class test_bytes_to_syms (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_bytes_to_syms_001 (self): - src_data = (0x01, 0x80, 0x03) - expected_result = (-1, -1, -1, -1, -1, -1, -1, +1, - +1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, +1, +1) - src = gr.vector_source_b (src_data) - op = digital.bytes_to_syms () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - -if __name__ == '__main__': - gr_unittest.run(test_bytes_to_syms, "test_bytes_to_syms.xml") - diff --git a/gr-digital/python/qa_chunks_to_symbols.py b/gr-digital/python/qa_chunks_to_symbols.py index 63af10d8ff..5ffe425132 100755 --- a/gr-digital/python/qa_chunks_to_symbols.py +++ b/gr-digital/python/qa_chunks_to_symbols.py @@ -25,10 +25,10 @@ import digital_swig as digital class test_chunks_to_symbols(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_bc_001(self): diff --git a/gr-digital/python/qa_clock_recovery_mm.py b/gr-digital/python/qa_clock_recovery_mm.py index f4c345b034..e904cf4c21 100755 --- a/gr-digital/python/qa_clock_recovery_mm.py +++ b/gr-digital/python/qa_clock_recovery_mm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,18 +21,18 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import random, cmath class test_clock_recovery_mm(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): # Test complex/complex version omega = 2 gain_omega = 0.001 @@ -40,9 +40,9 @@ class test_clock_recovery_mm(gr_unittest.TestCase): gain_mu = 0.01 omega_rel_lim = 0.001 - self.test = digital_swig.clock_recovery_mm_cc(omega, gain_omega, - mu, gain_mu, - omega_rel_lim) + self.test = digital.clock_recovery_mm_cc(omega, gain_omega, + mu, gain_mu, + omega_rel_lim) data = 100*[complex(1, 1),] self.src = gr.vector_source_c(data, False) @@ -64,10 +64,10 @@ class test_clock_recovery_mm(gr_unittest.TestCase): #print expected_result #print dst_data - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5) - def test02 (self): + def test02(self): # Test float/float version omega = 2 gain_omega = 0.01 @@ -75,9 +75,9 @@ class test_clock_recovery_mm(gr_unittest.TestCase): gain_mu = 0.01 omega_rel_lim = 0.001 - self.test = digital_swig.clock_recovery_mm_ff(omega, gain_omega, - mu, gain_mu, - omega_rel_lim) + self.test = digital.clock_recovery_mm_ff(omega, gain_omega, + mu, gain_mu, + omega_rel_lim) data = 100*[1,] self.src = gr.vector_source_f(data, False) @@ -99,10 +99,10 @@ class test_clock_recovery_mm(gr_unittest.TestCase): #print expected_result #print dst_data - self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 5) + self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5) - def test03 (self): + def test03(self): # Test complex/complex version with varying input omega = 2 gain_omega = 0.01 @@ -110,9 +110,9 @@ class test_clock_recovery_mm(gr_unittest.TestCase): gain_mu = 0.1 omega_rel_lim = 0.0001 - self.test = digital_swig.clock_recovery_mm_cc(omega, gain_omega, - mu, gain_mu, - omega_rel_lim) + self.test = digital.clock_recovery_mm_cc(omega, gain_omega, + mu, gain_mu, + omega_rel_lim) data = 1000*[complex(1, 1), complex(1, 1), complex(-1, -1), complex(-1, -1)] self.src = gr.vector_source_c(data, False) @@ -134,10 +134,10 @@ class test_clock_recovery_mm(gr_unittest.TestCase): #print expected_result #print dst_data - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) - def test04 (self): + def test04(self): # Test float/float version omega = 2 gain_omega = 0.01 @@ -145,9 +145,9 @@ class test_clock_recovery_mm(gr_unittest.TestCase): gain_mu = 0.1 omega_rel_lim = 0.001 - self.test = digital_swig.clock_recovery_mm_ff(omega, gain_omega, - mu, gain_mu, - omega_rel_lim) + self.test = digital.clock_recovery_mm_ff(omega, gain_omega, + mu, gain_mu, + omega_rel_lim) data = 1000*[1, 1, -1, -1] self.src = gr.vector_source_f(data, False) @@ -169,7 +169,7 @@ class test_clock_recovery_mm(gr_unittest.TestCase): #print expected_result #print dst_data - self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1) if __name__ == '__main__': diff --git a/gr-digital/python/qa_cma_equalizer.py b/gr-digital/python/qa_cma_equalizer.py index 75fb0f05ed..2af1505c1c 100755 --- a/gr-digital/python/qa_cma_equalizer.py +++ b/gr-digital/python/qa_cma_equalizer.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital class test_cma_equalizer_fir(gr_unittest.TestCase): @@ -33,7 +33,7 @@ class test_cma_equalizer_fir(gr_unittest.TestCase): def transform(self, src_data): SRC = gr.vector_source_c(src_data, False) - EQU = digital_swig.cma_equalizer_cc(4, 1.0, .001, 1) + EQU = digital.cma_equalizer_cc(4, 1.0, .001, 1) DST = gr.vector_sink_c() self.tb.connect(SRC, EQU, DST) self.tb.run() @@ -44,7 +44,11 @@ class test_cma_equalizer_fir(gr_unittest.TestCase): src_data = (1+0j, 0+1j, -1+0j, 0-1j)*1000 expected_data = src_data result = self.transform(src_data) - self.assertComplexTuplesAlmostEqual(expected_data, result) + + # only test last N samples to allow for settling. Also adjust + # for a 1 sample delay in the filter. + N = -500 + self.assertComplexTuplesAlmostEqual(expected_data[N:-1], result[N+1:]) if __name__ == "__main__": gr_unittest.run(test_cma_equalizer_fir, "test_cma_equalizer_fir.xml") diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index e0b5b3888e..750337a119 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -25,7 +25,7 @@ from cmath import exp, pi, log from gnuradio import gr, gr_unittest, blks2 from utils import mod_codes -import digital_swig +import digital_swig as digital # import from local folder import psk @@ -50,7 +50,7 @@ def twod_constell(): (-1+0j), (0-1j)) rot_sym = 2 dim = 2 - return digital_swig.constellation_calcdist(points, [], rot_sym, dim) + return digital.constellation_calcdist(points, [], rot_sym, dim) def threed_constell(): oned_points = ((1+0j), (0+1j), (-1+0j), (0-1j)) @@ -62,7 +62,7 @@ def threed_constell(): points += [oned_points[ia], oned_points[ib], oned_points[ic]] rot_sym = 4 dim = 3 - return digital_swig.constellation_calcdist(points, [], rot_sym, dim) + return digital.constellation_calcdist(points, [], rot_sym, dim) tested_constellation_info = ( (psk.psk_constellation, @@ -85,10 +85,10 @@ tested_constellation_info = ( 'mod_code': tested_mod_codes, 'differential': (False,)}, False, None), - (digital_swig.constellation_bpsk, {}, True, None), - (digital_swig.constellation_qpsk, {}, False, None), - (digital_swig.constellation_dqpsk, {}, True, None), - (digital_swig.constellation_8psk, {}, False, None), + (digital.constellation_bpsk, {}, True, None), + (digital.constellation_qpsk, {}, False, None), + (digital.constellation_dqpsk, {}, True, None), + (digital.constellation_8psk, {}, False, None), (twod_constell, {}, True, None), (threed_constell, {}, True, None), ) @@ -123,7 +123,7 @@ def tested_constellations(): break -class test_constellation (gr_unittest.TestCase): +class test_constellation(gr_unittest.TestCase): src_length = 256 @@ -151,7 +151,7 @@ class test_constellation (gr_unittest.TestCase): data = dst.data() # Don't worry about cut off data for now. first = constellation.bits_per_symbol() - self.assertEqual (self.src_data[first:len(data)], data[first:]) + self.assertEqual(self.src_data[first:len(data)], data[first:]) class mod_demod(gr.hier_block2): @@ -173,8 +173,7 @@ class mod_demod(gr.hier_block2): self.blocks = [self] # We expect a stream of unpacked bits. # First step is to pack them. - self.blocks.append( - gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)) + self.blocks.append(gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)) # Second step we unpack them such that we have k bits in each byte where # each constellation symbol hold k bits. self.blocks.append( @@ -183,13 +182,13 @@ class mod_demod(gr.hier_block2): # Apply any pre-differential coding # Gray-coding is done here if we're also using differential coding. if self.constellation.apply_pre_diff_code(): - self.blocks.append(digital_swig.map_bb(self.constellation.pre_diff_code())) + self.blocks.append(digital.map_bb(self.constellation.pre_diff_code())) # Differential encoding. if self.differential: - self.blocks.append(digital_swig.diff_encoder_bb(arity)) + self.blocks.append(digital.diff_encoder_bb(arity)) # Convert to constellation symbols. - self.blocks.append(digital_swig.chunks_to_symbols_bc(self.constellation.points(), - self.constellation.dimensionality())) + self.blocks.append(digital.chunks_to_symbols_bc(self.constellation.points(), + self.constellation.dimensionality())) # CHANNEL # Channel just consists of a rotation to check differential coding. if rotation is not None: @@ -197,13 +196,13 @@ class mod_demod(gr.hier_block2): # RX # Convert the constellation symbols back to binary values. - self.blocks.append(digital_swig.constellation_decoder_cb(self.constellation.base())) + self.blocks.append(digital.constellation_decoder_cb(self.constellation.base())) # Differential decoding. if self.differential: - self.blocks.append(digital_swig.diff_decoder_bb(arity)) + self.blocks.append(digital.diff_decoder_bb(arity)) # Decode any pre-differential coding. if self.constellation.apply_pre_diff_code(): - self.blocks.append(digital_swig.map_bb( + self.blocks.append(digital.map_bb( mod_codes.invert_code(self.constellation.pre_diff_code()))) # unpack the k bit vector into a stream of bits self.blocks.append(gr.unpack_k_bits_bb( @@ -214,7 +213,6 @@ class mod_demod(gr.hier_block2): self.blocks.append(self) self.connect(*self.blocks) - if __name__ == '__main__': gr_unittest.run(test_constellation, "test_constellation.xml") diff --git a/gr-digital/python/qa_constellation_decoder_cb.py b/gr-digital/python/qa_constellation_decoder_cb.py index 5401a07fc0..6a93b6e743 100755 --- a/gr-digital/python/qa_constellation_decoder_cb.py +++ b/gr-digital/python/qa_constellation_decoder_cb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2004,2007,2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,54 +21,54 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import math -class test_constellation_decoder (gr_unittest.TestCase): +class test_constellation_decoder(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_constellation_decoder_cb_bpsk (self): - cnst = digital_swig.constellation_bpsk() + def test_constellation_decoder_cb_bpsk(self): + cnst = digital.constellation_bpsk() src_data = (0.5 + 0.5j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = ( 1, 1, 0, 0, 1, 0, 1) - src = gr.vector_source_c (src_data) - op = digital_swig.constellation_decoder_cb (cnst.base()) - dst = gr.vector_sink_b () + src = gr.vector_source_c(src_data) + op = digital.constellation_decoder_cb(cnst.base()) + dst = gr.vector_sink_b() - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink + actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result) - def test_constellation_decoder_cb_qpsk (self): - cnst = digital_swig.constellation_qpsk() + def _test_constellation_decoder_cb_qpsk(self): + cnst = digital.constellation_qpsk() src_data = (0.5 + 0.5j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = ( 3, 1, 0, 2, 3, 2, 1) - src = gr.vector_source_c (src_data) - op = digital_swig.constellation_decoder_cb (cnst.base()) - dst = gr.vector_sink_b () + src = gr.vector_source_c(src_data) + op = digital_swig.constellation_decoder_cb(cnst.base()) + dst = gr.vector_sink_b() - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink + actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result) if __name__ == '__main__': diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index 8c2d2da0c5..871df2da28 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -24,7 +24,8 @@ import random from gnuradio import gr, blks2, gr_unittest from utils import mod_codes, alignment -import digital_swig, packet_utils +import packet_utils +import filter_swig as filter from generic_mod_demod import generic_mod, generic_demod from qa_constellation import tested_constellations, twod_constell @@ -51,7 +52,7 @@ FREQ_BW = 2*math.pi/100.0 PHASE_BW = 2*math.pi/100.0 -class test_constellation_receiver (gr_unittest.TestCase): +class test_constellation_receiver(gr_unittest.TestCase): # We ignore the first half of the output data since often it takes # a while for the receiver to lock on. @@ -104,7 +105,7 @@ class test_constellation_receiver (gr_unittest.TestCase): self.assertTrue(correct > REQ_CORRECT) -class rec_test_tb (gr.top_block): +class rec_test_tb(gr.top_block): """ Takes a constellation an runs a generic modulation, channel, and generic demodulation. @@ -130,9 +131,9 @@ class rec_test_tb (gr.top_block): mod = generic_mod(constellation, differential=differential) # Channel if freq_offset: - channel = gr.channel_model(NOISE_VOLTAGE, FREQUENCY_OFFSET, TIMING_OFFSET) + channel = filter.channel_model(NOISE_VOLTAGE, FREQUENCY_OFFSET, TIMING_OFFSET) else: - channel = gr.channel_model(NOISE_VOLTAGE, 0, TIMING_OFFSET) + channel = filter.channel_model(NOISE_VOLTAGE, 0, TIMING_OFFSET) # Receiver Blocks if freq_offset: demod = generic_demod(constellation, differential=differential, diff --git a/gr-digital/python/qa_correlate_access_code.py b/gr-digital/python/qa_correlate_access_code.py index 96246dcfb9..5a5f2209f7 100755 --- a/gr-digital/python/qa_correlate_access_code.py +++ b/gr-digital/python/qa_correlate_access_code.py @@ -52,13 +52,13 @@ class test_correlate_access_code(gr_unittest.TestCase): # 0 0 0 1 0 0 0 1 src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7 expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6 - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.correlate_access_code_bb("1011", 0) - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) def test_002(self): @@ -69,13 +69,13 @@ class test_correlate_access_code(gr_unittest.TestCase): #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = pad + code + (3, 0, 1, 1) - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.correlate_access_code_bb(access_code, 0) - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) def test_003(self): code = tuple(string_to_1_0_list(default_access_code)) @@ -85,14 +85,13 @@ class test_correlate_access_code(gr_unittest.TestCase): #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = code + (1, 0, 1, 1) + pad - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.correlate_access_code_tag_bb(access_code, 0, "test") - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) if __name__ == '__main__': gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml") diff --git a/gr-digital/python/qa_costas_loop_cc.py b/gr-digital/python/qa_costas_loop_cc.py index 75fdbc2f84..365eda736a 100755 --- a/gr-digital/python/qa_costas_loop_cc.py +++ b/gr-digital/python/qa_costas_loop_cc.py @@ -21,22 +21,23 @@ # from gnuradio import gr, gr_unittest -import digital_swig, psk +import digital_swig as digital +import psk import random, cmath class test_costas_loop_cc(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): # test basic functionality by setting all gains to 0 natfreq = 0.0 order = 2 - self.test = digital_swig.costas_loop_cc(natfreq, order) + self.test = digital.costas_loop_cc(natfreq, order) data = 100*[complex(1,0),] self.src = gr.vector_source_c(data, False) @@ -47,13 +48,13 @@ class test_costas_loop_cc(gr_unittest.TestCase): expected_result = data dst_data = self.snk.data() - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5) - def test02 (self): + def test02(self): # Make sure it doesn't diverge given perfect data natfreq = 0.25 order = 2 - self.test = digital_swig.costas_loop_cc(natfreq, order) + self.test = digital.costas_loop_cc(natfreq, order) data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] self.src = gr.vector_source_c(data, False) @@ -65,13 +66,13 @@ class test_costas_loop_cc(gr_unittest.TestCase): expected_result = data dst_data = self.snk.data() - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 5) - def test03 (self): + def test03(self): # BPSK Convergence test with static rotation natfreq = 0.25 order = 2 - self.test = digital_swig.costas_loop_cc(natfreq, order) + self.test = digital.costas_loop_cc(natfreq, order) rot = cmath.exp(0.2j) # some small rotation data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] @@ -90,13 +91,13 @@ class test_costas_loop_cc(gr_unittest.TestCase): # generously compare results; the loop will converge near to, but # not exactly on, the target data - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2) - def test04 (self): + def test04(self): # QPSK Convergence test with static rotation natfreq = 0.25 order = 4 - self.test = digital_swig.costas_loop_cc(natfreq, order) + self.test = digital.costas_loop_cc(natfreq, order) rot = cmath.exp(0.2j) # some small rotation data = [complex(2*random.randint(0,1)-1, 2*random.randint(0,1)-1) @@ -116,13 +117,13 @@ class test_costas_loop_cc(gr_unittest.TestCase): # generously compare results; the loop will converge near to, but # not exactly on, the target data - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2) - def test05 (self): + def test05(self): # 8PSK Convergence test with static rotation natfreq = 0.25 order = 8 - self.test = digital_swig.costas_loop_cc(natfreq, order) + self.test = digital.costas_loop_cc(natfreq, order) rot = cmath.exp(-cmath.pi/8.0j) # rotate to match Costas rotation const = psk.psk_constellation(order) @@ -145,7 +146,7 @@ class test_costas_loop_cc(gr_unittest.TestCase): # generously compare results; the loop will converge near to, but # not exactly on, the target data - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 2) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 2) if __name__ == '__main__': gr_unittest.run(test_costas_loop_cc, "test_costas_loop_cc.xml") diff --git a/gr-digital/python/qa_cpm.py b/gr-digital/python/qa_cpm.py index 12a84c76c2..2221d16b6f 100755 --- a/gr-digital/python/qa_cpm.py +++ b/gr-digital/python/qa_cpm.py @@ -21,15 +21,15 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import numpy class test_cpm(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def do_check_phase_shift(self, type, name): @@ -37,7 +37,7 @@ class test_cpm(gr_unittest.TestCase): L = 1 in_bits = (1,) * 20 src = gr.vector_source_b(in_bits, False) - cpm = digital_swig.cpmmod_bc(type, 0.5, sps, L) + cpm = digital.cpmmod_bc(type, 0.5, sps, L) arg = gr.complex_to_arg() sink = gr.vector_sink_f() @@ -68,7 +68,7 @@ class test_cpm(gr_unittest.TestCase): bt = 0.3 in_bits = (1,) * 20 src = gr.vector_source_b(in_bits, False) - gmsk = digital_swig.gmskmod_bc(sps, bt, L) + gmsk = digital.gmskmod_bc(sps, L, bt) arg = gr.complex_to_arg() sink = gr.vector_sink_f() diff --git a/gr-digital/python/qa_crc32.py b/gr-digital/python/qa_crc32.py index f86813f3f3..cd4006b1d3 100755 --- a/gr-digital/python/qa_crc32.py +++ b/gr-digital/python/qa_crc32.py @@ -21,40 +21,40 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital import random, cmath class test_crc32(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): data = 100*"0" expected_result = 2943744955 - result = digital_swig.crc32(data) + result = digital.crc32(data) #print hex(result) - self.assertEqual (expected_result, result) + self.assertEqual(expected_result, result) - def test02 (self): + def test02(self): data = 100*"1" expected_result = 2326594156 - result = digital_swig.crc32(data) + result = digital.crc32(data) #print hex(result) - self.assertEqual (expected_result, result) + self.assertEqual(expected_result, result) - def test03 (self): + def test03(self): data = 10*"0123456789" expected_result = 3774345973 - result = digital_swig.crc32(data) + result = digital.crc32(data) #print hex(result) - self.assertEqual (expected_result, result) + self.assertEqual(expected_result, result) if __name__ == '__main__': gr_unittest.run(test_crc32, "test_crc32.xml") diff --git a/gr-digital/python/qa_diff_encoder.py b/gr-digital/python/qa_diff_encoder.py index e4f5470af5..c28f4dbdf8 100755 --- a/gr-digital/python/qa_diff_encoder.py +++ b/gr-digital/python/qa_diff_encoder.py @@ -32,12 +32,12 @@ def make_random_int_tuple(L, min, max): return tuple(result) -class test_diff_encoder (gr_unittest.TestCase): +class test_diff_encoder(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_diff_encdec_000(self): diff --git a/gr-digital/python/qa_diff_phasor_cc.py b/gr-digital/python/qa_diff_phasor_cc.py index 3e7617fe47..833158d0a8 100755 --- a/gr-digital/python/qa_diff_phasor_cc.py +++ b/gr-digital/python/qa_diff_phasor_cc.py @@ -24,25 +24,25 @@ from gnuradio import gr, gr_unittest import digital_swig as digital import math -class test_diff_phasor (gr_unittest.TestCase): +class test_diff_phasor(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_diff_phasor_cc (self): + def test_diff_phasor_cc(self): src_data = (0+0j, 1+0j, -1+0j, 3+4j, -3-4j, -3+4j) expected_result = (0+0j, 0+0j, -1+0j, -3-4j, -25+0j, -7-24j) - src = gr.vector_source_c (src_data) - op = digital.diff_phasor_cc () - dst = gr.vector_sink_c () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink - self.assertComplexTuplesAlmostEqual (expected_result, actual_result) + src = gr.vector_source_c(src_data) + op = digital.diff_phasor_cc() + dst = gr.vector_sink_c() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() # run the graph and wait for it to finish + actual_result = dst.data() # fetch the contents of the sink + self.assertComplexTuplesAlmostEqual(expected_result, actual_result) if __name__ == '__main__': gr_unittest.run(test_diff_phasor, "test_diff_phasor.xml") diff --git a/gr-digital/python/qa_digital.py b/gr-digital/python/qa_digital.py index 97e35da568..6f54f14208 100755 --- a/gr-digital/python/qa_digital.py +++ b/gr-digital/python/qa_digital.py @@ -21,14 +21,14 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital class test_digital(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None if __name__ == '__main__': diff --git a/gr-digital/python/qa_fll_band_edge.py b/gr-digital/python/qa_fll_band_edge.py index 9e4ca079b7..a4269931f5 100755 --- a/gr-digital/python/qa_fll_band_edge.py +++ b/gr-digital/python/qa_fll_band_edge.py @@ -21,18 +21,19 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital +import filter_swig as filter import random, math class test_fll_band_edge_cc(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): sps = 4 rolloff = 0.35 bw = 2*math.pi/100.0 @@ -49,14 +50,14 @@ class test_fll_band_edge_cc(gr_unittest.TestCase): random.seed(0) data = [2.0*random.randint(0, 2) - 1.0 for i in xrange(200)] self.src = gr.vector_source_c(data, False) - self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps) + self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) # Mix symbols with a complex sinusoid to spin them self.nco = gr.sig_source_c(1, gr.GR_SIN_WAVE, foffset, 1) self.mix = gr.multiply_cc() # FLL will despin the symbols to an arbitrary phase - self.fll = digital_swig.fll_band_edge_cc(sps, rolloff, ntaps, bw) + self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) # Create sinks for all outputs of the FLL # we will only care about the freq and error outputs @@ -78,7 +79,7 @@ class test_fll_band_edge_cc(gr_unittest.TestCase): dst_data = self.vsnk_frq.data()[N:] expected_result = len(dst_data)* [-0.20,] - self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 4) + self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4) if __name__ == '__main__': gr_unittest.run(test_fll_band_edge_cc, "test_fll_band_edge_cc.xml") diff --git a/gr-digital/python/qa_framer_sink.py b/gr-digital/python/qa_framer_sink.py index bccc86dc78..e717e6ae05 100755 --- a/gr-digital/python/qa_framer_sink.py +++ b/gr-digital/python/qa_framer_sink.py @@ -63,11 +63,11 @@ class test_framker_sink(gr_unittest.TestCase): self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) - self.tb.run () + self.tb.run() result_data = rcvd_pktq.delete_head() result_data = result_data.to_string() - self.assertEqual (expected_data, result_data) + self.assertEqual(expected_data, result_data) def test_002(self): @@ -87,11 +87,11 @@ class test_framker_sink(gr_unittest.TestCase): self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) - self.tb.run () + self.tb.run() result_data = rcvd_pktq.delete_head() result_data = result_data.to_string() - self.assertEqual (expected_data, result_data) + self.assertEqual(expected_data, result_data) if __name__ == '__main__': gr_unittest.run(test_framker_sink, "test_framker_sink.xml") diff --git a/gr-digital/python/qa_glfsr_source.py b/gr-digital/python/qa_glfsr_source.py index 7d02037335..c5adab3023 100755 --- a/gr-digital/python/qa_glfsr_source.py +++ b/gr-digital/python/qa_glfsr_source.py @@ -25,10 +25,10 @@ import digital_swig as digital class test_glfsr_source(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_000_make_b(self): diff --git a/gr-digital/python/qa_lms_equalizer.py b/gr-digital/python/qa_lms_equalizer.py index 025c785aa4..7bde258e7f 100755 --- a/gr-digital/python/qa_lms_equalizer.py +++ b/gr-digital/python/qa_lms_equalizer.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital class test_lms_dd_equalizer(gr_unittest.TestCase): @@ -33,7 +33,7 @@ class test_lms_dd_equalizer(gr_unittest.TestCase): def transform(self, src_data, gain, const): SRC = gr.vector_source_c(src_data, False) - EQU = digital_swig.lms_dd_equalizer_cc(4, gain, 1, const.base()) + EQU = digital.lms_dd_equalizer_cc(4, gain, 1, const.base()) DST = gr.vector_sink_c() self.tb.connect(SRC, EQU, DST) self.tb.run() @@ -41,13 +41,17 @@ class test_lms_dd_equalizer(gr_unittest.TestCase): def test_001_identity(self): # Constant modulus signal so no adjustments - const = digital_swig.constellation_qpsk() + const = digital.constellation_qpsk() src_data = const.points()*1000 N = 100 # settling time expected_data = src_data[N:] result = self.transform(src_data, 0.1, const)[N:] - self.assertComplexTuplesAlmostEqual(expected_data, result, 5) + + # only test last N samples to allow for settling. Also adjust + # for a 1 sample delay in the filter. + N = -500 + self.assertComplexTuplesAlmostEqual(expected_data[N:-1], result[N+1:]) if __name__ == "__main__": gr_unittest.run(test_lms_dd_equalizer, "test_lms_dd_equalizer.xml") diff --git a/gr-digital/python/qa_map.py b/gr-digital/python/qa_map.py index 3ad99a2c12..0fd7c479a1 100755 --- a/gr-digital/python/qa_map.py +++ b/gr-digital/python/qa_map.py @@ -34,14 +34,14 @@ class test_map(gr_unittest.TestCase): def helper(self, symbols): src_data = [0, 1, 2, 3, 0, 1, 2, 3] expected_data = map(lambda x: symbols[x], src_data) - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.map_bb(symbols) - dst = gr.vector_sink_b () - self.tb.connect (src, op, dst) - self.tb.run () + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() result_data = list(dst.data()) - self.assertEqual (expected_data, result_data) + self.assertEqual(expected_data, result_data) def test_001(self): symbols = [0, 0, 0, 0] diff --git a/gr-digital/python/qa_mpsk_receiver.py b/gr-digital/python/qa_mpsk_receiver.py index e1f16ee671..bde8895e76 100755 --- a/gr-digital/python/qa_mpsk_receiver.py +++ b/gr-digital/python/qa_mpsk_receiver.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,101 +21,128 @@ # from gnuradio import gr, gr_unittest -import digital_swig -import random, cmath +import digital_swig as digital +import filter_swig as filter +import random, cmath, time class test_mpsk_receiver(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): # Test BPSK sync M = 2 theta = 0 loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 - mu = 0.25 + mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 - self.test = digital_swig.mpsk_receiver_cc(M, theta, loop_bw, - fmin, fmax, mu, gain_mu, - omega, gain_omega, - omega_rel) + self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, + fmin, fmax, mu, gain_mu, + omega, gain_omega, + omega_rel) - data = 1000*[complex(1,0), complex(1,0), complex(-1,0), complex(-1,0)] + data = 10000*[complex(1,0), complex(-1,0)] + #data = [2*random.randint(0,1)-1 for x in xrange(10000)] self.src = gr.vector_source_c(data, False) self.snk = gr.vector_sink_c() - self.tb.connect(self.src, self.test, self.snk) + # pulse shaping interpolation filter + nfilts = 32 + excess_bw = 0.35 + ntaps = 11 * int(omega*nfilts) + rrc_taps0 = filter.firdes.root_raised_cosine( + nfilts, nfilts, 1.0, excess_bw, ntaps) + rrc_taps1 = filter.firdes.root_raised_cosine( + 1, omega, 1.0, excess_bw, 11*omega) + self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) + self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) + + self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() - expected_result = 1000*[complex(-0.5,0), complex(0.5,0)] + expected_result = [0.5*d for d in data] dst_data = self.snk.data() # Only compare last Ncmp samples - Ncmp = 100 + Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) - expected_result = expected_result[len_e - Ncmp:] + expected_result = expected_result[len_e - Ncmp-1:-1] dst_data = dst_data[len_d - Ncmp:] - + #for e,d in zip(expected_result, dst_data): - # print e, d + # print "{0:+.02f} {1:+.02f}".format(e, d) - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) - def test02 (self): + def test02(self): # Test QPSK sync M = 4 theta = 0 - loop_bw = 2*cmath.pi/100.0 + loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 - mu = 0.25 + mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 - self.test = digital_swig.mpsk_receiver_cc(M, theta, loop_bw, - fmin, fmax, mu, gain_mu, - omega, gain_omega, - omega_rel) + self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, + fmin, fmax, mu, gain_mu, + omega, gain_omega, + omega_rel) - data = 1000*[complex( 0.707, 0.707), complex( 0.707, 0.707), - complex(-0.707, 0.707), complex(-0.707, 0.707), - complex(-0.707, -0.707), complex(-0.707, -0.707), - complex( 0.707, -0.707), complex( 0.707, -0.707)] + data = 10000*[complex( 0.707, 0.707), + complex(-0.707, 0.707), + complex(-0.707, -0.707), + complex( 0.707, -0.707)] + data = [0.5*d for d in data] self.src = gr.vector_source_c(data, False) self.snk = gr.vector_sink_c() - self.tb.connect(self.src, self.test, self.snk) + # pulse shaping interpolation filter + nfilts = 32 + excess_bw = 0.35 + ntaps = 11 * int(omega*nfilts) + rrc_taps0 = filter.firdes.root_raised_cosine( + nfilts, nfilts, 1.0, excess_bw, ntaps) + rrc_taps1 = filter.firdes.root_raised_cosine( + 1, omega, 1.0, excess_bw, 11*omega) + self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) + self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) + + self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() - expected_result = 1000*[complex(0, -1.0), complex(1.0, 0), - complex(0, 1.0), complex(-1.0, 0)] - dst_data = self.snk.data() + expected_result = 10000*[complex(-0.5, +0.0), complex(+0.0, -0.5), + complex(+0.5, +0.0), complex(+0.0, +0.5)] + + # get data after a settling period + dst_data = self.snk.data()[200:] # Only compare last Ncmp samples - Ncmp = 100 + Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) - expected_result = expected_result[len_e - Ncmp:] + expected_result = expected_result[len_e - Ncmp - 1:-1] dst_data = dst_data[len_d - Ncmp:] #for e,d in zip(expected_result, dst_data): - # print e, d + # print "{0:+.02f} {1:+.02f}".format(e, d) - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) if __name__ == '__main__': gr_unittest.run(test_mpsk_receiver, "test_mpsk_receiver.xml") diff --git a/gr-digital/python/qa_mpsk_snr_est.py b/gr-digital/python/qa_mpsk_snr_est.py index d392567bfd..c976bf21a8 100755 --- a/gr-digital/python/qa_mpsk_snr_est.py +++ b/gr-digital/python/qa_mpsk_snr_est.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,94 +29,93 @@ def get_cplx(): def get_n_cplx(): return complex(random.random()-0.5, random.random()-0.5) -class test_mpsk_snr_est (gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () +class test_mpsk_snr_est(gr_unittest.TestCase): + def setUp(self): + self.tb = gr.top_block() random.seed(0) # make repeatable N = 10000 self._noise = [get_n_cplx() for i in xrange(N)] self._bits = [get_cplx() for i in xrange(N)] - def tearDown (self): + def tearDown(self): self.tb = None - def mpsk_snr_est_setup (self, op): + def mpsk_snr_est_setup(self, op): result = [] for i in xrange(1,6): src_data = [b+(i*n) for b,n in zip(self._bits, self._noise)] - src = gr.vector_source_c (src_data) - dst = gr.null_sink (gr.sizeof_gr_complex) + src = gr.vector_source_c(src_data) + dst = gr.null_sink(gr.sizeof_gr_complex) - tb = gr.top_block () - tb.connect (src, op) - tb.connect (op, dst) - tb.run () # run the graph and wait for it to finish + tb = gr.top_block() + tb.connect(src, op) + tb.connect(op, dst) + tb.run() # run the graph and wait for it to finish result.append(op.snr()) return result - def test_mpsk_snr_est_simple (self): + def test_mpsk_snr_est_simple(self): expected_result = [11.48, 5.91, 3.30, 2.08, 1.46] N = 10000 alpha = 0.001 - op = digital.mpsk_snr_est_cc (digital.SNR_EST_SIMPLE, N, alpha) + op = digital.mpsk_snr_est_cc(digital.SNR_EST_SIMPLE, N, alpha) actual_result = self.mpsk_snr_est_setup(op) - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 2) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2) - def test_mpsk_snr_est_skew (self): + def test_mpsk_snr_est_skew(self): expected_result = [11.48, 5.91, 3.30, 2.08, 1.46] N = 10000 alpha = 0.001 - op = digital.mpsk_snr_est_cc (digital.SNR_EST_SKEW, N, alpha) + op = digital.mpsk_snr_est_cc(digital.SNR_EST_SKEW, N, alpha) actual_result = self.mpsk_snr_est_setup(op) - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 2) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2) - def test_mpsk_snr_est_m2m4 (self): + def test_mpsk_snr_est_m2m4(self): expected_result = [11.02, 6.20, 4.98, 5.16, 5.66] N = 10000 alpha = 0.001 - op = digital.mpsk_snr_est_cc (digital.SNR_EST_M2M4, N, alpha) + op = digital.mpsk_snr_est_cc(digital.SNR_EST_M2M4, N, alpha) actual_result = self.mpsk_snr_est_setup(op) - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 2) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2) - def test_mpsk_snr_est_svn (self): + def test_mpsk_snr_est_svn(self): expected_result = [10.90, 6.00, 4.76, 4.97, 5.49] N = 10000 alpha = 0.001 - op = digital.mpsk_snr_est_cc (digital.SNR_EST_SVR, N, alpha) + op = digital.mpsk_snr_est_cc(digital.SNR_EST_SVR, N, alpha) actual_result = self.mpsk_snr_est_setup(op) - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 2) + self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2) - def test_probe_mpsk_snr_est_m2m4 (self): + def test_probe_mpsk_snr_est_m2m4(self): expected_result = [11.02, 6.20, 4.98, 5.16, 5.66] actual_result = [] for i in xrange(1,6): src_data = [b+(i*n) for b,n in zip(self._bits, self._noise)] - src = gr.vector_source_c (src_data) + src = gr.vector_source_c(src_data) N = 10000 alpha = 0.001 - op = digital.probe_mpsk_snr_est_c (digital.SNR_EST_M2M4, N, alpha) + op = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, N, alpha) - tb = gr.top_block () - tb.connect (src, op) - tb.run () # run the graph and wait for it to finish + tb = gr.top_block() + tb.connect(src, op) + tb.run() # run the graph and wait for it to finish actual_result.append(op.snr()) - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 2) - + self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 2) if __name__ == '__main__': # Test various SNR estimators; we're not using a Gaussian diff --git a/gr-digital/python/qa_ofdm_insert_preamble.py b/gr-digital/python/qa_ofdm_insert_preamble.py index c45893fa38..d084796644 100755 --- a/gr-digital/python/qa_ofdm_insert_preamble.py +++ b/gr-digital/python/qa_ofdm_insert_preamble.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2007,2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,14 +22,14 @@ from gnuradio import gr, gr_unittest from pprint import pprint -import digital_swig +import digital_swig as digital -class test_ofdm_insert_preamble (gr_unittest.TestCase): +class test_ofdm_insert_preamble(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def helper(self, v0, v1, fft_length, preamble): @@ -41,7 +41,7 @@ class test_ofdm_insert_preamble (gr_unittest.TestCase): # print "len(v) = %d" % (len(v)) - op = digital_swig.ofdm_insert_preamble(fft_length, preamble) + op = digital.ofdm_insert_preamble(fft_length, preamble) v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_length) dst0 = gr.vector_sink_c() @@ -105,7 +105,6 @@ class test_ofdm_insert_preamble (gr_unittest.TestCase): p.append(tuple(t)) v += t - r = self.helper(v, npayloads*[1], fft_length, preamble) self.assertEqual(r[0], tuple(npayloads*[1, 0])) @@ -175,6 +174,5 @@ class test_ofdm_insert_preamble (gr_unittest.TestCase): p0, p1, p[12], p[13], p0, p1, p[14], p[15])) - if __name__ == '__main__': gr_unittest.run(test_ofdm_insert_preamble, "test_ofdm_insert_preamble.xml") diff --git a/gr-digital/python/qa_pfb_clock_sync.py b/gr-digital/python/qa_pfb_clock_sync.py index 06c8a60ba7..44419264f7 100755 --- a/gr-digital/python/qa_pfb_clock_sync.py +++ b/gr-digital/python/qa_pfb_clock_sync.py @@ -21,18 +21,19 @@ # from gnuradio import gr, gr_unittest +import filter_swig as filter import digital_swig as digital import random, cmath class test_pfb_clock_sync(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test01 (self): + def test01(self): # Test BPSK sync excess_bw = 0.35 @@ -52,7 +53,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): max_rate_deviation, osps) - data = 1000*[complex(1,0), complex(-1,0)] + data = 10000*[complex(1,0), complex(-1,0)] self.src = gr.vector_source_c(data, False) # pulse shaping interpolation filter @@ -62,18 +63,18 @@ class test_pfb_clock_sync(gr_unittest.TestCase): 1.0, # symbol rate excess_bw, # excess bandwidth (roll-off factor) ntaps) - self.rrc_filter = gr.pfb_arb_resampler_ccf(sps, rrc_taps) + self.rrc_filter = filter.pfb_arb_resampler_ccf(sps, rrc_taps) self.snk = gr.vector_sink_c() self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) self.tb.run() - expected_result = 1000*[complex(-1,0), complex(1,0)] + expected_result = 10000*[complex(-1,0), complex(1,0)] dst_data = self.snk.data() # Only compare last Ncmp samples - Ncmp = 100 + Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) expected_result = expected_result[len_e - Ncmp:] @@ -82,10 +83,10 @@ class test_pfb_clock_sync(gr_unittest.TestCase): #for e,d in zip(expected_result, dst_data): # print e, d - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) - def test02 (self): + def test02(self): # Test real BPSK sync excess_bw = 0.35 @@ -105,7 +106,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): max_rate_deviation, osps) - data = 1000*[1, -1] + data = 10000*[1, -1] self.src = gr.vector_source_f(data, False) # pulse shaping interpolation filter @@ -115,18 +116,18 @@ class test_pfb_clock_sync(gr_unittest.TestCase): 1.0, # symbol rate excess_bw, # excess bandwidth (roll-off factor) ntaps) - self.rrc_filter = gr.pfb_arb_resampler_fff(sps, rrc_taps) + self.rrc_filter = filter.pfb_arb_resampler_fff(sps, rrc_taps) self.snk = gr.vector_sink_f() self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) self.tb.run() - expected_result = 1000*[-1, 1] + expected_result = 10000*[-1, 1] dst_data = self.snk.data() # Only compare last Ncmp samples - Ncmp = 100 + Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) expected_result = expected_result[len_e - Ncmp:] @@ -135,7 +136,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): #for e,d in zip(expected_result, dst_data): # print e, d - self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 1) + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) if __name__ == '__main__': diff --git a/gr-digital/python/qa_pn_correlator_cc.py b/gr-digital/python/qa_pn_correlator_cc.py index 377bef5feb..4e81bf6662 100755 --- a/gr-digital/python/qa_pn_correlator_cc.py +++ b/gr-digital/python/qa_pn_correlator_cc.py @@ -26,7 +26,7 @@ import digital_swig as digital class test_pn_correlator_cc(gr_unittest.TestCase): def setUp(self): - self.tb = gr.top_block () + self.tb = gr.top_block() def tearDown(self): self.tb = None diff --git a/gr-digital/python/qa_probe_density.py b/gr-digital/python/qa_probe_density.py index c5b7e0e7c2..f42f00a7f7 100755 --- a/gr-digital/python/qa_probe_density.py +++ b/gr-digital/python/qa_probe_density.py @@ -34,37 +34,37 @@ class test_probe_density(gr_unittest.TestCase): def test_001(self): src_data = [0, 1, 0, 1] expected_data = 1 - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.probe_density_b(1) - self.tb.connect (src, op) - self.tb.run () + self.tb.connect(src, op) + self.tb.run() result_data = op.density() - self.assertEqual (expected_data, result_data) + self.assertEqual(expected_data, result_data) def test_002(self): src_data = [1, 1, 1, 1] expected_data = 1 - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.probe_density_b(0.01) - self.tb.connect (src, op) - self.tb.run () + self.tb.connect(src, op) + self.tb.run() result_data = op.density() - self.assertEqual (expected_data, result_data) + self.assertEqual(expected_data, result_data) def test_003(self): src_data = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] expected_data = 0.95243 - src = gr.vector_source_b (src_data) + src = gr.vector_source_b(src_data) op = digital.probe_density_b(0.01) - self.tb.connect (src, op) - self.tb.run () + self.tb.connect(src, op) + self.tb.run() result_data = op.density() print result_data - self.assertAlmostEqual (expected_data, result_data, 5) + self.assertAlmostEqual(expected_data, result_data, 5) if __name__ == '__main__': gr_unittest.run(test_probe_density, "test_probe_density.xml") diff --git a/gr-digital/python/qa_scrambler.py b/gr-digital/python/qa_scrambler.py index f5bd612429..3127a7c1e6 100755 --- a/gr-digital/python/qa_scrambler.py +++ b/gr-digital/python/qa_scrambler.py @@ -25,7 +25,7 @@ import digital_swig as digital class test_scrambler(gr_unittest.TestCase): - def setUp (self): + def setUp(self): self.tb = gr.top_block() def tearDown(self): diff --git a/gr-digital/python/qa_simple_framer.py b/gr-digital/python/qa_simple_framer.py index 09b2d329b2..f8c894da28 100755 --- a/gr-digital/python/qa_simple_framer.py +++ b/gr-digital/python/qa_simple_framer.py @@ -24,15 +24,15 @@ from gnuradio import gr, gr_unittest import digital_swig as digital import math -class test_simple_framer (gr_unittest.TestCase): +class test_simple_framer(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_simple_framer_001 (self): + def test_simple_framer_001(self): src_data = (0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, @@ -44,15 +44,14 @@ class test_simple_framer (gr_unittest.TestCase): 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x02, 0x88, 0x99, 0xaa, 0xbb, 0x55, 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x03, 0xcc, 0xdd, 0xee, 0xff, 0x55) - src = gr.vector_source_b (src_data) - op = digital.simple_framer (4) - dst = gr.vector_sink_b () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - + src = gr.vector_source_b(src_data) + op = digital.simple_framer(4) + dst = gr.vector_sink_b() + self.tb.connect(src, op) + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) if __name__ == '__main__': gr_unittest.run(test_simple_framer, "test_simple_framer.xml") diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index aafa5725d9..8584c59c6f 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -31,7 +31,7 @@ from generic_mod_demod import shared_mod_args, shared_demod_args from utils.gray_code import gray_code from utils import mod_codes import modulation_utils -import digital_swig +import digital_swig as digital # Default number of points in constellation. _def_constellation_points = 16 @@ -172,8 +172,8 @@ def qam_constellation(constellation_points=_def_constellation_points, pre_diff_code = range(0, m/2) + range(3*m/4, m) + range(m/2, 3*m/4) else: pre_diff_code = [] - constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, - side, side, width, width) + constellation = digital.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) return constellation # ///////////////////////////////////////////////////////////////////////////// diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py index 60f791af7f..859d981367 100644 --- a/gr-digital/python/qpsk.py +++ b/gr-digital/python/qpsk.py @@ -29,7 +29,7 @@ from gnuradio import gr from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod from gnuradio.digital.generic_mod_demod import shared_mod_args, shared_demod_args from utils import mod_codes -import digital_swig +import digital_swig as digital import modulation_utils # The default encoding (e.g. gray-code, set-partition) @@ -45,7 +45,7 @@ def qpsk_constellation(mod_code=_def_mod_code): """ if mod_code != mod_codes.GRAY_CODE: raise ValueError("This QPSK mod/demod works only for gray-coded constellations.") - return digital_swig.constellation_qpsk() + return digital.constellation_qpsk() # ///////////////////////////////////////////////////////////////////////////// # QPSK modulator @@ -68,12 +68,12 @@ class qpsk_mod(generic_mod): def __init__(self, mod_code=_def_mod_code, differential=False, *args, **kwargs): pre_diff_code = True if not differential: - constellation = digital_swig.constellation_qpsk() + constellation = digital.constellation_qpsk() if mod_code != mod_codes.GRAY_CODE: raise ValueError("This QPSK mod/demod works only for gray-coded constellations.") else: - constellation = digital_swig.constellation_dqpsk() - if mod_code not in (mod_codes.GRAY_CODE or mod_codes.NO_CODE): + constellation = digital.constellation_dqpsk() + if mod_code not in set([mod_codes.GRAY_CODE, mod_codes.NO_CODE]): raise ValueError("That mod_code is not supported for DQPSK mod/demod.") if mod_code == mod_codes.NO_CODE: pre_diff_code = False @@ -106,12 +106,12 @@ class qpsk_demod(generic_demod): *args, **kwargs): pre_diff_code = True if not differential: - constellation = digital_swig.constellation_qpsk() + constellation = digital.constellation_qpsk() if mod_code != mod_codes.GRAY_CODE: raise ValueError("This QPSK mod/demod works only for gray-coded constellations.") else: - constellation = digital_swig.constellation_dqpsk() - if mod_code not in (mod_codes.GRAY_CODE or mod_codes.NO_CODE): + constellation = digital.constellation_dqpsk() + if mod_code not in set([mod_codes.GRAY_CODE, mod_codes.NO_CODE]): raise ValueError("That mod_code is not supported for DQPSK mod/demod.") if mod_code == mod_codes.NO_CODE: pre_diff_code = False @@ -129,7 +129,7 @@ class qpsk_demod(generic_demod): def dqpsk_constellation(mod_code=_def_mod_code): if mod_code != mod_codes.GRAY_CODE: raise ValueError("The DQPSK constellation is only generated for gray_coding. But it can be used for non-grayed coded modulation if one doesn't use the pre-differential code.") - return digital_swig.constellation_dqpsk() + return digital.constellation_dqpsk() # ///////////////////////////////////////////////////////////////////////////// # DQPSK modulator @@ -149,7 +149,7 @@ class dqpsk_mod(qpsk_mod): __doc__ += shared_mod_args def __init__(self, mod_code=_def_mod_code, *args, **kwargs): - super(dqpsk_mod, self).__init__(mod_code, differential=True, + super(dqpsk_mod, self).__init__(mod_code, *args, **kwargs) # ///////////////////////////////////////////////////////////////////////////// @@ -171,7 +171,7 @@ class dqpsk_demod(qpsk_demod): __doc__ += shared_demod_args def __init__(self, mod_code=_def_mod_code, *args, **kwargs): - super(dqpsk_demod, self).__init__(mod_code, differential=True, + super(dqpsk_demod, self).__init__(mod_code, *args, **kwargs) # @@ -183,4 +183,3 @@ modulation_utils.add_type_1_constellation('qpsk', qpsk_constellation) modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod) modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod) modulation_utils.add_type_1_constellation('dqpsk', dqpsk_constellation) - diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index df5f04148c..299fd1c1d9 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -18,107 +18,24 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# generate helper scripts to expand templated files -######################################################################## -include(GrPython) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " -#!${PYTHON_EXECUTABLE} - -import sys, os, re -sys.path.append('${GR_CORE_PYTHONPATH}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.chdir('${CMAKE_CURRENT_BINARY_DIR}') - -if __name__ == '__main__': - import build_utils - root, inp = sys.argv[1:3] - for sig in sys.argv[3:]: - name = re.sub ('X+', sig, root) - d = build_utils.standard_dict(name, sig, 'digital') - build_utils.expand_template(d, inp) - -") - -macro(expand_i root) - # make a list of the .i generated files - unset(expanded_files_i) - foreach(sig ${ARGN}) - string(REGEX REPLACE "X+" ${sig} name ${root}) - list(APPEND expanded_files_i ${CMAKE_CURRENT_BINARY_DIR}/${name}.i) - endforeach(sig) - - #create a command to generate the .i files - add_custom_command( - OUTPUT ${expanded_files_i} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.i.t - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py - ${root} ${root}.i.t ${ARGN} - ) - - # Lists of generated i files - list(APPEND generated_swigs ${expanded_files_i}) -endmacro(expand_i) - - -######################################################################## -# Invoke macro to generate various sources -######################################################################## -expand_i(digital_chunks_to_symbols_XX bf bc sf sc if ic) - -add_custom_target(digital_generated_swigs DEPENDS - ${generated_swigs} -) - -######################################################################## # Setup swig generation ######################################################################## +include(GrPython) include(GrSwig) -######################################################################## -# Create the master gengen swig include files -######################################################################## -set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i.in) -file(WRITE ${generated_index} " -// -// This file is machine generated. All edits will be overwritten -// -") - -file(APPEND ${generated_index} "%include \"gnuradio.i\"\n\n") -file(APPEND ${generated_index} "%{\n") - -foreach(swig_file ${generated_swigs}) - get_filename_component(name ${swig_file} NAME_WE) - file(APPEND ${generated_index} "#include<${name}.h>\n") -endforeach(swig_file) -file(APPEND ${generated_index} "%}\n") - -foreach(swig_file ${generated_swigs}) - get_filename_component(name ${swig_file} NAME) - file(APPEND ${generated_index} "%include<${name}>\n") -endforeach(swig_file) - -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i -) - set(GR_SWIG_INCLUDE_DIRS ${GR_DIGITAL_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/../include ) -# Setup swig docs to depend on includes and pull in from build directory -set(GR_SWIG_LIBRARIES gnuradio-digital) -set(GR_SWIG_TARGET_DEPS digital_generated_includes core_swig) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i) -set(GR_SWIG_DOC_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_BINARY_DIR}/../include) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) + +set(GR_SWIG_LIBRARIES gnuradio-digital gnuradio-filter) + GR_SWIG_MAKE(digital_swig digital_swig.i) + GR_SWIG_INSTALL( TARGETS digital_swig DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital @@ -129,50 +46,6 @@ install( FILES digital_swig.i ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i - ${CMAKE_CURRENT_BINARY_DIR}/digital_generated.i - ${generated_swigs} - digital_additive_scrambler_bb.i - digital_binary_slicer_fb.i - digital_bytes_to_syms.i - digital_clock_recovery_mm_cc.i - digital_clock_recovery_mm_ff.i - digital_cma_equalizer_cc.i - digital_constellation.i - digital_constellation_receiver_cb.i - digital_constellation_decoder_cb.i - digital_correlate_access_code_bb.i - digital_correlate_access_code_tag_bb.i - digital_costas_loop_cc.i - digital_cpmmod_bc.i - digital_crc32.i - digital_descrambler_bb.i - digital_diff_decoder_bb.i - digital_diff_encoder_bb.i - digital_diff_phasor_cc.i - digital_fll_band_edge_cc.i - digital_framer_sink_1.i - digital_glfsr_source_b.i - digital_glfsr_source_f.i - digital_gmskmod_bc.i - digital_lms_dd_equalizer_cc.i - digital_kurtotic_equalizer_cc.i - digital_map_bb.i - digital_mpsk_receiver_cc.i - digital_mpsk_snr_est_cc.i - digital_ofdm_cyclic_prefixer.i - digital_ofdm_frame_acquisition.i - digital_ofdm_frame_sink.i - digital_ofdm_insert_preamble.i - digital_ofdm_mapper_bcv.i - digital_ofdm_sampler.i - digital_packet_sink.i - digital_pfb_clock_sync_ccf.i - digital_pfb_clock_sync_fff.i - digital_pn_correlator_cc.i - digital_probe_density_b.i - digital_probe_mpsk_snr_est_c.i - digital_scrambler_bb.i - digital_simple_framer.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "digital_swig" ) diff --git a/gr-digital/swig/_digital_hier.i b/gr-digital/swig/_digital_hier.i deleted file mode 100644 index 022e38644b..0000000000 --- a/gr-digital/swig/_digital_hier.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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 <digital_cpmmod_bc.h> -#include <digital_gmskmod_bc.h> -%} - -%include "digital_cpmmod_bc.i" -%include "digital_gmskmod_bc.i" diff --git a/gr-digital/swig/constellation.i b/gr-digital/swig/constellation.i new file mode 100644 index 0000000000..39eb7030fd --- /dev/null +++ b/gr-digital/swig/constellation.i @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010-2012 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. + */ + +%template(constellation_sptr) boost::shared_ptr<gr::digital::constellation>; + +%template(constellation_calcdist_sptr) boost::shared_ptr<gr::digital::constellation_calcdist>; +%pythoncode %{ +constellation_calcdist_sptr.__repr__ = lambda self: "<constellation calcdist (m=%d)>" % (len(self.points())) +constellation_calcdist = constellation_calcdist.make; +%} + +%template(constellation_rect_sptr) boost::shared_ptr<gr::digital::constellation_rect>; +%pythoncode %{ +constellation_rect_sptr.__repr__ = lambda self: "<constellation rect (m=%d)>" % (len(self.points())) +constellation_rect = constellation_rect.make; +%} + +%template(constellation_psk_sptr) boost::shared_ptr<gr::digital::constellation_psk>; +%pythoncode %{ +constellation_psk_sptr.__repr__ = lambda self: "<constellation PSK (m=%d)>" % (len(self.points())) +constellation_psk = constellation_psk.make; +%} + +%template(constellation_bpsk_sptr) boost::shared_ptr<gr::digital::constellation_bpsk>; +%pythoncode %{ +constellation_bpsk_sptr.__repr__ = lambda self: "<constellation BPSK>" +constellation_bpsk = constellation_bpsk.make; +%} + +%template(constellation_qpsk_sptr) boost::shared_ptr<gr::digital::constellation_qpsk>; +%pythoncode %{ +constellation_qpsk_sptr.__repr__ = lambda self: "<constellation QPSK>" +constellation_qpsk = constellation_qpsk.make; +%} + +%template(constellation_dqpsk_sptr) boost::shared_ptr<gr::digital::constellation_dqpsk>; +%pythoncode %{ +constellation_dqpsk_sptr.__repr__ = lambda self: "<constellation DQPSK>" +constellation_dqpsk = constellation_dqpsk.make; +%} + +%template(constellation_8psk_sptr) boost::shared_ptr<gr::digital::constellation_8psk>; +%pythoncode %{ +constellation_8psk_sptr.__repr__ = lambda self: "<constellation 8PSK>" +constellation_8psk = constellation_8psk.make; +%} diff --git a/gr-digital/swig/digital_additive_scrambler_bb.i b/gr-digital/swig/digital_additive_scrambler_bb.i deleted file mode 100644 index b063f06725..0000000000 --- a/gr-digital/swig/digital_additive_scrambler_bb.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,additive_scrambler_bb); - -digital_additive_scrambler_bb_sptr -digital_make_additive_scrambler_bb(int mask, int seed, - int len, int count=0); - -class digital_additive_scrambler_bb : public gr_sync_block -{ -}; diff --git a/gr-digital/swig/digital_binary_slicer_fb.i b/gr-digital/swig/digital_binary_slicer_fb.i deleted file mode 100644 index 30603748b3..0000000000 --- a/gr-digital/swig/digital_binary_slicer_fb.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,binary_slicer_fb); - -digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb (); - -class digital_binary_slicer_fb : public gr_sync_block -{ - private: - digital_binary_slicer_fb (); - - public: -}; diff --git a/gr-digital/swig/digital_bytes_to_syms.i b/gr-digital/swig/digital_bytes_to_syms.i deleted file mode 100644 index cf23f035c4..0000000000 --- a/gr-digital/swig/digital_bytes_to_syms.i +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,bytes_to_syms); - -digital_bytes_to_syms_sptr digital_make_bytes_to_syms(); - -class digital_bytes_to_syms : public gr_sync_interpolator -{ -}; diff --git a/gr-digital/swig/digital_clock_recovery_mm_cc.i b/gr-digital/swig/digital_clock_recovery_mm_cc.i deleted file mode 100644 index 4ce9a9725d..0000000000 --- a/gr-digital/swig/digital_clock_recovery_mm_cc.i +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,clock_recovery_mm_cc); - -digital_clock_recovery_mm_cc_sptr -digital_make_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit) throw(std::exception); - -class digital_clock_recovery_mm_cc : public gr_sync_block -{ - private: - digital_clock_recovery_mm_cc (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit); - -public: - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float omega) { d_mu = mu; } - void set_omega (float omega) { d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_relative_limit); - d_max_omega = omega*(1.0 + d_omega_relative_limit); - } - void set_verbose (bool verbose) { d_verbose = verbose; } -}; diff --git a/gr-digital/swig/digital_clock_recovery_mm_ff.i b/gr-digital/swig/digital_clock_recovery_mm_ff.i deleted file mode 100644 index 054ef9ebfe..0000000000 --- a/gr-digital/swig/digital_clock_recovery_mm_ff.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,clock_recovery_mm_ff); - -digital_clock_recovery_mm_ff_sptr -digital_make_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit=0.001) throw(std::exception); - -class digital_clock_recovery_mm_ff : public gr_sync_block -{ - private: - digital_clock_recovery_mm_ff (float omega, float gain_omega, - float mu, float gain_mu, - float omega_relative_limit); - -public: - float mu() const; - float omega() const; - float gain_mu() const; - float gain_omega() const; - - void set_gain_mu (float gain_mu); - void set_gain_omega (float gain_omega); - void set_mu (float omega); - void set_omega (float omega); -}; diff --git a/gr-digital/swig/digital_cma_equalizer_cc.i b/gr-digital/swig/digital_cma_equalizer_cc.i deleted file mode 100644 index 183e43ef94..0000000000 --- a/gr-digital/swig/digital_cma_equalizer_cc.i +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,cma_equalizer_cc) - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_adaptive_fir_ccc.i" - -digital_cma_equalizer_cc_sptr -digital_make_cma_equalizer_cc(int num_taps, float modulus, - float mu, int sps); - -class digital_cma_equalizer_cc : public gr_adaptive_fir_ccc -{ -private: - digital_cma_equalizer_cc(int num_taps, float modulus, - float mu, int sps); - -public: - float get_gain(); - void set_gain(float mu); - float get_modulus(); - void set_modulus(float mod); -}; diff --git a/gr-digital/swig/digital_constellation.i b/gr-digital/swig/digital_constellation.i deleted file mode 100644 index 248f900149..0000000000 --- a/gr-digital/swig/digital_constellation.i +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2011,2012 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. - */ - -%template(gr_complex_vector) std::vector<gr_complex>; -%template(unsigned_int_vector) std::vector<unsigned int>; - -// Make sure metric types get SWIGed. -%include "digital_metric_type.h" - -class digital_constellation; -typedef boost::shared_ptr<digital_constellation> digital_constellation_sptr; -%template(digital_constellation_sptr) boost::shared_ptr<digital_constellation>; - -class digital_constellation -{ -public: - digital_constellation (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); - std::vector<gr_complex> points(); - std::vector<gr_complex> s_points(); - std::vector<std::vector<gr_complex> > v_points(); - virtual unsigned int decision_maker (gr_complex *sample) = 0; - unsigned int decision_maker_v (std::vector<gr_complex> sample); - // void calc_metric(gr_complex *sample, float *metric, trellis_metric_type_t type); - // void calc_euclidean_metric(gr_complex *sample, float *metric); - // void calc_hard_symbol_metric(gr_complex *sample, float *metric); - std::vector<gr_complex> map_to_points_v(unsigned int value); - unsigned int bits_per_symbol (); - unsigned int arity (); - digital_constellation_sptr base (); - bool apply_pre_diff_code(); - void set_pre_diff_code(bool a); - std::vector<unsigned int> pre_diff_code(); - unsigned int rotational_symmetry(); - unsigned int dimensionality(); -}; - -class digital_constellation_calcdist; -typedef boost::shared_ptr<digital_constellation_calcdist> digital_constellation_calcdist_sptr; -%template(digital_constellation_calcdist_sptr) boost::shared_ptr<digital_constellation_calcdist>; -%rename(constellation_calcdist) digital_make_constellation_calcdist; -digital_constellation_calcdist_sptr -digital_make_constellation_calcdist(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); -%ignore digital_constellation_calcdist; - -class digital_constellation_calcdist: public digital_constellation -{ - public: - digital_constellation_calcdist (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int dimensionality); - unsigned int decision_maker (const gr_complex *sample); -}; - -class digital_constellation_sector: public digital_constellation -{ -}; - -class digital_constellation_rect; -typedef boost::shared_ptr<digital_constellation_rect> digital_constellation_rect_sptr; -%template(digital_constellation_rect_sptr) boost::shared_ptr<digital_constellation_rect>; -%rename(constellation_rect) digital_make_constellation_rect; -digital_constellation_rect_sptr digital_make_constellation_rect(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, unsigned int imag_sectors, - float width_real_sectors, float width_imag_sectors); -%ignore digital_constellation_rect; - -class digital_constellation_rect : public digital_constellation_sector -{ -public: - digital_constellation_rect (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, unsigned int imag_sectors, - float width_real_sectors, float width_imag_sectors); -}; - -class digital_constellation_psk; -typedef boost::shared_ptr<digital_constellation_psk> digital_constellation_psk_sptr; -%template(digital_constellation_psk_sptr) boost::shared_ptr<digital_constellation_psk>; -%rename(constellation_psk) digital_make_constellation_psk; -digital_constellation_psk_sptr digital_make_constellation_psk(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors); -%ignore digital_constellation_psk; - -class digital_constellation_psk : public digital_constellation_sector -{ -public: - digital_constellation_psk (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code, - unsigned int n_sectors); -}; - -/* - BPSK Constellation -*/ - -class digital_constellation_bpsk; -typedef boost::shared_ptr<digital_constellation_bpsk> digital_constellation_bpsk_sptr; -%template(digital_constellation_bpsk_sptr) boost::shared_ptr<digital_constellation_bpsk>; -%rename(constellation_bpsk) digital_make_constellation_bpsk; -digital_constellation_bpsk_sptr digital_make_constellation_bpsk(); -%ignore digital_constellation_bpsk; - -class digital_constellation_bpsk : public digital_constellation -{ -public: - digital_constellation_bpsk (); -}; - -/* - QPSK Constellation -*/ - -class digital_constellation_qpsk; -typedef boost::shared_ptr<digital_constellation_qpsk> digital_constellation_qpsk_sptr; -%template(digital_constellation_qpsk_sptr) boost::shared_ptr<digital_constellation_qpsk>; -%rename(constellation_qpsk) digital_make_constellation_qpsk; -digital_constellation_qpsk_sptr digital_make_constellation_qpsk(); -%ignore digital_constellation_qpsk; - -class digital_constellation_qpsk : public digital_constellation -{ -public: - digital_constellation_qpsk (); -}; - -/* - DQPSK Constellation -*/ - -class digital_constellation_dqpsk; -typedef boost::shared_ptr<digital_constellation_dqpsk> digital_constellation_dqpsk_sptr; -%template(digital_constellation_dqpsk_sptr) boost::shared_ptr<digital_constellation_dqpsk>; -%rename(constellation_dqpsk) digital_make_constellation_dqpsk; -digital_constellation_dqpsk_sptr digital_make_constellation_dqpsk(); -%ignore digital_constellation_dqpsk; - -class digital_constellation_dqpsk : public digital_constellation -{ -public: - digital_constellation_dqpsk (); -}; - - -/* - 8PSK Constellation -*/ - -class digital_constellation_8psk; -typedef boost::shared_ptr<digital_constellation_8psk> digital_constellation_8psk_sptr; -%template(digital_constellation_8psk_sptr) boost::shared_ptr<digital_constellation_8psk>; -%rename(constellation_8psk) digital_make_constellation_8psk; -digital_constellation_8psk_sptr digital_make_constellation_8psk(); -%ignore digital_constellation_8psk; - -class digital_constellation_8psk : public digital_constellation -{ -public: - digital_constellation_8psk (); -}; - -#if SWIGPYTHON -/* - We want print(constellation) in python to produce nice useful output so - we include code at the end of the generated python file that overrides - the SWIG-generated __repr__ method. - */ -%pythoncode %{ - -digital_constellation_calcdist_sptr.__repr__ = lambda self: '<constellation calcdist (m=%s)>' % str(len(self.points())) -digital_constellation_rect_sptr.__repr__ = lambda self: '<constellation rect (m=%s)>' % str(len(self.points())) -digital_constellation_psk_sptr.__repr__ = lambda self: '<constellation psk (m=%s)>' % str(len(self.points())) -digital_constellation_bpsk_sptr.__repr__ = lambda self: '<constellation bpsk>' -digital_constellation_qpsk_sptr.__repr__ = lambda self: '<constellation qpsk>' -digital_constellation_dqpsk_sptr.__repr__ = lambda self: '<constellation dqpsk>' -digital_constellation_8psk_sptr.__repr__ = lambda self: '<constellation 8psk>' - -%} -#endif diff --git a/gr-digital/swig/digital_constellation_decoder_cb.i b/gr-digital/swig/digital_constellation_decoder_cb.i deleted file mode 100644 index 547f57ee6a..0000000000 --- a/gr-digital/swig/digital_constellation_decoder_cb.i +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006, 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,constellation_decoder_cb) - -digital_constellation_decoder_cb_sptr -digital_make_constellation_decoder_cb (digital_constellation_sptr constellation); - -class digital_constellation_decoder_cb : public gr_sync_block -{ - private: - digital_constellation_decoder_cb (digital_constellation_sptr constellation); - - friend digital_constellation_decoder_cb_sptr - digital_make_constellation_decoder_cb (digital_constellation_sptr constellation); - - public: - ~digital_constellation_decoder_cb(); -}; diff --git a/gr-digital/swig/digital_constellation_receiver_cb.i b/gr-digital/swig/digital_constellation_receiver_cb.i deleted file mode 100644 index 9c4ba645e0..0000000000 --- a/gr-digital/swig/digital_constellation_receiver_cb.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,constellation_receiver_cb); - -%include "digital_constellation.i" - -digital_constellation_receiver_cb_sptr -digital_make_constellation_receiver_cb (digital_constellation_sptr constellation, - float loop_bw, float fmin, float fmax); - -class digital_constellation_receiver_cb : public gr_block, public gri_control_loop -{ - private: - digital_constellation_receiver_cb (digital_contellation_sptr constellation, - float loop_bw, float fmin, float fmax); -}; diff --git a/gr-digital/swig/digital_correlate_access_code_bb.i b/gr-digital/swig/digital_correlate_access_code_bb.i deleted file mode 100644 index 01087b8e93..0000000000 --- a/gr-digital/swig/digital_correlate_access_code_bb.i +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,correlate_access_code_bb); - -/*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - * \param threshold maximum number of bits that may be wrong - */ -digital_correlate_access_code_bb_sptr -digital_make_correlate_access_code_bb (const std::string &access_code, int threshold) - throw(std::out_of_range); - -/*! - * \brief Examine input for specified access code, one bit at a time. - * \ingroup block - * - * input: stream of bits, 1 bit per input byte (data in LSB) - * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) - * - * Each output byte contains two valid bits, the data bit, and the - * flag bit. The LSB (bit 0) is the data bit, and is the original - * input data, delayed 64 bits. Bit 1 is the - * flag bit and is 1 if the corresponding data bit is the first data - * bit following the access code. Otherwise the flag bit is 0. - */ -class digital_correlate_access_code_bb : public gr_sync_block -{ - friend digital_correlate_access_code_bb_sptr - digital_make_correlate_access_code_bb (const std::string &access_code, int threshold); - protected: - digital_correlate_access_code_bb(const std::string &access_code, int threshold); - - public: - ~digital_correlate_access_code_bb(); - - /*! - * \param access_code is represented with 1 byte per bit, e.g., "010101010111000100" - */ - bool set_access_code (const std::string &access_code); -}; diff --git a/gr-digital/swig/digital_correlate_access_code_tag_bb.i b/gr-digital/swig/digital_correlate_access_code_tag_bb.i deleted file mode 100644 index 03f20148a1..0000000000 --- a/gr-digital/swig/digital_correlate_access_code_tag_bb.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,correlate_access_code_tag_bb); - -digital_correlate_access_code_tag_bb_sptr -digital_make_correlate_access_code_tag_bb(const std::string &access_code, - int threshold, - const std::string &tag_name) - throw(std::out_of_range); - -class digital_correlate_access_code_tag_bb : public gr_sync_block -{ - public: - bool set_access_code(const std::string &access_code); -}; diff --git a/gr-digital/swig/digital_costas_loop_cc.i b/gr-digital/swig/digital_costas_loop_cc.i deleted file mode 100644 index ab09200a0a..0000000000 --- a/gr-digital/swig/digital_costas_loop_cc.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,costas_loop_cc); - -digital_costas_loop_cc_sptr -digital_make_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument); - -class digital_costas_loop_cc : public gr_sync_block, public gri_control_loop -{ - private: - digital_costas_loop_cc (float loop_bw, int order); -}; diff --git a/gr-digital/swig/digital_cpmmod_bc.i b/gr-digital/swig/digital_cpmmod_bc.i deleted file mode 100644 index fa7c50da75..0000000000 --- a/gr-digital/swig/digital_cpmmod_bc.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital, cpmmod_bc) - -digital_cpmmod_bc_sptr -digital_make_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta=0.3); - -class digital_cpmmod_bc : public gr_hier_block2 -{ - private: - digital_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - unsigned L, double beta); - - public: - std::vector<float> get_taps(); -}; - diff --git a/gr-digital/swig/digital_crc32.i b/gr-digital/swig/digital_crc32.i deleted file mode 100644 index 806bfad6a0..0000000000 --- a/gr-digital/swig/digital_crc32.i +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2011 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. - */ - -%rename(update_crc32) digital_update_crc32; -%rename(crc32) digital_crc32; - -unsigned int digital_update_crc32(unsigned int crc, const std::string buf); -unsigned int digital_crc32(const std::string buf); diff --git a/gr-digital/swig/digital_fll_band_edge_cc.i b/gr-digital/swig/digital_fll_band_edge_cc.i deleted file mode 100644 index 3efcb89ed1..0000000000 --- a/gr-digital/swig/digital_fll_band_edge_cc.i +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,fll_band_edge_cc); - -digital_fll_band_edge_cc_sptr digital_make_fll_band_edge_cc (float samps_per_sym, - float rolloff, - int filter_size, - float bandwidth); - -class digital_fll_band_edge_cc : public gr_sync_block, public gri_control_loop -{ - private: - digital_fll_band_edge_cc (float samps_per_sym, float rolloff, - int filter_size, float bandwidth); - - public: - ~digital_fll_band_edge_cc (); - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_samples_per_symbol(float sps); - void set_rolloff(float rolloff); - void set_filter_size(int filter_size); - void set_frequency(float freq); - void set_phase(float phase); - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_samples_per_symbol() const; - float get_rolloff() const; - int get_filter_size() const; - float get_frequency() const; - float get_phase() const; - - void print_taps(); -}; diff --git a/gr-digital/swig/digital_framer_sink_1.i b/gr-digital/swig/digital_framer_sink_1.i deleted file mode 100644 index a5c56560d3..0000000000 --- a/gr-digital/swig/digital_framer_sink_1.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,framer_sink_1); - -digital_framer_sink_1_sptr -digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); - -class digital_framer_sink_1 : public gr_sync_block -{ -}; diff --git a/gr-digital/swig/digital_glfsr_source_f.i b/gr-digital/swig/digital_glfsr_source_f.i deleted file mode 100644 index 4d94d8cd49..0000000000 --- a/gr-digital/swig/digital_glfsr_source_f.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,glfsr_source_f); - -digital_glfsr_source_f_sptr -digital_make_glfsr_source_f(int degree, bool repeat=true, - int mask=0, int seed=1) - throw (std::runtime_error); - -class digital_glfsr_source_f : public gr_sync_block -{ -public: - unsigned int period() const; - int mask() const; -}; diff --git a/gr-digital/swig/digital_gmskmod_bc.i b/gr-digital/swig/digital_gmskmod_bc.i deleted file mode 100644 index ad7b82237e..0000000000 --- a/gr-digital/swig/digital_gmskmod_bc.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital, gmskmod_bc) - -digital_gmskmod_bc_sptr -digital_make_gmskmod_bc(unsigned samples_per_sym=2, - double bt=0.3, unsigned L=4); - -class digital_gmskmod_bc : public gr_hier_block2 -{ - private: - digital_cpmmod_bc(int type, float h, - unsigned samples_per_sym, - double beta, unsigned L); - - public: - std::vector<float> get_taps(); -}; - diff --git a/gr-digital/swig/digital_lms_dd_equalizer_cc.i b/gr-digital/swig/digital_lms_dd_equalizer_cc.i deleted file mode 100644 index bd5c6ae29d..0000000000 --- a/gr-digital/swig/digital_lms_dd_equalizer_cc.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - - -GR_SWIG_BLOCK_MAGIC(digital,lms_dd_equalizer_cc) - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_adaptive_fir_ccc.i" - - -digital_lms_dd_equalizer_cc_sptr -digital_make_lms_dd_equalizer_cc (int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - -class digital_lms_dd_equalizer_cc : public gr_sync_block -{ -private: - digital_lms_dd_equalizer_cc (int num_taps, - float mu, int sps, - digital_constellation_sptr cnst); - -public: - float get_gain(); - void set_gain(float mu); -}; diff --git a/gr-digital/swig/digital_mpsk_receiver_cc.i b/gr-digital/swig/digital_mpsk_receiver_cc.i deleted file mode 100644 index 2338a18547..0000000000 --- a/gr-digital/swig/digital_mpsk_receiver_cc.i +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,mpsk_receiver_cc); - -digital_mpsk_receiver_cc_sptr digital_make_mpsk_receiver_cc (unsigned int M, float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, - float omega_rel); -class digital_mpsk_receiver_cc : public gr_block, public gri_control_loop -{ - private: - digital_mpsk_receiver_cc (unsigned int M,float theta, - float loop_bw, - float fmin, float fmax, - float mu, float gain_mu, - float omega, float gain_omega, float omega_rel); -public: - float modulation_order() const { return d_M; } - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - float gain_omega_rel() const {return d_omega_rel; } - void set_modulation_order(unsigned int M); - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega) { - d_omega = omega; - d_min_omega = omega*(1.0 - d_omega_rel); - d_max_omega = omega*(1.0 + d_omega_rel); - } - void set_theta(float theta) { d_theta = theta; } - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_gain_omega_rel(float omega_rel); -}; diff --git a/gr-digital/swig/digital_mpsk_snr_est_cc.i b/gr-digital/swig/digital_mpsk_snr_est_cc.i deleted file mode 100644 index f0ca13f874..0000000000 --- a/gr-digital/swig/digital_mpsk_snr_est_cc.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,mpsk_snr_est_cc); - -digital_mpsk_snr_est_cc_sptr -digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples=10000, - double alpha=0.001); - -class digital_mpsk_snr_est_cc : public gr_sync_block -{ -private: - void digital_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha); - -public: - double snr(); - snr_est_type_t type() const; - int tag_nsample() const; - double alpha() const; - void set_type(snr_est_type_t t); - void set_tag_nsample(int n); - void set_alpha(double alpha); -}; diff --git a/gr-digital/swig/digital_ofdm_frame_acquisition.i b/gr-digital/swig/digital_ofdm_frame_acquisition.i deleted file mode 100644 index b61297bdea..0000000000 --- a/gr-digital/swig/digital_ofdm_frame_acquisition.i +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2011 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. - */ - -#include <vector> - -GR_SWIG_BLOCK_MAGIC(digital,ofdm_frame_acquisition); - -digital_ofdm_frame_acquisition_sptr -digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len=4); - -class digital_ofdm_frame_acquisition : public gr_sync_decimator -{ - protected: - digital_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); - - public: - float snr() { return d_snr_est; } - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gr-digital/swig/digital_ofdm_frame_sink.i b/gr-digital/swig/digital_ofdm_frame_sink.i deleted file mode 100644 index cd3fa14229..0000000000 --- a/gr-digital/swig/digital_ofdm_frame_sink.i +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,ofdm_frame_sink); - -digital_ofdm_frame_sink_sptr -digital_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4); - -class digital_ofdm_frame_sink : public gr_sync_block -{ - protected: - digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - public: - ~digital_ofdm_frame_sink(); -}; diff --git a/gr-digital/swig/digital_ofdm_insert_preamble.i b/gr-digital/swig/digital_ofdm_insert_preamble.i deleted file mode 100644 index 0273c7fa75..0000000000 --- a/gr-digital/swig/digital_ofdm_insert_preamble.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,ofdm_insert_preamble); - -digital_ofdm_insert_preamble_sptr -digital_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - - -class digital_ofdm_insert_preamble : public gr_block -{ - protected: - digital_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); - public: - void enter_preamble(); -}; diff --git a/gr-digital/swig/digital_ofdm_mapper_bcv.i b/gr-digital/swig/digital_ofdm_mapper_bcv.i deleted file mode 100644 index 4e9aaba7d7..0000000000 --- a/gr-digital/swig/digital_ofdm_mapper_bcv.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,ofdm_mapper_bcv); - -digital_ofdm_mapper_bcv_sptr -digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length) throw(std::exception); - - -class digital_ofdm_mapper_bcv : public gr_sync_block -{ - protected: - digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - public: - gr_msg_queue_sptr msgq(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gr-digital/swig/digital_ofdm_sampler.i b/gr-digital/swig/digital_ofdm_sampler.i deleted file mode 100644 index 91056c320b..0000000000 --- a/gr-digital/swig/digital_ofdm_sampler.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,ofdm_sampler) - - digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); - -class digital_ofdm_sampler : public gr_sync_block -{ - private: - digital_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); -}; diff --git a/gr-digital/swig/digital_packet_sink.i b/gr-digital/swig/digital_packet_sink.i deleted file mode 100644 index 84f81f75cc..0000000000 --- a/gr-digital/swig/digital_packet_sink.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,packet_sink) - -digital_packet_sink_sptr -digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, - gr_msg_queue_sptr target_queue, - int threshold = -1); // -1 -> use default - -class digital_packet_sink : public gr_sync_block -{ - public: - bool carrier_sensed() const; -}; diff --git a/gr-digital/swig/digital_pfb_clock_sync_ccf.i b/gr-digital/swig/digital_pfb_clock_sync_ccf.i deleted file mode 100644 index dbba614cc1..0000000000 --- a/gr-digital/swig/digital_pfb_clock_sync_ccf.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,pfb_clock_sync_ccf); - -digital_pfb_clock_sync_ccf_sptr -digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class digital_pfb_clock_sync_ccf : public gr_block -{ - public: - void set_taps(const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_ccf*> &ourfilter); - - std::vector< std::vector<float> > get_taps(); - std::vector< std::vector<float> > get_diff_taps(); - std::vector<float> get_channel_taps(int channel); - std::vector<float> get_diff_channel_taps(int channel); - std::string get_taps_as_string(); - std::string get_diff_taps_as_string(); - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_clock_rate() const; -}; diff --git a/gr-digital/swig/digital_pfb_clock_sync_fff.i b/gr-digital/swig/digital_pfb_clock_sync_fff.i deleted file mode 100644 index 956495e5dd..0000000000 --- a/gr-digital/swig/digital_pfb_clock_sync_fff.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,pfb_clock_sync_fff); - -digital_pfb_clock_sync_fff_sptr -digital_make_pfb_clock_sync_fff(double sps, float loop_bw, - const std::vector<float> &taps, - unsigned int filter_size=32, - float init_phase=0, - float max_rate_deviation=1.5, - int osps=1); - -class digital_pfb_clock_sync_fff : public gr_block -{ - public: - void set_taps (const std::vector<float> &taps, - std::vector< std::vector<float> > &ourtaps, - std::vector<gr_fir_fff*> &ourfilter); - - std::vector< std::vector<float> > get_taps(); - std::vector< std::vector<float> > get_diff_taps(); - std::vector<float> get_channel_taps(int channel); - std::vector<float> get_diff_channel_taps(int channel); - std::string get_taps_as_string(); - std::string get_diff_taps_as_string(); - - void set_loop_bandwidth(float bw); - void set_damping_factor(float df); - void set_alpha(float alpha); - void set_beta(float beta); - void set_max_rate_deviation(float m); - - float get_loop_bandwidth() const; - float get_damping_factor() const; - float get_alpha() const; - float get_beta() const; - float get_clock_rate() const; -}; diff --git a/gr-digital/swig/digital_probe_mpsk_snr_est_c.i b/gr-digital/swig/digital_probe_mpsk_snr_est_c.i deleted file mode 100644 index 93db4127ac..0000000000 --- a/gr-digital/swig/digital_probe_mpsk_snr_est_c.i +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,probe_mpsk_snr_est_c); - -digital_probe_mpsk_snr_est_c_sptr -digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples=10000, - double alpha=0.001); - -class digital_probe_mpsk_snr_est_c : public gr_sync_block -{ -private: - void digital_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha); - -public: - double snr(); - snr_est_type_t type() const; - int msg_nsample() const; - double alpha() const; - void set_type(snr_est_type_t t); - void set_msg_nsample(int n); - void set_alpha(double alpha); -}; diff --git a/gr-digital/swig/digital_scrambler_bb.i b/gr-digital/swig/digital_scrambler_bb.i deleted file mode 100644 index ac9abef920..0000000000 --- a/gr-digital/swig/digital_scrambler_bb.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2012 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. - */ - -GR_SWIG_BLOCK_MAGIC(digital,scrambler_bb); - -digital_scrambler_bb_sptr -digital_make_scrambler_bb(int mask, int seed, int len); - -class digital_scrambler_bb : public gr_sync_block -{ -}; diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 191076d75c..3783da75ea 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -1,5 +1,5 @@ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,109 +19,166 @@ * Boston, MA 02110-1301, USA. */ +#define DIGITAL_API + %include "gnuradio.i" //load generated python docstrings %include "digital_swig_doc.i" -#if SWIGPYTHON -enum snr_est_type_t { - SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) - SNR_EST_SKEW, // Skewness-base est (>= 5 dB) - SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) - SNR_EST_SVR // SVR-based est (>= 0dB) -}; -#endif +%include "gr_cpm.h" -%include <gri_control_loop.i> +%include "gri_control_loop.h" -// Bring in generated blocks -%include "digital_generated.i" +// Used in the constellation objects +%template(unsigned_int_vector) std::vector<unsigned int>; %{ -#include "digital_additive_scrambler_bb.h" -#include "digital_binary_slicer_fb.h" -#include "digital_bytes_to_syms.h" -#include "digital_clock_recovery_mm_cc.h" -#include "digital_clock_recovery_mm_ff.h" -#include "digital_cma_equalizer_cc.h" -#include "digital_constellation.h" -#include "digital_constellation_decoder_cb.h" -#include "digital_constellation_receiver_cb.h" -#include "digital_correlate_access_code_bb.h" -#include "digital_correlate_access_code_tag_bb.h" -#include "digital_costas_loop_cc.h" -#include "digital_cpmmod_bc.h" -#include "digital_crc32.h" -#include "digital_descrambler_bb.h" -#include "digital_diff_decoder_bb.h" -#include "digital_diff_encoder_bb.h" -#include "digital_diff_phasor_cc.h" -#include "digital_fll_band_edge_cc.h" -#include "digital_framer_sink_1.h" -#include "digital_glfsr_source_b.h" -#include "digital_glfsr_source_f.h" -#include "digital_gmskmod_bc.h" -#include "digital_kurtotic_equalizer_cc.h" -#include "digital_lms_dd_equalizer_cc.h" -#include "digital_map_bb.h" -#include "digital_mpsk_receiver_cc.h" -#include "digital_mpsk_snr_est_cc.h" -#include "digital_ofdm_cyclic_prefixer.h" -#include "digital_ofdm_frame_acquisition.h" -#include "digital_ofdm_frame_sink.h" -#include "digital_ofdm_insert_preamble.h" -#include "digital_ofdm_mapper_bcv.h" -#include "digital_ofdm_sampler.h" -#include "digital_packet_sink.h" -#include "digital_pfb_clock_sync_ccf.h" -#include "digital_pfb_clock_sync_fff.h" -#include "digital_pn_correlator_cc.h" -#include "digital_probe_density_b.h" -#include "digital_probe_mpsk_snr_est_c.h" -#include "digital_scrambler_bb.h" -#include "digital_simple_framer.h" +#include "digital/metric_type.h" +#include "digital/mpsk_snr_est.h" +#include "digital/additive_scrambler_bb.h" +#include "digital/binary_slicer_fb.h" +#include "digital/chunks_to_symbols_bf.h" +#include "digital/chunks_to_symbols_bc.h" +#include "digital/chunks_to_symbols_sf.h" +#include "digital/chunks_to_symbols_sc.h" +#include "digital/chunks_to_symbols_if.h" +#include "digital/chunks_to_symbols_ic.h" +#include "digital/clock_recovery_mm_cc.h" +#include "digital/clock_recovery_mm_ff.h" +#include "digital/cma_equalizer_cc.h" +#include "digital/constellation.h" +#include "digital/constellation_receiver_cb.h" +#include "digital/constellation_decoder_cb.h" +#include "digital/correlate_access_code_bb.h" +#include "digital/correlate_access_code_tag_bb.h" +#include "digital/costas_loop_cc.h" +#include "digital/cpmmod_bc.h" +#include "digital/crc32.h" +#include "digital/descrambler_bb.h" +#include "digital/diff_decoder_bb.h" +#include "digital/diff_encoder_bb.h" +#include "digital/diff_phasor_cc.h" +#include "digital/fll_band_edge_cc.h" +#include "digital/framer_sink_1.h" +#include "digital/glfsr_source_b.h" +#include "digital/glfsr_source_f.h" +#include "digital/kurtotic_equalizer_cc.h" +#include "digital/lms_dd_equalizer_cc.h" +#include "digital/map_bb.h" +#include "digital/mpsk_receiver_cc.h" +#include "digital/mpsk_snr_est_cc.h" +#include "digital/ofdm_cyclic_prefixer.h" +#include "digital/ofdm_frame_acquisition.h" +#include "digital/ofdm_frame_sink.h" +#include "digital/ofdm_insert_preamble.h" +#include "digital/ofdm_mapper_bcv.h" +#include "digital/ofdm_sampler.h" +#include "digital/packet_sink.h" +#include "digital/pfb_clock_sync_ccf.h" +#include "digital/pfb_clock_sync_fff.h" +#include "digital/pn_correlator_cc.h" +#include "digital/probe_density_b.h" +#include "digital/probe_mpsk_snr_est_c.h" +#include "digital/scrambler_bb.h" +#include "digital/simple_framer.h" %} -%include "digital_additive_scrambler_bb.i" -%include "digital_bytes_to_syms.i" -%include "digital_binary_slicer_fb.i" -%include "digital_clock_recovery_mm_cc.i" -%include "digital_clock_recovery_mm_ff.i" -%include "digital_cma_equalizer_cc.i" -%include "digital_constellation.i" -%include "digital_constellation_decoder_cb.i" -%include "digital_constellation_receiver_cb.i" -%include "digital_correlate_access_code_bb.i" -%include "digital_correlate_access_code_tag_bb.i" -%include "digital_costas_loop_cc.i" -%include "digital_cpmmod_bc.i" -%include "digital_crc32.i" -%include "digital_descrambler_bb.i" -%include "digital_diff_decoder_bb.i" -%include "digital_diff_encoder_bb.i" -%include "digital_diff_phasor_cc.i" -%include "digital_fll_band_edge_cc.i" -%include "digital_framer_sink_1.i" -%include "digital_glfsr_source_b.i" -%include "digital_glfsr_source_f.i" -%include "digital_gmskmod_bc.i" -%include "digital_kurtotic_equalizer_cc.i" -%include "digital_lms_dd_equalizer_cc.i" -%include "digital_map_bb.i" -%include "digital_mpsk_receiver_cc.i" -%include "digital_mpsk_snr_est_cc.i" -%include "digital_ofdm_cyclic_prefixer.i" -%include "digital_ofdm_frame_acquisition.i" -%include "digital_ofdm_frame_sink.i" -%include "digital_ofdm_insert_preamble.i" -%include "digital_ofdm_mapper_bcv.i" -%include "digital_ofdm_sampler.i" -%include "digital_packet_sink.i" -%include "digital_pfb_clock_sync_ccf.i" -%include "digital_pfb_clock_sync_fff.i" -%include "digital_pn_correlator_cc.i" -%include "digital_probe_density_b.i" -%include "digital_probe_mpsk_snr_est_c.i" -%include "digital_scrambler_bb.i" -%include "digital_simple_framer.i" +%include "digital/metric_type.h" +%include "digital/mpsk_snr_est.h" +%include "digital/additive_scrambler_bb.h" +%include "digital/binary_slicer_fb.h" +%include "digital/chunks_to_symbols_bf.h" +%include "digital/chunks_to_symbols_bc.h" +%include "digital/chunks_to_symbols_sf.h" +%include "digital/chunks_to_symbols_sc.h" +%include "digital/chunks_to_symbols_if.h" +%include "digital/chunks_to_symbols_ic.h" +%include "digital/clock_recovery_mm_cc.h" +%include "digital/clock_recovery_mm_ff.h" +%include "digital/cma_equalizer_cc.h" +%include "digital/constellation.h" +%include "digital/constellation_receiver_cb.h" +%include "digital/constellation_decoder_cb.h" +%include "digital/correlate_access_code_bb.h" +%include "digital/correlate_access_code_tag_bb.h" +%include "digital/costas_loop_cc.h" +%include "digital/cpmmod_bc.h" +%include "digital/crc32.h" +%include "digital/descrambler_bb.h" +%include "digital/diff_decoder_bb.h" +%include "digital/diff_encoder_bb.h" +%include "digital/diff_phasor_cc.h" +%include "digital/fll_band_edge_cc.h" +%include "digital/framer_sink_1.h" +%include "digital/glfsr_source_b.h" +%include "digital/glfsr_source_f.h" +%include "digital/kurtotic_equalizer_cc.h" +%include "digital/lms_dd_equalizer_cc.h" +%include "digital/map_bb.h" +%include "digital/mpsk_receiver_cc.h" +%include "digital/mpsk_snr_est_cc.h" +%include "digital/ofdm_cyclic_prefixer.h" +%include "digital/ofdm_frame_acquisition.h" +%include "digital/ofdm_frame_sink.h" +%include "digital/ofdm_insert_preamble.h" +%include "digital/ofdm_mapper_bcv.h" +%include "digital/ofdm_sampler.h" +%include "digital/packet_sink.h" +%include "digital/pfb_clock_sync_ccf.h" +%include "digital/pfb_clock_sync_fff.h" +%include "digital/pn_correlator_cc.h" +%include "digital/probe_density_b.h" +%include "digital/probe_mpsk_snr_est_c.h" +%include "digital/scrambler_bb.h" +%include "digital/simple_framer.h" + +GR_SWIG_BLOCK_MAGIC2(digital, additive_scrambler_bb); +GR_SWIG_BLOCK_MAGIC2(digital, binary_slicer_fb); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bf); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_bc); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sf); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_sc); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_if); +GR_SWIG_BLOCK_MAGIC2(digital, chunks_to_symbols_ic); +GR_SWIG_BLOCK_MAGIC2(digital, clock_recovery_mm_cc); +GR_SWIG_BLOCK_MAGIC2(digital, clock_recovery_mm_ff); +GR_SWIG_BLOCK_MAGIC2(digital, cma_equalizer_cc); +GR_SWIG_BLOCK_MAGIC2(digital, constellation_receiver_cb); +GR_SWIG_BLOCK_MAGIC2(digital, constellation_decoder_cb); +GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_bb); +GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_tag_bb); +GR_SWIG_BLOCK_MAGIC2(digital, costas_loop_cc); +GR_SWIG_BLOCK_MAGIC2(digital, cpmmod_bc); +GR_SWIG_BLOCK_MAGIC2(digital, descrambler_bb); +GR_SWIG_BLOCK_MAGIC2(digital, diff_decoder_bb); +GR_SWIG_BLOCK_MAGIC2(digital, diff_encoder_bb); +GR_SWIG_BLOCK_MAGIC2(digital, diff_phasor_cc); +GR_SWIG_BLOCK_MAGIC2(digital, fll_band_edge_cc); +GR_SWIG_BLOCK_MAGIC2(digital, framer_sink_1); +GR_SWIG_BLOCK_MAGIC2(digital, glfsr_source_b); +GR_SWIG_BLOCK_MAGIC2(digital, glfsr_source_f); +GR_SWIG_BLOCK_MAGIC2(digital, kurtotic_equalizer_cc); +GR_SWIG_BLOCK_MAGIC2(digital, lms_dd_equalizer_cc); +GR_SWIG_BLOCK_MAGIC2(digital, map_bb); +GR_SWIG_BLOCK_MAGIC2(digital, mpsk_receiver_cc); +GR_SWIG_BLOCK_MAGIC2(digital, mpsk_snr_est_cc); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_cyclic_prefixer); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_acquisition); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_sink); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_insert_preamble); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_mapper_bcv); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_sampler); +GR_SWIG_BLOCK_MAGIC2(digital, packet_sink); +GR_SWIG_BLOCK_MAGIC2(digital, pfb_clock_sync_ccf); +GR_SWIG_BLOCK_MAGIC2(digital, pfb_clock_sync_fff); +GR_SWIG_BLOCK_MAGIC2(digital, pn_correlator_cc); +GR_SWIG_BLOCK_MAGIC2(digital, probe_density_b); +GR_SWIG_BLOCK_MAGIC2(digital, probe_mpsk_snr_est_c); +GR_SWIG_BLOCK_MAGIC2(digital, scrambler_bb); +GR_SWIG_BLOCK_MAGIC2(digital, simple_framer); + +GR_SWIG_BLOCK_MAGIC_FACTORY(digital, cpmmod_bc, gmskmod_bc); + +// Properly package up constellation objects +%include "constellation.i" diff --git a/gr-digital/swig/gnuradio/digital.scm b/gr-digital/swig/gnuradio/digital.scm deleted file mode 100644 index 834bc8d6de..0000000000 --- a/gr-digital/swig/gnuradio/digital.scm +++ /dev/null @@ -1,28 +0,0 @@ -;;; -;;; Copyright 2011 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 this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; Module that just re-exports the digital_swig module - -(define-module (gnuradio digital) - #:use-module (gnuradio export-safely) - #:use-module (gnuradio digital_swig) - #:duplicates (merge-generics replace check)) - -(re-export-all '(gnuradio digital_swig)) - diff --git a/gr-fcd/examples/c++/CMakeLists.txt b/gr-fcd/examples/c++/CMakeLists.txt index 05574f4a8c..adad7338cf 100644 --- a/gr-fcd/examples/c++/CMakeLists.txt +++ b/gr-fcd/examples/c++/CMakeLists.txt @@ -19,10 +19,11 @@ include_directories(${GR_FCD_INCLUDE_DIRS}) include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) +include_directories(${GR_FILTER_INCLUDE_DIRS}) include_directories(${GR_AUDIO_INCLUDE_DIRS}) add_executable(fcd_nfm_rx fcd_nfm_rx.cc) -target_link_libraries(fcd_nfm_rx gnuradio-fcd) +target_link_libraries(fcd_nfm_rx gnuradio-fcd gnuradio-filter) INSTALL(TARGETS fcd_nfm_rx diff --git a/gr-fcd/examples/c++/fcd_nfm_rx.cc b/gr-fcd/examples/c++/fcd_nfm_rx.cc index 0ebc5d2886..61417018a6 100644 --- a/gr-fcd/examples/c++/fcd_nfm_rx.cc +++ b/gr-fcd/examples/c++/fcd_nfm_rx.cc @@ -33,8 +33,8 @@ // Include header files for each block used in flowgraph #include <gr_top_block.h> -#include <gr_firdes.h> -#include <gr_fir_filter_ccf.h> +#include <filter/firdes.h> +#include <filter/fir_filter_ccf.h> #include <gr_quadrature_demod_cf.h> #include <gr_audio_sink.h> #include <fcd_source_c.h> @@ -85,8 +85,8 @@ int main(int argc, char **argv) fcd->set_lna_gain(gain); // Low pass filter - std::vector<float> taps = gr_firdes::low_pass(1.0, 96000, 5000.0, 1000.0); - gr_fir_filter_ccf_sptr filter = gr_make_fir_filter_ccf (2, taps); + std::vector<float> taps = gr::filter::firdes::low_pass(1.0, 96000, 5000.0, 1000.0); + gr::filter::fir_filter_ccf::sptr filter = gr::filter::fir_filter_ccf::make (2, taps); // FM demodulator // gain = sample_rate / (2*pi*max_dev) diff --git a/gr-fft/grc/CMakeLists.txt b/gr-fft/grc/CMakeLists.txt index 632a9aaad9..4c96d21738 100644 --- a/gr-fft/grc/CMakeLists.txt +++ b/gr-fft/grc/CMakeLists.txt @@ -19,8 +19,9 @@ install(FILES fft_block_tree.xml - fft_vxx.xml - goertzel_fc.xml + fft_fft_vxx.xml + fft_goertzel_fc.xml + fft_logpwrfft_x.xml DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "fft_python" ) diff --git a/gr-fft/grc/fft_block_tree.xml b/gr-fft/grc/fft_block_tree.xml index 3bda77eae1..5abbc3ef26 100644 --- a/gr-fft/grc/fft_block_tree.xml +++ b/gr-fft/grc/fft_block_tree.xml @@ -33,4 +33,9 @@ <block>fft_vxx</block> <block>goertzel_fc</block> </cat> + + <cat> + <name>Operators</name> + <block>logpwrfft_x</block> + </cat> </cat> diff --git a/gr-fft/grc/fft_vxx.xml b/gr-fft/grc/fft_fft_vxx.xml index 69f12ace77..69f12ace77 100644 --- a/gr-fft/grc/fft_vxx.xml +++ b/gr-fft/grc/fft_fft_vxx.xml diff --git a/gr-fft/grc/goertzel_fc.xml b/gr-fft/grc/fft_goertzel_fc.xml index 3712843586..3712843586 100644 --- a/gr-fft/grc/goertzel_fc.xml +++ b/gr-fft/grc/fft_goertzel_fc.xml diff --git a/grc/blocks/blks2_logpwrfft_x.xml b/gr-fft/grc/fft_logpwrfft_x.xml index 79a3bfc4bf..936be1cc71 100644 --- a/grc/blocks/blks2_logpwrfft_x.xml +++ b/gr-fft/grc/fft_logpwrfft_x.xml @@ -6,9 +6,9 @@ --> <block> <name>Log Power FFT</name> - <key>blks2_logpwrfft_x</key> - <import>from gnuradio import blks2</import> - <make>blks2.logpwrfft_$(type.fcn)( + <key>logpwrfft_x</key> + <import>from gnuradio import fft</import> + <make>fft.logpwrfft_$(type.fcn)( sample_rate=$sample_rate, fft_size=$fft_size, ref_scale=$ref_scale, diff --git a/gr-fft/python/CMakeLists.txt b/gr-fft/python/CMakeLists.txt index 16c29e5995..3cca444f9a 100644 --- a/gr-fft/python/CMakeLists.txt +++ b/gr-fft/python/CMakeLists.txt @@ -23,6 +23,7 @@ include(GrPython) GR_PYTHON_INSTALL( FILES __init__.py + logpwrfft.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/fft COMPONENT "fft_python" ) diff --git a/gr-fft/python/__init__.py b/gr-fft/python/__init__.py index 0fa643e35d..a532109b70 100644 --- a/gr-fft/python/__init__.py +++ b/gr-fft/python/__init__.py @@ -25,4 +25,4 @@ processing blocks for FFT and related functions. ''' from fft_swig import * - +from logpwrfft import * diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gr-fft/python/logpwrfft.py index 35a0ad7978..f48b60518f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py +++ b/gr-fft/python/logpwrfft.py @@ -20,8 +20,16 @@ # from gnuradio import gr, window -from stream_to_vector_decimator import stream_to_vector_decimator -import math +from gnuradio.blks2 import stream_to_vector_decimator +import sys, math + +import fft_swig as fft + +try: + from gnuradio import filter +except ImportError: + sys.stderr.write('fft.logpwrfft required gr-filter.\n') + sys.exit(1) class _logpwrfft_base(gr.hier_block2): """ @@ -57,7 +65,7 @@ class _logpwrfft_base(gr.hier_block2): window_power = sum(map(lambda x: x*x, fft_window)) c2magsq = gr.complex_to_mag_squared(fft_size) - self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size) + self._avg = filter.single_pole_iir_filter_ff(1.0, fft_size) self._log = gr.nlog10_ff(10, fft_size, -20*math.log10(fft_size) # Adjust for number of bins -10*math.log10(window_power/fft_size) # Adjust for windowing loss @@ -155,7 +163,7 @@ class logpwrfft_f(_logpwrfft_base): """ _name = "logpwrfft_f" _item_size = gr.sizeof_float - _fft_block = (gr.fft_vfc, ) + _fft_block = (fft.fft_vfc, ) class logpwrfft_c(_logpwrfft_base): """ @@ -163,5 +171,5 @@ class logpwrfft_c(_logpwrfft_base): """ _name = "logpwrfft_c" _item_size = gr.sizeof_gr_complex - _fft_block = (gr.fft_vcc, ) + _fft_block = (fft.fft_vcc, ) diff --git a/gr-filter/grc/CMakeLists.txt b/gr-filter/grc/CMakeLists.txt index 2e3fef4f07..0940f1c73c 100644 --- a/gr-filter/grc/CMakeLists.txt +++ b/gr-filter/grc/CMakeLists.txt @@ -19,23 +19,28 @@ install(FILES filter_block_tree.xml - dc_blocker_xx.xml - fft_filter_xxx.xml - fir_filter_xxx.xml - filter_delay_fc.xml - fractional_interpolator_xx.xml - freq_xlating_fir_filter_xxx.xml - hilbert_fc.xml - iir_filter_ffd.xml - interp_fir_filter_xxx.xml - pfb_arb_resampler.xml - pfb_channelizer.xml - pfb_decimator.xml - pfb_interpolator.xml - pfb_synthesizer.xml - rational_resampler_base_xxx.xml - single_pole_iir_filter_xx.xml - channel_model.xml + filter_dc_blocker_xx.xml + filter_fft_filter_xxx.xml + filter_fir_filter_xxx.xml + filter_filter_delay_fc.xml + filter_fractional_interpolator_xx.xml + filter_freq_xlating_fir_filter_xxx.xml + filter_hilbert_fc.xml + filter_iir_filter_ffd.xml + filter_interp_fir_filter_xxx.xml + filter_pfb_arb_resampler.xml + filter_pfb_channelizer.xml + filter_pfb_decimator.xml + filter_pfb_interpolator.xml + filter_pfb_synthesizer.xml + filter_rational_resampler_base_xxx.xml + filter_single_pole_iir_filter_xx.xml + filter_channel_model.xml + filter_low_pass_filter.xml + filter_high_pass_filter.xml + filter_band_pass_filter.xml + filter_band_reject_filter.xml + filter_root_raised_cosine_filter.xml DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "filter_python" ) diff --git a/grc/blocks/band_pass_filter.xml b/gr-filter/grc/filter_band_pass_filter.xml index af083473d3..c4c1852481 100644 --- a/grc/blocks/band_pass_filter.xml +++ b/gr-filter/grc/filter_band_pass_filter.xml @@ -7,9 +7,9 @@ <block> <name>Band Pass Filter</name> <key>band_pass_filter</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.$(type.fcn)( + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.$(type.fcn)( $gain, $samp_rate, $low_cutoff_freq, $high_cutoff_freq, $width, $win, $beta))</make> <callback>set_taps(firdes.$(type.fcn)($gain, $samp_rate, $low_cutoff_freq, $high_cutoff_freq, $width, $win, $beta))</callback> <param> diff --git a/grc/blocks/band_reject_filter.xml b/gr-filter/grc/filter_band_reject_filter.xml index dd5e7a9d76..a506789627 100644 --- a/grc/blocks/band_reject_filter.xml +++ b/gr-filter/grc/filter_band_reject_filter.xml @@ -7,9 +7,9 @@ <block> <name>Band Reject Filter</name> <key>band_reject_filter</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.band_reject( + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.band_reject( $gain, $samp_rate, $low_cutoff_freq, $high_cutoff_freq, $width, $win, $beta))</make> <callback>set_taps(firdes.band_reject($gain, $samp_rate, $low_cutoff_freq, $high_cutoff_freq, $width, $win, $beta))</callback> <param> diff --git a/gr-filter/grc/filter_block_tree.xml b/gr-filter/grc/filter_block_tree.xml index 711ce4059f..976833abb8 100644 --- a/gr-filter/grc/filter_block_tree.xml +++ b/gr-filter/grc/filter_block_tree.xml @@ -30,6 +30,13 @@ <name></name> <!-- Blank for Root Name --> <cat> <name>Filters</name> + <!-- FIR convenience filters --> + <block>low_pass_filter</block> + <block>high_pass_filter</block> + <block>band_pass_filter</block> + <block>band_reject_filter</block> + <block>root_raised_cosine_filter</block> + <!-- Regular Filter Blocks --> <block>dc_blocker_xx</block> <block>fft_filter_xxx</block> <block>fir_filter_xxx</block> diff --git a/gr-filter/grc/channel_model.xml b/gr-filter/grc/filter_channel_model.xml index 6d780974a2..6d780974a2 100644 --- a/gr-filter/grc/channel_model.xml +++ b/gr-filter/grc/filter_channel_model.xml diff --git a/gr-filter/grc/dc_blocker_xx.xml b/gr-filter/grc/filter_dc_blocker_xx.xml index 9bce5e980b..9bce5e980b 100644 --- a/gr-filter/grc/dc_blocker_xx.xml +++ b/gr-filter/grc/filter_dc_blocker_xx.xml diff --git a/gr-filter/grc/fft_filter_xxx.xml b/gr-filter/grc/filter_fft_filter_xxx.xml index 29612dffd6..29612dffd6 100644 --- a/gr-filter/grc/fft_filter_xxx.xml +++ b/gr-filter/grc/filter_fft_filter_xxx.xml diff --git a/gr-filter/grc/filter_delay_fc.xml b/gr-filter/grc/filter_filter_delay_fc.xml index 7b77c2caf9..7b77c2caf9 100644 --- a/gr-filter/grc/filter_delay_fc.xml +++ b/gr-filter/grc/filter_filter_delay_fc.xml diff --git a/gr-filter/grc/fir_filter_xxx.xml b/gr-filter/grc/filter_fir_filter_xxx.xml index 3925eb5559..3925eb5559 100644 --- a/gr-filter/grc/fir_filter_xxx.xml +++ b/gr-filter/grc/filter_fir_filter_xxx.xml diff --git a/gr-filter/grc/fractional_interpolator_xx.xml b/gr-filter/grc/filter_fractional_interpolator_xx.xml index 760e8bb060..760e8bb060 100644 --- a/gr-filter/grc/fractional_interpolator_xx.xml +++ b/gr-filter/grc/filter_fractional_interpolator_xx.xml diff --git a/gr-filter/grc/freq_xlating_fir_filter_xxx.xml b/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml index 178a42f487..178a42f487 100644 --- a/gr-filter/grc/freq_xlating_fir_filter_xxx.xml +++ b/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml diff --git a/grc/blocks/high_pass_filter.xml b/gr-filter/grc/filter_high_pass_filter.xml index 0e29cbb36f..6b041145d5 100644 --- a/grc/blocks/high_pass_filter.xml +++ b/gr-filter/grc/filter_high_pass_filter.xml @@ -7,9 +7,9 @@ <block> <name>High Pass Filter</name> <key>high_pass_filter</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.high_pass( + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.high_pass( $gain, $samp_rate, $cutoff_freq, $width, $win, $beta))</make> <callback>set_taps(firdes.high_pass($gain, $samp_rate, $cutoff_freq, $width, $win, $beta))</callback> <param> diff --git a/gr-filter/grc/hilbert_fc.xml b/gr-filter/grc/filter_hilbert_fc.xml index dd4c94b831..dd4c94b831 100644 --- a/gr-filter/grc/hilbert_fc.xml +++ b/gr-filter/grc/filter_hilbert_fc.xml diff --git a/gr-filter/grc/iir_filter_ffd.xml b/gr-filter/grc/filter_iir_filter_ffd.xml index 261aba320c..261aba320c 100644 --- a/gr-filter/grc/iir_filter_ffd.xml +++ b/gr-filter/grc/filter_iir_filter_ffd.xml diff --git a/gr-filter/grc/interp_fir_filter_xxx.xml b/gr-filter/grc/filter_interp_fir_filter_xxx.xml index 98a143f538..98a143f538 100644 --- a/gr-filter/grc/interp_fir_filter_xxx.xml +++ b/gr-filter/grc/filter_interp_fir_filter_xxx.xml diff --git a/grc/blocks/low_pass_filter.xml b/gr-filter/grc/filter_low_pass_filter.xml index 26435fd4d8..66d15bb592 100644 --- a/grc/blocks/low_pass_filter.xml +++ b/gr-filter/grc/filter_low_pass_filter.xml @@ -7,9 +7,9 @@ <block> <name>Low Pass Filter</name> <key>low_pass_filter</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.low_pass( + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.low_pass( $gain, $samp_rate, $cutoff_freq, $width, $win, $beta))</make> <callback>set_taps(firdes.low_pass($gain, $samp_rate, $cutoff_freq, $width, $win, $beta))</callback> <param> diff --git a/gr-filter/grc/pfb_arb_resampler.xml b/gr-filter/grc/filter_pfb_arb_resampler.xml index f3048000ac..5629adabfa 100644 --- a/gr-filter/grc/pfb_arb_resampler.xml +++ b/gr-filter/grc/filter_pfb_arb_resampler.xml @@ -7,12 +7,13 @@ <block> <name>Polyphase Arbitrary Resampler</name> <key>pfb_arb_resampler_xxx</key> - <import>from gnuradio import filter</import> + <import>from gnuradio.filter import pfb</import> <import>from gnuradio.filter import firdes</import> - <make>filter.pfb_arb_resampler_$(type)( + <make>pfb.arb_resampler_$(type)( $rrate, $taps, - $nfilts) + $nfilts, + $atten) </make> <callback>set_taps($taps)</callback> <param> @@ -50,6 +51,12 @@ <value>32</value> <type>int</type> </param> + <param> + <name>Stop-band Attenuation</name> + <key>atten</key> + <value>100</value> + <type>real</type> + </param> <sink> <name>in</name> <type>complex</type> diff --git a/gr-filter/grc/pfb_channelizer.xml b/gr-filter/grc/filter_pfb_channelizer.xml index 114abc0f06..26349cd10d 100644 --- a/gr-filter/grc/pfb_channelizer.xml +++ b/gr-filter/grc/filter_pfb_channelizer.xml @@ -7,9 +7,9 @@ <block> <name>Polyphase Channelizer</name> <key>pfb_channelizer_ccf</key> - <import>from gnuradio import filter</import> + <import>from gnuradio.filter import pfb</import> <import>from gnuradio.filter import firdes</import> - <make>filter.pfb.channelizer_ccf( + <make>pfb.channelizer_ccf( $nchans, $taps, $osr, @@ -29,7 +29,7 @@ self.$(id).set_channel_map($ch_map) <param> <name>Taps</name> <key>taps</key> - <value>None</value> + <value></value> <type>real_vector</type> </param> <param> diff --git a/gr-filter/grc/pfb_decimator.xml b/gr-filter/grc/filter_pfb_decimator.xml index b0540d3e2c..8ecf9b2d95 100644 --- a/gr-filter/grc/pfb_decimator.xml +++ b/gr-filter/grc/filter_pfb_decimator.xml @@ -7,12 +7,13 @@ <block> <name>Polyphase Decimator</name> <key>pfb_decimator_ccf</key> - <import>from gnuradio import filter</import> + <import>from gnuradio.filter import pfb</import> <import>from gnuradio.filter import firdes</import> - <make>filter.pfb_decimator_ccf( + <make>pfb.decimator_ccf( $decim, $taps, - $channel) + $channel, + $atten) </make> <callback>set_taps($taps)</callback> <param> @@ -23,7 +24,7 @@ <param> <name>Taps</name> <key>taps</key> - <value>None</value> + <value></value> <type>real_vector</type> </param> <param> @@ -32,6 +33,12 @@ <value>0</value> <type>int</type> </param> + <param> + <name>Stop-band Attenuation</name> + <key>atten</key> + <value>100</value> + <type>real</type> + </param> <sink> <name>in</name> <type>complex</type> diff --git a/gr-filter/grc/pfb_interpolator.xml b/gr-filter/grc/filter_pfb_interpolator.xml index 6004931235..59749ab900 100644 --- a/gr-filter/grc/pfb_interpolator.xml +++ b/gr-filter/grc/filter_pfb_interpolator.xml @@ -7,11 +7,12 @@ <block> <name>Polyphase Interpolator</name> <key>pfb_interpolator_ccf</key> - <import>from gnuradio import filter</import> + <import>from gnuradio.filter import pfb</import> <import>from gnuradio.filter import firdes</import> - <make>filter.pfb.interpolator_ccf( + <make>pfb.interpolator_ccf( $interp, - $taps) + $taps, + $atten) </make> <callback>set_taps($taps)</callback> <param> @@ -22,9 +23,15 @@ <param> <name>Taps</name> <key>taps</key> - <value>None</value> + <value></value> <type>real_vector</type> </param> + <param> + <name>Attenuation</name> + <key>atten</key> + <value>100</value> + <type>real</type> + </param> <sink> <name>in</name> <type>complex</type> diff --git a/gr-filter/grc/pfb_synthesizer.xml b/gr-filter/grc/filter_pfb_synthesizer.xml index e84b25e62e..e84b25e62e 100644 --- a/gr-filter/grc/pfb_synthesizer.xml +++ b/gr-filter/grc/filter_pfb_synthesizer.xml diff --git a/gr-filter/grc/rational_resampler_base_xxx.xml b/gr-filter/grc/filter_rational_resampler_base_xxx.xml index 399bfc74c9..399bfc74c9 100644 --- a/gr-filter/grc/rational_resampler_base_xxx.xml +++ b/gr-filter/grc/filter_rational_resampler_base_xxx.xml diff --git a/grc/blocks/root_raised_cosine_filter.xml b/gr-filter/grc/filter_root_raised_cosine_filter.xml index 81688d2973..fde88828da 100644 --- a/grc/blocks/root_raised_cosine_filter.xml +++ b/gr-filter/grc/filter_root_raised_cosine_filter.xml @@ -7,9 +7,9 @@ <block> <name>Root Raised Cosine Filter</name> <key>root_raised_cosine_filter</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.root_raised_cosine( + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.$(type)(#if str($type).startswith('interp') then $interp else $decim#, firdes.root_raised_cosine( $gain, $samp_rate, $sym_rate, $alpha, $ntaps))</make> <callback>set_taps(firdes.root_raised_cosine($gain, $samp_rate, $sym_rate, $alpha, $ntaps))</callback> <param> diff --git a/gr-filter/grc/single_pole_iir_filter_xx.xml b/gr-filter/grc/filter_single_pole_iir_filter_xx.xml index 3eaf52625f..3eaf52625f 100644 --- a/gr-filter/grc/single_pole_iir_filter_xx.xml +++ b/gr-filter/grc/filter_single_pole_iir_filter_xx.xml diff --git a/gr-filter/include/filter/CMakeLists.txt b/gr-filter/include/filter/CMakeLists.txt index c6bf109cde..536b74b54e 100644 --- a/gr-filter/include/filter/CMakeLists.txt +++ b/gr-filter/include/filter/CMakeLists.txt @@ -78,6 +78,7 @@ add_custom_target(filter_generated_includes DEPENDS ######################################################################## install(FILES api.h + adaptive_fir.h firdes.h fir_filter.h fir_filter_with_buffer.h diff --git a/gr-filter/include/filter/adaptive_fir.h b/gr-filter/include/filter/adaptive_fir.h new file mode 100644 index 0000000000..28db1c3c08 --- /dev/null +++ b/gr-filter/include/filter/adaptive_fir.h @@ -0,0 +1,88 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 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_FILTER_ADAPTIVE_FIR_H +#define INCLUDED_FILTER_ADAPTIVE_FIR_H + +#include <filter/api.h> +#include <filter/fir_filter.h> + +namespace gr { + namespace filter { + namespace kernel { + + /*! + * \brief Adaptive FIR filter kernel with gr_complex input, + * gr_complex output and gr_complex taps + * + * This class implements an adaptive FIR filter. Any class + * actually wanting to use adaptive FIRs will contain an object of + * this class. + */ + class FILTER_API adaptive_fir_ccc : public fir_filter_ccc + { + public: + adaptive_fir_ccc(int decimation, + const std::vector<gr_complex> &taps); + ~adaptive_fir_ccc(); + + protected: + // Override to calculate error signal per output + virtual gr_complex error(const gr_complex &out) = 0; + + // Override to calculate new weight from old, corresponding input + virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0; + + gr_complex d_error; + }; + + + /*! + * \brief Adaptive FIR filter kernel with gr_complex input, + * gr_complex output and float taps + * + * This class implements an adaptive FIR filter. Any class + * actually wanting to use adaptive FIRs will contain an object of + * this class. + */ + class FILTER_API adaptive_fir_ccf : public fir_filter_ccf + { + public: + adaptive_fir_ccf(int decimation, + const std::vector<float> &taps); + ~adaptive_fir_ccf(); + + protected: + // Override to calculate error signal per output + virtual float error(const gr_complex &out) = 0; + + // Override to calculate new weight from old, corresponding input + virtual void update_tap(float &tap, const gr_complex &in) = 0; + + float d_error; + }; + + } /* namespace kernel */ + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_FILTER_ADAPTIVE_FIR_H */ diff --git a/gr-filter/include/filter/adaptive_fir_ccc.h b/gr-filter/include/filter/adaptive_fir_ccc.h index 261259957f..15f823ba59 100644 --- a/gr-filter/include/filter/adaptive_fir_ccc.h +++ b/gr-filter/include/filter/adaptive_fir_ccc.h @@ -25,7 +25,6 @@ #include <filter/api.h> #include <gr_sync_decimator.h> -#include <filter/fir_filter.h> namespace gr { namespace filter { @@ -61,6 +60,8 @@ namespace gr { */ class FILTER_API adaptive_fir_ccc : virtual public gr_sync_decimator { + protected: + public: // gr::filter::adaptive_fir_ccc::sptr typedef boost::shared_ptr<adaptive_fir_ccc> sptr; @@ -73,7 +74,7 @@ namespace gr { * \param taps (complex) filter taps */ static sptr make(const char *name, int decimation, - const std::vector<gr_complex> &taps); + const std::vector<gr_complex> &taps); virtual void set_taps(const std::vector<gr_complex> &taps) = 0; virtual std::vector<gr_complex> taps() const = 0; diff --git a/gr-filter/include/filter/pfb_decimator_ccf.h b/gr-filter/include/filter/pfb_decimator_ccf.h index bf9d0d9508..e1a43eab83 100644 --- a/gr-filter/include/filter/pfb_decimator_ccf.h +++ b/gr-filter/include/filter/pfb_decimator_ccf.h @@ -56,7 +56,7 @@ namespace gr { * * The output signal will be the basebanded and decimated signal * from that channel. This concept is very similar to the PFB - * channelizer (see #gr_pfb_channelizer_ccf) where only a single + * channelizer (see #gr::filter::pfb_channelizer_ccf) where only a single * channel is extracted at a time. * * The filter's taps should be based on the sampling rate before diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index 532bd1992d..c47528046a 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -108,6 +108,7 @@ link_directories(${FFTW3F_LIBRARY_DIRS}) # Setup library ######################################################################## list(APPEND filter_sources + adaptive_fir.cc fir_filter.cc fir_filter_with_buffer.cc fft_filter.cc diff --git a/gr-digital/lib/digital_gmskmod_bc.cc b/gr-filter/lib/adaptive_fir.cc index e53e900370..b7d2262bb5 100644 --- a/gr-digital/lib/digital_gmskmod_bc.cc +++ b/gr-filter/lib/adaptive_fir.cc @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. - * + * Copyright 2011,2012 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, @@ -24,21 +24,37 @@ #include "config.h" #endif -#include <digital_gmskmod_bc.h> +#include <filter/adaptive_fir.h> #include <gr_io_signature.h> -// Shared pointer constructor -digital_gmskmod_bc_sptr -digital_make_gmskmod_bc(unsigned samples_per_sym, - double bt, unsigned L) -{ - return gnuradio::get_initial_sptr(new digital_gmskmod_bc(samples_per_sym, bt, L)); -} +namespace gr { + namespace filter { + namespace kernel { + + adaptive_fir_ccc::adaptive_fir_ccc(int decimation, + const std::vector<gr_complex> &taps) + : fir_filter_ccc(decimation, taps) + { + } + + adaptive_fir_ccc::~adaptive_fir_ccc() + { + } + + + /**************************************************************/ + + adaptive_fir_ccf::adaptive_fir_ccf(int decimation, + const std::vector<float> &taps) + : fir_filter_ccf(decimation, taps) + { + } -digital_gmskmod_bc::digital_gmskmod_bc(unsigned samples_per_sym, - double bt, unsigned L) - : digital_cpmmod_bc(gr_cpm::GAUSSIAN, 0.5, samples_per_sym, L, bt) -{ -} + adaptive_fir_ccf::~adaptive_fir_ccf() + { + } + } /* namespace kernel */ + } /* namespace filter */ +} /* namespace gr */ diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.cc b/gr-filter/lib/adaptive_fir_ccc_impl.cc index 515ef90cd0..a4304bcedb 100644 --- a/gr-filter/lib/adaptive_fir_ccc_impl.cc +++ b/gr-filter/lib/adaptive_fir_ccc_impl.cc @@ -43,7 +43,7 @@ namespace gr { gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex)), decimation), - kernel::fir_filter_ccc(decimation, taps), + kernel::adaptive_fir_ccc(decimation, taps), d_updated(false) { set_history(d_ntaps); diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.h b/gr-filter/lib/adaptive_fir_ccc_impl.h index fd6274a1d6..054cb4b53e 100644 --- a/gr-filter/lib/adaptive_fir_ccc_impl.h +++ b/gr-filter/lib/adaptive_fir_ccc_impl.h @@ -24,13 +24,14 @@ #define INCLUDED_FILTER_ADAPTIVE_FIR_CCC_IMPL_H #include <filter/adaptive_fir_ccc.h> -#include <filter/fir_filter.h> +#include <filter/adaptive_fir.h> #include <gr_types.h> namespace gr { namespace filter { - class FILTER_API adaptive_fir_ccc_impl : public adaptive_fir_ccc, public kernel::fir_filter_ccc + class FILTER_API adaptive_fir_ccc_impl : + public adaptive_fir_ccc, public kernel::adaptive_fir_ccc { private: std::vector<gr_complex> d_new_taps; diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.cc b/gr-filter/lib/adaptive_fir_ccf_impl.cc index 004a9286bb..f07b697106 100644 --- a/gr-filter/lib/adaptive_fir_ccf_impl.cc +++ b/gr-filter/lib/adaptive_fir_ccf_impl.cc @@ -43,7 +43,7 @@ namespace gr { gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex)), decimation), - kernel::fir_filter_ccf(decimation, taps), + kernel::adaptive_fir_ccf(decimation, taps), d_updated(false) { set_history(d_ntaps); diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.h b/gr-filter/lib/adaptive_fir_ccf_impl.h index a0c9581ea2..dc34185d68 100644 --- a/gr-filter/lib/adaptive_fir_ccf_impl.h +++ b/gr-filter/lib/adaptive_fir_ccf_impl.h @@ -24,13 +24,14 @@ #define INCLUDED_FILTER_ADAPTIVE_FIR_CCF_IMPL_H #include <filter/adaptive_fir_ccf.h> -#include <filter/fir_filter.h> +#include <filter/adaptive_fir.h> #include <gr_types.h> namespace gr { namespace filter { - class FILTER_API adaptive_fir_ccf_impl : public adaptive_fir_ccf, public kernel::fir_filter_ccf + class FILTER_API adaptive_fir_ccf_impl : + public adaptive_fir_ccf, public kernel::adaptive_fir_ccf { private: std::vector<float> d_new_taps; diff --git a/gr-filter/lib/channel_model_impl.cc b/gr-filter/lib/channel_model_impl.cc index f9e9954794..88732d95d3 100644 --- a/gr-filter/lib/channel_model_impl.cc +++ b/gr-filter/lib/channel_model_impl.cc @@ -48,7 +48,7 @@ namespace gr { double epsilon, const std::vector<gr_complex> &taps, double noise_seed) - : gr_hier_block2("gr_channel_model", + : gr_hier_block2("channel_model", gr_make_io_signature(1, 1, sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex))) { diff --git a/gnuradio-core/src/gen_interpolator_taps/README b/gr-filter/lib/gen_interpolator_taps/README index 8fe3e2ba32..8fe3e2ba32 100644 --- a/gnuradio-core/src/gen_interpolator_taps/README +++ b/gr-filter/lib/gen_interpolator_taps/README diff --git a/gnuradio-core/src/gen_interpolator_taps/gen_interpolator_taps.c b/gr-filter/lib/gen_interpolator_taps/gen_interpolator_taps.c index 2f359102cf..2f359102cf 100644 --- a/gnuradio-core/src/gen_interpolator_taps/gen_interpolator_taps.c +++ b/gr-filter/lib/gen_interpolator_taps/gen_interpolator_taps.c diff --git a/gnuradio-core/src/gen_interpolator_taps/objective_fct.c b/gr-filter/lib/gen_interpolator_taps/objective_fct.c index 129486d634..129486d634 100644 --- a/gnuradio-core/src/gen_interpolator_taps/objective_fct.c +++ b/gr-filter/lib/gen_interpolator_taps/objective_fct.c diff --git a/gnuradio-core/src/gen_interpolator_taps/praxis.f b/gr-filter/lib/gen_interpolator_taps/praxis.f index 9f3e03c977..9f3e03c977 100644 --- a/gnuradio-core/src/gen_interpolator_taps/praxis.f +++ b/gr-filter/lib/gen_interpolator_taps/praxis.f diff --git a/gnuradio-core/src/gen_interpolator_taps/praxis.txt b/gr-filter/lib/gen_interpolator_taps/praxis.txt index 9d06065660..9d06065660 100644 --- a/gnuradio-core/src/gen_interpolator_taps/praxis.txt +++ b/gr-filter/lib/gen_interpolator_taps/praxis.txt diff --git a/gnuradio-core/src/gen_interpolator_taps/simpson.c b/gr-filter/lib/gen_interpolator_taps/simpson.c index 31aaae4aef..31aaae4aef 100644 --- a/gnuradio-core/src/gen_interpolator_taps/simpson.c +++ b/gr-filter/lib/gen_interpolator_taps/simpson.c diff --git a/gnuradio-core/src/gen_interpolator_taps/simpson.h b/gr-filter/lib/gen_interpolator_taps/simpson.h index 68774f9a2e..68774f9a2e 100644 --- a/gnuradio-core/src/gen_interpolator_taps/simpson.h +++ b/gr-filter/lib/gen_interpolator_taps/simpson.h diff --git a/gr-filter/python/pfb.py b/gr-filter/python/pfb.py index ddf2899826..b9608362c3 100644 --- a/gr-filter/python/pfb.py +++ b/gr-filter/python/pfb.py @@ -39,7 +39,7 @@ class channelizer_ccf(gr.hier_block2): self._nchans = numchans self._oversample_rate = oversample_rate - if taps is not None: + if (taps is not None) and (len(taps) > 0): self._taps = taps else: # Create a filter that covers the full bandwidth of the input signal @@ -91,7 +91,7 @@ class interpolator_ccf(gr.hier_block2): self._interp = interp self._taps = taps - if taps is not None: + if (taps is not None) and (len(taps) > 0): self._taps = taps else: # Create a filter that covers the full bandwidth of the input signal @@ -133,7 +133,7 @@ class decimator_ccf(gr.hier_block2): self._decim = decim self._channel = channel - if taps is not None: + if (taps is not None) and (len(taps) > 0): self._taps = taps else: # Create a filter that covers the full bandwidth of the input signal @@ -182,7 +182,7 @@ class arb_resampler_ccf(gr.hier_block2): self._rate = rate self._size = flt_size - if taps is not None: + if (taps is not None) and (len(taps) > 0): self._taps = taps else: # Create a filter that covers the full bandwidth of the input signal @@ -235,7 +235,7 @@ class arb_resampler_fff(gr.hier_block2): self._rate = rate self._size = flt_size - if taps is not None: + if (taps is not None) and (len(taps) > 0): self._taps = taps else: # Create a filter that covers the full bandwidth of the input signal diff --git a/gr-qtgui/include/qtgui/freq_sink_c.h b/gr-qtgui/include/qtgui/freq_sink_c.h index e1c30080c2..2bef9035e8 100644 --- a/gr-qtgui/include/qtgui/freq_sink_c.h +++ b/gr-qtgui/include/qtgui/freq_sink_c.h @@ -52,7 +52,7 @@ namespace gr { /*! * \brief Build a complex PSD sink. * - * \param size size of the FFT to compute and display + * \param fftsize size of the FFT to compute and display * \param wintype type of window to apply (see filter/firdes.h) * \param fc center frequency of signal (use for x-axis labels) * \param bw bandwidth of signal (used to set x-axis labels) diff --git a/gr-qtgui/include/qtgui/freq_sink_f.h b/gr-qtgui/include/qtgui/freq_sink_f.h index 6b7d1717b5..51c4ac10a1 100644 --- a/gr-qtgui/include/qtgui/freq_sink_f.h +++ b/gr-qtgui/include/qtgui/freq_sink_f.h @@ -52,7 +52,7 @@ namespace gr { /*! * \brief Build a floating point PSD sink. * - * \param size size of the FFT to compute and display + * \param fftsize size of the FFT to compute and display * \param wintype type of window to apply (see filter/firdes.h) * \param fc center frequency of signal (use for x-axis labels) * \param bw bandwidth of signal (used to set x-axis labels) diff --git a/gr-qtgui/include/qtgui/sink_c.h b/gr-qtgui/include/qtgui/sink_c.h index b844ca7777..f8d58ddbe0 100644 --- a/gr-qtgui/include/qtgui/sink_c.h +++ b/gr-qtgui/include/qtgui/sink_c.h @@ -54,12 +54,15 @@ namespace gr { /*! * \brief Build a complex qtgui sink. * - * \param size size of the FFT to compute and display + * \param fftsize size of the FFT to compute and display * \param wintype type of window to apply (see filter/firdes.h) * \param fc center frequency of signal (use for x-axis labels) * \param bw bandwidth of signal (used to set x-axis labels) * \param name title for the plot - * \param nconnections number of signals connected to sink + * \param plotfreq Toggle frequency plot on/off + * \param plotwaterfall Toggle waterfall plot on/off + * \param plottime Toggle time plot on/off + * \param plotconst Toggle constellation plot on/off * \param parent a QWidget parent object, if any */ static sptr make(int fftsize, int wintype, diff --git a/gr-qtgui/include/qtgui/sink_f.h b/gr-qtgui/include/qtgui/sink_f.h index 961a5d561f..0af49ba9e2 100644 --- a/gr-qtgui/include/qtgui/sink_f.h +++ b/gr-qtgui/include/qtgui/sink_f.h @@ -54,12 +54,15 @@ namespace gr { /*! * \brief Build a floating point qtgui sink. * - * \param size size of the FFT to compute and display + * \param fftsize size of the FFT to compute and display * \param wintype type of window to apply (see filter/firdes.h) * \param fc center frequency of signal (use for x-axis labels) * \param bw bandwidth of signal (used to set x-axis labels) * \param name title for the plot - * \param nconnections number of signals connected to sink + * \param plotfreq Toggle frequency plot on/off + * \param plotwaterfall Toggle waterfall plot on/off + * \param plottime Toggle time plot on/off + * \param plotconst Toggle constellation plot on/off * \param parent a QWidget parent object, if any */ static sptr make(int fftsize, int wintype, diff --git a/gr-trellis/CMakeLists.txt b/gr-trellis/CMakeLists.txt index 16a3e7c191..2685be2950 100644 --- a/gr-trellis/CMakeLists.txt +++ b/gr-trellis/CMakeLists.txt @@ -94,13 +94,10 @@ CPACK_COMPONENT("trellis_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(src/lib) +add_subdirectory(src) add_subdirectory(doc) if(ENABLE_PYTHON) add_subdirectory(grc) - add_subdirectory(src/python) - add_subdirectory(src/examples/python) - add_subdirectory(src/examples/grc) endif(ENABLE_PYTHON) ######################################################################## diff --git a/gnuradio-core/src/examples/pfb/CMakeLists.txt b/gr-trellis/src/CMakeLists.txt index 6bb25568c8..56db84a3e4 100644 --- a/gnuradio-core/src/examples/pfb/CMakeLists.txt +++ b/gr-trellis/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -17,20 +17,12 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -include(GrPython) - -GR_PYTHON_INSTALL(PROGRAMS - channelize.py - chirp_channelize.py - decimate.py - fmtest.py - interpolate.py - resampler_demo.grc - resampler.py - synth_filter.py - synth_to_chan.py - reconstruction.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/pfb - COMPONENT "core_python" -) - +######################################################################## +# Add subdirectories +######################################################################## +add_subdirectory(lib) +if(ENABLE_PYTHON) + add_subdirectory(python) + add_subdirectory(examples/python) + add_subdirectory(examples/grc) +endif(ENABLE_PYTHON) diff --git a/gr-trellis/src/examples/python/test_cpm.py b/gr-trellis/src/examples/python/test_cpm.py index 7503a458b1..7e80d400be 100755 --- a/gr-trellis/src/examples/python/test_cpm.py +++ b/gr-trellis/src/examples/python/test_cpm.py @@ -8,7 +8,7 @@ ################################################## from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, filter from gnuradio.gr import firdes from grc_gnuradio import blks2 as grc_blks2 import math @@ -45,7 +45,7 @@ def run_test(seed,blocksize): BT=0.3; tt=numpy.arange(0,L*Q)/(1.0*Q)-L/2.0; #print tt - p=(0.5*scipy.stats.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.stats.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0; + p=(0.5*scipy.special.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.special.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0; p=p/sum(p)*Q/2.0; #print p q=numpy.cumsum(p)/Q; @@ -90,7 +90,7 @@ def run_test(seed,blocksize): ################################################## random_source_x_0 = gr.vector_source_b(data.tolist(), False) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf((-1, 1), 1) - gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(Q, p) + gr_interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Q, p) gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) gr_add_vxx_0 = gr.add_vcc(1) @@ -99,8 +99,8 @@ def run_test(seed,blocksize): gr_multiply_vxx_0 = gr.multiply_vcc(1) gr_sig_source_x_0 = gr.sig_source_c(Q, gr.GR_COS_WAVE, -f0T, 1, 0) # only works for N=2, do it manually for N>2... - gr_fir_filter_xxx_0_0 = gr.fir_filter_ccc(Q, MF[0].conjugate()) - gr_fir_filter_xxx_0_0_0 = gr.fir_filter_ccc(Q, MF[1].conjugate()) + gr_fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, MF[0].conjugate()) + gr_fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, MF[1].conjugate()) gr_streams_to_stream_0 = gr.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), diff --git a/gr-trellis/src/examples/python/test_turbo_equalization1.py b/gr-trellis/src/examples/python/test_turbo_equalization1.py index da1132d38c..e8b946458c 100755 --- a/gr-trellis/src/examples/python/test_turbo_equalization1.py +++ b/gr-trellis/src/examples/python/test_turbo_equalization1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, filter from gnuradio import eng_notation import math import sys @@ -64,7 +64,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL - isi = gr.fir_filter_fff(1,channel) + isi = filter.fir_filter_fff(1,channel) add = gr.add_ff() noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) diff --git a/gr-trellis/src/examples/python/test_turbo_equalization2.py b/gr-trellis/src/examples/python/test_turbo_equalization2.py index 886240efac..6b37ee9b59 100755 --- a/gr-trellis/src/examples/python/test_turbo_equalization2.py +++ b/gr-trellis/src/examples/python/test_turbo_equalization2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, filter from gnuradio import eng_notation import math import sys @@ -62,7 +62,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL - isi = gr.fir_filter_fff(1,channel) + isi = filter.fir_filter_fff(1,channel) add = gr.add_ff() noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) diff --git a/gr-trellis/src/examples/python/test_viterbi_equalization1.py b/gr-trellis/src/examples/python/test_viterbi_equalization1.py index caf99ff581..cb000d6852 100755 --- a/gr-trellis/src/examples/python/test_viterbi_equalization1.py +++ b/gr-trellis/src/examples/python/test_viterbi_equalization1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from gnuradio import gr -from gnuradio import trellis, digital +from gnuradio import trellis, digital, filter from gnuradio import eng_notation import math import sys @@ -25,7 +25,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL - isi = gr.fir_filter_fff(1,channel) + isi = filter.fir_filter_fff(1,channel) add = gr.add_ff() noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed) diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt index 8f29f9605b..315ef3a93c 100644 --- a/gr-trellis/src/lib/CMakeLists.txt +++ b/gr-trellis/src/lib/CMakeLists.txt @@ -148,6 +148,7 @@ list(APPEND gr_trellis_sources list(APPEND trellis_libs gnuradio-core + gnuradio-digital ${Boost_LIBRARIES} ) diff --git a/gr-trellis/src/lib/calc_metric.cc b/gr-trellis/src/lib/calc_metric.cc index ce628209b4..4d58a05482 100644 --- a/gr-trellis/src/lib/calc_metric.cc +++ b/gr-trellis/src/lib/calc_metric.cc @@ -27,14 +27,15 @@ template <class T> -void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float *metric, trellis_metric_type_t type) +void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, + float *metric, gr::digital::trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; switch (type){ - case TRELLIS_EUCLIDEAN: + case gr::digital::TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -45,7 +46,7 @@ void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float * } } break; - case TRELLIS_HARD_SYMBOL: + case gr::digital::TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -63,7 +64,7 @@ void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float * metric[o] = (o==minmi?0.0:1.0); } break; - case TRELLIS_HARD_BIT: + case gr::digital::TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); break; default: @@ -74,23 +75,27 @@ void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float * template -void calc_metric<short>(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type); +void calc_metric<short>(int O, int D, const std::vector<short> &TABLE, const short *in, + float *metric, gr::digital::trellis_metric_type_t type); template -void calc_metric<int>(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type); +void calc_metric<int>(int O, int D, const std::vector<int> &TABLE, const int *in, + float *metric, gr::digital::trellis_metric_type_t type); template -void calc_metric<float>(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type); +void calc_metric<float>(int O, int D, const std::vector<float> &TABLE, const float *in, + float *metric, gr::digital::trellis_metric_type_t type); /* -void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type) +void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, + float *metric, gr::digital::trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; switch (type){ - case TRELLIS_EUCLIDEAN: + case gr::digital::TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -99,7 +104,7 @@ void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, } } break; - case TRELLIS_HARD_SYMBOL: + case gr::digital::TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -115,7 +120,7 @@ void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, metric[o] = (o==minmi?0.0:1.0); } break; - case TRELLIS_HARD_BIT: + case gr::digital::TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); break; default: @@ -124,13 +129,14 @@ void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, } -void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type) +void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, + float *metric, gr::digital::trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; switch (type){ - case TRELLIS_EUCLIDEAN: + case gr::digital::TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -139,7 +145,7 @@ void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, flo } } break; - case TRELLIS_HARD_SYMBOL: + case gr::digital::TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -155,7 +161,7 @@ void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, flo metric[o] = (o==minmi?0.0:1.0); } break; - case TRELLIS_HARD_BIT: + case gr::digital::TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); break; default: @@ -165,13 +171,14 @@ void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, flo -void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type) +void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, + float *metric, gr::digital::trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; switch (type){ - case TRELLIS_EUCLIDEAN: + case gr::digital::TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -180,7 +187,7 @@ void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, } } break; - case TRELLIS_HARD_SYMBOL: + case gr::digital::TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -196,7 +203,7 @@ void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, metric[o] = (o==minmi?0.0:1.0); } break; - case TRELLIS_HARD_BIT: + case gr::digital::TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); break; default: @@ -209,14 +216,15 @@ void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, -void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type) +void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, + float *metric, gr::digital::trellis_metric_type_t type) { float minm = FLT_MAX; int minmi = 0; switch (type){ - case TRELLIS_EUCLIDEAN: + case gr::digital::TRELLIS_EUCLIDEAN: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -225,7 +233,7 @@ void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_co } } break; - case TRELLIS_HARD_SYMBOL: + case gr::digital::TRELLIS_HARD_SYMBOL: for(int o=0;o<O;o++) { metric[o]=0.0; for (int m=0;m<D;m++) { @@ -241,7 +249,7 @@ void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_co metric[o] = (o==minmi?0.0:1.0); } break; - case TRELLIS_HARD_BIT: + case gr::digital::TRELLIS_HARD_BIT: throw std::runtime_error ("Invalid metric type (not yet implemented)."); break; default: diff --git a/gr-trellis/src/lib/calc_metric.h b/gr-trellis/src/lib/calc_metric.h index 7cad6160aa..cc0a12878d 100644 --- a/gr-trellis/src/lib/calc_metric.h +++ b/gr-trellis/src/lib/calc_metric.h @@ -25,21 +25,23 @@ #include <vector> #include <gr_complex.h> -#include <digital_metric_type.h> +#include <digital/metric_type.h> template <class T> -void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, float *metric, trellis_metric_type_t type); +void calc_metric(int O, int D, const std::vector<T> &TABLE, const T *in, + float *metric, gr::digital::trellis_metric_type_t type); /* -void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, trellis_metric_type_t type); +void calc_metric(int O, int D, const std::vector<short> &TABLE, const short *in, float *metric, gr::digital::trellis_metric_type_t type); -void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, trellis_metric_type_t type); +void calc_metric(int O, int D, const std::vector<int> &TABLE, const int *in, float *metric, gr::digital::trellis_metric_type_t type); -void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, trellis_metric_type_t type); +void calc_metric(int O, int D, const std::vector<float> &TABLE, const float *in, float *metric, gr::digital::trellis_metric_type_t type); */ -void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, float *metric, trellis_metric_type_t type); +void calc_metric(int O, int D, const std::vector<gr_complex> &TABLE, const gr_complex *in, + float *metric, gr::digital::trellis_metric_type_t type); diff --git a/gr-trellis/src/lib/core_algorithms.cc b/gr-trellis/src/lib/core_algorithms.cc index 3ed912c08a..442565054a 100644 --- a/gr-trellis/src/lib/core_algorithms.cc +++ b/gr-trellis/src/lib/core_algorithms.cc @@ -154,7 +154,7 @@ void viterbi_algorithm_combined(int I, int S, int O, int S0,int SK, int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const Ti *in, To *out ) { @@ -231,7 +231,7 @@ void viterbi_algorithm_combined<short,unsigned char>(int I, int S, int O, int S0,int SK, int D, const std::vector<short> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const short *in, unsigned char *out ); @@ -245,7 +245,7 @@ void viterbi_algorithm_combined<int,unsigned char>(int I, int S, int O, int S0,int SK, int D, const std::vector<int> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const int *in, unsigned char *out ); @@ -259,7 +259,7 @@ void viterbi_algorithm_combined<float,unsigned char>(int I, int S, int O, int S0,int SK, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *in, unsigned char *out ); @@ -273,7 +273,7 @@ void viterbi_algorithm_combined<gr_complex,unsigned char>(int I, int S, int O, int S0,int SK, int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const gr_complex *in, unsigned char *out ); @@ -289,7 +289,7 @@ void viterbi_algorithm_combined<short,short>(int I, int S, int O, int S0,int SK, int D, const std::vector<short> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const short *in, short *out ); @@ -303,7 +303,7 @@ void viterbi_algorithm_combined<int,short>(int I, int S, int O, int S0,int SK, int D, const std::vector<int> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const int *in, short *out ); @@ -317,7 +317,7 @@ void viterbi_algorithm_combined<float,short>(int I, int S, int O, int S0,int SK, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *in, short *out ); @@ -331,7 +331,7 @@ void viterbi_algorithm_combined<gr_complex,short>(int I, int S, int O, int S0,int SK, int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const gr_complex *in, short *out ); @@ -347,7 +347,7 @@ void viterbi_algorithm_combined<short,int>(int I, int S, int O, int S0,int SK, int D, const std::vector<short> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const short *in, int *out ); @@ -361,7 +361,7 @@ void viterbi_algorithm_combined<int,int>(int I, int S, int O, int S0,int SK, int D, const std::vector<int> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const int *in, int *out ); @@ -375,7 +375,7 @@ void viterbi_algorithm_combined<float,int>(int I, int S, int O, int S0,int SK, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *in, int *out ); @@ -389,7 +389,7 @@ void viterbi_algorithm_combined<gr_complex,int>(int I, int S, int O, int S0,int SK, int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const gr_complex *in, int *out ); @@ -574,7 +574,7 @@ void siso_algorithm_combined(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<T> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const T *observations, float *post ) { @@ -726,7 +726,7 @@ void siso_algorithm_combined<short>(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<short> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const short *observations, float *post ); @@ -742,7 +742,7 @@ void siso_algorithm_combined<int>(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<int> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const int *observations, float *post ); @@ -758,7 +758,7 @@ void siso_algorithm_combined<float>(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const float *observations, float *post ); @@ -774,7 +774,7 @@ void siso_algorithm_combined<gr_complex>(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const gr_complex *observations, float *post ); @@ -787,7 +787,7 @@ void sccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const Ti *observations, To *data ) @@ -900,7 +900,7 @@ void sccc_decoder_combined<float,unsigned char>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, unsigned char *data ); @@ -912,7 +912,7 @@ void sccc_decoder_combined<float,short>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, short *data ); @@ -924,7 +924,7 @@ void sccc_decoder_combined<float,int>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, int *data ); @@ -936,7 +936,7 @@ void sccc_decoder_combined<gr_complex,unsigned char>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, unsigned char *data ); @@ -948,7 +948,7 @@ void sccc_decoder_combined<gr_complex,short>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, short *data ); @@ -960,7 +960,7 @@ void sccc_decoder_combined<gr_complex,int>( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, int *data ); @@ -1247,7 +1247,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const Ti *observations, To *data ) @@ -1366,7 +1366,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, unsigned char *data ); @@ -1379,7 +1379,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, short *data ); @@ -1392,7 +1392,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const float *observations, int *data ); @@ -1405,7 +1405,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, unsigned char *data ); @@ -1418,7 +1418,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, short *data ); @@ -1431,7 +1431,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<gr_complex> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const gr_complex *observations, int *data ); diff --git a/gr-trellis/src/lib/core_algorithms.h b/gr-trellis/src/lib/core_algorithms.h index a8765225bf..4efcc91235 100644 --- a/gr-trellis/src/lib/core_algorithms.h +++ b/gr-trellis/src/lib/core_algorithms.h @@ -26,7 +26,7 @@ #include <cmath> #include <vector> //#include <gr_complex.h> -#include "digital_metric_type.h" +#include "digital/metric_type.h" #include "fsm.h" #include "interleaver.h" @@ -55,7 +55,7 @@ void viterbi_algorithm_combined(int I, int S, int O, int S0,int SK, int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const Ti *in, To *out ); @@ -86,7 +86,7 @@ void siso_algorithm_combined(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<T> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const T *observations, float *post ); @@ -108,7 +108,7 @@ void sccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const Ti *observations, To *data ); @@ -129,7 +129,7 @@ void pccc_decoder_combined( const interleaver &INTERLEAVER, int blocklength, int iterations, float (*p2mymin)(float,float), int D, const std::vector<Ti> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling, const Ti *observations, To *data ); diff --git a/gr-trellis/src/lib/trellis.i b/gr-trellis/src/lib/trellis.i index 89be184041..d0b3707d05 100644 --- a/gr-trellis/src/lib/trellis.i +++ b/gr-trellis/src/lib/trellis.i @@ -21,21 +21,27 @@ */ %module(docstring="Generic coding/decoding.") trellis +#define DIGITAL_API + %include "gnuradio.i" // the common stuff //load generated python docstrings %include "trellis_swig_doc.i" %{ +#include "digital/constellation.h" +#include "digital/metric_type.h" #include "fsm.h" #include "interleaver.h" #include "trellis_permutation.h" #include "trellis_siso_f.h" #include "trellis_siso_combined_f.h" #include "trellis_constellation_metrics_cf.h" -#include "digital_constellation.h" %} +%include "digital/constellation.h" +%include "digital/metric_type.h" +%include "constellation.i" // ---------------------------------------------------------------- @@ -50,10 +56,3 @@ %include "trellis_constellation_metrics_cf.i" %include "trellis_generated.i" - -%import "digital_metric_type.h" -%import "digital_constellation.i" - - //%pythoncode %{ - // from gnuradio.gr import TRELLIS_EUCLIDEAN, TRELLIS_HARD_SYMBOL, TRELLIS_HARD_BIT - // %} diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc index 6e6aa2dd03..d7a7aba1d4 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.cc @@ -30,17 +30,17 @@ #include <stdexcept> #include <iostream> - - trellis_constellation_metrics_cf_sptr -trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE) +trellis_make_constellation_metrics_cf(constellation_sptr constellation, + trellis_metric_type_t TYPE) { - return gnuradio::get_initial_sptr (new trellis_constellation_metrics_cf (constellation, TYPE)); + return gnuradio::get_initial_sptr + (new trellis_constellation_metrics_cf(constellation, TYPE)); } - -trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE) +trellis_constellation_metrics_cf::trellis_constellation_metrics_cf(constellation_sptr constellation, + trellis_metric_type_t TYPE) : gr_block ("constellation_metrics_cf", gr_make_io_signature (1, -1, sizeof (gr_complex)), gr_make_io_signature (1, -1, sizeof (float))), @@ -54,7 +54,7 @@ trellis_constellation_metrics_cf::trellis_constellation_metrics_cf (digital_cons } void -trellis_constellation_metrics_cf::forecast (int noutput_items, gr_vector_int &ninput_items_required) +trellis_constellation_metrics_cf::forecast(int noutput_items, gr_vector_int &ninput_items_required) { assert (noutput_items % d_O == 0); unsigned int input_required = d_D * noutput_items / d_O; @@ -66,10 +66,10 @@ trellis_constellation_metrics_cf::forecast (int noutput_items, gr_vector_int &ni int -trellis_constellation_metrics_cf::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +trellis_constellation_metrics_cf::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { assert (noutput_items % d_O == 0); diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index 2c2070522c..91ab30986b 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -25,13 +25,17 @@ #include <trellis_api.h> #include <gr_block.h> -#include <digital_constellation.h> -#include <digital_metric_type.h> +#include <digital/constellation.h> +#include <digital/metric_type.h> + +using namespace gr::digital; class trellis_constellation_metrics_cf; typedef boost::shared_ptr<trellis_constellation_metrics_cf> trellis_constellation_metrics_cf_sptr; -TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); +TRELLIS_API trellis_constellation_metrics_cf_sptr + trellis_make_constellation_metrics_cf(constellation_sptr constellation, + trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -40,21 +44,24 @@ TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_met class TRELLIS_API trellis_constellation_metrics_cf : public gr_block { public: - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); protected: - trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); + trellis_constellation_metrics_cf(constellation_sptr constellation, + trellis_metric_type_t TYPE); private: - digital_constellation_sptr d_constellation; + constellation_sptr d_constellation; trellis_metric_type_t d_TYPE; unsigned int d_O; unsigned int d_D; - friend TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); + friend TRELLIS_API trellis_constellation_metrics_cf_sptr + trellis_make_constellation_metrics_cf(constellation_sptr constellation, + trellis_metric_type_t TYPE); }; diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i index c17522b113..13b11c0b06 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.i +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.i @@ -20,14 +20,12 @@ * Boston, MA 02110-1301, USA. */ -// WARNING: this file is machine generated. Edits will be over written - GR_SWIG_BLOCK_MAGIC(trellis,constellation_metrics_cf); -trellis_constellation_metrics_cf_sptr trellis_make_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); +trellis_constellation_metrics_cf_sptr +trellis_make_constellation_metrics_cf(gr::digital::constellation_sptr constellation, + gr::digital::trellis_metric_type_t TYPE); class trellis_constellation_metrics_cf : public gr_block { -private: - trellis_constellation_metrics_cf (digital_constellation_sptr constellation, trellis_metric_type_t TYPE); }; diff --git a/gr-trellis/src/lib/trellis_metrics_X.cc.t b/gr-trellis/src/lib/trellis_metrics_X.cc.t index 77eb8c81b5..756ac92a31 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.cc.t +++ b/gr-trellis/src/lib/trellis_metrics_X.cc.t @@ -34,34 +34,36 @@ @SPTR_NAME@ -trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) +trellis_make_@BASE_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE) { - return gnuradio::get_initial_sptr (new @NAME@ (O,D,TABLE,TYPE)); + return gnuradio::get_initial_sptr(new @NAME@(O,D,TABLE,TYPE)); } -@NAME@::@NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) - : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (float))), - d_O (O), - d_D (D), - d_TYPE (TYPE), - d_TABLE (TABLE) +@NAME@::@NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, -1, sizeof (@I_TYPE@)), + gr_make_io_signature(1, -1, sizeof (float))), + d_O (O), + d_D (D), + d_TYPE (TYPE), + d_TABLE (TABLE) { set_relative_rate (1.0 * d_O / ((double) d_D)); set_output_multiple ((int)d_O); } -void @NAME@::set_TABLE (const std::vector<@I_TYPE@> &table) +void @NAME@::set_TABLE(const std::vector<@I_TYPE@> &table) { d_TABLE = table; } void -@NAME@::forecast (int noutput_items, gr_vector_int &ninput_items_required) +@NAME@::forecast(int noutput_items, gr_vector_int &ninput_items_required) { assert (noutput_items % d_O == 0); int input_required = d_D * noutput_items / d_O; @@ -73,25 +75,24 @@ void int -@NAME@::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +@NAME@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { - assert (noutput_items % d_O == 0); assert (input_items.size() == output_items.size()); int nstreams = input_items.size(); -for (int m=0;m<nstreams;m++) { - const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; - float *out = (float *) output_items[m]; + for (int m=0;m<nstreams;m++) { + const @I_TYPE@ *in = (@I_TYPE@ *) input_items[m]; + float *out = (float *) output_items[m]; - for (int i = 0; i < noutput_items / d_O ; i++){ - calc_metric(d_O, d_D, d_TABLE,&(in[i*d_D]),&(out[i*d_O]), d_TYPE); + for(int i = 0; i < noutput_items / d_O ; i++) { + calc_metric(d_O, d_D, d_TABLE,&(in[i*d_D]),&(out[i*d_O]), d_TYPE); + } } -} - consume_each (d_D * noutput_items / d_O); + consume_each(d_D * noutput_items / d_O); return noutput_items; } diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t index ab406c51ea..9a671bc121 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.h.t +++ b/gr-trellis/src/lib/trellis_metrics_X.h.t @@ -32,7 +32,8 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; -TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); +TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE); /*! * \brief Evaluate metrics for use by the Viterbi algorithm. @@ -42,24 +43,27 @@ class TRELLIS_API @NAME@ : public gr_block { int d_O; int d_D; - trellis_metric_type_t d_TYPE; + gr::digital::trellis_metric_type_t d_TYPE; std::vector<@I_TYPE@> d_TABLE; - friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); - @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); + friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@(int O, int D, + const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE); + @NAME@(int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE); public: - int O () const { return d_O; } - int D () const { return d_D; } - trellis_metric_type_t TYPE () const { return d_TYPE; } - std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - void set_TABLE (const std::vector<@I_TYPE@> &table); - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int O() const { return d_O; } + int D() const { return d_D; } + gr::digital::trellis_metric_type_t TYPE() const { return d_TYPE; } + std::vector<@I_TYPE@> TABLE() const { return d_TABLE; } + void set_TABLE(const std::vector<@I_TYPE@> &table); + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; diff --git a/gr-trellis/src/lib/trellis_metrics_X.i.t b/gr-trellis/src/lib/trellis_metrics_X.i.t index 50aa7a7673..b53594f3a6 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.i.t +++ b/gr-trellis/src/lib/trellis_metrics_X.i.t @@ -24,17 +24,19 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); -@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); +@SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE); class @NAME@ : public gr_block { private: - @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE); + @NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, + gr::digital::trellis_metric_type_t TYPE); public: int O () const { return d_O; } int D () const { return d_D; } - trellis_metric_type_t TYPE () const { return d_TYPE; } + gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } void set_TABLE (const std::vector<@I_TYPE@> &table); std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } }; diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t index 03e21de1f5..e8f9f7296e 100644 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t +++ b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.cc.t @@ -45,7 +45,7 @@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ) { @@ -71,7 +71,7 @@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ) : gr_block ("@BASE_NAME@", diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t index 6e45ea10ac..81d9abbc1f 100644 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t @@ -45,7 +45,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, // perform "min-sum" or "sum-product" combining int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -67,7 +67,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t d_SISO_TYPE; int d_D; std::vector<@I_TYPE@> d_TABLE; - trellis_metric_type_t d_METRIC_TYPE; + gr::digital::trellis_metric_type_t d_METRIC_TYPE; float d_scaling; std::vector<float> d_buffer; @@ -80,7 +80,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -93,7 +93,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -109,7 +109,7 @@ public: int repetitions () const { return d_repetitions; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } + gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } float scaling () const { return d_scaling; } void set_scaling (float scaling); diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t index d841f67b45..8684ff650c 100644 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t +++ b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.i.t @@ -33,7 +33,7 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -50,7 +50,7 @@ private: trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -66,7 +66,7 @@ public: int repetitions () const { return d_repetitions; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } + gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } float scaling() const { return d_scaling; } void set_scaling (float scaling); diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t index 4508ca5cba..0fcfc70a68 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.cc.t @@ -45,7 +45,7 @@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ) { @@ -71,7 +71,7 @@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ) : gr_block ("@BASE_NAME@", diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t index 3fdc53c624..2cf03eaa55 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t @@ -45,7 +45,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( trellis_siso_type_t SISO_TYPE, // perform "min-sum" or "sum-product" combining int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -67,7 +67,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t d_SISO_TYPE; int d_D; std::vector<@I_TYPE@> d_TABLE; - trellis_metric_type_t d_METRIC_TYPE; + gr::digital::trellis_metric_type_t d_METRIC_TYPE; float d_scaling; std::vector<float> d_buffer; @@ -80,7 +80,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -93,7 +93,7 @@ class TRELLIS_API @NAME@ : public gr_block trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -109,7 +109,7 @@ public: int repetitions () const { return d_repetitions; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } + gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } float scaling () const { return d_scaling; } void set_scaling (float scaling); diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t index 84f2eb07d9..872afcad09 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.i.t @@ -33,7 +33,7 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -50,7 +50,7 @@ private: trellis_siso_type_t SISO_TYPE, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t METRIC_TYPE, + gr::digital::trellis_metric_type_t METRIC_TYPE, float scaling ); @@ -66,7 +66,7 @@ public: int repetitions () const { return d_repetitions; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } + gr::digital::trellis_metric_type_t METRIC_TYPE () const { return d_METRIC_TYPE; } trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } float scaling() const { return d_scaling; } void set_scaling (float scaling); diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.cc b/gr-trellis/src/lib/trellis_siso_combined_f.cc index d27fe44257..d956c47854 100644 --- a/gr-trellis/src/lib/trellis_siso_combined_f.cc +++ b/gr-trellis/src/lib/trellis_siso_combined_f.cc @@ -43,7 +43,7 @@ trellis_make_siso_combined_f ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE) + gr::digital::trellis_metric_type_t TYPE) { return gnuradio::get_initial_sptr(new trellis_siso_combined_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE,D,TABLE,TYPE)); } @@ -58,7 +58,7 @@ trellis_siso_combined_f::trellis_siso_combined_f ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE) + gr::digital::trellis_metric_type_t TYPE) : gr_block ("siso_combined_f", gr_make_io_signature (1, -1, sizeof (float)), gr_make_io_signature (1, -1, sizeof (float))), @@ -153,7 +153,7 @@ void siso_algorithm_combined(int I, int S, int O, float (*p2mymin)(float,float), int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const float *priori, const float *observations, float *post//, //std::vector<float> &alpha, //std::vector<float> &beta diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.h b/gr-trellis/src/lib/trellis_siso_combined_f.h index 4b28e8de4a..47fa20fb65 100644 --- a/gr-trellis/src/lib/trellis_siso_combined_f.h +++ b/gr-trellis/src/lib/trellis_siso_combined_f.h @@ -43,7 +43,7 @@ TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( trellis_siso_type_t d_SISO_TYPE, // perform "min-sum" or "sum-product" combining int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE + gr::digital::trellis_metric_type_t TYPE ); /*! @@ -60,7 +60,7 @@ class TRELLIS_API trellis_siso_combined_f : public gr_block trellis_siso_type_t d_SISO_TYPE; int d_D; std::vector<float> d_TABLE; - trellis_metric_type_t d_TYPE; + gr::digital::trellis_metric_type_t d_TYPE; //std::vector<float> d_alpha; //std::vector<float> d_beta; @@ -74,7 +74,7 @@ class TRELLIS_API trellis_siso_combined_f : public gr_block trellis_siso_type_t d_SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); trellis_siso_combined_f ( @@ -87,7 +87,7 @@ class TRELLIS_API trellis_siso_combined_f : public gr_block trellis_siso_type_t d_SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); public: @@ -100,7 +100,7 @@ public: trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } int D () const { return d_D; } std::vector<float> TABLE () const { return d_TABLE; } - trellis_metric_type_t TYPE () const { return d_TYPE; } + gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } void forecast (int noutput_items, gr_vector_int &ninput_items_required); int general_work (int noutput_items, diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.i b/gr-trellis/src/lib/trellis_siso_combined_f.i index 781280d896..228cdd1218 100644 --- a/gr-trellis/src/lib/trellis_siso_combined_f.i +++ b/gr-trellis/src/lib/trellis_siso_combined_f.i @@ -32,7 +32,7 @@ trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( trellis_siso_type_t SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); class trellis_siso_combined_f : public gr_block @@ -48,7 +48,7 @@ private: trellis_siso_type_t SISO_TYPE, int D, const std::vector<float> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } @@ -60,5 +60,5 @@ public: trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } int D () const { return d_D; } std::vector<float> TABLE () const { return d_TABLE; } - trellis_metric_type_t TYPE () const { return d_TYPE; } + gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } }; diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t index 74611ab8fb..b337b6f16c 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t @@ -41,7 +41,7 @@ trellis_make_@BASE_NAME@ ( int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE) + gr::digital::trellis_metric_type_t TYPE) { return gnuradio::get_initial_sptr (new @NAME@ (FSM,K,S0,SK,D,TABLE,TYPE)); } @@ -53,10 +53,10 @@ trellis_make_@BASE_NAME@ ( int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE) + gr::digital::trellis_metric_type_t TYPE) : gr_block ("@BASE_NAME@", - gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), - gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), + gr_make_io_signature (1, -1, sizeof (@I_TYPE@)), + gr_make_io_signature (1, -1, sizeof (@O_TYPE@))), d_FSM (FSM), d_K (K), d_S0 (S0), @@ -100,7 +100,7 @@ void viterbi_algorithm_combined(int I, int S, int O, int S0,int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE, + gr::digital::trellis_metric_type_t TYPE, const @I_TYPE@ *in, @O_TYPE@ *out)//, //std::vector<int> &trace) { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t index c7e468e73b..f0a64c3317 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t @@ -41,7 +41,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); /*! @@ -55,7 +55,7 @@ class TRELLIS_API @NAME@ : public gr_block int d_SK; int d_D; std::vector<@I_TYPE@> d_TABLE; - trellis_metric_type_t d_TYPE; + gr::digital::trellis_metric_type_t d_TYPE; //std::vector<int> d_trace; friend TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( @@ -65,7 +65,7 @@ class TRELLIS_API @NAME@ : public gr_block int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); @NAME@ ( @@ -75,7 +75,7 @@ class TRELLIS_API @NAME@ : public gr_block int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); public: @@ -85,7 +85,7 @@ public: int SK () const { return d_SK; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t TYPE () const { return d_TYPE; } + gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } //std::vector<int> trace () const { return d_trace; } void set_TABLE (const std::vector<@I_TYPE@> &table); void forecast (int noutput_items, diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t index 633ded7707..2687a2056d 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.i.t @@ -31,7 +31,7 @@ GR_SWIG_BLOCK_MAGIC(trellis,@BASE_NAME@); int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); class @NAME@ : public gr_block @@ -44,7 +44,7 @@ private: int SK, int D, const std::vector<@I_TYPE@> &TABLE, - trellis_metric_type_t TYPE); + gr::digital::trellis_metric_type_t TYPE); public: fsm FSM () const { return d_FSM; } @@ -53,7 +53,7 @@ public: int SK () const { return d_SK; } int D () const { return d_D; } std::vector<@I_TYPE@> TABLE () const { return d_TABLE; } - trellis_metric_type_t TYPE () const { return d_TYPE; } + gr::digital::trellis_metric_type_t TYPE () const { return d_TYPE; } //std::vector<short> trace () const { return d_trace; } void set_TABLE (const std::vector<@I_TYPE@> &table); }; diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/src/python/qa_trellis.py index 935459a3c7..c6ba40d11f 100755 --- a/gr-trellis/src/python/qa_trellis.py +++ b/gr-trellis/src/python/qa_trellis.py @@ -29,7 +29,7 @@ from gnuradio import gr, gr_unittest, blks2 import trellis import os -import digital_swig +import digital_swig as digital fsm_args = {"awgn1o2_4": (2, 4, 4, (0, 2, 0, 2, 1, 3, 1, 3), @@ -39,8 +39,8 @@ fsm_args = {"awgn1o2_4": (2, 4, 4, "nothing": (2, 1, 2, (0, 0), (0, 1)), } -constells = {2: digital_swig.constellation_bpsk(), - 4: digital_swig.constellation_qpsk(), +constells = {2: digital.constellation_bpsk(), + 4: digital.constellation_qpsk(), } class test_trellis (gr_unittest.TestCase): @@ -114,7 +114,7 @@ class trellis_tb(gr.top_block): s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol, gr.GR_MSB_FIRST) # initial FSM state = 0 enc = trellis.encoder_ss(f, 0) - mod = digital_swig.chunks_to_symbols_sc(constellation.points(), 1) + mod = digital.chunks_to_symbols_sc(constellation.points(), 1) # CHANNEL add = gr.add_cc() @@ -122,7 +122,7 @@ class trellis_tb(gr.top_block): # RX # data preprocessing to generate metrics for Viterbi - metrics = trellis.constellation_metrics_cf(constellation.base(), digital_swig.TRELLIS_EUCLIDEAN) + metrics = trellis.constellation_metrics_cf(constellation.base(), digital.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. va = trellis.viterbi_s(f, K, 0, -1) # pack FSM input symbols to shorts diff --git a/gr-vocoder/CMakeLists.txt b/gr-vocoder/CMakeLists.txt index 235054db62..6f9962d5a0 100644 --- a/gr-vocoder/CMakeLists.txt +++ b/gr-vocoder/CMakeLists.txt @@ -29,6 +29,8 @@ include(GrComponent) GR_REGISTER_COMPONENT("gr-vocoder" ENABLE_GR_VOCODER Boost_FOUND ENABLE_GR_CORE + ENABLE_GR_FFT + ENABLE_GR_FILTER ) GR_SET_GLOBAL(GR_VOCODER_INCLUDE_DIRS diff --git a/gr-vocoder/python/CMakeLists.txt b/gr-vocoder/python/CMakeLists.txt index ee3765d5e7..32f69f2b69 100644 --- a/gr-vocoder/python/CMakeLists.txt +++ b/gr-vocoder/python/CMakeLists.txt @@ -43,6 +43,8 @@ foreach(py_qa_test_file ${py_qa_test_files}) ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig ${CMAKE_BINARY_DIR}/gr-vocoder/python ${CMAKE_BINARY_DIR}/gr-vocoder/swig + ${CMAKE_BINARY_DIR}/gr-filter/python + ${CMAKE_BINARY_DIR}/gr-filter/swig ) set(GR_TEST_TARGET_DEPS volk gruel gnuradio-core gnuradio-vocoder) GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) diff --git a/gr-vocoder/python/cvsd.py b/gr-vocoder/python/cvsd.py index e9b3ee3054..0b38615f41 100644 --- a/gr-vocoder/python/cvsd.py +++ b/gr-vocoder/python/cvsd.py @@ -23,6 +23,11 @@ from gnuradio import gr import vocoder_swig +try: + from gnuradio import filter +except ImportError: + import filter_swig as filter + class cvsd_encode_fb(gr.hier_block2): ''' This is a wrapper for the CVSD encoder that performs interpolation and filtering @@ -47,8 +52,8 @@ class cvsd_encode_fb(gr.hier_block2): self.interp = resample src_scale = gr.multiply_const_ff(scale_factor) - taps = gr.firdes.low_pass(self.interp, self.interp, bw, 2*bw) - interp = gr.interp_fir_filter_fff(self.interp, taps) + taps = filter.firdes.low_pass(self.interp, self.interp, bw, 2*bw) + interp = filter.interp_fir_filter_fff(self.interp, taps) f2s = gr.float_to_short() enc = vocoder_swig.cvsd_encode_sb() @@ -79,8 +84,8 @@ class cvsd_decode_bf(gr.hier_block2): dec = vocoder_swig.cvsd_decode_bs() s2f = gr.short_to_float() - taps = gr.firdes.low_pass(1, 1, bw, 2*bw) - decim = gr.fir_filter_fff(self.decim, taps) + taps = filter.firdes.low_pass(1, 1, bw, 2*bw) + decim = filter.fir_filter_fff(self.decim, taps) sink_scale = gr.multiply_const_ff(1.0/scale_factor) self.connect(self, dec, s2f, decim, sink_scale, self) diff --git a/gr-wxgui/CMakeLists.txt b/gr-wxgui/CMakeLists.txt index 8150c7d802..ab00489065 100644 --- a/gr-wxgui/CMakeLists.txt +++ b/gr-wxgui/CMakeLists.txt @@ -38,6 +38,8 @@ endif(NOT CMAKE_CROSSCOMPILING) GR_REGISTER_COMPONENT("gr-wxgui" ENABLE_GR_WXGUI ENABLE_GR_CORE + ENABLE_GR_FFT + ENABLE_GR_FILTER ENABLE_PYTHON ${wxgui_python_deps} ) diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index dc31e84a10..72659b8fa4 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -26,7 +26,7 @@ from __future__ import division ################################################## import fft_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, fft from pubsub import pubsub from constants import * import math @@ -132,12 +132,12 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class fft_sink_f(_fft_sink_base): - _fft_chain = blks2.logpwrfft_f + _fft_chain = fft.logpwrfft_f _item_size = gr.sizeof_float _real = True class fft_sink_c(_fft_sink_base): - _fft_chain = blks2.logpwrfft_c + _fft_chain = fft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py index c756d8a3b2..1f91a976aa 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/src/python/fftsink_nongl.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window +from gnuradio import gr, gru, window, fft, filter from gnuradio.wxgui import stdgui2 import wx import plot @@ -122,13 +122,13 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vfc(self.fft_size, True, mywindow) + self.fft = fft.fft_vfc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin self.log = gr.nlog10_ff(20, self.fft_size, @@ -167,13 +167,13 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vcc(self.fft_size, True, mywindow) + self.fft = fft.fft_vcc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin self.log = gr.nlog10_ff(20, self.fft_size, diff --git a/gr-wxgui/src/python/numbersink2.py b/gr-wxgui/src/python/numbersink2.py index 011acdfd5e..85e8927e36 100644 --- a/gr-wxgui/src/python/numbersink2.py +++ b/gr-wxgui/src/python/numbersink2.py @@ -24,7 +24,7 @@ ################################################## import number_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, blks2, filter from pubsub import pubsub from constants import * @@ -74,11 +74,11 @@ class _number_sink_base(gr.hier_block2, common.wxgui_hb): if self._real: mult = gr.multiply_const_ff(factor) add = gr.add_const_ff(ref_level) - avg = gr.single_pole_iir_filter_ff(1.0) + avg = filter.single_pole_iir_filter_ff(1.0) else: mult = gr.multiply_const_cc(factor) add = gr.add_const_cc(ref_level) - avg = gr.single_pole_iir_filter_cc(1.0) + avg = filter.single_pole_iir_filter_cc(1.0) msgq = gr.msg_queue(2) sink = gr.message_sink(self._item_size, msgq, True) #controller diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py index e6ff532e76..ab07550397 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -24,7 +24,7 @@ ################################################## import scope_window import common -from gnuradio import gr +from gnuradio import gr, filter from pubsub import pubsub from constants import * import math @@ -43,7 +43,7 @@ class ac_couple_block(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_float), ) #blocks - lpf = gr.single_pole_iir_filter_ff(0.0) + lpf = filter.single_pole_iir_filter_ff(0.0) sub = gr.sub_ff() mute = gr.mute_ff() #connect diff --git a/gr-wxgui/src/python/waterfallsink_gl.py b/gr-wxgui/src/python/waterfallsink_gl.py index b69c5dda0c..b17f292875 100644 --- a/gr-wxgui/src/python/waterfallsink_gl.py +++ b/gr-wxgui/src/python/waterfallsink_gl.py @@ -24,7 +24,7 @@ ################################################## import waterfall_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, fft from pubsub import pubsub from constants import * @@ -117,12 +117,12 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class waterfall_sink_f(_waterfall_sink_base): - _fft_chain = blks2.logpwrfft_f + _fft_chain = fft.logpwrfft_f _item_size = gr.sizeof_float _real = True class waterfall_sink_c(_waterfall_sink_base): - _fft_chain = blks2.logpwrfft_c + _fft_chain = fft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False diff --git a/gr-wxgui/src/python/waterfallsink_nongl.py b/gr-wxgui/src/python/waterfallsink_nongl.py index 213415c82c..be164bbccd 100644 --- a/gr-wxgui/src/python/waterfallsink_nongl.py +++ b/gr-wxgui/src/python/waterfallsink_nongl.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window +from gnuradio import gr, gru, window, fft, filter from gnuradio.wxgui import stdgui2 import wx import gnuradio.wxgui.plot as plot @@ -91,9 +91,9 @@ class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vfc(self.fft_size, True, mywindow) + self.fft = fft.fft_vfc(self.fft_size, True, mywindow) self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) @@ -122,9 +122,9 @@ class waterfall_sink_c(gr.hier_block2, waterfall_sink_base): max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vcc(self.fft_size, True, mywindow) + self.fft = fft.fft_vcc(self.fft_size, True, mywindow) self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) diff --git a/grc/blocks/blks2_analysis_filterbank.xml b/grc/blocks/blks2_analysis_filterbank.xml deleted file mode 100644 index 93cfa30afd..0000000000 --- a/grc/blocks/blks2_analysis_filterbank.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Analysis Filterbank -################################################### - --> -<block> - <name>Analysis Filterbank</name> - <key>blks2_analysis_filterbank</key> - <import>from gnuradio import blks2</import> - <make>blks2.analysis_filterbank(mpoints=$mpoints, taps=$taps)</make> - <param> - <name>MPoints</name> - <key>mpoints</key> - <value>3</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>complex_vector</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - <nports>$mpoints</nports> - </source> -</block> diff --git a/grc/blocks/blks2_pfb_arb_resampler.xml b/grc/blocks/blks2_pfb_arb_resampler.xml deleted file mode 100644 index b58e70f1cb..0000000000 --- a/grc/blocks/blks2_pfb_arb_resampler.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Polyphase Arbitrary Resampler -################################################### - --> -<block> - <name>Polyphase Resampler</name> - <key>blks2_pfb_arb_resampler_ccf</key> - <import>from gnuradio import blks2</import> - <import>from gnuradio.gr import firdes</import> - <make>blks2.pfb_arb_resampler_ccf( - $rate, - $taps, - $size, -)</make> - <!-- Set taps not implemented yet - <callback>set_taps($taps)</callback> - --> - <callback>set_rate($rate)</callback> - <param> - <name>Resample Rate</name> - <key>rate</key> - <type>real</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>real_vector</type> - </param> - <param> - <name>Size (# phases)</name> - <key>size</key> - <value>32</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/blks2_pfb_channelizer.xml b/grc/blocks/blks2_pfb_channelizer.xml deleted file mode 100644 index 5a93c08664..0000000000 --- a/grc/blocks/blks2_pfb_channelizer.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Polyphase Channelizer -################################################### - --> -<block> - <name>Polyphase Channelizer</name> - <key>blks2_pfb_channelizer_ccf</key> - <import>from gnuradio import blks2</import> - <import>from gnuradio.gr import firdes</import> - <make>blks2.pfb_channelizer_ccf( - $nchans, - $taps, - $osr, - $atten) -self.$(id).set_channel_map($ch_map) - </make> - <!-- Set taps not implemented yet - <callback>set_taps($taps)</callback> - --> - <callback>set_channel_map($ch_map)</callback> - - <param> - <name>Channels</name> - <key>nchans</key> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <value>None</value> - <type>real_vector</type> - </param> - <param> - <name>Over Sample Ratio</name> - <key>osr</key> - <value>1.0</value> - <type>real</type> - </param> - <param> - <name>Attenuation</name> - <key>atten</key> - <value>100</value> - <type>real</type> - </param> - <param> - <name>Channel Map</name> - <key>ch_map</key> - <value>[]</value> - <type>int_vector</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - <nports>$nchans</nports> - </source> -</block> diff --git a/grc/blocks/blks2_synthesis_filterbank.xml b/grc/blocks/blks2_synthesis_filterbank.xml deleted file mode 100644 index 5979ed3f79..0000000000 --- a/grc/blocks/blks2_synthesis_filterbank.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Synthesis Filterbank -################################################### - --> -<block> - <name>Synthesis Filterbank</name> - <key>blks2_synthesis_filterbank</key> - <import>from gnuradio import blks2</import> - <make>blks2.synthesis_filterbank(mpoints=$mpoints, taps=$taps)</make> - <param> - <name>MPoints</name> - <key>mpoints</key> - <value>3</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>complex_vector</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - <nports>$mpoints</nports> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index a23518a3c4..30dfdb05d5 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -60,8 +60,6 @@ <block>gr_conjugate_cc</block> - <block>gr_fft_vxx</block> - <block>blks2_logpwrfft_x</block> <block>gr_vector_insert_x</block> </cat> <cat> @@ -120,7 +118,6 @@ </cat> <cat> <name>Synchronizers</name> - <block>gr_pfb_clock_sync_xxx</block> <block>gr_mpsk_sync_cc</block> @@ -153,39 +150,11 @@ </cat> <cat> <name>Filters</name> - <!-- FIR convenience filters --> - <block>low_pass_filter</block> - <block>high_pass_filter</block> - <block>band_pass_filter</block> - <block>band_reject_filter</block> - <block>root_raised_cosine_filter</block> - <!-- Filters that take taps as arguments --> - <block>gr_fir_filter_xxx</block> - <block>gr_interp_fir_filter_xxx</block> - <block>gr_fft_filter_xxx</block> - <block>gr_freq_xlating_fir_filter_xxx</block> - <block>gr_iir_filter_ffd</block> - <block>gr_filter_delay_fc</block> - <block>gr_channel_model</block> - <!-- Filter banks --> - <block>blks2_synthesis_filterbank</block> - <block>blks2_analysis_filterbank</block> - <!-- Polyphase filters --> - <block>blks2_pfb_arb_resampler_ccf</block> - <block>blks2_pfb_channelizer_ccf</block> - <block>gr_pfb_synthesizer_ccf</block> <!-- Other filters --> - <block>gr_single_pole_iir_filter_xx</block> - <block>gr_hilbert_fc</block> - <block>gr_goertzel_fc</block> - <block>gr_rational_resampler_base_xxx</block> <block>blks2_rational_resampler_xxx</block> - <block>gr_fractional_interpolator_xx</block> <block>gr_keep_one_in_n</block> <block>gr_keep_m_in_n</block> <block>gr_moving_average_xx</block> - <block>gr_iqcomp_cc</block> - <block>gr_dc_blocker</block> </cat> <cat> <name>Modulators</name> diff --git a/grc/blocks/gr_channel_model.xml b/grc/blocks/gr_channel_model.xml deleted file mode 100644 index d0d178d345..0000000000 --- a/grc/blocks/gr_channel_model.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Channel Model -################################################### - --> -<block> - <name>Channel Model</name> - <key>gr_channel_model</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.channel_model( - noise_voltage=$noise_voltage, - frequency_offset=$freq_offset, - epsilon=$epsilon, - taps=$taps, - noise_seed=$seed, -)</make> - <callback>set_noise_voltage($noise_voltage)</callback> - <callback>set_frequency_offset($freq_offset)</callback> - <callback>set_taps($taps)</callback> - <callback>set_timing_offset($epsilon)</callback> - <param> - <name>Noise Voltage</name> - <key>noise_voltage</key> - <value>0.0</value> - <type>real</type> - </param> - <param> - <name>Frequency Offset</name> - <key>freq_offset</key> - <value>0.0</value> - <type>real</type> - </param> - <param> - <name>Epsilon</name> - <key>epsilon</key> - <value>1.0</value> - <type>real</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <value>1.0 + 1.0j</value> - <type>complex_vector</type> - </param> - <param> - <name>Seed</name> - <key>seed</key> - <value>0</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_dc_blocker.xml b/grc/blocks/gr_dc_blocker.xml deleted file mode 100644 index 05c3420747..0000000000 --- a/grc/blocks/gr_dc_blocker.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## DC Blocker -################################################### - --> -<block> - <name>DC Blocker</name> - <key>gr_dc_blocker</key> - <import>from gnuradio import gr</import> - <make>gr.dc_blocker_$(type)($length, $long_form)</make> - <!-- <callback>set_length($length)</callback> --> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex</name> - <key>cc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - </option> - <option> - <name>Float->Float</name> - <key>ff</key> - <opt>input:float</opt> - <opt>output:float</opt> - </option> - </param> - <param> - <name>Length</name> - <key>length</key> - <value>32</value> - <type>int</type> - </param> - <param> - <name>Long Form</name> - <key>long_form</key> - <value>True</value> - <type>bool</type> - </param> - - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_fft_filter_xxx.xml b/grc/blocks/gr_fft_filter_xxx.xml deleted file mode 100644 index 5b4cd83cca..0000000000 --- a/grc/blocks/gr_fft_filter_xxx.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##FFT Filter -################################################### - --> -<block> - <name>FFT Filter</name> - <key>gr_fft_filter_xxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.fft_filter_$(type)($decim, $taps, $nthreads)</make> - <callback>set_taps($taps)</callback> - <callback>set_nthreads($nthreads)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>$type.taps</type> - </param> - <param> - <name>Num. Threads</name> - <key>nthreads</key> - <value>1</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_fft_vxx.xml b/grc/blocks/gr_fft_vxx.xml deleted file mode 100644 index 565354e415..0000000000 --- a/grc/blocks/gr_fft_vxx.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##FFT -################################################### - --> -<block> - <name>FFT</name> - <key>gr_fft_vxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio import window</import> - <make>#if $type() == "complex" -gr.fft_vcc($fft_size, $forward, $window, $shift, $nthreads) -#else -gr.fft_vfc($fft_size, $forward, $window, $nthreads) -#end if</make> - <callback>set_nthreads($nthreads)</callback> - <param> - <name>Input Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>hide_shift:</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>hide_shift:all</opt> - </option> - </param> - <param> - <name>FFT Size</name> - <key>fft_size</key> - <value>1024</value> - <type>int</type> - </param> - <param> - <name>Forward/Reverse</name> - <key>forward</key> - <type>enum</type> - <option> - <name>Forward</name> - <key>True</key> - </option> - <option> - <name>Reverse</name> - <key>False</key> - </option> - </param> - <param> - <name>Window</name> - <key>window</key> - <value>window.blackmanharris(1024)</value> - <type>real_vector</type> - </param> - <param> - <name>Shift</name> - <key>shift</key> - <type>enum</type> - <hide>$type.hide_shift</hide> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <param> - <name>Num. Threads</name> - <key>nthreads</key> - <value>1</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$fft_size</vlen> - </sink> - <source> - <name>out</name> - <type>complex</type> - <vlen>$fft_size</vlen> - </source> -</block> diff --git a/grc/blocks/gr_filter_delay_fc.xml b/grc/blocks/gr_filter_delay_fc.xml deleted file mode 100644 index 30d65bf825..0000000000 --- a/grc/blocks/gr_filter_delay_fc.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Filter Delay -################################################### - --> -<block> - <name>Filter Delay</name> - <key>gr_filter_delay_fc</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.filter_delay_fc($taps)</make> - <param> - <name>Taps</name> - <key>taps</key> - <type>real_vector</type> - </param> - <sink> - <name>in</name> - <type>float</type> - </sink> - <sink> - <name>in</name> - <type>float</type> - <optional>1</optional> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_fir_filter_xxx.xml b/grc/blocks/gr_fir_filter_xxx.xml deleted file mode 100644 index c4de8f539d..0000000000 --- a/grc/blocks/gr_fir_filter_xxx.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Decimating FIR Filter -################################################### - --> -<block> - <name>Decimating FIR Filter</name> - <key>gr_fir_filter_xxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.fir_filter_$(type)($decim, $taps)</make> - <callback>set_taps($taps)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Complex (Complex Taps)</name> - <key>fcc</key> - <opt>input:float</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Short (Real Taps)</name> - <key>fsf</key> - <opt>input:float</opt> - <opt>output:short</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Short->Complex (Complex Taps)</name> - <key>scc</key> - <opt>input:short</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>$type.taps</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_fractional_interpolator_xx.xml b/grc/blocks/gr_fractional_interpolator_xx.xml deleted file mode 100644 index 8d65ff8bfc..0000000000 --- a/grc/blocks/gr_fractional_interpolator_xx.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Fractional Interpolator -################################################### - --> -<block> - <name>Fractional Interpolator</name> - <key>gr_fractional_interpolator_xx</key> - <import>from gnuradio import gr</import> - <make>gr.fractional_interpolator_$(type.fcn)($phase_shift, $interp_ratio)</make> - <callback>set_interp_ratio($interp_ratio)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - </param> - <param> - <name>Phase Shift</name> - <key>phase_shift</key> - <type>real</type> - </param> - <param> - <name>Interpolation Ratio</name> - <key>interp_ratio</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml b/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml deleted file mode 100644 index e3ee66977d..0000000000 --- a/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml +++ /dev/null @@ -1,93 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Frequency Xlating Filter -################################################### - --> -<block> - <name>Frequency Xlating FIR Filter</name> - <key>gr_freq_xlating_fir_filter_xxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.freq_xlating_fir_filter_$(type)($decim, $taps, $center_freq, $samp_rate)</make> - <callback>set_taps($taps)</callback> - <callback>set_center_freq($center_freq)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Complex (Complex Taps)</name> - <key>fcc</key> - <opt>input:float</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Float->Complex (Real Taps)</name> - <key>fcf</key> - <opt>input:float</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Short->Complex (Complex Taps)</name> - <key>scc</key> - <opt>input:short</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Short->Complex (Real Taps)</name> - <key>scf</key> - <opt>input:short</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>$type.taps</type> - </param> - <param> - <name>Center Frequency</name> - <key>center_freq</key> - <value>0</value> - <type>real</type> - </param> - <param> - <name>Sample Rate</name> - <key>samp_rate</key> - <value>samp_rate</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_goertzel_fc.xml b/grc/blocks/gr_goertzel_fc.xml deleted file mode 100644 index f27d9582ea..0000000000 --- a/grc/blocks/gr_goertzel_fc.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Goertzel -################################################### - --> -<block> - <name>Goertzel</name> - <key>gr_goertzel_fc</key> - <import>from gnuradio import gr</import> - <make>gr.goertzel_fc($rate, $len, $freq)</make> - <callback>set_freq($freq)</callback> - <callback>set_rate($rate)</callback> - <param> - <name>Rate</name> - <key>rate</key> - <type>int</type> - </param> - <param> - <name>Length</name> - <key>len</key> - <type>int</type> - </param> - <param> - <name>Frequency</name> - <key>freq</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_hilbert_fc.xml b/grc/blocks/gr_hilbert_fc.xml deleted file mode 100644 index 165e8da237..0000000000 --- a/grc/blocks/gr_hilbert_fc.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Hilbert -################################################### - --> -<block> - <name>Hilbert</name> - <key>gr_hilbert_fc</key> - <import>from gnuradio import gr</import> - <make>gr.hilbert_fc($num_taps)</make> - <param> - <name>Num Taps</name> - <key>num_taps</key> - <value>64</value> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_iir_filter_ffd.xml b/grc/blocks/gr_iir_filter_ffd.xml deleted file mode 100644 index 9799150e80..0000000000 --- a/grc/blocks/gr_iir_filter_ffd.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##IIR Filter -################################################### - --> -<block> - <name>IIR Filter</name> - <key>gr_iir_filter_ffd</key> - <import>from gnuradio import gr</import> - <make>gr.iir_filter_ffd($fftaps, $fbtaps)</make> - <callback>set_taps($fftaps, $fbtaps)</callback> - <param> - <name>Feed-forward Taps</name> - <key>fftaps</key> - <type>real_vector</type> - </param> - <param> - <name>Feedback Taps</name> - <key>fbtaps</key> - <type>real_vector</type> - </param> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> -</block> diff --git a/grc/blocks/gr_interp_fir_filter_xxx.xml b/grc/blocks/gr_interp_fir_filter_xxx.xml deleted file mode 100644 index 55375ae021..0000000000 --- a/grc/blocks/gr_interp_fir_filter_xxx.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Interpolating FIR Filter -################################################### - --> -<block> - <name>Interpolating FIR Filter</name> - <key>gr_interp_fir_filter_xxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.interp_fir_filter_$(type)($interp, $taps)</make> - <callback>set_taps($taps)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Complex (Complex Taps)</name> - <key>fcc</key> - <opt>input:float</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Short (Real Taps)</name> - <key>fsf</key> - <opt>input:float</opt> - <opt>output:short</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Short->Complex (Complex Taps)</name> - <key>scc</key> - <opt>input:short</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - </param> - <param> - <name>Interpolation</name> - <key>interp</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>$type.taps</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_iqcomp_cc.xml b/grc/blocks/gr_iqcomp_cc.xml deleted file mode 100644 index 1603bdc42b..0000000000 --- a/grc/blocks/gr_iqcomp_cc.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##IQ Comp -################################################### - --> -<block> - <name>IQ Comp</name> - <key>gr_iqcomp_cc</key> - <import>from gnuradio import gr</import> - <make>gr.iqcomp_cc($mu)</make> - <param> - <name>Mu</name> - <key>mu</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_pfb_clock_sync.xml b/grc/blocks/gr_pfb_clock_sync.xml deleted file mode 100644 index 3e5e65d127..0000000000 --- a/grc/blocks/gr_pfb_clock_sync.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -## Polyphase Filter based Clock Sync -################################################### - --> -<block> - <name>Polyphase Clock Sync</name> - <key>gr_pfb_clock_sync_xxx</key> - <import>from gnuradio import gr</import> - <make>gr.pfb_clock_sync_$(type)($sps, $alpha, $taps, $filter_size, $init_phase, $max_dev, $osps) -self.$(id).set_beta($beta)</make> - <callback>set_taps($taps)</callback> - <callback>set_alpha($alpha)</callback> - <callback>set_beta($beta)</callback> - - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - </param> - - <param> - <name>Samples/Symbol</name> - <key>sps</key> - <type>real</type> - </param> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <param> - <name>Beta</name> - <key>beta</key> - <type>real</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>real_vector</type> - </param> - <param> - <name>Filter Size</name> - <key>filter_size</key> - <type>int</type> - </param> - <param> - <name>Initial Phase</name> - <key>init_phase</key> - <type>real</type> - </param> - <param> - <name>Maximum Rate Deviation</name> - <key>max_dev</key> - <type>real</type> - </param> - <param> - <name>Output SPS</name> - <key>osps</key> - <type>int</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> - <source> - <name>err</name> - <type>float</type> - <optional>1</optional> - </source> - <source> - <name>rate</name> - <type>float</type> - <optional>1</optional> - </source> - <source> - <name>phase</name> - <type>float</type> - <optional>1</optional> - </source> -</block> diff --git a/grc/blocks/gr_pfb_synthesizer.xml b/grc/blocks/gr_pfb_synthesizer.xml deleted file mode 100644 index 49e5cb0321..0000000000 --- a/grc/blocks/gr_pfb_synthesizer.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Polyphase Synthesis Filterbank -################################################### - --> -<block> - <name>Polyphase Synthesizer</name> - <key>gr_pfb_synthesizer_ccf</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.pfb_synthesizer_ccf( - $numchans, $taps, $twox) -self.$(id).set_channel_map($ch_map) - </make> - <callback>set_taps($taps)</callback> - <callback>set_channel_map($ch_map)</callback> - - <param> - <name>Channels</name> - <key>numchans</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Connections</name> - <key>connections</key> - <value>2</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>real_vector</type> - </param> - <param> - <name>2x Sample Rate</name> - <key>twox</key> - <value>False</value> - <type>bool</type> - </param> - <param> - <name>Channel Map</name> - <key>ch_map</key> - <value>[]</value> - <type>int_vector</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - <nports>$connections</nports> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_rational_resampler_base_xxx.xml b/grc/blocks/gr_rational_resampler_base_xxx.xml deleted file mode 100644 index 4b7720173c..0000000000 --- a/grc/blocks/gr_rational_resampler_base_xxx.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Rational Resampler Base -################################################### - --> -<block> - <name>Rational Resampler Base</name> - <key>gr_rational_resampler_base_xxx</key> - <import>from gnuradio import gr</import> - <import>from gnuradio.gr import firdes</import> - <make>gr.rational_resampler_base_$(type)($interp, $decim, $taps)</make> - <callback>set_taps($taps)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex->Complex (Complex Taps)</name> - <key>ccc</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Complex->Complex (Real Taps)</name> - <key>ccf</key> - <opt>input:complex</opt> - <opt>output:complex</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Complex (Complex Taps)</name> - <key>fcc</key> - <opt>input:float</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - <option> - <name>Float->Float (Real Taps)</name> - <key>fff</key> - <opt>input:float</opt> - <opt>output:float</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Float->Short (Real Taps)</name> - <key>fsf</key> - <opt>input:float</opt> - <opt>output:short</opt> - <opt>taps:real_vector</opt> - </option> - <option> - <name>Short->Complex (Complex Taps)</name> - <key>scc</key> - <opt>input:short</opt> - <opt>output:complex</opt> - <opt>taps:complex_vector</opt> - </option> - </param> - <param> - <name>Interpolation</name> - <key>interp</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Decimation</name> - <key>decim</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Taps</name> - <key>taps</key> - <type>$type.taps</type> - </param> - <sink> - <name>in</name> - <type>$type.input</type> - </sink> - <source> - <name>out</name> - <type>$type.output</type> - </source> -</block> diff --git a/grc/blocks/gr_single_pole_iir_filter_xx.xml b/grc/blocks/gr_single_pole_iir_filter_xx.xml deleted file mode 100644 index 50cf4a82d8..0000000000 --- a/grc/blocks/gr_single_pole_iir_filter_xx.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Single Pole IIR Filter -################################################### - --> -<block> - <name>Single Pole IIR Filter</name> - <key>gr_single_pole_iir_filter_xx</key> - <import>from gnuradio import gr</import> - <make>gr.single_pole_iir_filter_$(type.fcn)($alpha, $vlen)</make> - <callback>set_taps($alpha)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - </param> - <param> - <name>Alpha</name> - <key>alpha</key> - <value>1.0</value> - <type>real</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - </source> -</block> diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 59d78b4465..58bf026b43 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -55,6 +55,17 @@ if(NOT DEFINED COMPILER_NAME) endif() ######################################################################## +# Special clang flag so flag checks can fail +######################################################################## +if(COMPILER_NAME MATCHES "GNU") + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-Werror=unused-command-line-argument" HAVE_WERROR_UNUSED_CMD_LINE_ARG) + if(HAVE_WERROR_UNUSED_CMD_LINE_ARG) + set(VOLK_FLAG_CHECK_FLAGS "-Werror=unused-command-line-argument") + endif() +endif() + +######################################################################## # detect x86 flavor of CPU ######################################################################## if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64)$") @@ -82,7 +93,9 @@ macro(check_arch arch_name) COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub('\\W', '_', '${have_flag}'))" OUTPUT_VARIABLE have_flag OUTPUT_STRIP_TRAILING_WHITESPACE ) + set(CMAKE_REQUIRED_FLAGS VOLK_FLAG_CHECK_FLAGS) CHECK_CXX_COMPILER_FLAG(${flag} ${have_flag}) + unset(CMAKE_REQUIRED_FLAGS) if (NOT ${have_flag}) set(have_${arch_name} FALSE) endif() |