FIRF32.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "FIRF32.h"
  2. #include "Error.h"
  3. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  4. static __ALIGNED(8) float32_t coeffArray[64];
  5. #endif
  6. void FIRF32::test_fir_f32()
  7. {
  8. arm_fir_f32(&instFir, this->pSrc, this->pDst, this->nbSamples);
  9. }
  10. void FIRF32::test_lms_f32()
  11. {
  12. arm_lms_f32(&instLms, this->pSrc, (float32_t*)this->pRef, this->pDst, this->pErr,this->nbSamples);
  13. }
  14. void FIRF32::test_lms_norm_f32()
  15. {
  16. arm_lms_norm_f32(&instLmsNorm, this->pSrc, (float32_t*)this->pRef, this->pDst, this->pErr,this->nbSamples);
  17. }
  18. void FIRF32::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(FIRF32::SAMPLES1_F32_ID,mgr,this->nbSamples);
  24. coefs.reload(FIRF32::COEFS1_F32_ID,mgr,this->nbTaps);
  25. state.create(this->nbSamples + this->nbSamples + this->nbTaps - 1,FIRF32::STATE_F32_ID,mgr);
  26. output.create(this->nbSamples,FIRF32::OUT_SAMPLES_F32_ID,mgr);
  27. switch(id)
  28. {
  29. case TEST_FIR_F32_1:
  30. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  31. /* Copy coefficients and pad to zero
  32. */
  33. memset(coeffArray,0,32*sizeof(float32_t));
  34. float32_t *ptr;
  35. ptr=coefs.ptr();
  36. memcpy(coeffArray,ptr,this->nbTaps*sizeof(float32_t));
  37. this->pCoefs = coeffArray;
  38. #else
  39. this->pCoefs=coefs.ptr();
  40. #endif
  41. this->pSrc=samples.ptr();
  42. this->pDst=output.ptr();
  43. arm_fir_init_f32(&instFir,this->nbTaps,this->pCoefs,state.ptr(),this->nbSamples);
  44. break;
  45. case TEST_LMS_F32_2:
  46. refs.reload(FIRF32::REFS1_F32_ID,mgr,this->nbSamples);
  47. error.create(this->nbSamples,FIRF32::ERR_F32_ID,mgr);
  48. arm_lms_init_f32(&instLms,this->nbTaps,coefs.ptr(),state.ptr(),0.1,this->nbSamples);
  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_F32_3:
  55. refs.reload(FIRF32::REFS1_F32_ID,mgr,this->nbSamples);
  56. error.create(this->nbSamples,FIRF32::ERR_F32_ID,mgr);
  57. arm_lms_norm_init_f32(&instLmsNorm,this->nbTaps,coefs.ptr(),state.ptr(),0.1,this->nbSamples);
  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 FIRF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  66. {
  67. }