Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

fbool_nco.h

Go to the documentation of this file.
00001 /*
00002  * SPUC - Signal processing using C++ - A DSP library
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2, or (at your option)
00007  * any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 #ifndef FNCO
00019 #define FNCO
00020 #include <mync.h>
00021 #include <uint.h>
00022 namespace SPUC {
00026 template <int M, int L> class fbool_nco
00027 {
00028  public:
00029   bool phase;
00030 //  char v[20];
00031 
00032   protected:
00033   uint<M> acc;
00034   uint<M> fcw;
00035   uint<M> new_fcw;
00036 
00037 public:
00038         fbool_nco() { acc = fcw = new_fcw = 0};
00039         inline void set_frequency(uint<M> freq) { fcw = freq; }
00040         inline void reset_frequency(uint<M> freq) { new_fcw = fcw = freq; }
00041         inline bool get_phase(void) { return(phase);}
00042         inline void load(uint<L> loop_filter_out) {new_fcw = fcw + loop_filter_out;}
00043         bool clock() {
00044                 acc = acc + new_fcw;
00045                 phase = acc.overflow;
00046                 return(phase);
00047         }
00048         bool clock(uint<L> loop_filter_out) {
00049         new_fcw = fcw + loop_filter_out;
00050         return(clock());
00051         }
00052 
00053 };
00054 } // namespace SPUC 
00055 #endif

Generated on Fri Sep 16 11:02:30 2005 for spuc by  doxygen 1.4.4