ExampleCategoryQ15.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "ExampleCategoryQ15.h"
  2. #include "Error.h"
  3. #define SNR_THRESHOLD 70
  4. /*
  5. Reference patterns are generated with
  6. a double precision computation.
  7. */
  8. #define ABS_ERROR_Q15 ((q15_t)2)
  9. #define ABS_ERROR_Q63 ((q63_t)(1<<16))
  10. void ExampleCategoryQ15::test_op_q15()
  11. {
  12. const q15_t *inp1=input1.ptr();
  13. const q15_t *inp2=input2.ptr();
  14. q15_t *refp=ref.ptr();
  15. q15_t *outp=output.ptr();
  16. arm_add_q15(inp1,inp2,outp,input1.nbSamples());
  17. ASSERT_EMPTY_TAIL(output);
  18. ASSERT_SNR(output,ref,(q15_t)SNR_THRESHOLD);
  19. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
  20. }
  21. void ExampleCategoryQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  22. {
  23. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  24. switch(id)
  25. {
  26. case ExampleCategoryQ15::TEST_OP_Q15_1:
  27. ref.reload(ExampleCategoryQ15::REF_OUT_Q15_ID,mgr);
  28. break;
  29. }
  30. input1.reload(ExampleCategoryQ15::INPUT1_Q15_ID,mgr,nb);
  31. input2.reload(ExampleCategoryQ15::INPUT2_Q15_ID,mgr,nb);
  32. output.create(ref.nbSamples(),ExampleCategoryQ15::OUT_Q15_ID,mgr);
  33. }
  34. void ExampleCategoryQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  35. {
  36. output.dump(mgr);
  37. }