From 1d63a52520ebdac7242784eafa79093b7fc2710d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 2 Nov 2010 12:47:46 -0400 Subject: [PATCH 1/1] Adding ability for FIR filter with internal buffer to decimate. Also adds QA code to test decimate by 2 and 5. Removes lib/filter/gri_fir_filter_with_buffer_ccf.h that is autogenerated. --- .../gri_fir_filter_with_buffer_XXX.cc.t | 33 +++++++++++++++++ .../filter/gri_fir_filter_with_buffer_XXX.h.t | 18 ++++++++-- .../filter/gri_fir_filter_with_buffer_ccf.h | 18 ++++++++-- .../qa_gri_fir_filter_with_buffer_ccc.cc | 35 +++++++++++++----- .../qa_gri_fir_filter_with_buffer_ccc.h | 7 ++-- .../qa_gri_fir_filter_with_buffer_ccf.cc | 35 +++++++++++++----- .../qa_gri_fir_filter_with_buffer_ccf.h | 7 ++-- .../qa_gri_fir_filter_with_buffer_fcc.cc | 36 ++++++++++++++----- .../qa_gri_fir_filter_with_buffer_fcc.h | 7 ++-- .../qa_gri_fir_filter_with_buffer_fff.cc | 35 +++++++++++++----- .../qa_gri_fir_filter_with_buffer_fff.h | 7 ++-- .../qa_gri_fir_filter_with_buffer_fsf.cc | 35 +++++++++++++----- .../qa_gri_fir_filter_with_buffer_fsf.h | 9 +++-- .../qa_gri_fir_filter_with_buffer_scc.cc | 35 +++++++++++++----- .../qa_gri_fir_filter_with_buffer_scc.h | 7 ++-- 15 files changed, 257 insertions(+), 67 deletions(-) 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 index c0d061c8..15406884 100644 --- 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 @@ -77,6 +77,26 @@ void 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[], @@ -86,3 +106,16 @@ void 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 index d566b367..23d64b65 100644 --- 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 @@ -69,13 +69,25 @@ public: /*! * \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. + * \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. * @@ -93,7 +105,7 @@ public: * compute the output values. */ void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], - unsigned long n, unsigned decimate); + unsigned long n, unsigned long decimate); /*! * \brief install \p new_taps as the current taps. diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.h b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.h index 2b69f8b0..bd7fa33c 100644 --- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.h +++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.h @@ -69,13 +69,25 @@ public: /*! * \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. + * \p input is a single input value of the filter type * * \returns the filtered input value. */ gr_complex filter (gr_complex 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. + */ + gr_complex filter (const gr_complex input[], unsigned long dec); + /*! * \brief compute an array of N output values. * @@ -93,7 +105,7 @@ public: * compute the output values. */ void filterNdec (gr_complex output[], const gr_complex input[], - unsigned long n, unsigned decimate); + unsigned long n, unsigned long decimate); /*! * \brief install \p new_taps as the current taps. 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 index cff81ab1..e87d93eb 100644 --- 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 @@ -73,14 +73,31 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_ccc::test_decimate(unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -107,11 +124,13 @@ qa_gri_fir_filter_with_buffer_ccc::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -121,7 +140,7 @@ qa_gri_fir_filter_with_buffer_ccc::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results // @@ -130,7 +149,7 @@ qa_gri_fir_filter_with_buffer_ccc::t1 () // arithmetic, while the SSE version is using 32 bit float point // arithmetic. - for (int o = 0; o < ol; o++){ + 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); } 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 index 411a66a9..f9f206f6 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; 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 index f2e09db1..c25853b1 100644 --- 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 @@ -80,14 +80,31 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_ccf::test_decimate (unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -114,11 +131,13 @@ qa_gri_fir_filter_with_buffer_ccf::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -128,7 +147,7 @@ qa_gri_fir_filter_with_buffer_ccf::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results // @@ -137,7 +156,7 @@ qa_gri_fir_filter_with_buffer_ccf::t1 () // arithmetic, while the SSE version is using 32 bit float point // arithmetic. - for (int o = 0; o < ol; o++){ + 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); } 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 index b80be70a..924b4bc2 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; 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 index de0da9f1..19f27020 100644 --- 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 @@ -80,14 +80,32 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_fcc::test_decimate(unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -114,11 +132,13 @@ qa_gri_fir_filter_with_buffer_fcc::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -128,7 +148,7 @@ qa_gri_fir_filter_with_buffer_fcc::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results // @@ -137,7 +157,7 @@ qa_gri_fir_filter_with_buffer_fcc::t1 () // arithmetic, while the SSE version is using 32 bit float point // arithmetic. - for (int o = 0; o < ol; o++){ + 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); } 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 index 81b39f48..6201800f 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; 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 index ce689a54..8401e484 100644 --- 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 @@ -69,14 +69,31 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_fff::test_decimate(unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -103,11 +120,13 @@ qa_gri_fir_filter_with_buffer_fff::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -117,7 +136,7 @@ qa_gri_fir_filter_with_buffer_fff::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results // @@ -126,7 +145,7 @@ qa_gri_fir_filter_with_buffer_fff::t1 () // arithmetic, while the SSE version is using 32 bit float point // arithmetic. - for (int o = 0; o < ol; o++){ + 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); } 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 index 5bb6c3e9..54a9cdc5 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; 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 index f09a1d7a..09150538 100644 --- 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 @@ -67,14 +67,31 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_fsf::test_decimate (unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -101,11 +118,13 @@ qa_gri_fir_filter_with_buffer_fsf::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -115,10 +134,10 @@ qa_gri_fir_filter_with_buffer_fsf::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ CPPUNIT_ASSERT_EQUAL(expected_output[o], actual_output[o]); } delete f1; 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 index 38899b35..9c901464 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; 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 index 4ba433eb..03cd7102 100644 --- 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 @@ -80,14 +80,31 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) 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::t1 () +qa_gri_fir_filter_with_buffer_scc::test_decimate (unsigned int decimate) { const int MAX_TAPS = 9; const int OUTPUT_LEN = 17; @@ -114,11 +131,13 @@ qa_gri_fir_filter_with_buffer_scc::t1 () // compute expected output values memset(dline, 0, INPUT_LEN*sizeof(i_type)); - for (int o = 0; o < ol; o++){ + for (int o = 0; o < (int)(ol/decimate); o++){ // use an actual delay line for this test - for(int oo = INPUT_LEN-1; oo > 0; oo--) - dline[oo] = dline[oo-1]; - dline[0] = input[o]; + 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); } @@ -128,7 +147,7 @@ qa_gri_fir_filter_with_buffer_scc::t1 () // zero the output, then do the filtering memset (actual_output, 0, sizeof (actual_output)); - f1->filterN (actual_output, input, ol); + f1->filterNdec (actual_output, input, ol/decimate, decimate); // check results // @@ -137,7 +156,7 @@ qa_gri_fir_filter_with_buffer_scc::t1 () // arithmetic, while the SSE version is using 32 bit float point // arithmetic. - for (int o = 0; o < ol; o++){ + 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); } 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 index fd9fe5b7..970ca374 100644 --- 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 @@ -29,13 +29,16 @@ 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 (); + void t2 (); + void t3 (); }; -- 2.39.5