ExampleCategoryQ15.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "ExampleCategoryQ15.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 70
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define ABS_ERROR_Q15 ((q15_t)2)
  10. #define ABS_ERROR_Q63 ((q63_t)(1<<16))
  11. void ExampleCategoryQ15::test_op_q15()
  12. {
  13. const q15_t *inp1=input1.ptr();
  14. const q15_t *inp2=input2.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. (void)params;
  24. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  25. switch(id)
  26. {
  27. case ExampleCategoryQ15::TEST_OP_Q15_1:
  28. ref.reload(ExampleCategoryQ15::REF_OUT_Q15_ID,mgr);
  29. break;
  30. }
  31. input1.reload(ExampleCategoryQ15::INPUT1_Q15_ID,mgr,nb);
  32. input2.reload(ExampleCategoryQ15::INPUT2_Q15_ID,mgr,nb);
  33. output.create(ref.nbSamples(),ExampleCategoryQ15::OUT_Q15_ID,mgr);
  34. }
  35. void ExampleCategoryQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  36. {
  37. (void)id;
  38. output.dump(mgr);
  39. }