FIRQ15.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "FIRQ15.h"
  2. #include "Error.h"
  3. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  4. static __ALIGNED(8) q15_t coeffArray[64];
  5. #endif
  6. void FIRQ15::test_fir_q15()
  7. {
  8. arm_fir_q15(&instFir, this->pSrc, this->pDst, this->nbSamples);
  9. }
  10. void FIRQ15::test_lms_q15()
  11. {
  12. arm_lms_q15(&instLms, this->pSrc, (q15_t*)this->pRef, this->pDst, this->pErr,this->nbSamples);
  13. }
  14. void FIRQ15::test_lms_norm_q15()
  15. {
  16. arm_lms_norm_q15(&instLmsNorm, this->pSrc, (q15_t*)this->pRef, this->pDst, this->pErr,this->nbSamples);
  17. }
  18. void FIRQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  19. {
  20. std::vector<Testing::param_t>::iterator it = params.begin();
  21. this->nbTaps = *it++;
  22. this->nbSamples = *it;
  23. samples.reload(FIRQ15::SAMPLES1_Q15_ID,mgr,this->nbSamples);
  24. coefs.reload(FIRQ15::COEFS1_Q15_ID,mgr,this->nbTaps);
  25. state.create(this->nbSamples + this->nbTaps - 1,FIRQ15::STATE_Q15_ID,mgr);
  26. output.create(this->nbSamples,FIRQ15::OUT_SAMPLES_Q15_ID,mgr);
  27. switch(id)
  28. {
  29. case TEST_FIR_Q15_1:
  30. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  31. /* Copy coefficients and pad to zero
  32. */
  33. memset(coeffArray,0,32*sizeof(q15_t));
  34. q15_t *ptr;
  35. ptr=coefs.ptr();
  36. memcpy(coeffArray,ptr,this->nbTaps*sizeof(q15_t));
  37. this->pCoefs = coeffArray;
  38. #else
  39. this->pCoefs=coefs.ptr();
  40. #endif
  41. arm_fir_init_q15(&instFir,this->nbTaps,coefs.ptr(),state.ptr(),this->nbSamples);
  42. this->pSrc=samples.ptr();
  43. this->pDst=output.ptr();
  44. break;
  45. case TEST_LMS_Q15_2:
  46. refs.reload(FIRQ15::REFS1_Q15_ID,mgr,this->nbSamples);
  47. error.create(this->nbSamples,FIRQ15::ERR_Q15_ID,mgr);
  48. arm_lms_init_q15(&instLms,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  49. this->pSrc=samples.ptr();
  50. this->pRef=refs.ptr();
  51. this->pDst=output.ptr();
  52. this->pErr=error.ptr();
  53. break;
  54. case TEST_LMS_NORM_Q15_3:
  55. refs.reload(FIRQ15::REFS1_Q15_ID,mgr,this->nbSamples);
  56. error.create(this->nbSamples,FIRQ15::ERR_Q15_ID,mgr);
  57. arm_lms_norm_init_q15(&instLmsNorm,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  58. this->pSrc=samples.ptr();
  59. this->pRef=refs.ptr();
  60. this->pDst=output.ptr();
  61. this->pErr=error.ptr();
  62. break;
  63. }
  64. }
  65. void FIRQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  66. {
  67. }