commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8408 - gnuradio/branches/developers/ngoergen/gnuradio


From: ngoergen
Subject: [Commit-gnuradio] r8408 - gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src
Date: Mon, 12 May 2008 17:28:44 -0600 (MDT)

Author: ngoergen
Date: 2008-05-12 17:28:43 -0600 (Mon, 12 May 2008)
New Revision: 8408

Added:
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.i
Removed:
   gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc.i
Modified:
   gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/Makefile.am
   gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell.i
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.cc
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.h
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.cc
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.h
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.cc
   
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.h
   gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/qa_fir.py
Log:
gcell_fir_ccc_spu: qa code for ccc SPU based FIR filter gr block

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/Makefile.am     
2008-05-12 05:47:50 UTC (rev 8407)
+++ gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/Makefile.am     
2008-05-12 23:28:43 UTC (rev 8408)
@@ -46,17 +46,17 @@
 
 libgr_gcell_la_SOURCES = \
        gcell_fft_vcc.cc \
+       gcell_fir_util.cc \
        gcell_fir_ccc_simd.cc \
-       gcell_fir_ccc_spu.cc \
-       gcell_fir_filter_ccc.cc \
-       gcell_fir_util.cc
+       gcell_fir_ccc_spu.cc \  
+       gcell_fir_filter_ccc.cc 
 
 grinclude_HEADERS = \
        gcell_fft_vcc.h \
+       gcell_fir_util.h \
+       gcell_fir_filter_ccc.h \        
        gcell_fir_ccc_simd.h \
-       gcell_fir_ccc_spu.h \
-       gcell_fir_filter_ccc.h \
-       gcell_fir_util.h
+       gcell_fir_ccc_spu.h
 
 libgr_gcell_la_LIBADD = \
        $(GNURADIO_CORE_LA) \
@@ -76,7 +76,7 @@
        $(srcdir)/gc_job_manager.i \
        $(srcdir)/gcell.i \
        $(srcdir)/gcell_fft_vcc.i \
-       $(srcdir)/gcell_fir_ccc.i
+       $(srcdir)/gcell_fir_filter_ccc.i
 
 NON_LOCAL_IFILES = \
        $(GNURADIO_I)

Modified: gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell.i
===================================================================
--- gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell.i 
2008-05-12 05:47:50 UTC (rev 8407)
+++ gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell.i 
2008-05-12 23:28:43 UTC (rev 8408)
@@ -29,9 +29,11 @@
 //#include <stdexcept>
 
 #include <gc_job_manager.h>
-#include <gcell_fft_vcc.h>  
+#include <gcell_fft_vcc.h>
+#include <gcell_fir_filter_ccc.h>
 
 %}
 
 %include "gc_job_manager.i"
 %include "gcell_fft_vcc.i"
+%include "gcell_fir_filter_ccc.i"

Deleted: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc.i

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.cc
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.cc
   2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.cc
   2008-05-12 23:28:43 UTC (rev 8408)
@@ -26,95 +26,106 @@
 #include <gcell_fir_ccc_simd.h>
 
 #include <assert.h>
-#include <malloc16.h>
-#include <iostream>
 #include <stdexcept>
 
-using std::cerr;
-using std::endl;
+//#define GCELL_FIR_CCC_DEBUG2_TRUE
 
