| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #include "DECIMQ15.h"
- #include <stdio.h>
- #include "Error.h"
- #define SNR_THRESHOLD 70
- /*
- Reference patterns are generated with
- a double precision computation.
- */
- #define ABS_ERROR_Q15 ((q15_t)5)
- #define ABS_ERROR_Q63 ((q63_t)(1<<17))
- #define ONEHALF 0x40000000
- void DECIMQ15::test_fir_decimate_q15()
- {
- int nbTests;
- int nb;
- uint32_t *pConfig = config.ptr();
- const q15_t * pSrc = input.ptr();
- q15_t * pDst = output.ptr();
- q15_t * pCoefs = coefs.ptr();
- nbTests=config.nbSamples() / 4;
- for(nb=0;nb < nbTests; nb++)
- {
- this->q = pConfig[0];
- this->numTaps = pConfig[1];
- this->blocksize = pConfig[2];
- this->refsize = pConfig[3];
- pConfig += 4;
- this->status=arm_fir_decimate_init_q15(&(this->S),
- this->numTaps,
- this->q,
- pCoefs,
- state.ptr(),
- this->blocksize);
- ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
- arm_fir_decimate_q15(
- &(this->S),
- pSrc,
- pDst,
- this->blocksize);
- pSrc += this->blocksize;
- pDst += this->refsize;
- pCoefs += this->numTaps;
- }
- ASSERT_EMPTY_TAIL(output);
- ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
- ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
- }
- void DECIMQ15::test_fir_interpolate_q15()
- {
- int nbTests;
- int nb;
- uint32_t *pConfig = config.ptr();
- const q15_t * pSrc = input.ptr();
- q15_t * pDst = output.ptr();
- q15_t * pCoefs = coefs.ptr();
- nbTests=config.nbSamples() / 4;
- for(nb=0;nb < nbTests; nb++)
- {
- this->q = pConfig[0];
- this->numTaps = pConfig[1];
- this->blocksize = pConfig[2];
- this->refsize = pConfig[3];
- pConfig += 4;
- this->status=arm_fir_interpolate_init_q15(&(this->SI),
- this->q,
- this->numTaps,
- pCoefs,
- state.ptr(),
- this->blocksize);
- ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
- arm_fir_interpolate_q15(
- &(this->SI),
- pSrc,
- pDst,
- this->blocksize);
- pSrc += this->blocksize;
- pDst += this->refsize;
- pCoefs += this->numTaps;
- }
- ASSERT_EMPTY_TAIL(output);
- ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
- ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
- }
-
- void DECIMQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
- {
-
- (void)params;
- config.reload(DECIMQ15::CONFIGSDECIMQ15_ID,mgr);
-
-
- switch(id)
- {
- case DECIMQ15::TEST_FIR_DECIMATE_Q15_1:
- config.reload(DECIMQ15::CONFIGSDECIMQ15_ID,mgr);
- input.reload(DECIMQ15::INPUT1_Q15_ID,mgr);
- coefs.reload(DECIMQ15::COEFS1_Q15_ID,mgr);
- ref.reload(DECIMQ15::REF1_DECIM_Q15_ID,mgr);
- state.create(16 + 768 - 1,DECIMQ15::STATE_Q15_ID,mgr);
- break;
- case DECIMQ15::TEST_FIR_INTERPOLATE_Q15_2:
- config.reload(DECIMQ15::CONFIGSINTERPQ15_ID,mgr);
- input.reload(DECIMQ15::INPUT2_Q15_ID,mgr);
- coefs.reload(DECIMQ15::COEFS2_Q15_ID,mgr);
- ref.reload(DECIMQ15::REF2_INTERP_Q15_ID,mgr);
- state.create(16 + 768 - 1,DECIMQ15::STATE_Q15_ID,mgr);
- break;
- }
-
-
- output.create(ref.nbSamples(),DECIMQ15::OUT_Q15_ID,mgr);
- }
- void DECIMQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
- {
- (void)id;
- output.dump(mgr);
- }
|