| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- #include "SupportTestsQ7.h"
- #include <stdio.h>
- #include "Error.h"
- #include "Test.h"
- #define SNR_THRESHOLD 120
- #define REL_ERROR (1.0e-5)
- #define ABS_Q15_ERROR ((q15_t)(1<<8))
- #define ABS_Q31_ERROR ((q31_t)(1<<24))
- #define ABS_Q7_ERROR ((q7_t)10)
- #if defined ( __CC_ARM )
- #pragma diag_suppress 170
- #endif
- void SupportTestsQ7::test_copy_q7()
- {
- const q7_t *inp = inputQ7.ptr();
- q7_t *outp = outputQ7.ptr();
-
-
- arm_copy_q7(inp, outp,this->nbSamples);
-
-
- ASSERT_EQ(inputQ7,outputQ7);
- ASSERT_EMPTY_TAIL(outputQ7);
- }
- void SupportTestsQ7::test_fill_q7()
- {
- q7_t *outp = outputQ7.ptr();
- q7_t val = 0x40;
- int i;
-
- arm_fill_q7(val, outp,this->nbSamples);
-
-
- for(i=0 ; i < this->nbSamples; i++)
- {
- ASSERT_EQ(val,outp[i]);
- }
- ASSERT_EMPTY_TAIL(outputQ7);
- }
- void SupportTestsQ7::test_q7_float()
- {
- const q7_t *inp = inputQ7.ptr();
- float32_t *outp = outputF32.ptr();
-
-
- arm_q7_to_float(inp, outp,this->nbSamples);
-
-
- ASSERT_CLOSE_ERROR(refF32,outputF32,0.01,REL_ERROR);
- ASSERT_EMPTY_TAIL(outputF32);
- }
- void SupportTestsQ7::test_q7_q31()
- {
- const q7_t *inp = inputQ7.ptr();
- q31_t *outp = outputQ31.ptr();
-
-
- arm_q7_to_q31(inp, outp,this->nbSamples);
-
-
- ASSERT_NEAR_EQ(refQ31,outputQ31,ABS_Q31_ERROR);
- ASSERT_EMPTY_TAIL(outputQ31);
- }
- void SupportTestsQ7::test_q7_q15()
- {
- const q7_t *inp = inputQ7.ptr();
- q15_t *outp = outputQ15.ptr();
-
-
- arm_q7_to_q15(inp, outp,this->nbSamples);
-
-
- ASSERT_NEAR_EQ(refQ15,outputQ15,ABS_Q15_ERROR);
- ASSERT_EMPTY_TAIL(outputQ15);
- }
- static const q7_t testReadQ7[4]={-4,-3,-2,1};
- static q7_t testWriteQ7[4]={0,0,0,0};
- void SupportTestsQ7::test_read_q7x4_ia()
- {
- q31_t result=0;
- q7_t *p = (q7_t*)testReadQ7;
- result = read_q7x4_ia(&p);
- ASSERT_TRUE(result == 0x01FEFDFC);
- ASSERT_TRUE(p == testReadQ7 + 4);
- }
- void SupportTestsQ7::test_read_q7x4_da()
- {
- q31_t result=0;
- q7_t *p = (q7_t*)testReadQ7;
- result = read_q7x4_da(&p);
- ASSERT_TRUE(result == 0x01FEFDFC);
- ASSERT_TRUE(p == testReadQ7 - 4);
- }
- void SupportTestsQ7::test_write_q7x4_ia()
- {
- q31_t val = 0x01FEFDFC;
- q7_t *p = (q7_t*)testWriteQ7;
- testWriteQ7[0] = 0;
- testWriteQ7[1] = 0;
- testWriteQ7[2] = 0;
- testWriteQ7[3] = 0;
- write_q7x4_ia(&p,val);
- ASSERT_TRUE(testWriteQ7[0] == -4);
- ASSERT_TRUE(testWriteQ7[1] == -3);
- ASSERT_TRUE(testWriteQ7[2] == -2);
- ASSERT_TRUE(testWriteQ7[3] == 1);
- ASSERT_TRUE(p == testWriteQ7 + 4);
- }
-
- void SupportTestsQ7::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr)
- {
- (void)paramsArgs;
- switch(id)
- {
-
- case TEST_COPY_Q7_1:
- this->nbSamples = 15;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- outputQ7.create(inputQ7.nbSamples(),SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_COPY_Q7_2:
- this->nbSamples = 32;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- outputQ7.create(inputQ7.nbSamples(),SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_COPY_Q7_3:
- this->nbSamples = 47;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- outputQ7.create(inputQ7.nbSamples(),SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_FILL_Q7_4:
- this->nbSamples = 15;
- outputQ7.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_FILL_Q7_5:
- this->nbSamples = 32;
- outputQ7.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_FILL_Q7_6:
- this->nbSamples = 47;
- outputQ7.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_FLOAT_7:
- this->nbSamples = 15;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refF32.reload(SupportTestsQ7::SAMPLES_F32_ID,mgr,this->nbSamples);
- outputF32.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_FLOAT_8:
- this->nbSamples = 32;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refF32.reload(SupportTestsQ7::SAMPLES_F32_ID,mgr,this->nbSamples);
- outputF32.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_FLOAT_9:
- this->nbSamples = 47;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refF32.reload(SupportTestsQ7::SAMPLES_F32_ID,mgr,this->nbSamples);
- outputF32.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q31_10:
- this->nbSamples = 15;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ31.reload(SupportTestsQ7::SAMPLES_Q31_ID,mgr,this->nbSamples);
- outputQ31.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q31_11:
- this->nbSamples = 32;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ31.reload(SupportTestsQ7::SAMPLES_Q31_ID,mgr,this->nbSamples);
- outputQ31.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q31_12:
- this->nbSamples = 47;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ31.reload(SupportTestsQ7::SAMPLES_Q31_ID,mgr,this->nbSamples);
- outputQ31.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q15_13:
- this->nbSamples = 15;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ15.reload(SupportTestsQ7::SAMPLES_Q15_ID,mgr,this->nbSamples);
- outputQ15.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q15_14:
- this->nbSamples = 32;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ15.reload(SupportTestsQ7::SAMPLES_Q15_ID,mgr,this->nbSamples);
- outputQ15.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- case TEST_Q7_Q15_15:
- this->nbSamples = 47;
- inputQ7.reload(SupportTestsQ7::SAMPLES_Q7_ID,mgr,this->nbSamples);
- refQ15.reload(SupportTestsQ7::SAMPLES_Q15_ID,mgr,this->nbSamples);
- outputQ15.create(this->nbSamples,SupportTestsQ7::OUT_ID,mgr);
- break;
- }
-
- }
- void SupportTestsQ7::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
- {
- (void)id;
- switch(id)
- {
-
- case TEST_COPY_Q7_1:
- case TEST_COPY_Q7_2:
- case TEST_COPY_Q7_3:
- case TEST_FILL_Q7_4:
- case TEST_FILL_Q7_5:
- case TEST_FILL_Q7_6:
- outputQ7.dump(mgr);
- break;
- case TEST_Q7_FLOAT_7:
- case TEST_Q7_FLOAT_8:
- case TEST_Q7_FLOAT_9:
- outputF32.dump(mgr);
- break;
- case TEST_Q7_Q31_10:
- case TEST_Q7_Q31_11:
- case TEST_Q7_Q31_12:
- outputQ31.dump(mgr);
- break;
- case TEST_Q7_Q15_13:
- case TEST_Q7_Q15_14:
- case TEST_Q7_Q15_15:
- outputQ15.dump(mgr);
- break;
- }
- }
|