FIRQ31.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "FIRQ31.h"
  2. #include "Error.h"
  3. void FIRQ31::test_fir_q31()
  4. {
  5. const q31_t *pSrc=samples.ptr();
  6. const q31_t *pCoefs=coefs.ptr();
  7. q31_t *pDst=output.ptr();
  8. arm_fir_q31(&instFir, pSrc, pDst, this->nbSamples);
  9. }
  10. void FIRQ31::test_lms_q31()
  11. {
  12. const q31_t *pSrc=samples.ptr();
  13. const q31_t *pRef=refs.ptr();
  14. q31_t *pDst=output.ptr();
  15. q31_t *pErr=error.ptr();
  16. arm_lms_q31(&instLms, pSrc, (q31_t*)pRef, pDst, pErr,this->nbSamples);
  17. }
  18. void FIRQ31::test_lms_norm_q31()
  19. {
  20. const q31_t *pSrc=samples.ptr();
  21. const q31_t *pRef=refs.ptr();
  22. q31_t *pDst=output.ptr();
  23. q31_t *pErr=error.ptr();
  24. arm_lms_norm_q31(&instLmsNorm, pSrc, (q31_t*)pRef, pDst, pErr,this->nbSamples);
  25. }
  26. void FIRQ31::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  27. {
  28. std::vector<Testing::param_t>::iterator it = params.begin();
  29. this->nbTaps = *it++;
  30. this->nbSamples = *it;
  31. samples.reload(FIRQ31::SAMPLES1_Q31_ID,mgr,this->nbSamples);
  32. coefs.reload(FIRQ31::COEFS1_Q31_ID,mgr,this->nbTaps);
  33. state.create(this->nbSamples + this->nbTaps - 1,FIRQ31::STATE_Q31_ID,mgr);
  34. output.create(this->nbSamples,FIRQ31::OUT_SAMPLES_Q31_ID,mgr);
  35. switch(id)
  36. {
  37. case TEST_FIR_Q31_1:
  38. arm_fir_init_q31(&instFir,this->nbTaps,coefs.ptr(),state.ptr(),this->nbSamples);
  39. break;
  40. case TEST_LMS_Q31_2:
  41. refs.reload(FIRQ31::REFS1_Q31_ID,mgr,this->nbSamples);
  42. error.create(this->nbSamples,FIRQ31::ERR_Q31_ID,mgr);
  43. // Value of mu and postShift are arbitrary just for benchmark
  44. arm_lms_init_q31(&instLms,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  45. break;
  46. case TEST_LMS_NORM_Q31_3:
  47. refs.reload(FIRQ31::REFS1_Q31_ID,mgr,this->nbSamples);
  48. error.create(this->nbSamples,FIRQ31::ERR_Q31_ID,mgr);
  49. // Value of mu and postShift are arbitrary just for benchmark
  50. arm_lms_norm_init_q31(&instLmsNorm,this->nbTaps,coefs.ptr(),state.ptr(),100,this->nbSamples,1);
  51. break;
  52. }
  53. }
  54. void FIRQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  55. {
  56. }