-class boost_void_sptr {
-private:
- /*
-  * Return pointer to cache-aligned chunk of storage of size size bytes.
-  * Throw if can't allocate memory.  The storage should be freed
-  * with "free" when done.  The memory is initialized to zero.
-  */
-  static void *
-  aligned_alloc(size_t size, size_t alignment = 128)
-  {
-    void *p(0);
-    if (posix_memalign(&p, alignment, size) != 0){
-      perror("posix_memalign");
-      throw std::runtime_error("memory");
-    }
-    memset(p, 0, size);           // zero the memory
-    return p;
-  }
+#ifdef GCELL_FIR_CCC_DEBUG2_TRUE
+#include <iostream>
+#define GCELL_FIR_CCC_DEBUG2(x) std::cout << x << std::endl;
+#else
+#define GCELL_FIR_CCC_DEBUG2(x)
+#endif
 
-  class free_deleter {
-    public:
-      void operator()(void *p) {
-        free(p);
+class boost_void_sptr
+{
+  private:
+    /*
+     * Return pointer to cache-aligned chunk of storage of size size bytes.
+     * Throw if can't allocate memory.  The storage should be freed
+     * with "free" when done.  The memory is initialized to zero.
+     */
+    static void * aligned_alloc(size_t size, size_t alignment = 128)
+    {
+      void *p(0);
+      if (posix_memalign(&p, alignment, size) != 0) {
+        perror("posix_memalign");
+        throw std::runtime_error("memory");
       }
-  };
+      memset(p, 0, size); // zero the memory
+      return p;
+    }
 
-public:
+    class free_deleter
+    {
+      public:
+        void operator()(void *p)
+        {
+          free(p);
+        }
+    };
 
-  static boost::shared_ptr<void> 
-  aligned_alloc_sptr(size_t size, size_t alignment = 128)
-  {
-     return boost::shared_ptr<void>(aligned_alloc(size, alignment), 
free_deleter());
-  }
-};
+  public:
 
-gcell_fir_ccc_simd::gcell_fir_ccc_simd ()
-  : gr_fir_ccc_generic (),
-    d_ccomplex_dotprod(0),
-    d_aligned_taps_p(0),
-    d_ntaps(0)
+    static boost::shared_ptr<void> aligned_alloc_sptr(size_t size,
+        size_t alignment = 128)
+    {
+      return boost::shared_ptr<void>(aligned_alloc(size, alignment), 
free_deleter());
+    }
+  };
+
+gcell_fir_ccc_simd::gcell_fir_ccc_simd() :
+  gr_fir_ccc_generic(), d_ccomplex_dotprod(0), d_aligned_taps_p(0), d_ntaps(0)
 {
+
   // cerr << "@@@ gcell_fir_ccc_simd\n";
 
 }
 
-gcell_fir_ccc_simd::gcell_fir_ccc_simd (const std::vector<gr_complex> 
&new_taps)
-  : gr_fir_ccc_generic (new_taps),
-    d_ccomplex_dotprod(0),
-    d_aligned_taps_p(0),
-    d_ntaps(0)
+gcell_fir_ccc_simd::gcell_fir_ccc_simd(const std::vector<gr_complex> 
&new_taps) :
+  gr_fir_ccc_generic(new_taps), d_ccomplex_dotprod(0), d_aligned_taps_p(0),
+      d_ntaps(0)
 {
-  set_taps (new_taps);
+GCELL_FIR_CCC_DEBUG2( 
+      "gcell_fir_ccc_simd::gcell_fir_ccc_simd d_ccomplex_dotprod: " << 
+      (void*) d_ccomplex_dotprod  << " : " << d_ccomplex_dotprod)
+      
+    set_taps(new_taps);
+    GCELL_FIR_CCC_DEBUG2("after set_taps(new_taps):")
 }
 
-gcell_fir_ccc_simd::~gcell_fir_ccc_simd ()
+gcell_fir_ccc_simd::~gcell_fir_ccc_simd()
 {
 }
 
-void
-gcell_fir_ccc_simd::set_taps (const std::vector<gr_complex> &inew_taps)
+void gcell_fir_ccc_simd::set_taps(const std::vector<gr_complex> &inew_taps)
 {
-  gr_fir_ccc::set_taps(inew_taps);     // call superclass
+  gr_fir_ccc::set_taps(inew_taps); // call superclass
 
   const std::vector<gr_complex> new_taps(gr_reverse(inew_taps));
   unsigned long len(new_taps.size());
-  d_ntaps = (unsigned long) (len / 4) * 4 + (len % 4);
+  d_ntaps = (unsigned long) ((len / 4) + ((len % 4) > 0)) * 4;
 
-  d_aligned_taps = 
-    boost_void_sptr::aligned_alloc_sptr(d_ntaps * sizeof(std::complex<float>), 
128);
-
+  d_aligned_taps = boost_void_sptr::aligned_alloc_sptr(d_ntaps
+      * sizeof(std::complex<float>), 128);
+  
+  
   d_aligned_taps_p = (std::complex<float> *) d_aligned_taps.get();
 
   for (unsigned j = 0; j < len; ++j) {
     d_aligned_taps_p[j] = new_taps[j];
   }
-  for (unsigned j = 0; j < d_ntaps - len; ++j) {
+  for (unsigned j = len; j < d_ntaps; ++j) {
     d_aligned_taps_p[j] = 0.0;
   }
+
+GCELL_FIR_CCC_DEBUG2(
+    "gcell_fir_ccc_simd::set_taps len: " << len << " d_ntaps: " <<
+    d_ntaps << " (len / 4) " << (len / 4) << " ((len % 4) > 0) " <<
+    ((len % 4) > 0))
 }
 
-gr_complex 
-gcell_fir_ccc_simd::filter (const gr_complex input[])
+gr_complex gcell_fir_ccc_simd::filter(const gr_complex input[])
 {
   if (!ntaps())
     return 0.0;
@@ -124,35 +135,28 @@
 
   gr_complex result;
 
-  d_ccomplex_dotprod(
-       input, 
-       d_aligned_taps_p, 
-       d_ntaps, 
-        1,
-       &result);
+  d_ccomplex_dotprod(input, d_aligned_taps_p, d_ntaps, 1, &result);
 
   // cerr << "result = " << result[0] << " " << result[1] << endl;
 
   return result;
 }
 
-void gcell_fir_ccc_simd::filterN (gr_complex output[], const gr_complex 
input[],
-                        unsigned long n)
+void gcell_fir_ccc_simd::filterN(gr_complex output[], const gr_complex input[],
+    unsigned long n)
 {
-  if ((n < 4) || !(n % 4) || !ntaps())
+  if ((n < 4) || (n % 4) || !ntaps())
     return;
 
-  d_ccomplex_dotprod (
-       input, 
-       d_aligned_taps_p,
-       d_ntaps, 
-       n, 
-       output);
+  d_ccomplex_dotprod(input, d_aligned_taps_p, d_ntaps, n, output);
 
+GCELL_FIR_CCC_DEBUG2(
+    "gcell_fir_ccc_simd::filterN after d_ccomplex_dotprod n: " << n)
+
 }
 
-void gcell_fir_ccc_simd::filterNdec (gr_complex output[], const gr_complex 
input[],
-                           unsigned long n, unsigned decimate)
+void gcell_fir_ccc_simd::filterNdec(gr_complex output[],
+    const gr_complex input[], unsigned long n, unsigned decimate)
 {
-       assert(0);
+  assert(0);
 }

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.h
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.h
    2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_simd.h
    2008-05-12 23:28:43 UTC (rev 8408)
@@ -36,36 +36,34 @@
 class gcell_fir_ccc_simd : public gr_fir_ccc_generic
 {
   protected:
-  typedef void (*ccomplex_dotprod_t)(const std::complex<float>* input,
-                                     const std::complex<float>* taps,
-                                     unsigned int n_taps,
-                                     unsigned int n_samples,
-                                     std::complex<float>* result);
+    typedef void (*ccomplex_dotprod_t)(const std::complex<float>* input,
+        const std::complex<float>* taps, unsigned int n_taps,
+        unsigned int n_samples, std::complex<float>* result);
 
-  ccomplex_dotprod_t    d_ccomplex_dotprod;     // fast dot product primitive
+    ccomplex_dotprod_t d_ccomplex_dotprod; // fast dot product primitive
 
-  // CREATORS
-  gcell_fir_ccc_simd ();
-  gcell_fir_ccc_simd (const std::vector<gr_complex> &taps);
-  ~gcell_fir_ccc_simd ();
+    // CREATORS
+    gcell_fir_ccc_simd();
+    gcell_fir_ccc_simd(const std::vector<gr_complex> &taps);
+    ~gcell_fir_ccc_simd();
 
-  // MANIPULATORS
-  virtual void set_taps (const std::vector<gr_complex> &taps);
-  virtual gr_complex filter (const gr_complex input[]);
+    // MANIPULATORS
+    virtual void set_taps(const std::vector<gr_complex> &taps);
+    virtual gr_complex filter(const gr_complex input[]);
 
-  virtual void filterN (gr_complex output[], const gr_complex input[],
-                        unsigned long n);
+    virtual void filterN(gr_complex output[], const gr_complex input[],
+        unsigned long n);
 
-  virtual void filterNdec (gr_complex output[], const gr_complex input[],
-                           unsigned long n, unsigned decimate);
+    virtual void filterNdec(gr_complex output[], const gr_complex input[],
+        unsigned long n, unsigned decimate);
 
-private:
+  private:
 
-  boost::shared_ptr<void> d_aligned_taps;
+    boost::shared_ptr<void> d_aligned_taps;
 
-  gr_complex* d_aligned_taps_p;
+    gr_complex* d_aligned_taps_p;
 
-  unsigned int d_ntaps;
+    unsigned int d_ntaps;
 
 };
 

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.cc
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.cc
    2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.cc
    2008-05-12 23:28:43 UTC (rev 8408)
@@ -26,35 +26,58 @@
 #include <gcell_fir_ccc_spu.h>
 #include <gcp_fir_ccc.h>
 
+//#define GCELL_FIR_CCC_DEBUG2_TRUE
+
+#ifdef GCELL_FIR_CCC_DEBUG2_TRUE
+#include <iostream>
+#define GCELL_FIR_CCC_DEBUG2(x) std::cout << x << std::endl;
+#else
+#define GCELL_FIR_CCC_DEBUG2(x)
+#endif
+
 /*
  *     --- SPU version ---
  */
 
 extern spe_program_handle_t gcell_all;
 
-void gcell_fir_ccc_spu::ccomplex_dotprod_spu(
-                    const std::complex<float>* input,
-                     const std::complex<float>* taps,
-                     unsigned int n_taps,
-                     unsigned int n_samples,
-                     std::complex<float>* result) {
-  gc_job_desc_sptr jd(gcp_fir_ccc_submit(d_mgr, n_samples, n_taps,
-                            result, input, taps));
+boost::shared_ptr<gc_job_manager> gcell_fir_ccc_spu::d_mgr;
 
-  if (!d_mgr->wait_job(jd.get())){
+void gcell_fir_ccc_spu::ccomplex_dotprod_spu(const std::complex<float>* input,
+    const std::complex<float>* taps, unsigned int n_taps,
+    unsigned int n_samples, std::complex<float>* result)
+{
+
+    GCELL_FIR_CCC_DEBUG2(
+      "gcell_fir_ccc_spu::ccomplex_dotprod_spu: submit job n_samples: " << 
+      n_samples << " ntaps: " << n_taps)
+      
+    gc_job_desc_sptr jd(gcp_fir_ccc_submit(d_mgr, n_samples, n_taps, result,
+      input, taps));
+
+    GCELL_FIR_CCC_DEBUG2  (
+      "gcell_fir_ccc_spu::ccomplex_dotprod_spu: after submit, waiting " <<
+      std::endl)
+
+  if (!d_mgr->wait_job(jd.get())) {
     fprintf(stderr, "ccomplex_dotprod_spu wait_job failed: %s\n", 
gc_job_status_string(jd->status).c_str());
   }
+  GCELL_FIR_CCC_DEBUG2(
+      "gcell_fir_ccc_spu::ccomplex_dotprod_spu: after wait " <<
+      std::endl)
 }
 
- 
-gcell_fir_ccc_spu::gcell_fir_ccc_spu ()
-  : gcell_fir_ccc_simd () 
+gcell_fir_ccc_spu::gcell_fir_ccc_spu() :
+  gcell_fir_ccc_simd()
 {
+  
   d_ccomplex_dotprod = gcell_fir_ccc_spu::ccomplex_dotprod_spu;
+  d_mgr = gc_job_manager::singleton();
+}
 
-  gc_jm_options opts;
-  opts.program_handle = gc_program_handle_from_address(&gcell_all);
-  opts.nspes = 1;
-  d_mgr = gc_make_job_manager(&opts);
+gcell_fir_ccc_spu::gcell_fir_ccc_spu(const std::vector<gr_complex> &taps) :
+  gcell_fir_ccc_simd(taps)
+{
+  d_ccomplex_dotprod = gcell_fir_ccc_spu::ccomplex_dotprod_spu;
+  d_mgr = gc_job_manager::singleton();
 }
-

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.h
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.h 
    2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc_spu.h 
    2008-05-12 23:28:43 UTC (rev 8408)
@@ -20,8 +20,8 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#ifndef INCLUDED_GCELL_FIR_CCC_X86_H
-#define INCLUDED_GCELL_FIR_CCC_X86_H
+#ifndef INCLUDED_GCELL_FIR_CCC_SPU_H
+#define INCLUDED_GCELL_FIR_CCC_SPU_H
 
 #include <gcell_fir_ccc_simd.h>
 #include <gc_job_manager.h>
@@ -31,19 +31,16 @@
  */
 class gcell_fir_ccc_spu : public gcell_fir_ccc_simd
 {
-public:
-  gcell_fir_ccc_spu ();
-  gcell_fir_ccc_spu (const std::vector<gr_complex> &taps);
+  public:
+    gcell_fir_ccc_spu();
+    gcell_fir_ccc_spu(const std::vector<gr_complex> &taps);
 
-private:
-  static gc_job_manager_sptr d_mgr;
+  private:
+    static boost::shared_ptr<gc_job_manager> d_mgr;
 
-  static void ccomplex_dotprod_spu(
-                     const std::complex<float>* input,
-                     const std::complex<float>* taps,
-                     unsigned int n_taps,
-                     unsigned int n_samples,
-                     std::complex<float>* result);
+    static void ccomplex_dotprod_spu(const std::complex<float>* input,
+        const std::complex<float>* taps, unsigned int n_taps,
+        unsigned int n_samples, std::complex<float>* result);
 };
 
 #endif

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.cc
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.cc
 2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.cc
 2008-05-12 23:28:43 UTC (rev 8408)
@@ -34,55 +34,67 @@
 #include <gcell_fir_util.h>
 #include <gr_io_signature.h>
 
-gcell_fir_filter_ccc_sptr gr_make_fir_filter_ccc (int decimation, const 
std::vector<gr_complex> &taps)
+//#define GCELL_FIR_CCC_DEBUG2_TRUE
+
+#ifdef GCELL_FIR_CCC_DEBUG2_TRUE
+#include <iostream>
+#define GCELL_FIR_CCC_DEBUG2(x) std::cout << x << std::endl;
+#else
+#define GCELL_FIR_CCC_DEBUG2(x)
+#endif
+
+gcell_fir_filter_ccc_sptr gcell_make_fir_filter_ccc(int decimation,
+    const std::vector<gr_complex> &taps)
 {
-  return gcell_fir_filter_ccc_sptr (new gcell_fir_filter_ccc (decimation, 
taps));
+  return gcell_fir_filter_ccc_sptr(new gcell_fir_filter_ccc (decimation, 
taps));
 }
 
-
-gcell_fir_filter_ccc::gcell_fir_filter_ccc (int decimation, const 
std::vector<gr_complex> &taps)
-  : gr_sync_decimator ("fir_filter_ccc",
-                      gr_make_io_signature (1, 1, sizeof (gr_complex)),
-                      gr_make_io_signature (1, 1, sizeof (gr_complex)),
-                      decimation),
-    d_updated (false)
+gcell_fir_filter_ccc::gcell_fir_filter_ccc(int decimation,
+    const std::vector<gr_complex> &taps) :
+  gr_sync_decimator("fir_filter_ccc", gr_make_io_signature(1, 1,
+      sizeof(gr_complex)), gr_make_io_signature(1, 1, sizeof(gr_complex)),
+      decimation), d_updated(false)
 {
-  d_fir = gcell_fir_util::create_gcell_fir_ccc (taps);
-  set_history (d_fir.get()->ntaps ());
+    d_fir = gcell_fir_util::create_gcell_fir_ccc(taps);
+  set_history(d_fir.get()->ntaps());
 }
 
-gcell_fir_filter_ccc::~gcell_fir_filter_ccc ()
+gcell_fir_filter_ccc::~gcell_fir_filter_ccc()
 {
 }
 
-void
-gcell_fir_filter_ccc::set_taps (const std::vector<gr_complex> &taps)
+void gcell_fir_filter_ccc::set_taps(const std::vector<gr_complex> &taps)
 {
   d_new_taps = taps;
   d_updated = true;
 }
 
-int
-gcell_fir_filter_ccc::work (int noutput_items,
-                  gr_vector_const_void_star &input_items,
-                  gr_vector_void_star &output_items)
+int gcell_fir_filter_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[0U]);
   gr_complex *out((gr_complex *) output_items[0U]);
 
   int rnoutput_items((noutput_items >> 2) << 2);
 
+  GCELL_FIR_CCC_DEBUG2  (
+      " IN work: noutput: " << noutput_items << " rounded: " <<
+      rnoutput_items)
+
   if (d_updated) {
     d_fir.get()->set_taps (d_new_taps);
     set_history (d_fir.get()->ntaps ());
     d_updated = false;
-    return 0;               // history requirements may have changed.
+    return 0; // history requirements may have changed.
   }
 
-  if (decimation() == 1)
+  if (decimation() == 1) {
+    GCELL_FIR_CCC_DEBUG2(" IN work: filterN")
+
     d_fir.get()->filterN (out, in, rnoutput_items);
+  }
   else
-    d_fir.get()->filterNdec (out, in, rnoutput_items, decimation());
+  d_fir.get()->filterNdec (out, in, rnoutput_items, decimation());
 
   return rnoutput_items;
 }

Modified: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.h
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.h
  2008-05-12 05:47:50 UTC (rev 8407)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.h
  2008-05-12 23:28:43 UTC (rev 8408)
@@ -34,7 +34,8 @@
 class gcell_fir_filter_ccc;
 
 typedef boost::shared_ptr<gcell_fir_filter_ccc> gcell_fir_filter_ccc_sptr;
-gcell_fir_filter_ccc_sptr gr_make_fir_filter_ccc (int decimation, const 
std::vector<gr_complex> &taps);
+gcell_fir_filter_ccc_sptr gcell_make_fir_filter_ccc(int decimation,
+    const std::vector<gr_complex> &taps);
 
 class gr_fir_ccc;
 
@@ -44,26 +45,26 @@
  */
 class gcell_fir_filter_ccc : public gr_sync_decimator
 {
- private:
-  friend gcell_fir_filter_ccc_sptr gr_make_fir_filter_ccc (int decimation, 
const std::vector<gr_complex> &taps);
+  private:
+    friend gcell_fir_filter_ccc_sptr gcell_make_fir_filter_ccc(int decimation,
+        const std::vector<gr_complex> &taps);
 
-  std::auto_ptr<gr_fir_ccc>            d_fir;
-  std::vector<gr_complex>      d_new_taps;
-  bool                 d_updated;
+    std::auto_ptr<gr_fir_ccc> d_fir;
+    std::vector<gr_complex> d_new_taps;
+    bool d_updated;
 
-  /*!
-   * Construct a FIR filter with the given taps
-   */
-  gcell_fir_filter_ccc (int decimation, const std::vector<gr_complex> &taps);
+    /*!
+     * Construct a FIR filter with the given taps
+     */
+    gcell_fir_filter_ccc(int decimation, const std::vector<gr_complex> &taps);
 
- public:
-  ~gcell_fir_filter_ccc ();
+  public:
+    ~gcell_fir_filter_ccc();
 
-  void set_taps (const std::vector<gr_complex> &taps);
+    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);
+    int work(int noutput_items, gr_vector_const_void_star &input_items,
+        gr_vector_void_star &output_items);
 };
 
 #endif

Copied: 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.i
 (from rev 8407, 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_ccc.i)
===================================================================
--- 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.i
                          (rev 0)
+++ 
gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/gcell_fir_filter_ccc.i
  2008-05-12 23:28:43 UTC (rev 8408)
@@ -0,0 +1,59 @@
+/* -*- 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.
+ */
+
+#if 1
+
+// This version works.
+
+GR_SWIG_BLOCK_MAGIC(gcell, fir_filter_ccc)
+
+gcell_fir_filter_ccc_sptr 
+gcell_make_fir_filter_ccc(int decimation, const std::vector<gr_complex> &taps);
+
+class gcell_fir_filter_ccc : public gr_sync_decimator
+{
+ protected:
+  gcell_fir_filter_ccc (int decimation, const std::vector<gr_complex> &taps);
+
+ public:
+  ~gcell_fir_filter_ccc ();
+
+  void set_taps (const std::vector<gr_complex> &taps);
+};
+
+
+#else
+
+// This version gives swig heartburn.  We end up with an object that
+// not quite usable.
+
+GR_SWIG_BLOCK_MAGIC(gcell, fft_vcc);
+
+gcell_fft_vcc_sptr 
+gcell_make_fft_vcc (int fft_size, bool forward, const std::vector<float> 
window, bool shift=false);
+
+class gcell_fft_vcc : public gr_fft_vcc
+{
+ protected:
+  gr_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, 
bool shift);
+};
+
+#endif

