FIRQ31.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "FIRQ31.h"
  2. #include "Error.h"
  3. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  4. static __ALIGNED(8) q31_t coeffArray[64];
  5. #endif
  6. void FIRQ31::test_fir_q31()
  7. {
  8. arm_fir_q31(&instFir, pSrc, pDst, this->nbSamples);
  9. }
  10. void FIRQ31::test_lms_q31()
  11. {
  12. arm_lms_q31(&instLms, pSrc, (q31_t*)pRef, pDst, pErr,this->nbSamples);
  13. }
  14. void FIRQ31::test_lms_norm_q31()
  15. {
  16. arm_lms_norm_q31(&instLmsNorm, pSrc, (q31_t*)pRef, pDst, pErr,this->nbSamples);
  17. }
  18. void FIRQ31::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(FIRQ31::SAMPLES1_Q31_ID,mgr,this->nbSamples);
  24. coefs.reload(FIRQ31::COEFS1_Q31_ID,mgr,this->nbTaps);
  25. state.create(2*ROUND_UP(this->nbSamples,4) + this->nbSamples + this->nbTaps - 1,FIRQ31::STATE_Q31_ID,mgr);
  26. output.create(this->nbSamples,FIRQ31::OUT_SAMPLES_Q31_ID,mgr);
  27. switch(id)
  28. {
  29. case TEST_FIR_Q31_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(q31_t));
  34. q31_t *ptr;
  35. ptr=coefs.ptr();
  36. memcpy(coeffArray,ptr,this->nbTaps*sizeof(q31_t));
  37. this->pCoefs = coeffArray;
  38. #else
  39. this->pCoefs=coefs.ptr();
  40. #endif
  41. arm_fir_init_q31(&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_Q31_2:
  46. refs.reload(FIRQ31::REFS1_Q31_ID,mgr,this->nbSamples);
  47. error.create(this->nbSamples,FIRQ31::ERR_Q31_ID,mgr);
  48. // Value of mu and postShift are arbitrary just for benchmark
  49. arm_lms_init_q31(&instLms,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  50. this->pSrc=samples.ptr();
  51. this->pRef=refs.ptr();
  52. this->pDst=output.ptr();
  53. this->pErr=error.ptr();
  54. break;
  55. case TEST_LMS_NORM_Q31_3:
  56. refs.reload(FIRQ31::REFS1_Q31_ID,mgr,this->nbSamples);
  57. error.create(this->nbSamples,FIRQ31::ERR_Q31_ID,mgr);
  58. // Value of mu and postShift are arbitrary just for benchmark
  59. arm_lms_norm_init_q31(&instLmsNorm,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  60. this->pSrc=samples.ptr();
  61. this->pRef=refs.ptr();
  62. this->pDst=output.ptr();
  63. this->pErr=error.ptr();
  64. break;
  65. }
  66. }
  67. void FIRQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  68. {
  69. }