00001 #ifndef NCO 00002 #define NCO 00003 #include <spuc.h> 00004 // 00005 // Copyright(c) 1993-1996 Tony Kirke 00006 // author="Tony Kirke" * 00007 /* 00008 * SPUC - Signal processing using C++ - A DSP library 00009 * Copyright (C) 1993-2001 Tony Kirke. 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2, or (at your option) 00014 * any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 namespace SPUC { 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 class nco 00042 { 00043 public: 00044 unsigned long phase; 00045 // char v[20]; 00046 00047 protected: 00048 unsigned long acc; 00049 unsigned long fcw; 00050 unsigned long new_fcw; 00051 unsigned long mask_bits; 00052 00053 public: 00055 nco(long bits=8); 00057 inline void reset() { phase = new_fcw = fcw = acc = 0; } 00059 inline void set_frequency(unsigned long freq) { fcw = freq; } 00061 inline void reset_frequency(unsigned long freq) { new_fcw = fcw = freq; } 00063 inline long get_phase(void) { return(phase);} 00065 inline void load(long loop_filter_out) {new_fcw = fcw + loop_filter_out;} 00067 long clock(long loop_filter_out); 00069 long clock(); 00070 }; 00071 } // namespace SPUC 00072 #endif