Modified: gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/qa_fir.py
===================================================================
--- gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/qa_fir.py       
2008-05-12 05:47:50 UTC (rev 8407)
+++ gnuradio/branches/developers/ngoergen/gnuradio-gr-gcell/src/qa_fir.py       
2008-05-12 23:28:43 UTC (rev 8408)
@@ -24,12 +24,11 @@
 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)
+#primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
+#          53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2)
 
 
+
 class test_fir_filter(gr_unittest.TestCase):
 
     def setUp(self):
@@ -51,60 +50,116 @@
         self.assertFloatTuplesAlmostEqual2 (expected_result, result_data,
                                             abs_eps, rel_eps)
 
-    def test_001(self):
+    def test_matlab_vectors(self):
        tb = gr.top_block()
-       fir_size=32
-        src_data = tuple([complex(primes[2*i], primes[2*i+1]) for i in 
range(fir_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))
-
-       taps = ((1+1j),
-               (1+1j),
-               (1+1j),
-               (1+1j))
-
+       fir_size=32
+        src_data = ((1+2j),
+                        (3+4j),
+                        (-5+6j),
+                        (-7-8j),
+                        (9-10j),
+                        (-11.11-12.22j),
+                        (13.33+14.44j),
+                        (15.55+16.66j),
+                        (2.32+54.23j),
+                        (1.534+-23.24j),
+                        (12.4354+24.65j),
+                        (43.432+25.453j),
+                        (234.645-123.23j),
+                        (-23.23+12.65j),
+                        (1.54+2.32j),
+                        (-54.23+5.43j),
+                        (1+2j),
+                        (3+4j),
+                        (-5+6j),
+                        (-7-8j),
+                        (9-10j),
+                        (-11.11-12.22j),
+                        (13.33+14.44j),
+                        (15.55+16.66j),
+                        (2.32+54.23j),
+                        (1.534+-23.24j),
+                        (12.4354+24.65j),
+                        (43.432+25.453j),
+                        (234.645-123.23),
+                        (-23.23+12.65j),
+                        (1.54+2.32j),
+                        (-54.23+5.43j))
+        
+        expected_result = ((64.1026000000000 -   43.4098000000000j),
+                                (173.2946000000000 -  140.1590000000000j),
+                                (321.8706000000000 +   92.9254000000000j),
+                                (-149.0318000000000 +  451.6702000000000j),
+                                (-715.1218000000001 -   94.1181999999999j),
+                                (-733.6038860000001 +   86.2412780000000j),
+                                (260.6341900000000 -  508.9400820000001j),
+                                (1248.4060259999999 -  887.2833060000000j),
+                                (2381.0539260000000 -  471.1559619999999j),
+                                (582.9481764000001 +  449.6798860000001j),
+                                (-567.5329023600000 -  256.7424618000001j),
+                                (344.3637782000000 - 1737.1796927600003j),
+                                (-5150.7202918000003 - 9007.7184978000005j),
+                                (-1849.4548320000004 - 4283.8076880000008j),
+                                (862.7279460000002 + 1936.8460040000000j),
+                                (1555.5027799999998 + 4570.8760120000006j),
+                                (-1415.7215480000007 + 5625.1545719999995j),
+                                (106.4441000000000 -  857.9656999999999j),
+                                (79.6712000000000 -  569.7604000000001j),
+                                (447.4058000000000 -  331.0633999999999j),
+                                (-715.1218000000001 -   94.1181999999999j),
+                                (-733.6038860000001 +   86.2412780000000j),
+                                (260.6341900000000 -  508.9400820000001j),
+                                (1248.4060259999999 -  887.2833060000000j),
+                                (2381.0539260000000 -  471.1559619999999j),
+                                (582.9481764000001 +  449.6798860000001j),
+                                (-567.5329023600000 -  256.7424618000001j),
+                                (344.3637782000000 - 1737.1796927600003j),
+                                (-5150.7202918000003 - 9007.7184978000005j),
+                                (-1849.4548320000004 - 4283.8076880000008j),
+                                (862.7279460000002 + 1936.8460040000000j),
+                                (1555.5027799999998 + 4570.8760120000006j))
+    
+    
+        taps = ((-4.5434-34.323j), (2.32-23.6564j), (2.43+5.4j), (2.32+12.3j), 
(-12.32+13.2j))
+    
         src = gr.vector_source_c(src_data)
-        fir = gcell.fir_vccc(1, taps)
+        fir = gcell.fir_filter_ccc(1, taps)
         dst = gr.vector_sink_c()
         tb.connect(src, fir, dst)
         tb.run()
         result_data = dst.data()
-        #print 'expected:', expected_result
-        #print 'results: ', result_data
-        #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
+        result_data = result_data[:len(result_data) - 4]
+#       print 'expected:', expected_result
+#       print 'results: ', result_data
+        self.assertComplexTuplesAlmostEqual 
(expected_result[:len(expected_result) - 4], result_data, 2)
         self.assert_fir_ok2(expected_result, result_data)
 
+    def test_gr_fir(self):
+        tb = gr.top_block()
+        fir_size=1024
+        tap_size=17
+        #src_data = tuple([complex(primes[2*i], primes[2*i+1]) for i in 
range(fir_size)])
+        random.seed(23)
+        src_data = tuple([complex(random.uniform(-10, 10), random.uniform(-10, 
10)) for i in range(fir_size)])
+        random_taps = tuple([complex(random.uniform(-10, 10), 
random.uniform(-10, 10)) for i in range(tap_size)])
+    
+        src = gr.vector_source_c(src_data)
+        fir_ref = gr.fir_filter_ccc(1, random_taps)
+        dst_ref = gr.vector_sink_c()
+        
+        fir_cell = gcell.fir_filter_ccc(1, random_taps)
+        dst_cell = gr.vector_sink_c()
+        tb.connect(src, fir_cell, dst_cell)
+        tb.connect(src, fir_ref, dst_ref)
+        tb.run()
+        result_data = dst_cell.data()
+        expected_result = dst_ref.data()
+    
+#       print 'expected:', expected_result
+#       print 'results: ', result_data
+        self.assertComplexTuplesAlmostEqual (expected_result, result_data, 3)
+        self.assert_fir_ok2(expected_result, result_data)
+
 if __name__ == '__main__':
     gr_unittest.main ()
         





reply via email to

[Prev in Thread] Current Thread [Next in Thread]