GNU Radio v3.6.2-149-ga6d285d9 C++ API
digital_glfsr_source_b.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007,2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_GR_GLFSR_SOURCE_B_H
00024 #define INCLUDED_GR_GLFSR_SOURCE_B_H
00025 
00026 #include <digital_api.h>
00027 #include <gr_sync_block.h>
00028 
00029 class gri_glfsr;
00030 
00031 class digital_glfsr_source_b;
00032 typedef boost::shared_ptr<digital_glfsr_source_b> digital_glfsr_source_b_sptr;
00033 
00034 DIGITAL_API digital_glfsr_source_b_sptr
00035 digital_make_glfsr_source_b(int degree, bool repeat=true,
00036                             int mask=0, int seed=1);
00037 
00038 /*!
00039  * \brief Galois LFSR pseudo-random source
00040  * \ingroup source_blk
00041  *
00042  * \param degree Degree of shift register must be in [1, 32]. If mask
00043  *               is 0, the degree determines a default mask (see
00044  *               digital_impl_glfsr.cc for the mapping).
00045  * \param repeat Set to repeat sequence.
00046  * \param mask   Allows a user-defined bit mask for indexes of the shift
00047  *               register to feed back.
00048  * \param seed   Initial setting for values in shift register.
00049  */
00050 class DIGITAL_API digital_glfsr_source_b : public gr_sync_block
00051 {
00052  private:
00053   friend DIGITAL_API digital_glfsr_source_b_sptr
00054     digital_make_glfsr_source_b(int degree, bool repeat,
00055                                 int mask, int seed);
00056 
00057   gri_glfsr *d_glfsr;
00058 
00059   bool d_repeat;
00060   unsigned int d_index;
00061   unsigned int d_length;
00062 
00063   digital_glfsr_source_b(int degree, bool repeat,
00064                          int mask, int seed);
00065 
00066  public:
00067 
00068   ~digital_glfsr_source_b();
00069 
00070   int work(int noutput_items,
00071            gr_vector_const_void_star &input_items,
00072            gr_vector_void_star &output_items);
00073 
00074   unsigned int period() const { return d_length; }
00075   int mask() const;
00076 };
00077 
00078 #endif /* INCLUDED_GR_GLFSR_SOURCE_B_H */